PDA

View Full Version : Howto create a planet halo of light and a starfield



zingbat
08-08-2006, 04:58 PM
This is two questions in one. The first question is how do we create an halo of light for a planet? Similar to this:

http://www.firingsquad.com/media/gallery_image.asp/831/6

My second question how do we create a starfield background for a seamless world. The problem with this is imagine a nebula like in the picture above that is part of the background now imagine the player can travel seamlessly to the center of the nebula. How could we make this work?

Thanks in advance.

49er
08-08-2006, 07:51 PM
Hey Zingbat!

It's funny you should ask this because I was playing with this very thing recently. Very tricky!

In the first part of your question, I guess you're talking about rendering a planet's atmosphere from outer space? I've been messing with volume rendering techniques to handle this, but I haven't got it right yet. Some folks might just use a glow-/halo-sprite for simplicity/speed, which is just a blended, screen-aligned billboard. Or you could try a blurred/decimated version of a brightly colored sphere (pretty much the same idea). I guess it depends on your target system and how fancy you want to get. Perhaps with level of detail you could try a combination, depending on how far away the planet is.

For nebulas, I've had great success with volume rendering techniques again, but just for static images. I'd love to do some true 3D fly-through nebula, but it's difficult to get it just right in realtime. You could maybe try some of the techniques for rendering clouds, which might use some combination of concentric, semi-transparent ellipsoids and/or frame-grabbed impostors :-| Most the ideas involve just compositing layers in an attempt to approximate a volume of some kind.

I tend to bite of a bit more than I can chew to get as fancy as possible, then I end up waiting for the hardware to catch up. Then the new hardware comes out, and it starts all over again! :)

I guess my suggestion would be to learn about volume rendering techniques, how light transport works in gases and dust and so on. Then you can hack together your own approximation, and add complexity to it later as hardware evolves. It can never hurt to know some of the theory. I'm finding it better to start with the theory, then dumb it down for the hardware :)

For stars, plain old points work well for my really distant twinkers, then a few sprites for the closer ones. This works surprisingly well, especially if you vary the intensity (between 0.1 and 0.5 works great for me), which gives the illusion of different sizes and depths. You might even try a texture star-field on a sphere as backdrop, but I like points since I can generate millions of them, and using a random seed it's as easy to change the heavens as changing a single number.

Hope it helps!

zingbat
08-09-2006, 06:23 AM
Thanks for your elaborated description. I will try volume rendering. Hope it doesn't require very complex math.

Say is there any binary format to Volume Render data? How do we get a small nebula with this format if it exists?

49er
08-09-2006, 10:55 AM
The math can get very egg-headed at times. Thankfully, some very egg-headed people have made it much easier for the rest of us :)
http://www.vrvis.at/via/resources/course-volgraphics-2004/

This volume graphics course is awesome. It's advanced stuff to be sure, but these guys have made it at easy as it's going to get. The presentations are geared towards realtime methods, but it's an excellent overview of a complex topic.

Volume rendering is a huge subject, and I still have a great deal to learn myself. But it's surprisingly easy to build a software ray-caster, for example, for creating some really pretty images. I've found this to be a great way to start. You may also be interested in general ray-tracing and other offline techniques. I think the image based stuff will be around for quite some time.

I suppose you can use any format you like. I use simple image formats, like TGA and DDS. I generate my volume data (scalar field) using procedural techniques, so I never really need to store it. But if I were to store it, I'd probably just save out a list of floats, or perhaps shorts or something smaller and/or compressed to conserve disk space, depending on how large the data set was.

[Edit]

This particular PDF from the volume course gives a really good walkthrough of the math

http://www.vrvis.at/via/resources/course-volgraphics-2004/slides/SIGGRAPH04_Part01.pdf

And this I just found. Looks to be right up your alley!

http://sponeil.org/

zingbat
08-09-2006, 03:38 PM
Thank you. It will be a big effort to master this but it looks like this technique can create a very good quality universe.

k_szczech
08-09-2006, 06:24 PM
Atmospheres on the image you posted are very simple - they look like a simple quad drawn in the middle of planet that is just a bit larger than planet and has a round, smooth texture.
It could even be a triangle strip drawn around the planed without any texture.
You can see that there is no atmosphere between you and planet's surface.

If you want more realistic atmosphere then you need to draw a sphere around the planet with polygons facing towards planet (so the sphere is visible from inside) and calculate some kind of fog equation on every vertex of such sphere and every vertex of planet.
Such fog equation can be some simple imitation of atmosphere or something more complex like atmospheric scattering.
Take a look at this article:
http://www.gamedev.net/columns/hardcore/atmscattering/

It's more difficult than volume rendering but it's much faster without any quality compromise.

As for true 3d nebulas - using volume rendering can lead you to the point when you can get good quality or good speed but not both.
Look for volumefog on this page:
http://www.clootie.ru/delphi/download_dx90.html
It worked nicely on my GeForce 4Ti but it should be much easier to implement on GeForce 6 and above.
This technique's only limitation is that fog must have constant density and color.

Have you seen Freelancer? These nebulas and gas clouds did not use any volume rendering nor volume fog - simple polygons with blurry textures blended one on top of another and additionally standard fog when you enter a gas cloud. Simple and fast.