Animated AlphaMask

Software: Away3D 4.x

Paul Schlichter, Newbie
Posted: 04 May 2012 04:22 PM   Total Posts: 13

Hi there,

Anyone knows how to animate an alpha mask?

The idea is to have a moving alpha hole on a plane.
Treid AlphaMaskMethod, but i can’t find any way to animate the secondaryUVs…


Thanks for your help,
best regards smile

   

Paul Schlichter, Newbie
Posted: 07 May 2012 10:39 AM   Total Posts: 13   [ # 1 ]

Found a solution:

You can use ProjectiveTextureMethod to project an alpha texture on a textured mesh. All you need is a MaterialBase with alphaBlending enabled, a BitmapTexture with alpha channel to sample alpha from.

projectedAlphaHole = new BitmapTexture( new BitmapWithTransparency().bitmapData );
texProjector = new TextureProjectorprojectedAlphaHole );
projTexMethod = new ProjectiveTextureMethodtexProjectorProjectiveTextureMethod.ALPHA );
materialToPutAlphaMaskOn.addMethodprojTexMethod ); 

To make this work you need to add a new BlendMode to ProjectiveTextureMethod.as. Search for the follwing lines:

if (_mode == MULTIPLY)
{...}
else if (_mode == ADD)
{...}
else if (_mode == MIX)
{...

and add the follwing for an “alpha stencil”:

else if ( _mode == ALPHA )
{
   code 
+= "mov " targetReg ".w, " col + .w     \n";

Finally add a static const on top of class to identify the new BlendMode:

public static const ALPHA String "alpha"


Now have fun with

ProjectiveTextureMethodtexProjectorProjectiveTextureMethod.ALPHA ); 


smile

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X