llumination Model Wireframe rendering simple, ambiguous Color filling flat without any 3D information Requires modeling interaction of light with the object/surface to have a different color (shade in 3D
llumination Model Light on a surface is Absorbed Reflected Transmitted The amount reflected determines the color and brightness of the object light material (surface interaction
llumination Model The reflected light is scattered depending upon the surface properties and incident light Ambient light comes from all directions, is scattered in all directions Diffuse light comes from one direction and is scattered in all directions Specular light comes from one direction and is scattered in preferred direction
llumination Model Diffuse Reflection Lambert s Law L θ N d d. cos = kdl cos = k ( L N diffuse d l L: Light vector N: Normal θ: Angle between L and n k d diffuse reflection coefficient
llumination Model Diffuse Reflection
llumination Model Diffuse Reflection
llumination Model Diffuse Reflection Amount of light reflected depends on the direction to the light source and not on the direction to the viewer Viewer independent Distance from light source q can also be incorporated d = kdl ( L N kd = a + bq + cq ( L N 2 l
llumination Model Specular Reflection Highlights / Shininess Viewing Direction
llumination Model Specular Reflection N L θ θ α R V L: Light vector N: Normal θ: Angle between L and N α: Angle between R and V s s n = ksl cos. k n s specular reflection coefficient = ksl ( R V n specular reflection exponent
llumination Model Specular Reflection n=1 5 10 large n: metals small n: paper
llumination Model Specular Reflection Example
llumination Model Ambient Reflection Light from distributed light sources (and surroundings Also approximates effects of diffusely reflected light from outer bodies / objects. = k ambient a a k a ambient reflection coefficient a ambient incident light
llumination Model Phong llumination Model = + + = + + = + + = + + = m i n i i s i i d a a n l s l d a a n l s l d a a total V R k N L k k V R k N L k k. k k k reflection specular diffeuse reflection reflection ambient 1 ( ( ( ( cos cos
llumination Model Phong llumination Model Local computation for obtaining color (intensity at a point of the surface Basic inputs are light(s, material properties
llumination Model Reflection Vector N L θ i N θ r R L R 2 (L N N -L R = 2( L N N L
llumination Model Half Way Vector L N H V R nstead of L + V H = L + V R V can use N H
llumination Model Normal Vector Plane ax + by + cz + d = 0 p n n ( p p 0 = n = [ a b c] Normalize 0 p 0
llumination Model Normal Vector Plane v 3 n = ( v3 v1 ( v2 v1 Normalize v 1 v 2
llumination Model Normal Vector Sphere mplicit Equation = = + + = z f y f x f n z y x z y x f,, 0 1,, ( 2 2 2
llumination Model Normal Vector Parametric Surface, (, (, (, (, (,,,, v u b v v u b u v u b v v u b u v u n n m n m n m n m = u v n
llumination Model Light Sources Point light source Given by a point Light emitted in all directions Direction light source Given by a vector Spotlight light Given by a cone
llumination Model Phong llumination Model = + + = + + = + + = + + = m i n i i s i i d a a n l s l d a a n l s l d a a total V R k N L k k V R k N L k k. k k k reflection specular diffeuse reflection reflection ambient 1 ( ( ( ( cos cos
Polygon Shading Shading Process of applying illumination model to surface points Approaches Polygon (approximates the 3D shape/surface Flat Shading Gouraud Shading Phong Shading
Polygon Shading Flat Shading One intensity for the whole polygon constant shading For each face/polygon n p P y Select a point P on the face y Find normal to the face n p y Find intensity at P y Fill the polygon with Not smooth
Polygon Shading Flat Shading Example
Polygon Shading Flat Shading Computationally fast Not smooth Mach Band effect
Polygon Shading Gouraud Shading Smooth shading Compute intensity at vertices of a polygon ÖNeeds vertex normal Fill the interior with shade (intensity using interpolation
Polygon Shading Gouraud Shading Vertex Normal N 2 N v N 4 Normal at the vertex is average of normals of the faces incident at the vertex N 1 N 3 N v = P i = 1 n n i i
Polygon Shading Gouraud Shading Vertex Normal
Polygon Shading Gouraud Shading nterpolation (x 1, y 1 1 Scan line a s b 4 (x 2, y 2 (x 4, y 4 Scan conversion! 2 (x 3, y 3 3
Gouraud Shading nterpolation a b 2 3 4 s Scan line Polygon Shading 1 (x 1, y 1 (x 2, y 2 (x 3, y 3 (x 4, y 4 ] ( ( [ 1 ] ( ( [ 1 ] ( ( [ 1 1 4 4 1 4 1 1 2 2 1 2 1 a s b s b a a b s s s b s s a x x x x x x y y y y y y y y y y y y + = + = + = (x a, y s (x b, y s (x s, y s
Polygon Shading Gouraud Shading Example
Polygon Shading Gouraud Shading Handling Specular Reflections- Highlights Not Right
Polygon Shading Phong Shading nterpolate normals and then compute intensity Not to confuse with Phong llumination Model
Polygon Shading Phong Shading (x 1, y 1 N 1 llumination using N s Scan line N a N s N b N 4 N s s (x 2, y 2 (x 4, y 4 N 2 (x 3, y 3 N 3
Polygon Shading Phong Shading More accurate specular component Reduced Mach band effect Better shape approximation N 1 N 2 Original surface Computationally more intensive
Polygon Shading Phong Shading Example
Polygon Shading Phong Shading Example
Polygon Shading Problems Polygon Silhouette nterpolated shading
Polygon Shading Problems nterpolated shading nterpolation naccuracy (screen space vs world space Linear nterpolation Perspective nterpolation
Polygon Shading Problems Animation nterpolated shading V 1 Rotate V P 4 V 1 V 2 P V 2 V 3 V 3 V 4
Polygon Shading Problems nterpolated shading Vertex Normal Vertex Normals Face Normals
Polygon Shading Graphics Pipeline Order llumination computation is done early after modeling transformation Shading is done towards the end with rasterization (scan conversion
Polygon Shading Transparency Simple Model Non refractive = k + ( 1 k reflected transmitted k is the opacity factor (coefficient
Polygon Shading mplementation OpenGL Enable light sources JO(QDEOH*/B/,*+7 Light properties {r g b a} Glfloat light_diffuse[] = {1.0, 1.0, 1.0, 1.0} JO/LJKWY*/B/,*+7*/B',86(OLJKWBGLXVH Light position {x y z w} Glfloat light_position[] = {-1.0, 1.0, -1.0, 1.0} JO/LJKWY*/B/,*+7*/B326,7,21OLJKWBSRVLWLRQ
Polygon Shading mplementation OpenGL Material properties {r g b a} Glfloat mat_d[] = {0.1, 0.2, 0.8, 1.0} JO0DWHULDOY*/B5217*/B',86(PDWBG Normal vector JO1RUPDOQ[Q\Q] JO9HUWH[Q[Q\Q]