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
Generated using a custom equation
A galaxy
The range based color mode
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.
Procedural Nebulae
Procedural Nebulae
Last edited by Iaro on Tue Jul 29, 2008 5:02 am, edited 1 time in total.
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
Ganadu'r, The Eternal Sage (Other Current Project) - http://rpg.naget.com
-
- Posts: 1638
- Joined: Mon Apr 30, 2007 3:24 am
- Location: Montreal, CANADA
- Contact:
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:
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:
-
- Posts: 1638
- Joined: Mon Apr 30, 2007 3:24 am
- Location: Montreal, CANADA
- Contact:
The galaxy object is looking very similar to that picture.
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!
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!
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?
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?
.. anyhow.... thanks a tons for this invention Iaro.
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?
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?
.. anyhow.... thanks a tons for this invention 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.
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.