PDA

View Full Version : Blending two frame buffers!



sminith
06-28-2013, 05:57 AM
How to blend two frame buffers in OpenGL?
Let the first one be the default frame buffer (either front or back) and the second one be an overlay buffer. These two frame buffers need to get blended.
Please respond to this query.

Hannibal
06-28-2013, 08:11 AM
Just an idea:
You could use two 2D squares that fit your screen size, assign a texture to each and render into those textures.
When you render the two squares with their textures enable blending.

GClements
06-29-2013, 10:57 AM
Just an idea:
You could use two 2D squares that fit your screen size, assign a texture to each and render into those textures.
When you render the two squares with their textures enable blending.
If you only need the sort of blending provided by glBlendFunc(), you can render one image directly to the framebuffer and the other into a texture, then render the texture onto the existing framebuffer with blending.

If you don't have render-to-texture (glFramebufferTexture), you'll have to render into the framebuffer then copy the data to a texture with e.g. glCopyTexImage2D().

Hannibal
07-02-2013, 12:56 AM
If you only need the sort of blending provided by glBlendFunc(), you can render one image directly to the framebuffer and the other into a texture, then render the texture onto the existing framebuffer with blending.
You are right. One texture is enough to blend it with the default frame buffer.

marcClintDion
07-02-2013, 11:20 AM
Perhaps I'm doing things the round about way but I've found it useful to attach a framebuffer to the rendering of a screen aligned quad. Now you may composite several FBO's together using multi-texturing and capture the result as another texture.

sminith
08-17-2013, 08:37 AM
Thank you. We are rendering the object to a user defined frame buffer as a color attachment texture and blending it with the default frame buffer. But we have some confusion regarding the blending function.