Mirroring using the geometry shader

157 views Asked by At

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;
0

There are 0 answers