Loop and Boolean Or in shading


I am trying to implement a loop (a For) to use at several places in my shaders instead of coping and connecting nodes many times.
To do so I use a function an a reentrant connection. Because of the If used inside the function I was hoping to avoid the compilation error but it looks like I cannot turn around it.

Here is the function. Note I added some component masks to be sure the values are scalar.

And here is how it is used in the material.

  • Do you know how I could do a loop? Is there a way to do recursive functions?
  • And how would you implement a Boolean Or between 2 If? This is to do something like If (A

same problem,did you find some solution?

You should use Custom Node with actual HLSL code for that.