I’d like to now how to use AlphaMaskMethod.
You see it’s huge black edges on leaves. it’s png and
branchMat.alphaThreshold = 0.01;
So I made a texture with green color and texture with alpha channel, I though if texture all green with no other color pixels so my leaves can only bee green, and with alpha mask, it’s beautiful and pleased, with no black edges, but unfortunately AlphaMaskMethod did not work for me, and no any little example i can not found.
Simple test
package
{
import away3d.animators.*; import away3d.core.partition.*; import away3d.events.*;
import away3d.cameras.lenses.*;import away3d.core.base.*;import away3d.core.math.*;
import away3d.library.assets.*; import away3d.debug.*; import away3d.cameras.*;
import away3d.containers.*; import away3d.entities.*; import away3d.lights.*;
import away3d.materials.*; import away3d.materials.lightpickers.*;import away3d.materials.methods.*;
import away3d.primitives.*; import away3d.textures.*;import away3d.filters.*;
import away3d.materials.utils.*;import away3d.primitives.data.*;
import flash.display.*;import flash.events.*;import flash.system.*;
import flash.ui.*;import flash.utils.*;import flash.sampler.*;
import flash.net.*;import flash.media.*; import flash.net.*;
import flash.external.*;import flash.text.*;import flash.geom.*;
import flash.utils.*;
import mx.graphics.codec.*;
/**
* ...
* @author Lexcuk
*/
public class AlphaMaskTestDoc extends Sprite
{
private var view:View3D;
public function AlphaMaskTestDoc()
{
view = new View3D();
addChild(view);
view.antiAlias = 4;
//setup the camera
//trace('view.camera.lens.far ' + view.camera.lens.far);
view.camera.lens.far = 60000;
view.camera.x = view.camera.z = 0;
view.camera.y = 300;
trace('hello AlphaMaskMethod');
view.camera.lookAt(new Vector3D(0,0,0));
view.backgroundColor = 0xFFFFFF;
var orangeBitmap:BitmapData = new BitmapData(256, 256, false, 0x00FF00);
var cubeMaterial:TextureMaterial = new TextureMaterial(new BitmapTexture(orangeBitmap), true, true, true);
var s:Sprite = new Sprite();
s.graphics.beginFill(0x000000, 1);
s.graphics.drawRect(0, 0, 256, 256);
s.graphics.drawEllipse(100, 25, 60,90);
//addChild(s);
var alphaBitmap:BitmapData = new BitmapData(256, 256, true, 0x00000000);
alphaBitmap.draw(s);
//addChild(new Bitmap(alphaBitmap));
var alphaMaskMethod:AlphaMaskMethod = new AlphaMaskMethod(new BitmapTexture(alphaBitmap), false);
cubeMaterial.addMethod(alphaMaskMethod);
var cubeGeometry:CubeGeometry = new CubeGeometry(100, 100, 100, 1, 1, 1, true);
var mesh:Mesh = new Mesh(cubeGeometry, cubeMaterial);
view.scene.addChild(mesh);
addEventListener(Event.ENTER_FRAME, enterFrameHandler);
}
private function enterFrameHandler(e:Event):void {
view.render();
}
}
}
I see black square instead of green circle. How to do right thing with AlphaMaskMethod?