This tutorial presents a technique for generating a 32 bit image that is suitable, once converted to a texture, for use as a displacement map that will produce a pattern of high frequency bumps. The 32 bit image is derived from an orthographic rendering of a square polygon lit by instances of a custom light source shader. The shader is implemented such that its lighting distribution, figure 1, produces a gradation of grayscale values on the square polygon that will cause the displacement map to produce hemi-spherical "bumps".
For example, the image shown in figure 2 was converted
to a texture and used as a map to displace the polygon shown in figure 3.
The tutorial uses a python script to write a pre-baked (archive) rib file
that references an arbitary number of light sources. For
example, figure 3 is an image of a polygon lit by 1600 lights distributed in a
regular grid. Figure 4 shows the effect of using the image as a displacement map
on a nurbs sphere. Despite the very high frequency of the bumps at the pole of
the sphere the pattern displays very little aliasing - a benefit derived from
the use of a texture map.
Because the bumps for the final image were required to be hemi-spherical, a
custom light source shader, called
Listing 1 (bumpPointLight.sl)
The light source shader uses an output variable of type float so that its value can be used directly by the surface shader shown in listing 2.
Listing 2 (bumpPointSurface.sl)
Listing 3 is the python code that writes a pre-baked rib file that references the custom light source shader. If the script is run with Cutter the output rib file will be saved to the Cutter directory.
Listing 3 (regularGridOfLights.py)
Finally, listing 4 provides a rib file that uses the baked lighting rig produced
by regularGridOfLights.py. The rib file is setup so that a 32 bit secondary image
named "bumps.tif" is saved to the Cutter directory. The
Listing 4 (makeTexture.rib)
© 2002- Malcolm Kesson. All rights reserved.