RSL
|
Introduction
The relatively new shading strategy called |
"A Tour of Ray-Traced Shading in PRMan" prman_technical_rendering/AppNotes/rayintro.html#interiorvp "Shading Strategy" prman_technical_rendering/users_guide/attributes.html#shade_strategy "Writing Fancy Atmosphere Shaders" prman_technical_rendering/AppNotes/appnote.20.html |
"A Tour of Ray-Traced Shading in PRMan" provides examples of the use of a fog
shader. The code for the fog shader is given in "Writing Fancy
Atmosphere Shaders". For most people, trying to tease apart the inner workings
of the fog shader usually engenders a state of, well, fog. Shortly after
encountering "Trapezoidal integration" most readers quickly realize that making
sense of Pixar's fog shader is unlikely to be easy - few are disappointed!
Front and RearFigure 1 is based on an illustration accompanying, "Interior volume shaders without ray tracing"; a section of the first reference cited above. The sphere shown in the illustration has been assigned the following attribute. Attribute "shade" "strategy" ["vpvolumes"] |
|
When a volume shader uses the global variable point frontP = P - I; // the "front" micropolygon The distance from the front to back for a camera "ray" passing through a volume is, float totalDist = length(I);
|
Stepping
Figure 2 shows a few camera "rays" passing through a volume bounded by a sphere.
At uniform intervals long each |
|
The sphere shown above is 1.0 unit in diameter. Because the distance between the
intervals (step size) was 0.2 the "ray" passing through the center of the sphere
has 5 intervals along its length. The curved black lines represent the sample
points for approximately 82,000 Basic CodeThe basic code for an interior shader is shown below. Note the shader makes an initial randomized step before it begins sampling from front to rear. This ensures the volume is sampled in a way that avoids aliasing - figures 3, 4 and 5. |
|
|
|
Listing 1 - basic_interior.sl
|
Sampling 3D NoiseFor simplicity the shader developed in this section samples 3D noise but does not make any lighting calculations. |
Listing 2 - basic_noise.sl
|
The result of assigning the shader to a sphere is shown above. The lack of interior complexity combined with low contrast generates an uninteresting result. |
Listing 3 - contrast_noise.sl
|
The use of |
Listing 4 - contrast_noise.sl
|
The use of multiple overlays (octaves) of noise adds complexity to the interior. |
© 2002- Malcolm Kesson. All rights reserved.