Top down 2D lighting: How can colour/shade areas of my map?

I am working on a top-down 2D game. I would like to end up with something like this:

alt text

I can figure out the raycasting and the geometry bits. At which point I will have a set of polygons that I want to be light, and I want the rest of the map to be dark.

I do not know how to achieve this effect in unity, however. I am considering trying to apply an alpha mask to the camera such that it will only show the white polygons. I could then use Texture2D.SetPixels to update the alpha map.

Does anybody know if this is possible, or if there is an easier way to achieve the same effect?

Thankyou kindly.

Since your camera appears to be orthographic, you could just apply a material using an unlit shader with a white color/texture to the visible/light mesh, and a black one to the others (or just not renderer the “real” geometry at all, and only have a black background with the white mesh showing the visible parts rendered on top). I don’t know how resource-intensive it would be to reassign vertices of a mesh every frame, though.