-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Directional light shadows disappear when camera is rotated #8645
Comments
I've also noticed this issue. |
@DGriffin91 good to know it's not just me. Are you also using Vulkan + AMD card? |
I've seen it on both DX12 and Vulkan on Nvidia. I think it's probably an issue with the directional light shadow cascade calculations. Maybe something in: bevy/crates/bevy_pbr/src/light.rs Line 513 in ca81d3e
|
Here's a video of the issue: 2023-05-30.21-02-49.mp4This is with these settings:
This issue also happens in the sponza test scene. |
Hmm, I can't seem to reproduce with the example code on an M1 Max in macOS. Could someone make a video of the problem with the example code? Or else make a minimal example that reproduces the problem, plus a video showing the problem you see? |
Ok, I tried on |
@superdump I made a little test, the included one was a bit disorienting for me: https://github.com/DGriffin91/bevy_csm_test I see the issue on both vulkan and dx12 on a RTX3060. I have the camera spawn near one issue. You can also see it it you go up to one of the upper corners. |
cascades.mp4Looks like the issue occurs near the camera and near the cascade bounds.
|
# Objective - Fixes #8645 ## Solution Cascaded shadow maps use a technique commonly called shadow pancaking to enhance shadow map resolution by restricting the orthographic projection used in creating the shadow maps to the frustum slice for the cascade. The implication of this restriction is that shadow casters can be closer than the near plane of the projection volume. Prior to this PR, we address clamp the depth of the prepass vertex output to ensure that these shadow casters do not get clipped, resulting in shadow loss. However, a flaw / bug of the prior approach is that the depth that gets written to the shadow map isn't quite correct - the depth was previously derived by interpolated the clamped clip position, resulting in depths that are further than they should be. This creates artifacts that are particularly noticeable when a very 'long' object intersects the near plane close to perpendicularly. The fix in this PR is to propagate the unclamped depth to the prepass fragment shader and use that depth value directly. A complementary solution would be to use [DEPTH_CLIP_CONTROL](https://docs.rs/wgpu/latest/wgpu/struct.Features.html#associatedconstant.DEPTH_CLIP_CONTROL) to request `unclipped_depth`. However due to the relatively low support of the feature on Vulkan (I believe it's ~38%), I went with this solution for now to get the broadest fix out first. --- ## Changelog - Fixed: Shadows from directional lights were sometimes incorrectly omitted when the shadow caster was partially out of view. --------- Co-authored-by: Carter Anderson <[email protected]>
This appears to still be an issue in sponza with bevy 0.11 |
This appears to still be an issue in bistro with bevy 0.11 |
Bevy version
0.10.1,
main (f76b3c4)
Relevant system information
AdapterInfo { name: "AMD Custom GPU 0405 (RADV VANGOGH)", vendor: 4098, device: 5695, device_type: IntegratedGpu, driver: "radv", driver_info: "Mesa 22.2.5", backend: Vulkan }
What you did
See somewhat minimal example here.
What went wrong
Depending on the distance and angle of the camera some shadows partially disappear. As seen here it can quickly ruin a scene.
In the example code I gave only rectangular shadows should be possible but when you spawn in it looks like this:
Move around the camera with the mouse and you will see the shadow change shape.
Additional information
Same issue on my Windows 10 desktop (tested with Bevy 0.10.1) but I'm currently abroad so I cannot check the exact
AdapterInfo
. It has an AMD Vega 56 gpu and uses the Vulkan backend as well.The text was updated successfully, but these errors were encountered: