gpu

GPU State Preserving Particle Systems with WebGL & HaXe

Well this is the post I didnt think was going to happen. I have been struggling for weeks with this little bit of tech, ill explain more about why it has been so difficult in another post. For now however, ill just talk about this sample.

So the idea was to build upon what I had been working with previously with my stateless particles systems with WebGL and HaXe. The intention from the start was to replicate some of my very early work (from 2007) on state preserving particle systems in WebGL.

Before I go any further, you can check it out in action here:
http://mikecann.co.uk/projects/HaxeWebGLParticles/ 

First a quick reminder. The difference between a stateless and state-preserving particle simulation is that in the latter we store and update the positions, velocities and other properties of each particle per frame, allowing us to interact and control the simulation. This differs from the stateless particle simulation (detailed in my previous post), where the position for each particle is calculated each frame based on a fixed algorithm.

A fairly reccent addition to WebGL made this possible, namely texture lookups in the vertex shader (aka Vertex Texture Fetch). I wont go over the exact details how this makes state preserving particle systems possible as I have already documented it in my earlier work. A brief explanation is that it allows you to use the fragment shader to perform the updates on particle state stored in textures then use the vertex shader to map those states to a point-sprite vertex buffer.

Basically what this means is that the entire particle simulation can be contained and updated on the GPU, which means no read-back. This allows us to achieve simulations of millions of particles without too much difficulty (depending on GPU ofcourse).

I have uploaded the source for people to perouse at their leisure:
https://github.com/mikecann/HaxeWebGLParticles

As usual it was written using the JS target of HaXe so it should be fairly easy to understand whats going on if you have written any Ecma-script-like-language. Im going to detail this in my next post, but the code isnt the best I have ever written as its a result of a mish-mash of various samples and examples I have found on the web. If anyone has any comments on things that are wrong or could be done better I would be very happy to hear about them.

Assembly 2010 – CNCD & Fairlight Demo

It was the massive annual Assembly gathering last week. Traditionally its a place for the demo scene to gather and present their demos and to hack out new ones.

For those not in the know the demo scene or “scene” is where a team of people come together and compete to make a music video. Except that they arent videos in the traditional sense as its all generated using code and runs in realtime. This means that you have to be super efficient with your code. Some of the competitions are “64k” or even “4k” competitions which means that the whole demo must fit in 64kb or 4kb! The music is also produced by the groups and often excellent.

I have been checking out some of the demos produced by the teams this year and they are simply stunning. Every year they get better and better.

This one from CNCD and Fairlight particularly caught my eye as it has massive numbers of particles and a stunning soundtrack kinda reminiscent of glitchy Radiohead. Therefore I thought it essential I share it here.

Enjoy:

Oh while im at it check out this one from last year:

If you are interested in more demos from assembly you can get them all here: http://scene.org/newfiles.php?dayint=7&dir=/parties/2010/assembly10/

Oh I have also posted about the demoscene before here: http://mikecann.co.uk/art/andromeda-software-development-lifeforce-2007/

 Scroll to top