Thursday, July 31, 2008

Fun with Particles and Filters (AS3) Part 2

Yesterday I posted my first go around with some particle effects.

Today I have a new example using Blitting, which has improved performance but I am having trouble with the look and feel. I have tested it on two machines and the new version seems to get around double the frames per second and uses one-fifth the CPU usage. However, I am having trouble getting the bitmapdata to alpha out. I used a ColorMatrixFilter but that only seems to gray out the smoke... which ends up look much more polluting. You can view my progress here.

Once I figure out the alpha and clean up my code, I will post in more detail about the Blitting.

12 comments:

Unknown said...

so I am not sure how you are using the color matrix filter, but I have had great success applying it on an enterframe to slow fade out the bitmap.

ie

//set up a alpha fading matrix

alphaMatrix = new ColorMatrixFilter([

1,0,0,0,2,

0,1,0,0,3,

0,0,1,0,4,

0, 0, 0, 1,- 4]);

//the -4 at the end is what you want to mess with to drop the alpha


// then on an enterframe or timer or whatever, I would drop this...

yourBitmapData.applyFilter(yourBitmapData, rect, pt, alphaMatrix)


///Is that what you are doing? maybe it just has to do with orginal gradient you are using as the smoke. anyway, I look forward to your solution. Good Luck

Ickydime said...

ak10,
Thanks for the comment. Sorry for the delayed response. Been meaning to get back to this.

Yes, I was using the ColorMatrix Filter, but I was using the the second to last item instead of the last item. The second to last item gets multiplied against the source's alpha and I would just decrease the percent on each update. The last item appears to be the alpha offset. So I am guessing we are doing the same thing just in a different way. But I am still fairly new to ColorMatrixFilters and need further experimenting to see what works best.

Ickydime said...

To overcome the Alpha issues I ended up adding the alphaBitmapData parameters to the copyPixels function. Basically when I applied the ColorMatrixFilter with the deceased Alpha it caused the transparent area to become grey. By Adding the Alpha information during copyPixels it seemed to remove the extra grey area, although it also seemed to decrease performance slightly.

Adriaan said...

I'm curious, is this using the movieclips you mentioned in your first post about the particles? I'm still interested in the code you used for this. What's your reason for using the ColorMatrixFilter over, say, a Tweener instance that tweens the alpha to 0?

Ickydime said...

@Adriaan
Yeah, it is still using the basic MovieClip for reference. However, the MovieClip is never actually placed on the stage. Instead you use blitting and store the bitmapData. Using this data as a reference you copy the pixels of each particle into a single container. Since they are all in 1 container and each particle can have a different alpha... you can't use Tweener. You need to apply the alpha when you copy the pixels.

Hopefully that clears it up some.

Alice Wong said...

It’s amazing in support of me to truly have a blog site, which will be valuable meant for my knowledge. Thanks admin.
web design San Francisco

yanmaneee said...

pg shoes
jordan shoes
jordan 6
goyard handbags
yeezys
moncler
outlet golden goose
supreme outlet
yeezy 380
retro jordans

yanmaneee said...

yeezy boost 350
air jordan
golden goose outlet
supreme clothing
kevin durant shoes
supreme new york
yeezy
moncler outlet
yeezy boost 380
ggdb

Sarah Silva said...

They were particularly praised for their reaction time brand strategy agency and flexibility in the face of changing client demands. Project management was also systematic and smooth.

Cheryl Terrell said...

Regardless of whether you need assistance generating traffic to some big advanced site or just easy methods to use Digital scale for weed

Jamie Mack said...

Great! We will be connecting to this enormous post on our site. Continue the good writing.
UX design firm San Francisco

Splegalnurse said...

The gorgeous post learned a great deal Thanks greatly!
branding companies