GLSL vec3 to hex

This assumes the vector holds encoded values. If it came out of lighting math it is linear, and you need the linear reading to get the right hex.

Paste a GLSL vec3 value. Other formats work too.

hex
#00abe7

Need every format at once? Open in the full picker

Worked examples

Common colors converted from GLSL vec3 to hex, computed with the same engine the picker uses.

ColorGLSL vec3hexCopy
Pure redvec3(1.0, 0.0, 0.0)#ff0000
Pure greenvec3(0.0, 1.0, 0.0)#00ff00
Pure bluevec3(0.0, 0.0, 1.0)#0000ff
Whitevec3(1.0)#ffffff
Mid grayvec3(0.502)#808080
Blackvec3(0.0)#000000
Interface bluevec3(0.259, 0.529, 0.961)#4287f5
Success greenvec3(0.133, 0.773, 0.369)#22c55e
Danger redvec3(0.937, 0.267, 0.267)#ef4444
Warning ambervec3(0.961, 0.62, 0.043)#f59e0b
Editor blackvec3(0.118)#1e1e1e
Warm sandvec3(0.914, 0.769, 0.416)#e9c46a

How the conversion works

This assumes the vector holds encoded values. If it came out of lighting math it is linear, and you need the linear reading to get the right hex.

Both formats are computed from a single canonical representation (CIE XYZ with a D65 white point, held in floating point) rather than by chaining one format into the next. That matters because chained conversions accumulate rounding error, and because it means a color that cannot be represented in the target format is handled deliberately rather than by accident.

When the source describes a color outside the target's gamut, chroma is reduced in OKLCh while lightness and hue are held, following the CSS Color 4 gamut mapping algorithm. Clipping each channel independently would be simpler but visibly shifts hue on saturated colors.

Related conversions