Saturday, November 7, 2015

rts - How do I efficiently implement Fog of War in a Real-time Strategy game?


How is fog of war implemented in RTS games such as StarCraft II or Age of Empires? I'm making an RTS, and plan for every unit on the field to have circular vision up to a certain radius.


My first thought was having a mask that is black for every point except for points close to units, where it is transparent. The masking operation itself is fast in most graphics APIs (e.g. just call mix in a shader). The hard part is figuring out what mask to use and how to update it: updating it when any unit moves is very processor-heavy.



Is there any simpler way to manage this type of fog of war?



Answer



If your game has cell based occupancy, you can reduce the fog of war calculations by restricting up dates to the moments when a unit crosses the threshold from one cell to the next.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...