Search Unity

I need help with 2D light effect by mask or something, please!

Discussion in 'Shaders' started by JDKnight, May 16, 2013.

  1. JDKnight

    JDKnight

    Joined:
    Sep 12, 2012
    Posts:
    2
    Hi there!

    I'm struggling to find a solution to solve how to handle "faked" lights as you can see in the image attached. I'm thinking in grabbing a texture (render to texture) from a transparent layer (for example "queue"= "transparent+17") and render it in other in front of that ("queue" = "transparent+20). The idea is to "avoid" a plane with a color that tints the whole scene (p.e. at transparen+18 -) to get the original color behind and apply to it (fragment shader) the light flare texture and a geryscale mask with that form to lerp with the plane color too. But I can't tag the grabPass in a transparent layer different than the shader (That's one of my problems). Perhaps I'm thinking in a wrong way or someone can tell me another way to handle this problem.

    Thank you very much!
     

    Attached Files:

    Last edited: May 16, 2013
  2. Shaolin23

    Shaolin23

    Joined:
    Apr 4, 2013
    Posts:
    1
    Did you ever find a solution to this? I'm trying to do the same thing.

    Thanks in advance!
     
  3. Gibbonator

    Gibbonator

    Joined:
    Jul 27, 2012
    Posts:
    204
    Have you tried this blend mode:

    Code (csharp):
    1.  
    2. Blend DstColor One
    3.  
    What this does is take the current frame buffer colour, multiply it by the shader output and add it back to the framebuffer. It produces results that look more like lighting than a regular alpha or additive blend. I think Unity uses it for it's light projector shader. Your shader can be really simple, it just needs to sample a texture and output the result. No need for any GrabPass stuff.