<p>I understand that your pipeline looks like this: Transform polygon vertices -&gt; clip polygon -&gt; triangulate -&gt; draw edges of each triangle.</p>
<p>I would start with simple line drawing and disregard the clipping, filling and triangulation for now and see if the shaking still occurs. Then you can try to add the triangulation and the rest, one by one.</p>
<p>There is a couple of things that seem suspicous to me in the third video (see attached image):</p>
<ol>
<li>The horizontal green line stays still during the animation but shakes up and down. The other green horizontal line and the vertical lines dont shake, but that might be a coincidence. This seems to me like an inaccuracy in the transformation.</li>
<li>The boundary edges of the red polygon dont connect in the vertices in some frames. If the endpoints of both edges are represented by a single point, that means there is an error in the line drawing algorithm.</li>
</ol>
<p>Aliasing is causing slight trembling of the rotating lines as their slope changes, but not any of the problems mentioned above.</p>
<p><a href="https://i.sstatic.net/qSL5C.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/qSL5C.png" alt="enter image description here" /></a></p>

CC BY-SA 4.0
2023-06-25T20:21:01.833Z
Thanks for your points, I will go through them and see if I can find issues in them.

Regarding the pipeline I actually did implement them like that, starting from line drawing, then triangle drawing then triangle filling, and finally added clipping. I don't recall seeing such shaking, but now I know it is a problem, I might just start again and see if I can track it to an earlier stage in the pipeline.
Serilena
CC BY-SA 4.0
2023-06-25T18:30:44.530Z
2023-06-25T18:30:44.530Z
Aleš Koblížek
<p>I am making a Software renderer, and I noticed that there is a screen shaking like effect happening. shown in the first <a href="https://ufile.io/uov1de8z" rel="nofollow noreferrer">video</a>:</p>
<p>I tried doing filling without clipping against the small square, and the result is much better, yet, there is some sort of shaking on the edges as shown in the second <a href="https://ufile.io/hkcymcii" rel="nofollow noreferrer">video</a></p>
<p>Finally I tried drawing the clipped triangles outline, and the shaking is more apparent as shown in the third <a href="https://ufile.io/uexgf1wk" rel="nofollow noreferrer">video</a></p>
<p>My initial assumption was the line drawing was not accurate enough, so I tried both DDA and Bresenham line drawing without any success.</p>
<p>Additionally, I tried different triangulation schemes, I noticed that when I increase the number of created triangles (such as when I triangulate a square using the center as a new vertex instead of using one of the corners) the shaking gets worse. That led me to believe to the issue is related to shared edges in the triangles, and indeed in my triangle filling algorithm, I tried to remove the shared edge and got a bit better results (but it introduced different artifacts, some pixels were missing): <a href="https://git.sr.ht/%7Ealiabdulkareem/SoftwareRenderer/tree/FixTrianglulation/item/src/drawing.cpp#L450" rel="nofollow noreferrer">https://git.sr.ht/~aliabdulkareem/SoftwareRenderer/tree/FixTrianglulation/item/src/drawing.cpp#L450</a></p>
<p>That did not however remove it entirely (I believe I should remove the shared edges from the triangulation phase as well, not entirely sure how to do that, one idea is when I triangulate the triangles after the first one, I always more pixel in the direction of the two newly formed edges)</p>
<p>Also it does not explain entirely the second video shaking when there was a shared edge in the diagonal of a square, but it was fine, while the square edges were shaking despite not sharing an edge.</p>
<p>I am a bit puzzled as how to debug this as I can at least think of three different reasons:</p>
<p>1- Triangulation is wrong</p>
<p>2- Floating point inaccuracy</p>
<p>3- Aliasing (I heard that in animations, aliasing becomes very clear, not sure if that is the case)</p>
<p>Full source code: <a href="https://git.sr.ht/%7Ealiabdulkareem/SoftwareRenderer/tree/FixTrianglulation" rel="nofollow noreferrer">https://git.sr.ht/~aliabdulkareem/SoftwareRenderer/tree/FixTrianglulation</a></p>

