• entries
232
1462
• views
953709

# Planetary rings / asteroids

896 views

Planetary engine

The interfaces and rewritting of shaders in GLSL is progressing quite well, I'm pretty much ready to jump on the re-implementation of texturing, and improving water.

I got ride of the seams in some detail textures that were caused by multiplying the texture coordinates by a scale constant in the shaders ( in order to tile the texture a lot of times on the terrain ). It's a bit tricky to explain, but it was easy to implement, so I'll come back on the technique later ( if I don't forget ).

Rings / asteroid fields

I spent most of my week end refining the rendering and tweaking the asteroid fields.

Ring lighting

I introduced lighting of the rings ( yeah, it was missing in the previous update ). My natural approach was to compute a standard diffuse lighting term ( N^L with N being the ring normal, and L the sun direction ) and to add a bit of ambient on the unlit side of the ring, but to my surprise it didn't seem to work that way in reality. Apparently, the rings can range from very dark to very lit when seen from their unlit side, depending on the thickness of the ring. So instead, my lighting uses this formula:

float color = pow(gl_Color.x, 1.0 + (1.0 - diffuse.w) * 3.0);

With gl_Color.x being the vertex-to-sun angle ( ranging from 0.0, for unlit angle, to 1.0 for totally lit angle ), and diffuse.w being the opacity, taken from the ring texture.

Another aspect of ring lighting is that I didn't want to render the ring geometry twice with backface culling, but only once without backface culling; so depending on where the camera is, relative to the ring plane, the coefficient for lighting is adjusted ( typically, coef = +- N^L, with +- being the sign of the distance from the camera to the plane ).

Ring texturing

I was previously using a static texture ( Saturn's, to be more precise ). The ring texture is now procedurally generated. Nothing very advanced technically: a set of 3 main colors are chosen, and given some probabilities. Then, bands of colors are added together in the ring texture ( for the opacity in the alpha channel, they can be removed too ). The algorithm is running in 3 passes where the width of those bands of colors are varying.

Dust lighting

The dust particles are now looking up the correct color in the ring texture, so the texture and the dust particles all match together. I've also introduced alpha-blending for them, which makes them look much nicer than raw points. They are also fading in/out with distance instead of popping up suddenly.

Remember, the planet is still missing in the screenshots ( I can't add it before fixing some issues with the cascading Z frustums, to allow for correct Z-Buffer sorting ).

The shadowing of the planet is computed in the pixel shader by finding the distance between the pixel and the line passing through the planet center, with the sun direction. If this distance is lower than the planet radius, the pixel is in shadow.

The penumbra is also calculated ( at the moment with a constant, but later, will match the average thickness of the atmosphere ).

Precision issues

Last but not least, I had to fix many precision issues ( 64-bits coordinates are required to place objects at tens of AUs from the scene origin ), and render some effects such as the dust in camera space.

Besides impostors and minor bug fixes, I'm pretty much done with rings and asteroids fields.

Just my 2 cents here, but in my eye the falloff from lit to dark is far too sharp. It may be more "realistic", but it doesn't really look all that good to me. I'm sure it's dark on the lee side of a planet from the sun, but I don't think it's probably quite pitch black. But hey, I've never been on the lee side of a planet :)

Quote:
 Original post by Dragon88 Just my 2 cents here, but in my eye the falloff from lit to dark is far too sharp. It may be more "realistic", but it doesn't really look all that good to me. I'm sure it's dark on the lee side of a planet from the sun, but I don't think it's probably quite pitch black. But hey, I've never been on the lee side of a planet :)

But it' more realistic that way. See, for example, these images of Saturn's rings <http://ciclops.org//media/ir/2004/205_223_0.jpg> <http://ciclops.org//media/dr/2005/730_1558_2.png>. I haven't been there, but Cassini is :-)

Quote:
Original post by mchouza
Quote:
 Original post by Dragon88 Just my 2 cents here, but in my eye the falloff from lit to dark is far too sharp. It may be more "realistic", but it doesn't really look all that good to me. I'm sure it's dark on the lee side of a planet from the sun, but I don't think it's probably quite pitch black. But hey, I've never been on the lee side of a planet :) [ Emphasis added]

But it' more realistic that way. See, for example, these images of Saturn's rings <http://ciclops.org//media/ir/2004/205_223_0.jpg> <http://ciclops.org//media/dr/2005/730_1558_2.png>. I haven't been there, but Cassini is :-)

I guess (sadly) sometimes you just have to choose between realism and looking good in game development.

I dunno about you guys, but I think my eye needs to change its underwear. A variable penumbra on the ring, thats just icing on the cake.

Quote:
Original post by Dragon88
Quote:
Original post by mchouza
Quote:
 Original post by Dragon88 Just my 2 cents here, but in my eye the falloff from lit to dark is far too sharp. It may be more "realistic", but it doesn't really look all that good to me. I'm sure it's dark on the lee side of a planet from the sun, but I don't think it's probably quite pitch black. But hey, I've never been on the lee side of a planet :) [ Emphasis added]

But it' more realistic that way. See, for example, these images of Saturn's rings <http://ciclops.org//media/ir/2004/205_223_0.jpg> <http://ciclops.org//media/dr/2005/730_1558_2.png>. I haven't been there, but Cassini is :-)

I guess (sadly) sometimes you just have to choose between realism and looking good in game development.

Looks great if you ask me... :)

Quote:
 Original post by Dragon88 I guess (sadly) sometimes you just have to choose between realism and looking good in game development.

What, reality doesn't look good enough for you? ;-) Just kidding around.