Hello,
Probuilder vetex colors on my game object do not match the color selected from Probuilder color palette.
I am using Linear renedering. I understand this color accuracy is an issue with Linear rendering and vertex colors.
Is there a shader for Probuilder to correct this?
The shader I am using is Probuilder/DiffuseVetexColor.
Any help would be appreciated,
Raymond
ProBuilder should fix this themselves, because it’s IMO an oversight that it does not apply vertex colors correctly when using the linear color space. Vertex colors aren’t gamma corrected when in linear color space. If you are creating your own vertex colors in your own meshes, you solve this by using the .linear
property on the color when you set the vertex color.
This is a simple one (technically two) line fix in the Probuilder source code. Goto the file Editor\EditorCore\VertexColorPalette.cs
and change lines 182 and 194 from this:
colors *= col;
*
To this:
colors *= PlayerSettings.colorSpace == ColorSpace.Linear ? col.linear : col;
*
This new code will make it so that if you are in linear color space, it will apply the correct gamma correction to the vertex. This will not however update any previously assigned vertex colors. You would have to go in and re-assign all the vertex colors yourself, or create some script that will take the current vertex color and then convert it to a linear color. Neither are great solutions, unfortunately.
Another alternative is to write a shader which automatically gamma corrects the vertex colors based on the assumption that vertex colors are always in the gamma color space. This would retroactively fix any colors you apply. [See this thread for the function to call in the shader world][1] to convert the colors.
EDIT: This has been recognized in a ProBuilder thread.
_https://forum.unity.com/threads/probuilder-applying-incorrect-vertex-colors-when-using-linear-colorspace.927107/*_
_[1]: https://forum.unity.com/threads/using-only-vertex-colors-result-in-faded-too-light-colors.541565/#post-3571304*_