- Home /
From within the frag function of a shader, can you access the uv values of vertices?
I don't want the interpolated uv that is passed into the frag function. Rather, I'd prefer to manually calculate that. Possible?
fixed4 frag (v2f input) : SV_Target
{
// How to get these values? (if they are accessible)
float2 vertexA = float2(0.3, 0.5);
float2 vertexB = float2(0.5, 0.5);
// Do some manual lerp.
float2 l = lerp(vertexA, vertexB, 0.5);
fixed4 col = tex2D(_MainTex, l);
return col;
}
Not sure I understand the question: the vert function only processes vertices. The frag function processes all fragments. That's why texture samplers in the frag shader generally use interpolated UV values, because they don't get explicitly specified for every fragment - only for vertices.
But you can supply any values you want to the texture sampler - if you want to explicitly calculate some other UV coordinates per fragment, that's fine.
Your answer
Follow this Question
Related Questions
Combine Vertex / Fragment and Surface Shader 0 Answers
Can you specify both Surface and Vertex/Fragment shaders? 3 Answers
Data for each vertex from Material properties? 1 Answer
Mobile performance of splat map shader with distance blending 0 Answers
What is the meaning of a vertex shader for a post-processing shader? 1 Answer