Planetary Shadows

Started by
3 comments, last by Hawkblood 7 years, 6 months ago

I want to create shadows between moons and planets. This is not as easy as it sounds because the local star is not a point of light except for planets that are VERY far from it. Planet systems like Earth-Moon are close enough to the Sun that the eclipse area of the moon isn't exactly the size of the moon -- it's smaller. Likewise, Mercury was directly between the Sun and Earth, it has no eclipse area on Earth because the Sun isn't just a point of light, it has a huge surface that is generating light......

So the question: How do I make a shader to accomplish this? Conceptually, how is this done?

Advertisement

23vax5i.jpg

Ignoring the red / green stuff you see black area: completely shadowed, white area: filly lit, grey area: partially lit.

In 3D you would need to intersect cones to get a accurate solution, but it's easier in 2D.

Say we want to calculate lighting at the point where green & red lines intersect.

Looking at the scene from this point, both planets are just circles leading to those questions:

1. What is the radius / area of both circles? http://math.stackexchange.com/questions/73238/calculating-solid-angle-for-a-sphere-in-space

2. What's the distance between their centers? (i think you should use the angle between both 3D centers to the lit point, if you treat your 2D space on the unit sphere of this point)

3. How much sun area is occluded by planet area? http://mathworld.wolfram.com/Circle-CircleIntersection.html

A faster 1D approximization would be to use the circle diameters overlap instead area intersection (red and green bars in the picture).

That's pretty close to the accurate solution in practice.

I've done this stuff, but it would take time to find and understand the code again. It is however easier than it sounds.

What @JoeJ posted is correct, I'd extend his response with something interesting about the topic -> as you are working on planetary scale it might sound interesting to add general relativity context (allowing to F.e. simulate gravitational lensing and light-gravity interaction in general.

In reality even planets are generating some gravitational lensing - and therefore you are not actually going always along the line (as photon direction, frequency and therefore intensity are affected by gravity), although not even close to solar-scale (or bigger). It might be interesting to see such simulation on the surface of planet in binary/ternary star systems (Alpha Centauri AB for example).

My current blog on programming, linux and stuff - http://gameprogrammerdiary.blogspot.com

So the next big thing is... "Curve Tracing" :)

Villem Otte, I hadn't thought of having a lines effect behind planets to cause a relativistic effect for star light..... That's an interesting idea. I am however, curving my pathing when near a planet. I'm at work now, so I can't even view the image you showed JoeJ.... I'll try to read the links.

This topic is closed to new replies.

Advertisement