Shading Ô Specular Reflection

Shading Ô Specular Reflection

Computer Graphics 1, Lecture 5 April 25, 2005 The Phong Reflection Model Ambient reflection + Diffuse reflection + Shading Specular reflection Computer Graphics 1, Spring 2005 n v Lecture 5 r l θ φ Chapter 6 Ingela Nyström Ambient reflection Ambient reflection Ia = k a La Diffuse reflection Diffuse reflection n l θ θ • Id = kd Ld cos( ) = kd Ld (n l) Lambert’s law Ingela Nyström 1 Computer Graphics 1, Lecture 5 April 25, 2005 Specular reflection Specular reflection n v r φ l α φ • α Is = ks Ls cos ( ) = ks Ls (v r) Shininess = 20 The Phong Reflection Model Phong reflection For each color (r,g,b) calculate the reflected intensity : Ambient Distance term Diffuse Specular 1 • • α )) = Σ ( k L + 2 ( k L (n l) + k L (v r) I a a a+ bd + cd d d s s All lightsources Shininess Distance to lightsource Material properties: n v α r ka, kd, ks , l θ φ Lightsource properties: La, L d, L s, a, b, c Calculation of reflection vector r n l r ambient + diffuse + specular s s (l • n) n r = l + 2 s = l + 2 ( ( l • n) n - l ) = 2 ( l • n) n - l Ingela Nyström 2 Computer Graphics 1, Lecture 5 April 25, 2005 Use of halfway vector h When to use which parts of the model? v n v n h n r r r l l ψ l φ v I = Ia + I d + I s I = Ia Lightsource and observer are on the same side if sign ( l•n) = sign ( v•n) h = ( l+v) / | l+v| (v•r)α is replaced with ( n•h)α’ 2ψ = φ (or equally : (l•n)( v•n) > 0 ) Flat shading Flat shading • One colour for the whole polygon • Normal vector is easily calculated from a cross product • Fast, but with rather poor result • Mach bands are very prominent n c a b n = (b-a) × (c-a) / |(b-a) × (c-a)| Interpolated/Gouraud shading Interpolated/Gouraud shading • Calculate one colour at each vertex point • Linearly interpolate the colour over the surface • Normal vector needed at each vertex point • Medium speed, medium result • Commonly used nc nc c na nb a b Ingela Nyström 3 Computer Graphics 1, Lecture 5 April 25, 2005 Phong shading Polygonal Shading • Interpolate the normal vector over the surface • Calculate the colour at each pixel • Normal vector needed at each vertex point • Best result • Slow in its original form nc c na nb b a Flat Gouraud Phong Gouraud vs Phong Gouraud vs Phong • Gouraud interpolates colour • Phong interpolates normal vectors A highlight in the middle of a polygon is lost with Gouraud shading. This is most visible on large polygons with a close lightsource. Gouraud Phong Normal vectors of vertices Approximative Phong shading Average of neighbouring polygons n2 n+ n+ n+ n n = 1 2 3 4 n + + + n 1 n1 n 2 n 3 n 4 n3 Make use of a 2D lookup table, n 4 In real-time, this takes computing power. a texture map Often we transform pre-calculated normal It is not a perfect approximation as vectors (which may be true normals). we do not care about changing the l-vector, but it still looks good Ingela Nyström 4 Computer Graphics 1, Lecture 5 April 25, 2005 Shadows Shadows 2p to now a local model has been used Other objects are not involved Hence, no shadows are obtained But shadows can help the visual system to detect the third dimension Shadows Shadows from projections To calculate real shadows, we make a projection for each lightsource The lightsource itself is at the centre of projection (COP) Hidden surface removal techniques tell us which surfaces get illuminated We render the scene once for each lightsource Special tricks Special tricks A simple way to get a dark fuzzy blob If the lightsources do not move: under an object, is to add a “darksource“ pre-calculate “shadow polygons“ inside the object , i.e., a lightsource with If the objects do not move: negative light use “light maps“ (see texture lecture) Ingela Nyström 5.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    5 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us