Introduction
In this chapter we'll cover one of the types of volumetrics, available in V-Ray - Environment fog. EnvironmentFog is an atmospheric effect that allows the simulation of participating media like fog, atmospheric dust and so. Volumetric properties can be determined by 3d texture maps.
Parameters
The plugins we're interested in are VolumeFog, VolumeScatterFog and EnvironmentFog. The parameters of the each one are a subset of the parameters of the next, so we'll cover only the third one.
- color - Defines the color of the fog, when it is illuminated by light sources. For more information, see The Fog Color example below.
- color_tex - Defines the color of the fog, when it is illuminated by light sources. You can also use a texture map to drive the fog color.
- color_mult - Fog color multiplier
- emission - Fog emission color. Controls the fog emission (self-illumination). You can use this parameter to substitute the ambient illumination inside the fog, instead of using GI.
- emission_tex - Fog emission texture. Controls the fog emission (self-illumination). You can use this parameter to substitute the ambient illumination inside the fog, instead of using GI.
- emission_mult - Fog emission multiplier.
- emission_mult_tex - Fog emission multiplier texture.
- distance - Distance between fog particles. Controls the fog density. Larger values make the fog more transparent, while smaller values make it more dense.
- density - Fog density. A multiplier for the Fog distance parameter.
- density_tex - Texture for fog density. A multiplier for the Fog distance parameter that allows a texture to be used for the density of the fog.
- scatter_gi - When on, the fog will also scatter global illumination. Note that this can be quite slow. In many cases, global illumination within the fog can be substituted with a simple emission term. When this option is on, the currently selected global illumination algorithm in the V-Ray settings will be used to accelerate GI inside the volume (e.g. the irradiance map, light cache, photon map or brute-force).
- scatter_bounces - When Scatter GI is enabled, this controls the number of GI bounces that will be calculated inside the fog. For more information, see The Scatter GI and Scatter Bounces example below.
- use_height - Whether or not the height should be taken into account.
- height - Fog starting point along the up-axis. By default the up axis is Z.
Sampling parameters
EnvironmentFog can use either of two algorithms to calculate volumetric lighting. The first algorithm is a simple exponential sampling scheme, which is used when there are no texture maps specified. In this mode, EnvironmentFog takes a number of random points inside the volume and calculates the volumetric lighting at those points. The second algorithm is a raymarching scheme, which is used when any of the volume properties are mapped with a texture. In that case, EnvironmentFog traverses the fog volume in small steps, calculates the volume properties at each step and computes the volume lighting accordingly. For more information, see The Sampling Parameters without textures example below.
Exponential sampler
This sampler is used when there are no texture maps specified, in which case the volume properties are the same everywhere.
- subdivs - This parameter determines the number of points inside the fog at which volumetric lighting is evaluated. Smaller values for this parameter render faster, but may produce noise in the image. Higher values render longer, but with less noise. It is only used when there are no texture maps specified, in which case the volume properties are the same everywhere.
Raymarching sampler
This sampler is used when any of the fog properties (color, density, or emission) is mapped with a 3d texture. The sampler steps through the volume, evaluating volumetric textures and lighting, until it leaves the volume (if there are atmospheric gizmos specified), or until the accumulated volume transparency falls below a certain cut-off threshold, or until a specified number of maximum steps is reached. For more information, see The Sampling Parameters (raymarcher with textures) example below.
- step_size - Determines the size of one step through the volume. Smaller steps produce more accurate results but are slower to render. In general, dense volumes require smaller step sizes than more transparent volumes. In practice, step sizes that are two to three times smaller than the Fog distance parameter work well.
- tex_samples - Number of texture samples for each step through the volume. This allows to sample textures more accurately than the volumetric lighting. It is useful in cases where the textures vary much faster than the lighting itself (e.g. for detailed fractal textures).
- cutoff_threshold - Controls when the raymarcher will stop traversing the volume. If the accumulated volume transparency falls below this threshold, the volume will be considered opaque and tracing will be aborted. Higher values make the rendering faster but may introduce artifacts.
- max_steps - Maximum number of steps through the volume.
Ray filter
This section allows you to choose what type of rays are affected by the atmospheric effect
- affect_background - When this option is off, the background will not be obscured by the fog.
- affect_reflections - Specifies whether the fog will be rendered in reflections.
- affect_refractions - Specifies whether the fog will be rendered in refractions.
- affect_shadows - Specifies if the fog should affect shadow rays.
- affect_gi - Specifies if the fog should affect GI rays.
- affect_camera - Specifies if the fog will be visible to camera rays.
Others
- enabled - If false, disable the rendering
- gizmos - A list of atmospheric gizmos and arbitrary meshes within which the fog will be calculated. Note that when using a mesh acting as a Gizmo you should either hide it or make it not renderable in order to be able to see the atmospheric effect inside the mesh. For more information, see The Gizmo nodes example below.
- opacity_mode - If true, density will be treated as opacity.
- yup - If true, y is the up axis, not z.
- solid_mode - If true, this will cause to disable randomization when sampling and take 1 sample at 0.5 density.
- solid_threshold - Solid mode transparency threshold
- jitter - If true, add a random offset when starting sampling.
- shadow_opacity - Volume opacity scale for shadow rays.
- scale - List of floats, stretch aspect for the 3 axis, when the fog container must grow/shrink preserving its original density
- deep_output - Toggle the deep image output. Note that enabling this option will force ray marching even for simple volumetrics, which can cause slower rendering.
- ior - Index of refraction for the volume, which describes the way light bends when crossing the material surface. A value of 1.0 means the light will not change direction.
- fade_out_mode - fade out mode 0: Multiply by density, 1: Add density to falloff
- fade_out_radius - fade out effect for the edges
- per_object_fade_out_radius - fade out effect for the edges per object
- simplify_gi - Simplify global illumination. When this option is checked V-Ray will use a simplified method for calculating the GI when rendering parts of the fog that are textured or are being faded out.
- light_mode - light mode 0: no lights, 1: Use per-gizmo lights, 2: Override per-gizmo lights, 3: Intersect with per-gizmo lights, 4: Add to per-gizmo lights
- lights - A list with lights. How they affect the fog depends on the 'Light mode' parameter as well.
- use_shade_instance - True if the shade instance should be used when sampling textures.
- use_shade_data - True if the shade data should be used when sampling textures. The light mode will be ignored if this is true and the shader is not global!
Examples
Environment Fog
The following example is rendered using this scene. Check the comments inside to see how it is configured.
Volume Fog Shader
The following examples are rendered using the scenes from this bundle. See the comments on the different parameters and comment/uncomment the #include
s to see the different capabilities of the Volume fog shader.
Environment
Scatter
Volume
Fog color
This example demonstrates the effect of the fog Color. Note how color only changes the way the volume reacts to light, and not the volume transparency. A sphere shaped as the V-Ray logo has been used to confine the fog volume with the Environment Fog set as the Volume material in the shading group of the sphere. The opacity of the sphere's Surface material has been set to be 100 transparent by changing its Opacity Map to a black color. This means the Surface material has no contribution to the shading of the sphere, only the Environment Fog material.
For the last 2 images, the fog Color has been mapped with a texture. World XYZ mapping type was used for the textures.
Move the slider to see the example renders.
Fog distance
This example demonstrates the effect of the Fog distance parameter. Note how larger values make the fog more transparent. A sphere shaped as the V-Ray logo has been used to confine the fog volume with the Environment Fog set as the Volume material in the shading group of the sphere. The opacity of the sphere's Surface material has been set to be 100 transparent by changing its Opacity Map to a black color. This means the Surface material has no contribution to the shading of the sphere, only the Environment Fog material.
Move the slider to see the example renders.
Fog emission
This example demonstrates the effect of the Emission parameter. The Fog color is gray so as to better show the effect of the emission. Note that since we also have GI enabled, the fog emission causes the volume to illuminate both itself and other objects around it. The fog density is mapped with a Checker texture. A sphere shaped as the V-Ray logo has been used to confine the fog volume with the Environment Fog set as the Volume material in the shading group of the sphere. The opacity of the sphere's Surface material has been set to be 100 transparent by changing its Opacity Map to a black color. This means the Surface material has no contribution to the shading of the sphere, only the Environment Fog material.
In the last two renders, the Emission has been mapped with a texture. The Color is gray to better show the light scattering inside the volume, produced by the global illumination.
Move the slider to see the example renders.
Scatter GI and Scatter bounces
This example demonstrates the effect of the Scatter GI and Scatter bounces parameters. Note how multiple scattering of light inside the volume greatly increases the realism of the image.
Move the slider to see the example renders.
Example: Importance of GI
GI scattering is especially important when creating cloud-like volumes. For example, compare the following two images, done with and without GI scattering.
Global illumination is off
Global illumination is on with Scatter GI on and Scatter bounces set to100
The following example shows GI scattering inside a smoke volume. The volumetric textures (density and emission) for this example are provided from a fluid dynamics simulation in the form of 3D textures. Note how GI scattering causes the smoke to be naturally illuminated by the fire in the second row of images.
Fog height
When there are no geometry nodes connected to Environment Fog, the volume occupies space downward from a certain height along the scene's up-axis, determined by the Fog height parameter. The following examples demonstrate this. Note that as the Fog height is increased, the scene becomes darker - this is because the sun is blocked by a larger amount of fog. This can be corrected by increasing the Fog distance parameter and thus making the fog more transparent. Note also the sudden decrease of brightness when the camera is included inside the fog volume.
Move the slider to see the example renders.
Move the slider to see the example renders.
Sampling parameters (without textures)
When any of the parameters (density, color or emission) is mapped with a texture, VRayEnvironmentFog uses a raymarching algorithm to compute the intersection of a ray with the volume.
The following examples demonstrate the effect of the Step size parameter. A Box is used to confine the volume, and the density is mapped with a Checker texture. Note how smaller values cause less noise and smoother shading of the volume. Note also that denser volumes require smaller values of the Step size parameter in order to produce a smooth result compared to more transparent volumes. In general, values for the Step size that are 2 to 3 times smaller than the Fog distance parameter work okay in most cases.
Move the slider to see the example renders.
Sampling parameters (raymarcher with textures)
The following example demonstrates the effect of the Texture samples parameter. This parameter allows for more accurate sampling of textures with rapid changes, without the need to increase the Step size parameter, and thus saving render time.
Move the slider to see the example renders.
Gizmo nodes
When there are gizmos connected to VRayEnvironmentFog , then the volume is confined only inside the specified atmospheric gizmos and the Fog height parameter is ignored.
Volumetric caustics
This example demonstrates volumetric caustics and colored shadows with different settings.
Move the slider to see the example renders.
The quality of the volumetric caustics depends on the sampling of the volume fog, on the V-Ray caustics settings, and the caustics settings for the light. In both images below, all parameters are same with the exception of the caustics subdivs for the light in the light settings dialogue. Note how the more photons are shot, the more defined the caustics are. In this example, we also have the caustics Max. density parameter set to 0.3 in order to limit the photon density in the caustics map. This saves memory and makes the rendering faster, although it limits the spatial resolution of the caustics (in our case, to 0.3 scene units).
Compare the two examples where the light has 1000 Caustics subdivs (500,000 caustics photons are shot) and 200 Caustics subdivs (20,000 caustics photons are shot).
Note the broken caustics beam in the example with 1000 Caustics subdivs - this is not because there are not enough caustics photons, but because we don't have enough samples for the fog itself.
Aerial Perspective
The following example is rendered using this scene. Check the comments inside to understand different parameters of the plugin.
When using EnvironmentFog with weak lights, it may be necessary to turn down the Cut-off threshold parameter of the lights. The default value for this parameter works fine for surfaces, but for volumes, where a lot of weak light contributions are added together, it may produce a visible sharp boundary where the light calculations stop.
V-Ray does not have separate global illumination maps for volumetric rendering. Instead, all GI engines (the irradiance map, light cache, global/caustics photon maps) have been modified to support volumetric data.