next up previous contents
Next: Mental Ray Up: A Constant Surface Shader Previous: A Constant Surface Shader   Contents

RenderMan

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.


Table 1: A few predefined surface shader variables
Name Type Description
Cs color Surface color
Os color Surface opacity
Ci color Incident ray color
Oi color Incident ray opacity


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.

Figure 1: Vshade
\includegraphics[scale=0.5]{vshade.constant.ps}

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 ...
...

Figure 2: Using the constant shader
\includegraphics[scale=0.5]{constant.ps}


next up previous contents
Next: Mental Ray Up: A Constant Surface Shader Previous: A Constant Surface Shader   Contents
Jan Walter 2004-02-09