How to modify UVs of supplied texture in Function

I can’t figure out how to supply a texture to the function from material and modify UV coords inside that function. Let me explain on an example:

  • let’s say I want to blur the screen in PP, so I made a simple blur (add together 9 scene textures with UV offsets, divide by 9)
  • now I want to move the blurring algorithm to a function
  • in function I can only create inputs that don’t have UV input

How would I go about “offseting” UVs inside the function?

I could use “SceneTexture” node right inside that function, but in that case I would have to select the “Scene Texture Id” inside the function. I would rather like to supply the particular “scene texture” or “ID” (SceneColor, Specular or PostProccessInput0-6) to the function from the material itself. Is that possible?

Thanks

Edit: Basically I would like to make a blurring function that can blur whatever texture I supply to the function from the material. It would be enough if it works on V3.

1 Like

Bumping this question because I run into the same problem again. This time I’m doing some gradient mapping in a function and I need to supply the function with gradient texture and then modify it’s UV’s. Still can’t figure out how to do that.

Here is a screenshot of what I’m talking about:

Any help would be appreciated.

Ok, this is a bit embarrassing :slight_smile: , 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 :slight_smile:

1 Like

Thank you, that did the trick (and is extremely useful for landscape materials)!