Jump to content

Developer Insights #23 - Black Hole Sun


Recommended Posts

  • KSP Team

KerbalPortraits_Cioletti_800x450.png

Hey! I’m Jon Cioletti, the Senior Technical Artist focused on lighting and VFX here at Intercept Games! In celebration of the upcoming total solar eclipse, today we are looking at some of the lighting tech around eclipses in KSP2 - but first we have to talk about eclipses in REAL life!

To help with that, we reached out to one of our friends over at NASA: Senior Visualization Designer AJ Christensen. AJ works at NASA's Scientific Visualization Studio (SVS), where he develops visualization techniques and designs data-driven imagery for scientific analysis and public outreach. AJ was kind enough to take some time out of his busy day to answer a few questions to kick this Dev Diary off right:

Can you very basically describe an eclipse and why it is a special event? 

There are a lot of objects in space that pass between the Earth and the Sun at various times. We usually call it a “transit” when something that appears much smaller than the disk of the Sun passes in front of it, like an asteroid, or the International Space Station, or Venus.

iss-transit.en.jpg
Credit: NASA/Joel Kowsky

But through a crazy coincidence of physical size and distance from Earth, the apparent size of the disk of the Moon in the sky is almost exactly the same as the apparent size of the disk of the Sun in the sky, and so when the Moon transits in front of the Sun, we call it an eclipse because it blocks out a significant part of the Sun’s light.

The Moon actually orbits around Earth approximately every 27 days, so you might think we would see an eclipse every 27 days, but because of the tilt of that orbit, the Moon is usually not lined up with the Earth and Sun. For this reason, a lot of orbits result in no eclipse, or only a partial eclipse.

The total eclipse happening on April 8th is a rare event where the Earth, the Moon, and the Sun are all in a straight line, and the United States will be on the “day side” of the planet, meaning we get to experience the Sun being completely blocked out by the Moon for a few minutes in any given location along the path of totality. 


Credit: NASA Scientific Visualization Studio


What should people expect to see when viewing the eclipse?  

Anyone within the contiguous United States will be able to see the eclipse in some way on April 8th. If you are outside the path of totality, you will have several hours to witness a partial eclipse in the middle of the day. This means that the Sun will have a bit of a crescent shape, but it will not completely block the Sun. This is a fun time to put on approved solar eclipse viewing protective glasses and look at the shape of the sun, and to make pinhole projectors out of colanders or crisscrossed fingers to see lots of little crescent shadows on the ground.

If you are inside the path of totality, which is about 100 miles wide and travels from Texas to Maine, you will see that partial eclipse for several hours, but right in the middle will be 3-4 minutes of totality when the bright disk of the Sun called the “photosphere” is completely blocked. During totality, the temperature will drop, crickets may start chirping, and you will see sunset colors in the sky in 360-degrees all around you.


Credit: NASA Scientific Visualization Studio

If you are able, it is definitely worth trying to get inside the path of totality. One place of many that you can find more information to plan a trip is this visualization my colleagues made: 

image.png
Credit: NASA Scientific Visualization Studio


What happens to the Sun’s light during an eclipse? 

In the words of “Mr. Eclipse” Fred Espenak, a retired NASA astrophysicist, “there are no special eclipse rays.” The Sun continues to be what it always is – an extremely bright object in the sky that hurts to look at. This is why NASA insists that anyone viewing the eclipse should wear approved eclipse-viewing lenses, because even during a partial eclipse, you are still looking directly at the Sun. (Note, cameras can also be damaged if they look directly at the sun without a solar filter.)

However, in the last seconds before totality, there are some dazzling effects we can see. The first to occur is called the “Diamond Ring Effect”. This is where some of the sun’s light wraps around the horizon of the moon like a ring, and a sliver of light still at the edge creates a huge amount of glare like a diamond.

image of the diamond-ring effect during a solar eclipse
Credit: NASA/Carla Thomas

The next effect we call “Baily’s Beads” which are visible for only a moment – these are a line of bright spots of light that poke through the valleys on the edge of the Moon.

bright glowing "beads" at the edge of the Moon as the Moon nearly completely covers the Sun
Credit: NASA/Aubrey Gemignani

And finally, once the Sun is completely covered by the moon, we get to see magic of the Solar corona, long tendrils of illuminated plasma in the Sun’s atmosphere. The corona is always there in the sky, but it is usually completely covered up by glare from the disk of the Sun, which is about 1 million times brighter than the corona. For these 3 or 4 minutes of totality, we recommend taking off your eclipse glasses and soaking in the corona with your bare eyes.

