-
-
Notifications
You must be signed in to change notification settings - Fork 21.9k
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
[3.x] Add a project setting to enable 3D shadow dithering #53967
base: 3.x
Are you sure you want to change the base?
Conversation
71cb8d3
to
c58391c
Compare
2d859d2
to
2621898
Compare
Rebased and tested again, it works as expected (including GLES3 now). I'm marking this as ready for review accordingly. |
This reminds me I spent an evening doing a little experiment with dithering in 3.x a couple of months ago. This screenshot was just pushing things to get as soft shadows as possible: But it does illustrate a couple of things:
The option to varying the dither pattern by time is worth thinking about if the PR doesn't do this already. Also the dither pattern in the screenshot seems to look very regular, maybe we will end up wanting to have different dither pattern options. As resolutions have increased (even on mobile) using dither to better trade off quality / performance becomes more viable option. |
I'm not sure if it's worth the added complexity, as I don't think a lot of users will rush to toggle this option (it's disabled by default after all). The fact that shadows have visible noise in 4.x is already a controversial point, so I think a boolean is good enough.
This makes sense too, but I guess it should piggyback on the Shadow Blur property added by #60243 if that PR is merged. This is how it works in 4.x 🙂
See #61834 which does this for Note that |
This improves overall shadow quality at the cost of a grainy appearance when up close. Dithering is disabled by default to preserve the current appearance in existing projects, but it will be enabled by default in Godot 4.0. This setting works in both GLES3 and GLES2 and with any shadow filter mode (even Disabled).
2621898
to
e300217
Compare
vec2 dither = (-vec2(0.5) + quick_hash(gl_FragCoord.xy)) * shadow_pixel_size; | ||
#else | ||
vec2 dither = vec2(0.0); | ||
#endif | ||
|
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.
I don't know if you can do this with defines in GLSL, but it might be worth testing if something like this is possible:
#ifdef SHADOW_USE_DITHERING
#define PLUS_DITHER +((-vec2(0.5) + quick_hash(gl_FragCoord.xy)) * shadow_pixel_size)
#else
#define PLUS_DITHER
#endif
...
avg += textureProj(shadow, vec4(pos PLUS_DITHER + vec2(-shadow_pixel_size.x, 0.0), depth, 1.0));
This improves overall shadow quality at the cost of a grainy appearance when up close. Dithering is disabled by default to preserve the current appearance in existing projects, but it will be enabled by default in Godot 4.0.
This setting works in both GLES3 and GLES2 and with any shadow filter mode (even Disabled).
This PR is effectively the opposite of #53961, but for
3.x
🙂This effectively resurrects some of the ideas behind #7204 as well.
Note: GLES3 rendering is currently broken (it's all white without any shader errors). This is because more than 32 conditionals are being used, like in #54355.Edit (June 2023): This seems to be fixed in the latest
3.x
branch now, likely by incindental changes made for the ubershader implementation.Preview
Don't pay attention to the peter-panning - it's unrelated to this pull request.
GLES3
Shadow Filter Mode: Disabled
Shadow Filter Mode: PCF5 (default)
Shadow Filter Mode: PCF13
GLES2
Shadow Filter Mode: Disabled
The SpotLight rendering breaks when the filter mode is Disabled for some reason (even without this pull request).
Shadow Filter Mode: PCF5 (default)
Shadow Filter Mode: PCF13