Mixing translucent objects in a GL scene

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Mixing translucent objects in a GL scene

Martin
Hi folks!

I am seeking to use several translucent and non translutent objects that cross each other in a Jzy3d scene.

Up to now, Jzy3d was using a simple and naive approach to deal with translucent polygons: each shape is a composite made of quads or polygons, and is splitted at rendering, in order to sort all atomic polygons according to the distance of their barycenter to the current camera eye position. The problem is that the barycenter is a to approximated measure when polygons have very different size (see the cylinder nested in a box attached).

Indeed, the nested cylinder image attached shows that the barycenter approach makes the top side of each gray box farest from the barycenter of each cylinder side standing in front of the camera. The latter are thus rendered latter and override the top gray polygon.

The idea of sorting the splitted shapes this way relies on the idea that it seams necessary to init GL the following way to consistantly handle transparency:
1) Activate alpha buffer
2) Desactivate depth buffer

Splitting each side of the box into multiple cells could be an idea, but that would rapidly imply many polygons for a simple paralleliped. Moreover, the visual success would always depend on the resolution of the tesselated face, related to the size of its content (cylinder radius).

Does anybody has a generic method for handling clean transparency?

Thanks in advance for your suggestions.

Martin

Reply | Threaded
Open this post in threaded view
|

Re: Mixing translucent objects in a GL scene

Demoscene Passivist
Administrator
I can assure u, ur are not the only one asking that question

Order-Independen-Transparency/-Transluceny is a more or less an unresolved issue in computer graphics and is a very hot topic in research.

A common technique is called "depth-peeling" wich tries to render the scene in a number of z-slices (e.g. take this paper by Nvidia for a refined implementation in GL). Also techniques using the accumilation buffer or "Screen-Door-Transparency"-techniques are often used.

If u are searching for a very simple mehtod with completely ignores odering of the polygons maybe simple "additive blending" may work for the usecase u showed above.
Reply | Threaded
Open this post in threaded view
|

Re: Mixing translucent objects in a GL scene

Martin
Hi Demoscene,
Thank you very much for these really good suggestions.
Just for dreaming, would you have such code samples in your folders?
Cheers :)
Martin
Reply | Threaded
Open this post in threaded view
|

Re: Mixing translucent objects in a GL scene

gouessej
Administrator
Reply | Threaded
Open this post in threaded view
|

Re: Mixing translucent objects in a GL scene

Demoscene Passivist
Administrator
>Just for dreaming, would you have such code samples in your folders?

Nope, sorry I haven't had to solve this problem yet

But the stuff that Julien and I posted should give u a fairly good starting point for ur own implementation ...
Reply | Threaded
Open this post in threaded view
|

Re: Mixing translucent objects in a GL scene

Martin
Hi,

Trying some sample code related to alpha blending [1], I got an exception saying it's not available:

javax.media.opengl.GLException: Method "glBlendEquation" not available
        at jogamp.opengl.gl4.GL4bcImpl.glBlendEquation(GL4bcImpl.java:700)
        at glredbook12x.blendeqn.display(blendeqn.java:87)

So I discover one should call:

System.out.println("blend available:"+gl.isFunctionAvailable("glBlendEquation"));

What is the reason for unavailable functions?
Is that due to my hardware? Should I add open gl extensions?

[1] https://jzy3d.googlecode.com/svn/trunk/src/glredbook/glredbook12x/blendeqn.java 
Reply | Threaded
Open this post in threaded view
|

Re: Mixing translucent objects in a GL scene

Demoscene Passivist
Administrator
>What is the reason for unavailable functions?

Normally its a driver "issue" were the vendor simply does not support an OpenGL feature, usually because its not supported by his hardware.

>Is that due to my hardware? Should I add open gl extensions?

As far as I know glBlendFunc is part of the OpenGL 1.2 core spec, so it should be no "unsupported extension" issue. It was an extension back in the days, but that was ages ago . Also I can't imagine a hardware today that is not capable of implementing 1.2 core profile.

I myself am using glBlendFunc hereand it works fine, so its no general JOGL issue. Seems its somehow related to ur driver and/or platform ...

ps. Maybe doublecheck that ur platform is really using the hardware driver and not some sort of software fallback only supporting GL <1.2 ...
Reply | Threaded
Open this post in threaded view
|

Re: Mixing translucent objects in a GL scene

Martin
In reply to this post by Demoscene Passivist
I found this interesting slide show that compares dual depth peeling with another technic called weighted average.