How to achieve smooth tangent space normals?

For smooth surfaces (no edges) I do it like this:

  1. create space for per vertex

    double N[3]; //normal
    int cnt;
    
  2. per vertex init

    N={0.0,0.0,0.0}
    cnt=0;
    
  3. compute per face normal

    normal must be normalized length=1.0 !!! add this Normal to all vertexes used in face and increment cnt to all vertexes used in face

  4. per vertex normalize

    N/=cnt; // N = average normal from all vertex - neighbour faces
    

    be aware of cnt=0 for unused vertexes (division by zero)

  5. per vertex N contains the Normal you want

    now compute T,B vectors for TBN matrix (per vertex) as you do now

  6. output image is smooth

    My earth preview (with atmospheric scattering, bump mapping and more…) is here

hope it helps

Leave a Comment