PDA

View Full Version : About FBO GL_COLOR_ATTACHMENTn



McLeary
03-08-2011, 08:42 AM
I was wondering why there's more than one color attachment in a FBO. As far as I know, all the color attachments have the render result (Am I correct?).

If this is true, why not render the color buffer to one texture and use that texture multiple times?

Alfonse Reinheart
03-08-2011, 08:46 AM
I was wondering why there's more than one color attachment in a FBO.

So that you can output multiple different values to multiple buffers from the same fragment shader.

McLeary
03-08-2011, 04:22 PM
Suppose I have a FBO with 2 color attachments. How, in the fragment shader, can I do this? (Never Saw a shader that does that)

Alfonse Reinheart
03-08-2011, 04:57 PM
Like this (http://www.opengl.org/wiki/Framebuffer_Object#Multiple_Render_Targets).

Dark Photon
03-09-2011, 05:12 PM
That's the modern way to do it.

Or if forced to use an old GLSL profile (GLSL 1.2 or earlier), write to gl_FragData[n], where n is an index into the bound draw buffers (http://www.opengl.org/sdk/docs/man/xhtml/glDrawBuffers.xml). These draw buffers themselves are identified with the COLOR_ATTACHMENTn enums.

McLeary
03-16-2011, 03:28 PM
Thank you guys, this saves my life, literally.

Since I need a multi platform application (windows, linux and mac), I need to use glsl 1.2, since MacOS does not offer support for OpenGL > 2.1