Current stable version: 0.1.1

Volumetrics

Table of content:

 

Introduction.

YafaRay's volumetric features provide a simulation of light interacting with particles suspended in a region of space.  A common volumetrics scenario is the "beam of light" effect, for example when light enters a dusty room through a window creating a visible shaft of light.  YafaRay uses a realistic physics-based model to render volumetrics, and provides a basis for creating not just believable beams of light, but also smoke, clouds, fog, and other volumetric effects.

 

Important: Use PNG or any other lossless format to save renders with volumetrics. JPG compression kills volumetrics detail.

The Basics.

This section gives a brief overview of rendering volumetrics in YafaRay.  Specific parameters and settings are covered in subsequent sections.

Workflow.

There are several basic steps necessary to render volumetrics in YafaRay.  A brief outline of the workflow is:

  1. In the World tab of the YafaRay UI select the single scatter integrator in the volume integrator settings.
  2. Create a box-shaped object (the volume region) in the scene to act as a container for the volumetric effect.
  3. With the volume region object selected go to the Objects tab of the YafaRay UI and activate the Enable volume button.
  4. Ensure at least one light source in the scene illuminates the volume region.

Volume Types.

An important characteristic governing the final appearance of volumetric media is density.  It is intuitively clear that a greater particle density in a volume region equates to a more pronounced volumetric effect.  Also, a method to control density is needed to render effects such as clouds or smoke, which have a variable density.  So in YafaRay there are three different volume types for a region based on how density is controlled:

UniformVolume:  a uniform density volumetric effect, useful for dust, fog, mist, etc.

UniformDensity

ExpDensityVolume:  like a UniformVolume, but decreases the density of the volume as height (in positive z direction) increases.  Useful for ground fog, etc.

ExpDensityVolume

NoiseVolume:  lets a blender procedural texture control the density of the volume, good for clouds, smoke, etc.  Note that this method must be considered a "fake" compared to a realistic cloud or smoke density simulator that is unavailable in YafaRay.

NoiseVolume

One of these volume types can be selected for the volume region once Enable volume is selected.

 

Important:  when using NoiseVolumes the blender texture used must be called TEmytex, so that the texture setup looks like this:

NoiseVolume Texture Name Image

If this exact name is not used blender will crash during the render process and all work will be lost.  This limitation will be removed in the future.

The following sections discuss volumetric settings and parameters in detail.

Volume Integrator.

The volume integrator settings are located in the World tab of the Yafaray UI, underneath the background settings.  The settings here for the Single Scatter integrator pertain to the global precision of volumetric calculations.  These settings have a considerable impact on render speed, and so they are important to control the balance of speed versus quality.

Volume Integrator Settings

Step Size.

This parameter is the main control for the precision of volumetric rendering.  Consider the following example setup with a volume, a camera, and a light source:

Step Size Example

When a viewing ray shot from the camera (the blue lines) intersects a volume, the portion of the ray inside the volume is subdivided into "steps," with the length of each step being the value of the step size parameter (in blender units).  At each step shadow rays are traced to all the light sources in the scene (the red line) to determine how much light reaches the step, and then from this information the total light contribution to the viewing ray is computed.  This calculation at each step is called attenuation.

So the following conclusions about step size can be drawn:

  • Decreasing the step size value means more steps along the viewing ray and more attenuation calculations.  This leads to a more accurate result, at the expense of increased render times.
  • Longer viewing ray segments inside a volume have more steps and therefore require more attenuation calculations than shorter ray segments.

Other Volume Integrator Settings.

Here are the rest of the volume integrator settings:

  • Adaptive:  optimizes stepping calculations for NoiseVolumes, resulting in reduced render times for certain situations.  There is no visual change to the render result by using this option.
  • Optimize:  attenuation calculations can be computationally expensive for certain volumes.  This setting speeds this process by precomputing attenuation in the entire volume at a 3d grid of points.  These results are then interpolated and used as attenuation values at each step of a viewing ray, rather than calculating attenuation directly at this point.  This function is very helpful for reducing render times for NoiseVolumes and ExpDensityVolumes.
  • Att. Grid Resolution:  since the attenuation grid is an estimation, lower values can result in reduced detail in shaded areas.  For many volumes a value of 2 or 3 is sufficient, but for darker ones a higher value may be necessary.

Examples.

Step Size Example

The volume on the left is grainy because the step size is too high (0.5).  A lower step size on the right (0.1) corrects the issue, but is of course slower (four times slower in this case).

Att. Grid Resolution Example

Volumes with Att. Grid Resolution of 1, 3, and 5, plus another with Optimize off for reference.  Notice the improved shading detail with higher grid resolutions.  Even at a grid resolution of 5 the render time was about one third compared to the render without Optimize on.

For reference, the texture settings used for the NoiseVolumes in the previous examples are shown below:

Step Size and Att. Grid Example Texture Settings

Volume Regions.

The volume region defines the general shape and characteristics of a volumetric effect.  Volumetrics only occur inside of a volume region, allowing control over placement of a volumetric effect in a scene.  When a volume region is the active object in a scene the volume settings in the Objects tab of the YafaRay UI control specific aspects of how a volume renders.

