Cause and mechanism
A Custom Function node calls your HLSL code from Shader Graph. Shader Graph already generates a CBUFFER that groups material values. Declaring UnityPerMaterial or the same properties again in custom code can cause compilation errors or SRP Batcher compatibility problems, so check where those declarations are made.
Check and correct the setup
- Declare values in the Blackboard and wire them to function inputs.
Follow input, processing / condition, then output - Receive values through matching HLSL parameters; do not redeclare the graph material buffer.
Follow input, processing / condition, then output - In File mode, match precision suffixes and port signatures. Inspect generated code and Frame Debugger.
Follow input, processing / condition, then output
Limits and verification
Local function variables do not belong in a material buffer. Distinguish local, global, and material data instead of assuming all globals break compatibility.
A focused diagnostic setup
Add only a pass-through float Custom Function to a compatible simple graph. Compare function computation separately from material-property declarations.
Test in this order
- Expose one Blackboard value and pass it through a function port.
Follow input, processing / condition, then output - Remove duplicate UnityPerMaterial or same-name declarations conflicting with generated graph code.
Follow input, processing / condition, then output - Inspect generated errors/compatibility and restore the original calculations incrementally.
Follow input, processing / condition, then output
Interpret the result
A function call alone does not imply incompatibility. Separate material inputs from genuinely shared globals and inspect generated code and actual rendering.
Related explanations
- Custom Function (Custom Function Node)
- SRP Batcher Not Compatible: Unity URP Fix Checklist
- Shader Variant