2
$\begingroup$

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 ?

$\endgroup$
4
$\begingroup$

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

$\endgroup$
  • $\begingroup$ Can you explain what does "offset the X&Y screen coordinates by a sub-pixel amounts." mean ? Thank you :D $\endgroup$ – HOANG GIANG Sep 25 '18 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.