Handling visibility and Fog of War!

Early on in development, the fog for the game was a high priority. It was a core element of gameplay, as without it, players had effectively limitless information about the state of the map and the positioning of the enemy player. My primary point of research and reference early on was League of Legends, as I felt it was the easiest point of reference in terms of how to handle fog from a similar angle and distance as we did.

In conversation with my designer, Steph (link coming soon), there were a few key things that our game's fog of war system needed to handle.
- Visibility
- Limiting Information
- Restricting Controls
The first and the second come hand in hand in some ways, so I will run through them first.

Limiting What The Player Knows!

RTS games, the genre Mall or Nothing draws on the most from sylistically and gameplay-wise, are largely based on information and resources. Given the limited scope we had, resources were not the focus of our development at any point, really. Instead, we focused on information. The game's core loop is built around managing a trio of Leaders, who then command and send orders to Minions, who follow flocking like behaviours (described in the other article for this subtopic)!

If the player always knew where the other player's leaders were, or where every minion was, a lot of the games strategy would vanish. Take, for example, the minimap for a game like Pikmin, one of our other major influences.

Image courtesy of IGN! (Pikmin, Nintendo, 2001)

The map here only reveals the most key information, the location of your Pikmin (think like our minions), and the bases where you can collect more, plus any major ojectives. Our map looks much the same, and given there are two players, each player should only receive that information, reasonably.

Because of this, the fog would play a vital role in creating the game's feel and strategic element.

Limiting What The Player Can Target!

The player was also not allowed to send minions off into the fog to make sure they needed to actually move around the map to target different regions. This was relatively simple, as the Leader units each stored a visibility radius internally, and just clamping the position you targeted with a minion to that range was relatively straightforward.

How I did it!

All the planning and thinking aside, the actual drawing of the fog was pretty simple. It essentially amounted to drawing a sphere around each of the Leaders that were active, and then using that as a filter for our full screen shader by translating from 'fog of war space' to world space to determine if a colour should be multiplied or not.

The real challenge came with getting the colouring and falloff of the fog to feel good and correct. The first thing I tried was a method of falloff similar to a spotlight, with an Inner and Outer Radius. Any point inside the Inner Radius was entirely illuminated, and between the Inner and Outer radii a falloff was calculated. This looked fine, but felt a bit less 'foggy' than I would have liked. I decided to try a simple stupid solution, a linear falloff just using the distance proportional to the cutoff, and it looked much nicer.

Then there was the minions. They were not meant to render outside of visible ranges, as that would give away a lot of key information to the player. I ended up solving this by passing the Fog of War texture, and then checking if the fragment that was being rendered was in or outside of the fog of war's visibilty. If it was not visible, I just discarded it. Had the minions been bigger, this would have been a less viable solution, as the cutoff would have been more noticeable on larger or more complex geometry, but with the small size, it worked well!

How'd it turn out in the end?

I am really proud of the fog of war in Mall or Nothing, even if it is a relatively simple solution. I think it did a lot for the vibe of the game, and really helped cement the visual aesthetic. Without it, of course, there would have been a lot of gameplay consequences. If I were to have more time to go back and improve it, I would probably want to add some more 'juice' to the fogged elements of the map, a layer of dithering or noise to give it a bit more texture, almost like TV static, but as it stands, it did a lot to really cement the aesthetic of the game!