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. If you overwrite this parameter, be aware of the following:
|
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:
|
Is Overridable | Indicates whether the keyword's state can be overridden. 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 |
---|---|
Default Value | Select 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.