Transparent BitmapMaterial

25 views
Skip to first unread message

wagster

unread,
Aug 19, 2011, 5:20:58 PM8/19/11
to Away3D.dev
I'm struggling with the same problem as in this post:

http://groups.google.com/group/away3d-dev/browse_thread/thread/8debf3908238d77a

basically trying to draw a MovieClip onto a BitmapMaterial and place
in on a plane, while keeping the transparent parts of the MovieClip
transparent on the Plane.

... here's my class

public class Floor extends Plane
{
public function Floor(floorMc:MovieClip,
segmentsW:uint=1, segmentsH:uint=1, yUp:Boolean=true)
{
var bitmapData:BitmapData = new
BitmapData(2048, 2048, true, 0x00000000);
bitmapData.draw(floorMc);
var floorMaterial:BitmapMaterial = new
BitmapMaterial(bitmapData, false);
super(floorMaterial, floorMc.width,
floorMc.height, 1, 1, true);
rotationX = 90;
trace();
}
}

Firstly, I would like to create a BitmapData object the same size as
the MovieClip, but Texture3DProxy throws a "size must be power of 2"
error unless I set both height and width to a power of two, so

new BitmapData(floorMc.width, floorMc.height, true, 0x00000000)

doesn't work.

Secondly, I can't set the BitmapMaterial to transparent = true as
suggested above - because BitmapMaterial doesn't have a transparent
property.

Any ideas?

Cheers,

Wag

wagster

unread,
Aug 19, 2011, 5:28:49 PM8/19/11
to Away3D.dev
Aha. BitmapMaterial.transparent is dead. Long live
BitmapMaterial.alphaThreshold!

On Aug 19, 10:20 pm, wagster <ja...@pictureandword.com> wrote:
> I'm struggling with the same problem as in this post:
>
> http://groups.google.com/group/away3d-dev/browse_thread/thread/8debf3...

richardolsson

unread,
Aug 20, 2011, 9:13:30 AM8/20/11
to Away3D.dev
Either use alphaThreshold or alphaBlending. The former will set a
pixel entirely on or off depending on whether it's alpha is above or
below the threshold. The latter will use "smooth" blending so that
semi-transparent pixels show up as semi-transparent. In some cases
alphaBlending is required, but use it sparingly as it is significantly
heavier to process than alphaThreshold.


Cheers
/R
Reply all
Reply to author
Forward
0 new messages