CC BY-SA 4.0
2024-03-22T08:47:48.987Z
Sadly it seems the site that was hosting your video now won't allow access without handing over money :(
Simon F
CC BY-SA 4.0
2024-03-22T21:49:50.827Z
@SimonF Thanks for letting me know, I will try to find a free posting service (or maybe just upload it here by reducing the size of the file)
Serilena
<rendering><c++><rasterizer><triangulation><clipping>
Triangle Rasterization Shaking Issues
Serilena
# Triangle Rasterization Shaking Issues

(Asked by: username_0 on 2023-06-25)

I am making a Software renderer, and I noticed that there is a screen shaking like effect happening. shown in the first [video](https://ufile.io/uov1de8z):

I tried doing filling without clipping against the small square, and the result is much better, yet, there is some sort of shaking on the edges as shown in the second [video](https://ufile.io/hkcymcii)

Finally I tried drawing the clipped triangles outline, and the shaking is more apparent as shown in the third [video](https://ufile.io/uexgf1wk)

My initial assumption was the line drawing was not accurate enough, so I tried both DDA and Bresenham line drawing without any success.

Additionally, I tried different triangulation schemes, I noticed that when I increase the number of created triangles (such as when I triangulate a square using the center as a new vertex instead of using one of the corners) the shaking gets worse. That led me to believe to the issue is related to shared edges in the triangles, and indeed in my triangle filling algorithm, I tried to remove the shared edge and got a bit better results (but it introduced different artifacts, some pixels were missing): [https://git.sr.ht/~aliabdulkareem/SoftwareRenderer/tree/FixTrianglulation/item/src/drawing.cpp#L450](https://git.sr.ht/%7Ealiabdulkareem/SoftwareRenderer/tree/FixTrianglulation/item/src/drawing.cpp#L450)

That did not however remove it entirely (I believe I should remove the shared edges from the triangulation phase as well, not entirely sure how to do that, one idea is when I triangulate the triangles after the first one, I always more pixel in the direction of the two newly formed edges)

Also it does not explain entirely the second video shaking when there was a shared edge in the diagonal of a square, but it was fine, while the square edges were shaking despite not sharing an edge.

I am a bit puzzled as how to debug this as I can at least think of three different reasons:

1- Triangulation is wrong

2- Floating point inaccuracy

3- Aliasing (I heard that in animations, aliasing becomes very clear, not sure if that is the case)

Full source code: [https://git.sr.ht/~aliabdulkareem/SoftwareRenderer/tree/FixTrianglulation](https://git.sr.ht/%7Ealiabdulkareem/SoftwareRenderer/tree/FixTrianglulation)

**Tags:** rendering, c++, rasterizer, triangulation, clipping

> **Comments:**
> **username_1**: Sadly it seems the site that was hosting your video now won't allow access without handing over money :(  
> **username_0**: @username_1 Thanks for letting me know, I will try to find a free posting service (or maybe just upload it here by reducing the size of the file)  

---

## 1 answers

### Answer by username_2 on 2023-06-25. Score: 0

I understand that your pipeline looks like this: Transform polygon vertices -> clip polygon -> triangulate -> draw edges of each triangle.

I would start with simple line drawing and disregard the clipping, filling and triangulation for now and see if the shaking still occurs. Then you can try to add the triangulation and the rest, one by one.

There is a couple of things that seem suspicous to me in the third video (see attached image):

1. The horizontal green line stays still during the animation but shakes up and down. The other green horizontal line and the vertical lines dont shake, but that might be a coincidence. This seems to me like an inaccuracy in the transformation.
2. The boundary edges of the red polygon dont connect in the vertices in some frames. If the endpoints of both edges are represented by a single point, that means there is an error in the line drawing algorithm.

Aliasing is causing slight trembling of the rotating lines as their slope changes, but not any of the problems mentioned above.

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

> **Comments:**
> **username_0**: Thanks for your points, I will go through them and see if I can find issues in them.  Regarding the pipeline I actually did implement them like that, starting from line drawing, then triangle drawing then triangle filling, and finally added clipping. I don't recall seeing such shaking, but now I know it is a problem, I might just start again and see if I can track it to an earlier stage in the pipeline.  

---

