-
-
Notifications
You must be signed in to change notification settings - Fork 838
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
Fix normals map of the Moon, increase its resolution and implement shadows #2781
Conversation
Great PR! Please pay attention to the following items before merging: Files matching
This is an automatically generated QA checklist based on modified files |
0d1c262
to
26c570c
Compare
Much better! @Atque, do you have comparisons? Now we'd need real comparison pictures! I try to find something with a date. |
Indeed much better!
Sadly, no new photos. Here are two that I know the date and location of. The first was taken at 2020-02-12 23:11 UTC+1, and the second at 2020-03-05 17:54 UTC+1, both from 58,3 N, 11,4 E. I took them using a 300 mm lens of cheap quality. |
Seems like it matches reality pretty good. I can recommend this website for validation too: Keep in mind to use geocentric point of view. |
OK, I think this is good. What we need now may be some more finetuning (again) for the Lunar brightness. This is not easy and not part of this PR. |
26c570c
to
532050f
Compare
But do note that its images are simulated, not the ground truth. |
True, but I would trust NASA on this. I haven't compared the details though. |
…adows With the old normal map, near the poles we had dark-shaded parts of craters that should actually be brighter — as if the Sun is not where it is, and this behavior inconsistently depended on longitude... The new texture added in this commit fixes behavior of shadows. Now the resolution of the normal map is the half that of the reflectance texture, 2048×1024. Further increase leads to excessive noise due to lack of proper mip mapping (and its non-triviality for normal maps), so this looks like a good compromise between the shapes of the craters and background noise. Additionally, a new kind of texture is added: horizon map. This texture contains elevation of the horizon in four directions: North, East, South, West. These elevations take terrain (mountains, craters etc.) surrounding each point of the map into account. These data are used in the fragment shader to determine whether the Sun is visible or is hidden behind the terrain. The data for the normals and horizon maps were generated using the elevation data in the [CGI Moon Kit](https://svs.gsfc.nasa.gov/cgi-bin/details.cgi?aid=4720). The generation was done using [map-bumper](https://github.com/10110111/map-bumper) with the following commands: heightmap2normalmap 1727.4 0.5e-3 ~/Downloads/ldem_16_uint.tif moon_normals.png 1024 256 heightmap2horizonmap 1727.4 0.5e-3 ~/Downloads/ldem_16_uint.tif moon_horizon.png 1024 Moon radius is taken here as 1727.4 instead of 1737.4 to take into account that the uint16 version has a global shift of values by 10 km. Normal map was generated with 256-fold supersampling.
532050f
to
70b2055
Compare
Just to be sure: The shader has nothing critical for weak systems, right? I see another sampler2D, but I am not aware of limitations. |
The shader doesn't. Or shouldn't :) But note that we have two textures now, with total size 9.3× old single texture. In other words, if the original texture took 1.5 MiB of VRAM, these two will take together 14 MiB. |
Uh, right. While this should still not pose a problem for PCs, this may be the end of Raspi3 support. Or we can finally provide a guideline to downsample all textures. May be in another PR, I will likely have no dev time for about two weeks now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks very good now, thank you!
Hello @10110111! Please check the fresh version (development snapshot) of Stellarium: |
Hello @10110111! Please check the latest stable version of Stellarium: |
This is an improvement on #2780, which was rejected basically due to the lack of shadows, which the bump mapping technique can't provide.
In this commit, in addition to fixing the normals map, a new kind of texture is added: horizon map. This texture contains elevation of the horizon in four directions: North, East, South, West. These elevations take terrain (mountains, craters etc.) surrounding each point of the map into account.
These data are used in the fragment shader to determine whether the Sun is visible or is hidden behind the terrain.
Even if we later decide that we want a geometric model of the Moon to make non-circularity of its rim visible during solar eclipses, this horizon map will still be useful, because it'll save us from the shadow mapping step, which itself has lots of pitfalls fixing which would likely reduce performance.
The data for the normals and horizon maps were generated using the elevation data in the CGI Moon Kit.
The generation was done using map-bumper with the following commands:
Moon radius is taken here as 1727.4 instead of 1737.4 to take into account that the uint16 version has a global shift of values by 10 km. Normal map was generated with 256-fold supersampling.
Screenshots
View from the Earth
Old:
New:
For comparison see the previous attempt that lacked shadows (the screenshot here).
A real-life photo at the same location, date and time is below. Although it's blurry, you can see some craters being shaded both in the new screenshot above and in this photo.
View from "Earth Observer" (to look at a pole)
Old:
New:
For comparison see the previous attempt that lacked shadows (the screenshot here).