0

I'm trying to perform simple geometry mirroring at the geometry shader stage. My vertex data comes out correctly but the vertex lighting is not correct for the mirrored geometry.

For the vertices i'm simply mirroring about the XZ plane which works fine for my needs;

a = VPosition[0];
a.y = -a.y;
b = VPosition[1];
b.y = -b.y;
c = VPosition[2];
c.y = -c.y;
gl_Position = ModelViewProj * vec4( a, 1.0 );
EmitVertex();
gl_Position = ModelViewProj * vec4( b, 1.0 );
EmitVertex();
gl_Position = ModelViewProj * vec4( c, 1.0 );
EmitVertex();
EndPrimitive();

But how to i mirror the vertex normals? Simply negating the normal y in the same way as the vertex doesn't seem to work.

E.g.

an = VNormal[0];
an.y = -an.y;
  • 2
    Why in the geometry shader and not in the vertex shader? Negating the y-component should work. Keep in mind that you reverse the face's vertex order if you use backface culling or anything orientation-dependent. Correcting the order might be an argument for the geometry shader. – Nico Schertler Dec 16 '16 at 21:02
  • Please show the actual code that "doesn't seem to work". Also, explain the way in which it "doesn't work". – Nicol Bolas Dec 16 '16 at 21:09
  • 1
    You should describe how the lighting is actually calculated, in which space, and what the vertex shader actually is doing. – derhass Dec 16 '16 at 21:09
  • Mirroring is perfomed in the geometry shader and not vertex shader as extra triangles are created and emitted. – Roger Floydman Dec 16 '16 at 21:47

0 Answers0