Search Unity

2D Fake Lights

Discussion in 'General Graphics' started by Zelek, Jan 26, 2015.

  1. Zelek

    Zelek

    Joined:
    Jun 12, 2010
    Posts:
    87
    I'd like to simulate lighting in my 2D scene, and I just need some advice on how to accomplish the following:
    1. Starting with a simple 2D scene like this:

    2. I'm then going to apply a semi-transparent black layer that matches the screen size:

    3. And then, I'd like to remove areas of that black layer based on where the light sources are:
    However, rather than an all-or-nothing cutout like in #3, I'd like it to be a gradual falloff as the distance from the light source increases. Does anyone know of an existing shader that could be used for this? The "cutout" shaders don't seem to support partial transparency, so maybe some sort of blending shader?