I'm making a geometry shader that generates waves on a mesh (preferably a flat plane), using a heightMap.
Everything is working fine, except the normals don't really work out.
I set the normal for each vertex using the crossproduct, which is correct for each triangle individually.
However, the geometry shader goes over every vertex multiple times, so it will assign a different normal for every triangle (right?).
Which means it cannot interpolate correctly.
I tried to be creative and check for every vertex if its normal is default (0,1,0), like so:
if ((vertices.Normal.y >= 1.01f && vertices.Normal.y <= 0.99f)) normal0 = vertices.Normal;
else normal0 = normalize(cross(top0 - top1, top0 - top2));
So that it will reuse the normal if it's already assigned to that vertex. However, it's still giving me the same problem. Any ideas how to solve this?
Well, nevermind. I can just do the exact same in the vertex shader. Silly me.