To get a normal of vertex[x, z], make a vector from vertex[x-1, z] to vertex[x+1, z], and another vector from vertex[x, z-1] to vertex[x, z+1]. The normal is the normalized cross product of these two vectors.
Actually it is just a water texture with a water algorithm applied to the y axis. I have a calculateNormals() function that takes 3 vertices, but I don’t think it will work in this case. What I am doing is creating a triangle strip out of two triangles out of 4 vertices like:
2 1
|\ |
||
4 3
Does what you proposed still work for this scenario? Or do I have to calculate the normal for each triangle and then average them?
Thanks for your help.
[This message has been edited by dcd (edited 02-06-2003).]
So in fact it is a heightmap, when you think of it. Yes, this will work with it too.
Calculating normals by averaging face normals isn’t an absolute solution you should use everywhere. I kept doing it for years, but it actually gives quite bad results sometimes. It’s just a general technique that can be used with arbitary models. For heightmaps you don’t need it.