# Alpha blending appears dark when using Stage3D

**URL:** <https://forum.kirupa.com/t/alpha-blending-appears-dark-when-using-stage3d/330928>\
**Category:** flash\
**Created:** [April 10, 2013, 11:39am UTC](https://forum.kirupa.com/t/alpha-blending-appears-dark-when-using-stage3d/330928 "2013-04-10T11:39:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Spencer\_Evans](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@Spencer\_Evans](https://forum.kirupa.com/u/Spencer_Evans)\
**Post date:** [April 10, 2013, 11:39am UTC](https://forum.kirupa.com/t/alpha-blending-appears-dark-when-using-stage3d/330928/1 "2013-04-10T11:39:04Z")

</div>

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:

```auto

           _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:

```auto

           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:
