away3d / away3d-core-openfl

Away3D engine for OpenFL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Alpha Blending Issue

dimumurray opened this issue · comments

Here's an odd thing that keeps cropping up. I have an app with a number of overlapping 3D planes. Each plane has a texture applied with alpha transparency. On native targets, a slight white outline/glow appears where the textures overlap. On the HTML5 target the white glow is even more prominent.

Here are some images to illustrate.

Ideally this is what I want:

The native(windows) target has white outlines but they are near negligible so I won't bother posting it...

The HTML5 target, however, produces this:

I have no idea where the "white halo" comes from.

Here's the code if anyone cares to investigate:
https://github.com/dimumurray/AlphaTest

I've been recently experiencing this issue myself. I've not found the problem yet so I'll need to investigate further. Thanks for logging it.

This is caused by the way OpenFL is storing pixels in BitmapData.

If you change the lines:

    splatterMaterial.alphaPremultiplied = true;

and

    glyphsMaterial.alphaPremultiplied = true;

to

    splatterMaterial.alphaPremultiplied = false;

and

    glyphsMaterial.alphaPremultiplied = false;

Then you will get the correct behavior on html5 and native, and a different incorrect behavior in flash.

@Greg209 Please look at openfl/lime#409

openfl/openfl#622 fixed native. The html5 target still has some problems. I'm not sure why just yet.