hex to HLSL float3

Identical maths to GLSL, different spelling. Unity shader code often uses fixed3 or half3 for colours, which take the same values.

Hue
Alpha
100%
HLSL float3
float3(0.259, 0.529, 0.961)

Paste a hex value — other formats work too.

Need every format at once? Open in the full picker

Worked examples

Common colours converted from hex to HLSL float3, computed with the same engine the picker uses.

ColourhexHLSL float3Copy
Pure red#ff0000float3(1.0, 0.0, 0.0)
Pure green#00ff00float3(0.0, 1.0, 0.0)
Pure blue#0000fffloat3(0.0, 0.0, 1.0)
White#fffffffloat3(1.0)
Mid grey#808080float3(0.502)
Black#000000float3(0.0)
Interface blue#4287f5float3(0.259, 0.529, 0.961)
Success green#22c55efloat3(0.133, 0.773, 0.369)
Danger red#ef4444float3(0.937, 0.267, 0.267)
Warning amber#f59e0bfloat3(0.961, 0.62, 0.043)
Editor black#1e1e1efloat3(0.118)
Warm sand#e9c46afloat3(0.914, 0.769, 0.416)

How the conversion works

Identical maths to GLSL, different spelling. Unity shader code often uses fixed3 or half3 for colours, which take the same values.

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 colour that cannot be represented in the target format is handled deliberately rather than by accident.

When the source describes a colour 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 colours.

Related conversions