In my procedurally generated mesh in Unity, not all vertices are vertexes of all neighbouring triangles - essentially, it's a grid with cells of varying sizes. This is messing up the calculation of normals however, making the lightning not smooth. How should I account for this? This is a part of the mesh to illustrate what I mean, in shaded wireframe and shaded mode:

  • 1
    $\begingroup$ "it's a grid with cells of varying sizes" Then fix that. You only get guarantees of seamless rendering if the triangles have binary-identical shared vertex positions. The way you're building your meshes, it is very possible that you can get gaps in your rendering, small dots between the "neighboring" triangles that show the background. $\endgroup$ Commented Nov 2, 2019 at 22:30
  • $\begingroup$ @NicolBolas the varying cell sizes are only at a certain distance from the camera, so I don't worry much about those gaps $\endgroup$
    – Jonan
    Commented Nov 2, 2019 at 22:36
  • 1
    $\begingroup$ These gaps can occur at any distance. Even if know the edges are parallel because the interpolation from both edges have different start and end points we cannot guarantee the edges along the same scanline are exactly at the same pixel. $\endgroup$
    – PaulHK
    Commented Nov 4, 2019 at 3:18
  • $\begingroup$ Just to add to @PaulHK 's comment: there is a description on the problems of T-Junctions in this thread computergraphics.stackexchange.com/a/1464/209 $\endgroup$
    – Simon F
    Commented Nov 5, 2019 at 11:26

1 Answer 1


For the shading to match, the normals (and any other vertex attributes) of the small triangles' verts would have to match the linear interpolation along the large triangle edge that they adjoin to.

For example: all the vertices in the green box below would need to be set by interpolating between the two blue vertices, based on their position along that edge.

As Nicol alluded to however, you may not get perfectly watertight rendering—or a perfect match in the shading—when constructing a mesh with T-junctions like this.

wireframe marked with vertices]


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.