# 3-Dimensional Fog of War

I’m contemplating adding a 3-dimensional FoW to my tile-based isometric game. If you remember the old X-Com games, you know how it works. You don’t have just a single layer of blackness over the terrain, but effectively one FoW block on every tile that hasn’t been explored (seen) yet, on all height levels.

The problem with just one FoW plane is that with an isometric game, the player will be able to see “under” it and see part of a tile that should be shrouded. So a block enclosing the whole tile(cube) is preferable.

Now, it’s not possible to have every FoW block as a seperate gameobject, because the FPS drops like a rock. However, I know how to do basic FoW (raycasting upwards at angles at a FoW plane, finding the nearest hit vertice, and setting the alphas to 0), and I wonder if it’s possible to do something similar with a generated mesh consisting of many blocks?

I’m obviously not looking for any finished codes, just some pointers regarding the principle would be nice

Are your tiles separate objects? You could render them differently based on object state, in a way that conveys FoW, without adding objects.

Is your camera only allowed to pan and zoom, as many isometric games have? If so, you could design a 2d shroud that covers one tile perfectly from the camera’s perspective. You could add vertices to that procedurally.

If your camera can pitch, you could extend the above principle to 3d by adding duplicate vertices on another plane to create a volume.

Also, if you’re seeing performance issues with some FoW tests, do you have any profiler data that suggests where the problem is? Sometimes, if something isn’t efficient with 1000 instances, it isn’t efficient with 10 or even 1 (and the problem isn’t really the instance count).

I had a similar issue few months ago

and cam up with a solution using Spot Light. In my case I needed to hide all part of the scene that was outside a defined radius.

In your case, you could have spot light above each tile, the spot uses a cookie so that it lights up as a square.

Then when one tile is visited, you put on the light. As a matter of fact you can easily work on the cookie so that it would be sharp on the edge or maybe showing a little of what is next.

Then not matter the rotation of the camera, if there is no light there is no view.