Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using gl_FragColor vs. out vec4 color?

There seems to be a lot of ambiguity about gl_FragColor being deprecated. For example, it is missing in the GLSL 4.40 specification, but it is included in the GLSL 4.60 specification.

What is the safest, most compatible, most supported strategy? Using gl_FragColor or defining a shader output like out vec4 color?

like image 476
IntellectualKitty Avatar asked Jul 21 '18 19:07

IntellectualKitty


People also ask

Is gl_FragColor deprecated?

Yes, gl_FragColor is deprecated. You should use the following syntax: layout(location = 0) out vec4 diffuseColor; It is included in the GLSL 4.60 spec under the section 7.1.

What is vec4 color?

a vec4 is a vector of 4 floating point values; in this case a color defined as RGBA (red, green, blue, alpha).

Is gl_Position deprecated?

As our collegue just said, gl_Position is not deprecated.

What is vec4 OpenGL?

vec4 is a floating point vector with four components. It can be initialized by: Providing a scalar value for each component. Providing one scalar value. This value is used for all components.


1 Answers

Yes, gl_FragColor is deprecated. You should use the following syntax:

layout(location = 0) out vec4 diffuseColor;

It is included in the GLSL 4.60 spec under the section 7.1.7. Compatibility Profile Built-In Language Variables. That means, if you create a core context this variable will not be available.

like image 195
dari Avatar answered Sep 21 '22 18:09

dari