Special Features
intermediate conceptsDynamic Fog & Mist 2 (Built-in) · Features
Overview
Beyond the basic fog effect, Dynamic Fog & Mist 2 includes several specialized features: fog volumes for zone-based transitions, fog of war for strategy games, VR support, and gradient fog for artistic control.
Fog Volumes
Fog volumes let you define zones where fog properties automatically change when the player enters or exits.
Setup
- Go to GameObject > Create Other > Fog Volume.
- Position the volume and adjust the Collider bounds to cover the desired area.
- In the Inspector, configure:
- Target Profile — a
DynamicFogProfileScriptableObject with the desired fog settings. - Target Fog Alpha / Sky Haze Alpha — opacity values inside the volume.
- Target Fog Colors — color1 and color2 for the zone.
- Transition Duration — how long (in seconds) the blend takes.
- Target Profile — a
Fog of War (Image Effect)
The image-effect fog of war lets you clear circular or rectangular areas of fog via scripting. This works with any camera perspective.
Setup
- Enable Fog of War in the DynamicFog inspector.
- Set the Center and Size of the fog-of-war region (default: centered at origin, 1024 x 1024).
- Adjust Texture Size to control the resolution of the transparency map (higher = more precise clearings).
Scripting
DynamicFog fog = DynamicFog.instance;
// Clear a circular area around the player
fog.SetFogOfWarAlpha(player.position, 10f, 0f);
// Clear a rectangular area
fog.SetFogOfWarAlpha(bounds, 0f, 0.5f);
// Query fog value at a position
float alpha = fog.GetFogOfWarAlpha(worldPosition);
// Reset all cleared areas
fog.ResetFogOfWar();
You can also create static fog-of-war holes: GameObject > Create Other > Dynamic Fog > Dynamic Fog of War Hole.
Fog of War (Dedicated Prefab)
For top-down perspectives, the dedicated FogOfWarLayer prefab provides better performance than the image-effect approach because it uses a mesh-based shader instead of a full-screen pass.
Setup
- Drag the
FogOfWarLayerprefab fromDynamicFog/Resources/Prefabsinto your scene. - Position the plane over the terrain or area to cover.
- Use the
DynamicFogOfWarAPI:
DynamicFogOfWar fog = DynamicFogOfWar.instance;
// Optional: smooth cut along terrain edges
fog.SetFogWarTerrainBoundary(terrain, borderSize);
// Clear fog at a position
fog.SetFogOfWarAlpha(worldPosition, radius, alpha);
// Reset to fully opaque
fog.ResetFogOfWar();
// Control texture resolution
fog.fogOfWarTextureSize = 512;
VR & Single Pass Stereo Rendering
Dynamic Fog & Mist fully supports VR with Single Pass Stereo Rendering. It has been tested with Oculus and OpenVR SDKs.
| Setting | Action |
|---|---|
| Single Pass Stereo in Player Settings | Enable the Single Pass Stereo checkbox in the DynamicFog inspector (auto-detected from Player Settings — just verify it matches). |
| Multi-Pass Stereo | No special configuration needed. |
Gradient Fog
Dynamic Fog exposes two color selectors (Color and Color 2) that blend together to create artistic fog gradients. Use this to achieve sunrise/sunset fog transitions, eerie green-to-purple mist, or any custom color blend.
Next Steps
- Scripting Reference — full API for runtime fog control.
- Performance Tips — optimize fog for your target platform.
Suggest an improvement
Help us improve this documentation page.