In games like Command & Conquer or Age of Empires, players can't see all of the map. Terrain and enemies are revealed only when the player has soldiers nearby.

As I understand it, the most performant way of doing this is by representing map visibility as a grid of cells. When a unit moves into a new cell it updates all cells within a circle shape around the unit.

However, I would like to know how to integrate sight blocking. What I mean by this, is that if a cell is occupied by something which a unit can't see past (like a wall) all cells behind the wall are covered by fog-of-war.

Here's a YouTube video of what it should look like. The author doesn't go into how they did it, aside from mentioning "brute force shadow casting".

  • 2
    \$\begingroup\$ The author of that video gives a step-by-step breakdown in this Tumblr post, which might be useful to you. \$\endgroup\$
    – DMGregory
    Commented Aug 16, 2018 at 13:27
  • \$\begingroup\$ @DMGregory I think that may have answered my question. \$\endgroup\$
    – user83633
    Commented Aug 16, 2018 at 14:15
  • 1
    \$\begingroup\$ Sweet! If you get it working, it would be great to add an answer here yourself, so it's easier for future users working on similar issues to search for. \$\endgroup\$
    – DMGregory
    Commented Aug 16, 2018 at 14:16
  • \$\begingroup\$ I am working on a performant implementation of a Fog of War, checkout my twitter twitter.com/arielsan, my idea is to make a blog post about the it at some point but if you see something that could help you could ask me directly. I will try to answer the question too. \$\endgroup\$
    – arielsan
    Commented Aug 27, 2018 at 0:55

1 Answer 1


Basically what I do is, for each pixel in vision range, I go pixel by pixel and check a line to the center (using the Bresenham's line algorithm), if there is no obstacle, then the pixel is visible, otherwise, it is blocked.

It works pretty well, ~100 units at 60fps, check out this tweet to see it working. I plan to write a blog post to explain in detail the implementation.

Don't know if that works for you as an answer.


You must log in to answer this question.