RSL
|
|
For the calculation of direct lighting, surface shaders generally add the values
returned by the RSL functions |
Example 2 - faded trailAlthough the first shader is somewhat rudimentary it can, with minor modifications, produce some additional effects. Figure 3, for example, demonstrates how a shader can cause the trail of light to fade. Listing 3 shows how this can be done by maintaining a count of the number of times a non-zero spot light value is baked into the point cloud. |
Listing 2
|
Example 3 - noisey trail
The rsl // STEP 4. Apply noise to the "fade" _spot = _spot * (1 - smoothstep(0, 10, writes * noise(transform("shader", P) * 8))); In this code fading begins after a spot light value has been written 10 into the point cloud. The noise value (frequency of 8) in effect "jitters" the true number of writes. |
Testing the Shaders
The rib file given in listing 3 can be used to test the first two shaders.
Use the Cutter text editor to convert the rib to a keyframe animation file - figure 6.
The second keyframe of the animation file can should be edited so spot light
moves across the polygon ie.
Keyframe 1 LightSource "spotlight" 1 "intensity" 25 "from" [-0.5 4 0] "to" [-0.5 0 0] "coneangle" 0.05 Keyframe 2 LightSource "spotlight" 1 "intensity" 25 "from" [0.5 4 0] "to" [0.5 0 0] "coneangle" 0.05 In addition, the "frame_num" parameter in the second keyframe should be changed to 30.
When rendering the first frame of an animation the renderer (prman) will issue a warning that can be ignored ie. T43030 Point cloud file "PATH_TO/data.ptc" doesn't exist. If you are using prman version 13.5.1 you will also get this warning that can also be ignored ie. S44019 {WARNING} Brick map "PATH_TO/data.ptc" does not contain enough data. |
Listing 3
|
Trailing a Magic LightExample 4
Querrying a light source for a parameter named "coneangle" in order to
identify a spot light is not as flexible as using a custom light source shader that has
been designed to work in conjunction with an accumulation surface shader. So-called magic
light source shaders offer an attractive alternative to using regular light source shaders.
|
Listing 4
|
Listing 5 is a modified version of listing 2. The variable named "__category" enables the illuminance function to "loop over" only those lights in a scene that have been tagged as "magicPointLight". Because of the improved use of the illuminance function the shader can now conviently use the standard lighting functions to obtain the ambient, diffuse and specular lighting components. The "trail_3" shader is, to all intents and purposes, a customized version of the classic Pixar "plastic" shader. |
Listing 5
|
© 2002- Malcolm Kesson. All rights reserved.