Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

mtemple

Fog of War II

This topic is 6166 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Gentlemen, Ok, so nobody knows anything about how Blizzard did their Fog of War for Starcraft. I have actually implemented a Warcraft style Fog-of-War that works just fine but it does not do alpha blending. Does anyone know anything about any kind of Fog-of-War just so I can check myself and be sure my reverse engineered methodology is not butt-slow and totally flawed? I know someone must know of something because Fog-of-War is a pretty integral part of this type of game. Any thoughts, references, magazine articles, pamphlets, communist propaganda, air-dropped leaflets, or ANYTHING would be greatly appreciated. Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
Hop over to SourceForge and download the code for Freecraft and see if it has anything useful for you--it probably will.
--


WNDCLASSEX Reality;
...
...
Reality.lpfnWndProc=ComputerGames;
...
...
RegisterClassEx(&Reality);


Unable to register Reality...what''s wrong?
---------
Dan Upton
Lead Designer
WolfHeart Software

Share this post


Link to post
Share on other sites
I don''t know what your actual problem is (looks like you''re referring to another thread), but you can simulate simple alpha-blending with transparency by only drawing some pixels, leaving others clear. This can be faster if you don''t have hardware acceleration and are using video memory. For example, 1 black + 3 transparent in every 4 pixels is similar to 25% black, and 3 black + 1 transparent in every 4 is like 75% black.

Share this post


Link to post
Share on other sites
"so nobody knows anything about how Blizzard did their Fog of War for Starcraft"

I don''t recall the fog of war in starcraft being all that mysterious...

Are we just talking about how you could see terrain, but not units? That''s really easy to do...And there are lots of ways to do it...Especially with using 3D cards to do the ''effects'' like alpha...

If you currently have a black-out FOW and you just need to add the alpha for the terrain that you''ve discovered, just draw it on top of what you currently have with some transparency...

As for using stippled alpha, as Kylotan mentioned. Sure it''s faster, but then you''ll look like you''re running the game on a Matrox Mystique...Bleh!

G''luck,
-Alamar

Share this post


Link to post
Share on other sites
Hey! I AM running the game on a Matrox Mystique

By the way, that simple alpha stuff doesn''t look too bad if you''re in a high enough resolution (1024x768 or above). Besides, that''s the only way you''re gonna get fast enough alpha blending if you use video memory for your graphics without the whole 3D pipeline business, as reading from vid mem is v. slow.

Share this post


Link to post
Share on other sites
Thanks to you guys for the input. I appreciate it because there does not seem to be much written about it, though I agree it doesn''t seem too mysterious on the surface.
As far as my stuff goes, I already have a working FOW that looks like Warcraft II. With this, I am simply drawing monochrome bitmaps (tiles) that are either totally black (unexplored tiles), or some combination of black and/or black checkered (stippled) pixels for the explored but not currently visible areas. I keep track of the fog by simply marking each underlying map tile according to whether it is explored or visible. This was how I did it before I was able to alpha blend.
To implement alpha blending, I know the easiest thing to do would be to just replace the FOW tiles that have checkered areas with black tiles that are drawn partially alpha blended. But alpha blending is none too fast (like kylotan says, reading from video memory, ecccch!) and I wanted to be sure that this was how Starcraft was doing it.
But the real problem is that I am simply drawing my FOW as the last drawing step, on top of everything else (tiles, units, buildings, etc.). This seems a little heavy handed and my profiler shows quite a bit of time used to do this. It may be that this is how it''s done and I just need to buff it out to make it faster. I also need come up with a system to avoid drawing the stuff that is just going to be covered with a black FOW tile anyway.
But, I was wondering if there was some clever system of possibly just fading certain areas to black (I use 16bpp by the way). Is my tiling system with alpha blending really the fastest way to do this? I just don''t want to be doing it the stupid way if everyone else knows of a better system.
Like, (alamar) what do you mean by 3D cards to do the ''effects'' like alpha? That sounds interesting. I think what I have now is the system that (kylotan) is describing, am I correct?

Thanks again very much for the suggestions,

Mark Temple
Enemy Technology

Share this post


Link to post
Share on other sites
Well, for one, if I remember correctly Starcraft is actually only 256 colors in game which actually allows them to do much faster alpha blending via look-up tables.

If you''re doing you''re own blitting routines and locking surfaces a lot, don''t use video memory. Assemble everything in one offscreen software surface, then blit all at once to the screen, this is much faster than reading from video memory. Alernatively assemble you''re base layer with blending in software, blit to you''re back-buffer, blit in all units and what-not, then flip it all forward. So you''d be keeping terrain and what-not in software surfaces and units and such in video. By keeping the base layer in a seperate surface you only need to update it when visibility changes as well, also keep track of whether or not a tile has changed so you don''t have to re-blend it if it hasn''t, if the alpha blending is slow, you want to do it as little as possible and it shouldn''t be necessary to to it every frame.

If you''re storing on a per-tile bases visibility, then I assume you''re not drawing tiles that are entirely black at all, unless you''re assembling a surface with all the tiles ahead of time? You don''t want to black-out tiles after drawing them, rather don''t draw them in the first place.

If you only need one level of "blending" it''s probably a lot faster to pre-calc a blended version of a tile and use that. It does double the memory for art, but will be a lot faster. Of course, it is difficult to get nice smooth edges or fading doing this. Also sticking to a couple discreet levels can be faster, i.e. 50 percent 25 percent 75 percent darkenning, etc...

3-D hardware can do alpha blending faster, but if you only need some simple darkening, I''d keep it to 2-D.

cheers,


mat williams
Lead Programmer, Designer
Zero Sum Software
www.zero-sum.com

Share this post


Link to post
Share on other sites
Mat,

Outstanding! If I understand you correctly, the only thing you would lose by having the fog and map tiles maintained on a separate suface in system memory, is that units could not be shaded as they emerge form the fog since they are drawn after the map surface has been blitted to VRAM. They would just "pop" out, which is no big deal since that is what StarCraft and Warcraft seem to do anyway. And yes, I completely understand that I do not want to be drawing tiles that are completely blacked out.
As for the discreet levels of blending, I''m guessing that means that I draw the fog edge tiles with just a couple passes at 75% to 25% blending since I am unsure if I can do "per pixel" blending in 16bpp. And in any case, the per-pixel blending would be much slower even if I had it, right?
Well, that sounds like a very workable plan. I believe I shall implement it!

Thanks again!

Mark.

Share this post


Link to post
Share on other sites
Right, that''s the only trade off, the popping in of units, but that''s pretty standard.

If you want have absolutely best speed and looks you maintain 2 versions of each tile, in fog and out of fog. You draw appropriately from the correct version. Then you flag the tiles which border the two regions. Then use per-pixel alpha blending only on the edge tiles to get a smooth transition.
Assuming you fogged terrain is 50% darker than your normal, you could just blend 3 pixels along the edge of the unfogged area and still get a much smoother transition (12.5%, 25%, 37.5%) and the same for the fogged-black edges (62.5, 75, 87.5).
Done properly you''re only blending a few pixels and only when the tile''s view state gets changed and you''re never blending tiles that are not edges.

Let me know how it turns out,
cheers,



mat williams
Lead Programmer, Designer
Zero Sum Software
www.zero-sum.com

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!