I was trying AlphaMaskMethod and found out that method cannot change texture alpha. I use the following code:
var _mat:TextureMaterial = new TextureMaterial( Cast.bitmapTexture(new Circle()));
_mat.alphaBlending = true;
_mat.repeat = true;
var _alphamaskMat:BitmapTexture = Cast.bitmapTexture(new CheckerGrid());
_mat.addMethod(new AlphaMaskMethod(_alphamaskMat, false));
As far as i understand, AlphaMaskMethod changes fragment code to multiply source texures red channel with target textures all channels
return getTex2DSampleCode(vo, temp, textureReg, _texture, uvReg) +
"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(alphaReg, 1);
_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 ?