Enhanced Compatibility
intermediate conceptsVolumetric 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:
| Material | Location | Use Case |
|---|---|---|
| SpriteFogDiffuse | Resources/Extras/ | Diffuse-lit sprites |
| SpriteFogUnlit | Resources/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
- Locate the
#pragma surfaceline. Addnoinstancing finalcolor:overlayFogat the end. UseoverlayFogStandardfor Standard shaders oroverlayFogStandardSpecularfor specular setup. - 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 - Ensure the Input struct contains
float4 screenPosandfloat3 worldPos. - 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:
- Add the optional keyword pragmas after other
#pragmalines. - Include the overlay before the vertex shader:
#include "Assets/VolumetricFog/Resources/Shaders/VolumetricFogOverlayVF.cginc" - Add to your vertex output struct:
float3 worldPosandfloat4 screenPos. - At the end of your fragment shader:
col = overlayFog(i.worldPos, i.screenPos, col); - Add
VolumetricFogMaterialIntegrationto the camera and register objects.
Suggest an improvement
Help us improve this documentation page.