Procedural Nebulae

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
Post Reply
Iaro
Posts: 45
Joined: Sat Feb 05, 2005 7:01 am

Procedural Nebulae

Post by Iaro »

This is the first version of something I've been working on to generate procedural nebulae and other distant celestial objects such as galaxies. Nebulae can be generated using several types of strange attractors, or with other methods such as simple random positions for particles.

Initially I did some tests using billboards, but for a large number of particles the aplication slowed down very quickly. So I wrote a custom scene node that can render a large number of particles very quickly (a jump of 25 to ~ 1200-1300 FPS).

There are a number of generators you can use: pickover, lorenz, polynomial etc. You can also generate random particles bounded in a cube, galaxies, and can also define your own custom equations for generation. If you don't want to use the 3D nebula, and only need a background, you can render te nebula to a texture and use it on a skyplane (one face of a skybox). The skyplane material is additive so you can also use a skybox in the same scene.

For coloring the particles 3 modes can be used: uniform color, which assigns the same color to all the particles, gradient color which assigns colors from a gradient based on the time of generation and range color which makes "clumps" of color. The last mode is very slow so be carefull with the number of particles.

To use the nebula and/or skyplane in your projects include the CNebula.h/.cpp and CSkyPlane.h files. An usage example is also included. In the example use the 1-8 keys to view 3D objects and shift + 1-8 to view renderings of those objects. In addition to the example source you can find a description of each function parameter here.

Download link: http://www.mediafire.com/?mzvecdphdu2

And some screenshots:

A so called "Lorenz butterfly" using the uniform color mode
Image

Generated using a custom equation
Image

A galaxy
Image

The range based color mode
Image

An interesting thing you can do with this objects is animate them. To do so modify at least one of the parameters by a very small value each frame/second, and call the generation function again. But try and use only the first two coloring modes for this.
If you want to find "interesting" looking objects you can use Chaoscope a free strange attractor viewer, at least for the functions that use strange attractors.
Last edited by Iaro on Tue Jul 29, 2008 5:02 am, edited 1 time in total.
wyrmmage
Posts: 204
Joined: Sun Mar 16, 2008 3:12 am
Contact:

Post by wyrmmage »

that's pretty cool stuff, I must say :)
Worlds at War (Current Project) - http://www.awkward-games.com
Ganadu'r, The Eternal Sage (Other Current Project) - http://rpg.naget.com
Dorth
Posts: 931
Joined: Sat May 26, 2007 11:03 pm

Post by Dorth »

Ok, first, wow, second, what is the license of this, third, wow!
Iaro
Posts: 45
Joined: Sat Feb 05, 2005 7:01 am

Post by Iaro »

The license is zlib.
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Post by christianclavet »

Wow! The galaxy model is looking great! I've not checked the code yet, but is there a way to add more detail in them? (generating more points)

If we could zoom on the galaxy object and view the stars! :D
Iaro
Posts: 45
Joined: Sat Feb 05, 2005 7:01 am

Post by Iaro »

You can have ~ (2^20)/2 particles. From tests the largest number of particles is 524287 before the polycount resets from about a million to zero. If you want to see individual "stars" for the galaxy generator either a smaller number of particles or a larger size for the galaxy can be used. The galaxy looks blurry because a large number of particles are used and because the billboard texture doesn't resemble a star, but is a slightly transparent rounded rectangle.

I've been thinking about having more than one type of texture in a nebula. I think a solution would be to have two nebula objects at the same position, only one of them can have a much smaller number of particles but the particles could be much larger. This would give very bright stars among a blurry nebula.

An example from wikipedia:
Image
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Post by christianclavet »

The galaxy object is looking very similar to that picture.
Image

Is's only missing the stars and it would make a very nice representation of that picture. (With the control you gave in the demo, I could "fly" inside it and it looked like it had volume (look very similar to a volumetric effect).

This is awesome! :o
lpersona
Posts: 58
Joined: Fri Jul 18, 2008 8:03 am
Location: low
Contact:

Post by lpersona »

i love it..

haven't taken a closer look at the code yet, but the precompiled application worked wonderfully


edit:

okay .. i tried to include the 3rd nebula into the hello world tutorial code (yes i actually just started with irrlicht)

and.. it works.. but... incredibly slow. the precompiled exe ran in the slowest moments at 173 fps on my pc.

my self coded nebula at around... 68 fps? :cry:

i'm probably too noobish for running your code properly ... or maybe the player model that is loaded in the hello world tutorial slows my program down by 105 fps... but that's unlikely.. it's a very low poly model

.. well okay.. i also used a slightly higher resolution window... but still... a 105 fps decrease? :shock:



.. anyhow.... thanks a tons for this invention Iaro.
Iaro
Posts: 45
Joined: Sat Feb 05, 2005 7:01 am

Post by Iaro »

Could you also post a FPS value for the example application. If the example application runs faster for the same example then maybe there's a problem with your program. The example was compiled with Irrlicht 1.4 and uses the DirectX driver. (In OpenGL there is a problem with rendering billboards correctly.)

Two things that can affect speed:
1. The program was compiled in debug mode. Try recompiling it in release mode.
2. If there are a lot of particles (in the thousands) very close to the camera the speed can be smaller. Do you just have a static camera or something like a FPS camera?

Edit: Sorry, you already posted a FPS value for the example application. But you can still try the two things for speeding up the program.

Some other speed related things:
Try lowering the particle count while at the same time increasing particle size. While this can make the nebula more blurry maybe the visual representation will be pretty similar in both cases.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

lpersona, as standard the Hello World tutorial uses the Software driver (set in the createDevice function), this is incredibly slow so try changing it to OpenGL or DirectX for hardware acceleration.
Image Image Image
Post Reply