Here is the code:
Vertex shader:
#version 330
layout(std140) uniform;
layout(location = 6) in vec4 worldPosition;
layout(location = 7) in int FIndex;
flat out int[] passFIndex;
uniform Projection
{
mat4 view;
mat4 projection;
};
uniform mat3[6] FMatrix;
void main()
{
gl_Position = worldPosition;
passFIndex = int[](FIndex);
}
geometry shader:
#version 330
layout(std140) uniform;
layout(points) in;
layout(triangle_strip, max_vertices = 136) out;
flat in int[] passFIndex;
uniform Projection
{
mat4 view;
mat4 projection;
};
uniform mat3[6] FMatrix;
void main()
{
vec3 newPos = FMatrix[passFIndex[0]] * vec3(-0.5f, -0.5f, 0.5f);
...
So the problem is, the passFIndex is not being set properly when I set it equal to an array consisting of just the vertex attribute at location 7. The problem is, it's always set to 0. However, I KNOW the underlying vertex data for FIndex is not 0, because I can use a different shader program (one without a GS) and FIndex varies appropriately.
I can replace "passFIndex = int [ ] (FIndex)" with "passFIndex = int [ ] (2)" or some other constant in there, and that works to create an array with a non-zero, and it indexes as expected in the geometry shader. This seems to tell me that something is going wrong in the vertex shader but I can't imagine what it is.