How to mimic a For loop in Shader Graph?

Hi guys,

In previous versions, I found out that using the old ShaderGraph API (CodeFunctionNode class inheritance), one could create a for loop and iterate a number of times on some HLSL code.

Since this got removed from Unity, can anyone tell me how I should go for it?
Thanks

1 Like

Hi there,
They replaced the old ShaderGraph API with Custom fonction nodes, which are nodes you can type HLSL in. It’s not as powerful as the old API, but I think in your specific case it shouldn’t matter.
https://docs.unity3d.com/Packages/com.unity.shadergraph@6.7/manual/Custom-Function-Node.html

But this only works on 6.7 right? I couldn’t see the same feature on 5.16.1 with the regular 2019.1.10f version of Unity

It’s

It’s there in your version too. In SG, look for “custom” and “Custom Function” will appear.
4773671--454748--upload_2019-7-22_16-27-37.png

1 Like