Fog of war reference
The fog of war, what reveals it, what it hides, the URP pass that draws it, and the server-side visibility check. For how to use it, see Fog of war.
VtFogOfWar
Component. Add it with Add Component → Vantage → Fog Of War → VtFogOfWar.
Top-down RTS fog-of-war singleton. Maintains a visibility texture over the terrain with three logical states per texel: Unexplored, Explored, Visible. Other systems query IsVisible / IsExplored to dim or hide objects per-tile.
Inspector fields
Toggle
| Field | Type | Default | Range | Description |
|---|---|---|---|---|
Fog Enabled (fogEnabled) |
bool |
On | Update and draw the fog. Off hides the fog and every position counts as visible. |
Resolution
| Field | Type | Default | Range | Description |
|---|---|---|---|---|
Pixels Per Unit (pixelsPerUnit) |
int |
4 | 1 to 16 | Texels per world unit. 4 gives smooth circle edges at modest memory (256² for a 64-unit map). |
Appearance
| Field | Type | Default | Range | Description |
|---|---|---|---|---|
Explored Alpha (exploredAlpha) |
float |
0.8 | 0 to 1 | Alpha used for explored-but-not-currently-visible texels (0 = clear, 1 = opaque). |
Unexplored Alpha (unexploredAlpha) |
float |
1 | 0 to 1 | Alpha used for unexplored texels. 1 = fully opaque black. |
Visible Alpha (visibleAlpha) |
float |
0 | 0 to 1 | Alpha used for currently-visible texels. 0 = fully clear. |
Fade Speed (fadeSpeed) |
float |
8 | ≥ 0.1 | Lerp rate for fog alpha transitions. Higher = snappier, lower = smoother fade. |
Edge Softness (edgeSoftness) |
float |
0.8 | 0.1 to 1 | Fraction of a source’s radius where the fog begins to fall off (0.8 = soft 20% rim). |
Performance
| Field | Type | Default | Range | Description |
|---|---|---|---|---|
Updates Per Second (updatesPerSecond) |
float |
20 | ≥ 0 | How often the fog is recomputed and uploaded. Fades keep their speed at any rate. 0 updates every frame. |
Scripting API
| Member | Description |
|---|---|
static VtFogOfWar Instance { get; } |
The fog of war in the scene, or null when there is none. |
bool FogEnabled { get; set; } |
Is fog updating and rendering right now. |
VtFogField Field { get; } |
The fog data behind the textures, built on first use. Rebuilt by Reinitialize. |
Rect WorldRect { get; } |
The ground the fog covers, on the XZ plane: x/y are the world X and Z of its minimum corner, width/height its size. |
Texture2D OverlayTexture { get; } |
The fog as a black texture whose alpha is the fog’s opacity, row 0 at the minimum Z of WorldRect. Made on first use and kept current with every fog update from then on, for a minimap or any UI that draws the fog over a picture of the ground. |
static void RegisterSource(IVtVisionSource source) |
Register a source so the fog reveals around it each frame. |
static void UnregisterSource(IVtVisionSource source) |
Stop revealing around the given source (does not un-explore what was seen). |
bool IsVisible(Vector3 worldPos) |
True if the given world position is currently visible (not just explored). Returns true unconditionally when fog is disabled. |
bool IsExplored(Vector3 worldPos) |
True if the given world position has been seen at least once. True unconditionally when fog is disabled. |
void Reinitialize() |
Rebuild the fog texture / overlay using the current terrain size. Call after world generation resizes the terrain — otherwise the fog grid is sized for the pre-resize terrain and the reveal-around-player math maps to the wrong texels. |
VtVisionSource
Component. Add it with Add Component → Vantage → Fog Of War → VtVisionSource.
Reveals the fog of war around this object. Attached by VtUnit when the definition’s VtUnitDefinition.visionRadius is above 0, or add it by hand to anything else that should see: a watchtower, a scout drone, a torch.
Inspector fields
| Field | Type | Default | Range | Description |
|---|---|---|---|---|
Radius (radius) |
float |
10 | ≥ 0 | How far this source reveals, in world units, before Vision Radius modifiers. |
Scripting API
| Member | Description |
|---|---|
Transform Transform { get; } |
This object’s transform; the fog is revealed around its position. |
float VisionRadius { get; } |
How far this source reveals right now: radius with the owner’s Vision Radius modifiers applied. Never negative. |
VtFogOfWarCuller
Component. Add it with Add Component → Vantage → Fog Of War → VtFogOfWarCuller.
Applies the VtFogOfWar state to every VtFogCullable in the scene, a few times a second. Put one in the scene next to the fog of war. Each cullable carries its own rule through VtFogCullable.Mode.
Inspector fields
| Field | Type | Default | Range | Description |
|---|---|---|---|---|
Update Interval (updateInterval) |
float |
0.2 | ≥ 0.05 | Seconds between visibility updates. Higher = cheaper, lower = snappier reveal. |
Scripting API
| Member | Description |
|---|---|
static void Register(VtFogCullable c) |
Add c to the fog updates. Cullables register themselves when enabled. |
static void Unregister(VtFogCullable c) |
Take c out of the fog updates. Cullables unregister themselves when disabled. |
VtFogCullable
Component. Add it with Add Component → Vantage → Fog Of War → VtFogCullable.
Shows, dims or hides this object’s renderers by the VtFogOfWar state at its position. Add it to any prefab whose visibility should follow the fog; a VtFogOfWarCuller in the scene keeps it up to date.
Inspector fields
| Field | Type | Default | Range | Description |
|---|---|---|---|---|
Mode (mode) |
VtFogCullable.Mode | HideWhenUnexplored |
Hide-and-dim rule. HideWhenUnexplored = terrain features (stays in memory, dimmed). HideWhenNotVisible = enemies/VFX (hidden outside current vision). | |
Explored Dim (exploredDim) |
float |
0.4 | 0 to 1 | Brightness multiplier applied to the renderers while in ‘explored but not visible’ state. 0 = black, 1 = no dimming. Only used when Mode = HideWhenUnexplored. |
Scripting API
| Member | Description |
|---|---|
VtFogCullable.Mode CullMode { get; } |
The rule this object follows: kept dimmed once explored, or hidden outside current vision. |
void ApplyFogState(bool visible, bool explored) |
Show, dim or hide this object’s renderers for a fog state: visible when it is in current vision, explored when it has been seen before. |
VtFogOfWarExclude
Component. Add it with Add Component → Vantage → Fog Of War → VtFogOfWarExclude. Adds Camera automatically.
Marker component. Attach to any Camera that should skip the VtFogOfWarRendererFeature’s screen-space pass. Common use cases: portrait/preview cameras that render off-map geometry (outside the fog texture’s sampling range), or cutscene cameras that should always see everything.
VtFogOfWarRendererFeature
Asset. Inherits ScriptableRendererFeature.
URP renderer feature that draws the fog of war over the scene as a screen-space pass. It reads the camera depth to find where each pixel lies on the map, so the fog also covers cliffs, rims and walls correctly. Add it to your URP Renderer asset, assign a material with the Custom/FogOfWarScreen shader, and turn on Depth Texture in the URP asset.
Inspector fields
| Field | Type | Default | Description |
|---|---|---|---|
Fog Material (fogMaterial) |
Material |
None | Material using the Custom/FogOfWarScreen shader. |
Render Pass Event (renderPassEvent) |
RenderPassEvent |
AfterRenderingTransparents |
Where in the rendering pipeline the fog is drawn. AfterRenderingTransparents is the typical choice — fog is applied on top of fully-shaded scene color. |
Scripting API
| Member | Description |
|---|---|
override void Create() |
Set up the fog pass. URP calls it when the renderer loads the feature or a field changes. |
override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) |
Queue the fog pass for a camera. Skipped without a material, without an enabled VtFogOfWar, and for cameras with VtFogOfWarExclude. |
IVtVisionSource
Interface. Implemented by VtVisionSource.
Contract for anything that reveals fog-of-war. Any MonoBehaviour (player, campfire, watchtower, cultist scout, …) implementing this becomes a valid vision source — VtFogOfWar never sees the concrete type.
Scripting API
| Member | Description |
|---|---|
Transform Transform { get; } |
World-space transform of the vision source. |
float VisionRadius { get; } |
Current reveal radius in world units. Evaluated each frame — may vary with day/night, buffs, etc. |
VtInterest
Static class.
Decides whether a world position is inside a viewer’s vision. The server uses it to send each client only the units its own vision sources can see, so fog of war holds up against a modified client. Plain C#: your transport gathers the client’s vision sources and asks per unit; the co-op sample’s interest manager does this on a timer.
Scripting API
| Member | Description |
|---|---|
static bool IsVisibleTo(IReadOnlyList<IVtVisionSource> viewers, Vector3 position, float margin) |
True when position lies within any of viewers’ vision radius plus margin, measured on the ground plane. No viewers means nothing is visible. |
static bool IsVisibleTo(IReadOnlyList<IVtVisionSource> viewers, Vector3 position) |
Same as IsVisibleTo with the margin from the tuning asset. |
Enums
VtFogCullable.Mode
When a fog-controlled object is shown, dimmed or hidden.
| Value | Description |
|---|---|
HideWhenUnexplored |
Visible in vision, dimmed in explored, hidden in unexplored. For static props. |
HideWhenNotVisible |
Visible in vision only, hidden everywhere else. For moving/stateful objects. |