Reflect sun and moon using actual textures or generated moon phase.#17066
Reflect sun and moon using actual textures or generated moon phase.#17066sofar wants to merge 1 commit intoluanti-org:masterfrom
Conversation
10ca98d to
3cedbbc
Compare
|
That's really nice, I hope we can get this merged. |
This patch replaces the "placeholder" sun reflection in water. For this to work, you must have waving water enabled. Previously this only worked when shadows were enabled, but, with this change, it no longer depends on shadows being enabled or not. The sun/moon reflection uses the actual texture that the game uses. I've used Mineclonia to test it and tweak sizes (they're a tiny tiny bit larger in the reflection but I think it's reasonable, because smaller looks weird really quick) and test that the actual reflections are correct (this part took quite a while). Mineclonia relies on the generated sun texture (a bunch of squares stacked on top of each other) so this has been tested with both variants - texture and generated sun/moon. A bunch of new shader stuff is needed to make this work, this patch pulls all of those changes in. The noise functions previously only in the shadow ifdefs are now also needed outside of it. The specular dot that was previously used is now gone. The only times when it now could be used is when the sun or moon is actively hidden or there is a loading issue, or at the wicked time boundary. We avoid any weird visual in all those conditions by just not having it anymore. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3cedbbc to
00833fa
Compare
| float fresnel_factor = computeFresnelFactor(fNormal, viewVec); | ||
|
|
||
| // Derive nighttime from dayLight brightness | ||
| float dayBrightness = dot(dayLight, vec3(0.2125, 0.7154, 0.0721)); |
There was a problem hiding this comment.
Thanks for extracting most of it into functions.
I am still a bit unclear why this (non-shadow) branch is any different than the shadow branch.
For example if we check for caves here, shouldn't we in the other branch as well? It seems to me that the code should be identical.
There was a problem hiding this comment.
I'll do another pass over this. I noticed it too and you're right, I don't think it needs to be that different to begin with. It probably stems from me starting with a group of things that were unrelated before I made the change independent of shadows being enabled.
There was a problem hiding this comment.
Thanks for looking.
(And sorry for the tone of the first comment - about the code duplication, wasn't meant to sound snarky, but it did.)




This patch replaces the "placeholder" sun reflection in water. For this to work, you must have waving water enabled. Previously this only worked when shadows were enabled, but, with this change, it no longer depends on shadows being enabled or not.
The sun/moon reflection uses the actual texture that the game uses. I've used Mineclonia to test it and tweak sizes (they're a tiny tiny bit larger in the reflection but I think it's reasonable, because smaller looks weird really quick) and test that the actual reflections are correct (this part took quite a while).
Mineclonia relies on the generated sun texture (a bunch of squares stacked on top of each other) so this has been tested with both variants - texture and generated sun/moon.
A bunch of new shader stuff is needed to make this work, this patch pulls all of those changes in. The noise functions previously only in the shadow ifdefs are now also needed outside of it.