I am in the middle of writing an engine based on Monogame which eventually will be open source.
It is targeted at flight simulators rather than a normal game engine, which obviously comes with it’s own massive set of issues.
At the moment I am adding stars and planets to the engine.
I have a table of some 9000 bright sky objects which I position in the sky based on date, time, latitude and longitude.
They are rendered very efficiently by spritebatch, thanks to one of Shawn Hargreaves little blog posts.
My problem now is turning them on and off realistically.
When the camera is at ground level it’s pretty easy,it’s just a function of the angle between horizontal and the sun position.
However when you are at altitude, it becomes much more complex.
Once you get high enough, the stars are visible regardless of time of day.
Has anyone come across any documents or code related to this?
I really don’t want to add a frigg to the code that kinda almost works, I would much rather have some kind of real world solution.
My gut feeling is that I need to start with a ray that goes from the camera position to the sun position.
Then a ray that goes from the camera to the nearest point on the Earth to the sun.
The angle between them should give me one factor in the equation, the other has to be some factor calculated based on the thickness of the atmosphere at the camera altitude.
But I am not sure.
This is what I currently have.
Any ideas gratefully received.