PDA

View Full Version : Weighted average for transparency



Ido_Ilan
04-04-2008, 01:15 AM
Hi,

I want to use the weighted average as described in the latest Nvidia OpenGL SDK in the 'Dual Depth Peeling' example but it seems that this technique can only work for 1 object, if I want different transparency for different objects, some of them opaque, it will not work as it always blend based on averages.

Is there any way to use it in such a way?

Thanks,
Ido

Brolingstanz
04-05-2008, 03:52 PM
Haven't looked at that particular example yet. All I can say with any certainty is that transparency isn't yet a done deal in realtime graphics, no matter how you slice it (no pun intended).

Can you give us a quick rundown of the technique, or better still do you have a link to a relevent document handy? It's saturday, and I for one am a shiftless layabout on saturdays.

sqrt[-1]
04-05-2008, 04:29 PM
I think it is this paper:
http://developer.download.nvidia.com/SDK/10/opengl/src/dual_depth_peeling/doc/DualDepthPeeling.pdf

I would render all the opaque geometry first, then only use this technique with a existing z-buffer to render transparent objects.

Ido_Ilan
04-05-2008, 11:12 PM
Thanks for the replays,


I would render all the opaque geometry first, then only use this technique with a existing z-buffer to render transparent objects.

I don't think this will work, to use the weighted average the depth test must be disabled, it average everything based on it alpha and because the geometry is not sorted I can't use the z-buffer.

I thought about saving the min/max z-buffer and use it to combine the scene in the final stage but I don't think it is good because I will get incorrect result.

Any suggestion?

Thanks,
Ido

sqrt[-1]
04-06-2008, 04:58 PM
I don't think this will work, to use the weighted average the depth test must be disabled


Depth writing must be disabled, but depth testing is fine to have on. (not I have not implemented this myself, but am 99% sure from looking at the paper)

Ido_Ilan
04-06-2008, 10:35 PM
Ok,

So I draw all opaque objects into the fbo using depth write+test, then draw all transparent objects using the weighted average with depth test enabled but depth write disabled.
The fbo will have 3 attachments, two colors: sum of colors, number of fragments to average and one depth attachment.

I must draw all my objects into the fbo and I can't use the back buffer.
Is that correct?

Ido

sqrt[-1]
04-07-2008, 12:14 AM
Without actually implementing it, it seems correct.

Ido_Ilan
04-07-2008, 03:50 AM
Hi,

I've implemented it, very easy, it works ok, thank you for the help.

I see two problems with this approach:

1. When I change an object from opaque to transparent there is a sharp drop in "color"/"lighting" as you see only front faces and next you see the blending. (if the blending was based both on alpha factor and z factor it could be better).
2. you loose a lot of details, If its only one object it looks ok, but when several transparent on screen you loose many colors.

Next I will sort all the triangles in the scene and compare the result, currently the engine sort the triangles per object, this work very well and fast(bucket sort based on 2048 z slices) but have problems with contained transparent objects.

Ido