AIR provides two common ways of rendering ambient occlusion: a special envlight light shader that uses ambient occlusion to compute its shadows, and an occlusionpass surface shader.
The envlight and occlusionpass shaders included with AIR rely on attributes and options to control their behavior. Because Massive does not provide a convenient way of setting custom attributes and options, we have developed special versions of these shaders - massive_envlight and massive_occlusionpass - that do not rely on custom attributes or options.
These shaders should not be used with the occlusion prepass. If you wish to use the occlusion cache with an occlusion prepass, use the standard envlight and occlusionpass shaders with the process described below under occlusion caching.
For ambient occlusion to function properly, ray-traced shadows must be enabled in Massive’s render dialog.
Shader Parameter Quick Reference
The massive_envlight and massive_occlusionpass shaders add the following parameters to those in the envlight and occlusionpass shaders:
The main quality control is the samples parameter, which gives the number of rays cast for each occlusion estimate. Use more rays to produce a smoother image with less noise at the expense of longer rendering time. It normally makes sense to increase or decrease the number of samples by a factor of 2.
The maxhitdist parameter sets the maximum distance to search for occluding objects. Lower values will reduce rendering time as well as noise.
The coneangle parameter gives the half angle in radians of the cone of directions within which occlusion rays are distributed. The default value of PI/2 (~1.57) distributes rays over a hemisphere. Use smaller values to concentrate the rays more in the normal direction, producing a more focused occlusion result.
The shadowbias parameter is used to prevent incorrect ray-object intersections by giving an offset to add to each ray's starting location.
More information on ambient occlusion can be found in the AIR user manual under
The occlusion cache accelerates rendering by storing occlusion estimates and re-using them at nearby locations. Obtaining smooth results with the occlusion cache typically requires enabling the occlusion prepass. The easiest way to employ the occlusion cache with Massive is to use a small auxilliary text file with the RIB commands required for occlusion rendering. Here's a sample file for rendering an occlusion pass:
When rendering multiple frames you'll need to include a frame block with the frame number in the air command line to generate a unique image name for each frame. For example:
air occpass.rib {FrameBegin 22} render.0022.rib {FrameEnd}
will render to
occlusion.0022.png
The shell script generated by Massive can be modified to include the additional command line parameters in the line that begins air. This method can be used to render an occlusion pass with the RIB files generated for a beauty pass in Massive; there is no need to generate a separate set of RIB files for the occlusion pass.
The same workflow can be used without the occlusion cache and prepass. To disable the occlusion cache, change the maxerror value to 0 in the auxilliary rib file. To disable the occlusion prepass set the prepass option value to 0. Here’s a sample rib for rendering without an occlusion cache:
Veteran AIR and Massive user Phil Hartmann offers the following tips on rendering occlusion:
1. In Massive set the shading rate to 0.25 or 0.5. Set Pixel Samples to 8x8. Set the trace bias in the range 1 to 10.
2. In the massive_envlight or massive_occlusionpass shaders, set samples to 32 or 64. Set maxhitdist to 200 to 500 cm.
3. If memory use is an issue, render the occlusion pass separately from other passes with the massive_occlusionpass shader.
4. To maximize processor usage on a multicore machine, run multiple processes with 1 thread each rather than a single process with multiple threads.
Selective Occlusion Testing with Groups
Problem: A user wishes to render an occlusion pass with agents and terrain in the same image. Agents should be rendered with normal occlusion from all geometry. The terrain should show occlusion from agents but not from the terrain itself.
Solution: Grouping can be used to restrict the objects tested for occlusion as follows:
1. The first step is to assign a group name to the agents by creating a small text file with the following:
Unzip to the shaders directory of the Air installation.
3. Assign the (new) massive_occlusionpass shader to the terrain. Set the new shadowgroups parameter to "agents" to restrict occlusion testing to just the agents.
4. Assign the massive_occlusionpass shader to the agents, leaving the shadowgroups parameter with its default empty value (so all objects occlude the agents).