Enhanced Compatibility

intermediate concepts

Volumetric Fog & Mist (Built-in) · Core Concepts

Enhanced Compatibility

Volumetric Fog & Mist 2 integrates with a variety of third-party assets and Unity features. This page covers compatibility notes and setup instructions.

Sprite Compatibility

Standard Unity sprite shaders do not write to the Z-buffer, which prevents correct fog interaction. Two custom sprite shaders are included:

MaterialLocationUse Case
SpriteFogDiffuseResources/Extras/Diffuse-lit sprites
SpriteFogUnlitResources/Extras/Unlit sprites

Assign one of these materials to your Sprite Renderers to make sprites fully compatible with the fog image effect.

Time of Day

Assign the Sun game object from Sky Dome to the Sun field in the VolumetricFog Inspector. The fog will synchronize direction and color with the time-of-day cycle.

Enviro

Add the VolumetricFogDayCycleManager script to any game object in your scene. It modifies fog colors and densities during the day according to the time provided by Enviro.

Other Sky Managers

Two parameters need attention with sky dome assets:

  • Sky Depth — reduce the value under Sky Haze section to match the sky dome distance.
  • Sun orientation — drag any game object representing the current sun direction into the Sun property.

Gaia

Volumetric Fog & Mist is available from Gaia's Extension Manager with one-click preset buttons for quick configuration.

Horizon[ON]

Compatible with the real terrain only. You may need to reduce Max Distance and combine with Horizon[ON]'s own fog for long-distance coverage.

Custom Surface Shader Integration

Embed the fog effect directly into surface shaders for perfect transparency handling.

Step 1 — Modify the Shader

  1. Locate the #pragma surface line. Add noinstancing finalcolor:overlayFog at the end. Use overlayFogStandard for Standard shaders or overlayFogStandardSpecular for specular setup.
  2. Add optional keyword pragmas before the surface line:
    // Distance fog (optional)
    #pragma multi_compile_local __ FOG_DISTANCE_ON
    // Point lights (optional)
    #pragma multi_compile_local __ FOG_POINT_LIGHTS
    // Sun shadows (optional, slow compilation)
    #pragma multi_compile_local __ FOG_SUN_SHADOWS_ON
  3. Ensure the Input struct contains float4 screenPos and float3 worldPos.
  4. Include the overlay after the Input struct:
    #include "Assets/VolumetricFog/Resources/Shaders/VolumetricFogOverlay.cginc"

Step 2 — Add Integration Script

Add the VolumetricFogMaterialIntegration component to the camera with VolumetricFog.

Step 3 — Register Objects

Drag one game object per unique material into the Materials list. Only one object per shader is needed since they share the same material properties.

Custom Vertex/Fragment Shader Integration

Similar process for vertex/fragment shaders:

  1. Add the optional keyword pragmas after other #pragma lines.
  2. Include the overlay before the vertex shader:
    #include "Assets/VolumetricFog/Resources/Shaders/VolumetricFogOverlayVF.cginc"
  3. Add to your vertex output struct: float3 worldPos and float4 screenPos.
  4. At the end of your fragment shader:
    col = overlayFog(i.worldPos, i.screenPos, col);
  5. Add VolumetricFogMaterialIntegration to the camera and register objects.
Tip: Check the DemoIntegration scene for complete working examples of both surface and vertex/fragment shader integration.
Was this page helpful?