So i was trying to make MultiMeshInstance3D create faces with different textures through shaders when i stumbled upon this issue. my original code had a sampler2D array for holding different textures. i tried to minimize and simplify my code to find the issue. in this picture is the minimized version of the shader used to recreate the issue:
and how it looks:
the idea is simple, using Multimesh.SetInstanceCustomData(ID, new Color(0f,0f,0f,0f));
(which is written in c# btw), we tell the shader which texture to use, when INSTANCE_CUSTOM.r
is 0, it uses the first texture and when it's 1, the second texture.
here is what happens when we call Multimesh.SetInstanceCustomData(ID, new Color(0f,0f,0f,0f));
on all instances:
the shader uses the first material. now when i use Multimesh.SetInstanceCustomData(ID, new Color(1f,0f,0f,0f));
this happens:
all the faces are Zfighting with what seems to be the default material. as you can see, both of the materials are the same, the code is the same, the MultiMeshInstance3D is the same, the only thing that changed was the INSTANCE_CUSTOM
we pass to the shader. any number other than zero will cause this issue.
I'm new to shaders so i don't really know whats going on. any help is much appreciated.
Thanks in advance!