Search Unity

Glow effect with adjustable threshold (enjoy)

Discussion in 'Shaders' started by meverett, Sep 1, 2008.

  1. meverett

    meverett

    Joined:
    Sep 9, 2005
    Posts:
    34
    Hey all,

    So I really love the Glow effect in Unity, but one thing that always bothered me about it was the inability to selectively dial in at what level of brightness/saturation the glow actually affects (i.e. darker colors do not get a glow/blur applied).

    In other bloom/glow shaders I had used and written this was the case and I felt it provided a more realistic effect (only lighter highlights come through), without washing out the whole screen.

    So I made a version of the Glow effect that does just that. The only addition is one new Inspector parameter (GlowThreshold), and one additional line placed in the down sample pass of the down sample shader (which means there is a new shader file as well).

    When the glow threshold is 0 you basically have the old Glow effect (the whole screen is affected). As the glow threshold approaches 1, only colors with a higher and higher brightness value actually pass through the effect and get blurred and combined.

    I think you'll really enjoy the control of having this parameter.

    I've included a Unity package that you can import into your projects to add this new image effect. You of course will need Unity Pro to use this effect. You can add the effect to your camera by selecting it in the editor and going to:

    Component->Image Effects->Glow Threshold

    Of course the old Glow effect is left intact.

    Enjoy!
     

    Attached Files:

  2. mia

    mia

    Joined:
    Dec 31, 2007
    Posts:
    83
    xcellent work! thanks for sharing this.
     
  3. seon

    seon

    Joined:
    Jan 10, 2007
    Posts:
    1,441
    This is awesome.. thanks :)
     
  4. drJones

    drJones

    Joined:
    Oct 19, 2005
    Posts:
    1,351
    wow fantastic - thanks so much for sharing ; )
     
  5. diese440

    diese440

    Joined:
    May 25, 2007
    Posts:
    105
    thanks, i love it :D
     
  6. ttt121

    ttt121

    Joined:
    Oct 20, 2008
    Posts:
    18
    well done!thx!
     
  7. podperson

    podperson

    Joined:
    Jun 6, 2006
    Posts:
    1,371
    Very nice.
     
  8. Neodrop

    Neodrop

    Joined:
    Oct 24, 2008
    Posts:
    1,359
    Whats wrong at my side? Pro License I have.
     

    Attached Files:

  9. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Import Pro Standard Assets package.
     
  10. Neodrop

    Neodrop

    Joined:
    Oct 24, 2008
    Posts:
    1,359
    I am a stupid moose!
    I forgot to add Pro Asset package. All fine! Super work!
     
  11. Zante

    Zante

    Joined:
    Mar 29, 2008
    Posts:
    429
    Any screenshots? :]

    So this would make lightmaps look even better?
     
  12. Thomas-Pasieka

    Thomas-Pasieka

    Joined:
    Sep 19, 2005
    Posts:
    2,174
    Thanks for sharing this one! I always wanted to "choice" when it comes to "glow" ;)
     
  13. nm8shun

    nm8shun

    Joined:
    Jul 14, 2007
    Posts:
    476
    Awesome! Fantastic stuff. Thanks for sharing. Plugged right into a project I'm working on...
     
  14. Joe ByDesign

    Joe ByDesign

    Joined:
    Oct 13, 2005
    Posts:
    841
    Very cool glow; thanks for sharing this; offers users a choice of techniques :)

    Think the default pro blur has nice features too, but sometimes yes, you want it based on scene highlights, rather than alpha maps (as cool as that is in varying context)
     
  15. faif

    faif

    Joined:
    May 12, 2009
    Posts:
    2
    Hi,

    Great work. Do you know how can I change/remove the black border of the shader?

    In Windows by default Unity chooses to open the paint program, which apparently breaks things when I make changes (only the border remains when I'm trying i.e. to change the color of it).

    Thanks.
     
  16. raviraj_vdy

    raviraj_vdy

    Joined:
    May 14, 2009
    Posts:
    309
    Hi there

    Can i use this glow on the trail renderer.

    thanx
     
  17. FractalCore

    FractalCore

    Joined:
    May 15, 2009
    Posts:
    151
    I couldn't get this to import.

    The file glowthresholdeffect_898.unitypackage is 40kb once extracted from the .gz and when I try to import, it says "Error while importing package: Couldn't decompress package" It extracted from the .gz without saying the file was corrupt so I'm not sure what's going on.

    Could someone post the files themselves instead of a package?
     
  18. ToreTank

    ToreTank

    Joined:
    Jun 23, 2008
    Posts:
    165
    I've seen this myself a couple of times, and it seems to work if you simply remove the .gz instead of manually extracting it (then import into Unity). Not sure if this is your problem, but worth a try I guess :)
     
  19. 3dever

    3dever

    Joined:
    Mar 2, 2009
    Posts:
    71
    Thanks! This must be at the wiki :)
     
  20. God-at-play

    God-at-play

    Joined:
    Nov 3, 2006
    Posts:
    330
    I was really disappointed with the built-in Glow, so I'm very relieved to see the ability to set the threshold. Much needed; thanks!

    I also had to change the clamping of the Blur Spread. I don't see any good reason to lock it to 0.5 - 1, so I changed the min to 0. Turns out 0.01 Blur Spread was pretty close to what I was looking for.

    Threshold is a great addition to glow effects. Thanks again.
     
  21. God-at-play

    God-at-play

    Joined:
    Nov 3, 2006
    Posts:
    330
    I added the ability to adjust the downsampling level, too. It's really important for tight glows to have a lower level to it. My application of glow requires a 1 (i.e. no downsampling) to really look good. But the nice thing is that I can programmatically up it back up to 2 or 4 if performance is low.

    WARNING: Downsampling level is set to a float right now cuz I'm lazy, but obviously it should be used as an integer. :p

    Hope others have a good use for it ^_^
     

    Attached Files:

  22. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,790
    This is awesome! Is it possible to disable downsampling completely? When I set the downsample amount to 0 Unity crashes without fail.
     
  23. God-at-play

    God-at-play

    Joined:
    Nov 3, 2006
    Posts:
    330
    As I mention in my previous post, setting downsample to 1 effectively disables it. The meaning of the number refers to the samples per pixel(per side). So 1:1 is not downsampling, but 1:2 is downsampling to use half the size, and so on.
     
  24. ant001

    ant001

    Joined:
    Dec 15, 2010
    Posts:
    116
    sorry to ask; but would it be able to have some alphas materials not be effected by glow, that are also transparent?
     
  25. stolenpad

    stolenpad

    Joined:
    May 4, 2012
    Posts:
    10
    very nice and intresting !
     
  26. WikiMalik

    WikiMalik

    Joined:
    Nov 13, 2014
    Posts:
    16
    Wonderful