Keyword parameter reference
There are two types of keywords: Boolean and Enum. Each keyword type has a few specific parameters in addition to the many parameters that all keyword types have in common.
Common parameters
Parameters that all keyword types have in common.
| Name | Description |
|---|---|
| Name | The display name of the keyword. Unity shows this name in the title bar of nodes that reference the corresponding keyword, and also in the Material Inspector if you expose that keyword. |
| Reference | The internal name for the keyword in the shader. Use this Reference name instead of the display Name when you reference the keyword in a script. If you overwrite this parameter, be aware of the following:
|
| Promote to final Shader | Makes the keyword available across the entire shader rather than only within the subgraph. |
| Definition | Sets the keyword declaration type, which determines how Unity compiles the shader code. This allows you to optimize the balance between build time, runtime, and file sizes. The options are:
|
| Allow Definition Override | Makes the keyword's Definition overridable at compile time through the project's Shader Build Settings. When this option is enabled, Shader Graph uses dynamic branching (if) in generated code instead of preprocessor directives (#if). Enabling this option doesn't affect the shader's runtime performance unless the Shader Build Settings override the Definition to Dynamic Branch at compile time. |
| Allow State Override | Sets the keyword scope to Global, making the keyword state overridable at runtime. If this option is disabled, the keyword scope is set to Local and the keyword state is not overridable. For more information, refer to Toggle shader keywords in a script. |
| Generate Material Property | Generates a material property declaration to display the keyword as a property in the material inspector. This adds a [Toggle(_KEYWORD)] attribute to the material property. For more information, refer to MaterialPropertyDrawer. |
| Stages | Set the stage the keyword applies to. The following options are available:
|
Boolean keywords
Parameter specific to Boolean keywords in addition to the common parameters.
| Name | Description |
|---|---|
| Default Value | Enable this parameter to set the keyword's default state to on, and disable it to set the keyword's default state to off. This parameter determines the value to use for the keyword when Shader Graph generates previews. It also defines the keyword's default value when you use this shader to create a new Material. |
Enum keywords
Parameters specific to Enum keywords in addition to the common parameters.
| Name | Description |
|---|---|
| Include "none" entry | Includes a special entry in addition to the Entries list to allow the enum to have a "no value selected" state. For more details about the corresponding shader code behind this option, refer to Branch when all keywords in a set are disabled. |
| Default Value | Selects an entry from the drop-down menu to determine which value to use for the keyword when Shader Graph generates previews. This also defines the keyword's default value when you use this shader to create a new Material. When you edit the Entries list, Shader Graph automatically updates the options in this control. |
| Entries | This list defines all the states for the keyword. Each state has a separate Entry Name and Reference Suffix.
|
When you define an Enum keyword, Shader Graph displays labels for each state consisting of a version of the Enum's Entry Name appended to the main Reference name.
Note
Special characters such as (, ), !, or @ are not valid in the Entry Name of an Enum keyword. Shader Graph converts invalid characters to underscores (_).
Built-in keywords
The parameters of built-in keywords depend on their type, which is always of either the Boolean or Enum type, and you cannot edit their values.
All Built-in keyword fields in the Node Settings tab of the Graph Inspector are grayed out except for the Default field, which you can enable or disable to show the differences in Shader Graph previews. You also cannot expose Built-in keywords in the Material Inspector.