0

So, these are my normals for a generated mesh, contrast boosted in gimp to make them easier to see: Normals

The mesh is a pyramid with a flat top. All of the normals are smoothed appropriately by averaging them will weighted surrounding face normals, and that works as expected.

However, as you can see, there are very noticeable seams wherever there are flat surfaces. With only diffuse lighting these are barely noticeable, but with specular they look hideous.

How can I get rid of these? My first thought was to replace all of the 6 vertex tiles with 12 vertex tiles, so that they would all be the same. However, that would of course double the size of the mesh. Is there any other way to do what I'm after?

EDIT: All of the corners have the triangles lain out to fit over their respective corners, all flat surfaces are split along the NE/SW.

Jagoly
  • 939
  • 1
  • 8
  • 32
  • 1. draw the normals as lines from their vertex to actually see what is really happening. 2. have you normalized your normals after averaging? – Spektre Aug 11 '14 at 06:18
  • 1: I'll try that, but can't I already gather all of that information from the colours displayed? 2: Yes – Jagoly Aug 11 '14 at 06:29
  • Actually, what I'm doing was getting the sum of sum of the weighted surrounding face normals, then normalizing that. But should do the same thing – Jagoly Aug 11 '14 at 06:33
  • yeap but if you have a bug in code then the normals can be computed wrongly so if you draw the lines you can visually check if their are correct or not. I compute the average normal without weighting .... – Spektre Aug 11 '14 at 06:39
  • look here http://stackoverflow.com/a/21930058/2521214 – Spektre Aug 11 '14 at 06:40
  • If I don't weight them, won't the lighting be completely wrong though? http://stackoverflow.com/questions/24925618/computing-normals-for-squares – Jagoly Aug 11 '14 at 06:46
  • If the normal is the same for the same vertex in all faces then No the lighting will be OK. (unless you are using some funny shader stuff dependent on face surface size) – Spektre Aug 11 '14 at 06:50
  • copied comments to answer so I can add image ... as you can see no lighting artifacts at all (per vertex normal shading) – Spektre Aug 11 '14 at 07:15

1 Answers1

1
  1. Draw the normals as lines from their vertex to actually see what is really happening.

    • just draw line for each vertex V and corresponding normal N

      double V[3],N[3],tmp[3];
      for (int i=0;i<3;i++) tmp[i]=V[i]+0.3*N[i]; // 0.3 is the line size ...
      glColor3f(0.0,0.5,0.0);
      glBegin(GL_LINES);
      glVertex3dv(V);
      glVertex3dv(N);
      glEnd();
      
    • this way you can easily visually check the correctness of normals

    • there should be single normal line per vertex on smooth areas
    • if there are more then there is your problem
    • for example this is how it should look: surface normals
    • green lines are the normals
    • triangle surface is generated by Bezier surface
    • normals are computed by crossproduct + smoothed (like in bullet 2)
    • left image is wireframe+normals
    • middle image is surface+normals
    • right just surface
  2. I use this normal averaging

Community
  • 1
  • 1
Spektre
  • 49,595
  • 11
  • 110
  • 380