Friday 10 June 2011

4K Galaxy Demo

As another little experiment, I started working on a 4K demo, using the brillaint framework released by iQ on his website: http://iquilezles.org/www/material/isystem1k4k/isystem1k4k.htm

I'm not too sure about what I want to do with this but the main idea was to try and simulate a spiral galaxy made of 500K+ particles and see how nice I can manage to make it look. Plus maybe some attempt at a chiptune style music track to go along.

Regarding the galaxy simulation, my original idea was to create a velocity field and simply advect the particles to make them go round on elliptic orbits and simulate what is calles a density wave, which is apparently what creates the spiral arms. A picture's worth a 1000 words:
(from http://drgoulu.com/)

The corresponding implementation was pretty numerically instable and led to stars either flying off or collapsing into 1 single point after a few seconds of simulation. And I should probably post some of the weird/beautiful results that randomly appeared as my code was buggy here and there ... I would be incapable of creating such visuals from scratch even if I wanted to :)

The instability was coming from the advection step, so I changed my mind about the whole technique and ended up calculating the star's orbit directly in the shader, which is numerically stable.

Here's what I've got so far (sorry for the lowrez video):


And a side benefit, trying to write code that is that minimal is a great learning experience that I definatly recommend.

EDIT: Fixed video link.
-m

No comments:

Post a Comment