Make a 2D shader to only show sprites with light?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By PugMasterPug

I need to make a shader such that nothing is visible unless a Light2D is close, if there is no light nearby then it should be displayed as solid black. How can I do this? I’ve been trying to write a shader to do this but can’t figure out how to.

Any help is appreciated.

:bust_in_silhouette: Reply From: Calinou

You could use lights as a mask to achieve that. See the 2D Light Masks Demo.