Sign in to follow this  

Mini map fog of war

This topic is 3592 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

I'm working on an HL2 mod that's half RTS half FPS, one of my few tasks remaining is to implement fog of war. I've gotten something working, but it's dog slow right now. I use the built in procedural material process to access the pixels of a blank texture sheet (it's currently 1024 x 1024 - I'm going to drop that down), at each pixel I loop through the entities and check if that pixel falls within the visible radius, if it is, I drop it's alpha to 0, otherwise it gets left with RGB at 200 and it's A at 128. This works ok - I get nice circles in my grey fog on the mini map, but even only running the process once a second it has a big impact on fps (in a release build, I drop from 299 fps to 150 - lower still when it does the processing). I've got quite a powerful machine, so the impact on players with lower end rigs would be, unpleasant. What else do people do for fog of war on minimaps? I don't have much chance of doing anything overly complicated due to the lack of engine access. [update] Dropping to 512 x 512 has helped a lot - I've just got to figure out how to make sure that the fog of war overlay still matches the base minimap image in terms of positioning.

Share this post


Link to post
Share on other sites
While i've never made one myself...

How about just checking where you DO see?
Create a list of all the units, and plot units+radius/line of sight into the map.

Anything else is discarded as unknown.

Share this post


Link to post
Share on other sites
That's essentially what I'm doing - but I still need to translate from minimap to world to check if it's a bit of world I can see or not.

Share this post


Link to post
Share on other sites
You don't want to loop through all entities per pixel. It should be a lot faster to just loop through the entities once per map update, and draw a circle in the texture around each entity. A million pixels times N entities is a lot. If the average circle is about ten thousand pixels (100x100), then just drawing the circles is a hundred times less work.

Anyway, if you don't update the map every frame then your framerate drop has to do with something else than the fog of war implementation... Not that 3 milliseconds per frame is that dramatic.

Share this post


Link to post
Share on other sites
I assume your game uses a 3 or 3 dimensional grid for the fog of war cells, and sets each one to revealed or hidden as appropriate. This function may be the member function of the map or whatever.

every second do this:
(1 second is enough, giving the appearance that the minimap is using a radar rather than being a smaller version of the map.)


FOREACH entity in game AS e
IF get_fog_of_war_cell(e.xpos,e.ypos,e.zpos).revealed=TRUE
draw_specific_spot_on_minimap()
ELSE
IF is_revealed_on_radar(e)
draw_generic_radar_anomoly_on_minimap()
END IF
END IF
NEXT



The important function here is get_fog_of_war_cell(x,y,z) which takes a vector and returns the cell that vector is inside of.

Share this post


Link to post
Share on other sites

This topic is 3592 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this