how to disable uv interpolation

is it possible to get the uv of the nearest vertex rather than the interpolated one in shader graph?
i am triying to use the uvs of a mesh to specifi which texture from a texture2DArray the shader should get but because uvs are interpolated it also uses other textures between textures. if it is not possible to disable uv interpolation, is it perhaps possible to pass data through a mesh thad does not get interpolated between vertices?

Hey, did you get this working?

Hi. I’m at the exactly same situation… any luck?

I need more information about what you’re doing - because what you’re describing doesn’t sound like it would work to me. A vertex has a set UV value and the next vertex over has another value. Typically, there’s interpolation between them as you say. If there’s no interpolation, what do you get in between them? Are you hoping that each triangle with have a single UV value?

I assume this is similar to my situation. I made a triplanar multi texture shader using texture2Darrays for my voxel terrain meshes. My solution is not elegant and I would like a better solution.
Since UVs interpolate, for each triangle, I save all 3 vertices’ texture indices in the first 3 uv values and then I store a blend amount of 1 or 0 to the next 3 uv values based on which vertex it is. Here is how I store the indices and blend amounts for all 3 vertices in the uvs:
vertex 0 =
uv0 = vector4(0, 0, vertex0 tex index, vertex1 tex index) // first 2 values are not used (i forget why I had to)
uv1 = vector4(0, 0, vertex2 tex index, vertex0 blend amount)
uv2 = vector4(0, 0, vertex1 blend amount, vertex2 blend amount)
Therefore, for all 3 vertices in a triangle, the first 3 index values would be the same (i.e. 2, 2, 5 if first 2 vertices use texture 2 and the 3rd uses texture 5) across all vertices, but the blend amounts for vertex0 would be 1, 0, 0 and vertex1 would be 0, 1, 0 and vertex2 would be 0, 0, 1
Its messy, but the shader ends up blending the blend amounts and keeping the index values all the same by doing 3 texture lookups with the indices and blending using the blend amount values.

The fragment would just choose the nearest vertex I believe, but shader graph needs the no interpolation feature for many things like this, or else it’ll make texturing based on index create bleeding of the interpolated indices.

The OP needed the same thing as my request, a long while ago:

It’s a simple keyword to prepend to fields on custom interpolators. For reasons beyond my comprehension, the Shadergraph team has refused to add this feature that should take about 10 minutes to implement.

1 Like