corona_2017-solar-eclipse.en.jpg
Credit: Miloslav Druckmüller, Peter Aniol, Shadia Habbal/NASA Goddard, Joy Ng

Once totality ends, Baily’s Beads and the Diamond Ring will appear again and we recommend putting your eclipse glasses back on to enjoy the rest of the partial eclipse. 


How does that inform your work with the Visualizations team at NASA? 

My team is called the Scientific Visualization Studio, and we use both observed and computed data to make images and videos that explain science research. We have been working closely with scientists and communicators across NASA to create computer graphics imagery to help explain what the April 8th eclipse will look like on the Earth’s surface and in the sky, the surprising geometry of the Earth-Moon-Sun system, and more.

We even recently published a game aimed toward younger audiences on NASA’s SpacePlace website called “Snap It!” that gets into what transits are and how eclipses are a special kind of transit. You can find it at this link: https://go.nasa.gov/SnapIt.

And, of course, you can view thousands of visualizations about the eclipse and other science topics at our website: svs.gsfc.nasa.gov. 

----

So now that we have a good idea of what happens during eclipses in real life, let's jump into the game!

Directional Lighting

To try and simulate the lighting we see in our solar system we use a variety of systems, but for the eclipse we’ll be focusing on our direct lighting solution with the star of the solar system: Kerbol. While a star technically emits light in all directions, in our game we only really need to care about the star’s light that reaches our player. To handle this, we use a Directional Light which, by definition, is located infinitely far away and emits in one direction only. 

directionallight.png

This works great for lighting our worlds with an intense light from a single distant source like a star. This directional light is also responsible for the direction that all shadows are cast in game. 

To make this directional light behave more like an actual star, we attenuate its intensity based on distance and occlusion. Distance is the easier of the two. If the player flies their Kerbals way out towards Eeloo they’ll noticed their vessel gets much dimmer. Looking back at Kerbol they can see it shrinking in the skybox as well. To manage this, in the lighting code we attenuate the light’s intensity based on the Inverse Square Law which states that “the intensity of the radiation is inversely proportional to the square of the distance”. The formula looks a little something like this: 1 /² . Things like artist adjustable overrides and camera auto-exposure play into the lighting too, but in general throughout the solar system, the further you get from the star, the dimmer it gets.

For smaller objects like terrain, buildings, and parts, we use shadows to show light being occluded. But for something as huge as a celestial body we track how much they block our Kerbals from the star itself to attenuate the light intensity appropriately. As an example, we’ll use a solar eclipse with Kerbol and the Mun.

kerbolmun.png
Simulated eclipse

Intersection of Circles

When you think about it in a flat 2D space, this is just two circles intersecting each other. If that’s the case then we can solve for the area of overlap to determine how occluded Kerbol is. The diagrams and formulas below show more of the math being done behind the scenes:

Our lighting system holds a reference to the current SOI celestial body, that body’s star and any neighboring bodies. All of these bodies are projected into a normalized sphere around the player where the system checks if any bodies are going to intersect. We can quickly verify this by checking if the sum of the body’s radii are greater than or equal to the distance between them. Once we pass this check, the intersection code starts and we begin solving for the amount of overlap to determine the percentage a body is blocked.

circleswoah.png

First step is to solve for the distance each circle is from the center of the intersection. To do this we use the equation of a circle and populate it with the values we know.

C₁:  ² +  ² =  ₁²

C₂:  ( x - d  )² +  ² =  ₂²

Then, isolate ² in each equation and combine both equations like so:

²=  ₁² - d ₁²

