What it does

A Custom Function adds HLSL code to Shader Graph for calculations that are awkward to build from nodes. String mode contains the function body; File mode calls an external function. Match the input/output types and precision.

Figure: Conceptual relationship: Graph inputs → HLSL function → Graph outputs
Figure: Conceptual relationship: Graph inputs → HLSL function → Graph outputs

How to use it

String mode defines ports and a function body; File mode references an HLSL file and function name. Match File-mode precision suffixes such as _float and _half.

A concrete example

For a small addition exercise, define A and B inputs and an Out output, with Out = A + B; as the String body. Explicit ports help distinguish incorrect values from a missing-function compilation error.

How to check it

  1. Start with simple values and visualize the output as color to inspect type and range.
    Follow input, processing / condition, then output
    Follow input, processing / condition, then output
  2. Check stage restrictions and node-specific texture handling before adding derivatives, matrices or texture inputs.
    Follow input, processing / condition, then output
    Follow input, processing / condition, then output

Limitations

Check File-mode precision suffixes and stage restrictions.

References