Website powered by

Tech art - two implementations of sight line based fog of war

Two simple implementations of sight line based fog of war effect I tried. Done in Unreal 4.
The first method is to run ray marching on the depth buffer. The second is to generate procedural mesh based on line traces. See details in description of each picture.

Depth map ray marching implementation. It does almost all the computation within a post process shader (next pic), thus on GPU.

Material setup. This current implementation is, however, only accurate when the game is top down. A possible workaround would be to bake a height map, project screen pixels on it and trace that instead.

Material setup. This current implementation is, however, only accurate when the game is top down. A possible workaround would be to bake a height map, project screen pixels on it and trace that instead.

Code for the custom node. It is a simple ray marching. The step size can be adjusted if needed.

Code for the custom node. It is a simple ray marching. The step size can be adjusted if needed.

Procedural mesh implementation. A procedural mesh is created using line trace data (next pic), and rendered into a custom stencil buffer. The darkening and blur is done in a simple post process material. You can see slight jittering around the edges.

Line traces. Extra traces are added recursively on edges, i.e. between a hit and a missed trace, to get better quality.

Line traces. Extra traces are added recursively on edges, i.e. between a hit and a missed trace, to get better quality.