cKleinhuis
|
|
« on: May 06, 2013, 12:37:06 AM » |
|
hi all, i have read about order independent transparency, why is it so hard to achieve ? as far as i have seen the standard blend modes do not allow to set up "additive" blending, and always a shader is needed, but a nice example was not found by me, can anyone point me to how to set up an independent rendering method for opengl thank you
|
|
|
Logged
|
---
divide and conquer - iterate and rule - chaos is No random!
|
|
|
hobold
Fractal Bachius
Posts: 573
|
|
« Reply #1 on: May 06, 2013, 12:46:57 AM » |
|
i have read about order independent transparency, why is it so hard to achieve ?
Because light in nature travels trough the farthest transparent object first, and through the nearest transparent object last before it hits our eyes. Additionally, the interactions between light and transparent materials tend to be non-commutative. In other words, in a traditional rasterizer like OpenGL, you have to render transparent surfaces back to front. The alternative would be a Z-buffer that stores not just a single Z-coordinate, but a sorted list of transparent surfaces at that particular pixel. Or you use raytracing, where each ray hits surfaces in geometrical order, regardless of the order in which they were specified in the model.
|
|
|
Logged
|
|
|
|
Tglad
Fractal Molossus
Posts: 703
|
|
« Reply #2 on: May 06, 2013, 01:18:08 AM » |
|
as far as i have seen the standard blend modes do not allow to set up "additive" blending opengl does support additive blending. But it is not a very good approximation of transparency... it might work ok for frosted glass which tends towards white as you look through more of it.
|
|
|
Logged
|
|
|
|
cbuchner1
|
|
« Reply #3 on: May 06, 2013, 01:36:38 PM » |
|
hi all, i have read about order independent transparency, why is it so hard to achieve ? as far as i have seen the standard blend modes do not allow to set up "additive" blending, and always a shader is needed, but a nice example was not found by me, can anyone point me to how to set up an independent rendering method for opengl thank you I've posted an improved "order independent transparency" sample (based on OpenSceneGraph) to the osg-submissions mailinglist recently. This example uses depth peeling, which is a multi-pass technique. It shows how to combine solid and transparent geometry, and also how to use GLSL shaders in combination with depth peeling. OpenSceneGraph is an open source scene graph, a middleware between the application and the OpenGL API. There are other approaches to transparency rendering, like sorting all objects or even object faces from back to front before rendering. But this only works for few objects or relatively simple geometries, and also sorting individual faces becomes nearly impossible when your geometry is arranged as a quad or triangle mesh, where the faces are already arranged as quad or tri strips. So yes, real transparency is hard. Christian
|
|
« Last Edit: May 06, 2013, 02:40:57 PM by cbuchner1 »
|
Logged
|
|
|
|
cKleinhuis
|
|
« Reply #4 on: May 06, 2013, 02:47:07 PM » |
|
so, as i understand the additive blending is the cheapest single step? any examples around ? i am not seeking reality here, i am just wanting to counter my millions of dots that i can not by any means sort in each step
|
|
|
Logged
|
---
divide and conquer - iterate and rule - chaos is No random!
|
|
|
cbuchner1
|
|
« Reply #5 on: May 06, 2013, 02:52:23 PM » |
|
so, as i understand the additive blending is the cheapest single step? any examples around ? i am not seeking reality here, i am just wanting to counter my millions of dots that i can not by any means sort in each step Additive blending does not really achieve a realistic transparency effect - but it is the only order independent blending operation (subtractive blending as well). It is kind of cool for "glow" effects, because the more "transparency" layers you add the brighter (or darker for subtractive blending) things become. Just experiment with this blending feature to see if that will suit your needs. You will have to draw solid geometry first, then all the transparent objects with depth test enabled, but depth writes disabled.
|
|
« Last Edit: May 06, 2013, 03:07:59 PM by cbuchner1 »
|
Logged
|
|
|
|
cKleinhuis
|
|
« Reply #6 on: May 06, 2013, 03:25:38 PM » |
|
so, i am unsure, is additive blending just the alpha *source+ (one minus dest alpha)*dest equation ?
|
|
|
Logged
|
---
divide and conquer - iterate and rule - chaos is No random!
|
|
|
cbuchner1
|
|
« Reply #7 on: May 06, 2013, 04:31:38 PM » |
|
so, i am unsure, is additive blending just the alpha *source+ (one minus dest alpha)*dest equation ?
glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
|
|
Logged
|
|
|
|
cKleinhuis
|
|
« Reply #8 on: May 06, 2013, 06:08:35 PM » |
|
nice, thank you will try it right away
|
|
|
Logged
|
---
divide and conquer - iterate and rule - chaos is No random!
|
|
|
cKleinhuis
|
|
« Reply #9 on: May 06, 2013, 06:46:03 PM » |
|
hmm, ok, you are right it is somehow problematic, i wonder why the color is getting white ...
|
|
|
Logged
|
---
divide and conquer - iterate and rule - chaos is No random!
|
|
|
kram1032
|
|
« Reply #10 on: May 06, 2013, 08:41:53 PM » |
|
that's why it's called additive.
|
|
|
Logged
|
|
|
|
cKleinhuis
|
|
« Reply #11 on: May 06, 2013, 09:00:54 PM » |
|
but if i add 2 blue colors, why is it getting white then ?
|
|
|
Logged
|
---
divide and conquer - iterate and rule - chaos is No random!
|
|
|
Syntopia
|
|
« Reply #12 on: May 06, 2013, 11:03:21 PM » |
|
The joys of glBlendFunc. I still remember the first time, I tried reading the documentation on that one! but if i add 2 blue colors, why is it getting white then ? Are you sure you are not saturating your colors? Are they pure blue, with no lighting enabled? I think per default OpenGL sets some ambient global light (GL_LIGHT_MODEL_AMBIENT).
|
|
|
Logged
|
|
|
|
cKleinhuis
|
|
« Reply #13 on: May 06, 2013, 11:20:35 PM » |
|
hmm, the colors are set/interpolated in the vertex shader, so no light influence here it has to do with my iteration visualisation, if you look carefully in the mandelbox iteration visualisations you spot the problem when the bailouted points move back to their starting positions, in that case many points are rendered wrongly, hence i have exactly 1 million of them and already use the vertex shaders for interpolating there would be in no case time for sorting them out .. a 2 step rendering would be - in my eyes - expensive as well, but just doubled amount right now i stick with the normal blending equation to make it really look good something like the flame rendering algorithm should be used, but this would induce more effort for the rendering, by just calculating the number of pixels that lie on top ... and then renormalizing the output ... something like this ... because no matter what i do i have a problem anyways ... either there is no point overlaping another one and hence i could not reduce the alpha anymore, but when 3 or 10 points lie on top of eachother they just blend to white ... another problem with the normalization would be to keep the overall renormalisation stable throughout the animation, because the amount of points that lie on top of eachother may vary strongly from frame to frame ... ehrm, i need a faster computer!
|
|
|
Logged
|
---
divide and conquer - iterate and rule - chaos is No random!
|
|
|
|