Open BlackCurtainStudio opened 1 month ago
I've reproduced this issue with a spotlight in the MyGame template - it even shows up in the editor. After a lot of time inside RenderDoc, my conclusion is the following lines: https://github.com/stride3d/stride/blob/4c46fdcc4da0021514fbaaea3d432095d164b9b6/sources/engine/Stride.Rendering/Rendering/Shadows/ShadowMapReceiverBase.sdsl#L39-L41
My understanding is that the first line transforms the pixel position (from world space) into "shadow map texture space".
This calculation occurs for every pixel on screen and basically every pixel that's nowhere near the spotlight/shadow should theoretically be "outside" the UV space of the shadow map. The problem is that there are some weird angles where this matrix calculation causes shadowPosition.w
to be zero then the division by w
causes xyz
to be infinite and the subsequent shadow calculations produce garbage results (ie. NaN).
I think the solution might be to do an early exit check if the pixel isn't actually within the shadow map uv space? Any graphics guru able to chime in?
I couldn't reproduce this issue with the point light, I think it needs a more precise setup to reproduce it, though I suspect it should have the same issue.
@Basewq thanks a lot for investigating. I've also traced this bug down to the shadow maps, but couldn't find the correct line.
I'll have a look at it!
This has been reported several times: https://github.com/stride3d/stride/issues/325
I can confirm the issue is in the editor as well. Here's an example with a Point Light. However, the issue disappears when using Type DualParaboloid.
Release Type: Official Release
Version: 4.2.0.2232
Platform(s): Windows
Describe the bug Point Light and Spot Light with shadow map PCF filter enabled produces a black screen artifact randomly.
To Reproduce Steps to reproduce the behavior:
Expected behavior No screen artifacts should appear.
Screenshots