alphaMask - alphaBlending material/texture problem

Software: Away3D 4.x

Vice, Member
Posted: 06 April 2012 04:16 PM   Total Posts: 58

in my scene there are 3 planes - one upon the other with a distance between them. the material of all planes using alphablending, because i have to look trough all of the planes to the “ground”.

Now, the order of rendering is not correct. the last plane seems to be in the middle and not on top-position.

But for some camera positions/angles the order seems to be correct.

I know there is a render problem in general for alphatransparency but are there a workaround to force the correct render-order or e.g…..?

thanks for ideas and suggestions!

   

Vice, Member
Posted: 06 April 2012 09:30 PM   Total Posts: 58   [ # 1 ]

try to fix it with Objectcontainer but the top-plane already apears to be darker or fully transparent. Changing camera postion let the object render correct with exact alpha value. ....?!

   

Vice, Member
Posted: 06 April 2012 10:22 PM   Total Posts: 58   [ # 2 ]

z-sorting problems with particles too. using flint and away3d with bitmap-particles has the same unsightly effect like the z-sorting of planes with transparency.

   

Vice, Member
Posted: 07 April 2012 02:05 PM   Total Posts: 58   [ # 3 ]

i think a movie tells more then….... so please have a look:

http://www.youtube.com/watch?v=uE3fRwwR_z4

   

jtopaz, Member
Posted: 08 April 2012 08:12 AM   Total Posts: 53   [ # 4 ]

I have given up using alphaBlending because of z-sorting problems…
I am now only use alphaThreshold = 0.5 (not sure what is the different between them?)
Hope z-sorting problems solved asap.

   

Vice, Member
Posted: 08 April 2012 08:54 AM   Total Posts: 58   [ # 5 ]

no, alphaThreshold is no option, because there is no semitransparency. pixels are still there or not and sometimes you need to look trough a texture or let another texture shine trough for a special effect.
but there must be a workaround to force correct z-sorting????! I looked to flare3d and there is an example for alphablending and z-sorting. it looks very good. wish away3d can use it too because in many cases you need alphablending for common effects.

   

Vice, Member
Posted: 08 April 2012 11:38 PM   Total Posts: 58   [ # 6 ]

there are no z-sorting problem by objects with positioning on (0,0,0). so the objects null point has to be in world null point (0,0,0). ?!

   

Camurai, Newbie
Posted: 11 September 2012 03:41 PM   Total Posts: 1   [ # 7 ]

It looks like the z-sorting for alphablending is based on the position of the mesh. so if the center point is closer to the camera, that meshs material is placed on top of the others in the order.

This causes issues with things like large planes with smaller objects on top of them, because the large planes center point could easily be closer to the camera then other objects, event though the other objects are on to.

The only way I can see of getting around this issue is a bit hacky. you would need to make the geometry custom (cant use the built plane, cube etc geometry) and set it up so that each objects 0,0 points are a positioned in a way to ensure that the bottom most one will always be farther away then the ones you want to display above it.

This may still have some glitchy behavior. really the alphablending sorting needs to be enhanced. perhaps working off of individual faces normals instead?

* another way to offset the 0 point of the mesh is to apply transformation matix to its subgeometry

var lowerPlaneGeo::PlaneGeometry = new PlaneGeometry(40004000);
var 
geoOffset:Function = new function(item:SubGeometryindex:intvector:Vector.<SubGeometry>):void
{
 
var matrix:Matrix3D = new Matrix3D();
 
matrix.appendTranslation(020000);
 
item.applyTransformation(matrix);
}
lowerPlaneGeo
.subGeometries.forEach(geoOffset);
lowerPlaneGeo.-= 2000

now the lower planes center point will be 2000 units lower, so it should be at the bottom of the list for alpha blendings as long as you are above it (it will obviously be a little wonky when if you view from below)

   

mwoodman, Newbie
Posted: 26 September 2012 04:39 PM   Total Posts: 4   [ # 8 ]

Thanks for that, @Camurai.  Several posts have alluded to using applyTransformation(), but yours is the first I’ve seen with a concrete code sample. 

Offsetting geometry y-depths from the mesh’s y-depth is a usable work-around.  I’m using it for PlaneGeometries that were clipping other geometries at certain view angles.  This work-around forces the correct z-ordering and doesn’t restrict you to using certain alphaThreshold values, (or giving up on using alpha blending).

In case anyone else needs it, here’s a couple of generic functions that you can paste in and use.

/**
 * Adjust Mesh Y-depth to work around z-index alpha blending problems.
 * (Don't use with meshes that share geometries.)
 */
private function adjustMeshYDepth(mesh:Meshoffset:int):void {
  adjustGeometryYDepth
(mesh.geometryoffset);
  
mesh.-= offset;
}

/**
 * Adjust Geometry Y-depth to work around z-index alpha blending
 * problems.  (If called directly, owning mesh.y must have offset manually
 * subtracted.)
 */
private function adjustGeometryYDepth(geometry:Geometryoffset:int):void {
  
var matrix:Matrix3D = new Matrix3D();
  
matrix.appendTranslation(0offset0);
  
geometry.subGeometries.forEach(function(item:SubGeometryindex:intvector:Vector.<SubGeometry>):void {
    item
.applyTransformation(matrix);
  
});

If your mesh’s geometry isn’t shared by other meshes, then you can just call adjustMeshYDepth() like so:

var geometry:Geometry = ...
var 
mesh:Mesh = new Mesh(geometry, ...
var 
offset:int 1000;

adjustMeshYDepth(meshoffset); 

However, if a geometry is used in more than one mesh, you’ll need to call adjustGeometryYDepth() just once for the geometry, then subtract the offset value from each mesh.y value in your own code.  Like so:

var sharedGeometry:Geometry = ...
var 
meshFoo:Mesh = new Mesh(sharedGeometry, ...
var 
meshBar:Mesh = new Mesh(sharedGeometry, ...
var 
meshBaz:Mesh = new Mesh(sharedGeometry, ...
var 
offset:int 1000;

// Only adjust shared geometry once
adjustGeometryYDepth(sharedGeometryoffset);

// Manually adjust each mesh that uses the shared geometry
meshFoo.-= offset;
meshBar.-= offset;
meshBaz.-= offset
   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X