Skip to content

Vision Layers

Vision layers allow you to create independent fog channels on the same map. This enables multi-level environments, team-based vision, or any scenario where different groups of units should have separate lines of sight.

Overview

The fog system uses RGBA channels to provide up to four independent fog layers (R, G, B, A). Each vision source reveals specific layers, and entities are only visible when revealed by matching layers.

Configuration

1. FogOfWarManager - Layers Texture

Open the FogOfWarManager component and locate the Vision Layers section.

The Layers texture is an optional RGBA texture that defines where each layer can reveal fog:

  • Leave empty - All layers work everywhere on the map
  • Assign RGBA texture - Control which areas each layer can reveal
  • White (1.0) in a channel = that layer can reveal fog in this area
  • Black (0.0) in a channel = that layer cannot reveal fog in this area

For example, to create a two-floor building: - Paint the ground floor area with Red channel only (R=1, G=0, B=0, A=0) - Paint the upper floor area with Green channel only (R=0, G=1, B=0, A=0)

You can create this texture in any image editor (Photoshop, GIMP, etc.) and import it as a regular texture.

2. VisionSource - Layer Property

Select any GameObject with VisionSourceAuthoring and set the Layer property to determine which fog channels this source reveals:

You can select multiple layers by clicking the dropdown and checking multiple options.

3. VisibilitySwitch - Layer Property

Select any GameObject with VisibilitySwitchAuthoring and set the Layer property to determine which vision layers can reveal this entity:

An entity becomes visible when any vision source on a matching layer covers one of its check points.

Example: Multi-Level Terrain

Let's create a map with normal terrain, a ramp leading up, and a raised hill where ground units can't see the upper level from below:

Step 1: Create the Layers Texture

  1. Create a new texture in your image editor matching your map size
  2. Paint the normal terrain area with pure red (R=255, G=0, B=0)
  3. Paint the raised hill area with pure green (R=0, G=255, B=0)
  4. Paint the ramp/transition area with yellow (R=255, G=255, B=0) so units can see both levels there
  5. Import the texture into Unity and assign it to FogOfWarManager → Vision Layers → Layers

Step 2: Configure Ground Units

For units that walk on normal terrain:

  1. Add VisionSourceAuthoring component
  2. Set Layer to R (red channel only)
  3. Add VisibilitySwitchAuthoring component
  4. Set Layer to R (red channel only)

These units can only reveal and be revealed on the normal terrain level.

Step 3: Configure Flying Units

For flying units that can see both terrain levels:

  1. Add VisionSourceAuthoring component
  2. Set Layer to R, G (both red and green channels)
  3. Add VisibilitySwitchAuthoring component
  4. Set Layer to R, G (both red and green channels)

These units can reveal and be revealed on both terrain levels.

Step 4: Handle Units Moving Between Levels

When a ground unit walks up the ramp to the hill, change its layers at runtime:

  1. Get the entity's VisionSource component
  2. Change Layer from R to R, G
  3. Get the entity's DetectionLayer component
  4. Change VisionLayer from R to R, G

The unit can now see both levels. When it walks back down, change the layers back to R only.

Result

  • Ground units on normal terrain can see each other but not up to the hill
  • Flying units can see everything on both terrain levels
  • Ground units that walk up the ramp gain vision of the upper hill
  • The system automatically handles fog revealing based on the layers texture and unit settings