I’m generating a procedural mesh and attempting to texture each vertex. I’ve attempted to use the RGB channels but given shaders automatically lerp between values, I cannot sort out how to get multiple (i.e. more than 4, using RGBA) texture support for my basic terrain mesh.
I’ve read that there are no custom Vertex Attributes in other threads but it doesn’t seem likely, as Unity’s own Terrain tools support many (more than 4) textures. Is there any documentation on custom Vertex Attributes? I’ve been searching for 3 days on how to do this. I’ve watched all the tutorials on terrain painting I can find on youtube and ShaderGraph. Conceptually, any way to get this done?
Thanks!
PB
Unity’s system draws the terrain once for every four textures, and stores the texture weights into a texture, so it’s not pulling from the vertices for that information at all. OpenGL (and I suspect DX11 but I haven’t checked) have semantics for turning off vertex interpolation, but to properly blend textures across the face what you actually need to know is the values stored on the neighboring vertices, which you don’t have access to in the vertex shader. You could possibly fix that in the geometry shader, but that would be a bad idea for many reasons.
What I do in MegaSplat is basically store barycentric weights for each vertex and use them to recover the original values of the three vertices of a triangle, giving me my original index’s for sampling. Then for each “layer” of texture, I sample the three texture sets (one for each vertex) and use the barycentric weights to blend them.