# RGB and Hex values entered for a color3 result in different color than what was used

**URL:** <https://forum.babylonjs.com/t/rgb-and-hex-values-entered-for-a-color3-result-in-different-color-than-what-was-used/25243>\
**Category:** Questions\
**Created:** [November 13, 2021, 4:47am UTC](https://forum.babylonjs.com/t/rgb-and-hex-values-entered-for-a-color3-result-in-different-color-than-what-was-used/25243 "2021-11-13T04:47:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![douglasg14b](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/douglasg14b/32/19926_2.png) [@douglasg14b](https://forum.babylonjs.com/u/douglasg14b)\
**Post date:** [November 13, 2021, 4:47am UTC](https://forum.babylonjs.com/t/rgb-and-hex-values-entered-for-a-color3-result-in-different-color-than-what-was-used/25243/1 "2021-11-13T04:47:47Z")

</div>

This is weird…

The color entered for the material is not the color in the inspector.

- Playground: [https://playground.babylonjs.com/#2FDQT5#1227](https://playground.babylonjs.com/#2FDQT5#1227)
- Color Hex: `#82D52F`
- Color RGB: `(130, 213, 47)`

```auto
    var pbr = new BABYLON.PBRMetallicRoughnessMaterial("pbr", scene);
    sphere.material = pbr;

    pbr.baseColor = BABYLON.Color3.FromInts(130, 213, 47);
    //pbr.baseColor = BABYLON.Color3.FromHexString('#82D52F'); // <--- or use
    
    pbr.metallic = 0;
    pbr.roughness = 1.0;

```

**What is should look like:**

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/2/b/2bd49684068d3fa15129fd596e6e3c2b0c014bec.png)

**What it actually looks like:**

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/0/9/09faf44ea5c5dce4c8f7c54c1ced4ffd0e0e2a75.png)

---

<div class="post-metadata">

**Author:** ![inteja](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/inteja/32/22553_2.png) [@inteja](https://forum.babylonjs.com/u/inteja)\
**Post date:** [November 13, 2021, 4:58am UTC](https://forum.babylonjs.com/t/rgb-and-hex-values-entered-for-a-color3-result-in-different-color-than-what-was-used/25243/2 "2021-11-13T04:58:52Z")

</div>

You need to convert to linear space as best explained by @Evgeni_Popov here: [PBRMaterial Albedo Color RGB in Playground Code Different than RGB Shown in Inspector and on Object - #5 by Evgeni\_Popov](https://forum.babylonjs.com/t/pbrmaterial-albedo-color-rgb-in-playground-code-different-than-rgb-shown-in-inspector-and-on-object/9675/5)

---

<div class="post-metadata">

**Author:** ![douglasg14b](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/douglasg14b/32/19926_2.png) [@douglasg14b](https://forum.babylonjs.com/u/douglasg14b)\
**Post date:** [November 13, 2021, 5:09am UTC](https://forum.babylonjs.com/t/rgb-and-hex-values-entered-for-a-color3-result-in-different-color-than-what-was-used/25243/3 "2021-11-13T05:09:42Z")

</div>

Thanks, that’s the problem.

* * *

**For future readers, in short form:**

1. Colors are made in sRGB space, they need to be converted to linear space
2. Do this with `Color3.toLinearSpace()`
3. Example:

```auto
BABYLON.Color3.FromHexString('#82D52F').toLinearSpace();`

```
