Originally posted by davepermen:
i think when your planets/moons are detailed enough (enough vertices), you just have to calculate for every vertex, if the line between it and the lightsource ( sun, i suppose ) hits another object… search about ray->sphere intersection, and you should success…
Yikes. For the special case you’re dealing with, where both potential shadowers are (as near as makes no difference) spheres, this is overkill though. If you want to try the stencil volume approach then the shadow volume will always be a cut-off cone; you don’t need to process all the vertices.
I think you’d find it a lot easier, though, to use a projective texture with a big round shadow in the middle and the rest of it transparent.
(If you want to get really fancy, you could even implement the shadowing body as a spotlight with a negative colour (“darklight”); this should give you the nice penumbra soft-shadows you see in real lunar eclipses.)