Volume Region Tips.

Some quick notes on volume regions:

  • The size of a volume region has a direct effect on render times.  From the discussion on step size it is clear that a bigger volume requires more steps along a viewing ray and more attenuation calculations than a smaller volume.  So it is important for efficient rendering of volumetrics that the volume region be as small as possible.
  • As noted earlier, volume regions cannot be rotated in a scene.  The edges of the volume region object must remain aligned with the global coordinate axes.

Absorption and Scattering.

The volume region settings in the Objects tab control specific qualities related to the look of a volumetric effect.  Each type of volume region (UniformVolume, ExpDensityVolume, NoiseVolume) may have its own unique set of parameters, but every volume region type has parameters controlling two fundamental properties -- absorption (sigma_a) and scattering (sigma_s).

  • sigma_a (absorption):  some volumes absorb a certain amount of light that they receive, for example black smoke from a fire exhibits a lot of absorption.
  • sigma_s (scattering):  scattering occurs when light traveling along a path encounters a particle in a volume and is redirected to a new path.  Scattering affects how the camera detects light in two ways:  light rays heading towards the camera can be redirected away from the camera, and light rays not originally aimed at the camera can be scattered in its direction.  The "beam of light" effect is the result of light being scattered towards the camera.

Examples.

Absorption and Scattering Example

On the left is a volume with only absorption (sigma_a = 0.5), and has a dark smoky appearance.  On the right is the same volume but with scattering added (sigma_s = 0.05), and has a denser, more complex look.

Absorption and Scattering Example Texture Settings

For reference, these are the texture settings used to create the previous example image.

Scattering in Spot Light Example

These show the effect of scattering on light from spot lights.  Notice how the the monkey object blocks light from the lamps, creating a shadowed area in the visible cone of light.  Also note the interaction of the colored lamps in the volume.

Scattering in Area Lights Example

These show the result of area lights in a volume.  Here light from the area lamps is scattered widely across the volume.

Volume Region Types.

This section discusses the different types of volume regions, including parameters and workflow specific to a particular volume type.

UniformVolume.

The UniformVolume type provides a basic uniform density volumetric effect within the volume region.

UniformVolume Settings

The parameters for the UniformVolume are limited to controls for absorption and scattering.  These parameters were discussed in a previous section.

ExpDensityVolume.

The ExpDensityVolume defines a density within the volume region that decreases with increased height (in the direction of the positive z-axis).  This decrease is an exponential rate of decay, controllable using the two parameters height and steepness.  This volume type is useful for effects such as ground fog where the effect is most pronounced close to the ground.

ExpDensity Volume Settings

In addition to parameters for absorption and scattering, the ExpDensityVolume has the following settings:

  • height:  controls the density of the volume before it starts to fall off.  Bigger height values will result in a denser volumetric effect close to the ground.
  • steepness:  controls how quickly the density falls off.  Higher steepness values will result in a quicker transition between the areas of maximum density and no density.

Examples.

ExpDensityVolume Example Image

In the above example H is height and S is steepness.  Notice that increasing the value for height results in a denser volumetric effect near the floor, while decreasing the value for steepness results in a longer and slower transition from dense to not dense.

NoiseVolume.

The NoiseVolume type allows the density of the volume to be controlled by a blender procedural texture.  YafaRay translates the intensity values of a blender texture into density, with darker values on the texture corresponding to lower density and lighter values corresponding to higher density.  This provides a method to approximate the look of different variable-density effects such as steam, smoke, clouds etc.

NoiseVolume Settings.

NoiseVolume Settings

The NoiseVolume has the following unique parameters:

  • Sharpness:  controls how sharp a NoiseVolume looks at the border between areas of high and low density.  With higher values of sharpness a NoiseVolume will look crisper and more distinct at the edges.
  • Cover:  has the effect of defining what percentage of a procedural texture maps to zero density.  As values for cover decrease from 1, a greater percentage of the texture's lowest intensity values map to zero density, creating a sparser volumetric effect with more empty spaces.
  • Density: a global density multiplier.  At the default density value of 1 a procedural texture can sometimes correspond to densities too high or too low to give a useful output.  Adjusting this density parameter can bring the result back to a workable range.

Sharpness and Cover Example

The above example illustrates the effect of both the sharpness and cover parameters (S=sharpness, C=cover). For those interested, the texture settings used to create this example volume are included below:

Sharpness and Cover Example Image Settings

The NoiseVolume Texture.

The blender procedural texture used to control the density of a NoiseVolume is the primary control for how this volume type looks.  First, even though this information was mentioned earlier, it is so important that it will be repeated:

 

Important:  when using NoiseVolumes the blender texture used must be called TEmytex, so that the texture setup looks like this:

NoiseVolume Texture Name

If this exact name is not used blender will crash during the render process and all work will be lost.  This limitation will be removed in the future.

NoiseVolume Texture Example Image

All settings relevant to the use of a procedural texture for a NoiseVolume can be found in blender's texture buttons panel (F6).  Any procedural texture supported by YafaRay can be used as a texture for a NoiseVolume.  More information on YafaRay and procedural textures is available in the Procedural Textures section of the manual.