FogOfWarManager
The FogOfWarManager component is the central coordinator that owns all GPU resources and acts as the bridge between the ECS world and the render pipeline.
Overview
FogOfWarManager is a singleton MonoBehaviour that manages the fog of war system. It creates render textures, uploads vision data to the GPU, and applies the fog effect to cameras with matching tags.
The manager automatically creates a FogConfig ECS entity that ECS systems use to coordinate processing. Disabling the manager GameObject also pauses all ECS fog processing.
FogOfWarManager (Inspector)
Map Bounds
| Property | Type | Default | Description |
|---|---|---|---|
| Left Bound | float |
-5 |
Left edge of the fogable area in world space |
| Right Bound | float |
5 |
Right edge of the fogable area in world space |
| Bottom Bound | float |
-5 |
Bottom edge of the fogable area in world space |
| Top Bound | float |
5 |
Top edge of the fogable area in world space |
Visuals
| Property | Type | Default | Description |
|---|---|---|---|
| Camera Tags | string[] |
["MainCamera"] |
Tags of cameras that receive the fog screen effect |
| Injection Point | InjectionPoint |
AfterRenderingPostProcessing |
URP render pass event at which the fog effect is applied: BeforeRenderingTransparents, AfterRenderingTransparents, BeforeRenderingPostProcessing, or AfterRenderingPostProcessing |
| Unexplored Fog Texture | Texture |
null |
Tiling texture overlaid on unexplored areas (leave null for solid color) |
| Unexplored Fog Tint | Color |
(1, 1, 1) |
Color tint for unexplored areas |
| Explored Fog Texture | Texture |
null |
Tiling texture for areas that have been explored but are not currently visible |
| Explored Fog Tint | Color |
(0.5, 0.5, 0.5, 0.5) |
Color tint for explored areas |
| Fade In Duration (seconds) | float |
0.2 |
Time for fog to clear when an area enters vision |
| Fade Out Duration (seconds) | float |
0.2 |
Time for fog to return when an area leaves vision |
| Entity Fade Duration (seconds) | float |
0.2 |
Time for entity fade transitions (used by UpdateVisibilitySystem) |
| Filter Mode | FilterMode |
Bilinear |
Filtering applied to fog render textures: Point, Bilinear, or Trilinear |
| Blur Strength | float |
3 |
Gaussian blur intensity (0 = no blur, 3 = maximum) |
Vision Layers
| Property | Type | Default | Description |
|---|---|---|---|
| Layers | Texture |
null |
Optional RGBA texture that defines areas where vision can reveal fog. Each channel (R, G, B, A) creates a separate layer that can be matched with vision sources. White areas allow vision, black areas block it. This enables features like team-specific vision or terrain-based visibility restrictions (see Vision Layers) |
Performance
| Property | Type | Default | Description |
|---|---|---|---|
| Texture Size | Vector2Int |
(1024, 1024) |
Resolution of internal fog render textures. Higher values produce more accurate fog boundaries and less pixelated edges, but consume more GPU memory |
| Max Vision Sources | int |
100 |
Maximum number of vision sources that will be processed per frame. If more vision sources exist in the scene, the excess will be ignored |
Public API
GetDataToSave() → Vector2Int[]
Returns a run-length encoded representation of the explored area. Each Vector2Int stores the start (inclusive) and end (exclusive) pixel index of a run of explored pixels.
Load(Vector2Int[] data)
Restores a previously saved explored state by writing data back into the internal render texture.