Jump to content
  • Advertisement
Sign in to follow this  
Hawkblood

Planetary Shadows

This topic is 739 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Edited by JoeJ

Share this post


Link to post
Share on other sites

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).

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!