²=  ₂² - ( d₁ -

₁² - ₁² =  r ₂² - ( ₁ -

Finally, we can solve for d ₁ and d ₂ :

₁ = ( r ₁² - r ₂² + d ²) / 2d

₂ = d -

After that we can begin solving for the angle of the sector formed when tracing the radii of our celestial body to the intersection points:

intersectionpoints.png

With our new θ₁ and θ₂ in radians, we can solve for the area of each body’s overlapping segment A₁ and A₂.  The following formula is derived by subtracting the area of the triangle from the area of the sector formed by this angle:

Area of a triangle =  ( 1 / 2 ) r²  sin⁡θ
Area of a sector =  ( 1 / 2 ) r² θ

Area of segment = ( ( 1 / 2 ) r² θ ) -  ( ( 1 / 2 ) r²  sin⁡θ ) = ( r² / 2 ) * ( θ - sin⁡θ )

A1 = ( ( r₁² ) / 2 ) * ( θ₁ - sin⁡θ₁ )
A2 = ( ( r₂² ) / 2 ) * ( θ₂ - sin⁡θ₂ )

Total Area = A1 + A2
 

CircleIntersection.gif

And there you have it, the area of overlap for the celestial body. This can then be used to determine the percentage of visibility the further body has by subtracting the occluded area from the total projected circle area and with that number we can scale the intensity of the light emitted by that source body. In our case for the eclipse that will dim the Kerbol’s intensity as the Mun passes over


Simulated eclipse over the KSC


Lens Flare Occlusion

The final piece of the puzzle here is the lens flare of the star changing to show that it has been occluded by the Mun. The same visible percentage value is passed through to the lens flare system where it attenuates the scale of the flare to match the reduction of directional lighting in the environment. Unfortunately, this doesn’t capture the details of a total solar eclipse though.


Simulated eclipse over the KSC from the ground

We have plans to improve the look of eclipses and celestial body occlusion beyond attenuation and add more noticeable “flair” to a total eclipse like Kerbol’s corona peeking out from behind the Mun!

We’ll be keeping a close eye on the next total solar eclipse as reference and inspiration! And, if you're nearby and able to, we hope that you join us on April 8th in safely viewing this awesome event right above our heads.

Thanks to AJ and everyone over at NASA for contributing to this Dev Diary - and thanks to you for reading!

Cioletti

Link to comment
Share on other sites

I hope when you add full occlusion during the eclipse that you'll also add to a future built-in alarm clock a means of tracking when these occur. I'd enjoy planning landings to see all of the eclipses. I don't have a good sense of how to go about that without knowing the time of these events or where they even can occur.

Link to comment
Share on other sites

Cool!

But I mean, meh in the grand scale of things that is Kerbal Space Program 2's development.

Gonna catalog this one as dev blog filler. Next one please.

Edited by MARL_Mk1
Link to comment
Share on other sites

What

A

Letdown

A genuine embarrassment if I'm to be honest... Can't we just get the version you were all playing before release, the one you said you "couldn't put down"?  At this point it seems like Intercept as a whole is almost scared of the fandom and does everything possible to avoid any interactions and take any critisism like you've stormed into their houses on xmas day and stole all their toys. It boggles the mind.

This, to me, is not how an EA should be... Where's the quick iteration, the engagement and updating of the community? What exactly about this release, apart from the state of the game, can be considered at true early access title? You've done everything  possible at this point to restrict information given, from posts like this, cutting K.E.R.B, bug tracker etc... It's apparent that you don't want to listen to the community because everytime there is outcry, you just restrict access to information even further. Even the discord is a wasteland, same old posts about kapybaras and 1000's of pictures of craft that look exactly the damned same... And a community manager 24/7 on do not disturb. Maybe it's time to get an adult at the helm to wrangle the nonsense into check because the way this release is being handled, in my opinion, is beyond shocking. I worked in QA compatabilty for one of the big 2 console companies for nearly 12 years, I can honestly say we NEVER recieved anythig close to approching the mess that this game finds itself in, there seems to be an incredible lack of talent in the building.

Even this post as an example... If your aim is to engage new players and "dumb" down some of the mechanics then why the heck are we being presented deep mathmatical equations as news? I mean, really... What does this possibly mean to somebody (including me) who is picking up KSP2 for the first time?

Edited by TickleMyMary
Link to comment
Share on other sites

Well, at least they seem to have the development of the KSP2 visual  experience moving along nicely. That aspect represents a clear improvement over stock KSP1 IMO, and I'm glad they're continuing to work on it.  But now can we have a dev blog about improving physics performance? Doubling the frame rate would really get me excited!

Link to comment
Share on other sites

1 hour ago, herbal space program said:

Well, at least they seem to have the development of the KSP2 visual  experience moving along nicely. That aspect represents a clear improvement over stock KSP1 IMO, and I'm glad they're continuing to work on it.  But now can we have a dev blog about improving physics performance? Doubling the frame rate would really get me excited!

Yeah, it turns into a slideshow when I build anything more complex than a beginner rocket. I know the devs don't care about us dinosaurs, but if this game is good, all the newbies now will soon become veterans and will be disappointed when they try to make something fun.

Link to comment
Share on other sites

49 minutes ago, Intercept Games said:

We have plans to improve the look of eclipses and celestial body occlusion beyond attenuation and add more noticeable “flair” to a total eclipse like Kerbol’s corona peeking out from behind the Mun!

Things like this give me an appreciation of the complexity other forms of software development entail. Once upon a time I wanted to be a game developer, but when Physics and Calc intervened, I thought better of it. I'm looking forward to how this takes shape, and also wouldn't mind some times/locations where we can look out for an eclipse on Kerbin.

Link to comment
Share on other sites

12 minutes ago, Scarecrow71 said:

So you can occlude light, but not radio waves?

shhh you might alert my brain to something that doesn't make sense

Link to comment
Share on other sites

Nice. Except,

1 hour ago, Intercept Games said:

Our lighting system holds a reference to the current SOI celestial body, that body’s star and any neighboring bodies.

and

and

 

1 hour ago, Intercept Games said:

The final piece of the puzzle here is the lens flare of the star changing to show that it has been occluded

and I think the worst offender, that renders the whole thread invalid, is

Can't have an eclipse if there's no sun to begin with.

Apologies for being harsh and nitpicky, but get your systems working before talking about them. Don't be a Colossal Order 2.

Link to comment
Share on other sites

17 minutes ago, Scarecrow71 said:

So you can occlude light, but not radio waves?

Different, tougher problem, since light can come from  only a few well-defined sources  outside of your immediate physics range, and radio waves can come from any craft you may have in the Kerbolar system. Also, calculating all that continually for your active craft will slow performance even more, so I'd much rather they wait on that until they get their physics engine out of first gear.

Link to comment
Share on other sites

11 minutes ago, herbal space program said:

Different, tougher problem, since light can come from  only a few well-defined sources  outside of your immediate physics range, and radio waves can come from any craft you may have in the Kerbolar system. Also, calculating all that continually for your active craft will slow performance even more, so I'd much rather they wait on that until they get their physics engine out of first gear.

crawler first gear.

Link to comment
Share on other sites

Interesting topic! Always great to hear how stuff work.

For the future, like The Aziz linked, it would be cool to see the eclipse being actually projected onto the surface of the body instead of dimming the whole body like it currently does.

I don’t know how this could be integrated to the system you presented.

Edited by Spicat
Link to comment
Share on other sites

This was a fine update if it was given without any preannouncement. This is a cool insight but, uh, not really what anyone is asking for more of when we’re asking for more communication. There was no reason this just couldn’t have been released; by pre announcing it (even with the disclaimer it wasn’t about colonies) you just set everyone up for disappointment.

So guess I’m checking out for a few months again, hopefully the colony update is big enough to hit my home feed on Reddit. I think I’m done checking in on the subreddit and the forums for a while as it is a complete waste of my time at this point.

Link to comment
Share on other sites

2 hours ago, herbal space program said:

Different, tougher problem, since light can come from  only a few well-defined sources  outside of your immediate physics range, and radio waves can come from any craft you may have in the Kerbolar system. Also, calculating all that continually for your active craft will slow performance even more, so I'd much rather they wait on that until they get their physics engine out of first gear.

Even if you assume you have only 1 craft in Kerbin's SOI, and the Mun is directly between the craft and Kerbin:  they can occlude light but not line of sight for radio waves?

Link to comment
Share on other sites

2 minutes ago, Scarecrow71 said:

Even if you assume you have only 1 craft in Kerbin's SOI, and the Mun is directly between the craft and Kerbin:  they can occlude light but not line of sight for radio waves?

I suppose if you limit it to line of sight for the active vessel craft to Kerbin alone, it becomes a much simpler problem, but I was assuming you were talking about an actual Comnet with relays. And I should add that without the latter, having your signal get unavoidably occluded by the Mun and/or Kerbin when the tracking station is on the other side of it would represent a truly annoying impediment to gameplay IMO.  So either the whole Comnet enchilada or no signal occlusion are the only good options, and the game is just not ready performance-wise to digest the whole enchilada yet.

Link to comment
Share on other sites

2 hours ago, Spicat said:

it would be cool to see the eclipse being actually projected onto the surface of the body instead of dimming the whole body like it currently does.

I don’t know how this could be integrated to the system you presented.

Wasn't it Scatterer that did that in ksp1? I wonder who responsible for the creation of it is now the part of the team, hmmm...

Link to comment
Share on other sites

1 hour ago, herbal space program said:

And I should add that without the latter, having your signal get unavoidably occluded by the Mun and/or Kerbin when the tracking station is on the other side of it would represent a truly annoying impediment to gameplay IMO.  

Didn't the original game have multiple CommNet ground stations placed around Kerbin to prevent this?
Correct me if I'm wrong, I'd have to open up the game to check, but I remember seeing 'relayed through Island Station' or something.

1 hour ago, herbal space program said:

So either the whole Comnet enchilada or no signal occlusion are the only good options, and the game is just not ready performance-wise to digest the whole enchilada yet.

Yeah, but this game has been in development 6+ years now. If CommNet hasn't been implemented properly yet, is it likely to ever be? Things like CommNet being missing seriously makes me wonder what they were doing for all that time.
If you are correct and that doing calculations for all Active Craft hampers things, I'm worried that they're being seriously handicapped by their decision to simulate all active vessels.

5 hours ago, Intercept Games said:

 

With our new θ₁ and θ₂ in radians, we can solve for the area of each body’s overlapping segment A₁ and A₂.  The following formula is derived by subtracting the area of the triangle from the area of the sector formed by this angle:

Area of a triangle =  ( 1 / 2 ) r²  sin⁡θ
Area of a sector =  ( 1 / 2 ) r² θ

Area of segment = ( ( 1 / 2 ) r² θ ) -  ( ( 1 / 2 ) r²  sin⁡θ ) = ( r² / 2 ) * ( θ - sin⁡θ )

A1 = ( ( r₁² ) / 2 ) * ( θ₁ - sin⁡θ₁ )
A2 = ( ( r₂² ) / 2 ) * ( θ₂ - sin⁡θ₂ )

Total Area = A1 + A2

Instead of calculating the area, couldn't this be done more efficiently by just using a cosine equation?
Get the vector from current position to the Mun or occluding body, get the vector from current position from to light source (Kerbol) or CommNet relay, and compare the two vectors with a cosine (past a threshold of close to 1.0 or -1.0, I forget which) to see if they're intersecting. The distance to each object is also known, which tells which body is occluding which, and also the radius of the planetary body will be known, which along with the distance allows the area or field of view to be calculated - a Solid Angle measured in steradians. This value along with the cosine value can be used to attenuate the light intensity (or block a signal). This calculation has the advantage of being more lightweight and therefore be run on multiple planetary bodies and vessels. I wouldn't be surprised if CommNet from the original game used some kind of similar calculation.

Link to comment
Share on other sites

9 minutes ago, Westinghouse said:

Yeah, but this game has been in development 6+ years now. If CommNet hasn't been implemented properly yet, is it likely to ever be? Things like CommNet being missing seriously makes me wonder what they were doing for all that time.

From my understanding CommNet is omitted in KSP2 as a decision to make the game more approachable.

I think a simple option to enable commNet or disable it would solve the approachable issue, but they say it’s not a current priority. 

it very well could be a performance thing buried under the veil of “easier for new players” but I don’t think we will ever know the answer to that unless they change their mind on the priority thing. 

Link to comment
Share on other sites

6 minutes ago, Westinghouse said:

Didn't the original game have multiple CommNet ground stations placed around Kerbin to prevent this?
Correct me if I'm wrong, I'd have to open up the game to check, but I remember seeing 'relayed through Island Station' or something.

Yes, it did, but then that's another point you have to continuously calculate line of sight for, so it moves the overall system toward just having the whole ComNet. My overall point was just that you either have to accommodate multiple signal sources or you have to ignore all that. There is no tenable middle ground really for basic gameplay reasons.

 

12 minutes ago, Westinghouse said:

If you are correct and that doing calculations for all Active Craft hampers things, I'm worried that they're being seriously handicapped by their decision to simulate all active vessels.

Not sure how you define "active vessel" here, but I have noticed that having more missions ongoing, even if they are more or less on rails outside of the current vessel's physics range, seems to degrade performance significantly. Whatever they're doing wrt to calculating those vessels, they need to pare it down substantially, or things like ComNet will never, ever work.

Link to comment
Share on other sites

16 minutes ago, Icegrx said:

From my understanding CommNet is omitted in KSP2 as a decision to make the game more approachable.

See, if that's true then it makes me question whether these people are the right people to be in charge of the KSP franchise.

Obviously I get they want to market it to a broad range. Having Kerbal Space Program become some sort of educational standard for STEM to be sold to schools and education institutions is probably some Private Division marketing executive's wet dream. But the fact of it is that launching spacecraft  is hard. Any player capable of launching a rocket into orbit around Kerbin and sending it to the Mun will easily be able to get their head round radio signals back home being blocked. I wasn't playing the original game before CommNet was introduced but the concept always seemed fantastic to me, forcing us to think ahead and build relay satellites. Passing out of site from the homeworld and out of contact with Mission Control always seemed magnificently ominous and eerie to me, making me imagine what a lone Apollo command module pilot would have felt.

Maybe the devs are being forced into these silly decisions by clueless PD executives and managers. But if instead this development team really are determined to make a dumbed down 'Kerbal for Kids', maybe they should switch to making mobile games for iPhone instead.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...