RSL

Introduction
The shading language functions Listing 1


What is the mod() Function
The mod(3, 2); returns the value 0.5  the remainder of 3 divided by 2. The function can be used to map the range 0 to 1 to a sequence of repeating subranges 0 to 1. In each subrange the maximum value becomes infinitly close to 1 but never actually reaches that value.
The
To generate 8 repeating patterns, say in the ' float ss = mod(s * 8, 1);
Using 1 as the divider ensures we obtain the correct remainder.
The effect of using mod() in both ' 
Using the mod() FunctionThe "repeatbump" shader shown in listing 1 is a slightly modified version of the previous "basicbump" shader. For brevity the code for the function "square" is not shown. Only the new code is shown colored, the original code is shown in gray. Download repeatbump.sl Listing 2

Using the floor() FunctionThe floor() function returns the integer portion of a number. For example, floor(3.7) returns 3. As such it can be used to determine which part of the repeat pattern our shader is currently being used on. Listing 3 provides the code that generated the staggered repeats seen in figure 3. Listing 3
To see how this is done with a surface color refer to staggeredcolor.sl.
For a highly detailed explanation about patterns refer to,

© 2002 Malcolm Kesson. All rights reserved.