Onslaught is a very strategic level based game, where vision and positioning play a key role. As the difficulty increases, I wanted to provide 2D lighting mechanism such that players are limited by vision. And of course, send some meat hungry wolves after them.

Onslaught achieves this by creating an alpha mask that is recorded by another camera. Both Game and Mask cameras write to a RenderTexture instead of presenting to the Screen. Then a Shader combines both and Outputs a Surface Material (Unity Surface Shader is used for lighting, hence the output is a surface material).

This Surface Material is then presented on the MainCamera using Graphics.Blit (Which copies 1 texture to another, but in this case we set the Source Texture to null and Destination Texture to null[for render to Screen]).

Game Camera sees this:

Masking Camera sees this:

How it works in background:

How the effect looks like:

Dev Tool to Support it: