Combining two blending functions

Started by
1 comment, last by Nanaky 17 years ago
Hi everyone, I have implemented the technique for casting shadows in 2D described in this article: http://www.gamedev.net/reference/articles/article2032.asp (without but with mirrors and reflections, but that doesn't matter). However I am faced with a problem, which I think is not a big one but enough to prevent me from solving it with my little knowledge of OpenGL and with Google. A light is simulated by storing its intensity in the alpha channel of the pixel buffer, then the scene is rendered with this blending equation: glBlendFunc(GL_DST_ALPHA, GL_ONE) This process is repeated for each light. (An ambient light is used for light colour.) This works nicely but I also want to use transparency in sprites, stored in the alpha channel of TGA files. This is done with this equation: glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) I don't see how to combine the equations. It should be equivalent to (I think) glBlendFunc(GL_SRC_ALPHA * GL_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA) (if it was possible write that). I hope there is a way to do that. Thanks for any answer. :)
Advertisement
If i understand your question, you can render all transperent sprites in a FBO and then render the lightning stuff with the oter blending method.
Thank you for the help, it works. :)

I still have to place the generated texture properly, but this is another problem, which I think I'm able to solve myself.

Thanks. ;)

This topic is closed to new replies.

Advertisement