Skip to content

Better balance for stellar visibility in twilight and moonlight#4839

Open
Atque wants to merge 2 commits intoStellarium:masterfrom
Atque:skybright-experiments
Open

Better balance for stellar visibility in twilight and moonlight#4839
Atque wants to merge 2 commits intoStellarium:masterfrom
Atque:skybright-experiments

Conversation

@Atque
Copy link
Copy Markdown
Contributor

@Atque Atque commented Mar 25, 2026

Description

A long lasting problem with Stellarium is unrealistic appearance of stars during early twilight and moonlight. This fix brings better balancing and (to my layman eyes) more realistic stellar appearance, but it's purely empirical and does not bring any better physical model. All stars become fully visible at about -18 degrees solar altitude, instead of the current -8, which I find "reasonably good". See the screenshots below and notice the difference.

Although not many lines have changed (most of the new lines are just comments), do test it thoroughly. I might have missed some special-case where we might need calibration. I've tested for different moon phases, solar eclipse and of course different twilight steps, and it seems fine.

It should work equally well for ShowMySky and Preetham.

Opinions are most welcome, but bear in mind that this is chiefly a visual fix, to better estimate stellar visibility during early twilight stages and full moon.

Fixes #4291

Screenshots:

Both screenshots below are at the end of nautical twilight (Sun at -12 degrees).

This branch (greatly reduced stellar visibility):
stellarium-024

master branch (full stellar visibility!):
stellarium-025

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • This change requires a documentation update
  • Housekeeping

Test Configuration:
Ubuntu 24.04.4 LTS
Qt 6.4.2

Checklist:

  • My code follows the code style of this project.
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (header file)
  • I have updated the respective chapter in the Stellarium User Guide
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@github-actions
Copy link
Copy Markdown

Great PR! Please pay attention to the following items before merging:

Files matching src/**/*.cpp:

  • Are possibly unused includes removed?

This is an automatically generated QA checklist based on modified files.

@gzotti gzotti added this to the 26.2 milestone Mar 26, 2026
const float bortleIntensity = 1.f+(15.5f-2*nelm)*atmFadeIntensity; // smoothed Bortle index moderated by atmosphere fader.

const float lum = drawer->surfaceBrightnessToLuminance(12.f+0.15f*bortleIntensity); // was 11.5; Source? How to calibrate the new texture?
const float lum = drawer->surfaceBrightnessToLuminance(14.f+0.15f*bortleIntensity); // was 11.5; Source? How to calibrate the new texture?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment first appeared in 282e148. Did you check the look in the moonlight?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only briefly after that commit. Does it look bad to you?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tried this change at all, just looked through the code. I don't have much clear and unpolluted skies here to observe stars in twilight, so I can't check how well this change corresponds to reality.

Copy link
Copy Markdown
Contributor Author

@Atque Atque Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not really meant to be fully physically correct, only a better solution than what Stellarium currently provides.

@gzotti
Copy link
Copy Markdown
Member

gzotti commented Mar 26, 2026

Thanks for also taking this up. The so far latest act of balancing was needed urgently and maybe rushed when SMS came just for V1.0 in 2022 and showed different sky brightness values (and IIRC therefore different star appearance) compared to the Preetham/Schaefer sky. This is still an unsolved mystery. Unfortunately my last week under pristine skies was in 2017. It is also always difficult to model "remembered view" against "photographic record" when the latter can just show so much more than you may have seen with imperfect eyes. Also, while there is a bright belt of twilight over the solar azimuth, how many stars do you see 60° above when the eye is not blinded? For a really long-lasting fix we should (and this is why I have not taken this up yet) step a bit further back and re-investigate actual computed sky brightness values according to our "classical" Schaefer implementation, SMS, and sky/twilight brightness values from the literature. (This has also be requested as extension of the mouse cursor plugin, see #1404.) Then don't forget the effects of different settings for light pollution and extinction. Most users still think in "Bortle Scale", which we have officially declared deprecated but still support in the GUI for convenience, as it is a nice and simple site descriptor. It would be great to have an artificial "Sky Quality Meter" estimate computed from our sky models that could give an equivalent reading to the physical device.

@Atque
Copy link
Copy Markdown
Contributor Author

Atque commented Mar 26, 2026

Yes indeed, a better solution would of course be per-pixel luminance values, and draw stars and the Milky Way/Zodiacal light according to that. But I was bothered enough, as a resident of 58° N, by midsummer night skies showing just as many stars as December nights, that I thought a "quick fix" could at least be a start. Looking directly into the twilight arc still draws fewer stars than looking at zenith.

@Atque Atque marked this pull request as ready for review March 27, 2026 09:32
@github-actions github-actions bot requested a review from 10110111 March 27, 2026 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Objects visible too early in twilight

3 participants