Procedurally generated galaxy (image-heavy)

Miscellaneous Forums/Blitz Showcase/Procedurally generated galaxy (image-heavy)

It uses a predefined picture, and generates a number of stars based on the intensity of the RGB pixel.


It's a lot more trickier than you think. The pixel values are interpolated so that there are no sudden variations in star densities between a totally white and a totally black pixel. To smooth out the density transitions, the values of the neighboring pixels have to be taken into consideration. And all of this has to be calculated and generated in real-time while scrolling.

I wish I could take the credit for that brilliant algorithm, but the underlying function is actually blatantly ripped from the reverse-engineered Elite II Frontier executable... Ehem... Forget I said that. ;)

Anyone interested in the galaxy generator fundamentals, head over here:
http://www.jongware.com/galaxy1.html