Skip to content

Advanced

This page covers advanced technical details about the RTS Fog of War system, including URP rendering requirements, automatic configuration validation and global shader properties.

URP Depth Texture Requirement

The Fog of War system requires the Depth Texture feature to be enabled in the Universal Render Pipeline (URP) asset for proper functionality.

Automatic Validation

The system includes an automatic validator that checks and enables the Depth Texture setting when the project loads in the Unity Editor. If the setting is disabled, the validator will:

  1. Automatically enable Depth Texture in your active URP asset
  2. Save the changes to the asset
  3. Display a warning message in the Console with a reference to the modified asset

Validator Implementation

The validator runs automatically via [InitializeOnLoadMethod] when Unity loads, ensuring the correct URP configuration without manual intervention.

Warning

Disabling the Depth Texture after it has been automatically enabled may cause the fog effect to not render correctly.

Global Shader Properties

The Fog of War system communicates with shaders through global shader properties. These properties are automatically set by the FogOfWarManager and can be accessed in custom shaders.

Property Name Type Description
_CurrentFog Texture2D Contains the current vision state (areas currently visible to vision sources)
_AllFog Texture2D Contains both discovered and current vision data (R: discovered, G: current)
_FogOfWar_Texture Texture2D The final processed fog texture with blur applied
_FogOfWar_Orientation float Map orientation: 0 = XY plane, 1 = XZ plane
_FogOfWar_MapOffset Vector2 The center point of the map bounds in world space
_FogOfWar_MapSize Vector2 The dimensions of the map (width and height)
_FogOfWar_Color Vector3 The fog color in linear color space
_FogOfWar_Enabled float Fog enabled state: 0 = disabled, 1 = enabled