<p>When modeling parametric surfaces with a mesh in the parameter domain, T-junctions will most probably appear as <em>discontinuities</em> in the surface. These will show up as gaps in the rendering. See below.</p>

<p>More generally, T-junctions in triangle meshes will probably result in discontinuities of interpolated attributes, such as color and normals.</p>

<p><a href="https://i.sstatic.net/5U2ei.png" rel="noreferrer"><img src="https://i.sstatic.net/5U2ei.png" alt="enter image description here"></a>
<a href="https://i.sstatic.net/d2248.png" rel="noreferrer"><img src="https://i.sstatic.net/d2248.png" alt="enter image description here"></a></p>

CC BY-SA 3.0
2015-09-09T01:48:28.167Z
See also http://stackoverflow.com/questions/23530807/glsl-tessellated-environment-gaps-between-patches.
lhf
CC BY-SA 3.0
2015-09-09T01:44:12.587Z
2015-09-09T01:52:32.200Z
2015-09-09T01:52:32.200Z
lhf
<p>Floating-point rounding error.</p>

<p>After you transform the T junction and the point in the T can get rounded away from the edge.</p>

<p>Then it can happen that a fragment that gets sampled for a pixel lies in the gap between the 2 surfaces.</p>

<p>This can be fixed by not having a T-junction in the first place.</p>

CC BY-SA 3.0
2015-09-09T08:04:11.530Z
2015-09-09T08:04:11.530Z
ratchet freak
<p>The simple way to avoid this is to ensure that all your vertices are welded</p>

<p>You issue is that you have cuts along edges with a vertex, but you do not have a corresponding vertex on the adjacent edge to weld/connect it to, if you think of it like a button on a shirt, you've sown on a button to the edge, but haven't given it a hole so the fabric is open.</p>

<p>In the picture below, the red dots represent correctly welded vertices, the blue dots all need an additional vertex to be cut in to the adjacent edge.</p>

<p><a href="https://i.sstatic.net/Xy7f2.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Xy7f2.png" alt="enter image description here"></a></p>

<p>Generally speaking it is good practice to keep your modelling in quad's &amp; tri's, this helps to alleviate this issue as you should always have a corresponding vertex to weld too. It also helps to keep to quads if you plan to use any subdivision methods on the mesh.</p>

CC BY-SA 3.0
2015-09-09T09:04:21.967Z
2015-09-09T09:04:21.967Z
MephistonX
<p>lhf's answer is good from the perspective of tessellation, but these can occur with simpler triangle mesh use cases.</p>

<p>Take this trivial example of three, <em>screen-space</em> triangles, ABC, ADE and DBE...</p>

<p><a href="https://i.sstatic.net/sFxmG.png" rel="noreferrer"><img src="https://i.sstatic.net/sFxmG.png" alt="enter image description here"></a> </p>

<p>Although point E was, mathematically, intended to be exactly on the line segment AB, the pipeline won't be using fully precise values, such as rational numbers (e.g. <a href="https://gmplib.org/" rel="noreferrer">https://gmplib.org/</a>). Instead, it will likely be using floats, and so some approximation/error will be introduced. The result is probably going to be something like:</p>

<p><a href="https://i.sstatic.net/2QYZw.png" rel="noreferrer"><img src="https://i.sstatic.net/2QYZw.png" alt="enter image description here"></a></p>

<p>Note that <em>all</em> of the vertices may have inaccuracies. Although the example above shows a crack, the T-junction may instead result in overlap along the edge causing pixels to be drawn twice. This might not seem as bad, but it can cause problems with transparency or stencil operations.</p>

<p>You <em>might</em> then think that with floating-point the error introduced will be insignificant, but in a renderer, the screen-space vertex (X,Y) values <em>are nearly always represented by fixed-point numbers</em> and so the displacement from the ideal location will usually be much greater. Further, as the rendering hardware "interpolates" the line segment pixel-by-pixel with its own internal precision, there is even more chance it will diverge from the rounded location of E.</p>

<p>If the T-junction is "removed" by, say, also dividing triangle ABC into two, i.e. AEC and EBC, the problem will go away as the shifts introduced by the errors will all be consistent.</p>

<p>Now, you might ask why do renderers (especially HW) use fixed-point maths for the vertex XY coordinates? Why don't they use floating-point in order to reduce the problem? Although some did (e.g. Sega's Dreamcast) it can lead to another problem where the triangle set-up maths becomes catastrophically inaccurate, particularly for long-thin triangles, and they change size in unpleasant ways.</p>

CC BY-SA 3.0
2015-09-09T20:17:47.533Z
When you say "vertex (X,Y) values are nearly always represented by fixed-point numbers", I'm guessing you mean the screen-space vertex coordinates in the rasterizer, right? Not the original model-space vertices.
Nathan Reed
CC BY-SA 3.0
2015-09-10T05:41:56.587Z
@NathanReed Yes. Just the screen-space X&Y (and, perhaps on some GPUs the Z).  I'll edit it to make that clearer.
Simon F
CC BY-SA 3.0
2015-09-09T08:38:29.530Z
2015-09-28T10:31:28.150Z
2015-09-28T10:31:28.150Z
Simon F
<p>I have heard from many sources that having T-junctions in 3D meshes is a bad idea because it could result in cracks during rendering. Can someone explain why that happens, and what one can do to avoid them?</p>

