away3d / away3d-core-openfl

Away3D engine for OpenFL
166 stars 41 forks source link

Alpha Blending Issue #40

Open dimumurray opened 9 years ago

dimumurray commented 9 years ago

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

Greg209 commented 9 years ago

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.

Type1J commented 9 years ago

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 https://github.com/openfl/lime/issues/409

Type1J commented 9 years ago

https://github.com/openfl/openfl/pull/622 fixed native. The html5 target still has some problems. I'm not sure why just yet.