Light Patch in 2D

I’m looking to do an effect in 2D spritey land where everything that would normally be rendered is very dark and a patch of the screen is rendered normally hopefully giving the effect of a spot light or something.

I was intending to draw the screen dark, stencil in the lighted patch then render the effected items light. However, I can’t think of a nice way to render what would nromally be light in a darker shade apart from either keeping a set of tiles that are darker or rendering the screen then filling the alpha with a darker colour.

Any ideas on how to darken a complete screen? It might also be useful for fading out a screen?

Cheers for any help,

Kev

If you’re not already using them you can set the vertex colours to a grey value rather than pure white, that’d darken all your sprites in a nice controllable way. A big fullscreen quad is the usual way though, its simple and easily controllable.

I wouldn’t use the stencil test though, it might be better just to draw the whole screen as normal then blend a spotlight texture over the whole screen. That’d get you nice soft edges to your spotlight.