Confuzed. Per vertex normals,tangents and binormals for smooth rendering

hello.
I have a 3ds loader that also compute per face normals, per face tangents and per face binormals.
But the results is ugly :frowning: (not smooth).
To make it smooth I must compute the per vertex normals, per vertex tangents and per vertex binormals. Any idea how I will do that?

thanks

Try iterating over each triangle in the mesh, calculating each triangle’s normal as you go, and adding the normal to each vertex in the triangle.

for( each mesh triangle T )
{
    Vertex& A = verts[T.indices[0]];
    Vertex& B = verts[T.indices[1]];
    Vertex& C = verts[T.indices[2]];
   
    // Assume a clockwise winding
    Vector N = normalize(cross(C.pos - A.pos, B.pos - A.pos));
    
    // Accumulate normals
    A.N += N;
    B.N += N;
    C.N += N;
}

Once you have iterated the entire triangle list, iterate over the vertices and normalize the normals. From these vertex normals you can derive the tangent and binormal vectors using a variety of methods.

I assume you already have the data structures in place.

Hi!
I recently did something of that sort for Doom 3 models (though I’m having a normalizing cube map dilemna)… anyways, the bottom of this page Bump mapping tutorial mentions breifly how to do the tangent, normal, and binormal for a polygon, and it is easily extened to a mesh, by summing the per triangle tangent basis vectors (normal, binormal, tangent) for each component vertex in the triangle, then normalizing the three vectors for each vertex after going through all of the triangles. Next, for each vertex, compute the vector to the light source(s), and eye position for specular lighting, and the transformed tangent space VertexToLight and VertexToEye are:

TSLight.x = sTangent DOT3 VertexToLight;
TSLight.y = tTangent DOT3 VertexToLight;
TSLight.z = vertNormal DOT3 VertexToLight;

TSEye.x = sTangent DOT3 VertexToEye;
… …

Later, Mike

Mike, did you fix your cubemap?

I’ve been playing with those Doom3 models recently, too. Cyberdemon blew me clean away :eek: