<p>Assuming the small triangles form continuous surfaces, although many of the small triangles "fall through the gaps" (so to speak), some should still cover the samples. If on the other hand, they are separate/independent triangles then it will alias very badly.</p>

<p>One possible alternative to just doing higher resolutions would be to simulate an <a href="https://www.cse.msu.edu/~cse872/tutorial5.html" rel="nofollow noreferrer">Accumulation Buffer</a>. In essence, do <em>N</em> XxY pixel renders, but for every render, offset the X&amp;Y screen coordinates by a sub-pixel amounts. </p>

<p>You can then combine the <em>N</em> images, (perhaps initially with a simple box filter, but a Gaussian would be better) to produce your final XxY image.</p>

<blockquote>
  <p>Can you explain what does "offset the X&amp;Y screen coordinates by a sub-pixel amounts." mean ?</p>
</blockquote>

<p>Perhaps it'd be a good idea to read  <a href="https://graphics.stanford.edu/courses/cs248-02/haeberli-akeley-accumulation-buffer-sig90.pdf" rel="nofollow noreferrer" title="The Accumulation Buffer">Haeberli and Akeley's original paper</a> but I'll try to put in a bit of an explanation on how I would try to do the XY shifts. (<em>I apologise in advance if I've made some fundamental flaw in the following logic...</em>)</p>

<p>Let's assume we want to shift the image by <span class="math-container">$(x_{offset}, y_{offset})$</span> in pixels where, <em>probably</em>, <span class="math-container">$|x_{offset}| &lt; 0.5$</span> and <span class="math-container">$|y_{offset}|&lt;0.5$</span>.</p>

<p>We want to add this offset to each vertex <em>after</em> it's been projected into screen coordinates. Now since we don't have much control of the pipeline post clipping and projection, we'll need to do that by adjusting the projection matrix. If we assume our default projection matrix, P, does something of the following:
<span class="math-container">$$(X_{world}, Y_{world}, Z_{world}, 1).P=(X_{clip},Y_{clip},Z_{clip}, W_{clip})$$</span>
i.e. maps from world space to clip space, then to shift the points in image space we'll need an additional "matrix" adjustment which, off the top of my head, will be <em>something</em> like...
<span class="math-container">$$Adjust= \begin{bmatrix}
    1 &amp; 0 &amp; 0 &amp; 0 \\
    0 &amp; 1 &amp; 0&amp; 0 \\
    0 &amp; 0 &amp;1&amp; 0 \\
    scaledX_{offset} &amp; scaledY_{offset} &amp;0&amp; 1 \\
    \end{bmatrix}
$$</span>
The "scaling" should take into account the resolution of the target image. </p>

<p>Create a new, per offset, projection matrix from <span class="math-container">$P.Adjust$</span> for each "offset" image you want to accumulate.</p>

CC BY-SA 4.0
2018-09-25T13:24:30.323Z
Can you explain what does "offset the X&Y screen coordinates by a sub-pixel amounts." mean ? Thank you :D
HOANG GIANG
CC BY-SA 4.0
2018-09-25T13:07:07.380Z
2018-09-26T12:03:15.117Z
2018-09-26T12:03:15.117Z
Simon F
<p>For research purpose, I have to implement z-buffering algorithm to render 3D face models. But I got a problem that the triangles are too small to be rendered (i.e. there is no pixel covered completely  by any of the triangles).</p>

<p>I've tried to increase the resolution of the output image (so that the triangles get bigger) but it's been <span class="math-container">$10,000 \times 10,000$</span> so far (I think it's pretty high) and my computer can't suffer from higher resolutions.</p>

<p>Can you give me some solution for this problem ?</p>

<rendering><3d><z-buffer><implementation>
Z-buffering implementation with small triangles
HOANG GIANG
# Z-buffering implementation with small triangles

(Asked by: username_0 on 2018-09-25)

For research purpose, I have to implement z-buffering algorithm to render 3D face models. But I got a problem that the triangles are too small to be rendered (i.e. there is no pixel covered completely by any of the triangles).

I've tried to increase the resolution of the output image (so that the triangles get bigger) but it's been $10,000 \times 10,000$ so far (I think it's pretty high) and my computer can't suffer from higher resolutions.

Can you give me some solution for this problem ?

**Tags:** rendering, 3d, z-buffer, implementation


---

## 1 answers

### Answer by username_1 on 2018-09-25. Score: 3 | Accepted answer

Assuming the small triangles form continuous surfaces, although many of the small triangles "fall through the gaps" (so to speak), some should still cover the samples. If on the other hand, they are separate/independent triangles then it will alias very badly.

One possible alternative to just doing higher resolutions would be to simulate an [Accumulation Buffer](https://www.cse.msu.edu/~cse872/tutorial5.html). In essence, do *N* XxY pixel renders, but for every render, offset the X&Y screen coordinates by a sub-pixel amounts.

You can then combine the *N* images, (perhaps initially with a simple box filter, but a Gaussian would be better) to produce your final XxY image.

> Can you explain what does "offset the X&Y screen coordinates by a sub-pixel amounts." mean ?

Perhaps it'd be a good idea to read [Haeberli and Akeley's original paper](https://graphics.stanford.edu/courses/cs248-02/haeberli-akeley-accumulation-buffer-sig90.pdf "The Accumulation Buffer") but I'll try to put in a bit of an explanation on how I would try to do the XY shifts. (*I apologise in advance if I've made some fundamental flaw in the following logic...*)

Let's assume we want to shift the image by $(x\_{offset}, y\_{offset})$ in pixels where, *probably*, $|x\_{offset}| < 0.5$ and $|y\_{offset}|<0.5$.

We want to add this offset to each vertex *after* it's been projected into screen coordinates. Now since we don't have much control of the pipeline post clipping and projection, we'll need to do that by adjusting the projection matrix. If we assume our default projection matrix, P, does something of the following:
$$(X\_{world}, Y\_{world}, Z\_{world}, 1).P=(X\_{clip},Y\_{clip},Z\_{clip}, W\_{clip})$$
i.e. maps from world space to clip space, then to shift the points in image space we'll need an additional "matrix" adjustment which, off the top of my head, will be *something* like...
$$Adjust= \begin{bmatrix}
1 & 0 & 0 & 0 \\
0 & 1 & 0& 0 \\
0 & 0 &1& 0 \\
scaledX\_{offset} & scaledY\_{offset} &0& 1 \\
\end{bmatrix}
$$
The "scaling" should take into account the resolution of the target image.

Create a new, per offset, projection matrix from $P.Adjust$ for each "offset" image you want to accumulate.

> **Comments:**
> **username_0**: Can you explain what does "offset the X&Y screen coordinates by a sub-pixel amounts." mean ? Thank you :D  

---

