z-positioning / alpha bug? (see video)

Software: Away3D 4.x

Avatar
FlyOn, Jr. Member
Posted: 13 November 2012 08:01 PM   Total Posts: 36

Hi,

See this video:
http://www.youtube.com/watch?v=aVoV5LTyzj4

I created text in a plane. Behind the text is a rectangle. But why do the characters seem to be behind the plane (or in front of it from the back) when they are not?

Setup:
Each character is a ObjectContainer3D with a Plane with the character as material. All characters have the same z-position (0). And the rectangle has as z:20. And is a plane with colormaterial that is slightly see through.

Am I doing something wrong or is this a bug?

   

Avatar
Rob Bateman, Administrator
Posted: 17 November 2012 09:27 PM   Total Posts: 120   [ # 1 ]

This is something you have to watch for when using any materials with a transparency, as you have in your letters. Objects containing transparency are automatically sorted in the scenegraph to ensure that non-transparent objects are rendered first.

To make this a fast calculation , the z position of the entity is used for sorting. However, in your example the z position of some of the letters when viewed at a certain angle will fall behind the z position of the rear plane, causing them to render behind the plane instead of in front.

There was a patch submitted for this problem that introduced a zOffset property to the Entity object, allowing you to offset the value used for the sort without moving the object itself. However, I’ve just had a look at the commit history and it doesn’t look like it was ever checked in.

I’ve forwarded this thread onto the patch author who will be reviewing his code early next week to submit the updated patch to the master and dev branches. Hopefully it shouldn’t take long

   

Avatar
FlyOn, Jr. Member
Posted: 18 November 2012 10:54 AM   Total Posts: 36   [ # 2 ]

great, I think I understand the issue now. Thank you Rob. Will be looking out for the zOffset.

   

Avatar
Alejandro Santander, Administrator
Posted: 25 November 2012 06:44 PM   Total Posts: 414   [ # 3 ]

I’ve added a “zOffset” property to Object3D.as. You can find this in the hotfix branch. The feature will be evaluated by the team and eventually make it to the master branch.

Usage:
If you give you character planes a zOffset of say 1000, even though their distance from the larger plane remains as “n”, the sorter will beleive its actually 1000 + n and as a result, they will always be rendered in front of the big plane, even if you look at the objects from the back. If you want to avoid them showing up on the back, you’re gonna have to detect the view angle and then manually invert the zOffset values.

Please let me know if this works out for you.

   

Avatar
alihm, Jr. Member
Posted: 07 January 2013 02:52 PM   Total Posts: 49   [ # 4 ]

Alejandro, a million thanks man. It worked as expected for me smile clever and simple solution. Hope it gets included in the next version.

   

ricovitch, Newbie
Posted: 16 January 2013 11:01 AM   Total Posts: 22   [ # 5 ]

Hi,

We have been investigating those issues also.
As i understand the “zoffset patch” allows to manually sorting the objects.
But there already seems to have the pieces in Away3D to do this king of sorting automatically between opaque/blended objects in the scene.

But it seems this sorting is done on the “z” values of the entities, withouth taking in account the position of the object relative to the camera.

We tested a patch in Entity.pushModelViewProjection, that computes _zIndices from bounds center projection with the camera. (on 4.0.9 version)
This gives us better results with sorting the opaque/blended objects.

Here is our modified pushModelViewProjection method (away3d.entities.Entity) :

public function pushModelViewProjection(camera Camera3D) : void
{
 
if (++_mvpIndex == _stackLen{
  _mvpTransformStack[_mvpIndex] 
= new Matrix3D();
  
_stackLen++;
 
}
 
//@Patch
 
var _boundsCenter Vector3D = new Vector3D(  (this.minX this.maxX) * 0.5, (this.minY this.maxY) * 0.5, (this.minZ this.maxZ) * 0.5); 
 
//@Patch

 
var mvp Matrix3D _mvpTransformStack[_mvpIndex];
 
mvp.copyFrom(sceneTransform);
 
mvp.append(camera.viewProjection);
 
mvp.copyColumnTo(3_pos);
   
 
//@Patch
 
var _transformedBoundsCenter Vector3D mvp.transformVector_boundsCenter );

 
_zIndices[_mvpIndex] = -(_transformedBoundsCenter.subtract(camera.position)).length;
   
 
//_zIndices[_mvpIndex] = -_pos.z;
 //@Patch
   

Avatar
GoroMatsumoto, Sr. Member
Posted: 02 June 2013 05:08 PM   Total Posts: 166   [ # 6 ]

I run into a z-sort problem with alpha blended material on 4.1.1 beta.
And I tried solve it with “zOffset” property.

But the property seems not work, and not be referred from any other classes even once.

Is there any other workaround on 4.1.1?
Thank you for your any helps.
Cheers.

*I have posted this zOffset issue on github too.
https://github.com/away3d/away3d-core-fp11/issues/574

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X