<p>I assume you're talking about triangles with two vertices equal, and a third vertex at a different point. They don't appear in filled polygon mode because such triangles have zero area and don't cover any pixel centers. It's not that there's a special rule &quot;degenerate triangles are dropped&quot;, it's that they naturally don't generate any fragments when rasterized. (GPUs may still detect and drop degenerate triangles early in the pipeline as an optimization.)</p>
<p>But when drawn as lines, there is no reason why the lines would be dropped. The rasterization rules for lines always produce a line of the specified width in pixels, and when you draw the triangle's edges as lines, if the edges are nonzero length then they will show up.</p>
<p>There is no mode to control this that I'm aware of. There used to be a thing called &quot;edge flags&quot; that could control which edges of each triangle were rasterized or not, but that was deprecated from GPU APIs long ago.</p>
<p>For other options, you could try to use <a href="https://www.khronos.org/opengl/wiki/Vertex_Rendering#Primitive_Restart" rel="nofollow noreferrer">primitive restart</a> to avoid needing degenerate triangles at all, or you could create a separate index buffer for wireframe rendering that doesn't include the degenerate triangles.</p>

CC BY-SA 4.0
2021-06-24T16:48:41.760Z
2021-06-24T16:48:41.760Z
Nathan Reed
<p>I have made use of degenerate triangles when rendering a mesh. While the degenerate triangles are not rasterized when using <code>GL_FILL</code> polygon mode, they are when I do mesh debugging with <code>GL_LINE</code> mode.</p>
<p>Why is this the case? Are there any options to prevent rasterization in <code>GL_LINE</code> mode?</p>

CC BY-SA 4.0
2021-06-26T00:08:01.090Z
A geometry shader could take triangles in and output lines, output nothing for degenerate triangles.
pmw1234
<opengl><rasterizer>
Why are degenerate triangles rasterized when using GL_LINE polygon mode
Lenny White
# Why are degenerate triangles rasterized when using GL_LINE polygon mode

(Asked by: username_0 on 2021-06-24)

I have made use of degenerate triangles when rendering a mesh. While the degenerate triangles are not rasterized when using `GL_FILL` polygon mode, they are when I do mesh debugging with `GL_LINE` mode.

Why is this the case? Are there any options to prevent rasterization in `GL_LINE` mode?

**Tags:** opengl, rasterizer

> **Comments:**
> **username_1**: A geometry shader could take triangles in and output lines, output nothing for degenerate triangles.  

---

## 1 answers

### Answer by username_2 on 2021-06-24. Score: 4 | Accepted answer

I assume you're talking about triangles with two vertices equal, and a third vertex at a different point. They don't appear in filled polygon mode because such triangles have zero area and don't cover any pixel centers. It's not that there's a special rule "degenerate triangles are dropped", it's that they naturally don't generate any fragments when rasterized. (GPUs may still detect and drop degenerate triangles early in the pipeline as an optimization.)

But when drawn as lines, there is no reason why the lines would be dropped. The rasterization rules for lines always produce a line of the specified width in pixels, and when you draw the triangle's edges as lines, if the edges are nonzero length then they will show up.

There is no mode to control this that I'm aware of. There used to be a thing called "edge flags" that could control which edges of each triangle were rasterized or not, but that was deprecated from GPU APIs long ago.

For other options, you could try to use [primitive restart](https://www.khronos.org/opengl/wiki/Vertex_Rendering#Primitive_Restart) to avoid needing degenerate triangles at all, or you could create a separate index buffer for wireframe rendering that doesn't include the degenerate triangles.


---

