Shading Outline Intrductin Diffuse reflectin Specular reflectin Ambient light Refinements: Incrprating several light surces and distance Adding clr Rendering Faces 1
Shading T add realism Shading mdel Simplificatin f physical mdel Interactin f Light and Surfaces The incident light interact with surfaces : Sme is absrbed Sme is reflected Sme is transmitted int interir 2
The Gal Input: a 3D bject Material and clr f the bject Psitin and structure f the light surce Value f intensity f the light surce Output: The intensity f pints f the given bject Reflected and Scattered Light Diffuse Scattering Matt surfaces Specular reflectin Shiny plastic Highlight Translucent Glass, water Penetrate the surface 3
Clr Surce Three cmpnent intensity (red, green, blue) Luminance f the surce The red cmpnent f surce the red cmpnent f image The green cmpnent f surce the green cmpnent f image The blue cmpnent f surce the blue cmpnent f image Three similar but independent calculatins We fcus n ne scalar value nly Three Imprtant Vectrs T cmpute the intensity at P, we need The unit nrmal vectr n The unit vectr v, frm P t the viewer The unit vectr l, frm P t the light n l P v 4
Diffuse Reflectin A perfect diffuse reflectr scatters the light equally in all directins Same appearance t all viewers Interact with the surface material Surce f the clr Imprtant factrs: Material f the surface The psitin f the light Rugher surface means higher diffusin Lambertian surface Lambert s Law L d : diffuse light frm surce I d : diffuse reflectin at P is diffuse reflectin cefficient K d relates t the material f the surface n P l n P l n P l n P l 5
Diffuse Cefficient K d is usually determined by a trial and errr apprach Examples: Cmpnent Gld Black plastic Silver Red 0.75 0.01 0.5 Green 0.6 0.01 0.5 Blue 0.22 0.01 0.5 K d =0.05 K d =0.25 K d =0.5 K d =0.75 K d =1 Specular Reflectin Diffusin: n highlights, rugh surface Specular: highlights, shiny and smth surfaces View dependent reflectin 6
Midterm results Phng Mdel fr Specular Reflectin r is the reflectin f l abut n : specular light frm surce : shininess cefficient l n r l n r v P P 7
The Shininess Cefficient Summary 8
Ambient Light Physical rules are t simplified N indirect and glbal interactin f light T vercme the prblem: use a back light called ambient light Ambient Light Specificatin Nt situated at any particular pint Spreads in all directins unifrmly L a : the amunt f ambient light in envirnment I a : the amunt f ambient light at each pint : ambient reflectin cefficient K a =0 K a =0.5 K a =1 9
Cmbining all Lights Cntributins: Phng reflectin mdel The final mdel = diffuse + specular + ambient A cmplete example Brass ambient=(0.33,0.22,0.03) Brass diffuse=(0.78, 0.57,0.11) Brass specular=(0.99, 0.91,0.81) Brass_shininess = 27.8; Right Light=(1.0,0.0,0.0) Left Light=(1.0,1.0,1.0) 10
Incrprating a Distance Term d: distance f S frm P Exaggerated result Mre experimental parameters a,b,c are cntrl parameters Tw light surces Right Light=(1.0,0.0,0.0) Left Light=(1.0,1.0,1.0) OpenGL supprts up t 8 light surces 11
Several Light Surces The ttal reflectin at p is : sum f all cntributed intensities frm all surces OpenGL allws us t define several light surces Plygn shading=fill plygns 12
Plygnal mesh Shading fr each face in the mesh fr each pint n the face *Find nrmal at this pint *Use Phng mdel t find the clr These tw steps can require large amunt f cmputatins Painting faces (plygn shading) as an alternative apprach Flat Shading Flat shading Individual faces are visualized Same clr fr any pint f the face Suitable fr a distant viewer and light surces OpenGL: glshademdel(gl_flat) 13
Smth Shading Smth shading Visualize underlying surface Each pint f the face has its wn clr Tw techniques: Guraud and Phng shading OpenGL: glshademdel(gl_smooth) Flat versus Smth shading Efficient Nt suitable fr smth bjects Specular highlights are rendered prly 14
Des the human visin system always wrk prperly? Des the human visin system always wrk prperly? Akiyshi's illusin pages 15
Akiyshi's illusin pages Des the human visin system always wrk prperly? Akiyshi's illusin pages Filling Plygns 16
Plygn Fill Fr each face in the mesh fr (y=ybt; y<=ytp; y++){ find xleft and xright fr (x=xleft; x<= xright; x++){ * find the clr c fr the pixel at (x,y) put c int the pixel at (x,y) } } Flat shading: Mve (*) t the utside f lps Efficient Smetimes, it is nt interesting Screen space Smth Shading (Guraud) Guraud shading: cmputes a different value f c Bilinear interplatins Mre expensive than flat shading 17
Phng Shading Better realism fr highlights Use nrmal f vertices t interplate nrmal f interir pints Linear interplatin f n 1 and n 4 Linear interplatin f n 1 and n 2 Linear interplatin f n l and n r Nrmalize n Drawback: relatively slw n l n r n n 2 n 3 nl n r n n 1 Clarificatin Phng reflextin mdel means: While Phng shading means: n 2 n 3 nl n r n n 1 18
Cmpare 19