Documentation

Unity Spark

Open Unity Spark

Unity Spark

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 nameSets the name of a new shader graph.
CreateCreates a new shader graph with the name in New graph name and opens it. Unavailable until you enter a name.
UndoUndoes your last change to the graph. You can also press Ctrl+Z (macOS: Cmd+Z).
RedoRedoes the last change you undid. You can also press Ctrl+Shift+Z or Ctrl+Y (macOS: Shift+Cmd+Z).
ImportedAppears 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 offAppears as a badge when you select Turn off.
Rejected by the GPUAppears as a badge when the graphics card rejects the shader.
ApplySaves 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 graphics device rejected this shader. Objects using it don't render.
The message includes the following buttons.

Button

Description

RetryBuilds the shader again.
Turn offStops the shader from running for this session. The message changes to
Turned off until you retry it or reload. The graph itself is unchanged.
Select Turn on to run it again.
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 SpaceOpens 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 portConnects the two ports.
Select a connected input portDisconnects the wire into that port.
Select a node or wire, then press Delete or BackspaceDeletes the selected node or wire. You can't delete the Master node.
Drag a nodeMoves the node.
Double-click a Custom Function nodeOpens the node's code under the canvas. For more information, refer to Custom Function panel.
Right-click a wire into an input that runs statementsDisplays 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.
TypeSets 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).
AccessSets 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.
LayoutSets 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

FloatA single number.
VectorA group of numbers, such as a direction.
ColorA color.
Texture 2DAn image.
BufferData 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

KindSets 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

WorkflowSets the workflow: Metallic or Specular. Lit only.
BlendSets how the surface blends with what's behind it: Opaque, Alpha Blend, Additive, or Multiply.
CullSets which faces aren't drawn: Back, Front, or Off.
Depth testSets the depth comparison: Less Equal, Less, Equal, Greater, Greater Equal, Not Equal, or Always.
Cast shadowsDetermines whether the surface casts shadows. Enabled by default.
Receive FogDetermines whether the surface receives fog. Enabled by default.
Depth writeSets whether the surface writes depth: Auto, Force, or Disable.
Alpha clippingEnables alpha clipping. Disabled by default.
Preserve specular lightingDetermines 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 reflectionsDetermines 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.
InstancingDetermines 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

BlendSets how the pass blends with what's behind it: Opaque, Alpha Blend, Additive, or Multiply.
Depth testSets the depth comparison: Less Equal, Less, Equal, Greater, Greater Equal, Not Equal, or Always.
Depth writeSets whether the pass writes depth: Auto, Force, or Disable.
Depth modeSets what the depth input holds: Eye, Linear01, or Raw.

Instancing settings

The following settings are available when Kind is Instancing.

Setting

Description

SpaceSets where Unity Spark places the copies: Local Space or World Space.
Instance dataDefines 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

SystemSelects which of the graph's systems the side panel shows.
Add systemAdds another system to the graph.
Remove systemRemoves 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 codeDetermines 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 codeReplaces the shader code with the code that the node graph compiles to, and uses it. The nodes stay.
WorkgroupSets the number of threads per workgroup along x, y, and z. Each value is between 1 and 256. The default is
64
,
1
,
1
.

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.

Additional resources