CC BY-SA 3.0
2015-09-09T01:35:03.463Z
See http://stackoverflow.com/questions/21593786/in-gouraud-shading-what-is-the-t-junction-issure-and-how-to-demonstrate-it-with.
lhf
<mesh>
Why do T-junctions in meshes result in cracks?
ap_
# Why do T-junctions in meshes result in cracks?

(Asked by: username_0 on 2015-09-08)

I have heard from many sources that having T-junctions in 3D meshes is a bad idea because it could result in cracks during rendering. Can someone explain why that happens, and what one can do to avoid them?

**Tags:** mesh

> **Comments:**
> **username_1**: See http://stackoverflow.com/questions/21593786/in-gouraud-shading-what-is-the-t-junction-issure-and-how-to-demonstrate-it-with.  

---

## 4 answers

### Answer by username_4 on 2015-09-09. Score: 24 | Accepted answer

lhf's answer is good from the perspective of tessellation, but these can occur with simpler triangle mesh use cases.

Take this trivial example of three, *screen-space* triangles, ABC, ADE and DBE...

[![enter image description here](https://i.sstatic.net/sFxmG.png)](https://i.sstatic.net/sFxmG.png)

Although point E was, mathematically, intended to be exactly on the line segment AB, the pipeline won't be using fully precise values, such as rational numbers (e.g. <https://gmplib.org/>). Instead, it will likely be using floats, and so some approximation/error will be introduced. The result is probably going to be something like:

[![enter image description here](https://i.sstatic.net/2QYZw.png)](https://i.sstatic.net/2QYZw.png)

Note that *all* of the vertices may have inaccuracies. Although the example above shows a crack, the T-junction may instead result in overlap along the edge causing pixels to be drawn twice. This might not seem as bad, but it can cause problems with transparency or stencil operations.

You *might* then think that with floating-point the error introduced will be insignificant, but in a renderer, the screen-space vertex (X,Y) values *are nearly always represented by fixed-point numbers* and so the displacement from the ideal location will usually be much greater. Further, as the rendering hardware "interpolates" the line segment pixel-by-pixel with its own internal precision, there is even more chance it will diverge from the rounded location of E.

If the T-junction is "removed" by, say, also dividing triangle ABC into two, i.e. AEC and EBC, the problem will go away as the shifts introduced by the errors will all be consistent.

Now, you might ask why do renderers (especially HW) use fixed-point maths for the vertex XY coordinates? Why don't they use floating-point in order to reduce the problem? Although some did (e.g. Sega's Dreamcast) it can lead to another problem where the triangle set-up maths becomes catastrophically inaccurate, particularly for long-thin triangles, and they change size in unpleasant ways.

> **Comments:**
> **username_5**: When you say "vertex (X,Y) values are nearly always represented by fixed-point numbers", I'm guessing you mean the screen-space vertex coordinates in the rasterizer, right? Not the original model-space vertices.  
> **username_4**: @username_5 Yes. Just the screen-space X&Y (and, perhaps on some GPUs the Z).  I'll edit it to make that clearer.  

---

### Answer by username_1 on 2015-09-09. Score: 9

When modeling parametric surfaces with a mesh in the parameter domain, T-junctions will most probably appear as *discontinuities* in the surface. These will show up as gaps in the rendering. See below.

More generally, T-junctions in triangle meshes will probably result in discontinuities of interpolated attributes, such as color and normals.

[![enter image description here](https://i.sstatic.net/5U2ei.png)](https://i.sstatic.net/5U2ei.png)
[![enter image description here](https://i.sstatic.net/d2248.png)](https://i.sstatic.net/d2248.png)

> **Comments:**
> **username_1**: See also http://stackoverflow.com/questions/23530807/glsl-tessellated-environment-gaps-between-patches.  

---

### Answer by username_2 on 2015-09-09. Score: 5

Floating-point rounding error.

After you transform the T junction and the point in the T can get rounded away from the edge.

Then it can happen that a fragment that gets sampled for a pixel lies in the gap between the 2 surfaces.

This can be fixed by not having a T-junction in the first place.


---

### Answer by username_3 on 2015-09-09. Score: 2

The simple way to avoid this is to ensure that all your vertices are welded

You issue is that you have cuts along edges with a vertex, but you do not have a corresponding vertex on the adjacent edge to weld/connect it to, if you think of it like a button on a shirt, you've sown on a button to the edge, but haven't given it a hole so the fabric is open.

In the picture below, the red dots represent correctly welded vertices, the blue dots all need an additional vertex to be cut in to the adjacent edge.

[![enter image description here](https://i.sstatic.net/Xy7f2.png)](https://i.sstatic.net/Xy7f2.png)

Generally speaking it is good practice to keep your modelling in quad's & tri's, this helps to alleviate this issue as you should always have a corresponding vertex to weld too. It also helps to keep to quads if you plan to use any subdivision methods on the mesh.


---

