Review 2: Illumination, Shading, Texturing and Anti-aliasing

Slides:



Advertisements
Similar presentations
CSE 781 Anti-aliasing for Texture Mapping. Quality considerations So far we just mapped one point – results in bad aliasing (resampling problems) We really.
Advertisements

1 Graphics CSCI 343, Fall 2013 Lecture 18 Lighting and Shading.
Texture Mapping I Real-time Rendering Texture Mapping I CSE 781 Prof. Roger Crawfis.
03/16/2009Dinesh Manocha, COMP770 Texturing Surface’s texture: its look & feel Graphics: a process that takes a surface and modifies its appearance using.
Texture Mapping Jian Huang, CS594, Fall 03 This set of slides references the ones used at Ohio State for instruction.
Anti-Aliasing Jian Huang, CS594, Fall 2008 This set of slides references our text book and the slides used at Ohio State by Prof. Roger Crawfis.
Computer Graphics Inf4/MSc Computer Graphics Lecture 13 Illumination I – Local Models.
CSPC 352: Computer Graphics
Virtual Realism LIGHTING AND SHADING. Lighting & Shading Approximate physical reality Ray tracing: Follow light rays through a scene Accurate, but expensive.
1 Computer Graphics By : Mohammed abu Lamdy ITGD3107 University of Palestine Supervision: Assistant Professor Dr. Sana’a Wafa Al-Sayegh.
Illumination and Shading
Based on slides created by Edward Angel
Illumination Model & Surface-rendering Method 박 경 와.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Shading I.
University of New Mexico
Computer Graphics - Class 10
IMGD 1001: Illumination by Mark Claypool
Computer Graphics (Fall 2005) COMS 4160, Lecture 16: Illumination and Shading 1
(conventional Cartesian reference system)
7M836 Animation & Rendering
Objectives Learn to shade objects so their images appear three- dimensional Learn to shade objects so their images appear three- dimensional Introduce.
CS 376 Introduction to Computer Graphics 03 / 30 / 2007 Instructor: Michael Eckmann.
Coordinate Systems X Y Z (conventional Cartesian reference system) X Y Z.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Shading Week 5, Wed 1 Oct 2003 recap: lighting shading.
Illumination and Shading
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Shading I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
CS 480/680 Computer Graphics Shading I Dr. Frederick C Harris, Jr.
Computer Graphics Inf4/MSc Computer Graphics Lecture 11 Texture Mapping.
CS 445 / 645: Introductory Computer Graphics
1 Texturing. 2 What is Texturing? 3 Texture Mapping Definition: mapping a function onto a surface; function can be:  1, 2, or 3D  sampled (image) or.
CS 445 / 645 Introduction to Computer Graphics Lecture 18 Shading Shading.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Shading (introduction to rendering). Rendering  We know how to specify the geometry but how is the color calculated.
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) CS 426 Intro to 3D Computer Graphics © 2003, 2004, 2005 Jason Leigh Electronic.
COMPUTER GRAPHICS CS 482 – FALL 2014 AUGUST 27, 2014 FIXED-FUNCTION 3D GRAPHICS MESH SPECIFICATION LIGHTING SPECIFICATION REFLECTION SHADING HIERARCHICAL.
CS 638, Fall 2001 Admin Grad student TAs may have had their accounts disabled –Please check and the lab if there is a problem If you plan on graduating.
1 Texture Mapping ©Anthony Steed Overview n Texture mapping Inverse and Forward Mapping Bilinear interpolation Perspective correction n Mipmapping.
COLLEGE OF ENGINEERING UNIVERSITY OF PORTO COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 1 Shading (Shading) & Smooth Shading Graphics.
Shading & Texture. Shading Flat Shading The process of assigning colors to pixels. Smooth Shading Gouraud ShadingPhong Shading Shading.
CSC418 Computer Graphics n Illumination n Lights n Lightinging models.
Rendering Overview CSE 3541 Matt Boggus. Rendering Algorithmically generating a 2D image from 3D models Raster graphics.
David Luebke 1 10/26/2015 Lighting CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
CS 325 Introduction to Computer Graphics 03 / 26 / 2010 Instructor: Michael Eckmann.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Basic Rendering Pipeline and Shading Spring 2012.
Game Programming 06 The Rendering Engine
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Illumination and Shading
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
CS 325 Introduction to Computer Graphics 03 / 29 / 2010 Instructor: Michael Eckmann.
UV Mapping After a 3D object has been modeled it must be prepared for texturing. 3D surfaces can be “unwrapped” into a 2D representation with. This process.
11/5/2002 (c) University of Wisconsin, CS 559 Last Time Local Shading –Diffuse term –Specular term –All together –OpenGL brief overview.
Local Illumination and Shading
CS559: Computer Graphics Final Review Li Zhang Spring 2010.
Where We Stand So far we know how to: –Transform between spaces –Rasterize –Decide what’s in front Next –Deciding its intensity and color.
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
Illumination and Shading Sang Il Park Sejong University.
OpenGL Shading. 2 Objectives Learn to shade objects so their images appear three-dimensional Introduce the types of light-material interactions Build.
Lighting and Reflection Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
David Luebke3/16/2016 CS 551 / 645: Introductory Computer Graphics David Luebke
Illumination Models. Introduction 1 Illumination model: Given a point on a surface, what is the perceived color and intensity? Known as Lighting Model,
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
Computer Graphics Ken-Yi Lee National Taiwan University (the slides are adapted from Bing-Yi Chen and Yung-Yu Chuang)
Computer Graphics: Illumination
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
Antialiasing. What is alias? Alias - A false signal in telecommunication links from beats between signal frequency and sampling frequency (from dictionary.com)
Anti-aliasing for Texture Mapping
Computer Graphics (Fall 2003)
Chapter 14 Shading Models.
Adding Surface Detail 고려대학교 컴퓨터 그래픽스 연구실.
Adding Surface Detail 고려대학교 컴퓨터 그래픽스 연구실.
Presentation transcript:

