Search Issue Tracker
Won't Fix
Votes
0
Found in
2020.2.0b6
2020.3
2020.3.5f1
2021.1
2021.2
Issue ID
1332499
Regression
Yes
Selecting a Shader throws an "Invalid conditional expression" error from Varyings.hlsl
How to reproduce:
1. Open the user's attached "ShaderGraphErrorsAfterUpgrading 2019.4.25.zip" project
2. In the Project window go VFX -> _Materials and click on "Shader_Graph_DiscoBall_BaseColor_NoFog"
3. Observe the Console and the Inspector for "Shader_Graph_DiscoBall_BaseColor_NoFog"
Expected results: There are no errors in the Console and in the Inspector for "Shader_Graph_DiscoBall_BaseColor_NoFog"
Actual results: There are 2 errors in the Console and in the Inspector for "Shader_Graph_DiscoBall_BaseColor_NoFog"
Reproducible with: 2020.2.0b6, 2020.3.7f1, 2021.1.5f1, 2021.2.0a14
Not reproducible with: 2018.4.33f1, 2019.4.26f1, 2020.2.0b5
Note:
-The errors are:
Shader error in 'DiscoBall_BaseColor_NoFog': Invalid conditional expression
Comments (1)
-
Metthatron
Jan 05, 2022 09:10
I haven't seen then files but I am assuming you are using a custom HLSL inside the Shader graph. I have encountered this error while exploring the UOP repository in URP 10.2.+, there is a leap in URP's handling of of branching in custom HLSL Shaders.
For example:
#if SHADERGRAPH_PREVIEW
should become:
#if defined(SHADERGRAPH_PREVIEW)
(Note : you don't need to do the same for #ifndef branch ...if not defined.)
and this solved my errors.
Hope this helps anyone coming across it.
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- "Shader warning in 'Hidden/Light2D': implicit truncation of vector type" is thrown when building Universal 2D template
- AI Assistant breaks compilation of packages using System.Runtime.CompilerServices.Unsafe via auto-referencing
- Unity Hub checks the "Documentation" module by default on the 6.4 and 6.5 streams despite that it was unchecked with the previous installs
- Shortcut that toggles between Dopesheet and Curves Views in the Animation Window's Timeline is mislabed
- Property List Items Overlap onto the Property List's top edge when scrolling through a long Property List
Resolution Note (2021.2.X):
Neither Shader Graph, nor URP supports upgrading generated shaders. Regenerating the shader from an upgraded shader graph should work.