Fog of War
Fog of war hides what a player cannot see. It has two halves that do not share state.
- The simulation half gives every player a grid of cells. Each cell holds a byte of flags: has the player ever explored it, and which kinds of sight currently cover it. Units paint onto the grid with vision stamps. Abilities, target queries and the minimap read it. It is deterministic and identical on every machine.
- The presentation half draws the fog over the screen, hides the actors of enemy units you cannot see, and feeds the minimap. It reads the grid and never writes to it.
The simulation half is why fog is fair: an ability with Requires Line Of Sight checks the grid inside the simulation, so it cannot target a hidden enemy.
The grid and its bits
Section titled “The grid and its bits”The grid comes from the level bake (see Navigation and Level Data). It needs a Sein Level Volume, and bakes ground height and static sight blockers into it. Its cell size is Vision Cell Size (100 by default), independent of the navigation cell size and a whole multiple of it.
Each cell holds one byte per player. Each bit is a kind of sight:
| Bit | Name in the editor | Meaning |
|---|---|---|
| 0 | E (Explored) | The player has seen this cell at some time in the match. Never cleared |
| 1 | V (Normal) | Covered by ordinary sight right now |
| 2 to 7 | N0 to N5 | Six custom layers, covered right now |
Explored is set by any stamp that covers the cell. A cell the player has never seen has no bits and draws fully black. A cell it has seen before but cannot see now has only Explored and draws dimmed.
Vision stamps
Section titled “Vision stamps”A unit is a vision source if it has a Sein Vision component. The component holds:
| Setting | Default | Meaning |
|---|---|---|
| Eye Height | 180 | How high above the unit the sight starts. Taller eyes see over blockers that block shorter ones |
| Vision Stamps | one stamp | The areas the unit sees |
A new Sein Vision component starts with one stamp. Each stamp has:
- A shape, Radial, Rect or Conical, with its offset, yaw offset and size. A stamp has a radius of 1000 by default. A conical stamp has a Cone Angle (Total Degrees), a Cone Length and a Round Far Edge toggle.
- Enabled. A disabled stamp costs nothing. Use it for a building whose window cones switch on while the building is manned.
- Layer Mask. Which bits the stamp paints. The default is V (Normal). Explored is added automatically.
The stamp does not reveal everything in its shape. Sight is cast from the stamp’s origin, so walls and buildings stop it, and a taller Eye Height clears lower blockers. A conical stamp casts from its apex, so a window cone sees from the window, not the middle of the building.
Vision is recomputed every Vision Tick Interval simulation ticks (3 by default, so 10 times a second at the default 30). A unit that has not moved and has the same stamps skips the work. A raised value is cheaper and makes the fog lag a little as units walk in and out.
Two things silence a source. A site under construction (it carries SeinARTS.State.UnderConstruction) emits no vision, and neither does an entity removed from the world, such as a Soldier riding a Truck.
Terrain changes sight
Section titled “Terrain changes sight”A terrain type has a Vision Multiplier. While a unit stands on it, the radius of each of its stamps is scaled by that number. A Vision Multiplier of 0.6 turns the Truck’s 1200 stamp into 720 while it stands in a forest. This cuts the unit’s own sight and does not block sight through the forest. See Navigation and Level Data.
Blockers
Section titled “Blockers”Stamps are stopped by occluders. On Sein Extents:
| Setting | Meaning |
|---|---|
| Bakes Into Fog Of War | Placed props are stamped into the bake: walls, buildings, hedgerows. Mobile units are skipped |
| Blocks Fog Of War | A runtime occluder: smoke, a destructible wall. It needs a shape with a non-zero Height |
| Blocked Fog Of War Layer Mask | Which bits it blocks. The default blocks every layer. Clear Thermal and a smoke cloud is invisible to thermal sight |
The occluder’s height is the shape’s Height. Fog and navigation are independent: a fence can block sight and not paths (Bakes Into Fog Of War on, Bakes Into Nav off), and a glass wall the reverse. Bake Static Blockers on the level volume turns the baked occluders off entirely.
Layers
Section titled “Layers”V, the Normal layer, is always there. The project can add up to six more in Project Settings > Plugins > SeinARTS > Fog Of War > Vision Layers: Thermal, Radar, Detector and the like. All six slots exist and ship disabled. Each has Enabled, Layer Name and a Debug Color.
Layers match by bit, not by name. The name is only for Blueprint queries and the debug viewer. Three things line up:
- A stamp’s Layer Mask says which bits it paints.
- A target’s Fog Visibility Layer Mask says which bits can reveal it. It lives on the unit’s SeinARTS Entity Bridge component. The default, 0xFE, is every bit except Explored.
- A target is visible to a player when at least one of the player’s stamps covers its cell on a bit that both masks share.
So a Scout Drone with a second stamp on N0 sees units that emit on N0, and an Infiltrator whose mask is N0 only is seen by that drone and by nothing else. A disabled slot keeps its bit working. It just has no name. Never insert or reorder a slot in the middle once a project has shipped, because every later slot’s bit shifts and saves and replays break. Append, or rename.
The target’s Fog Visibility Policy says what happens after it is revealed:
| Policy | Behavior |
|---|---|
| Vision Layers Only | Visible only while a stamp covers it. Standard for enemy units |
| Visible Once Seen | Stays visible as a ghost after it has been seen once. Standard for enemy buildings |
| Visible Once Explored | Visible once its cell has been explored, even if the entity itself was never seen |
| Always Visible | Never hidden. Walls, landmarks and effects whose stamp blocks sight but whose actor must stay on screen |
The owner always sees its own units. Shared vision, granted with Grant Diplomacy and SeinARTS.Diplomacy.Grant.ShareVision, lets one player see what another sees.
To change a unit’s mask during a match, use Set Entity Emission Mask, Add Entity Emission Layers and Remove Entity Emission Layers. A Cloak ability removes V on activate and adds it back on end.
Turning fog off
Section titled “Turning fog off”Set Fog Of War Class (Fog Of War settings) to None. Nothing is hidden and every unit is always visible. Cell queries return true, Requires Line Of Sight is permissive, and a warning on screen reminds you while it is off. You can silence the warning in the SeinARTS editor preferences.
Because the setting changes simulation results, every player in a match needs the same value.
Drawing the fog
Section titled “Drawing the fog”Fog is drawn by a Sein Fog Of War Render actor you place in the level, with a post-process material. The renderer rebuilds a small texture from the local player’s grid whenever vision changes and feeds it to the material.
The material must be a Post Process material with three parameters, with exactly these names:
| Parameter | Type | Filled with |
|---|---|---|
FogTexture |
Texture | The per-cell tint. RGB is the fog color and A is how much to darken |
FogWorldMin |
Vector | The world XY of the texture’s corner |
FogWorldSize |
Vector | The world XY size the texture covers |
The material turns a screen pixel’s world position into texture coordinates and lerps the scene toward the fog color by the alpha. Add Fog and a Minimap builds it step by step.
On the actor:
| Setting | Default | Meaning |
|---|---|---|
| Fog Post Process Material | The material above. Without it nothing draws | |
| Unexplored Color | black | The fog color |
| Unexplored Opacity | 1 | Opacity over cells never seen |
| Explored Opacity | 0.75 | Opacity over seen-before cells. 0 is no dimming |
| Smoothing Strength | 0.1 | Edge blur, in fog cells. 0 is blocky |
| Vision Layer Post Process Materials | six disabled slots | A look for each custom layer. See below |
The actor can switch the local player’s view to a custom layer. Set Active Vision Layer takes -1 for Normal or 0 to 5 for a custom slot. Cycle Vision Layer steps through Normal and each enabled layer, and the console command Sein.Vision.Layer does the same. In a layer view, the fog reveals only what that layer sees, unless the slot’s Combine With Normal Vision is on, and the slot’s Post Process Material restyles the whole screen under the fog: a heat palette, say. This changes only the local view. It never touches the simulation.
Hiding enemy actors is separate from the overlay. A unit’s actor is hidden whenever the local player cannot see its entity, so an enemy vanishes from the world even with no fog material at all.
Queries
Section titled “Queries”All of these are presentation and ability queries. They read the grid and change nothing.
| Node | Use |
|---|---|
| Is Cell Visible | Is a point covered right now. Takes a player and an optional layer name (Normal by default) |
| Is Cell Explored | Has the player ever seen the point |
| Get Cell Bitfield | The raw byte, for debugging |
| Is Entity Visible | Whether a player sees an entity, honoring its policy, mask and footprint |
| Get Local Observer | The player this machine shows: the local player, then a surviving teammate once defeated |
| Is Local Player Spectating | True for a defeated player who watches on |
Requires Line Of Sight on an ability (see Abilities) fails the activation unless the owner’s player sees the target now, on a layer the target emits. A target point needs Normal sight. Find Targets and Check Target do the same, through the query’s Require Line Of Sight (on by default). With fog off, all of these allow the target.
The minimap reads the same grid. See Add Fog and a Minimap.
Debug views
Section titled “Debug views”Sein.FogOfWar.Show draws the grid in the viewport: in play, the local player’s visible and explored cells. Sein.FogOfWar.Show.Layer <bit> picks a layer: 0 is Explored, 1 is Normal and 2 to 7 are N0 to N5. Sein.FogOfWar.Show.Player shows another player’s vision. See Console commands.
Example: a watchtower and a scout
Section titled “Example: a watchtower and a scout”A Watchtower has Eye Height 500 and one Radial stamp of radius 1,800. A Scout has Eye Height 180 and a stamp of 1,000, and a second stamp of 1,500 on N0, named Thermal.
- At the default Vision Cell Size of 100, the tower’s stamp covers about 1,000 cells (a circle of 18 cells radius). A low wall across the road can block the Scout’s sight and not the tower’s, because the tower’s eyes are higher.
- When the Scout walks into the forest, with a Vision Multiplier of 0.6, its stamps shrink to 600 and 900.
- An enemy Infiltrator has a Fog Visibility Layer Mask of N0 only. The tower’s V stamp does not reveal it. The Scout’s Thermal stamp does, once it is within 900 units in the forest and 1,500 outside.
Common mistakes
Section titled “Common mistakes”- No volume. A map with no Sein Level Volume has no fog grid, so nothing is hidden and every query allows the target. A volume that was never baked still gets a grid, but with no baked ground height or sight blockers. Bake after moving walls.
- A material with the wrong parameter names. The renderer sets
FogTexture,FogWorldMinandFogWorldSize. A different name is ignored and the fog never draws. - No render actor. Visibility and queries still work, but nothing is drawn.
- Height 0 on an occluder. Its shape then never blocks sight.
- A stamp radius of 0. It reveals nothing.
- Layer bits that do not line up. A thermal stamp reveals nothing unless a target’s Fog Visibility Layer Mask includes that bit.
- Reordering vision layers. It shifts every later bit. Append or rename.
- Matching layers by name. Layers match by bit. A renamed slot keeps its bit, and the name only serves lookups.
Related
Section titled “Related”- Add Fog and a Minimap for fog in the demo
- Add terrain and vision layers for a working custom layer
- Collision and Extents for occluder shapes
- Navigation and Level Data for the bake and Vision Multiplier
- Fog of War reference, Fog of War settings, Sein Vision and Sein Fog Of War Render