RGB to GLSL vec3
A plain divide by 255 keeps the colour encoded. Reach for the linear form when the value takes part in lighting maths.
vec3(0.259, 0.529, 0.961)Paste a RGB value — other formats work too.
Need every format at once? Open in the full picker
Worked examples
Common colours converted from RGB to GLSL vec3, computed with the same engine the picker uses.
| Colour | RGB | GLSL vec3 | Copy |
|---|---|---|---|
| Pure red | rgb(255 0 0) | vec3(1.0, 0.0, 0.0) | |
| Pure green | rgb(0 255 0) | vec3(0.0, 1.0, 0.0) | |
| Pure blue | rgb(0 0 255) | vec3(0.0, 0.0, 1.0) | |
| White | rgb(255 255 255) | vec3(1.0) | |
| Mid grey | rgb(128 128 128) | vec3(0.502) | |
| Black | rgb(0 0 0) | vec3(0.0) | |
| Interface blue | rgb(66 135 245) | vec3(0.259, 0.529, 0.961) | |
| Success green | rgb(34 197 94) | vec3(0.133, 0.773, 0.369) | |
| Danger red | rgb(239 68 68) | vec3(0.937, 0.267, 0.267) | |
| Warning amber | rgb(245 158 11) | vec3(0.961, 0.62, 0.043) | |
| Editor black | rgb(30 30 30) | vec3(0.118) | |
| Warm sand | rgb(233 196 106) | vec3(0.914, 0.769, 0.416) |
How the conversion works
A plain divide by 255 keeps the colour encoded. Reach for the linear form when the value takes part in lighting maths.
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.