views:

106

answers:

1

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)?

+1  A: 

i want to give some examples:

void add(in float a, in float b, out float c)
{
    //you can not use c here. only set value
    //changing values of a and b does not change anything.
    c = a + b;
}

void getColor(out float r, out float g, out float b)
{
   //you can not use r, g, b here. only set value
   r = gl_FragColor.r;
   g = gl_FragColor.g;
   b = gl_FragColor.b;
}

void amplify(inout vec4 pixelColor, in value)
{
   //inout is like a reference
   pixelColor = pixelColor * value;
}
ufukgun