skip to Main Content

Enhanced compatibility

Enhanced Sprite Compatibility

Standard Unity sprite shaders are not compatible with Image Effects as they are not rendered as 3D objects and don’t write to Z-Buffer on real world positions. That forces Image Effects to be rendered before the transparent queue so at least sprites (as particles) are not covered by the Image Effect. This cause that sprites look floating over the scene as the fog makes them clearly separated from rest of the scene.

To avoid the problem described above, Volumetric Fog & Mist includes two custom sprite shaders found in Resources/Extras folder. You will find two materials with names SpriteFogDiffuse and SpriteFogUnlit, which you may just assign to your Sprite Renderers to make Sprite fully compatible with the Image Effects.

Compatibility with Time of Day

If you use Time of Day asset, you may assign the Sun game object found under Sky Dome to the Sun field in the Volumetric Fog & Mist inspector. That will sync the direction and color of the Sun light with the fog.

Compatibility with Enviro

If you use Enviro asset, you can add “VolumetricFogDayCycleManager” script to your any object in your scene (ie. the same camera where you have Volumetric Fog) to modify colors and densities during the day according to the time of day provided by Enviro.

Compatibility with other Sky Managers

The compatibility with Sky managers in Volumetric Fog & Mist affects two parameters:

  • Depth of skybox: many sky managers use a “Sky Dome” to render the sky. This sky dome is a big sphere that surrounds the scene. To allow sky haze work with sky domes, reduce the sky depth parameters under the sky haze section.

  • Sun orientation: fog lighting will adapt automatically to the Sun orientation. Just drag and drop any gameobject that reflects current Sun direction onto the Sun property in the inspector.

Compatibility with Gaia

Volumetric Fog & Mist is also available from Gaia’s Extension Manager. You will find a list of convenient buttons that configures and select the different presets of Volumetric Fog & Mist in just one click.

 

Compatibility with Horizon(ON)

Volumetric Fog & Mist has been tested with recent versions of Horizon(ON). It will only work with the real terrain though, so you will probably need to reduce the max distance factor and combine Volumetric Fog & MIst with the fog effect provided by Horizon(ON) for the long distance.

Compatibility with other shaders (surface shaders)

Although Volumetric Fog & Mist provides methods to render before/after transparent objects, it’s also possible to embed the fog effect into other complex shaders so the fog is rendered in the same pass. This solution solves some problems related with transparency.

To integrate Volumetric Fog & Mist in an existing surface shader, please follow these steps:

Step 1: Apply the following changes to your shader:

  • Edit the surface shader and locate the line starting with #pragma surface …”. Add “noinstancing finalcolor:xxx” at the end of the same line (without quotes) where xxx can be overlayFog (regular surface shaders), overlayFogStandard (standard surface shader) or overlayFogStandardSpecular (standard surface shader with specular setup). If “fullforwardshadows” is present, you may want to remove it to reduce compilation time if not needed.
  • Insert the following lines just before the #pragma surface line (only if you wish this features):
// Insert only if you want to use the distance fog option
#pragma multi_compile_local __ FOG_DISTANCE_ON

// Insert only if you want point lights to affect the material
#pragma multi_compile_local __ FOG_POINT_LIGHTS

// Insert only if you want shadows over the fog in the material (compilation can take a very long time!)
#pragma multi_compile_local __ FOG_SUN_SHADOWS_ON
  • Locate the Input struct declaration and add the following fields if they’re not already present:
struct Input {
   ...
   float4 sreenPos;
   float3 worldPos;
}
  • Add this line just after the Input struct declaration:
#include "Assets/VolumetricFog/Resources/Shaders/VolumetricFogOverlay.cginc" 

(if you have moved VolumetricFog to another location please include the appropriate path)

  • Save changes.

Step 2: Add “VolumetricFogMaterialIntegration” script to the Camera where Volumetric Fog is attached.

Step 3: Finally, drag & drop the game objects that use the surface shader to the Materials list of the Volumetric Fog Material Integration inspector. Important: it’s only necessary to have one object per modified shader added to the list. For example, if you have 2 lakes or rivers with same material, just add one of them as they will be sharing the same material hence the same properties.

Tip: check demo scene DemoIntegration for a working example.

Compatibility with other shaders (vertex/fragment shaders)

Although Volumetric Fog & Mist provides methods to render before/after transparent objects, it’s also possible to embed the fog effect into other complex shaders so the fog is rendered in the same pass. This solution solves some problems related with transparency.

To integrate Volumetric Fog & Mist in an existing vertex/fragment shader, please follow these steps:

Step 1: Apply the following changes to your shader:

  • Apply the following changes to your shader:
    • Insert the following lines just after any other #pragma line:
// Insert only if you want to use the distance fog option
#pragma multi_compile_local __ FOG_DISTANCE_ON

// Insert only if you want point lights to affect the material
#pragma multi_compile_local __ FOG_POINT_LIGHTS

// Insert only if you want shadows over the fog in the material (compilation can take a very long time!)
#pragma multi_compile_local __ FOG_SUN_SHADOWS_ON
    • Add this line just before the vertex shader declaration:
#include "Assets/VolumetricFog/Resources/Shaders/VolumetricFogOverlayVF.cginc" 

(If you have moved VolumetricFog to another location please include the appropriate path)

    • Add this line to the end of the fragment shader:
// apply fog
col = overlayFog(i.worldPos, i.screenPos, col);

Note that you must supply the “worldPos” and “screenPos” paramters. Refer to the demo scene “DemoIntegration” for a full example of integrated shaders.

float3 worldPos : TEXCOORD1;
float4 screenPos : TEXCOORD2;
    • Save changes.

Step 2: Add “VolumetricFogMaterialIntegration” script to the Camera where Volumetric Fog is attached.

Step 3: Finally, drag & drop the game objects that use the surface shader to the Materials list of the Volumetric Fog Material Integration inspector. Important: it’s only necessary to have one object per modified shader added to the list. For example, if you have 2 lakes or rivers with same material, just add one of them as they will be sharing the same material hence the same properties.

Tip: check demo scene DemoIntegration for a working example.

Tip: check demo scene DemoIntegration for a working example.

Back To Top