- Home /
Probuilder Vertex Colors do not match Vertex Palette colors in Linear rendering.
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
I'm seeing the same thing. I'm using linear color space, and the results of vertex coloring match what happens when I have my own shaders, but don't append .linear
when I send the color to the shader. I'm also using the Universal Render Pipeline.
Answer by Why485 · Jul 07, 2020 at 02:45 PM
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[i] = col;
To this:
colors[i] = 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 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/
Your answer
Follow this Question
Related Questions
Painted Vertices are Blockly, Looking to smooth them Out 1 Answer
Banding artifacts with linear color space and color correction image effect 1 Answer
Changes to Mesh Vertex Colors Reset on Build 1 Answer
Weird Vertex Shader Behaviour 0 Answers
How to prevent frustum culling when using a vertex shader? 2 Answers