0

I have a webgl shader set up with some shaders. I'm using multiple render targets (gl_FragData[])

In the first shader, I can output to

gl_FragData[0] = vec4(..);
gl_FragData[1] = vec4(..);
gl_FragData[2] = vec4(..);

Now with my second shader, I want to output to gl_FragData[3] and save the texture to pass to my third shader.

The second shader doesn't seem to output to gl_FragData[3], yet this works if I use it in my first shader. I want the output of gl_FragData[3] to be stored in a texture and sent to the third shader.

I think it may have to do with the framebuffer, but I've tried changing that and have had no luck. What am I missing?

1
  • Why not just make 2 framebuffers. One with 3 attachments, one with 1 attachment, output to gl_FragData[0] in the second shader Commented Apr 8, 2017 at 13:39

1 Answer 1

0

If you want to use the same framebuffer, you'll need to mask off the unused draw buffers: drawBuffers([COLOR_ATTACHMENT0, COLOR_ATTACHMENT1, COLOR_ATTACHMENT2]) for the first shader, and drawBuffers([NONE, NONE, NONE, COLOR_ATTACHMENT3]) for the second shader.

From EXT_draw_buffers:

Any colors, or color components, associated with a fragment that are not written by the fragment shader are undefined.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.