I wondered if anyone could give me some advice on a problem I am facing with FBOs.
As a basic example of what i’m trying to do, if I have a screen of 100x100, I create two FBOs, each the same size as the screen. On the first FBO I draw an ‘X’ on the top half, on the second FBO I draw a ‘Y’ on the bottom half. I then blit each FBO to the screen. However, when i do this i only see the contents of the final FBO I drew. Is there a way to allow both FBOs to be seen?
That’s what’s supposed to happen. glBlitFramebuffer() is a copy operation (with optional resizing and/or downsampling). It is not a compositing operation.
Thanks @Dark_Photon, I made the mistake of thinking blitting would composite instead of replace.
If it helps makes things any clearer as to what I’m trying to achieve:
I initially was not using an FBO (other than the default ‘screen’ FBO). I created a series of external textures (this is on Android ‘GLES11Ext.GL_TEXTURE_EXTERNAL_OES’ vs GL_TEXTURE_2D), drew them to their own quads and rendered them from back to front. This worked well and I was able to achieve the transparency I wanted using:
This meant that even though the quad filled the screen, if i didn’t draw something to a particular part of the quad, I could see the contents of the quad behind it.
However, I now need to be able to group certain textures so that I can apply transforms to them. My first attempt at this was using an FBO to represent the group, however when drawing these to the screen I was using ‘glBlitFramebuffer’ which as you have rightly pointed out is not the correct approach.
My latest attempt is to take the 2d textures (not external texture if this changes things) from the FBOs and draw those to the screen but I am running into the same problem as I did when using ‘glBlitFrameBuffer’. Is there a way to make the FBO textures behave (in regard to transparency) as my previous textures?
And what specifically do you mean by “group certain textures”. Do you mean, instead of rendering all layers back-to-front, compositing nearby layers into layer groups and then compositing the layer groups back-to-front? If so, you may find that a different Blend Function will serve you better than (SRC_ALPHA, ONE_MINUS_SRC_ALPHA). In particular, Premultiplied Alpha (ONE, ONE_MINUS_SRC_ALPHA).
Sure. That I can see, there is nothing fundamentally different about what you were doing (before the Blit detour) and what you’re trying to do now.
Perhaps you could illustrate the problem with a specific example?
Obviously, if you don’t rendering something that covers a specific pixel, the result can’t modify that pixel.