-
-
Notifications
You must be signed in to change notification settings - Fork 22k
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
Use lower shadow normal bias for distant directional shadow splits #60178
Use lower shadow normal bias for distant directional shadow splits #60178
Conversation
This causes Shadow Acne, especially the lower the value of Split 1 is (changing other splits also changes things, but not as much as Split 1 seems to). This also hinders current mitigation of issue that prompted godotengine/godot-proposals#4387 making it worse Here's a Test Scene, open in current master (with the blur PR merged) and this PR |
Mitigations for the test example were found, shrinking objects slightly or using godotengine/godot-proposals#4517 techniques (reversing face culling and shrinking slightly) helps, and generally as the Acne becomes visible only on faces viewed at grazing angles (by the light) it generally isn't actually that much of a problem. Still The new behavior should be documented with mitigations, for those that do run into these edge cases if this is merged, until the issue gets resolved, if it ever does. |
Perhaps this should be exposed as a tweakable then? I've found that setting high normal bias values magically erases peter panning while allowing bias to be set higher, meaning that shadow acne is also defeated. The shadow improvements are specifically why I'd like to migrate to Godot 4, as reverse face culling introduces multiple issues that can't all be resolved by just changing the geometry. And for my application, I can get away with lower bias as I will be opting for little to no shadow filtering, meaning less shadow acne. |
Is this PR going to get looked at again anytime soon? |
We took a look at this in today's render meeting. It seems that the same change can be made on the CPU side to avoid the extra work at run time
Also, from mrjustaguys testing it sounds like this introduces shadow acne. We definitely don't want to add something that creates shadow acne |
c81d758
to
7bdd358
Compare
I've retested this PR and I've found some flaws in my original testing methodology Comparing the Quality of the two options (No reduction in normal bias vs reduction in normal bias for distant splits) the issues of detached splits is significantly more clear, and appear almost always (to an annoying degree, with no mitigations but to drop normal bias and get acne everywhere), whereas the added shadow acne only becomes visible under extreme conditions (sufficiently large Distant geometry that's probably untextured and on grazing angles with the sun, where the sun is sufficiently bright) The mitigations of the two paths are dropping Normal Bias without the PR which introduces heavy acne everywhere and requires Bias increase to reduce and introduce peter panning, or with the PR to just tweak Biasing settings and introduce peter panning. I want to Stress this point, The most likely scenario for seeing acne added by this PR are open world day-night cycles, given that it's best shown on very large flat(ish) planes with minimal discernable texture detail to mask acne. This acne in the distant splits would naturally be however hidden by the fact that as night falls, and the sun is at such grazing angles, you'd also want your sun to have very low light energy by that point (for the lighting in general to just look good) at which even seeing actual shadows becomes hard close by, let alone some acne far off in the distance. |
Rebased and tested again on Forward+/Mobile with and without Blend Splits (in various split configurations), it works as expected. I've incorporated @clayjohn's suggestion so that no shader changes are required (visuals are unchanged). |
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.
Discussed in the rendering meeting.
@badsectoracula Will test this on another scene and see how it looks. But ultimately we are happy to merge this for 4.5 and see if anyone complains
7bdd358
to
acf9e0e
Compare
This reduces the visual discrepancy between shadow splits when Normal Bias is greater than 0. Shadow acne at a distance may be slightly more present, but if the bias and normal bias values are tuned to avoid acne up close, acne will usually not be present in distant splits.
acf9e0e
to
dfc05ca
Compare
@badsectoracula Did you ever get a chance to test this? |
In pretty much all the tests i could think of this PR was fine and didn't really show much of a visual difference. The biggest difference was when i tried with a large area, expanded distance and a directional light that casts long shadows in which case this PR was actually an improvement. Check the two screenshots below, the first one is the current master and the second is master with this PR applied. The shadow shapes look more "correct" with the PR to me and in one case (red arrow) the current behavior in master "breaks" the shape whereas with the PR it looks correct: |
Thanks! |
Follow-up to #48776.
This reduces the visual discrepancy between shadow splits when Normal Bias is greater than 0. Shadow acne at a distance may be slightly more present, but if the bias and normal bias values are tuned to avoid acne up close, acne will usually not be present in distant splits.
Tested on desktop (PCSS + PCF) and mobile (PCF) backends, with and without Blend Splits enabled. Performance is identical compared to before.
Testing project: test_shadow_splits.zip
Preview
Stills (from the MRP)
Blend Splits disabled
Blend Splits enabled
In motion
Normal Bias was increased to 10 to exagerate the difference. Usually, the difference isn't as pronounced, but it can still be significant when using Normal Bias set to 2 as done in #55757.
Before
directionallight3d-normal-bias-before.mp4
After
directionallight3d-normal-bias-after.mp4