Hi, I want to create a shader where each vertex has an index baked into color or uv that specifies which texture to use, then blend the triangle’s 3 vertices’ respective textures.
However, because all vertex data is interpolated, I can’t figure out a way of extracting whole numbers back out from the interpolated data.
For example,
vertex1: texture 3,
vertex2: texture 18,
vertex3: texture 43
I’ve considered packing this number into a different channel for each vertex, so
vertex1: (3,0,0),
vertex2: (0,18,0)
vertex3: (0,0,43)
but in the fragment shader they’re still interpolated and I can’t restore them as their original whole numbers.
In the unity docs, they show passing a Vertex ID into a custom interpolator,
but I figure that just gets interpolated too. And, it would only be useful if somebody knows a way of accessing vertex data in the fragment shader using a vertex ID.
Any ideas would be super helpful. If I could get something like this to work it would allow my smooth voxel program to support biomes, which would be very cool :). Unfortunately, I’ve been pretty stuck here…
I feel like there’s either gotta be an obvious way to do this, or a really clever one, lol.
Thanks!