Wednesday, February 18, 2009

More Grillz

I have been painstakingly implementing proper bounding for all primitives (except "disk", as usual).
With a bound one can easily estimate the screen area of a primitive and decide the resolution of the grid to use (how finely a primitive has to be tesselated).
For performance reasons, it makes sense to have a limit on how large a grid can be (how many vertices it can contain). If a primitive would produce a grid too that is large, the primitive gets split until its derived sub-primitives are small enough to be diced (converted into a grid).
Splitting can either convert a primitive into a different one (a generic polygon into a series of quads) or simply subdivide a primitive.. for example a sphere can be split into two hemispheres.. same formula, just with different angluar ranges.

They way I do dicing right now is still not very good. Primitive area estimation doesn't take into account dimensions individually, so, splits always happen for both U and V equally and grids always have square dimensions (NxN vertices, where N = sqrt( area ) ).
So, I should implement a better raster estimator. The Production Rendering book provides a better one, so that doesn't require too much thinking on my part.
Then I'll have to look into occlusion: making sure that front most samples are visible 8)
I could implement a simple Z-Buffer system as a hider.. but I want to stay away from Z-Buffer, because later on is going to be a nightmare once I start playing with translucency, though it could be a starting point to implement something like A-Buffer.

But even before all this, I guess I need to start bucketing: rendering one screen's sub-rectangle at the time. This is to minimize memory usage and improve cache coherence.
I'm not too worried about performance right now, but bucketing kind of gives a license to get fancy with hiding, because one doesn't have to retain a whole scene until the last pixel, but rather render just a small portion of it at once.. a lot more efficient and parallelizable.

For another overview on all this REYES stuff check out the slides from the presentation "Real-Time Reyes-Style Adaptive Surface Subdivision".


No comments:

Post a Comment