| - | - |
|---|---|
Float Vector |
First value |
Float Vector |
Second value |
| - | - |
|---|---|
| SAIT | Sum of the two inputs |
| - | - |
|---|---|
Float Vector |
Minuend |
Float Vector |
Subtrahend |
| - | - |
|---|---|
| SAIT | Difference of the two inputs |
| - | - |
|---|---|
Float |
Base |
Float |
Exponent |
| - | - |
|---|---|
Float |
Result of base raised to the power of the exponent |
| - | - |
|---|---|
Vector3 Vector4 |
First vector |
Vector3 Vector4 |
Second vector |
| - | - |
|---|---|
Float |
Dot product result |
| - | - |
|---|---|
Vector4 |
Input color |
Vector4 |
Target color |
Vector4 |
Replacement color |
| - | - |
|---|---|
Vector4 |
Color with replaced values |
| - | - |
|---|---|
Vector2 |
Tiling values |
Vector2 |
Offset values |
| - | - |
|---|---|
Vector2 |
Modified UV coordinates |
| - | - |
|---|---|
Float |
Distortion strength |
Vector2 |
UV coordinates |
| - | - |
|---|---|
Vector2 |
Warped UV coordinates |
Set the name of the node.
If using "File", ensure the external HLSL file name exactly matches the function name defined in the HLSL file. This ensures the function is correctly referenced in the Shader Graph pipeline.
CustomFunction.hlsl, the function inside it should also be named
CustomFunction.
Define the required Inputs and Outputs for the custom function in Shader Graph. These will automatically
generate ports for you to connect other nodes.
Float (time), Vector3 (position)Vector3 (new position)In the custom HLSL code, the in and out parameters correspond to these inputs and outputs:
in represents the data coming into the function (e.g., time, position).out defines the return value (e.g., modified position).Directly write the HLSL code inside the custom function node editor in Shader Graph.
Ensure that the in and out parameters match the inputs and outputs you defined in Shader Graph.
float3 CustomPosition(in float time, in float3 position, out float3 newPosition) {
newPosition = position + float3(sin(time), cos(time), 0.0);
return newPosition;
}
Write the HLSL code in an external .hlsl file and reference the file in Shader Graph.
1. Create an HLSL file named CustomPosition.hlsl.
2. Write the custom function inside the file. The in and out parameters should match the Shader Graph
inputs and outputs.
float3 CustomPosition(in float time, in float3 position, out float3 newPosition) {
newPosition = position + float3(sin(time), cos(time), 0.0);
return newPosition;
}
3. Save the file in your project directory, for example, Assets/Shaders/CustomPosition.hlsl.
4. Link the file in Shader Graph:
CustomPosition.hlsl.Connect the custom function node’s input ports to other nodes, such as Time and Position, to feed data into the
custom function.
Connect the output port to apply the function result in the Shader Graph pipeline.
Time (as a float) and Position (as a vector)Modified Position (vector with new position)This would make the custom node update an object's position based on time in the shader.