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
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961