# Render on other render targets starting from one already rendered on

I have to perform a double pass convolution on a texture that is actually the color attachment of another render target, and store it in the color attachment of ANOTHER render target. This must be done multiple time, but using the same texture as starting point

What I do now is (a bit abstracted, but what I have abstract is guaranteed to work singularly)

renderOnRT(firstTarget); // This is working.

for each other RT currRT{
glBindFramebuffer(GL_FRAMEBUFFER, currRT.frameBufferID);
programX.use();
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, firstTarget.colorAttachmentID);
programX.setUniform1i("colourTexture",0);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, firstTarget.depthAttachmentID);
programX.setUniform1i("depthTexture",1);
programX.vertexAttribPointer(POSITION_ATTRIBUTE, 3, GL_FLOAT, GL_FALSE, 0, (void*)0);

programY.use();
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, currRT.colorAttachmentID); // The second pass is done on the previous pass
programY.setUniform1i("colourTexture",0);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, currRT.depthAttachmentID);
programY.setUniform1i("depthTexture",1);
programY.vertexAttribPointer(POSITION_ATTRIBUTE, 3, GL_FLOAT, GL_FALSE, 0, (void*)0);
}


The problem is that I end up with black textures and not the wanted result.

The GLSL programs program(X,Y) works fine, already tested on single targets.

Is there something stupid I am missing?

Even an hint is much appreciated, thanks!

• The for contains the double pass convolution step? – Cristina Jun 12 '14 at 13:54
• @Cristina The programs programX and programY are build with the shaders that perform the convolution, they do work as they give the wanted result with a single target – JTulip Jun 12 '14 at 14:08

You are drawing to currRT, the first convolution step fills in currRT.colorTexture. Then in the second draw call you use currRT.colorTexture for the second step of the convolution. This produces undefined behavior in GL.