Hi,
I’m having a small issue with alpha blending when working with 3D. Example:
The top rendering came from the flash IDE and it looks identical to displaying the object using the display list (these are on white backgrounds btw). The bottom rendering was produced by my code and is rendered as a textured quad. I’m trying to figure out why the alpha is behaving oddly when using the GPU.
Here is my context3d initialization code:
_context3D.configureBackBuffer(_backBufferWidth, _backBufferHeight, 16, false, false);
_context3D.setCulling(Context3DTriangleFace.BACK);
_context3D.setBlendFactors(Context3DBlendFactor.SOURCE_ALPHA, Context3DBlendFactor.ONE_MINUS_SOURCE_ALPHA);
Here is my shader code:
var vertexShaderCode:String = "";
vertexShaderCode += "m44 op, va0, vc0
"; //p transform
vertexShaderCode += "mov v0, va1
"; //color
vertexShaderCode += "mov v1, va2
"; //uv
var fragmentShaderCode:String = "";
fragmentShaderCode += "tex ft1, v1, fs0 <2d,nomip,linear,clamp>
";
fragmentShaderCode += "mul ft2, ft1, v0
";
fragmentShaderCode += "mov oc, ft2
";
var assembler:AGALMiniAssembler = new AGALMiniAssembler();
var vertexShader:ByteArray = assembler.assemble(Context3DProgramType.VERTEX, vertexShaderCode);
var fragmentShader:ByteArray = assembler.assemble(Context3DProgramType.FRAGMENT, fragmentShaderCode);
var shader:Program3D = _context3D.createProgram();
shader.upload(vertexShader, fragmentShader);
_context3D.setProgram(shader);
I’m hoping for a little help from someone more experienced at 3d with flash than I. Any ideas why this is happening?
Thanks so much!
-S
Just as a reference, here is the original image: