Shader Graph window reference
Find the toolbar, canvas actions, properties, and master settings in the Unity Spark Shader Graph window to create and apply shader graphs.
Read time 7 minutesLast updated 3 hours ago
The Shader Graph window is a node editor for shader graphs. It has a toolbar, a canvas where you connect nodes, and a side panel with the graph's properties and master settings.
To open the Shader Graph window, do one of the following:
- Select Add window (+) in any window group and select Shader Graph.
- Double-click a shader graph in the Project window.
- Select a shader graph in the Project window, then select Open in the Inspector window.
Unity Spark saves your changes to a graph only when you select Apply. For more information about Shader Graph in Unity Spark, refer to Materials and shaders.
Toolbar
The toolbar contains the following controls.
Control | Description |
|---|---|
| Open graph… | Opens a shader graph from your project. |
| New graph name | Sets the name of a new shader graph. |
| Create | Creates a new shader graph with the name in New graph name and opens it. Unavailable until you enter a name. |
| Undo | Undoes your last change to the graph. You can also press Ctrl+Z (macOS: Cmd+Z). |
| Redo | Redoes the last change you undid. You can also press Ctrl+Shift+Z or Ctrl+Y (macOS: Shift+Cmd+Z). |
| Imported | Appears as a badge when the open graph came from a Unity Shader Graph file. You can't import Unity Shader Graph files, so the badge appears only on graphs imported earlier. |
| Turned off | Appears as a badge when you select Turn off. |
| Rejected by the GPU | Appears as a badge when the graphics card rejects the shader. |
| Apply | Saves the graph and compiles it into a shader. Materials that use the shader update. Unavailable while the graph has errors. After you apply, a status line under the toolbar displays the result or the first error. |
If the graphics card rejects the shader, a message under the toolbar reads The message includes the following buttons.
The graphics device rejected this shader. Objects using it don't render.Button | Description |
|---|---|
| Retry | Builds the shader again. |
| Turn off | Stops the shader from running for this session. The message changes to |
When no graph is open, the window displays
Open a graph or create a new one to start editing.Canvas
Use the following actions on the canvas.
Action | Description |
|---|---|
| Right-click the canvas, or press Space | Opens the node search at the pointer. Enter text in Search nodes… to filter the list, then select a node or press Enter to add the first match. Press Esc to close the search. Nodes that the graph's master Kind doesn't support appear unavailable, with the reason. |
| Drag from a port to another port | Connects the two ports. |
| Select a connected input port | Disconnects the wire into that port. |
| Select a node or wire, then press Delete or Backspace | Deletes the selected node or wire. You can't delete the Master node. |
| Drag a node | Moves the node. |
| Double-click a Custom Function node | Opens the node's code under the canvas. For more information, refer to Custom Function panel. |
| Right-click a wire into an input that runs statements | Displays Run earlier, Run later, and Disconnect, to change the order the statements run in or to remove the wire. |
Custom Function panel
When you double-click a Custom Function node, a panel titled Custom Function <name> opens under the canvas. Edit the node's WebGPU Shading Language (WGSL) code in the panel, and the node updates as you type. For a node imported from Unity, the panel also shows the original High-Level Shading Language (HLSL) code, read-only, beside the WGSL code. Select Close (X) or press Esc to close the panel. The node keeps its code.
Properties
The Properties section of the side panel lists the graph's exposed properties. Each property shows its name, its type, and a Remove (trash icon) button that deletes it.
Control | Description |
|---|---|
| Name (optional) | Sets the name of a new property. If you leave it empty, Unity Spark names the property after its type. If you enter the name of an existing property, the new property replaces it. |
| Type | Sets the type of the new property: Float, Vector, Color, Texture 2D, or Buffer. |
| Add property (+) | Adds the property to the graph. You can also press Enter in Name (optional). |
| Access | Sets the access to Read or Read/Write for a Buffer property. The same choice appears for a texture property in a Compute graph, or for a texture property that's set to Read/Write. |
| Layout | Sets the layout of each element in the buffer for a Buffer property. Hover over the field to display the resulting layout. |
Property types
Type | Description |
|---|---|
| Float | A single number. |
| Vector | A group of numbers, such as a direction. |
| Color | A color. |
| Texture 2D | An image. |
| Buffer | Data for advanced graphs, such as Compute graphs. |
Float, Vector, Color, and Texture 2D properties appear as fields on the materials that use the graph.
Master
The Master section of the side panel sets what kind of shader the graph produces and how it draws.
Setting | Description |
|---|---|
| Kind | Sets the kind of shader: Unlit, Lit, Fullscreen, Instancing, Visual Effect, or Compute. You can't change the kind while a Visual Effect graph has more than one system. |
The other settings depend on the Kind.
Unlit and Lit settings
The following settings are available when Kind is Unlit or Lit.
Setting | Description |
|---|---|
| Workflow | Sets the workflow: Metallic or Specular. Lit only. |
| Blend | Sets how the surface blends with what's behind it: Opaque, Alpha Blend, Additive, or Multiply. |
| Cull | Sets which faces aren't drawn: Back, Front, or Off. |
| Depth test | Sets the depth comparison: Less Equal, Less, Equal, Greater, Greater Equal, Not Equal, or Always. |
| Cast shadows | Determines whether the surface casts shadows. Enabled by default. |
| Receive Fog | Determines whether the surface receives fog. Enabled by default. |
| Depth write | Sets whether the surface writes depth: Auto, Force, or Disable. |
| Alpha clipping | Enables alpha clipping. Disabled by default. |
| Preserve specular lighting | Determines whether highlights and reflections keep their strength when the surface fades with alpha. Lit only, with Blend set to Alpha Blend or Additive. When enabled, only the diffuse lighting fades with alpha, so highlights and reflections keep their strength, as on glass. When disabled, the whole surface fades with alpha. |
| Receive screen-space reflections | Determines whether the surface receives screen-space reflections. Lit only, with Blend set to Opaque. When the scene's screen-space reflections are on, the surface reflects what's on screen. Disable to keep the surface out of them. |
| Instancing | Determines whether the shader reads per-instance transforms from an instance set. Required on the material that an instance set draws with. |
Fullscreen settings
The following settings are available when Kind is Fullscreen.
Setting | Description |
|---|---|
| Blend | Sets how the pass blends with what's behind it: Opaque, Alpha Blend, Additive, or Multiply. |
| Depth test | Sets the depth comparison: Less Equal, Less, Equal, Greater, Greater Equal, Not Equal, or Always. |
| Depth write | Sets whether the pass writes depth: Auto, Force, or Disable. |
| Depth mode | Sets what the depth input holds: Eye, Linear01, or Raw. |
Instancing settings
The following settings are available when Kind is Instancing.
Setting | Description |
|---|---|
| Space | Sets where Unity Spark places the copies: Local Space or World Space. |
| Instance data | Defines a per-copy record, written as a WGSL layout. Each member becomes an input on the Master node. |
Visual Effect settings
The following settings are available when Kind is Visual Effect.
Setting | Description |
|---|---|
| System | Selects which of the graph's systems the side panel shows. |
| Add system | Adds another system to the graph. |
| Remove system | Removes the selected system, with the wires into it and the blocks that run in it. You can't remove the first system. |
Compute settings
The following settings are available when Kind is Compute.
Setting | Description |
|---|---|
| Use shader code | Determines whether to compile the master's WGSL code instead of the node graph. The graph stays, and compiles again when you disable this setting. |
| Convert to code | Replaces the shader code with the code that the node graph compiles to, and uses it. The nodes stay. |
| Workgroup | Sets the number of threads per workgroup along x, y, and z. Each value is between 1 and 256. The default is |
Errors
When the graph has errors, the side panel lists them under Errors, and a line under the toolbar displays the first error. Select an error in the list to select the node that caused it.