RMS
Using Custom Light Source Shaders


return to main index



Introduction

This tutorial demonstrates how to assign a custom light source shader to a Maya light when using Pixar's RenderMan Studio release 2, 3.0.0 and 3.0.1.

The "shd_distant" shader (listing 1) used in this tutorial is based on the classic Pixar "shadowdistant" light source shader. The reader may wish to review the tutorial "RSL:Directional Light Source Shaders". It provides an introduction to the writing of directional light source shaders.


Listing 1 (shd_distant.sl)


light
shd_distant(float  intensity = 1;
            color  lightcolor = color(1,1,1);
            string shadowname = "";
            float  width = 1;
            float  samples = 16 )
{
vector direction = vector "shader" (0,0,1);
solar(direction, 0.0) {
    Cl = intensity * lightcolor;
    if(shadowname != "")
        Cl *= 1 - shadow(shadowname, Ps, "samples", samples, 
                        "width", width);
    }
}

Compile the source code and save the .slo file in a location convenient for use with Maya.



RenderMan Studio 2.0 & 3.0.0

Assigning the Shader

Create a directional light source in Maya. Ensure the light is selected and then open the Attribute editor. From the Attributes menu select "Add Shadow Attrs" and "Add Custom Light Shader" - shown below.



Figure 1


Figure 1


Click the "Use Depth Map Shadow" checkbox - figure 3. The "controls" for the attributes will be displayed at the bottom of the editor - figure 4.



Figure 3


Figure 4


Checking the Deep Shadow Pass

To confirm a shadow map pass will be generated open the "RenderMan Controls..." window, available from the main RenderMan menu, and choose View->Pass Settings Tree. You should see "DeepShadow" - figures 5 and 6.



Figure 5


Figure 6


As a result of adding the shadow attrs the RenderMan for Maya (RfM) plugin will, at render time, generate a deep shadow pass rib file. The name of the map will be prefixed with the name of scene and the name of the light, for example, a typical (relative) path might be,

renderman/SCENE_NAME/data/0001/SCENE_NAMELIGHTNAME_DeepShadow.001.tex

Assigning the Custom Shader

Click on the checker box beside the "Custom Light Shader" text field. The attribute editor will display a RenderManLight tab. Browse and select the shd_distant.slo compiled shader file. The parameters for the shader will be displayed - figure 7.



Figure 7


Referencing the Deep Shadow Texture

In the "shadowname" text field enter the following TCL command.

    [passinfo [subst $OBJNAME]_DeepShadow filename]

Be very careful not to accidentally add white space before or after the outer square braces. At render time the TCL expression will be evaluated and the full path of the shadow map will be assigned to the "shadowname" parameter. For example,

    LightSource "PATH_TO/shd_distant" "RenderManLight1" <OTHER PARAMETERS>
                "string shadowname" ["PATH_TO/LightShape1_DeepShadow.001.tex"]

Specifying the TCL Expression in the Shader Source

To avoid burdening a lighting artist with the chore of entering a TCL expression in the "shadowname" parameter it might be useful to assign it as the default value.


shd_distant.sl (modified)


light
shd_distant(float  intensity = 1;
            color  lightcolor = color(1,1,1);
            string shadowname = "[passinfo [subst $OBJNAME]_DeepShadow filename]";
            float  width = 1;
            float  samples = 16 )
{
original shader code...
}


RenderMan Studio 3.0.1

Assigning the Shader

Create a directional light source in Maya. Ensure the light is selected and then open the Attribute editor. From the Attributes menu select "Add Custom Deep Shadow Map" and "Add Custom Light Shader".



Figure 8


Figure 9

Do NOT check the "Use Depth Map Shadow" checkbox - figure 10. The "controls" for the attributes will be displayed at the bottom of the editor - figure 11.



Figure 10


Figure 11


Click on the checker box beside the "Custom Light Shader" text field. The attribute editor will display a RenderManLight tab. Browse and select the shd_distant.slo compiled shader file. The parameters for the shader will be displayed - figure 12.



Figure 12


Referencing the Deep Shadow Texture

In the "shadowname" text field enter the following TCL command.

    [passinfo rmanDeepShadowPass filename]

Specifying the TCL Expression in the Shader Source

To avoid burdening a lighting artist with the chore of entering a TCL expression in the "shadowname" parameter it might be useful to assign it as the default value.


shd_distant.sl (modified)


light
shd_distant(float  intensity = 1;
            color  lightcolor = color(1,1,1);
            string shadowname = "[passinfo rmanDeepShadowPass filename]";
            float  width = 1;
            float  samples = 16 )
{
original shader code...
}


© 2002- Malcolm Kesson. All rights reserved.