RSL
|
Variety
The shading language incorporates many useful maths functions that can
be used to generate visual effects such as bumpiness and variations
in color. Maths functions, however, produce visual effects that look
unnaturally smooth and regular.
The
|
|
|
Frequency & Amplitude
In a displacement shader noise might be used to effect the bumpiness
of a surface in say the '
Because the default values of ' hump = noise(s);
is shown in figure 4. |
|
Figure 5 |
|
To increase the frequency of the output values (from the noise function) the input values are scaled, for example, |
||
A poly plane displaced by, hump = noise(s * 5); is shown in figure 5. To control the amplitude of the noise its output value can be scaled. In the line of code shown below the difference in height between the valleys and peaks is reduced by approximately a third ie. hump = noise(s * 5) * 0.3; Figures 4 and 5 are examples of one-dimensional noise. |
2D Noise
The hump = noise(s * 5, t * 5) * 0.3;
Using two values generates two-dimensional noise.
Listing 1 shows that replacing the constant values (5 and 0.3) with the instance variables,
Listing 1
|
3D Noise
The noise function also accepts a three-dimensional input. For
example, we could use the global variable
Listing 2
|
Sticky 3D Noise
A problem arises when using the global variable |
|
To make the displacements "stick" to the surface of the polyplane, point Listing 3
Figure 9 shows three frames of an animation in which the displacement shader is using "object" space. In effect the displacements are parented to the polyplane. |
© 2002- Malcolm Kesson. All rights reserved.