Computer Graphics Lecture 29 Mathematics of Lighting and Shading - III Taqdees A. Siddiqi cs602@vu.edu.pk
Mathematics of Lighting and Shading - III Taqdees A. Siddiqi cs602@vu Mathematics of Lighting and Shading - III Taqdees A. Siddiqi cs602@vu.edu.pk
Traditional 3D Hardware-Accelerated Lighting Models
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
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.
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).
we have an ambient term and then a sum of all the light from the light sources
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
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!
we've included the reflection coefficients for each term, k for completeness.
The reflection coefficients are in the [0,1] range and are specified as part of the material property
This equation does fail to take into account any gross roughness or anything other than perfect isotropic reflection
the surface is treated as being perfectly smooth and equally reflective in all directions
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)
or a surface that doesn't really reflect light uniformly in all directions (like brushed metal, hair, or skin).
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
Let's take a look at the individual parts of the traditional lighting pipeline.
Ambient Light
Ambient light is the light that comes from all directions — thus all surfaces are illuminated equally regardless of orientation
Figure 1: Ambient light provides illumination, but no surface details.
We can see that it's difficult to make out details or depth information with just ambient light.
Ambient lighting is our friend Ambient lighting is our friend. With it we make our scene seem more realistic than it is.
A world without ambient light is one filled with sharp edges, of bright objects surrounded by sharp, dark, harsh shadows.
A world with too much ambient light looks washed out and dull.
Diffuse Light
Diffuse light is the light that is absorbed by a surface and is reflected in all directions
In the traditional model, this is ideal diffuse reflection
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
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
Unlike ambient light, the intensity of diffuse light is directional and is a function of the angle of the incoming light and the surface
This type of shading is called Lambertian shading after Lambert's cosine law,
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
Since we're dealing with vertices here and not surfaces, each vertex has a normal associated with it
Diffuse light decreases as the angle between the light vector and the surface normal increases.
Figure 2 shows the intensity of reflected light as a function of the angle between the vertex normal and the light direction.
The equation for calculating diffuse lighting is
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)
Diffuse light shading brings out some surface details
The problem with just diffuse lighting is that it's independent of the viewer's direction
Thus as we change the viewing angle to a vertex, the vertex's diffuse light value never changes
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
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
Ambient and Diffuse light together give a much better shading
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.
Specular Light
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.
Specular light's intensity follows the reflection vector.
Most discussions of lighting (including this one) start with Phong's lighting equation
Phong's Specular Light Equation
Warnock [WARNOCK 1969] and Romney [ROMNEY 1969] were the first to try to simulate highlights using a cos n (θ ) term.
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
Phong's equation for specular lighting is
Figure 6: The relationship between the normal n, the light vector l, the view direction v, and the reflection vector r.
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.
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!
The reflection coefficients are in the [0,1] range and are specified as part of the material property
Let's take a look at the individual parts of the traditional lighting pipeline.
Ambient Light
Figure 1: Ambient light provides illumination, but no surface details.
Diffuse Light
Diffuse light decreases as the angle between the light vector and the surface normal increases.
The equation for calculating diffuse lighting is
Diffuse light shading brings out some surface details
Ambient and Diffuse light together give a much better shading
Specular Light
Specular light's intensity follows the reflection vector.
Phong's equation for specular lighting is
Computer Graphics Lecture 29