CortS
07-20-2010, 01:13 PM
I'm seeing strange behavior while trying to set up multiple render targets.
I'm setting up an FBO with three color attachments, rendering a test object, and then combining the three offscreen buffers in a separate pass. The GLSL program I'm using to render the test object declares three output fragment colors (outFrag0, outFrag1 and outFrag2), which I've mapped to the three render targets using glDrawBuffers() and glBindFragDataLocation(). All of this appears to work correctly; the final composited frame looks correct, and if I inspect each of the three render targets individually, they all contain the expected data. So far so good.
The problem comes if I switch to a GLSL program that doesn't write to all three render targets. If I use a program that only writes to outFrag0, for example, I would expect that nothing would be written to outFrag1 and outFrag2. Instead, I end up with the same data written to all three render targets. If I write to outFrag0 and outFrag1, then render target #3 gets a copy of the data in render target #2.
Is this the intended behavior? If I bind an FBO with N render targets, do all of my shaders need to explicitly write to all N render targets? That seems like a needless waste of bandwidth, if nothing else.
I can post code if necessary, but I wanted to validate the theory first.
Thanks!
- cort
I'm setting up an FBO with three color attachments, rendering a test object, and then combining the three offscreen buffers in a separate pass. The GLSL program I'm using to render the test object declares three output fragment colors (outFrag0, outFrag1 and outFrag2), which I've mapped to the three render targets using glDrawBuffers() and glBindFragDataLocation(). All of this appears to work correctly; the final composited frame looks correct, and if I inspect each of the three render targets individually, they all contain the expected data. So far so good.
The problem comes if I switch to a GLSL program that doesn't write to all three render targets. If I use a program that only writes to outFrag0, for example, I would expect that nothing would be written to outFrag1 and outFrag2. Instead, I end up with the same data written to all three render targets. If I write to outFrag0 and outFrag1, then render target #3 gets a copy of the data in render target #2.
Is this the intended behavior? If I bind an FBO with N render targets, do all of my shaders need to explicitly write to all N render targets? That seems like a needless waste of bandwidth, if nothing else.
I can post code if necessary, but I wanted to validate the theory first.
Thanks!
- cort