hex to HLSL float3
Identical math to GLSL, different spelling. Unity shader code often uses fixed3 or half3 for colors, which take the same values.
Paste a hex value. Other formats work too.
float3(0.0, 0.671, 0.906)Need every format at once? Open in the full picker
Worked examples
Common colors converted from hex to HLSL float3, computed with the same engine the picker uses.
| Color | hex | HLSL float3 | Copy |
|---|---|---|---|
| Pure red | #ff0000 | float3(1.0, 0.0, 0.0) | |
| Pure green | #00ff00 | float3(0.0, 1.0, 0.0) | |
| Pure blue | #0000ff | float3(0.0, 0.0, 1.0) | |
| White | #ffffff | float3(1.0) | |
| Mid gray | #808080 | float3(0.502) | |
| Black | #000000 | float3(0.0) | |
| Interface blue | #4287f5 | float3(0.259, 0.529, 0.961) | |
| Success green | #22c55e | float3(0.133, 0.773, 0.369) | |
| Danger red | #ef4444 | float3(0.937, 0.267, 0.267) | |
| Warning amber | #f59e0b | float3(0.961, 0.62, 0.043) | |
| Editor black | #1e1e1e | float3(0.118) | |
| Warm sand | #e9c46a | float3(0.914, 0.769, 0.416) |
How the conversion works
Identical math to GLSL, different spelling. Unity shader code often uses fixed3 or half3 for colors, 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 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.