Rendering Volumes In RAT

zj, March 2003

Light that passes through a material tends to loss its transmission due to random scattering as it meets the tiny particals in the material.

When you have a chance to observe ground fog, notice there is always some maximum distance that you can see through it. Because light comes from distance beyond that travels too long to be seen. In order to compute how much the light is attenuated, it is necessary to know both the attenuation coefficient and the distance the light travels.

 

This is a simple depthcue shader. It returns white when the depth of the surface point seems to be 1, and attenuates the color when P moves closer to the near clipping plane. In this case, no light is sampled.

 

 

 

In order to render atmospheric effects like smoke and light fog, the approach of Ray March along view vector must be adopted.

Sampling lights and attenuating the light from the surface point P after it travels each step, this solution can be very time-consuming becauce it requires a lot of current sample points along the view vector. So I think it is absolutely necessary to render volume effects separately.

 

I write the template of zjLightFog to put the idea into practice.

Attach zjLightFog to all the geometries in the scene. Make sure that there is some geometry behind the fog to be rendered because PRMan shades surfaces, not volumes. It needs some start point for the Ray March calculating.

The template of Fog that PIXAR provided seems to scatter all lights in the scene, which is not what we expected. I solved the problem by using light category. The illuminace loop only evaluates light(s) from the category of "foglight". Attach zjSpot to the spot light(s) to be scattered, and change the __category to foglight, then reload it.

This is the light fog rendered. Feel free to use techniques such as intensity falloff, barndoor and light blocker to change the light color.

 

 

 

 

 

Color blending between different lights.

 

 

 

 

 

 

 

Catching shadows.

 

 

 

 

 

 

 

 

 

Save the fog pass. It is not necessary to rerender it as long as the camera doesn't change.

 

 

 

 

 

 

Detaching the zjLightFog. This is a much faster normal render without any volume effects.

 

 

 

 

 

 

Composite the fog pass over the normal render in 2D, and change the blending mode to "Screen". That are many tricks can be done in post 2D software, rather faster and easier than in 3D.

 

 

 

 

Another test.