Download presentation
Presentation is loading. Please wait.
Published byLiliana Todd Modified over 7 years ago
1
Computer Graphics Lecture 29 Mathematics of Lighting and Shading - III Taqdees A. Siddiqi
2
Mathematics of Lighting and Shading - III Taqdees A. Siddiqi cs602@vu
Mathematics of Lighting and Shading - III Taqdees A. Siddiqi
3
Traditional 3D Hardware-Accelerated Lighting Models
4
We will now take a look at the traditional method of calculating lighting in hardware
A method that we'll find is sufficient for most of our needs
5
The traditional approach in real-time computer graphics has been to calculate lighting at a vertex as a sum of the ambient, diffuse, and specular light.
6
In the simplest form (used by OpenGL and Direct3D), the function is simply the sum of these lighting components (clamped to a maximum color value).
7
we have an ambient term and then a sum of all the light from the light sources
9
where itotal is the intensity of light (as an rgb value) from the sum of the intensity of the global ambient value and the diffuse and specular components of the light from the light sources
10
This is called a local lighting model since the only light on a vertex is from a light source, not from other objects. That is, lights are lights, not objects!
11
we've included the reflection coefficients for each term, k for completeness.
12
The reflection coefficients are in the [0,1] range and are specified as part of the material property
13
This equation does fail to take into account any gross roughness or anything other than perfect isotropic reflection
14
the surface is treated as being perfectly smooth and equally reflective in all directions
15
Thus this equation is really not good at modeling the illumination of objects that have anything other than a smooth surface (like fur or sand)
16
or a surface that doesn't really reflect light uniformly in all directions (like brushed metal, hair, or skin).
17
However, with liberal use of texture maps to add detail, this model has served pretty well and can still be used for a majority of the lighting processing to create a realistic environment in real time
18
Let's take a look at the individual parts of the traditional lighting pipeline.
19
Ambient Light
20
Ambient light is the light that comes from all directions — thus all surfaces are illuminated equally regardless of orientation
21
Figure 1: Ambient light provides illumination, but no surface details.
22
We can see that it's difficult to make out details or depth information with just ambient light.
23
Ambient lighting is our friend
Ambient lighting is our friend. With it we make our scene seem more realistic than it is.
24
A world without ambient light is one filled with sharp edges, of bright objects surrounded by sharp, dark, harsh shadows.
25
A world with too much ambient light looks washed out and dull.
26
Diffuse Light
27
Diffuse light is the light that is absorbed by a surface and is reflected in all directions
28
In the traditional model, this is ideal diffuse reflection
29
This is good for rough surfaces where the reflected intensity is constant across the surface and is independent of viewpoint but depends only upon the direction of the light source to the surface
30
The regardless of the direction from which we view an object with a stationary diffuse light source on it, the brightness of any point on the surface will remain the same
31
Unlike ambient light, the intensity of diffuse light is directional and is a function of the angle of the incoming light and the surface
32
This type of shading is called Lambertian shading after Lambert's cosine law,
33
The law states that the intensity of the light reflected from an ideal diffuse surface is proportional to the cosine of the direction of the light to the vertex normal
34
Since we're dealing with vertices here and not surfaces, each vertex has a normal associated with it
35
Diffuse light decreases as the angle between the light vector and the surface normal increases.
36
Figure 2 shows the intensity of reflected light as a function of the angle between the vertex normal and the light direction.
37
The equation for calculating diffuse lighting is
38
Diffuse light term is now multiplied by the dot product of the unit normal of the vertex and the unit direction vector to the light from the vertex (not the direction from the light)
39
Diffuse light shading brings out some surface details
40
The problem with just diffuse lighting is that it's independent of the viewer's direction
41
Thus as we change the viewing angle to a vertex, the vertex's diffuse light value never changes
42
We have to rotate the object (change the normal direction) or move the light (change the light direction) to get a change in the diffuse lighting of the object
43
However, when we combine the ambient and diffuse, as in Figure 4, we can see that the two types of light give a much more realistic representation than either does alone
44
Ambient and Diffuse light together give a much better shading
45
Figure 4: When diffuse and ambient terms are combined, you get more detail and a more natural-looking scene. The final color is the combination of the ambient and diffuse colors.
46
Specular Light
47
Specular light is the light from a light source that is reflected by a surface and is reflected in such a manner that it's both a function of the light's vector and the viewer's direction.
48
Specular light's intensity follows the reflection vector.
49
Most discussions of lighting (including this one) start with Phong's lighting equation
50
Phong's Specular Light Equation
51
Warnock [WARNOCK 1969] and Romney [ROMNEY 1969] were the first to try to simulate highlights using a cos n (θ ) term.
52
But it wasn't until Phong Bui-Tong [BUI 1998] reformulated this into a more general model that formalized the power value as a measure of surface roughness that we approach the terms used today for specular highlights
53
Phong's equation for specular lighting is
55
Figure 6: The relationship between the normal n, the light vector l, the view direction v, and the reflection vector r.
56
RECAP The traditional approach in real-time computer graphics has been to calculate lighting at a vertex as a sum of the ambient, diffuse, and specular light.
58
This is called a local lighting model since the only light on a vertex is from a light source, not from other objects. That is, lights are lights, not objects!
59
The reflection coefficients are in the [0,1] range and are specified as part of the material property
60
Let's take a look at the individual parts of the traditional lighting pipeline.
61
Ambient Light
62
Figure 1: Ambient light provides illumination, but no surface details.
63
Diffuse Light
64
Diffuse light decreases as the angle between the light vector and the surface normal increases.
65
The equation for calculating diffuse lighting is
66
Diffuse light shading brings out some surface details
67
Ambient and Diffuse light together give a much better shading
68
Specular Light
69
Specular light's intensity follows the reflection vector.
70
Phong's equation for specular lighting is
72
Computer Graphics Lecture 29
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.