Jump to content
  • Advertisement
Sign in to follow this  
Nanaky

OpenGL Combining two blending functions

This topic is 4267 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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. :)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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. ;)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!