1
\$\begingroup\$

I assume the most straightforward way to draw planetary rings (such as those around Saturn) is to use a texture that is transparent everywhere except for the rings, and then place the planet in the middle of the texture and that's it.

The problem with this approach is that I don't know how to shadow the area of the rings texture that is behind the planet (which isn't lit by the sun). At the moment I have a rings texture that is permanently lit and a planet that darkens in the areas where it's not lit by the sun. The planet revolves around the sun, so the lit/shadowed areas are constantly changing.

Any suggestions on how to apply shadow on the rings?

\$\endgroup\$
  • \$\begingroup\$ Are your shadows currently only coming from cosine based shading values? Have you tried any techniques such as shadow maps? \$\endgroup\$ – Mokosha Nov 26 '13 at 15:45
3
\$\begingroup\$

Josh's answer is the "how to do it properly" answer.

My answer is the "the simplest thing that could possibly work" answer: Just draw the shadow straight into the ring texture, and now your ring appears to have received a shadow from the planet.

If your planet moves around the sun, then spin the ring so that the side with the "shadow" is always away from the sun, relative to the planet's current position.

This is going to be heaps easier than implementing shadow mapping, and will render faster, and will probably even look better due to increased texture resolution (compared against the resolution of the depth buffer you'll need for the shadow mapping).

\$\endgroup\$
  • 2
    \$\begingroup\$ Pretty good idea actually; you can store the "shadow" ring in a separate texture if you need to (as you might when the ring itself is of non-uniform visual style throughout and so "spinning" the ring would look weird). \$\endgroup\$ – user1430 Nov 27 '13 at 3:25
  • \$\begingroup\$ Mm, with a shader to use the shadow data from the second texture. I like the way you think, Josh! :) \$\endgroup\$ – Trevor Powell Nov 27 '13 at 6:45
  • \$\begingroup\$ Cheers, Trevor. Implemented it like this eventually, mainly because of the reasons from your last paragraph. \$\endgroup\$ – async Nov 27 '13 at 11:55
3
\$\begingroup\$

Presumably you model the planet as a sphere. You can model the rings as a large quad that intersects the planet sphere (as you described) or as an actual ringed geometry object (with a similar kind of texture).

In both cases, if the planet is considered an occluding object in any kind of shadow mapping (or other shadow-handling technique that takes into account actual occluder geometry and light source position, that is, not simple "blob shadows"), the ring geometry can receive the results of the shadow mapping algorithm and appear in shadow behind the planet.

Shadow mapping is quite common, and while beyond the specific scope of your question, you can fairly easily find tutorials online for OpenGL, D3D, XNA and so on to get you started. The topic also comes up quite a bit on this site itself.

\$\endgroup\$
  • \$\begingroup\$ Thanks for your time & for introducing me to shadow mapping, Josh. Most certainly it will be a matter of days or weeks at most when I need shadow mapping, but Trevor's solution is more appropriate and easier in my situation. \$\endgroup\$ – async Nov 27 '13 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.