RSL
|
Introduction
Some objects, particularly those made of glass, can appear to have a rich sub-surface
texture - figure 1. This tutorial demonstrates a shading technique that mimics sub-surface
textures without the need to use ray tracing. The shaders on this page rely on a
trick that strickly speaking should not be allowed by the RenderMan shading language,
namely, allowing a surface shader to assign a value to point
The reflections from the surface of the vase shown in figure 1 appear to be smooth
and glossy. However, the small scale bumps appear to unmistakenly "belong" to a layer of material
that we interpret as beneath the surface of the glass. To reproduce this visual effect
the shader in listing 2 makes two sets of lighting calculations sandwiched around a
"temporary" displacement.
|
Lighting ComponentsThe lighting calculations, excluding environment mapping, are based on a combination of ambient, diffuse and specular lighting components. The shader on this page is based on the code for the plastic shader presented on page 337 of The RenderMan Companion. To keep the code of the surface shader short and because the lighting calculations are performed twice they have been rolled into a single function. Likewise, the code responsible for environment mapping has been implemented as a function. Both functions are in a header file - ShadingUtils.h (listing 1). The header file should be saved into the same directory as the the shader (listing 2). If the reader is using Cutter to edit these files, compilation of the shader will be easy because the editor will automatically link to the header file. |
Listing 1 (ShadingUtils.h)
|
Shader CodeThe basic implementation of the shader is shown in listing 2. Listing 3 demonstrates the use of the shader in a rib file. |
Listing 2
|
Reference RendersThe next set of images provide a visual break-down of the output of the shader. The "trick" to this technique is producing a believable displacement. Figure 4 shows the effect of trying to procedurally produce high frequency displacements. It would have been better had the displacements been generated from a displacement map. How that can be achieved is left as a problem for the reader to solve. |
|
|
|
|
|
Listing 3
|
© 2002- Malcolm Kesson. All rights reserved.