Before we will look into light shaders we will start with a simple
surface shader. One of the standard shaders shipping with all
RenderMan compatible renderers is the constant surface
shader:
surface constant()
{
Oi = Os;
Ci = Os * Cs;
}
The source code specifies the shader type (surface), the
shader name (constant), and uses only predefined surface
shader variables11. See table 1 for
an explanation of the predefined surface shader variables we used so
far and table 3 on page
for a complete table.
In a RenderMan surface shader you will set the variables Oi
and Ci to new values. In this case you simply copy the value
for the incoming opacity and you multiply the already existing color
by the opacity value. This allows colors from behind the surface to
show through without overflowing the bounds of a color.
With AIR there comes a program called Vshade for the Windows
platform. You can use that program to write the shader visually,
compile it with an user interface, and render directly to see the
effect. The constant shader would look like in figure
1.
But where do the values for Os and Cs come from? They
might be the default values (if not specified) or you will find a
line starting with Opacity or Color in the RIB file
(just before the surface shader is called and attached to the
following geometry with Surface "constant").
You can download the RIB file12 which was used to render the picture in figure 2 from the same web page where you got this document.
Basically there is a plane in front of a more complicated mesh which looks like a monkey. The plane has the constant surface shader attached and defines a green color and a half transparent material:
...
# Plane
Color [ 0 1 0 ]
Opacity [ 0.5 0.5 0.5 ]
Surface "constant"
PointsPolygons ...
...