Ok, this is very strange, let me explain what I’m doing and what I see happening:
- I have a shader with a _Color that is chosen via the editor color picker
- In code I read this value out as an RGB color and it appears to be converted to RGB correctly
- In code I stick that color into a mesh vertex color
- In my shader instead of using the _Color that was picked by the HSV color picker I instead use the color from the vertex color - this should be the same color!
- Now, even though technically everything should be the same, my shader looks different (brighter, washed out)
Here are some other things I’ve tried:
Different semantics for the vertex color
Binding the vertex color to the tangent stream of a mesh instead of the color stream
Hardcoding the color value into the albedo in the shader - still wrong!
Let me explain that last one in a bit of detail:
According to the HSV color picker my values are H: 95, S: 166, V 205
If I get material.color in code this gives me the rgb color approx 0.49, 0.8, 0.21 (According to online web conversion pages this is correct)
If in my shader (Surface Shader) I assign Albedo to this rgb color it looks significantly different than it does if I set Albedo to _Color, even though these should be the same!
It looks to me that if in my code I get the material color I get a different value than the shader is getting from _Color - somehow the color conversion is different. So in Code the color is converting to 0.49, 0.8, 0.21, but in the shader it ends up more like 0.3, 0.7, 0.1 or something like that. Somehow there’s something strange about how _Color is used in the shader - it’s converted differently than standard HSV conversion or has something extra applied to it somehow…
I’m using 5.0.0f4
Again, to reproduce this do the following:
- Read the material color out in code and print it out
- Change your shader to hardcode Albedo to the RGB values from 1, instead of using _Color
- It looks different, even though it should look identical!
Any idea? It seems like a straight up bug.