Wednesday, April 18, 2012

[VolumetricLighting] additive blending

I finally figured out how to *additively blend* the following two passes to get the final render:
The additive blending equation looks like this: colorFinal = (colorTop)*(alphaTop) + colorBottom
So when the bottom image is black (0,0,0), the final color will be the top image color. And when the top image is transparent (alpha=0), then the final color will be the bottom pixel.
This is different from the blending method I took to blend the untextured objects and the light source background image, where I set the final color to be bottom pixel if the top pixel's alpha value is 0, and otherwise, set the final color to be the top pixel color. One very important things is that when we clear the screen, we should set the alpha channel of the background color to be 0.0 (because we don't want it to contribute to our final rendering).

No comments: