GraphicalDamon
10-16-2011, 10:08 AM
Hello! This is hopefully a quick one.
Is it possible to pass an array as a varying into a geometry shader from a vertex shader? I'm filling an array with position values in the vertex shader, and then I'm trying to use those positions in the geometry shader to output vertices. Needless to say, it's not working.
I have this in the vertex shader:
varying vec4 wPositions[7];
... code to fill wPositions with data ...
And this in the geometry shader:
varying vec4 wPositions[7];
for (int i = 0; i < 7; i++) {
gl_Position = wPositions[i];
gl_TexCoord[2] = wPositions[i];
EmitVertex();
EndPrimitive();
}
In the fragment shader I'm using gl_TexCoord[2] as the position for splatting into a texture map. Basically this code at a high level takes one vertex from the vertex shader and splits it into seven positions (each in a slightly different location), which are then supposed to be passed to and output by the geometry shader, and all seven are splatted with the fragment shader. However, the position data is getting lost somewhere, because all the points are being splatted at (0, 0) in the texture map.
Is it possible to pass an array as a varying into a geometry shader from a vertex shader? I'm filling an array with position values in the vertex shader, and then I'm trying to use those positions in the geometry shader to output vertices. Needless to say, it's not working.
I have this in the vertex shader:
varying vec4 wPositions[7];
... code to fill wPositions with data ...
And this in the geometry shader:
varying vec4 wPositions[7];
for (int i = 0; i < 7; i++) {
gl_Position = wPositions[i];
gl_TexCoord[2] = wPositions[i];
EmitVertex();
EndPrimitive();
}
In the fragment shader I'm using gl_TexCoord[2] as the position for splatting into a texture map. Basically this code at a high level takes one vertex from the vertex shader and splits it into seven positions (each in a slightly different location), which are then supposed to be passed to and output by the geometry shader, and all seven are splatted with the fragment shader. However, the position data is getting lost somewhere, because all the points are being splatted at (0, 0) in the texture map.