AlphaMaskMethod cant change alpha

Software: Away3D 4.x

dikmene, Newbie
Posted: 20 February 2013 12:45 PM   Total Posts: 1

I was trying AlphaMaskMethod and found out that method cannot change texture alpha. I use the following code:

var _mat:TextureMaterial = new TextureMaterialCast.bitmapTexture(new Circle()));
   
_mat.alphaBlending true;
   
_mat.repeat true;

   var 
_alphamaskMat:BitmapTexture Cast.bitmapTexture(new CheckerGrid());
   
_mat.addMethod(new AlphaMaskMethod(_alphamaskMatfalse)); 

As far as i understand, AlphaMaskMethod changes fragment code to multiply source texures red channel with target textures all channels

return  getTex2DSampleCode(votemptextureReg_textureuvReg) +
     
"mul " targetReg ", " targetReg ", " temp ".x\n"

After some code digging i found this code piece in ShaderCompiler.compileMethods()

if (_preserveAlpha{
    alphaReg 
_registerCache.getFreeFragmentSingleTemp();
    
_registerCache.addFragmentTempUsages(alphaReg1);
    
_fragmentCode += "mov " alphaReg ", " _sharedRegisters.shadedTarget ".w\n";
   
}

........

   if (
_preserveAlpha{
    _fragmentCode 
+= "mov " _sharedRegisters.shadedTarget ".w, " alphaReg "\n";
    
_registerCache.removeFragmentTempUsage(alphaReg);
   

When i comment out that piece, method works like expected(or as i expected). And I couldnt find a way to change _preserveAlpha to false.

Whats the proper way to do this ?

 

   

rdoi, Member
Posted: 13 February 2014 01:03 PM   Total Posts: 86   [ # 1 ]

We got the same problem, and it looks like it is a bug. So, I’ve opened a issue in the GitHub:
https://github.com/away3d/away3d-core-fp11/issues/679

The preserveAlpha is set automatically during some shader pass of the material so not so easy to workaround.

The problem that remains is the alphaBlending=true requirement, that causes z-order problems by itself…

Lets hope they give us a good solution.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X