Search Unity

Trying to create a glowing effect for 2D sprites

Discussion in 'Shaders' started by Prank1710, Sep 22, 2014.

  1. Prank1710

    Prank1710

    Joined:
    Sep 22, 2014
    Posts:
    2
    Hi all,

    This is my first post here so I hope I can ask my question clearly.

    I am trying to create a glowing effect for the sprites that we are planning to use in our game. These sprites are essentially black and white and the plan is to make the white parts of the texture glow proportional to their intensity. (There are no lights, the glow will just be decided by a color used in the inspector).

    I understand this process requires shaders but I am relatively new to them and I'm facing a lot of difficulty in getting this working. I have been following this article: http://http.developer.nvidia.com/GPUGems/gpugems_ch21.html but I do not understand how to go about creating the glow source mask. I have been able to use a simple two pass Gaussian blur on the entire sprite but I haven't been able to isolate just the white parts for that as I want to.

    I also thought about having the white sections as a separate sprite, blurring them and then just overlaying them on top of the independent black sprite but have been unsuccessful with that because I tried to use multiple passes in the shader and it lead to one error after another.

    I would love some input, suggestions or any form of guidance. Thanks in advance.
     
  2. aubergine

    aubergine

    Joined:
    Sep 12, 2009
    Posts:
    2,878
    If you have unity pro, my "Glow Per Object" asset does what you want. Even for transparent sprites.
     
  3. Lasuperbiscotte

    Lasuperbiscotte

    Joined:
    Sep 22, 2014
    Posts:
    7
  4. Prank1710

    Prank1710

    Joined:
    Sep 22, 2014
    Posts:
    2
    Thanks for the replies guys. I will definitely check out the asset Aubergine as well as your thread Lasuperbiscotte.

    Meanwhile, I have been working further on the shader and while I get some decent results (though not exactly what you could call glow), there's a strange thing happening with my result.

    My texture seems to create a small inverted manifestation of itself within the texture and I have no idea how that's happening. I am using a blurring technique used in this thread:
    http://answers.unity3d.com/questions/407214/gaussian-blur-shader.html

    In fact I think the OP had the same issue and I have left a comment asking whether it was fixed or not because the answer to the question didn't solve my problem at least.