◩ Graphics & images

The RGB model and additive color: how a screen creates colors

Why three lights are enough to reproduce almost any color: additive mixing, metamerism, hexadecimal notation and the limits of the RGB model on screens.

Every screen we use, from phone to television, shows millions of colors using just three kinds of light: red, green and blue. This is not an arbitrary technological trick but a consequence of how human vision works. Understanding the link helps you interpret RGB values correctly, not be surprised when the same color code looks different on two devices, and know what RGB cannot do.

Three receptors, three primaries

The human retina, in normal lighting, perceives color thanks to three types of cones, sensitive in different ways to short, medium and long wavelengths. The brain does not receive the full spectrum of the light, only three signals, one per cone type.

A surprising fact follows: two lights with very different spectra can look identical if they stimulate the three cones in the same way. This phenomenon is called metamerism and it underpins all color reproduction. The screen does not recreate the spectrum of the sunset you photographed: it produces a mix of three lights that "fools" the cones in the same way.

Additive mixing

Adding colored lights together is called additive mixing. Starting from darkness (no light), you add the primaries:

Combination Perceived result
red + green yellow
green + blue cyan
blue + red magenta
red + green + blue at maximum white
no light black

The yellow you see on a monitor contains no "yellow" light at all: it is red and green together. Holding a magnifying glass up to many screens reveals the separate subpixels, and the yellow part of the image shows only red and green subpixels lit.

How RGB values are written

With 8 bits per channel each component runs from 0 to 255. The most common notations are:

  • Decimal: rgb(30, 90, 168).
  • Hexadecimal: #1E5AA8, where each pair of digits is a channel (1E = 30, 5A = 90, A8 = 168).
  • Short hexadecimal: #F80 equals #FF8800, because each digit is doubled.
  • Normalised: values from 0.0 to 1.0, used in much 3D software and in shaders.

Reading a hex code at a glance is a small but very useful skill. If the first byte is high and the others low, the color leans red; if all three are equal, it is a gray; if they are all close to FF, it is a light, low-saturation color.

The problem: which red?

An RGB value on its own does not identify a precise color. rgb(255, 0, 0) means "the most intense red this device can produce." But the red of a budget panel and that of a professional display are physically different.

To give the numbers an absolute meaning you must specify:

  1. The coordinates of the three primaries, that is, which red, which green and which blue.
  2. The white point, that is, which white you get with all three channels at maximum (for example D65, a standard approximating average daylight).
  3. The transfer curve, that is, how the numbers translate into light intensity.

Together these three pieces of information define a color space, such as sRGB or Display P3. A file with no color space indicated is normally interpreted as sRGB, the reference standard for the web and most consumer devices.

The numbers are not proportional to light

A very common mistake is to think that rgb(128, 128, 128) emits half the light of rgb(255, 255, 255). It does not: in sRGB the values are encoded with a non-linear curve (the gamma), designed to distribute the available levels better according to the eye's sensitivity. Gray 128 emits about a fifth of the light of white, yet it looks halfway.

This non-linearity has practical consequences: mixing or blending colors by taking the arithmetic mean of sRGB values produces transitions darker than expected. The issue is covered in detail in the discussion of gamma correction.

What RGB cannot show

The triangle formed by the three primaries, drawn on a chromaticity diagram, encloses all the colors the screen can produce: its gamut. Some real colors fall outside:

  • certain very saturated greens and cyans, like those of some lagoons or some lasers;
  • the deepest spectral violets;
  • some fluorescent colors in paints and fabrics.

No combination of positive values of the three primaries can reproduce them. Wide-gamut spaces push the triangle's corners further out and include more of them, but no three-primary screen covers every visible color.

Practical advice

  • When someone gives you a color as an RGB code, ask which color space it is defined in.
  • For critical visual comparisons, use a calibrated screen and consistent lighting.
  • Do not use "pure" RGB values (255, 0, 0) as interface colors: they look harsh and vary a lot from screen to screen.
  • For gradients computed in code, work in a linear or perceptual space and convert at the end.

In short

  • The screen exploits the retina's three cone types: three lights suffice thanks to metamerism.
  • Additive mixing starts from black and adds light: red and green make yellow, all three make white.
  • An RGB value has a precise meaning only within a color space (primaries, white, curve).
  • sRGB values are not proportional to the light emitted.
  • Every screen has a limited gamut: some real colors stay outside it.
MM
Marco Marzaduri

Marco Marzaduri works in cybersecurity, digital forensics and web development. A computer science graduate, he combines rigorous technical analysis with attention to the people who use technology.

Read also