Diagnostics
Shader Script checks shader code while it's compiled and reports problems as regular C# compiler errors and warnings, in your IDE and in the Unity Console. Double-click one to go to the code it's about.
Tip
Visual Studio 2022 runs source generators, such as Shader Script's, only when you save a file or build the project, so by default it shows these errors only then. To see them as you type, open Tools > Options > Text Editor > C# > Advanced, set Source Generators > Source generator execution to Automatic, and restart Visual Studio.
Each diagnostic has a code: SSG and four digits. The first digit is the category:
| Codes | Category |
|---|---|
SSG0xxx |
Declarations: shader classes, members, methods, names |
SSG1xxx |
Material properties and their attributes |
SSG2xxx |
Shader attributes and fragment outputs |
SSG3xxx |
Types |
SSG4xxx |
Statements and expressions |
SSG5xxx |
Shared code |
SSG9xxx |
Internal errors and version mismatches |
All diagnostics are errors, except the warnings SSG1017 and SSG2001–SSG2007. While there are errors, Unity doesn't load the new code, so shaders aren't regenerated: they stay as they were after the last successful compilation.
Errors without an SSG code in the Console that come from a shader, rather than from a C# file, are reported by Unity's shader compiler. See Debugging shaders.
Declarations
SSG0001
Invalid [Shader] base class
A class marked with [Shader] must derive directly from one of the shader kinds: ShaderScript.Lit, ShaderScript.Unlit or ShaderScript.Fullscreen. A shader can't derive from another shader class, or from a base class of your own. To share code between shaders, use shared code.
SSG0002
Missing Vert method
The shader has no Vert method with the signature its kind expects. Implement it with override, as the base class declares it:
public override void Vert(VertexInput IN, ref VertexOutput OUT) { }
SSG0003
Missing Frag method
The shader has no Frag method with the signature its kind expects. Implement it with override, as the base class declares it.
SSG0004
Invalid shader name
The name in [Shader("...")] can't be used by Unity. The message says why: the name is empty, contains quotes, backslashes or control characters, has an empty part ("A//B", or a / at the start or end), or has a part that starts or ends with a space.
SSG0005
Field in a shader class
A shader class can't have fields, other than const ones: a shader has no state between pixels. Use a material property for a value set per material, a const for a fixed value, or a local variable in the method. For a fixed vector, or another value C# doesn't allow in a const, write a method that returns it. static readonly fields aren't supported.
SSG0006
Unsupported member
A shader class or a [ShaderCode] type contains a member that shader code doesn't support: a constructor, an operator, an indexer, an event, or a nested type. The message names the kind of member. See What shared code can contain.
SSG0007
Method without a body
A method has no body, so there is nothing to translate: for example, it's extern, or a partial method without an implementation.
SSG0008
Generic method
Shader code doesn't support generic methods. Write an overload for each type you need instead:
static float Square(float v) { return v * v; }
static float3 Square(float3 v) { return v * v; }
SSG0009
Method returns an array
A method in shader code can't return an array. Return it through an out or ref parameter instead. See Arrays.
SSG0010
Underscore in a type name
The names of shader classes and [ShaderCode] types can't contain _: Shader Script uses underscores in the names it generates.
SSG0011
Underscore in a method name
The names of methods in shader code can't contain _, for the same reason as SSG0010.
SSG0012
Underscore in a variable name
The names of local variables, parameters, fields and constants in shader code can't contain _, for the same reason as SSG0010. Shader Script also uses _ to rename a variable whose name HLSL reserves for itself, such as point or step, which becomes point_ in the generated shader.
Material properties
See Material properties for the property types, their default values and their attributes.
SSG1001
Unsupported property type
The type of a property can't be a material property type, for example string or double. See Property types for the supported ones.
SSG1002
Property with code
A property of a shader class declares a material property, so it must be { get; }, without a setter or a body. To compute a value, write a method:
public float Strength { get; } = 1f; // a material property
float DoubleStrength() { return Strength * 2; } // a computed value
SSG1003
Underscore in a property name
Property names can't contain _: the material property is named _ followed by the C# name.
SSG1004
Reserved property name
Shader Script generates material properties of its own for the surface settings, such as _Surface, _Blend or _Cull, and the shader compilers reserve a few names of the same form, such as _Bool or _Complex. A property whose name would map to one of them, such as Surface or Complex, must be renamed.
SSG1005
Invalid bool property
A bool property can't be a material property. Its only use is a check whether a texture is assigned, with [TextureIsSet]. See Checking whether a texture is assigned.
SSG1006
Unsupported initial value
The initial value of a scalar property must be a number, such as = 0.5f or = -1. Expressions such as = 1 + 2, and constants, aren't supported.
SSG1007
Unsupported initial value
The initial value of a vector property must be a constructor with numbers, such as = new float4(1, 1, 1, 1). The message shows the form for the property's type.
SSG1008
Unsupported initial value
A value in the constructor of a vector property's initial value isn't a number. Write each component as a number, such as new float3(0.5f, 0, 1).
SSG1009
Unsupported initial value
Matrix properties can't have an initial value. See Matrices.
SSG1010
Unsupported initial value
Texture2DArray, Texture3D and Cubemap properties can't have an initial value.
SSG1011
Unsupported initial value
The initial value of a Texture2D property must be one of the built-in textures: Texture2D.White, Black, Gray, LinearGray, Red or Bump. See Default textures.
SSG1012
Unsupported initial value
The initial value of an enum property must be one of the enum's values, such as = Quality.High. Casts, such as = (Quality)1, aren't supported.
SSG1013
Empty enum
An enum with no values can't be the type of a material property.
SSG1014
Invalid display name
The name in [DisplayName] is empty or contains quotes, or it uses the "Section/Label" form with an empty section or label.
SSG1015
Invalid header text
The text of [Header] must not be empty and can contain only letters, digits, spaces and underscores: Unity can't read other characters there.
SSG1016
Invalid custom attribute
The value of [CustomAttribute] must not contain square brackets: Shader Script adds them itself.
SSG1017
[Color] on a non-color property (warning)
[Color] and [MainColor] apply only to float4 and half4 properties. On a property of another type, the attribute is ignored.
SSG1018
Invalid [Range]
[Range] can only be applied to float properties.
SSG1019
Invalid [NoScaleOffset]
[NoScaleOffset] can only be applied to Texture2D properties.
SSG1020
Invalid [KeywordSwitch]
[KeywordSwitch] can only be applied to int, float and enum properties.
SSG1021
Conflicting attributes
[Toggle] and [KeywordSwitch] can't be applied to the same property: both show a checkbox, but they work differently. Choose one, see Checkboxes and switches.
SSG1022
Invalid [Inline]
[Inline] can't be applied to a texture property. It goes on the property declared right after the texture property, and draws that property on the texture's line.
SSG1023
Invalid [Inline]
A property with [Inline] must be declared right after a texture property, or after another [Inline] property that follows one.
SSG1024
Invalid [Inline]
At most two [Inline] properties can follow one texture property.
SSG1025
Invalid [DetailMap]
[DetailMap] can only be applied to Texture2D properties.
SSG1026
Invalid [DetailScale]
[DetailScale] can only be applied to float properties.
SSG1027
Invalid [DetailScale]
Only one property of a shader can have [DetailScale].
Shader attributes and fragment outputs
SSG2001
Attribute has no effect (warning)
An attribute on the shader class doesn't apply to its kind, for example a surface setting on a Fullscreen shader, and is ignored. See Which kinds support which settings.
SSG2002
Unused fragment output (warning)
Frag sets specularColor, but no render pipeline reads it: on URP the workflow is Metallic, and on HDRP the material type doesn't include Specular Color. Use [WorkflowMode(WorkflowMode.Specular)] or WorkflowMode.Override for URP, and [Material(MaterialType.SpecularColor)] for HDRP. See Material types.
SSG2003
Unused fragment output (warning)
Frag sets metallic, but no render pipeline reads it: on URP the workflow is Specular, and on HDRP the material type doesn't include Standard. Use [WorkflowMode(WorkflowMode.Metallic)] or WorkflowMode.Override for URP, and [Material(MaterialType.Standard)] for HDRP.
SSG2004
Unused fragment output (warning)
Frag sets emission, but [Emission] turns emission off. See Emission.
SSG2005
Unused fragment output (warning)
Frag sets distortion or distortionBlur, but distortion is off. Add [Distortion(DistortionEnableMode.On)] or DistortionEnableMode.Override. See Distortion.
SSG2006
Unused fragment output (warning)
Frag sets coatMask, but clear coat is off. Add [ClearCoat(ClearCoatMode.On)] or ClearCoatMode.Override. See Clear coat.
SSG2007
Unused fragment output (warning)
Frag sets depthOffset, but [DepthOffset(DepthOffsetMode.Off)] turns depth offset off. Remove the attribute: without it, depth offset is on whenever Frag sets the value. See Depth offset.
Types
SSG3001
Unsupported type
A type can't be used in shader code, for example string, object or a class. If it's your own struct, mark it with [ShaderCode]. See What's not supported.
This includes double: most GPUs don't support double precision. Use float, and the f suffix for literals, such as 0.5f. See Scalar types.
SSG3002
Unsupported generic type
A generic type, such as Func<T> or int? (Nullable<int>), can't be used in shader code. The only generic types shader code supports are the array types.
SSG3003
Unsupported use of a type
A type name is used where shader code expects a value.
SSG3004
Type available only in a shader
Shared code uses a type that belongs to a shader, such as FragmentInput or VertexOutput. Pass the values you need as parameters instead. See What shared code can use.
SSG3005
Ambiguous field type
Some fields of the input and output structures, such as the UV channels and the custom fields interp0…, take their type from how you use them. Here, the use doesn't say which type it is, typically because the variable is declared with var. Make it explicit:
float2 uv = IN.uv0; // or: var uv = (float2)IN.uv0;
SSG3006
Conflicting field types
A field whose type follows its use, as in SSG3005, is used as two different types in one shader, for example as float2 in one place and as float3 in another. Use the same type everywhere, with a cast where needed. See Passing values to Frag.
Statements and expressions
See What's not supported for what to use instead of the unsupported C# features.
SSG4001
Unsupported statement
Shader code doesn't support a statement, such as foreach, goto, try, throw or a local function. The message names the kind of statement, as the C# compiler calls it, for example ForEachStatement.
SSG4002
Unsupported expression
Shader code doesn't support an expression, such as a switch expression, default, a string, a lambda, is, as, ??, checked or a tuple. The message names the kind of expression, for example SwitchExpression.
SSG4003
Object initializer
Object initializers, such as new Light { Color = c }, aren't supported. Create the value with new Light(), then assign the fields.
SSG4004
nameof in shader code
nameof can't be used in shader code: shader code has no strings. (nameof in attribute arguments, such as [TextureIsSet(nameof(BaseMap))], is fine.)
SSG4005
Declaration in an argument
A variable can't be declared in an argument, as in GetValues(out float a). Declare it before the call:
float a;
GetValues(out a);
SSG4006
Discard
Discards aren't supported in shader code, as in GetValues(out _) or _ = F(). Use a variable instead, and ignore its value.
SSG4007
Unsupported default parameter value
A call leaves out an argument whose default value can't be written in shader code. Default values can be numbers, bool values and enum values; for other types, pass the argument explicitly.
SSG4008
Array elements outside a variable declaration
An array created with elements can only be the initial value of a variable. Declare the variable first, then use it:
array4<float> weights = new array4<float>(1, 2, 3, 4);
float sum = Sum(weights);
SSG4009
Unsupported method
A method can't be used in shader code, for example a method of a .NET or Unity class such as Mathf.Abs. If it's a method of your own type, mark the type with [ShaderCode]. For math, use the math class.
SSG4010
Unsupported member
A static field or constant of a type that shader code doesn't know is used, for example Mathf.PI. If it's your own type, mark it with [ShaderCode]. For math constants, use the ones in math, such as math.PI.
SSG4011
Unsupported call
A call has a form shader code doesn't support, such as calling the result of an expression. Call methods by their name, as Method(...), Type.Method(...) or value.Method(...).
SSG4012
Unsupported member access
A member is accessed in a way shader code doesn't support, such as p->x in unsafe code. Use a.b.
Shared code
See Shared code.
SSG5001
Non-static [ShaderCode] class
A class marked with [ShaderCode] must be static. For a data type with its own methods, use a struct.
SSG5002
Property in shared code
Shared code can't have properties. Use a method or a field.
SSG5003
Static field that isn't const
Static fields in shared code must be const: shader code has no global variables. static readonly fields aren't supported either: their initializers are code that C# runs once. For a fixed vector, or another value C# doesn't allow in a const, write a method that returns it.
SSG5004
Field with an initial value
An instance field of a [ShaderCode] struct can't have an initial value. Assign it after creating the struct.
Internal errors and version mismatches
These errors mean that Shader Script doesn't recognize something that exists in its C# API, usually because the package's C# code and its code generator come from different versions. Reinstall the Shader Script package. If the error stays, please report it.
SSG9001
Unsupported attribute syntax
Shader Script can't read the arguments of an attribute.
SSG9002
Unknown shader attribute
Shader Script doesn't recognize an attribute on a shader class.
SSG9003
Unknown enum value
An attribute argument is a value its enum doesn't define, for example a number cast to the enum type, such as (ZTestFunction)42. Use one of the enum's named values.
SSG9004
Unknown Texture2D default
Shader Script doesn't recognize a built-in texture used as the initial value of a Texture2D property.
SSG9005
Unknown field
Shader Script doesn't recognize a field of an input or output structure.
SSG9006
Unknown type name
Shader Script can't determine the full name of a type.
SSG9007
Internal error
An unexpected error occurred while translating a class. Please report it, with the code that causes it if possible.
SSG9008
Internal error
An unexpected error occurred while generating shaders. Please report it.