I have something like the following setup,
Vertex Shader (... for irrelevant stuff):
#version 330 core
uniform mat4 ModelViewMatrix;
...
in vec4 position;
...
out vec4 out_position;
...
void main()
{
...
out_position = ModelViewMatrix * position;
...
}
Geometry Shader (... for irrelevant stuff):
#version 330 core
...
uniform mat4 ProjectionMatrix;
...
layout(lines) in;
layout(triangle_strip, max_vertices = 4) out;
in vec4 out_position[];
...
void main()
{
vec4 lineDirection = out_position[1] - out_position[0];
vec4 scaledLineWidthDir = ...;
...
gl_Position = ProjectionMatrix * (lineDirection - scaledLineWidthDir);
EmitVertex();
gl_Position = ProjectionMatrix * (lineDirection + scaledLineWidthDir);
EmitVertex();
gl_Position = ProjectionMatrix * (-lineDirection + scaledLineWidthDir);
EmitVertex();
gl_Position = ProjectionMatrix * (-lineDirection - scaledLineWidthDir);
EmitVertex();
EndPrimitive();
}
but when I try to run the shader it appears as if the ModelViewMatrix is not being used (I get "Getting the location of inactive uniform" when trying to set it up), even thought I am using it to compute the gl_Position in the geometry shader. What gives?
It is my understanding that the geometry shader here takes in 2 vertices, and outputs 4, for the fragment shader to use, am I understanding and using geometry shaders correctly?