In a scene, illumination from light emitting sources is reflected off multiple surfaces, these reflections combine to produce a uniform illumination called ambient light. Ambient light appears to come equally from all directions.
|
|
Light emitting sources come in two basic types;
If a surface is exposed only to ambient light then we can express
the intensity of diffuse reflection as:
The level of diffuse reflection of ambient light is similar in all directions. Highly reflective surfaces (smooth or polished) have a near one, which means that almost all the incident light is reflected.
To simplify calculations we will assume that the light rays are parallel as they strike the surface (This is a good approximation for sources which are reasonably far away from the surface). We will describe the orientation of a surface with a unit normal vector and the direction of the light source is the unit vector (figure 7.5).
The angle between the two vectors, , is called the angle of incidence. Lambert's law states that the amount of reflected light is proportional to the cosine of the angle of incidence. This can also be written as a dot product;
A surface is illuminated by a light source only if the angle of incidence is between and .
The intensity of light from a point source drops off as the source
is moved away from the object. So we can model the intensity of
the light striking the surface as:
Putting all of this together, we get the following equation for
the intensity of diffuse reflection due to a point source:
These equations assume we are dealing with mono-chromatic (white) light. In real world situations, light sources have different colors, and our model should be able to handle this. To accommodate the use of colours, our light intensity values and our reflectivity constants should become 3-Vectors, each vector contains values for the Red, Green and Blue components of the light source.
Now becomes ( ) and becomes ( ) where represents the amount of red light in the source and so on. This breakdown is important as different surfaces reflect the colours by different amount; e.g. A surface with yellow pigmentation will reflect a lot of Red and Green, but will absorb most of the Blue light.
When viewing a shiny surface in the presence of a light source, bright spots on the surface are often seen. This is called specular reflection (fig 7.6.
|
Specular reflection is only observed at certain viewing angles and depends on the orientation of the viewer with respect to the light source. On a shiny surface, much of the incident light is reflected away from the surface at an angle similar to the angle of incidence (figure 7.7). For real surfaces, specular reflection is observed over a small range of angles around the angle of reflection. As the viewer moves away from the angle of reflection, the specular component decreases.
In figure 7.8, is a unit vector in the direction of the viewer and is a vector along the angle of reflection. When and coincide, the viewer sees maximum specular refection, as increases, the specular reflection decreases. For shiny surfaces the specular reflection is very bright but visible only over a small range of angles, for less shiny surfaces, the specular reflection is not as bright, but is visible over a wide range of angles. A good approximation to the observed behavior of specular reflection is the Phong Specular Model.
In the Phong model, the intensity of specular reflection is
proportional to , where depends on the surface
and ranges between 1 and 200. Very shiny surfaces have high values
of , as specular refection is exhibited over a small range of
. We know that
, so;
There now remains the problem of determining ;
(8.1) | |||
(8.2) | |||
(8.3) | |||
(8.4) | |||
(8.5) | |||
(8.6) | |||
(8.7) | |||
(8.8) | |||
(8.9) | |||
(8.10) | |||
(8.11) | |||
(8.12) | |||
(8.13) | |||
(8.14) |
|
This average normal will coincide closely with the normal of the actual modelled surface at that point. This vector is then used in a reflection model to determine the light intensity at that point. This process is repeated for all vertices in the model. Once the correct intensity has been calculated for each vertex, these are used to interpolate intensity values over the face. The interpolation scheme is know as bi-linear interpolation.
In the figure 7.14, intensities are known for , and . and can be interpolated as follows:
Gouraud smoothes the faceted appearance of meshes, because the interpolated intensities along an edge are used to shade both polygons which share that edge. This means that there is not a discontinuity of colour at the edges of adjoining faces.
However, although the mesh appears smooth, the polygons are still visible at the edge of the object when viewed as a silhouette. Gouraud can also interpolate incorrectly which results in some rendering errors which remove some detail (figure 7.15).
The biggest problem with Gouraud shading is the fact it reproduces specular shading poorly and if specular reflection is displayed, it is determined by the polygon mesh rather than the modelled surface. If a highlight occurs in the middle of a polygon, but not at any of the vertices, the highlight will not be rendered by interpolation (figure 7.16). Also, Mach banding can occur when specular refection is incorporated into Gouraud, for this reason, the specular component is often ignored when using Gouraud, giving 'smother' results.
Thus we have a good approximation of the surface normal at each scanline position (pixel) and therefore we are able to calculate more accurately the intensity at that point, including specular highlights. The interpolation scheme for normals, is similar to Intensity interpolation.
Phong shading requires intensity calculations at each point on the face, so is therefore far more expensive that Gouraud which only performs intensity calculations at the vertices. Note that the computation of normals in both Gouraud and Phong must be done in world coordinates, as pre-warping distorts the relative orientation between surface, light-source and eye. Both these methods can be integrated with Z-Buffer or scanline filling algorithms.