Skip to content

Commit e50a291

Browse files
svc-reach-platform-supportEvergreen
authored andcommitted
[Port] [6000.2] docg-6776: clarify Custom Function uniform usage and matrix example
1 parent b0927ef commit e50a291

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Packages/com.unity.shadergraph/Documentation~/Custom-Function-Node.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,11 @@ void MyFunction_float(float3 A, float B, out float3 Out)
9191
#endif //MYHLSLINCLUDE_INCLUDED
9292
```
9393

94-
**File** mode allows for more flexibility with custom functions in a graph. You can define uniform variables outside the function scope, as shown here with a matrix.
94+
The **File** mode allows for more flexibility with custom functions in a graph.
95+
96+
#### Shared data and uniform variables
97+
98+
To supply shared data to your function without additional ports, use uniform variables defined outside the function scope.
9599

96100
```
97101
//UNITY_SHADER_NO_UPGRADE
@@ -106,6 +110,14 @@ void MyFunction_float(float3 A, float B, out float3 Out)
106110
#endif //MYHLSLINCLUDE_INCLUDED
107111
```
108112

113+
When you add a uniform variable in a Custom Function, like the `float4x4` matrix in the example above, you make this variable global. As a result:
114+
115+
- You can set this uniform globally only, using `Shader.SetGlobalMatrix()`.
116+
- You don't have to add an input parameter to allow the shader to access them directly.
117+
- You can't set it per material, because it's not declared in the `UnityPerMaterial` cbuffer and doesn't have a material property associated with it.
118+
119+
#### Multiple functions and multiple files
120+
109121
You can define multiple functions in the same file, and call them from your referenced function. Alternatively, you can reference the same file, but use different functions from different Custom Function nodes.
110122

111123
```

0 commit comments

Comments
 (0)