Ok, this is a bit embarrassing , I somehow haven’t noticed (or maybe tried it long before and something didn’t work so I just ignored it) that FunctionInput node has besides Scalar and Vec1-4 also Texture2D selectable as input type.
But to understand how that works I first had to learn the difference between Texture Object and Texture Sample. This may sound stupid I guess, but without shader or general programing background I so far didn’t have a case where using Texture Sample wouldn’t do the trick, so I have been always using that and the difference between Texture Sample and Texture Object never came to question :).
Anyway, if someone would bump into similar problem:
- in the function you have to use FunctionInput where you select the Input Type to be “FunctionInput_Texture2D” (and not scalar or vector)
- now outside of the function you have to use “Texture Object” node (or Texture Object Parameter) and supply it to your function input (one that you just set to “FunctionInput_Texture2D” in the previous step)
- using Texture Sample node wouldn’t work as the node outputs vector data, while the “Texture Sample” node in the function expects “Texture Object” (which is “whole texture” and not sampled vector data)
edit: this solves my 2nd problem, I now have to rethink the first problem with the new knowledge