Problem with alpha blending and Z-order

Software: Away3D 4.x

mole, Newbie
Posted: 26 January 2012 10:24 AM   Total Posts: 29

When I turn on alpha blending, I’m experiencing a lot of sorting problems. These problems do not occur when I turn off blending.
Is there a way to fix this? Am I overlooking something?

   

Avatar
theMightyAtom, Sr. Member
Posted: 26 January 2012 10:59 AM   Total Posts: 669   [ # 1 ]

This one’s been posted about a few times. Turns out to be a limitation of GPU rendering.
http://www.google.com/search?q=Alpha-blending+and+the+Z-buffer

In Away there are 2 possible fixes.

1) make all your meshes into a single mesh.
or…
2) Use alpha threshold instead.’

Good Luck!

   

mole, Newbie
Posted: 26 January 2012 02:34 PM   Total Posts: 29   [ # 2 ]

Thanks, alpha treshold did the trick!

   

Alex Bogartz, Sr. Member
Posted: 28 January 2012 03:11 AM   Total Posts: 216   [ # 3 ]

Ack!  I just ran into this problem today when using two objects with alpha blending on each.

Can you post some code with what worked?

Thanks!

   

Avatar
theMightyAtom, Sr. Member
Posted: 28 January 2012 11:48 AM   Total Posts: 669   [ # 4 ]

Hi Alex, if you read up on this you will find its a common problem in OpenGL rather than Away3D. The quick fix is alpha threshold. You’ll find of other workarounds depending on your particular predicament.

   

Alex Bogartz, Sr. Member
Posted: 28 January 2012 08:10 PM   Total Posts: 216   [ # 5 ]

Thanks!  I’m not trying to be lazy (well ok, maybe a little), but can anyone post code demonstrating how alpha threshold works?  That way at least when the next person searches on this problem the solution will be here on the thread.

   

Avatar
theMightyAtom, Sr. Member
Posted: 29 January 2012 06:34 AM   Total Posts: 669   [ # 6 ]

someBitmapMaterial.alphaThreshold = 0.5;

   

rewb0rn, Newbie
Posted: 12 February 2012 03:18 PM   Total Posts: 8   [ # 7 ]

@theMightyAtom: A general GPU rendering problem is not the actual problem with translucent materials in Away3D. What is, is the missing opportunity to determine the render sorting. In OpenGL you can determine the sorting for translucent materials in the code, which gives decent results most of the time.

In Away3D this possibility is missing and to be honest, that’s awkward. Of course there are always lots of things on the todo list in an OS software, but in my oppinion this one should really have high priority… No offense, anyway.

   

Avatar
theMightyAtom, Sr. Member
Posted: 12 February 2012 03:51 PM   Total Posts: 669   [ # 8 ]

None taken, but I am quite sure you’ll find this not an omission on the part of the away team, but a general effect of how OpenGL works natively.
http://www.opengl.org/wiki/Transparency_Sorting

There are complex workarounds in both OpenGL and DirectX apparently, but whether they’re possible though AGAL is another matter. I’ve certainly not come across a solution yet. If you can program one, please submit it :O)

   

mwoodman, Newbie
Posted: 26 September 2012 04:54 PM   Total Posts: 4   [ # 9 ]
theMightyAtom - 12 February 2012 03:51 PM

None taken, but I am quite sure you’ll find this not an omission on the part of the away team, but a general effect of how OpenGL works natively.
http://www.opengl.org/wiki/Transparency_Sorting

There are complex workarounds in both OpenGL and DirectX apparently, but whether they’re possible though AGAL is another matter. I’ve certainly not come across a solution yet. If you can program one, please submit it :O)

I couldn’t use alphaThreshold with my textures.  However, I got the results I needed by offsetting y values in subgeometries away from the Mesh’s y value.  It doesn’t change the apparent view distance, but the underlying offset forces the z-ordering to be what you want. It won’t work for all situations, but in my use cases it works like a charm.  Code posted here:

http://away3d.com/forum/viewthread/2285/#10681

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X