Review 2: Illumination, Shading, Texturing and Anti-aliasing Jian Huang, CS594, Spring 2002

Illumination Vs. Shading Illumination (lighting) model: determine the color of a surface point by simulating some light attributes. Shading model: applies the illumination models at a set of points and colors the whole image.

Local illumination Only consider the light, the observer position, and the object material properties

Basic Illumination Model Simple and fast method for calculating surface intensity at a given point Lighting calculating are based on: The background lighting conditions The light source specification: color, position Optical properties of surfaces: Glossy OR matte Opaque OR transparent (control refection and absorption)

Ambient light (background light) The light that is the result from the light reflecting off other surfaces in the environment A general level of brightness for a scene that is independent of the light positions or surface directions -> ambient light Has no direction Each light source has an ambient light contribution, Ia For a given surface, we can specify how much ambient light the surface can reflect using an ambient reflection coefficient : Ka (0 < Ka < 1)

Ambient Light So the amount of light that the surface reflect is therefore Iamb = Ka * Ia

Diffuse Light The illumination that a surface receives from a light source and reflects equally in all directions This type of reflection is called Lambertian Reflection (thus, Lambertian surfaces) The brightness of the surface is indepenent of the observer position (since the light is reflected in all direction equally)

Lambert’s Law How much light the surface receives from a light source depends on the angle between its angle and the vector from the surface point to the light (light vector) Lambert’s law: the radiant energy ’Id’ from a small surface da for a given light source is: Id = IL * cos(q) IL : the intensity of the light source is the angle between the surface normal (N) and light vector (L)

The Diffuse Component The total diffuse reflection = ambient + diffuse Surface’s material property: assuming that the surface can reflect Kd (0<Kd<1), diffuse reflection coefficient) amount of diffuse light: Idiff = Kd * IL * cos(q) If N and L are normalized, cos(q) = N*L Idiff = Kd * IL * (N*L) The total diffuse reflection = ambient + diffuse Idiff = Ka * Ia + Kd * IL * (N*L)

Examples Sphere diffusely lighted from various angles !

Specular Light These are the bright spots on objects (such as polished metal, apple ...) Light reflected from the surface unequally to all directions. The result of near total reflection of the incident light in a concentrated region around the specular reflection angle

Phong’s Model for Specular How much reflection light you can see depends on where you are

Phong Illumination Curves Specular exponents are much larger than 1; Values of 100 are not uncommon. : glossiness, rate of falloff

Specular Highlights Shiny surfaces change appearance when viewpoint is changed Specularities are caused by microscopically smooth surfaces. A mirror is a perfect specular reflector

Phong Illumination Moving Light Change n

Putting It All Together Single Light (white light source)

Flat Shading

Smooth Shading Need to have per-vertex normals Gouraud Shading Interpolate color across triangles Fast, supported by most of the graphics accelerator cards Phong Shading Interpolate normals across triangles More accurate, but slow. Not widely supported by hardware

Gouraud Shading Normals are computed at the polygon vertices If we only have per-face normals, the normal at each vertex is the average of the normals of its adjacent faces Intensity interpolation: linearly interpolate the pixel intensity (color) across a polygon surface

Gouraud Shading

Phong Shading Model Gouraud shading does not properly handle specular highlights, specially when the n parameter is large (small highlight). Reason: colors are interpolated. Solution: (Phong Shading Model) 1. Compute averaged normal at vertices. 2. Interpolate normals along edges and scan-lines. (component by component) 3. Compute per-pixel illumination.

Phong Shading

What Dreams May Come

How to efficiently add graphics detail? Solution - (its really a cheat!!) How? MAP surface detail from a predefined (easy to model) table (“texture”) to a simple polygon

