Skip to content

Fix z fighting of HiPS levels#4376

Merged
alex-w merged 1 commit intomasterfrom
hips-z-fighting-fix
Jun 19, 2025
Merged

Fix z fighting of HiPS levels#4376
alex-w merged 1 commit intomasterfrom
hips-z-fighting-fix

Conversation

@10110111
Copy link
Contributor

Description

When a tile is drawn in a planetary survey, and then its child of a higher level is drawn over, we can often observe the lower-level tile shining through the higher-level one, and the shape that shines through depends on the position of the planet, which resembles z fighting.

To combat this, we now draw only the deepest HiPS level requested for the current zoom level, substituting lower-resolution textures for the tiles whose native-resolution textures haven't been loaded yet.

This makes it much harder to support fading between levels, so fading support is removed.

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

How Has This Been Tested?

Test Configuration:

  • Operating system: Ubuntu 20.04
  • Graphics Card: Intel UHD Graphics 620

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

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.

@10110111
Copy link
Contributor Author

Here's a screencast of how the issue looks (a bit overcompressed, but enough to get an idea): https://youtu.be/gKLiFmzM9k8.

This might be hard to reproduce with low-order HiPS, I reproduce it with an order-6 survey of the Moon that I'm preparing.

@alex-w
Copy link
Member

alex-w commented Jun 17, 2025

Hmm... I see an empty place when HiPS for Moon is enabled.

P.S. Probably this is internet connection issue

@gzotti
Copy link
Member

gzotti commented Jun 17, 2025

I also see no image, but the logfile screams:

[    40.645][DBG ] Load allsky QUrl("https://data.stellarium.org/surveys/moon-normal/Norder0/Allsky.webp?v=2458533")
[    40.666][DBG ] Load allsky QUrl("https://data.stellarium.org/surveys/moon/Norder0/Allsky.webp?v=2458519")
[    40.666][DBG ] got allsky
[    40.686][DBG ] got allsky
[    40.686][DBG ] Load allsky QUrl("https://data.stellarium.org/surveys/moon-normal/Norder0/Allsky.webp?v=2458533")
[    40.707][DBG ] Load allsky QUrl("https://data.stellarium.org/surveys/moon/Norder0/Allsky.webp?v=2458519")
[    40.707][DBG ] got allsky
[    40.727][DBG ] got allsky
[    40.727][DBG ] Load allsky QUrl("https://data.stellarium.org/surveys/moon-normal/Norder0/Allsky.webp?v=2458533")
[    40.747][DBG ] Load allsky QUrl("https://data.stellarium.org/surveys/moon/Norder0/Allsky.webp?v=2458519")
[    40.748][DBG ] got allsky
[    40.768][DBG ] got allsky

@10110111
Copy link
Contributor Author

Hmm, I didn't test on a survey with Allsky used.

@10110111
Copy link
Contributor Author

Hmm... I see an empty place when HiPS for Moon is enabled.

Well, I get the normal Moon with the default Stellarium's survey.

I also see no image, but the logfile screams

Hmm, I wonder why... What I get is this and nothing more:

[    34.293][DBG ] Load allsky QUrl("https://data.stellarium.org/surveys/moon/Norder0/Allsky.webp?v=2458519")
[    34.323][DBG ] Load allsky QUrl("https://data.stellarium.org/surveys/moon-normal/Norder0/Allsky.webp?v=2458533")
[    34.404][DBG ] got allsky
[    34.419][DBG ] got allsky
[    34.422][WARN] Normal map survey's hips_order=2 is less than that of the color survey: 3. Will reduce the total order accordingly.

Do you maybe have some other surveys enabled?

@10110111
Copy link
Contributor Author

I also see no image, but the logfile screams

Do you also get this in master?

@gzotti
Copy link
Member

gzotti commented Jun 17, 2025

I also see no image, but the logfile screams

Do you also get this in master?

Uh, indeed! As soon as Survey is selected, HiPS drawing activated and Moon is in view. There are no other (deepsky) HiPS active.

@10110111
Copy link
Contributor Author

Uh, indeed! As soon as Survey is selected, HiPS drawing activated and Moon is in view. There are no other (deepsky) HiPS active.

So HiPS is broken for you in master? The symptoms you show may indicate that Allsky is downloaded, but can't be read as an image, i.e. QImage::fromData(data) returns a null image. What if you try downloading the URL logged via a browser — does this give a viewable image?

When a tile is drawn in a planetary survey, and then its child of a
higher level is drawn over, we can often observe the lower-level tile
shining through the higher-level one, and the shape that shines through
depends on the position of the planet, which resembles z fighting.

To combat this, we now draw only the deepest HiPS level requested for
the current zoom level, substituting lower-resolution textures for the
tiles whose native-resolution textures haven't been loaded yet.

This makes it much harder to support fading between levels, so fading
support is removed.
@10110111 10110111 force-pushed the hips-z-fighting-fix branch from b9d403b to fafdf5a Compare June 18, 2025 04:40
@10110111
Copy link
Contributor Author

Please try again, the log should calm down and report an error once (per file) in case of a failure to decode the image.

@gzotti
Copy link
Member

gzotti commented Jun 18, 2025

OK, that seems to work. But the next strange obervation: select a crater near the rim, then zoom in. (FoV in range of 1-2 arcmins - just where the HiPS looks still inviting...). Suddenly the Moon vanishes. This does not happen in 25.1, and not with the default Moon.

@10110111
Copy link
Contributor Author

I reproduce vanishing sectors that have no corner inside the screen in both this branch and the older versions. This is a years old problem with Stellarium's HiPS. I wonder why you see a different behavior between versions. Just to make sure, what crater did you select? And did you set the time to the same values when testing each version?

@gzotti
Copy link
Member

gzotti commented Jun 18, 2025

Riccioli, 2 25-7-12 12:56 CEDT
This PR: Vanishes when FoV<43".
25.1: Ah -- Poof! Same issue, indeed. I just scrolled around between east and west rims before, so apparently it works sometimes.

@10110111
Copy link
Contributor Author

So, is this PR OK to go in then?

Copy link
Member

@alex-w alex-w left a comment

Choose a reason for hiding this comment

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

Thanks!

@gzotti
Copy link
Member

gzotti commented Jun 19, 2025

Yes, should be OK from my side.

@alex-w alex-w added this to the 25.2 milestone Jun 19, 2025
@alex-w alex-w merged commit 1c80523 into master Jun 19, 2025
31 checks passed
@alex-w alex-w deleted the hips-z-fighting-fix branch June 19, 2025 08:12
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.

3 participants