Teun van der Zalm developed an algorithm for creating nebulae in games, VR, and film. This showcase of the results, set to a lovely free track by Lee Rosevere, hints at the beauty that emerges from math.
van der Zalm explains the development of the formula:
After testing complicated algorithms, I arrived at the Perlin Noise algorithm. This algorithm was invented in 1983 (my birth year) by Ken Perlin and was later used by several computer programs.
While experimenting with the noise algorithm, I find out that this was not good enough for the base of the nebula system. Therefore I had to use multiple and different noise fields to produce a more life like nebula form. It became clear through experiments that I needed a starting point to build on. First I created an primal object designed by a procedural algorithm based on the Perlin Noise. After that I transformed the object to particles and manipulate these with the noise algorithm. The result is the base nebula without all the detail. In the second phase I deform the base through maps that are based on fractal noise. The final result is an high dense and high detailed particle system. This way I can create close up, medium and total shots of the nebula.
The video includes a lovely quote from the eminently quotable Carl Sagan, from Cosmos: A Personal Voyage Episode 1: The Shores of the Cosmic Ocean: "A cloud that veils one of nature's secret places. This is a stellar nursery, a place where stars are born. They condense by gravity from gas and dust until their temperatures become so high that they begin to shine. Such clouds mark the births of stars as others bear witness to their deaths."