Using mesh with multiple color sets

I have a mesh in Maya which has multiple colour sets
8211192--1071783--upload_2022-6-16_18-1-33.png

The manual seems to say you can use multiple colour semantics

But when I try to include the second set in Appdata

            struct appdata
            {
                float4 vertex : POSITION;
                float4 uv : TEXCOORD0;
                float2 lightUV : TEXCOORD1;
                half3 normal : NORMAL;
                half4 color : COLOR;
                half4 color1 : COLOR1;
            };

I get the error “Vertex program ‘vert’: unknown input semantics COLOR/1”
I read somewhere that that error is because Appdata only supports a single COLOR semantic.
SurfaceShader Semantic COLOR1 not working - Unity Answers

Does that mean that, although shaderlab supports multiple COLOR semantics, there is no way to import multiple vertex color sets from a mesh…or am I missing something?

As far as I know, yes you can only have one COLOR semantic (though maybe the experimental custom vertex data settings feature might be able to do that). But this isn’t a big deal, you can instead store those colors in other UV channels and simply use TEXCOORD# semantic instead.

Thanks Invertex,
I’m still not sure how I read the color data from the model though, if I can’t include the COLOR1 set in appdata. How do I get it from the mesh into a TEXCOORD.

(Just to be clear, the color sets I want to work with are already baked into the mesh (in maya). So the problem I’m having is more about reading them from the mesh, rather than working with them once they are in the shader.)

TEXCOORD are the UV channels. So if you can instead bake them to a UV channel instead of Color channel in Maya, then you’ll be able to get those values in your shader. You may have to look for a Maya script to transfer color to UV channels as this is a more unorthodox usage of UV channels that most tools don’t make an option for.

1 Like