Write into single colorAttachment in one drawcall

94 Views Asked by At

I created a fbo with two-color attachments i.e., colorAttachment0 and colorAttachment1.

so my question is I want to draw into single colorattachment in one draw call.

in my shader i tried this but not working:

if(attachmentVal==0) //I am sending the attachmentVal as uniform
{
outColor = vec4(1,0,0,0);
}
if(attachmentVal==1)
{
outColor2 = vec4(1,1,1,0);
}

But it is not working. so my question is, is it possible to render into a single attachment in a single draw call by controlling the selection of the attachment??

If possible please give me a solution to this problem.

Thank you.

1

There are 1 best solutions below

5
solidpixel On

Use glDrawBuffers() to select which attachments are active for the current draw.