Creating Nebulas and Starscapes in Fantasia + Source Code!

Oct 27, 2010

Yes! I just released support for new type of filters in Fantasia that I called Creations. The first, Nebula Creation, allows me do to starry background images like this (source code below):

Update: shortly after releasing the source code I noticed the nebula image was fixed (only the opacity mask was varying), fixed it and uploaded again.

nebula1

Or this:

nebula2

If you’d like to try for yourself, open Fantasia now (http://fantasia.nokola.com) and go to Creations (after Effects).

image

The first one is done by creating a nebula with no stars (set to zero), then Tint, then add stars. The second one is just the Nebula generator Smile I find both very usable for space shooter games Smile

The Creation filters work with the selection brush, and you can easily sprinkle some stars on an image:

Original:

starBefore

Starry night:

starAfter

The starry night version looks much more interesting…just waiting for few comets to pop up! Original image is from here: http://www.flickr.com/photos/dagoaty/4360363431/

I also made a small sample that has just the Nebula generator: http://nokola.com/nebula 

Download source code

I used lots of various sources on perlin noise (like Ken Perlin’s homepage and multiple algorithms for noise), until I got to the current version. It’s optimized to use integer numbers (fixed point calculations) throughout.

A little bit on the algorithm: the important part of the logic is drawing a low-frequency noise (freq = 2) on screen by masking it’s opacity with exponentially filtered high frequency noise (freq = 7). Thus, the low frequency noise becomes a smooth nebula, and the high frequency noise tells “if there’s nebula on screen or not”. In the source code there are a lot of internal parameters to play with.

Hope you like it! Please comment!

    
blog comments powered by Disqus

nokola.com | Terms | Log in

Recent

About the author

Happy & enjoying life. Software enthusiast.
The opinions I express here and on nokola.com are mine and not my employeer's (Microsoft).
This is the official blog of nokola.com. You can find Silverlight samples, coding stuff, and hopefully other interesting things here.