How to achieve smooth tangent space normals?

久未见 提交于 2019-11-27 02:02:45
Spektre

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!