URP Shadow Cascades weird bug/behaviour in Build

Hello, I’ve been testing around and developing a scene in Unity URP, and i’ve hit a weird visual glitch which seems to be related to the shadow cascade and shadow distance configuration and a directional light. In a scene with a single directional light and a spotlight, using real-time shadows and lightning, The cast shadow behaves normally.

The glitch arises on the built project. Using Foward+ Render Path and Vulkan or DX11, both show the same behavior, all with high fidelity quality in the options. (4096 shadowmap etc.)
Shadow artifacts appear and flicker as the camera moves, as shown in the link bellow.

This behavior seems to be directly linked to the first shadow cascade segment, as I increase it, the artifacts stop but, as expected, the shadow quality plummets. I have also made adjustments in the near clip of the directional light, and it doesn’t seem to do anything. The build is already in maximum quality and retaining all shader variants.
What is confusing me is why this behavior only happens on the build and not on the editor. It goes away if the directional light is disabled completely or its shadows. Does anyone know anything about it, or what might be causing it?

3 Likes

Not to hijack, but I’m experiencing something similar.
In the editor, my shadows look fine, and in older builds they’re fine, too.

But having upgraded to 6000.0.36f1, I’m finding that shadows seem to be reacting on a very near distance around the camera.

I made sure to remove all URP settings except for the high quality ones, and ensured it’s the only available option in Project Settings->Quality

I’m using GPU Resident Drawer, but also tried with it disabled, no change.

There’s one directional light (inheriting settings from the URP asset), and one camera.

My current settings, and a shot of it working in the editor:

I tried taking the cascade count down to 1, and then took Depth Bias down to 0, and then finally the shadows would remain, but they look absolutely awful.

Here’s a video of how the build is now acting:

Any hints would be welcome, thanks!

2 Likes

I have the exact same problem since I upgraded to 6000.0.36f1. I tried everything but nothing works. Shadows are great on Editor and Development Build but when i build without Development this problem occurs. I thought it will be about shader stripping but i can’t try it because when i turn off stripping it compiles huge amount of shaders, and it probably will take forever to complete. I also tried tweaking cascade settings but didn’t work.

1 Like

Same here! I spent an unbelievable 7 hours yesterday testing different settings, building, getting frustrated, and repeating the process. Today, I just switched back to my old Unity 2022 version

anything to get rid of that Unity splash screen!

2 Likes

6000.0.37f1 is out, so I thought I’d give it a go, alas, still broken.

EDIT: I opened a bug from the Unity Hub, ended up as IN-94816

2 Likes

I can confirm too, the issue still happens in 6000.0.37f1. I tried tweaking cascade values and as I saw it only respects to first distance of cascade. So if “Split 1” set to 10m, after 10m shadows completely cutting off without any fading. But this only happen when you build while “Development Mode” unchecked.

2 Likes

Same behavior for me, doesn’t matter if the develop mode is checked or not. I also thought it could be shader stripping, but I disabled any form of shader stripping and after almost a hour of compilation, it still stayed the same way.

1 Like

I didn’t see that there was already a question about this, so I accidentally opened one too, the problem is also present for me in version 6000.0.37f1.

2 Likes

I can confirm that checking the Development Build checkbox fixes the issue in version 6000.0.37f1, but it’s not a real solution because you’ll still see “Development Build” in the bottom right corner of the screen, and the game size has increased from 94MB to 133MB. Unity definitely needs to fix this and release a new LTS version.

2 Likes

Hey everyone, thanks for reporting this issue. I’ve reproduced the bug locally and found it has something to do with one of my job system optimizations so once I figure it out, I’ll be able to submit a fix and get this resolved. Sorry about the bug!

3 Likes

Thanks for the answers everyone!, I will wait for the unity fix now!

That’s great - any idea on when this is likely to be fixed?

(I have also experienced this problem and its resolution if delaying our next game release).

Thanks!

I got this mail overnight, no exact date, but it’s been found and worked on (thanks Dale!)

1 Like

It’s hard to say how long it will take to fix but I’ve already found the piece of code that affects this bug. It seems like some compiler optimization is causing problems, but I haven’t nailed that part down yet.

I know of a code change that can workaround this bug, so if I don’t figure it all out today, I’ll submit the workaround which should fix this bug and the fix would come shortly after that. My guess is 6000.0.39f1 or 6000.0.40f1 if I do the workaround.

5 Likes

Thanks for the quick response on the issue, I really appreciate this kind of communication. :slight_smile:

Thanks again Dale, especially considering current circumstances.

1 Like

As NoshBar points out, I landed a fix for this issue a few hours ago and we’re waiting for confirmation from QA that it really is fixed. Assuming everything goes smoothly, the fix is scheduled to go out with 6000.0.41f1.

2 Likes

FYI 6000.0.41 is out! I’ll upgrade my project this weekend and edit this comment with how it goes.

EDIT: it workses, yay! Thank you to everyone who contributed!