RSL
|
IntroductionIt is useful to think about a shading effect, say making a colored pattern, as a process of sequentially applying layers of colored foil to a surface. As each layer of foil is applied it is cut out by a digital "cookie-cutter".
Figure 1 shows a "cookie-cutter" and foreground and background colored "foils". The cookie-cutter can also be thought of as a mask that allows one layer of color to be composited onto another layer of color. The cookie-cutter ie. mask, defines areas of transparency and opacity. Opaque areas allow parts of a foreground foil to overlay a background foil. Defining a Cookie-Cutter
Listing 1 provides the code for a function that returns 0 or 1 depending on whether
an location ( Listing 1
The value retured from the function is used
by |
Using a Cookie-CutterThe source for a simple layered shader is shown below in listing 2. Listing 2
If you are using Cutter to compile the RSL source code make sure that both the "lib.h" and "layering1.sl" are in the shader source code directory specified in Cutter's Preferences - figure 2. If you are not using Cutter the full path to the "lib.h" file must be specfied by the #include statement.
|
Multiple LayersBy repeating step 2 several times, for example, mask = rectangle(0.1, 0.3, 0.8, 0.7, s, t); surfcolor = mix(Cs, color(0,0,1), mask); mask = circle(0.3, 0.5, 0.25, s, t); surfcolor = mix(surfcolor, color(1,0.239,0), mask);
a shader can give the illusion the
surface to which it is assigned has multiple colored layers - figure 3.
A function called Listing 3
|
© 2002- Malcolm Kesson. All rights reserved.