Vertex Color precision on various devices.

I’m making a shader in which the R channel of Vertex Color is used as a bit mask with 8 flags, with which I want to mark the places where different textures should apply. But, I have concerns about the accuracy of vertex color on various devices. How likely is it that in different stressful situations, or for example on different devices, my vertex color may not be accurate enough, causing various visual artifacts?

Data from vertics is not compressed like textures. so inputs of vertex shader everything will be fine.
but everything else depend on platform and shader code

Vertex colors in Unity, out of the box, are either 8 bit/channel, 0…1 range (Color32) or 32 bit/channel, full float (Color). You can also make the Mesh colors attribute your own custom format, if you really want to, using Mesh scripting API.

So yes, it all should work fine. Use default Color32 (Mesh.colors32), that way you get 32 bits total (8 bits/channel). In your shader you will get a value in 0…1 range for each channel, so multiply that by 255 to get into 0…255 range.

And then, unless you are on WebGL 1.0 or OpenGL ES 2.0 (both of these are no longer supported by Unity, I think?), you can cast to an integer and do bit mask operations to check your “flags” etc.

1 Like