Procedural Planetary Nebula

Panda3D Forum Index -> Code Snippets Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Legion


Posts: 152
Location: Germany

PostPosted: Wed Aug 08, 2007 11:30 pm    Post subject: Procedural Planetary Nebula Reply with quote
[UPDATE]

I've got a video on youtube from the nebula:

[url]http://www.youtube.com/watch?v=0KxgaRuQfPY[url]

[/UPDATE]
Some of us (including me, of course) are working on space shooter type of games.
And I've taken some time (together with the guys on Pandas IRC channel) to create one effect a good space shooter game can't afford to miss...
...a planetary nebula!

Of yourse, you could just render some great looking nebulae on your skybox, but what we wanted (Treeform and myself) was a volumetric nebula that you could actually fly through.

So after some internet research I found some equations that could help with generating such nebulae.

http://www.btinternet.com/~ndesprez/manual/attractors.htm

Based on those "strange attractors" I created some code, that generates a nebula as a set of GeomParticles...

The code(with enough comments I hope):

http://legion.panda3dprojects.com/download/nebula2.py

And some screenshots with different angles and particle densities:





The last two are with 1000000 particles, obviously too much fro the frame rate, the first one is with 100000 particles...
so enjoy...
_________________
---OmniCode 0.1.6 ---
sxy cm180 kg90 skffffff ha7d4419 eso sp< Ag1982 anE hdd ZoB Rl! Kd! MBintp FHg UFCthulhu IN12 Ad* PrPython(3)^(9)&C(2)^(5)&Basic(5)&PHP(4)^(7)


Last edited by Legion on Fri Aug 10, 2007 10:12 pm; edited 1 time in total
treeform


Posts: 2027
Location: Seattle

PostPosted: Wed Aug 08, 2007 11:38 pm    Post subject: Reply with quote
yes Legion is da man! I already put the nebulas into my game and they look awesome! I will let screen shots speak for them selfs!









and with more game elements:



Thanks alot for sharing Legion!!!
_________________
Panda3d IRC irc://irc.freenode.net/panda3d | BUGs https://bugs.launchpad.net/panda3d
My MMORTS game: http://aff2aw.com
GitHub: http://github.com/treeform | Twitter: http://twitter.com/treeform
Josh Yelon


Posts: 1360

PostPosted: Thu Aug 09, 2007 1:11 pm    Post subject: Reply with quote
Have you tried using a significantly smaller number of particles, but with each individual particle larger?
_________________
Josh Yelon, Teacher, Carnegie Mellon Entertainment Technology Center
Legion


Posts: 152
Location: Germany

PostPosted: Thu Aug 09, 2007 1:43 pm    Post subject: Reply with quote
Yes I did, but that just looks bad...
But you could try that for yourself (just takes a minute to adjust the number of particles and the thickness with setRenderModeThickness() )
And don't ask about using textured sprite particles, that won't even let me go up to 1000 particles with a reasonable frame-rate.

Though, I want to experiment with shaders, to achieve a denser look with less particles. But right now shaders won't work (somehow my system is a little bit messed up)...
_________________
---OmniCode 0.1.6 ---
sxy cm180 kg90 skffffff ha7d4419 eso sp< Ag1982 anE hdd ZoB Rl! Kd! MBintp FHg UFCthulhu IN12 Ad* PrPython(3)^(9)&C(2)^(5)&Basic(5)&PHP(4)^(7)
Hypnos


Posts: 546
Location: Zürich, Switzerland

PostPosted: Fri Aug 10, 2007 7:00 am    Post subject: Reply with quote
i changed the code structure a bit and added 2 other algorithms to play around with.

The used function can now be defined at the end of the file "a = nebula(func)"
- where func may be:
- default : the previous one
- lorenz
- ifsLorenz

to see the full capabilities i recommend playing around with the 'changeable variables' in the classes default, lorenz and ifsLorenz. Try little changes on separate numbers, as it often exceeds the number range of python.

http://public.nouser.org/~rspoerri/Development/python/panda3d/projects/nebulae/nebula2.py
Legion


Posts: 152
Location: Germany

PostPosted: Fri Aug 10, 2007 9:37 am    Post subject: Reply with quote
Thanks Hypnos...
I already had the feeling, that the nebula class should provide more flexibility, so one could render different shapes...
_________________
---OmniCode 0.1.6 ---
sxy cm180 kg90 skffffff ha7d4419 eso sp< Ag1982 anE hdd ZoB Rl! Kd! MBintp FHg UFCthulhu IN12 Ad* PrPython(3)^(9)&C(2)^(5)&Basic(5)&PHP(4)^(7)
darksmaster923


Posts: 101
Location: Cali USA

PostPosted: Mon Aug 13, 2007 7:52 am    Post subject: Reply with quote
it looks...........beautiful.............
_________________
I am the law
Hypnos


Posts: 546
Location: Zürich, Switzerland

PostPosted: Wed Aug 15, 2007 9:07 am    Post subject: Reply with quote
I added a interactive environment to change the parameters on the fly. Get the latest version of my modification from:

http://public.nouser.org/~rspoerri/Development/python/panda3d/projects/nebulae/nebula3.py

It also allows you to save the files into .bam
Because it recalculates the whole nebula when pressing a button the number of particles during modifying should be kept low. Once you found something nice you can increase the number of particles easily.

The only thing that has to be changed manually is the attractortype at the end of the file.
Hypnos


Posts: 546
Location: Zürich, Switzerland

PostPosted: Sat Sep 01, 2007 4:16 am    Post subject: Reply with quote
Hi,

I've updated the code again and added a galaxy generator if have found lying around on my harddisk (though i did not write it), it's currently the default when starting up.

I hope this helps someone.

this version is not integrated into the editing (however the names of the variables are more meaningful)
http://public.nouser.org/~rspoerri/Development/python/panda3d/projects/nebulae/nebula4.py

this version can be edited using the keys in the editor (the variable names are just useless), note that not all parameters can be changed (like the thickness of the arms and the depth of the arms, the other fixed vars are relative to other variables (like radius of the core/ radius of the arms)):
http://public.nouser.org/~rspoerri/Development/python/panda3d/projects/nebulae/nebula4_1.py

radu


Posts: 143
Location: Bucharest

PostPosted: Tue Nov 10, 2009 7:28 am    Post subject: backup Reply with quote
anyone happens to have the 4 or 4_1 version available somewhere?

on a side note: has anyone considered bringing all these examples together, including these small experiments, into a wiki or something, so they don't get lost as times goes by?
ThomasEgi


Posts: 1820
Location: Germany,Koblenz

PostPosted: Tue Nov 10, 2009 8:46 am    Post subject: Reply with quote
radu: serach the forum for "demomaster" . aside from that we have the code-snippset and showcase corner here on the forum. then we have panda3dprojects which can host larger examples. only very few things are lost. you'r also free to write samples to be included into panda.
_________________
rig: dell inspiron 1720; ubuntu 9.10_64 ;panda 1.7.0
may a catgirl be with you. nyaan nyan~~ ^.^
Hypnos


Posts: 546
Location: Zürich, Switzerland

PostPosted: Tue Nov 10, 2009 8:57 am    Post subject: Reply with quote
here's a updated link, containing all versions i've worked on:

http://www.nouser.org/WD/Development/python/panda3d/projects/nebulae/Archiv.zip
_________________
http://www.nouser.org/
BA Gamedesign, Zurich University of the Arts
Display posts from previous:   
Post new topic   Reply to topic    Panda3D Forum Index -> Code Snippets All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group