Reading the GLSL 1.40 specification:
Fragment outputs can only be float, floating-point vectors, signed or unsigned integers or integer vectors, or arrays of any these. Matrices and structures cannot be output. Fragment outputs are declared as in the following examples:
out vec4 FragmentColor; out uint Luminosity;
The fragment color is defined writing gl_FragColor... is it right? Somebody could clear my ideas about these outputs? May I write only 'FragmentColor' of the example to determine fragment color? May I read back them ('Luminosity' for example)?
Your example has 2 outputs. They have corresponding FBO slots associated after GLSL program linking. You can redirect them using glBindFragDataLocation
.
Once you activated the shader and bound FBO, it all depends on a draw mask, set by glDrawBuffers
. For example, if you passed GL_COLOR_ATTACHMENT0
and GL_COLOR_ATTACHMENT2
there, that would mean that output index 0 will go to the attachment 0, and output index 1 would go to the color attachment 2.