Using Brickmap Geometry

return to main index

Download scripts.zip
View Code:


This tutorial provides a number of scripts suitable for writing geometric and shading data to a brickmap that can be subsequently rendered as a geometric primitive. Using brickmaps as geometry is a technique ideally suited to situations where surfaces are rendered using computationally expensive techniques.

The advantage of using brickmaps as geometry is that their internal data structure enables PRMAN to automatically apply level-of-detail without the need for an artist to prepare multiple versions of the same model.

The current version RMS 18 does not provide a convenient way of baking and re-using brickmaps as geometry. The scripts given here are intended to provide a starting point for those who wish to develop more flexible, robust and artist-friendly interfaces for use in a production environment.

Know Issues/Problems

Baking a brickmap from a scene that is rendered without raytracing is straightforward. However, when raytracing it is essential the "Hider" is "reyes", figure 1, and geometry is set to single sided - figure 2.

Figure 1

Figure 2

Ordinarily, baking brickmaps and subsequently using them as geometric primitives involves a rather cumbersome sequence of operations. The motivation for preparing the scripts presented by this tutorial is to reduce the "bake-and-serve" workflow to a couple of mouse clicks. The tricky part is ensuring the scripts are installed correctly and the two shaders (listings 1 & 2) are compiled and their .slo files are copied to the project directory that contain the Maya scene files.

Step 1

Download and unzip scripts.zip file. It contains all the scripts and shaders used by this tutorial.

Step 2

Move the following four scripts to the directory that RMS sources at startup.

For example, if the reader has followed the recommendations given in the tutorial RMS: Customizing the scripts should be moved to the "maya/projects/RMS_mel" directory.

Step 3 - Preparing the Scene

Launch Maya, set the project directory and open the scene to be used for baking a brickmap. Hide all the objects except for the "target" surfaces that are intended to be baked into the brickmap. Make sure RenderMan is the chosen renderer and the "target" object is tightly framed by the camera. Ensure the shaders assigned to the geometry have their specularity set to zero. Make a note of the dimensions of the object being baked. The quality of the brickmap will depend on the frame size, shading rate and a value know as "maxerror".

Step 4 - Baking the Brickmap

Open the script editor and use the following command to render and bake the brickmap.


The proc parameter, in this example 0.002, sets the "maxerror" when a temporarty pointcloud generated by PRMan is converted by a utility program called "brickmake" to the final brickmap. Rendering will begin immediately and at its conclusion the data directory should contain a brickmap. The mel proc takes care of,
    - writing and compiling a volume shader called "bakeGeoBrickmap",
    - declaring several DisplayChannels,
    - assigning the Atmosphere (bakeGeoBrickmap) shader,
    - setting three special Attributes, and finally,
    - making a System call to "brickmake" to convert a pointcloud to a brickmap.

Step 5 - Resolving Errors

If Maya cannot find the procedure use these commands,

    source "/PATH_TO/bakeGeoBrickmap.mel";

Step 6 - Viewing the Brickmap

To view the brickmap open a terminal, cd to the data directory and use this command,
    brickviewer NAME_OF_THE_BRICKMAP.bkm

Step 7 - Using the Brickmap

Begin a new Maya scene. Make sure the scene is saved and the project directory has been set. Create a polygon cube with dimensions that match those of the object that was baked. If the cube is scaled make sure that "Freeze Transforms" is applied to it. Select the cube and in the script window enter this command.


Toggle the transform and shape tabs of the attribute window. A new panel titled "Extra RenderMan Attributes" will appear in the lower part of the shape tab - figure 3.

Figure 3

Use the browse button and locate the brickmap. By default the brickmap will be rendered, without raytracing, using the material assigned to the cube (proxy object).

By avoiding the use of a sophisticated shader such as RMSGPSurface the brickmap(s) will render very quickly. For example, figure 4 shows a blobby rendered before being baked as a brickmap. Using a RMSGPSurface shader with sub-surface scattering (specular gain set to 0.0) and a single spherical area light the image took 11 min 10 sec to render at a frame size of HD540.

Figure 4

The blobby was baked as a brickmap and assigned to 8 proxy cubes, figure 5.

Figure 5

The 8 proxies used the barebones shader given in listing 1; the "floor" was assigned RMSGPMatte. A spherical geo area light illuminated the "floor". Total rendering time, including the depth-of-field, was 2 min 28 sec. With the floor, area light and raytracing turned "off" a single instance of a blobby brickmap took 9 seconds to render!

Figure 6

Listing 1 (barebones.sl)

barebones(float  Kfb = 1  /* fake brightness */) {
    Oi = Os;
    Ci = Oi * Cs * Kfb;

© 2002- Malcolm Kesson. All rights reserved.