Problem: copying rgb and hex value into threejs result in different colors when using Blender’s color picker. Even though ThreeJS is configured to (1) be in sRGB color space, and (2) to convert the gamma corrected hex into linear-sRGB space, and (3) no tonemapping.
I’m assuming that either (1) I don’t understand color spaces well enough or (2) I have missed some configuration that is causing it to not behave correctly or (3) there’s a bug in Blender or ThreeJS (unlikely)
-
I’m viewing a png image in sRGB color space in Blender’s Texture Painter image viewer
-
I use Blender’s color picker to sample a color in the image
-
I copy the RGB value and the hex value into my ThreeJS project. The RGB value is (.537,.992,.984) and the hex is 0x89FDFB
According to Blender docs, the color picker’s hex value is gamma corrected: Color Picker - Blender 4.2 Manual
Here is an image from Blender:
Here is the ThreeJS code:
const color = new THREE.Color().setHex(0x89FDFB,THREE.SRGBColorSpace);
const color2 = new THREE.Color().setRGB(.537, .992, .984);
return (
<>
{/* the 'flat' argument removes tonemapping*/}
<Canvas flat>
<mesh>
<boxGeometry />
<meshBasicMaterial color={color}/>
</mesh>
<mesh position={[2,2,0]}>
<boxGeometry />
<meshBasicMaterial color={color2} />
</mesh>
</Canvas>
</>
)
Versions:
-
Blender 4.2.3
-
react-three/fiber 8.17.8
-
react-three/postprocessing 2.16.3
-
three 0.168.0