Depth Peeling using OSMesa and two Depth-Buffers

Hi all!

I have modified Mesa 5.0.1 to use the stencil buffer as a second depth testing facility to implement Depth Peeling for order independet transparency with OSMesa.
It currently is only useful with OSMesa, as I added functions to brutefully set depth and stencil buffer by handing over a pointer to it (which could be made somewhat nicer and safer I presume)

If someone is interested in this work or wants to review it, feel free to contact me or post here.

Why not put together a web site… describe the project… etc

It sounds interesting cause I have no idea how to modify MESA. It has a certain “je ne sais quoi” that makes it difficult to understand the source.

Said and done!

Whoever is interested will find the first version of a site describing my efforts on this page:
http://www.gup.uni-linz.ac.at/~mpolak/MesaModWeb/

Cool stuff, Picard2!

There’s actually a much simpler way to do depth peeling in the GeForceFX series GPUs.
You can see the example in: http://cvs1.nvidia.com/DEMOS/OpenGL/src/layerz_3x/layerz.cpp

Specifically, the fragment program for peeling is:

!!FP1.0
TEXC H0, f[WPOS], TEX0, RECT;
KIL EQ.xxxx;
MOV o[COLH], f[COL0];
END

You can do an equivalent version with ARB_fragment_program, which will be supported in Mesa.

Thanks -
Cass

That’s beautiful, you have actually figured out what to do with the source code and pushed the z-buffer and stencil both to 32 bpp.

That’s something some of us have wanted for a while. So you can add support for any precision now, right? double, long double

I wanted this in case some people don’t have a NV card. Having a software renderer isn’t bad when one doesn’t have the hardware and suits well for offline rendering.

What is OSMesa exactly? It’s considered a separate component from MESA or …

PS: Someone had modified MESA to support F-buffers (the person who came up with the concept did it I think) http://graphics.stanford.edu/projects/shading/pubs/hwws2001-fbuffer/

Originally posted by V-man:

That’s something some of us have wanted for a while. So you can add support for any precision now, right? double, long double

We could give this a try…
I think you just have to edit the src/config.h File and mtypes.h to set the right type for GLstencil. What I can’t tell is, if all of the algorithms will still work consistently.


What is OSMesa exactly? It’s considered a separate component from MESA or …

OSMesa is some sort of extension for software-rendering into an arbitrarily sized buffer, by Brian Paul. Pro: arbitrary buffer without special extensions needed, Con: no accelaration. Brian Paul has made a nice comparison of the different techniques: http://www.mesa3d.org/brianp/sig97/offscrn.htm