Download

Problem: Applying UVs to Mat Expression

Hello Ue4 Material Gurus, seeking some advice with UVs. My intention is replace the texture sample (texture asset) with the Lerp result and apply the custom UV. I feel that there’s a material node that exists to handle this, but I’m having difficulties narrowing it down. Hopefully, the image attached more accurately describes my intentions:

https://forums.unrealengine.com/attachment.php?attachmentid=101151&stc=1

I sincerely appreciate all advice and recommendations.

I will need a bit more detail about what you are trying to do since I can’t really make sense of what you are saying. You show a lerp that has been pasted in place with connections from nowehere. Generally a lerp and a texture sample are pretty different so we need to know what you hope to achieve to help.

Hello Ryan. Thank you for the prompt response. I just realized that mockup is terrible. My goal is to apply UV Input to the Output Imagery of the Lerp expression.

https://forums.unrealengine.com/attachment.php?attachmentid=101201&stc=1

I am sorry but I am still not getting it.

What is the blue box?
What is the UV data?
What is the lerp doing?

Can you make a regular sentence describing the what and the why of what you are doing?

Ie, custom UVs are usually used to optimize certain expressions by solving them on the vertex shader. But without knowing what you are doing with the custom UVs I cannot help.

Are you asking how to write code for a texture sample inside of the custom node?

I sincerely apologize as part of my challenge has been asking the right question. I’m working with UE4 4.11 Eye Shader. I’ve created my own Iris with material expressions and I want to use the texture output of the final material expression [which happens to be a Lerp], instead of Texture Sample Node with the UV output from Custom Mat Expression that applies refraction to the texture. However, the Texture Sample Node has a input for UVs, so I was seeking for a Material Node with inputs for UVs and texture input from material expression (the blue box) or other means.

What is the lerp for?

Lerps and textures are two completely different things so I am not sure what you mean still.

The texture sample node already has a “Tex” input, but this has to be a texture OBJECT. It can be a texture object parameter. There is no way to lerp between two texture parameter objects before they have been sampled, you need to sample both separately and then lerp them.

What do you mean by “apply the UV to the Lerp”?
The “Lerp” function does not take UV coordinates as inputs.
There is no way to “apply the UV to a Lerp.”

Can you describe the actual math you want the node to do?
Given inputs x, y, z, it calculates/uses those inputs to generate output w, using mathematical formula … what?

I have to admit I’m new to the Material Editor, Material Concepts and Terminology. I’m using the Lerps for masking purposes to control Color and PBR on Sclera, Iris, and Pupil areas. The Lerp outputs the result (iris) I want to apply the refraction UVs to. If there is a means to convert the result (iris) to texture object, then I could use Texture Sample Node to apply the UVs. I’m reviewing each node in the Material Reference and feel I’m close to a breakthrough. I sincerely appreciate you taking time to read and answer this post.

I think that what you are trying to do is to sample output of your material expression with given UVs, like a texture. Thing is that you can’t do that. your lerp output is already per-pixel value and you can’t sample it again within a scope of the same material.

If you want to apply any refraction, you can’t do that at the end, it has to be done in the beginning by adding to the UVs of your initial texture sample. Once a texture is sampled there is no such thing as changing the UVs or anything like that since from that point it is no longer even considered a texture, it is just considered a single color value returned for each UV position.

Thank you very much RyanB. [Lightbulb] Ahh, now I understand. I now have a plan of action. Kudos to you Sir!

Thanks to everyone who offered their insight. Your input is invaluable to me.