Fog Examples

Plasma fog

Plasma like fog, that is, fog which is self illuminating, can be simulated by the following VSL structure:

  • The first two VSL objects in the Surface properties shader make the fog surface invisible. Assigning the value of 2 to the Volume sampling channel activates the volume effects: the interior of the fog cloud is studied by taking two samples at suitable intervals. For a simple fog like this, even a smaller value of 1 would suffice.

Example file: tutorprojects/material/vsl/plasma

Linear fog

The rendering system handles the blending of fog effects to other illumination automatically. The blending ratio is defined by the Turbidity property, which defines the density of the fog. The blending process is not linear: The longer the distance, which the light travels inside the fog, the stronger the influence of the fog becomes, but the fog never stops the ray completely.

The example image shows the structure of a material, which overrules this default fog shading. The fog effect defined by it is linear: if a layer of say 1 meter changes the illumination traveling through it by 50 %, then two meters of fog hides the background completely. The density of the fog defines the distance, which is required for full impenetrability.

  • Turbidity channel is not used at all. The material computes and assigns the fog effect to the illumination channel. Leaving turbidity to zero means that no default shading will take place.

  • The fog is similar to the previous example in that it is self-illuminating.

Example file: tutorprojects/material/vsl/linearfog

Shadows in fog

The two fog types presented above are self-illuminating: light sources do not affect them at all. A fog that reacts with light can be obtained by the following VSL code:

  • The interaction with light sources is obtained by assigning a non-zero value to the Volume:Color channel in the Volume properties shader. The color channel defines the diffuse shading properties of the fog particles.

  • The Volume sampling channel has now a much higher value than in the previous example. The higher the value, the more accurately the shape and details of the shadows inside the fog are rendered.

Example file: tutorprojects/material/vsl/shadowfog

Additive fog

The Linear fog example above explained how to define custom fog shading for a self-illuminating plasma fog using the Volume properties shader. It is possible to customize the default fog shading of fog that reacts with light in the Volumetric shading shader, which is evaluated after fog illumination computations.

The material below shows one such example, additive fog. The fog is diffusely illuminated. It has the special property that it never darkens the illumination behind it. A normal fog does this: black smoke can hide flames of fire.

  • Density is a parameter that the controls the thickness of the fog.

  • Sampling defines how accurately the shadows in the fog are computed.

  • The main parameters are initialized in the Material initialization shader.

  • The Surface properties shader makes the fog surface transparent, removes diffuse shading from it (Color=black) so that the surface becomes clear, and launches volumetric sampling by copying the sampling parameter to the Volume sampling channel.

  • The Volume properties shader does not set the Turbidity channel, which controls default shading of the fog. Instead, it moves the sample position randomly along the traced ray. The sampling density and distance control the amount of random movement. Therefore, the random variation keeps the samples inside the fog. The random factor improves quality and helps to detect small shadows.

  • Volume shading computes fog illumination, which is proportional to density and distance. This illumination is simply added to any previous illumination. This makes the fog additive.

Example file: tutorprojects/material/vsl/additivefog

Shadows by fog

This example demonstrates how to use the Volume filtering shader. In this shader, it is possible to define how the interior of a material creates shadows. The shadowing property is defined by assigning suitable values to the VFilter:Transparency channel in the Volume filtering shader.

The VSL hierarchy is:

  • The rather complex computations in the Volume filtering shader take care of several details: they produce a shadow, whose intensity is proportional to the square of the distance which the light travels in the fog. The intensity is modified by some Noise and the shadow color is smoothly faded to white at edges.

  • The rather complex computations in the Volume filtering shader take care of several details: they produce a shadow, whose intensity is proportional to the square of the distance which the light travels in the fog. The intensity is modified by some Noise and the shadow color is smoothly faded to white at edges.

  • The shadow in the example project is quite subtle and it is hard to tell if it is really the interior and not the surface, which creates the shadow. The difference becomes important in animations where objects and/or light sources are inside the fog. In other situations, it may be a better solution to create the shadow on the surface, because volumetric filtering is quite a time consuming feature. Especially, when both volumetric illumination and volumetric filtering are activated (like in the example), lots of computations are required, because the interior of the fog creates shadows in the interior of the fog. Therefore, the rendering time required by volumetric effects becomes proportional to the square of the sampling density - a 10 times higher sampling rate takes 100 times longer to render.

  • Volumetric effects, Lighting in volume and Volume shadows in the Render settings/Ray tracing options must be enabled when rendering this example.

Example file: tutorprojects/material/vsl/shadowbyfog