Next: Illuminated streamlines
Up: Visualising vector fields
Previous: Hedgehog plot
The solution that yields a result equivalent to the thin tube approach is actually a variant of fake Phong shading applied to lines. The fake Phong method uses the hardware-accelerated texturisation for shading. The idea is to let the graphics library and the hardware transform and linearly interpolate some adequate values, and store the corresponding pre-calculated light intensities in a texture. The texture transformation matrix mechanism allows us to calculate up to three dot products and use them as texture co-ordinates. The simplified shading equation for local lighting is:
, , and are constant coefficients, characterising the material. is the light vector, is the view vector, is the surface normal and L is light intensity or radiance.
The reflection vector may be expressed as:
That way the radiance is expressed as a function of
and
:
It is possible to use these two values as texture co-ordinates, however, the approximation will not be perfect. Although the interpolation of the dot products is equivalent to the interpolation of the normal vector, there is no possibility to normalise the interpolated vector for every pixel. This method is usually called flat Phong shading. If the normal vector is set as the vertex texture co-ordinate for every vertex, the dot products are evaluated and scaled into the [0,1] domain by the texture transformation itself, provided the transformation matrix is set up as follows:
Unfortunately, it is not possible to completely eliminate the normalisation problem without multiple three-dimensional textures. However, a different approximation is obtained if we do not interpolate the normal itself, but two other vectors perpendicular to each other and the normal, and applying the Pythagorean theorem. If both diffuse and specular lighting are needed, this still requires a huge three-dimensional texture. The method is called fake Phong shading [2], and although it tends to create exaggerated lights in darker areas, it is more accurate than flat Phong shading near the more important highlighted spots.
Figure 6:
Textures used for illuminated lines[5] and in fake Phong shading[2]. J and K vectors are perpendicular to the surface normal.
|
Next: Illuminated streamlines
Up: Visualising vector fields
Previous: Hedgehog plot
Szecsi Laszlo
2001-03-21