Search Issue Tracker
By Design
Won't Fix in 2022.3.X
Votes
0
Found in
2022.3.59f1
6000.0.40f1
Issue ID
UUM-98634
Regression
No
"Shader error redefinition of 'Varyings'" error appears when selecting the shader
Reproduction steps:
1. Open the attached “IN-96041_Repro.zip“ project
2. Select the “Assets/MyTestShader.shader“ Shader in the Project Browser
3. Observe the Console
Expected result: No errors are present
Actual result: “Shader error in 'MyTestShader': redefinition of 'Varyings' at Assets/MyTestShader.shader(43) (on metal)“ appears
Reproducible with: 2022.3.59f1, 6000.0.40f1
Couldn’t test with: 6000.1.0b8, 6000.2.0a5 (Instead a different error is present from UUM-98633)
Reproducible on: M1 Max MacOS 15.1.1 (Tested by CQA)
Not reproducible on: No other environment tested
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 Graph Node information is briefly displayed in Graph Inspector when clicking on Category in the Blackboard
- Module installation fails with "Download failed: Validation Failed" errors when using beta.2 Hub version
- JsonConvert conversion fails trying to call GetCallbackMethodsForType when [OnDeserialized] is used in a class
- Shader Graph Category dropdown cannot be expanded/collapsed when clicking on the text
- Different text alignment in the column header in Entities "System" window
Resolution Note:
It looks like the shader needs few fixes to work with no errors:
* struct Varyings {...} needs a ";" at the end of it.
* You're using: #pragma vertex MeshCloudVertex but then you have
Varyings Vertex(Attributes IN)
{
Varyings OUT = (Varyings)0;
OUT.color.w = ComputeFogFactor(OUT.positionHCS.z);
}
The compiler looks for a function named MeshCloudVertex (because of the #pragma vertex line). But you’ve actually defined Vertex. Because of this mismatch, Unity falls back to some default behavior during compilation and re-parses Varyings in a way that leads to a duplicate structure definition in the generated code for Metal. So the user should either change the pragma to "#pragma vertex Vertex" or rename their function to "Varyings MeshCloudVertex".
* Also the function is missing a return value of type Varyings -> Add "return OUT;" at the end of the function.
Resolution Note (2022.3.X):
It looks like the shader needs few fixes to work with no errors:
* struct Varyings {...} needs a ";" at the end of it.
* You're using: #pragma vertex MeshCloudVertex but then you have
Varyings Vertex(Attributes IN)
{
Varyings OUT = (Varyings)0;
OUT.color.w = ComputeFogFactor(OUT.positionHCS.z);
}
The compiler looks for a function named MeshCloudVertex (because of the #pragma vertex line). But you’ve actually defined Vertex. Because of this mismatch, Unity falls back to some default behavior during compilation and re-parses Varyings in a way that leads to a duplicate structure definition in the generated code for Metal. So the user should either change the pragma to "#pragma vertex Vertex" or rename their function to "Varyings MeshCloudVertex".
* Also the function is missing a return value of type Varyings -> Add "return OUT;" at the end of the function.