Download presentation
Presentation is loading. Please wait.
Published byMaryann Jackson Modified over 8 years ago
1
Computer Graphics Lecture 30 Mathematics of Lighting and Shading - IV Taqdees A. Siddiqi cs602@vu.edu.pk
2
The Phong’s Specular Light Equation
3
Phong's equation for specular lighting is
5
The more the view direction, v, is aligned with the reflection direction, r, the brighter the specular light will be. Note the introduction of the ms term (shininess value), which is a power term that attempts to approximate the distribution of specular light reflection.
6
This can be seen in the next Figure, which shows values of for values of ‘m’ ranging from 1 to 128. As we can see, the specular highlights get narrower for higher values, but they don't get any brighter.
7
Figure: Phong's specular term for various values of the "shininess" term. Note that the values never get above 1.
8
To calculate r we can use the following equation: f l and n are normalized, then the resulting r is normalized and the equation can be simplified as:
9
And just as we did for diffuse lighting, if the dot product is negative, then the term is ignored.
10
Figure: A specular term just shows the highlights.
11
The Lighting Equation
12
Now that we have computed the various light contributions to our final color value, we can add them up to get the final color value.
13
Note that the final color values will have to be made to fit in the [0,1] range for the final rgb values.
14
Our final scene with ambient, diffuse, and specular light contributions (with one white light above and to the left of the viewer) looks like Figure 1.
15
Figure 1: A combination of ambient, diffuse, and specular illumination.
16
Next we will discuss some refinements and alternative ways of calculating the various coefficients of the lighting equation.
17
Light Attenuation
18
Light in the real world loses its intensity as the inverse square of the distance from the light source to the surface being illuminated
19
An empirical model was developed that seems to give satisfactory results. This is the attenuation model that's used in OpenGL and DirectX
20
The attenuation factor is calculated by the following equation:
21
The fatten factor is the attenuation factor. The distance d between the light and the vertex is always positive.
22
where the kc, kl, and kq parameters are the constant, linear, and quadratic attenuation constants, respectively
23
The lighting equation with the attenuation factor looks like this.
24
Figure 2 shows a sample of what attenuation looks like. This image is the same as the one shown in Figure 1, but with light attenuation added.
25
Figure 2: A scene with light attenuation. The white sphere is the light position.
26
Schlick's Simplification for the Specular Exponential Term
27
Real-time graphics programmers are always looking for simplifications. We’ve probably gathered that there's no such thing as the "correct" lighting equation, just a series of hacks to make things look right with as little computational effort as possible
28
Schlick [SCHLICK 1994] suggested a replacement for the exponential term since that's a fairly expensive operation. If we define part of our specular light term as follows:
29
where S is either the Phong or Blinn-Phong flavor of the specular lighting equation, then Schlick's simplification is to replace the preceding part of the specular equation with:
30
which eliminates the need for an exponential term. At first glance, a plot of Schlick's function looks very similar to the exponential equation (Figure 3).
31
Figure 3: Schlick's term for specular looks very much like the more expensive Phong term.
32
Schlick's simplification works. The blue values are Schlick's, and the red are the exponential plot. As the view and light angles get closer (i.e., get closer to zero on the x axis), we can see that the values of the curves are quite close.
33
Figure 4: Schlick's vs. Phong's specular terms.
34
Oren—Nayar Diffuse Reflection
35
One of the problems of the standard Lambertian model is that it considers the surface as a smooth diffuse surface.
36
The classic example of this is a full moon.
37
it's pretty obvious that this doesn't follow the Lambertian distribution—if it did, the edges of the moon would be in near darkness
39
Figure 5: The full moon is an good example of something that doesn't show Lambertian diffuse shading.
40
The effect we're looking at is called backscattering.
41
Backscattering is when a rough surface bounces around a light ray and then reflects the ray in the direction the light originally came from
42
Note that there is a similar but different effect called retroreflection
43
Retroreflection is the effect of reflecting light towards the direction from which it came, no matter the orientation of the surface
44
This is the same effect that we see on bicycle reflectors. However, this is due to the design of the surface features (made up of vshaped or spherical reflectors) rather than a scattering effect.
45
when the light direction is closer to the view direction, we get the effect of forward scattering
46
Forward scattering is just backscattering from a different direction
47
Figures 6 and 7 show the same surfaces demonstrating backscattering and forward scattering.
48
Both the dirt field in Figure 6 and the soybean field in Figure 7 can be considered rough diffuse reflecting surfaces.
49
Figure 6: The same dirt field showing widely differing reflection properties.
50
Figure 7: A soybean field showing differing reflection properties.
51
Notice how the backscattering image shows a near uniform diffuse illumination, whereas the forward scattering image shows a uniform dull diffuse illumination.
52
The Oren—Nayar diffuse shading model looks like this.
53
Where
54
ρ/π is a surface reflectivity property, which we can replace with our surface diffuse color. E0 is a light input energy term, which we can replace with our light diffuse color.
55
And the θi term is just our familiar angle between the vertex normal and the light direction. Making these exchanges gives us
56
which looks a lot more like the equations we've used. There are still some parameters to explain.
57
σ is the surface roughness parameter. It's the standard deviation in radians of the angle of distribution of the microfacets in the surface roughness model. The larger the value, the rougher the surface.
58
θr is the angle between the vertex normal and the view direction.
59
φr - φi is the circular angle (about the vertex normal) between the light vector and the view vector.
60
α is max(θi, θr). β is min (θi, θr).
61
Note that if the roughness value is zero, the model is the same as the Lambertian diffuse model. Oren and Nayar also noted that we can replace the value 0.33 in coefficient A with 0.57 to better account for surface interreflection.
62
RECAP Phong's equation for specular lighting is
63
Figure: Phong's specular term for various values of the "shininess" term. Note that the values never get above 1.
64
To calculate r we can use the following equation: If l and n are normalized, then the resulting r is normalized and the equation can be simplified as:
65
And just as we did for diffuse lighting, if the dot product is negative, then the term is ignored.
66
Figure: A specular term just shows the highlights.
67
Note that the final color values will have to be made to fit in the [0,1] range for the final rgb values.
68
Figure 1: A combination of ambient, diffuse, and specular illumination.
69
Light Attenuation
70
Light in the real world loses its intensity as the inverse square of the distance from the light source to the surface being illuminated
71
The attenuation factor is calculated by the following equation:
72
The fatten factor is the attenuation factor. The distance d between the light and the vertex is always positive.
73
where the kc, kl, and kq parameters are the constant, linear, and quadratic attenuation constants, respectively
74
The lighting equation with the attenuation factor looks like this.
75
Figure 2: A scene with light attenuation. The white sphere is the light position.
76
Schlick [SCHLICK 1994] suggested a replacement for the exponential term since that's a fairly expensive operation. If we define part of our specular light term as follows:
77
where S is either the Phong or Blinn-Phong flavor of the specular lighting equation, then Schlick's simplification is to replace the preceding part of the specular equation with:
78
Figure 3: Schlick's term for specular looks very much like the more expensive Phong term.
79
Figure 4: Schlick's vs. Phong's specular terms.
80
Oren—Nayar Diffuse Reflection
81
One of the problems of the standard Lambertian model is that it considers the surface as a smooth diffuse surface.
83
Backscattering is when a rough surface bounces around a light ray and then reflects the ray in the direction the light originally came from
84
Retroreflection is the effect of reflecting light towards the direction from which it came, no matter the orientation of the surface
85
when the light direction is closer to the view direction, we get the effect of forward scattering
86
Figure 6: The same dirt field showing widely differing reflection properties.
87
Figure 7: A soybean field showing differing reflection properties.
88
Where
89
ρ/π is a surface reflectivity property, which we can replace with our surface diffuse color. E0 is a light input energy term, which we can replace with our light diffuse color.
90
And the θi term is just our familiar angle between the vertex normal and the light direction. Making these exchanges gives us
91
which looks a lot more like the equations we've used. There are still some parameters to explain.
92
σ is the surface roughness parameter. It's the standard deviation in radians of the angle of distribution of the microfacets in the surface roughness model. The larger the value, the rougher the surface.
93
θr is the angle between the vertex normal and the view direction.
94
φr - φi is the circular angle (about the vertex normal) between the light vector and the view vector.
95
α is max(θi, θr). β is min (θi, θr).
96
Computer Graphics Lecture 30
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.