Version: 2022.3
Language : English
Targeting graphics APIs and platforms in HLSL
Declare shader keywords

Declaring and using shader keywords in HLSL

You can declare shaderA program that runs on the GPU. More info
See in Glossary
keywords and use them in conditional statements, so shaders behave differently when you enable or disable the keywords. You can use shader keywords in regular graphics shaders including surface shadersA streamlined way of writing shaders for the Built-in Render Pipeline. More info
See in Glossary
, and compute shaders.

Page Description
Declare shader keywords Use a #pragma directive in HLSL code to declare keywords.
Make shader behavior conditional Use an if statement in HLSL code, or a pre-processor directive, to mark parts of your shader code conditional based on whether you enable or disable a shader keyword.
Use shortcuts to create keyword sets Use Unity shader directive shortcuts to create sets of shader keywords and variants.

Additional resources

Targeting graphics APIs and platforms in HLSL
Declare shader keywords