Setting RGBA color of a material

I am trying to set the color 32 of a material and so far I have found that the best way to do is - colorcode/255. But it somehow does not come to the requried rgba color I need when I check the inspector window. How do I solve this?

myMat.albedoColor = new BABYLON.Color3(76/255, 91/255, 99/255);

For RGBA there is BABYLON.Color4, like this:

myMat.albedoColor = new BABYLON.Color4(76/255, 91/255, 99/255, 0.8);

Thank you, I tried that but it takes completely different color code as shown below in the image.

ColorCode

There is the tip below - convert your color toLinearSpace (or maybe to GammaSpace depending your specific settings).
Something like
myMat.albedoColor = new BABYLON.Color4(76/255, 91/255, 99/255, 0.8).toLinearSpace();

See also Wrong albedo colors

1 Like

That actually worked. Really weird :sweat_smile:
Thank you.

1 Like