
previous | next | writing shaders: contents | rmannotes: top

This section describes techniques for incorporating illumination models -- specifically the "plastic" illumination model -- into surface shaders. It does not discuss the theory behind illumination models or how parameters of the plastic model should be used.
The most commonly used illumination model in RenderMan shaders is the so-called "plastic" illumination model which incorporates diffuse, specular, and ambient reflection. We can add the plastic illumination model to shaders as a final layer (after the other layers have determined the surface color) or we can incorporate it into individual layers to achieve surfaces with non-uniform illumination.
You'll find that in most shaders which use the plastic model, the same set of instance variables are used. The table below briefly summarizes those variables.
| name | type | description |
|---|---|---|
| Ka | float | ambient reflection constant -- the percentage of ambient light in the scene reflected by this surface |
| Kd | float | diffuse reflection constant -- the percentage of diffuse light in the scene reflected by this surface |
| Ks | float | specular reflection constant -- the percentage of specular light in the scene reflected by this surface (i.e. brightness of specular highlights) |
| roughness | float | specular roughness constant (1 = very rough, 0.0001 = very smooth) -- the concentration (brightness) of specular highlights |
| specular | color | specular reflection color |
In addition, certain auxillary variables will be used in RManNotes shaders to implement the illumination model.
| Nf | point | forward facing normal |
| V | point | view vector |
Let's assume that surface_color contains the surface color
of the object without illumination. We can compute a new value for
surface_color which will include the plastic illumination
model with the following code fragment. Note that this fragment declares
Nf and V locally and assumes that
Ka, Kd, Ks, roughness,
and specularcolor are instance variables.
point Nf, V; ... Nf = faceforward(normalize(N), I); V = -normalize(I); surface_color = surface_color * (Ka * ambient() + Kd * diffuse(Nf)) + specularcolor * Ks * specular(Nf, V, roughness);
|
| surf2.1.sl, Os = (1,1,1) |
The surf2.1.sl shader shown above contains a simple screen pattern and incorporates the plastic illumination model using the computations and variables described above.
The shader presented in the previous section (surf2.1.sl) uses the same illumination computation for all layers. Because the illumination is treated independently of the underlying surface color, the ball appears to may made of one multi-colored material. By varying the illumination per layer (as in surf2.2.sl), we can generate the effect of a surface composed of differing materials.
|
| surf2.1.sl (left) and surf2.2.sl (right) |
In the image above, the sphere on the left shows uniform illumination of layers; the sphere on the right shows non-uniform illumination. In particular note that on the right sphere, the highlight applies only to the foreground layer and that ambient light is lacking in the background layer.

previous | next | writing shaders: contents | rmannotes: top

RManNotes is Copyright © 1995, 1996 Stephen F. May
Any comments or suggestions appreciated.
Steve May (smay@pixar.com)Last Modified: 5/6/96