Thursday, February 12, 2009

Getting it on with the Grids

I've been spending more time trying to implement the REYES pipeline as described by Production Rendering .
It's a great book, but it takes some page flipping to try to get code and data structures right from the short code snippets (already found a small error) and the plain English explanations which are a bit scattered (I wish I had a PDF version for those times when I need to look up things which are explained in other pages).

It's funny how the REYES approach is very much like the "forward texturing" that was being used by the first NVidia card, the NV1.
I remember deriding that approach back then and now it may actually come back to the real-time rendering world 8)

The image in the post shows the usual test image composed of quadrics.. this time around without any polygons. I use OpenGL only to blit my offscreen buffer on the display.
I went throught the steps of actually turning each primitive into a "grid", and the visible points on screen are the grid vertices.

Two important things are still missing before I can call that geometry:
- Grid size should be dynamic.. so that there wouldn't be any empty spaces between vertices
- The grid needs to be converted into micro-polygons

Right now I just output vertices as pixels, but I should instead thing of those vertices are part of a mesh of quads (a filled grid).
Those quads would then not be directly rendered on screen, but instead the rasterizer would have to go through every pixel and sample all the quads intersecting that pixel (or micro-polygons) to give a final color.

The dynamic grid resolution thing is already a powerful concept if one thinks a bit ahead: high quality rendering is filled with motion blur and depth of field (DOF) blurring effect.
With the current real-time rasterization approaches, one renders at full resolution (with multi-sampling or super sampling anti-aliasing.. which is the non-REYES equivalent of having more than one micro-polygon contributing to one pixel) and only after applies some sort of blurring.
With the REYES approach instead, one can take into account the DOF blurring right there and potentially have a much coarser grid.. perhaps even with micro-polygons that are bigger than one pixel ?

Unfortunately REYES does not take into account frame animation coherence.. so those grids are rebuilt every frame... but I can see some potential to optimize there..