I am trying to pass vertex attributes from my vertex shader -> geometry shader and then to the fragment shader.
Pretty simple program, here is my vertex shader:
#version 440 core uniform mat4 uModelViewMatrix; uniform mat4 uProjMatrix; in vec4 aPosition; out vec3 modelPosition; void main() { modelPosition = aPosition.xyz; gl_Position = uProjMatrix * uModelViewMatrix * aPosition; } Here is my geometry shader:
#version 440 core layout (triangles) in; layout (triangle_strip, max_vertices = 3) out; in vec3 modelPosition[]; out vec3 gModelPosition[]; void main() { for (int i = 0; i < gl_in.length(); i++) { gl_Position = gl_in[i].gl_Position; EmitVertex(); } gModelPosition[0] = modelPosition[0]; gModelPosition[1] = modelPosition[1]; gModelPosition[2] = modelPosition[2]; EndPrimitive(); } And here is my fragment shader:
#version 440 core in vec3 gModelPosition; out vec4 fragColor; void main() { fragColor = vec4(gModelPosition, 1.0); } I get the following error:
PROGRAM_LINKING_ERROR: error: "gModelPosition" not declared as input from previous stage If I just comment out the last line in the fragment shader, and say fragColor = vec4(1.0); it works fine. And I clearly am declaring gModelPosition as an input from the previous stage.
Am I doing something wrong here?