Home

Awesome

MangoFog Unity

MangoFog is a 2D/3D mesh rendered fog of war system for the Unity Engine. It's based off TasharenFogOfWar except it can use a MeshRenderer, SpriteRenderer, or render directly to the GPU. Plus several other features. The original blur algorithm and LOS algorithm is all thanks to TasharenFogOfWar. The same technique is applied to the Orthographic2D perspective. The fog runs on its own thread and doesn't affect performance. https://github.com/insominx/TasharenFogOfWar

MangoFog is currently not meant or optimized for mobile devices In the future, there may be a more lightweight and performant version of MangoFog released to target these devices.

I'm using this for a 2D game I'm developing for fun. Maybe someone else will also find it useful. Here's a screen shot from the included example scene using some art from opengameart and the Tilemap system. If there's any comments, questions or issues, email me at mwozniak@wozware.net or mkwozniak@outlook.com.

MangoFog Preview GIF

MangoFog Preview

This is meant for Unity Versions 2018 + Tested with URP but should work with Built-In

Features

Installation

  1. Create a GameObject and add the MangoFogInstance component.
  2. Take the MangoFogMaterial (in the Materials folder) and drag it into the Fog Material slot.
  3. Take the FOWRender shader (in the Shaders folder) and drag it into the Fog Shader slot.
  4. Assign the values in the inspector for your desired scene setup.
  5. Create a GameObject and add the MangoFogUnit component.
  6. Set the RevealerType to Radius if you want Radius type revealing and LOS if you want Line Of Sight type revealing.
  7. Set the radius and/or the Fov Degrees accordingly. (Mind it can produce weird results if you overshoot the degrees and inner/outer radius)
  8. That's it! If you set the inspector values correct for your scene, you can press play and see the FoW with your revealer radius.

Make sure to call Dispose() on the MangoFogInstance before switching scenes

Here is a standard 2D Orthographic setup in the Inspector.

MangoFog2D Inspector Setup

Here is the settings I used in the preview for my 2D character.

MangoFog2D Revealer 2D Setup

Not Included Yet

  1. Minimap

Experimental Features

The experimental chunks feature allows multiple threads to be created each with their own fog, allowing for the FoW to cover huge areas without rendering massive textures. It works and there is an example scene that tests it out, although there is a one known issue: When exiting/entering a chunk there is a visible seam as revealers move through them when using blur. Any ideas on how to fix this issue would be greatly appreciated.