Login  Register

Re: Rendering transparent triangles with opengl...

Posted by Xerxes Rånby on May 22, 2015; 11:19am
URL: https://forum.jogamp.org/Rendering-transparent-triangles-with-opengl-tp4034507p4034508.html

Hi

You are tackling a "hard" problem, the behaviour you see with opengl is
correct according to the opengl specification.

There is several papers available on how to do Order-Independent
Transparency using opengl.
http://on-demand.gputechconf.com/gtc/2014/presentations/S4385-order-independent-transparency-opengl.pdf

OpenGL only give you an API to make use your hardware, its up to you to
use it properly.

I would suggest you to study different ways to do Order-Independent
Transparency using a GPU.
http://en.wikipedia.org/wiki/Order-independent_transparency

You may get the effect you want if you first sort the triangles to be drawn from back to front, but that is not enough you actually need to sort each pixel fragment as shown in the linked paper above.

Cheers
Xerxes

Den 2015-05-22 12:47, ManuelBrotz [via jogamp] skrev:
> Hello
>
> I am new to opengl and have a problem.
> I want to render some semi-transparent, overlapping triangles using
> opengl. The rendering works, but the triangles don't look right.
>
> What do i have to do, to make them look the way i want?
>
> I have attached an eclipse project with the source i used to render
> both images below.
> Triangles.zip <http://forum.jogamp.org/file/n4034507/Triangles.zip>
>
> Please note, that you will only see the difference between the two
> files when you use the attached eclipse project to generate them on
> your own machine!
>
> The opengl rendering seems to get the alphablending wrong. I think,
> the alpha channel of a rendered triangle always replaces the alpha
> channel of the pixels below the triangle. This is not what i want!
>
> Any help is appreciated!
>
> Manuel Brotz
>
>
>
> That's what i get: (rendered using opengl)
>
>
> That's what i want: (rendered using BufferedImage and Graphics2D)
>
>
>
> ------------------------------------------------------------------------
> If you reply to this email, your message will be added to the
> discussion below:
> http://forum.jogamp.org/Rendering-transparent-triangles-with-opengl-tp4034507.html 
>
> To start a new topic under jogl, email
> ml-node+s762907n782158h61@n3.nabble.com
> To unsubscribe from jogamp, click here
> <http://forum.jogamp.org/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=762907&code=eGVyeGVzQGd1ZGlubmEuY29tfDc2MjkwN3wtNTE5NjUwMzEw>.
> NAML
> <http://forum.jogamp.org/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
>