Good old Plasma effect

April 18th 2009

Back in 2006, when I was a real noob coding wise (now I'm just below average), I did this plasma effect with AS2.



3 years later, in 2009, the effect with flash 10 looks like this.



Get the sources here. (It's VERY simple)

Thanks to Steve Ferrigno for indirectly pushing myself on coding the effect with Pixel Bender just by asking for the .fla of the 2006 effect :)
9 comments written so far...

Happy now? Mr.Tucker? ;)
April 18th 2009
mr.doob
And how about New Pixel Bender and fuly CS4 (no pv3d) acid_cubes http://mrdoob.com/lab/pv3d/acid_cubes.html ? =) Have a nice day...
April 19th 2009
Ole Jak
I can't see why pixel bender is needed on that one. Making it pv3d-less could be interesting for getting used with flash 10 3d, but uhm... not too inspired :D
April 19th 2009
mr.doob
Great! more res. more detail!
But I was wondering about performance.

Function Calling Vs. Variable usage.

Improves something on speed?

SinT=Math.sin(Timer * .0002);
CosT=Math.cos(Timer * .00005);
Timer=getTimer();

shader.data.center.value = [ SinT * 300 + (stage.stageWidth >> 1), Math.cos(Timer * .0001) * 300 + (stage.stageHeight >> 1) ];
shader.data.wave.value = [ Math.sin(Timer * .0001) * .06 + 0.01, CosT * .05 ];
shader.data.offset.value = [ Math.sin(Timer * .0004) * 200, Math.cos(Timer * .0003) * 200 ];
shader.data.color_offset.value = [ SinT * 2, Math.sin(Timer * .00009) * 2, CosT * 2 ];
shader.data.distort.value = [ Math.sin(Timer * .00008) * .05 ];
April 20th 2009
jaK
That won't change much jaK. That's called once per frame. It can give you half a frame or a frame, but if you want to optimise you should go down to optimise the kernel, as it gets executed once per pixel and there are sin/cos there too.

Be my guest ;)
April 20th 2009
mr.doob
So, it's like GLSL fragment shaders, or a some sort of software variable pipeline?

Things changed a lot in ActionScript! :D
.
So, in this case you can try to pre-compute a few things here in order to speed-up things a bit.

Althought your angle increment has Timer involved within. Have to adjust that for pre-comp. table access.

Anyway, this is a fast test, to make us an idea on how this new AS stuff works.

April 20th 2009
JaK
This is how the shader language looks like:

http://code.google.com/p/mrdoob/source/browse/trunk/lab/effects/shaders/plasma/dev/assets/plasma.pbk

And yeah, I didn't optimised it as much as I could, I just kept it fun and moved to the next thing.
April 20th 2009
mr.doob
Quite nice! It shows a drastic improvement in speed and processing power in 3 years. Now if only it could compare to Java even.. :)
April 20th 2009
thewickedchris
thewickedchris: I'm not very confident neither to Java or AS, in terms of improvement in speed.

When I want such that thing I move to C++ & O.S accel. drivers fullscreen rendering, like 3 years or more ago...

;D
April 21st 2009
JaK

Have your say!

Name:

Website:

Comment:

Some of the projects that I worked on.



Some of the HTML5 and Actionscript experiments I've done.