zOffset has no effect in depth sorting

Software: Away3D 4.x

flexwiz, Newbie
Posted: 09 April 2014 02:52 PM   Total Posts: 14

Hi,

I have a scene where I stack planes on top of each other (like postcards) on an XZ plane.
Each of these has a TextureMaterial with alphaBlending set to true. The textures are cutout images, so they contain transparent areas on the edges, and while they are by themselves opaque I must set alphaBlending to true.

The problem is simple: I want the top postcards (with higher Y coord value) to be rendered on top of the bottom postcards, with lower Y value. However, with the perspective camera tilted above them at about 40 degrees, I often get the opposite result.

As a side note, each postcard also has a XZ offset, and it looks like when the top cards are moved away from the camera, they get rendered on the bottom.

After going through forum posts about transparency sorting, I followed a suggestion to assign each card with a zOffset value (which is undocumanted). This had no effect at all. Even setting it to very high values did not affect the order of depth sort.

I am really at lost here. Is there any standard way of dealing with this?
I know openGL use to have polygonOffset for that, and Unity3D has an Orthographic sort mode to handle coplanar flat objects. Anything like that in Away3D maybe?

   

flexwiz, Newbie
Posted: 10 April 2014 02:08 AM   Total Posts: 14   [ # 1 ]

I found this related thread about alpha blending and Z-order:
http://away3d.com/forum/viewthread/1774/

So it turns out that using alphaThreshold does fix the z-order problem, but creates a new one. Using it has a side effect of a very noticeable aliasing artifact on the edges - effectively all the soft edges in the cut-out images are lost.

Since the alpha here is not used for translucent pixels but for soft edges, the question is if there is any way to force the z-ordering so it would treat the cards as opaque while keeping the alpha blending?

how about custom sort, or custom renderer?

   

beers, Member
Posted: 10 April 2014 02:23 AM   Total Posts: 53   [ # 2 ]

i cant help with alphablending, but with alphathreshold using a ‘distance field alpha’ (google distance field alpha) can smooth out those jagged edges. Doesnt make them soft, but does make it smooth.

beers

   

flexwiz, Newbie
Posted: 10 April 2014 05:21 PM   Total Posts: 14   [ # 3 ]

Interesting - That could be a suitable solution.

Have you ever implemented distance filed alpha on as3/flash?
Not sure how it’s done.

   

beers, Member
Posted: 10 April 2014 07:27 PM   Total Posts: 53   [ # 4 ]

Yes it works perfectly in away3d with no additional code needed (other than setting your alphaThreshold to 0.5 for best results). I use it all the time in my projects.

The magic is in the custom alphamap. Valve has a good paper on how to create the distance field alphamap (google valve distance field alpha) .There are tools available to do it as well.

beers

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X