The current version of RenderMan Studio (4.0) does not provide a direct way of rendering RenderMan volume primitives. This tutorial provides a relatively easy way of rendering a sphere, cone, cylinder or cube (polygonal or nurbs) as a volume - figure 1.
The TCL Proc
The technique employs a ribbox assigned to the shading group of an object such as a poly sphere. The ribbox calls a TCL proc that queries the name of the shape node to which the shading group is assigned and based on the name, say "pSphereShape1", and the size of its bounding box it generates a few of lines of rib that RfM inserts into a payload of a RenderMan Look File (.rlf). For example,
#ribbox: BaseVolumeSG ArchiveBegin "_ribbox_" Rotate -90 1 0 0 IfBegin "$user:pass_class == 'Final'" Volume "ellipsoid" [-1.0 1.0 -1.0 1.0 -0.951055 0.951055] [2 2 2] Else #Volume "ellipsoid" [-1.0 1.0 -1.0 1.0 -0.951055 0.951055] [2 2 2] IfEnd Attribute "visibility" "camera" 0 ArchiveEnd ReadArchive "_ribbox_"
The code for the proc is given next.
Listing 1 (VolumeUtils.tcl)
Create poly cube.
Open Slim. Create a base volume node and set its density color to hsv
values 1.0 1.0 0.1. Click on the node and choose "Add to Scene"..
Assign the BaseVolume shader to the cube.
Select the BaseVolumeSG tab and choose,
Change RIB Box Interpolation from "none" to "TCL".
Enter the following code into the Rib Box,
Render the scene.
Prior to RMS version 4 the rib generated by a ribbox was inserted directly into the
output rib stream
immediately before the geometric description of a surface. This provided a
opportunity for a ribbox to generate rib statements customized for each surface
that shared a shading group.
Using Multiple Procs
Figure 2 shows a poly cube illuminated by point lights generated by a particle system and rendered volumetrically. The lights are created by a TCL proc given in the tutorial RfM Ribbox: Lights On Particles.
The BaseVolumeSG assigned to the cube had a ribbox containing calls to two TCL procs.
In particular, notice that each call is within open and close square brackets.
© 2002- Malcolm Kesson. All rights reserved.