Game Development Community

Full Map Fog of War

by Sean Taylor · in RTS Starter Kit · 06/12/2009 (3:21 pm) · 3 replies

Unfortunately, I haven't made one.... yet ;) But I was doing some research of other RTS games to see how they visually achieved fog of war. So far I've only tested Age of Mythology and Rise of Nations. They both seem to use a "blanket" over the terrain, and then each unit has a small light source attached to them that lights the terrain in an area. Once a unit has passed to a "blanketed" area, the black blanket seems to descend below the terrain. There's also a light source attached to each building which have a much larger lighted area.

My idea for viable FoW would be to duplicate the terrain data a few z-coordinates above the terrain and apply a single black texture, that fades to transparent when it falls below a slope threshold, which is easy with the way terrain is textured. The Problem is that terrain is staticly generated, meaning its all done before the mission is started and can't be changed during gameplay. I found a few posts about opening the terrain to script, which would make FoW more viable, or, you could create a new class that deals with only FoW. Here's one of the posts: http://www.garagegames.com/community/resources/view/7262 This would allow for a blanket terrain to black out the terrain before units are generated, then using the visibility manager, you could alter the blanket terrain to descend below the normal terrain as the units are made.

Comments and feedback are required! ;)

#1
06/14/2009 (9:03 pm)
This is a bump, and an update for an idea that struck me while study-playing some RTS games.

Currently, the pathfinding addition uses a kind of grid that sets up nodes per area of the terrain. Now if it were adapted to also handle say, visibility, which would be: unexplored, visible, and explored. Unexplored would recieve a black area and visible would be if a unit were in the area providing full visibility of the area, and unexplored would be explored but currently not being watched. Would adapting the pathfinding grid to also handle visibility?
#2
06/15/2009 (10:09 am)
For the kit revamping works we had planned at one moment, a unified grid for pathfinding and visibility; also building placement validation and Fog of War could be attached; Guy thought about using some known techniques, for visibilty.

Resulted a bit out of proportion for the resources we got, given that torque network approach is different than the usual RTS engine/game, making it difficult to implement grid based vision on multiplayer configuration. Finally returned to the stock visManager, at least for the first phases.

If interested on pushing forward, let me know and I can point you to where the grid based visibility is explained, but if you are in prototyping phase, I would not walk into that swamp for now.

The stock visibilty manager have some issues, some of them engaged by Thomas Huehn here.
#3
10/28/2009 (4:36 pm)
We did this in the RTS pack that was made for TGE. We didn't need networking so it may need to be done a bit different. Also keep in mind I didn't implement the system just helped design it. Also we are going to eventually port or re-implement it in T3D.

We looked at using lighting and basically dropping them and having them fade then disappear, but this causes massive performance issues, especially when you start getting big history or lots of units.

We also looked at using the terrain texture system, but in TGE the grid size would be huge and we wanted it to be a bit smaller.

So basically what we did is create another UV set, a texture (you could change the size of) and then projected it on to the terrain. The data is stored in two arrays (one for the history fog and another for the bright fog). These arrays are faded out gradual over time and modified every time a new position is logged. Any objects like trees or buildings simply used a shader the modulates the default color of the object based on the intensity of the fog terrain beneath it. The effect was quite fast and looked pretty good. I would put up some screen shots, but I probably can't because of the nature of our project (NDA and whatnot) also I would love to give more info about how the system worked, but it was done by someone who doesn't work for us anymore and was both poorly (barely at all) documented and the code is quite messy, so we ourselves are trying to figure it out in order to port it.

I am hoping that once we do port it we can have some way of posting some information about how it was done, possibly have a resource or sell it as an add-on. I am going to try to do as much of that as possible, but not sure how much I will be able to do since it is payed work and obviously just posting all the code wouldn't make someone paying for the work hours happy.

When first doing my research I found this: http://catalinzima.spaces.live.com/Blog/cns!3D9ECAE1F2DC56EF!238.entry There is a full download of the source although it is C# using xna but the concepts should be able to carry and may be helpful. There is also was an article written by John Sedlak, but seems it is not up anymore here is what I searched for though: 'Fog Of War article by John Sedlak' here is is current site: http://jsedlak.com/ but it doesn't seem to have the 3D fog of war article. He also talked about how it is out of date here: http://focusedgames.com/2009/08/14/update/

Also there are a couple open source rts's like http://boson.eu.org/ you may be able to borrow some code from or at least see how other implemented things like fog of war.

There are also a couple post on the gameDev site about ways of doing it.

Anyway hope that helps, and I will hopefully some time this year be posting some info about how we did ours once we port it or how we will be doing it if we re-write the system.