yes, left to right, heh, sorry I'd only been awake like 15mins when I wrote that [grin]
Anyways, you've been tripped up by something which caught me as well when I first used Geo-shaders; in and out varyings.
With a Geo-shader you have to specifiy which varyings are inputs from the VS and which are outputs to the VS.
With that in mind your code becomes;
#version 120 #extension GL_EXT_geometry_shader4 : enablevarying in vec3 normal[gl_VerticesIn];varying out vec3 oNormal;void main(void){ for(int i=0; i< gl_VerticesIn; i++) { oNormal = normal; gl_Position = gl_PositionIn; gl_TexCoord = gl_TexCoordIn; EmitVertex(); } EndPrimitive();}
Note the extra varyings and the addition of the
in and
out qualifiers on the types to tell the compiler how we are using them. Also, note that the
in varying is an array, just like the built in vars you already read; this is because we are operating at geometry level so you, of course, have access to the varyings of the vertices in your primative.
Then in the main loop you just pass through the data as before so that you can get at it in the fragment shader (which needs the varying changed from 'normal' to 'oNormal' to match the output from the Geo-Shader.
Also, an important thing to remember is there is no 'magic' here; if you don't read something in a stage and pass it on then a latter stage can't get at it. So, if you don't read the normals in the geo-shader and pass them on the pixel shader won't magically get a copy; the pipeline has effectively just forgotten about it. Always pass the data down the line; uniforms are the only thing every stage can get to globally.