- Home /
Changing Shaders HDR Color results in different Color.
I want to change the color of single objects with a shared material via MaterialPropertyBlocks. For example I've made a simple Shader for testing: Ive created a material using my shader and setup two spheres in my scene and colored them blue.
Now im trying to use a MaterialPropertyBlock to change the color of the right sphere to the exact same color. The outcome is different:
The script changing the color looks like this:
private Renderer _renderer;
private MaterialPropertyBlock _propBlock;
[ColorUsage(true, true)]
public Color blue;
private void Awake()
{
_propBlock = new MaterialPropertyBlock();
_renderer = GetComponent<Renderer>();
}
void Start()
{
setObjectsColor();
}
private void setObjectsColor()
{
_renderer.GetPropertyBlock(_propBlock);
_propBlock.SetColor("_Color", blue);
_renderer.SetPropertyBlock(_propBlock);
}
Ive noticed when changing the color mode in the Shader from HDR to Default, it results in the purple Color from my second screen. Changing any value in the color picker then will immediately change the color to a Default non glowing Color. Im not sure if theres some internal conversion going on im missing.
Hope its a simple mistake from my side and someone can help me.
Answer by xxxDOSxxx · Nov 08, 2020 at 01:27 PM
I have the same problem, have you found a solution?
I figured out that the Exposed Color Parameter is at fault. If you use a Vector4 instead you wont have to change the way it works and still get the desired result.