Unity 2022.2 URP Shadows.hlsl Error

I recently updated from 2021 to 2022, and my custom shaders no longer work. I receive this error.

Shader error in 'Custom/Toon/Toon Water': Invalid conditional expression. at .../Library/PackageCache/com.unity.render-pipelines.universal@14.0.5/ShaderLibrary/Shadows.hlsl(270)

The offending line of code in Shadows.hlsl looks like this:


It looks like a syntax error since #if is used instead of #ifdef - however, there surely can’t be a syntax error in the official URP code?

I’ve seen a few threads that seem to suggest the shader preprocessor syntax may have changed - am I missing something here?

3 Likes

I’m seeing the same problem in URP 14.0.4 and 14.0.6

And in 14.0.6 here, too.

Just upgraded to Unity 2022.3.2f1 and URP to 14.0.8 and getting this syntax error as well in Shadows.hlsl line 262. Wtf?

I reported it after my last post and it was confirmed as a bug on their end. Hopefully tbe fix makes it out soon.

1 Like

Looking around, it seems like it was fixed recently → (UUM-37723) Unity 2023.2.0b2

Yeah, pretty sure I got an update saying it’d been fixed for 2023. It’s the kind of thing you’d really hope would be addressed in the LTS, though.

I’m having the issue on Unity 2022.3.13f1 + URP 14.0.9 :face_with_spiral_eyes: