Custom Node (material) calling other custom node?

I’m trying to port a shader, and it involves calling a custom function within a for loop of another custom function. What i’ve found is that I can’t have an input as a function pointer, and I can’t simply put functions within that custom code (because I’m guessing it’s wrapped in a function anyway). Does anyone know how i’d call (custom) function a from within a for loop in (custom) function b?

Just in case this is useful to anyone else…

You can add functions to the end of “Common.usf” in Engine\Shaders … as in C:\Program Files\Epic Games\UE_4.15\Engine\Shaders
These functions can be called from within your custom nodes.
The editor will pick up the file change immediately, and update itself. This doesn’t require recompiling the engine.

Possibly someone can get them to add the ability to name a custom node specifically, or namespace it in some way, to avoid this exercise. The engine obfuscates the custom-node naming, into some arbitrary name.

You can sort of do nested calls. The biggest challenge is the functions get auto named by the hlsl translator. The names start at return CustomExpression0 and then increment to 1, 2 etc.

If you chain one custom node into the input of another, it will force that one to be the 0. You would do that purely to enforce the numbered order. Then you can call it like this in the outer node:

CustomExpression0(Parameters, variables);

Note that you need the “Parameters” there. After that you need to include all the input arguments you want to pass.

This can be somewhat fragile as if you add a material function that uses the custom node and hook it to the vertex shader, it could bump all the orders. To double check the names under the hood use the ‘show hlsl’ option.

take a look here: Extending Custom HLSL / Custom Expressions - Rendering - Epic Developer Community Forums