Presentation is loading. Please wait.

Presentation is loading. Please wait.

Specular Reflection Lecture 27 Mon, Nov 10, 2003.

Similar presentations


Presentation on theme: "Specular Reflection Lecture 27 Mon, Nov 10, 2003."— Presentation transcript:

1 Specular Reflection Lecture 27 Mon, Nov 10, 2003

2 Specular Reflection The intensity of specular reflected light varies with direction. The maximum intensity is in the “ideal” direction. Angle of reflection = angle of incidence.

3 Specular Reflection Specular reflection creates the appearance of “shininess.” Surfaces with a high specular reflection appear very shiny. Surfaces with a low specular reflection appear matte.

4 Example LampShader.exe

5 Blinn and Phong Lighting OpenGL uses the Blinn lighting model of specular reflection. However, we will first study the Phong lighting model since it seems more natural.

6 Phong Lighting The intensity of the reflection is a function of the angle between the viewer and the ideal direction r of reflection of light from the light source off the surface.

7 Phong Lighting P s n v Light Source Eye Surface r  Ideal Direction 

8 Phong Lighting To compute r, note that r + s equals twice the projection of s onto n. s n r rs 

9 Phong Lighting The projection of s onto n is (s  n)/(n  n)n = (s  n)n Therefore, r + s = 2(s  n)n and r = –s + 2(s  n)n

10 Computing Specular Reflection According to the Phong lighting model, the specular reflection is proportional to the cosine of the angle between v and r, raised to a power (called “shiny”). This is calculated as (r  v) shiny

11 Computing Specular Reflection Two other factors are Intensity of the incident light.  0  L s  1. Specular property of the surface.  0  m s  1. The formula for specular reflection is r s = L s m s (r  v) shiny

12 Computing Specular Reflection Of course, if s  n < 0 or if r  v < 0, then r s = 0. Why?

13 Blinn Lighting A slightly more efficient method is the Blinn lighting model. Let h be the halfway vector, the unit vector halfway between s and v. Use h  n instead of r  v. r s = L s m s (h  n) shiny

14 Blinn Lighting P s n v Light Source Eye Surface h  Halfway

15 Blinn Lighting How does h  n compare to s  v? If s, n, and v are coplanar, then the angle between h and n is half of the angle between s and v. Why is Blinn lighting more efficient? h is computed as h = (s + v)/|s + v|. This is more efficient to compute than r.

16 Emissive Lighting Emissive lighting is light that emitted by the surface itself. It is used for objects that are meant to glow. It is independent of all light sources and directions. Let m e be the intensity of the emissive light.

17 Computing the Shade of a Surface The total reflection from a point is the sum of the ambient, diffuse, and specular reflections and the emissive light. s a m a + L a m a + L d m d (s  n) + L s m s (h  n) shiny + m e

18 Lighting in OpenGL Since the diffuse and specular reflections depend on light sources, there is a separate contribution for each light source. OpenGL provides up to 8 light sources. Furthermore, there is a separate color component for each type of light. Red, green, blue.

19 The Lighting Model The complete formula for n lights is I = (s ar m ar + s ag m ag + s ab m ab ) +  0…n (L ar m ar + L ag m ag + L ag m ag ) +  0…n (L dr m dr + L dg m dg + L db m db )(s  n) +  0…n (L sr m sr + L sg m sg + L sb m sb )(h  n) shiny + (m er + m eg + m eb ).

20 The Lighting Model For each color, the computed value is “clamped” to the interval [0, 1]. If the value exceeds 1, then it is set to 1.

21 Gouraud Shading vs. Phong Shading Gouraud shading computes the specular reflection only at the vertices and then interpolates. This guarantees that the brightest reflection will be at a vertex (or along an edge).

22 Gouraud Shading vs. Phong Shading Phong shading interpolates (and normalizes) the normal vectors and then uses them to compute the specular reflection at each vertex. Phong shading is much more realistic. much less efficient.

23 Gouraud Shading vs. Phong Shading dim reflection dim reflection dim interpolated reflection Gouraud shading.

24 Gouraud Shading vs. Phong Shading bright reflection Phong shading. interpolated vectors dim reflection dim reflection


Download ppt "Specular Reflection Lecture 27 Mon, Nov 10, 2003."

Similar presentations


Ads by Google