Stellarium / stellarium

Stellarium is a free GPL software which renders realistic skies in real time with OpenGL. It is available for Linux/Unix, Windows and macOS. With Stellarium, you really see what you can see with your eyes, binoculars or a small telescope.
https://stellarium.org
GNU General Public License v2.0
7.76k stars 821 forks source link

White sky when zooming out (ShowMySky) #3351

Closed Atque closed 1 year ago

Atque commented 1 year ago

Using the latest master, the sky turns completely white using SMS and showing certain points of the sky. It appears the anti-solar point is broken. Using an older calculation of the sky textures, shows no problem.

Introduced by efa6b05?

Windows 10 64-bit Qt 6.4.2 AMD Radeon RX 5700 XT

10110111 commented 1 year ago

I don't reproduce this. Please give more detailed instructions, the log, and possibly screenshots or a screencast.

Atque commented 1 year ago

First it looks normal: stellarium-243

But looking too far down, yields a white, broken atmosphere: stellarium-244

Looking even further towards the nadir, Stellarium gets incredibly slow (0.2 FPS). Disabling atmosphere gives normal FPS rates.

Log: log.txt

I fear this might be yet another AMD trouble?

Edit: Hmmm. ShowMySky works fine (no mie scattering below horizon), using the CMS master. Edit II: Oh, no wait. There's a hole in the sky near nadir there as well :/

gzotti commented 1 year ago

I had though this was solved by cmake/CPM magic: SMS not found on Windows. I had my SMS library from January. Is there a new version? Please add instructions to BUILDING.md.

10110111 commented 1 year ago

SMS not found on Windows

This is irrelevant to this issue.

10110111 commented 1 year ago

I fear this might be yet another AMD trouble?

May well be.

Edit: Hmmm. ShowMySky works fine (no mie scattering below horizon), using the CMS master. Edit II: Oh, no wait. There's a hole in the sky near nadir there as well :/

Could you recompute the model via calcmysky adding --radiance argument to the command line, and show me the radiance spectrum of the broken nadir area?

Atque commented 1 year ago

Could you recompute the model via calcmysky adding --radiance argument to the command line, and show me the radiance spectrum of the broken nadir area?

This is the result: bild

10110111 commented 1 year ago

OK, I suppose it may be a problem with the GPU implementation of tanh function. Normally it should yield 1.0 for large arguments, but maybe your GPU spits something inedible. What if you use the following patch for CalcMySky?

diff --git a/shaders/render.frag b/shaders/render.frag
index 7c264b6..5287267 100644
--- a/shaders/render.frag
+++ b/shaders/render.frag
@@ -125,7 +125,7 @@ void main()
         // forward scattering peak. The second factor, with tanh, makes the
         // transition near sunset from a bit above horizon to a bit below smoother.
         pseudoMirrorDepth = sqr(max(0, dot(viewDir, sunDirection))) *
-                               tanh(150 * (newViewElev - horizElev) / (PI/2 - horizElev));
+                               tanh(min(10, 150 * (newViewElev - horizElev) / (PI/2 - horizElev)));
     }

     CONST float cosSunZenithAngle =dot(zenith,sunDirection);
10110111 commented 1 year ago

(Note that to fully apply this patch, you need to regenerate the model.)

Atque commented 1 year ago

OK, I suppose it may be a problem with the GPU implementation of tanh function. Normally it should yield 1.0 for large arguments, but maybe your GPU spits something inedible. What if you use the following patch for CalcMySky?

diff --git a/shaders/render.frag b/shaders/render.frag
index 7c264b6..5287267 100644
--- a/shaders/render.frag
+++ b/shaders/render.frag
@@ -125,7 +125,7 @@ void main()
         // forward scattering peak. The second factor, with tanh, makes the
         // transition near sunset from a bit above horizon to a bit below smoother.
         pseudoMirrorDepth = sqr(max(0, dot(viewDir, sunDirection))) *
-                               tanh(150 * (newViewElev - horizElev) / (PI/2 - horizElev));
+                               tanh(min(10, 150 * (newViewElev - horizElev) / (PI/2 - horizElev)));
     }

     CONST float cosSunZenithAngle =dot(zenith,sunDirection);

I have never managed to build CMS from source (only used the stable releases or builds from Appveyor). Could you provide a binary?

10110111 commented 1 year ago

You can take an artifact from an AppVeyor build. Just apply the patch to the render.frag file you can find inside.

Atque commented 1 year ago

Oh yeah, of course, those can be altered after the build.

The fix you provided seems to have solved this. No more hole in the nadir area, and the area below the horizon looks better when Mie scattering is not mirrored: stellarium-245

This is how it is supposed to look, right? If so, the issue can be closed.

10110111 commented 1 year ago

I'll push this fix, and the commit will close this issue.

github-actions[bot] commented 1 year ago

Hello @Atque!

Please check the fresh version (development snapshot) of Stellarium: https://github.com/Stellarium/stellarium-data/releases/tag/weekly-snapshot

github-actions[bot] commented 1 year ago

Hello @Atque!

Please check the latest stable version of Stellarium: https://github.com/Stellarium/stellarium/releases/latest