<p>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.</p>

<p>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.</p>

<p>As Nicol alluded to however, you may not get perfectly watertight rendering—or a perfect match in the shading—when constructing a mesh with <a href="https://computergraphics.stackexchange.com/questions/1461/why-do-t-junctions-in-meshes-result-in-cracks">T-junctions</a> like this.</p>

<p><img src="https://i.sstatic.net/pJ6zm.png" alt="wireframe marked with vertices">]</p>

CC BY-SA 4.0
2019-11-02T22:55:57.767Z
2019-11-02T22:55:57.767Z
Nathan Reed
<p>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:
<a href="https://i.sstatic.net/CtwSH.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/CtwSH.png" alt=""></a><a href="https://i.sstatic.net/8vTR6.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/8vTR6.png" alt=""></a></p>

CC BY-SA 4.0
2019-11-02T22:30:28.203Z
"*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.
Nicol Bolas
CC BY-SA 4.0
2019-11-02T22:36:11.950Z
@NicolBolas the varying cell sizes are only at a certain distance from the camera, so I don't worry much about those gaps
Jonan
CC BY-SA 4.0
2019-11-04T03:18:35.347Z
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.
PaulHK
CC BY-SA 4.0
2019-11-05T11:26:27.370Z
Just to add to @PaulHK 's comment:  there is a description on the problems of T-Junctions in this thread https://computergraphics.stackexchange.com/a/1464/209
Simon F
<3d><mesh>
Calculating normals for vertices which aren't a vertex of all neighbouring triangles
Jonan
# Calculating normals for vertices which aren't a vertex of all neighbouring triangles

(Asked by: username_0 on 2019-11-02)

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:
[![](https://i.sstatic.net/CtwSH.png)](https://i.sstatic.net/CtwSH.png)[![](https://i.sstatic.net/8vTR6.png)](https://i.sstatic.net/8vTR6.png)

**Tags:** 3d, mesh

> **Comments:**
> **username_1**: "*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.  
> **username_0**: @username_1 the varying cell sizes are only at a certain distance from the camera, so I don't worry much about those gaps  
> **username_2**: 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.  
> **username_3**: Just to add to @username_2 's comment:  there is a description on the problems of T-Junctions in this thread https://computergraphics.stackexchange.com/a/1464/209  

---

## 1 answers

### Answer by username_4 on 2019-11-02. Score: 3 | Accepted answer

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 username_1 alluded to however, you may not get perfectly watertight rendering—or a perfect match in the shading—when constructing a mesh with [T-junctions](https://computergraphics.stackexchange.com/questions/1461/why-do-t-junctions-in-meshes-result-in-cracks) like this.

![wireframe marked with vertices](https://i.sstatic.net/pJ6zm.png)]


---

