Setting Volume Object Attributes

Volume objects have numerous properties controlling how they are rendered. These properties can be set when the object is created or set using the SetProperty method.

Example Code
The example code discussed in the following sections is contained in the procedure file obj_vol.pro, located in the examples/doc/objects subdirectory of the IDL distribution. Run the example procedure by entering obj_vol at the IDL command prompt or view the file in an IDL Editor window by entering .EDIT obj_vol.pro. The procedure file stops after each operation (roughly corresponding to each section below) and requests that you press return before continuing.

Volume Opacity

The opacity table controls the transparency of a given voxel value. Manipulation of the opacity table is critical to improving the quality of a rendering. The following figure reflect the sample code, which makes the prism transparent and the cubes opaque, allowing the cube within the prism to be seen. This is done by setting the OPACITY_TABLE0 array to low values for the prism and high values for the cubes.

Figure 7-2: Volume Object Opacity

objvol2.gif

Volume Color

Each voxel value can be assigned an individual color as well. This color mapping can be changed by changing the RGB_TABLE0 property. To further highlight the cubes, we change their colors to blue and red, as shown in the example code, obj_vol.pro, located in the examples/doc/objects subdirectory of the IDL distribution.

Volume Lighting

Adding lights enhances the edges of volumes. Gradients within the volume are used to approximate a surface normal for each voxel, and the lights in the current view are then applied. The gradient shading is enabled by setting the LIGHTING_MODEL property equal to one. The ambient volume color is selected by setting the AMBIENT property of the volume object to a color value. Setting the TWO_SIDED property allows both sides of a voxel to be lighted. See obj_vol.pro in the examples/doc/objects subdirectory of the IDL distribution for an example of using a light source.

Note
Only DIRECTIONAL light sources are honored by the volume object. Because normals must be computed for all voxels in a lighted view, enabling light sources increases the rendering time.

See Light Objects for more details on creating and using light objects.

Compositing

The volume object supports a number of methods for blending the projected voxels together to form an image. By default, Alpha blending is used. (In Alpha blending, each voxel occludes voxels behind it according to the opacity of the voxel in front). Another common compositing technique is the maximum intensity projection (MIP). Set the volume object to use MIP compositing by setting the COMPOSITE_FUNCTION property equal to one as shown in obj_vol.pro, located in the examples/doc/objects subdirectory of the IDL distribution. See "IDLgrVolume Properties" (IDL Reference Guide) for other options.

ZBuffering

When combining a volume with other geometry in the Object Graphics system, volume objects should in general be drawn last to ensure they intersect the other (solid) objects properly. To increase rendering speed, the intersection operation is disabled by default. To enable the intersection calculations, set the ZBUFFER property of the volume object equal to one.

Additionally, volume objects allow for control over the rendering of invisible (opacity equals zero) voxels. By default, the zbuffer will be updated for such voxels (even though no change is made in the image color). This writing to the zbuffer by transparent voxels be disabled by setting the ZERO_OPACITY_SKIP property.

These properties are set near the beginning of the obj_vol.pro file, located in the examples/doc/objects subdirectory of the IDL distribution.

Note
In volumes with large numbers of voxels with their opacity set to zero, enabling ZERO_OPACITY_SKIP can improve rendering performance.

Interpolation

By default, when rendering a volume object, values between the voxels are estimated using nearest neighbor sampling. When higher quality rendering is desired, trilinear interpolation can be selected instead by setting the INTERPOLATE property equal to one.

myvolume->SetProperty, INTERPOLATE=1 

Note
Trilinear interpolation will cause the rendering to take considerably longer than nearest neighbor interpolation. See Interpolation Methods (Using IDL) for more information on interpolation.

Rendering speed

Rendering speed can be improved by reducing the quality of the rendering. Use the RENDER_STEP property to control this speed/quality trade-off. The value of the RENDER_STEP property specifies a step size in the screen dimensions which is used to skip voxels during the rendering process. Larger values yield faster rendering times, but lower final image quality. For example, to render only half as many voxels in the screen Z dimension, use the following statement:

myvolume->SetProperty, RENDER_STEP=[1,1,2]  

A more complex example using a volume object is shown in the volume visualization demo. To start the demos, type demo at the IDL command prompt.

Figure 7-3: Volume Object Rendering

objvol3.gif