PBRMaterial and manually set Albedo Color gets changed by Babylon?

setting albedo color of a PBRMaterial gets overriden by BabylonJS?

const material = new PBRMaterial('logo', scene);
material.albedoColor = Color3.FromHexString('#F8981D');

but its visibly appearing too bright and wrong shade

opening inspector shows albedo color as FCCA5F (definitely brighter and slightly different shade) which is not what i’ve set.
how was this calculated and why is babylon overriding color set by user?

if i again set albedo color using inspector to F8981D, then it appears exactly as it should
but then if i check mesh.material.albedoColor.toHexString(), it shows #F05202?!?

version: babylonjs 5.0.0-rc.12

So what you set by code is in linear space (f8981d) but when open the inspector it displays it in gamma space for convenience (fcca5f) but under the hood the actual linear space value will still be used by the material.

The color should not change when opening/closing the inspector.

1 Like

ok, that explains one thing.

follow-up question: i’ve used color picker from on an external image to get hex code of the color.
if i use that hex code to set material.albedoColor, its waay too bright and wrong shade.
but if i use that hex color in inspector, its perfectly correct.

so given that colors in my case are ok in gamma space, but incorrect in linear space, how can i set color from hex in gamma space programmatically?

Color3.FromHexString(’#F8981D’).toLinearSpace(); or toGammaSpace() if you ever needs it :slight_smile:

3 Likes

aaah…of course its simple, just need to babylon better :slight_smile:
thanks!