Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fancy stars #396

Open
wants to merge 61 commits into
base: main
Choose a base branch
from
Open

Fancy stars #396

wants to merge 61 commits into from

Conversation

Schneegans
Copy link
Member

@Schneegans Schneegans commented Jan 5, 2025

Summary

This PR does three main things:

  1. Substantially improve the performance of the glare filter.
  2. Add two new star rendering methods: SR-Points and Glare Disc.
  3. Add initial support for rendering a subset of the Gaia DR3 catalog.

See below for more details.

Other Changes

  • The star color is now computed according to this paper. This has a different white point than the previous implementation, so the colors of the stars will look different.
  • The VBO for the stars does not contain their color anymore. Instead, the effective blackbody temperature is stored which reduces the data required for each star by two floats.
  • The default glare intensity and quality have been slightly increased.
  • The SR-Points rendering method is now the default for the star rendering.
  • Many shaders are now stored in glsl files instead of being hardcoded in the source code.

1. Glare Performance Improvements

The glare computation is now much faster.
There are a couple of reasons for this:

  • Lots of texture lookups have been removed by using hardware linear interpolation instead of manually interpolating between the texture samples when computing the mipmaps.
  • The glare is now computed using half floats instead of floats. This became possible by scaling the luminance by the frame's maximum luminance prior to the glare computation. This ensures that the glare values always stay within the range of half floats. This change is optional and can be toggled via the UI at runtime.
  • The expensive bicubic interpolation for the glare was usually done for each screen space pixel even if the glare is only computed for half the screen's resolution. We added a pass which combines the glare mipmap levels using the lower resolution and use then linear cheap linear interpolation to get the final glare value in the tone mapping pass.

2. New Star Rendering Methods

Glare Disc

This method renders the stars as camera facing billboards. The center of the billboard contains a star which looks like the Smooth Disc method. However, the billboard of bright stars is made slightly larger, and a glare effect is added to the star. This makes them look almost like the Smooth Disc method when the glare is enabled, but without requiring the glare computation. This makes them look quite cool in non-HDR mode where the glare is not computed.

SR-Points

This is a very advanced alternative star rendering method.
"SR" stands for "software rasterizer" which is a technique to render the stars using a compute shader instead of the traditional rasterization pipeline.
This makes it very efficient to discard stars which are either too dim to be seen or out of the frustum.
This way, we can draw significantly more stars in one draw call than before.

Besides, this mode can render the stars extremely small, but not too small.
Our smallest stars we had before were 1 pixel in size but suffered from aliasing when moving slowly across the screen.
Our new software rasterizer distributes the luminance of a star over an area of 2x2 pixels based on the subpixel position of the star. This makes the stars look much better when moving slowly across the screen than with the previous GL_POINTS method.

3. Gaia DR3

To test this new rendering method, we created a subset of the Gaia DR3 catalogue which contains several tens of millions of the brightest stars.
The PR contains code to load these subsets, however we are still thinking about how to provide the data to the user, as these catalogues are quite large, and we don't want to ship them with the application.

Schneegans and others added 30 commits December 12, 2024 12:57
Evaluate Bi-Cubic Glare-Interpolation in Compute-Preprocess for
Copy link

github-actions bot commented Jan 5, 2025

Pull Request Test Coverage Report for Build 12690840035

Details

  • 0 of 283 (0.0%) changed or added relevant lines in 9 files are covered.
  • 21 unchanged lines in 4 files lost coverage.
  • Overall coverage decreased (-0.009%) to 1.167%

Changes Missing Coverage Covered Lines Changed/Added Lines %
plugins/csp-stars/src/Stars.hpp 0 2 0.0%
src/cs-core/GraphicsEngine.cpp 0 3 0.0%
src/cs-core/Settings.cpp 0 4 0.0%
src/cosmoscout/Application.cpp 0 5 0.0%
plugins/csp-stars/src/Plugin.cpp 0 15 0.0%
src/cs-graphics/HDRBuffer.cpp 0 15 0.0%
src/cs-graphics/ToneMappingNode.cpp 0 18 0.0%
src/cs-graphics/GlareMipMap.cpp 0 105 0.0%
plugins/csp-stars/src/Stars.cpp 0 116 0.0%
Files with Coverage Reduction New Missed Lines %
src/cs-graphics/HDRBuffer.cpp 1 0.0%
src/cs-graphics/GlareMipMap.cpp 6 0.0%
src/cs-graphics/ToneMappingNode.cpp 7 0.0%
plugins/csp-stars/src/Stars.cpp 7 0.0%
Totals Coverage Status
Change from base Build 12629138651: -0.009%
Covered Lines: 193
Relevant Lines: 16545

💛 - Coveralls

@Schneegans Schneegans marked this pull request as ready for review January 6, 2025 07:19
@Schneegans Schneegans requested a review from JonasGilg January 6, 2025 07:19
@JonasGilg
Copy link
Member

It looks really awesome! While running it I couldn't find any bugs. I just noticed, that the loading time on first startup is REALLY slow. The CPU seems to be the bottleneck. Is it possible to improve the first startup time with some multithreading?

I will review the code next.

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