I have implemented an algorithm to calculate vertex normals by taking the normalized average of all its adjacent triangles. I have subdivided a cube two times with catmull clark and checked the shading. If you look close at the first image you can have these dark lines than run along the topological edges of the mesh (defined in the second picture).

Is this normal (no pun intented) and have to do with vertex normals being just an approximation of surface normals? If so why exactly does these artifacts occur? Or have I probably done something wrong with how I calculated the normals?

enter image description here enter image description here enter image description here

  • 2
    $\begingroup$ Looks like the optical illusion known as en.wikipedia.org/wiki/Mach_bands $\endgroup$
    – lightxbulb
    Aug 6 '21 at 9:41
  • $\begingroup$ @lightxbulb I see thanks! I just wanted to clarify. I see clear mach bands where's the edge between the light and shadow. And I meant along the topological edges that you can see defined in the second picture. These are mach bands then too right? Whatever reason might be behind the issue, this causes very ugly shading. Do you know if there're any ways to avoid this? Maybe use different shading algorithm in fragment shaders? $\endgroup$ Aug 6 '21 at 19:49
  • $\begingroup$ I think the issue is a disconitnuous derivative, which you see there. I assume that if your normals are proper (I am not certain about that), and one uses non-linear interpolation (e.g. slerp with 3 vectors) then one should be able to get the proper shading. This is too expensive however, and people usually opt to just increase the triangle count. $\endgroup$
    – lightxbulb
    Aug 6 '21 at 20:07
  • $\begingroup$ Here is an interesting blog on this subject (and interpolation in general): asawicki.info/… $\endgroup$
    – pmw1234
    Aug 6 '21 at 21:14
  • $\begingroup$ @pmw1234 While I liked the blog I am not sure how quadrilateral interpolation is relevant to the question, maybe I am missing something. On a side note, this may be relevant: researchgate.net/publication/… $\endgroup$
    – lightxbulb
    Aug 6 '21 at 21:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.