Sign in to follow this  
Guy Meh

Blending method for glow shader

Recommended Posts

There are certain parts of a scene/model that I've set to glow. I don't want HDR and do not intend to use floating point textures. I just want the colours of the glowing parts to bleed into their surroundings to give a fuzzy outline...as if they were glowing. As far as I understand, the standard technique is to render the scene to one texture, render the glowing parts to a second texture (with a black background), blur the glow texture (rendering to a couple more textures), then render the original scene texture and the blurred glow texture on top of each other to the screen using some kind of blending. The blending part I'm not sure of. I keep reading that additive blending is typical. But wouldn't that cause many colours to approach white or otherwhise not preserve their original colour. For example, if I have an orange (R= 0.5, G = 1.0, B = 0.0) face that's set to be glowing, and I render the face to the scene texture and the glow texture and then blend them together, I end up with yellow (R = 1.0, G = 1.0 [2.0 uncapped], B = 1.0). What kind of blending do I need if I want to make certain regions in the scene glow while still preserving their original colours?

Share this post


Link to post
Share on other sites
Quote:
Original post by Guy Meh
I keep reading that additive blending is typical. But wouldn't that cause many colours to approach white or otherwhise not preserve their original colour.

Yes. This is known as clipping, and is not specific to glow effects: Overlighting a colored surface will do it too. If you don't want to do HDR and tone mapping, then the only solution is good art and level design -- picking textures and lighting and lighting parameters that ensure this doesn't happen too often. BTW, your example (a glow amount of 0.5,1.0,0.0) is a ridiculously high glow value. Just because the face is bright orange doesn't mean the glow color should be bright orange. A multiplier is applied to tone things down.

Share this post


Link to post
Share on other sites
Hm. So when I render the glowing parts to the glow texture, I render them a bit darker so that they don't brighten up the scene too much in the final render. Or I pick colours that don't produce extreme brightening effects after the blending.

Now, this assumes that I'm rendering the glowing parts on top of a black background in the glow texture, such that the texture is completely opaque. Would it be possible though to create a texture that is completely transparent, render the glowing parts opaquely to that texture (I don't expect to have any objects that are alreayd transparent), then modify the alpha values instead of the colours themselves when doing the blur. The glow texture would be a partially transparent overlay that I could place on top of the scene texture when making the final render, where I can use standard alpha blending to make the final image. Because all I want is to be able to set different regions of the scene to have fuzzy edges; they don't necessarily have to be brightened.

Share this post


Link to post
Share on other sites
Sure, you could do that. The key will be to divide the blur color by the alpha value in the blur shader, such that the edges tend towards colored transparent rather than black transparent. BTW, make sure to test out with different-colored blur objects which are adjacent on the screen, to make sure the results are what you want.

Share this post


Link to post
Share on other sites
There is an alternative to consider. What artists know as "Screen" blending in Photoshop is my preferred way to get the effect of additive blending without "blowout".

Whereas additive blending is simply:

Source + Dest

Screen blending is:

Source + (1 - Source) * Dest

This can be configured with standard blending hardware:

SrcBlend = SrcColor One (thank you Sunray)
DestBlend = InvSrcColor

[Edited by - 0xffffffff on July 28, 2009 6:57:26 PM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this