I am absolutely running out of time and I’m hoping I can get a clear answer from here.
I need MRTs for a project. I successfully used FBOs before but never with multiple render targets. My test structure is this:
1 FBO (call it A)
Attach A four textures at Attachments 0,1,2 and 3
Each of the four textures are at texture levels 0, 1, 2, 3 (GL_TEXTUREi)
I output to those textures in frag shader as this:
fragOutput0 = vec4( 1.0, 0.0, 0.0, 1.0 );
fragOutput1 = vec4( 1.0, 1.0, 1.0, 1.0 );
fragOutput2 = vec4( 1.0, 1.0, 1.0, 1.0 );
fragOutput3 = vec4( 1.0, 1.0, 1.0, 1.0 );
Each of these fragOutputs are bound to 0,1,2,3 during linking stage of the shader.
Then I feed in these four textures into a new frag shader pass. I initialize the texture sampler positions at 0,1,2,3. At every frame before I initialize the second shader I bound these four textures to the four texture locations (GL_TEXTUREi) just in case.
And I draw the output of the second frag shader on screen.
The output is just one-to-one copy of the texture. I basically output whatever is in each of the textures and the problem is that they all have the same thing! (RED color as I output to out location 0 in first shader). It’s almost like I’ve bound all of them to the attachment0 location but I haven’t, they are all different, they are all different textures, attached to the different attachment places in the FBO and I assume they should be outputted as the first texture red and the rest all black. But all of them are red.
I have no idea why. Help?
Thanks.