Skip to content
Paul Torreiter
FOW Compute Shader Plugin: key image

02 / 11 - Games & VR Applications

FOW Compute Shader Plugin

GPU-accelerated fog of war for Unreal Engine 5, published on Fab: compute-shader visibility mask, GPU readbacks, memory, height-aware occlusion and four premade effects.

Description

I just released my first Plugin on the Fab Marketplace, featuring a GPU-accelerated Fog of War system for Unreal Engine^^.

It was at first developed for our Game Project "Obscura", but I decided to build out into its own little plugin, making the system a lot more versatile and adaptable. The Fog of War for our game had to achieve high fidelity, good performance and had to be able to affect gameplay mechanics. I solved this by creating custom compute shaders, writing a smooth mask into an editor exposed render target texture, with which I control various fog effects.

At first, the CPU calculated its own visibility mask in order to control game mechanics. However, the final plugin allows for single or batched GPU Readbacks, making it possible to query the actual visibility mask, respecting the occlusion, fades and memory.

To package the game's FOW mechanics into the plugin, I cleaned and expanded the system radically, adding a ton of new features and improving the various shader pipelines.

The resulting, final system features memory for already discovered areas, different hide modes for actors, height aware occlusion with different raymarching techniques, visibility queries and a lot more. Due to relying on compute shaders, the system can handle a multitude of vision sources (10000+).

Even though the plugin primarily aims to enable the creation of cool, self made Fog of War Effect, the plugin comes with four premade effects. They are meant as examples, utilizing different shader domains.

  • a translucent surface Material for layered meshes (fake volumetric effect - used in our RTS game)
  • a Volume Material
  • a light function Material
  • a post-process Material

The full documentation can be found here:

Full documentation

The plugin product page can be found here:

Plugin product page on Fab

Maybe in a future post, I will go into depth about the main premade fog effect and explain its shader graph..

Media

Fab marketplace title card of the plugin with its debug panel

The plugin comes with an example project, which allows the user to try out the different settings and premade fog effects.

A grove dissolving into layered fog

Our game uses multiple transparent layers, using the same mesh as the water plane. The effect is very cheap and works perfectly for top down RTS games.

Tree canopy in fog with a lone gnome
Oblique view of a meadow and mountains lit through the fog light function

The calculated mask can also be used inside a lightfunction..

Golden meadow with a purple shadow cast by the light function
Meadow split between lit and shadowed fog
An island in a grey void, the post-process fog material

.. or a postprocess material.