Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenGL: Rendering two transparent planes intersecting each other: impossible or not?

I ran to this problem hard, it seems impossible to render.

How can one solve this problem? I want the OpenGL render it like it looks at the right side of this image below:

alt text

like image 559
Newbie Avatar asked Nov 08 '10 19:11

Newbie


2 Answers

You need to render your planes while disabling the depth test and using an order independent blending formula.

If you have some opaque geometries on the back, draw those ones, put the depth buffer to read only instead of disabling the depth test, and render the transparent ones.

There are also advanced techniques dealing with that common problem, like depth peeling.

EDIT

You can put the depth buffer in read only using: glDepthMask(GL_FALSE).

Here is a good article explaining why you can't achieve the perfect transparency: Transparency Sorting. Also give a look at Order Independent Transparency with Dual Depth Peeling article which covers two methods (one is quite straightforward and single pass) used to have exact (or approximate) order independant transparency.

I forgot to mention Alpha to Coverage.

like image 168
tibur Avatar answered Oct 21 '22 09:10

tibur


One non-trivial solution is to split the planes into parts, sort them and then render them back to front. However the perfect sorting is hard to achieve. Like in the article posted in the other answer: Transparency Sorting: Depth Sorting

like image 22
tauran Avatar answered Oct 21 '22 09:10

tauran