Shader class architecture

Figure 194 and Figure 195 show the TShader class architecture. The TShader derived classes shown in Figure 195 provide default shading styles.


Every default shader has a TReflectanceShader instance to simulate the way objects reflect light and is the default drawing port shader. TReflectanceShader simulates how objects reflect light.

You can derive from TReflectanceShader to implement your own ligh simulation algorithms. The other TShader derived classes are used with texture maps to compute the final color and texture of a surface.


Reflectance shader

TReflectanceShader simulates how objects reflect light. It models the interactions of illumination with surface reflection properties to calculate the appropriate color of a surface using a reflecton model and a shading model. This is the default shader provided by the drawing port. Figure 187 shows a hollow cylinder drawn with the default reflectance shader.

TReflectanceShader carefully tunes reflection coefficients and surface colors to generate images of a reasonable quality. The lack of surface detail in TReflectanceShader may sometimes cause graphics to appear too smooth or too uniform. You can increase surface detail by mapping digitized images or procedurallydefined virtual images to 3D graphics using texture maps.

Reflection model

The reflection model uses the following three major components: ambient reflection, diffuse reflection, and specular reflection.

Shading model

The
shading model uses the ambient, diffuse, and specular reflection and models reflectance as a function of wavelength and incidence angle. In addition, ambient, diffuse, and spectral shading is computed from the light and other surfaces present in the scene.

By default, TReflectanceShader computes the color of a surface as the weighted sum of the intensity. The intensity is computed from values returned by the Diffuse and Specular functions combined with the ambient component that is automatically taken from the scene bundle. The final appearance of the displayed color is computed from the shader, shading sample, camera, and light sources in the pipeline.

Materials react to ambient, diffuse, and specular reflection differently. For example, a dull surface such as chalk exhibits strong diffuse reflection, but is not very specular; whereas, a shiny surface exhibits strong specular reflection. TReflectanceShader has the functions shown in Figure 196 for setting and getting ambient, diffuse, and specular coefficient values. A value of 1 for any coefficient simulates a broad, gentle highlight falloff; higher values simulate a sharp, focused highlight.



[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker