Advanced forum still down? anyway this involves shaders anyway…
Most OIT demos I have seen cannot be used to render on top of an existing opaque scene. I was wondering if anyone had thought of doing this:
Proof of concept demo (update on cass’s old demo) Needs GeForceFX (no reason other than this is a hack job) http://home.swiftdsl.com.au/~radlegend/GLIntercept/new_OIT.zip
This new modification to this demo allows an existing scene of opaque geometry
to be present first before rendering the transparent geometry. (All intersections are handled)
(This demo renders the balls/plane as the opaque geometry)
Once the opaque geometry is rendered , this basically works by doing an initial setup pass to write to the stencil buffer the count
of the number of times the transparent geometry under-laps the opaque geometry.
The transparent scene is then rendered in “layers” (starting with the back layer) while incrementing the
stencil test on each layer so that opaque geometry is not over-written.
(ie layer 0 only writes where the stencil test is “0”, layer 1 can write where the stencil value is
0-1, layer 2 stencil 0-3 etc.)
Since the layers are rendered in reverse order there is no need to store the result of each layer
and then blend all the layers in order with full screen quads. (as in the old demo)
(However, the stencil technique could still be done with this “front-layer” technique if so desired)
This demo uses the destination alpha as a “secondary depth” value so saving the depth buffer between
frames is not necessary. (as in the old demo)
TODO:
This is only a proof of concept demo and has two main TODO’S:
-The layers other than the first layer do not do lighting (needs to be added to the vertex program)
and are shown as yellow.
-The “alpha depth value” is not calculated correctly (major hack) so some artifacts appear in if you look close enough.
-If fragment programs ever get access to the color buffer this demo could be implemneted without any
frame buffer texture sub-loads
This demo could be dome on GeForce2 level hardware (using texture stages instead of a fragment program)
with two passes per layer.
When I have some more free time I’ll update the demo to work on non-GeforceFX cards and fix the above TODO’s