I have to compute vertex normals for combined TRIANGLE_STRIPs. The combination results in grounds (terrain) consisting of those TRIANGLE_STRIPs.
I wonder how I will be able to compute a normal for each vertex.
Because computing a normal for each triangle only would result in per triangle lighting. I prefer per vertex lighting to have smooth edges between the triangles.
Please help me, am I right with this statement?
The next question: How do I compute a normal for each vertex in a TRIANGLE_STRIP?
Exacly the same way you compute the normal for ordinary triangles… You could average the normals of triangles that share the same vertex and store the result as that vertex normal. This may give you smooth edges, but you should make sure that you model has no sharp edges.
For about your statement, I’m actually pretty sure you can’t do any per face normals with triangle strips. For that point to be true, all the strip needs to represent the same surface flat plane, which obviously is not the case for terrains.
You can’t have per-face normals because vertices are shared between faces. OpenGL interpolates the vertex normal across the face to perform lighting (not really corrent, as only color will be interpolated). Because of this, the only one possibility to get per-face normals is to specify the same normal for each vertex of the face. You can’t do it in your case, as vertices are shared.
Averaging the normals
step 1:
set all normals to (0,0,0)
for all faces:
for all face vertices set vertex normal to the sum of vertex normal and face normal
Of course you can have smooth terrain with strips, this is the way to do: per vertex normals are made for that point.
Also, using index array with strips is not really a need.
And as others said, lineary interpolate all face normals for each vertex and you’ll have something really acceptable in most of situations.
For more accurate normals you’ll need a parametric representation of your surface.