Table of Contents

Fog Of War World API


FogOfWarWorld (namespace FOW) is the singleton manager. Access the active instance via FogOfWarWorld.instance.

using FOW;

var fow = FogOfWarWorld.instance;

Static Properties

Member Type Description
FogOfWarWorld.instance FogOfWarWorld The active Fog Of War World.
FogOfWarWorld.ActiveRevealers FogOfWarRevealer[] All currently registered revealers.
FogOfWarWorld.NumActiveRevealers int Count of active revealers.
FogOfWarWorld.ActiveHiders FogOfWarHider[] All currently registered hiders.
FogOfWarWorld.NumActiveHiders int Count of active hiders.

Visibility & Fog Sampling

TestPointVisibility

public static bool TestPointVisibility(Vector3 point)

Returns true if the given world point is currently within a revealer's line of sight. This queries revealers directly, so it works in Pixel-Perfect sampling mode.

if (FogOfWarWorld.TestPointVisibility(enemy.position))
    Debug.Log("Enemy is visible!");

SampleFogTextureAtPoint

public static bool SampleFogTextureAtPoint(Vector3 worldPosition)

Returns true if the point is visible according to the fog texture (Texture sampling mode). Requires World Bounds.

SampleFogTextureColorAtPoint

public static float SampleFogTextureColorAtPoint(Vector3 worldPosition)

Returns the fog opacity (0–1) at a world position by sampling the fog texture.

GetFowTextureUVFromWorldPosition

public static float2 GetFowTextureUVFromWorldPosition(Vector3 worldPosition)

Converts a world position to a fog-texture UV coordinate.

Tip

For frequent CPU sampling, enable Async Readback Fog Data To Cpu so reads take the fast path. See Sampling Mode.

Runtime Configuration

SetFowAppearance

public void SetFowAppearance(FogOfWarAppearance appearanceMode)
public FogOfWarAppearance GetFowAppearance()

Change the fog appearance at runtime. FogOfWarAppearance values: Solid_Color, GrayScale, Blur, Texture_Sample, Outline, None, Custom.

SetFowEffectStrength

public static void SetFowEffectStrength(float strength)

Sets the global strength of the fog effect (0–1). Useful for fading the whole effect in or out.

SwitchSpatialAccelerationMode

public void SwitchSpatialAccelerationMode(bool useSpatial)

Enables or disables spatial acceleration at runtime.

ToggleStagedUploads

public void ToggleStagedUploads(bool enabled)

Enables or disables staged GPU uploads at runtime.

SwitchHidersUseFogTextureMode

public void SwitchHidersUseFogTextureMode(bool useFogTextureToSeeHiders)

Switches whether hiders are revealed via the fog texture or via direct revealer line of sight.

ToggleFogTextureAsyncReadbackToCpu

public void ToggleFogTextureAsyncReadbackToCpu(bool useAsyncReadback)

Enables or disables asynchronous CPU readback of the fog texture.

World Bounds

UpdateWorldBounds

public void UpdateWorldBounds(Vector3 center, Vector3 extent)
public void UpdateWorldBounds(Bounds newBounds)

Updates the World Bounds at runtime.

GetFowBoundsPositionFromWorldPosition

public Vector2 GetFowBoundsPositionFromWorldPosition(Vector3 worldPosition)

Projects a world position onto the fog plane.

Fog Texture & Save / Load

GetFOWRT

public RenderTexture GetFOWRT()

Returns the fog RenderTexture (Texture sampling / minimap modes).

ClearFowTexture

public void ClearFowTexture()

Resets all exploration back to the starting state.

GetFowTextureSaveData

public byte[] GetFowTextureSaveData()

Returns a PNG-encoded byte[] of the current exploration state. See Saving & Loading.

LoadFowTextureData

public void LoadFowTextureData(byte[] save)

Restores exploration from a byte array previously produced by GetFowTextureSaveData.