Rayleigh v2 - #6285
Conversation
|
What's the best way to test this? What am I looking for? |
Try to look at Venus or Titan, it should not have any sharp edges
A little bit, not that catastrophic drop from 50 FPS to 3 FPS using uniform arrays and doing mix() between its elements With my GPU, it was like 55 -> 51 FPS drop |
|
If this is slower, this would be an optional setting.
In the original PR @Mc-Pain mentions:
|
|
It's still an optional setting along with legacy atmosphere |
|
Will make some time to benchmark this soon, and I'd like to investigate the possibility of using a similar precomputation method for other objects in the scene. |
2405914 to
81f446e
Compare
|
It crashes on my end. The new game starts, and crashes after a second. |
2b1b9f5 to
c11b671
Compare
|
@sturnclaw @impaktor there's a problem I had implemented a new atmosphere model (with tropopause) to actually resolve #6052 Mars and Earth looks fine with this: To resolve this, I've increased samples count to 64 but had a significant performance drop: |
|
Maybe you need different models per-atomsphere type? Or to base the number of samples on some atmospheric property? Why does it work well for one planet but not another? Height of atmosphere? Density? etc and base it on that instead of fixed sampling number. Then if you want to have a sampling "quality" could be set based on a multiplier of that number, eg (0.5, 0.75, 1.0, 1.25, 1.5) |
Checking if I can return 0.001 atm as atmosphere threshold (I decreased it to 1e-15) |
I'd suggest {1.0, 1.5, 2.0, 3.0, 4.0} |
sturnclaw
left a comment
There was a problem hiding this comment.
I'm generally happy with the look of this PR. It makes a huge difference to have the terrain match the sky, especially at highly-grazing angles, and the water on Mars appears incredibly beautiful.
However.
There are some bugs with the implementation that render it unsuitable for merge at the moment. The biggest one is the fact that the terrain appears to only be doing a ray-test against the geosphere radius and not taking the current sample depth into account, as at incident angles the terrain becomes shaded as though it were the sky.
This manifests as a visible "line" near the horizon where the terrain receives a completely different color, and at grazing angles even makes the terrain appear invisible.
(This terrain is not bugged / invisible, it's just being shaded as though it were sky.)
Finally, and this is an incredibly minor thing, when flying the horizon line appears to "warp" / "undulate", faintly visible in this screenshot here (note the jagged edge between terrain and sky rather than a smooth line). I'm not sure exactly what's causing this, but it's quite attention-grabbing.
On the whole, performance is quite good. At 1440p, a near-fullscreen Terrain+Sky pass takes approximately 2ms of GPU time on my 2070 Super; this is way better than I expected and much faster than previous iterations of the feature. In the future, I can look into an early-Z pass to reduce overdraw, now that terrain lighting is an appreciable amount of time.
I don't think the above issues will all be fixed in time for the upcoming bugfix release, but once the points raised here and in the review comments are addressed I consider this PR almost ready to merge; I haven't gone over the shader code with a fine-tooth-comb yet but I'm liking what I see.
|
There's more hard work to be done:
There should be a sequence point (in C++ means: https://en.cppreference.com/cpp/language/eval_order) between materials and rendering: not a single object is to be rendered until all materials are prepared and fully evaluated. UPD |
sturnclaw
left a comment
There was a problem hiding this comment.
Following our discussion on IRC, I've dug into and fixed a few mathematical anomalies with this PR in the name of getting it out the door.
I'm leaving a series of before/after comparisons to illustrate the graphical effects of said anomalies - they primarily stem from the fact that the clamped cosine lobe lighting term was being applied a few times too many, and that the effects of terrain height were not being fully propagated into all of the lighting calculations.
While there are a few things that could be further improved (the appearance of in-scattering at the planet/atmosphere edge when viewed from space for one), this is Good Enough to release on Monday.
I'd like to extend my commendation to @Mc-Pain for doing all of the hard work on this PR and keeping with it through its extended development cycle. You can manually squash together your development commits or I can do a squash merge at your discretion.
Before my changes:
After:
Before:
After:
Before:
After:
As you can see, there's definitely some visual fidelity lost in this last example (Moscow on Earth) compared to an "ideal" photorealistic Earth. However, compared to the legacy version, I think there's no comparison...
As an addendum, @sam52796 will be happy to note that he got his wish of a brighter blue Earth sky 😆.












Experimental approach to improve rayleigh shaders:
Might be slow, but still accurate pre-calculated density LUT's and synced models within physics and graphics engines.