Material color mask based on UV coordinates?

Hey,

I’m using flat colors for most of my meshes, but I need multiple colors per mesh. To achieve that, I separated the UVs of my meshes based on their color and arranged them accordingly in a 0 to 1 UV space (see image).

47018-checkeruvs.png

However, I can’t use a texture since I need to be able to set the colors via parameters in the material. So I have to somehow mask/lerp the colors based on UV coordinates or a control texture of some kind.

Some of the starter content materials, like the chair or lamp, use the R/G/B/A channels of a texture to separate colors. But I need much more than only 4 colors, so this isn’t an option for me.

Does anyone know a good way to set this up? Any ideas would be appreciated!

It appears there is no elegant way to do this, so I ended up using the RGBA channels of a control texture (see below) and isolated the individual squares by adding and subtracting the channels. It looks messy, but performance-wise it doesn’t seem to be an issue and definitely beats having 20+ material slots per character.

47474-controltexture.png

Hello, this looks exactly like what I’m looking for:) However, I cannot see the nodes in the picture. I know it has been a couple of years, but maybe you could share this solution once more?
Anyway thanks for the tip!