New Order Independent transparency idea

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)

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)

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

Your demo doesn’t work here (Radoen 9800Pro, Catalyst 4.3):

8 bits of dst alpha
8 bits of stencil
Error loading vertex program
Error on line 19: malformed declaration (hint: ‘;’)

I think the problem is at this line:

MOV, {0.7,0.7,0,0};

I’ve seen a similar problem in the forum. Try this:

PARAM temp = {0.7,0.7,0,0}
MOV, temp;

I tried to compile it myself but I don’t have the include files (glh_*)…

As I said above I did not think it would work on a non-GeForecFX card (As I did some massive hacks)
(I am also still using NV_texture_rectangle as the old Nvidia demo did - will need the Nvidia Effects browser to compile)

Will do a non-card dependant version when time permits. (probably in about a month)

Thanks! This is an excellent idea and has a marked improvement in performance on my lowly 5200.

I do notice that the result of the blending is different (wrong?)

Also any chance anyone can convert the arb assembly to a higher level shading language so a poor sod like me can understand it and incorporate into other shaders… please…?

Coming late to this game I was hoping not to have to learn shader assembly…

The origional demo had everyting as a transparent object, this demo is of transparent objects rendered after and intersecting a already existing opaque scene. (hence the balls in my demo are rendered first as standard opaque geometry -hence the differences -As the above TODO also said I have not done the lighting on the layer slices so hence another difference)

This was only a quick proof of concept.

If you really want I will update the demo to use GLSL when I fix the above TODO’s. (You may be waiting a while(week or two) as I am busy currently with the next release of GLIntercept - GLSL and DisplayList loggers)

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.