Texture Mapping Problem #1 Fitting a square peg in a round hole We deal with non-linear transformations Which parts map where?

Texture Mapping Problem #2 Mapping from a pixel to a “texel” Aliasing is a huge problem!

What is a Texture? Given the (texture/image index) (u,v), want: F(u,v) ==> a continuous reconstruction = { R(u,v), G(u,v), B(u,v) } = { I(u,v) } = { index(u,v) } = { alpha(u,v) } = { normals(u,v) } = { surface_height(u,v) } = ...

RGB Textures Places an image on the object “Typical” texture mapping

Opacity Textures A binary mask, really redefines the geometry.

Bump Mapping This modifies the surface normals. More on this later.

Displacement Mapping Modifies the surface position in the direction of the surface normal.

Texture and Texel Each pixel in a texture map is called a Texel Each Texel is associated with a (u,v) 2D texture coordinate The range of u, v is [0.0,1.0]

(u,v) tuple For any (u,v) in the range of (0-1, 0-1), we can find the corresponding value in the texture using some interpolation

Two-Stage Mapping Model the mapping: (x,y,z) -> (u,v) Do the mapping

Image space scan For each y For each x compute u(x,y) and v(x,y) copy texture(u,v) to image(x,y) Samples the warped texture at the appropriate image pixels. inverse mapping

Image space scan Problems: Finding the inverse mapping Use one of the analytical mappings Bi-linear or triangle inverse mapping May miss parts of the texture map Texture Image

Inverse Mapping Need to transform back to world space to do the interpolation Orientation in 3D image space Foreshortening (.8,1) (.5,1) (.5,.7) (.1,.6) (.6,.2)

Texture space scan For each v For each u compute x(u,v) and y(u,v) copy texture(u,v) to image(x,y) Places each texture sample to the mapped image pixel. Forward mapping

Texture space scan Problems: May not fill image Forward mapping needed

Texture Mapping Mapping to a 3D Plane Simple Affine transformation rotate scale translate y z v x u

Texture Mapping Mapping to a Cylinder u -> q v -> z Rotate, translate and scale in the uv-plane u -> q v -> z x = r cos(q), y = r sin(q) v u

Texture Mapping Mapping to Sphere Impossible!!!! Severe distortion at the poles u -> q v -> f x = r sin(q) cos(f) y = r sin(q) sin(f) z = r cos(q)

Sampling What we have in computer graphics is a point sampling of our scene, or: I(x) = f(x)•ST(x) What we would like is more of an integration across the pixel (or larger area): I(x) = f(x) h(x) What should h(x) be?

Sampling Theorem The Shannon Sampling Theorem A band-limited signal f(x), with a cutoff frequency of l, that is sampled with a sampling spacing of T may be perfectly reconstructed from the discrete values f[nT] by convolution with the sinc(x) function, provided: l is called the Nyquist limit.

Sampling and Anti-aliasing If don’t have Nyquist rate, then aliasing artifacts.

Two possible solutions So far we just mapped one point, results in bad aliasing (resampling problems) Two possible solutions: Super-sampling: not very good (slow!) Low-pass filtering: popular approaches – mipmaps, SAT

Quality considerations Pixel area maps to “weird” (warped) shape in texture space v ys pixel xs u

Quality considerations We need to: Calculate (or approximate) the integral of the texture function under this area Approximate: Convolve with a wide filter around the center of this area Calculate the integral for a similar (but simpler) area.

Quality considerations the area is typically approxiated by a rectangular region (found to be good enough for most applications) filter is typically a box/averaging filter - other possibilities how can we pre-compute this?

Summed Area Table (SAT) Determining the rectangle: Find bounding box and calculate its aspect ratio pixel u v xs ys

Summed Area Table (SAT) Determine the rectangle with the same aspect ratio as the bounding box and the same area as the pixel mapping. pixel u v xs ys

Summed Area Table (SAT) Center this rectangle around the bounding box center. Formula: Area = aspect_ratio*x*x Solve for x – the width of the rectangle Other derivations are also possible using the aspects of the diagonals, …

Summed Area Table (SAT) Calculating the color We want the average of the texel colors within this rectangle (u4,v4) u v (u3,v3) + - - + (u2,v2) (u1,v1) + - + -

Summed Area Table (SAT) To get the average, we need to divide by the number of texels falling in the rectangle. Color = SAT(u3,v3)-SAT(u4,v4)-SAT(u2,v2)+SAT(u1,v1) Color = Color / ( (u3-u1)*(v3-v1) ) This implies that the values for each texel may be very large: For 8-bit colors, we could have a maximum SAT value of 255*nx*ny 32-bit pixels would handle a 4kx4k texture with 8-bit values. RGB images imply 12-bytes per pixel.