Top-down map view fog of war?

I’m adding a map view to my game (by basically doing a looking-down view of the world). I want to add a fog of war, whereby the map is initially blacked-out, and is slowly uncovered as the player explores.

I was thinking of doing this by placing a plane mesh across the map, and adding data to it’s material to use as the opacity mask of where the player has been.

I can probably store data of where the player has been in a grid array, but how can I use this data in a material? I know how I would add one (or several) co-ordinates as points to draw the alpha, but how would I use a grid of many hundreds of them?

Or does anyone else have a better suggestion on how to go about this?

Edit: I guess what I’m after is similar to how other games deal with snow footstep displacement during run time. They must be writing to a displacement texture and using that in the materia. I can’t find any info on that in UDK though.

I’ve managed to get something working using a ScriptedTexture, and using it as an opacity mask for the material i’m using to cover the whole map.

I’m pretty new to using Canvas. Is is possible to paint to the canvas bit by bit (rather than having to draw every single shape/line/etc on every OnRender call)?

I don’t think there’s any way to do that with just what’s provided. I think you would need an external library for editing image data. And then you would need to reload the image data dynamically. I’m pretty sure that you can use a GFxMovie’s render texture as the opacity mask, and ActionScript provides a way of loading/refreshing an image dynamically. You would then just have to create a native class for drawing to an image file, or make a DLL that does the same thing.

You could also draw black boxes on the canvas based on a quadtree. Give each quad a property of whether it is entirely blocked, partly revealed, or completely revealed. If it is completely blocked, draw a black box over the whole sector. If it has been partly revealed, look one level deeper. If it has been entirely revealed, skip the sector.

After running some tests, i’m finding there is very little overhead in applying >100,000 tiles to the canvas in a single tick, so I will just re-render the canvas each time the player opens the map.