Massive amounts of 3D particles without Alchemy and PixelBender

As a response to Ralph Hauwert’s article I created a little example of what can be achieved using plain ActionScript 3 syntax. Ralph has put up a great example of how you can wire things like Alchemy, ActionScript and PixelBender together to achieve an astonishing result.

However I asked myself if it is possible to achieve the same result without making use of Alchemy, PixelBender or bytecode manipulation. I asked the guys sitting with me in the office to compare the results and they were unfortunately very different on various machines. Sometimes my version is faster, sometimes the version from Ralph is faster and sometimes they are about the same.

Now there are some very important things to note here and I am surprised that I got so close. Since Ralph is making use of PixelBender the number crunching is done on multiple cores. Something that is not possible with the ActionScript version which is the real bottleneck. And there is another big difference. Ralph’s calculations are done in 32bit while I am using 64bit precision. Therefore I am happy with the result and it shows that using pure ActionScript is still a good choice.

In order to optimize the code I used a linked list for the particles and minimized the comparisons between different data types. Here is the result.

Sources:

2 Comments

  1. RiaanWest
    Posted Jun 13, 2012 at 5:35 pm | Permalink

    More than 3 years later, and I’m using your method to do a Kinect-driven particle cloud app :)

    I have one question, and hopefully you’ll see this:

    Is there any way to increase the particle size when they come closer to the “viewer”?

    I would really appreciate your help!

    Thanks

  2. Jon Deo
    Posted Oct 31, 2012 at 1:47 am | Permalink

    @Riaan
    Possibly to late …
    Short answer: No

    This would heavily impact performance, since at the moment each particle is drawn as a pixel.
    Changing the size of a particle depending on its z-value, would mean drawing some kind of shape at the position of the particle.
    That would be hard to do with the use of a vector, so you’d have to draw the shape onto the bitmap, making everything that speeds up this version obsolete.

6 Trackbacks

  1. […] Massive amounts of 3D particles without Alchemy and PixelBender at 3 Apr 2009. Ralph's calculations are done in 32bit while I am using 64bit precision.. on my machine core 2 duo 1.7Ghz(Win XP, Firefox 3) your version runs at.. Pingback on Apr 6th, 2009 at 11:11 am. 2 More play with Alchemy.blog.joa-ebert.com/…/massive-amounts-of-3d-particles-without-alchemy-and -pixelbender/ – Massive amounts of 3D particles without Alchemy and PixelBender at […]

  2. By Performance verbessern - Flashforum on Jun 28, 2011 at 5:34 pm

    […] […]

  3. […] PixelBender+Alchemy option (by Ralph Hauwert) http://www.unitzeroone.com/blog/2009/03/18/flash-10-massive-amounts-of-3d-particles-with-alchemy-source-included/ Pure AS3 option (by Joa Ebert) http://blog.joa-ebert.com/2009/04/03/massive-amounts-of-3d-particles-without-alchemy-and-pixelbender… […]

  4. […] […]

  5. By Alchemy 와 속도 | Blog on Nov 19, 2011 at 9:19 pm

    […] of 3D particles with Alchemy 란 블로그로 Alchemy의 속도에 논란을 불지폈지만,Massive amounts of 3D particles without Alchemy and PixelBender 란 블로그를 보면 Vector를 사용하고 코드를 최적화 하면Actionscript 만으로도 […]

  6. […] and File Streams I’ve read quite a few posts and comments on the internet debating whether or not Alchemy is faster than straight ActionScript, since it all runs within the […]