All those colors, so why is it gray?
Because it is holding more than your screen can show.
Part three This picks up where So, the colors are in the computer? left off. That guide covered how a color becomes numbers: bits, the budget they make, and the transfer functions that decide where it gets spent. If you have not read it, start there.
Open a file straight off a cinema camera and it looks washed out, like someone left the picture in the sun. It is not broken. It is gray because it is holding more than your screen can show.
Every curve in part two assumed one thing: the brightest thing in the picture is the white of your screen. Point a camera at a room with a window and that stops being true. The sky outside, a lamp, the glint off a car are all far brighter than white, and they are colors too.
Log squeezes all of that into 0 to 1 so none of it gets thrown away, and the gray is what that squeeze looks like before anything has decided where white goes. Float goes further and drops the ceiling altogether. Then, with the whole scene in the computer, we do the math on it in a working space where the math is actually right.
Log, and holding a whole scene
Gamma solved storage for pictures already finished for a screen. A camera pointed at the world sees far more range than any screen shows, and log is the same budgeting trick stretched to hold it.
Gamma has an assumption baked in: the brightest thing in the picture is display white. For a finished image that is true by definition. For a camera it is absurd. Point one at a room with a window and the sunlit wall outside is thousands of times brighter than the shadow under the desk.
Log encoding bends a whole scene’s worth of light, twelve to seventeen stops of it, into a storable 0 to 1, so each stop gets roughly the same slice of the codes, and you decide later which of those stops becomes white. Every vendor publishes where middle gray lands on its curve, because exposure is set relative to it.
This is the line between two words you will hear constantly. Display-referred means already cooked for a screen. Scene-referred means the numbers describe how much light was there, with every decision about the screen still deferred. Log stores scene-referred light.
Interns get this wrong Log footage looks flat and gray. That is on purpose. It is holding its dynamic range in reserve, waiting for a transform to decide what becomes white. Grading it as if it were a finished picture, or slapping a display curve on it and calling it done, throws away the reason it was shot that way.
| curve | code 0-1 | 10-bit code | codes per stop |
|---|
HDR: when the display gets a range too
[Every curve so far is relative: 1.0 means “as bright as this display goes”. PQ is absolute: each code means a specific number of nits, up to 10,000, and its shape comes from a model of human contrast sensitivity rather than from a CRT. HLG is the broadcast compromise: relative, gamma-like at the bottom and log at the top, so it still looks reasonable on an SDR set.]
The widget is a simulation, and honestly so: a browser canvas is 8-bit. What is there is a synthetic scene held as floats in memory, with detail from about 0.0005 up past 3.5, and a switch that runs it through the destructive part of an 8-bit export first: clamp to 0 to 1, round to 256 codes. Range you cannot see right now is not range you do not have. Until you clamp.
[Almost everything the widget above leans on traces back to Paul Debevec. In 1997, with Jitendra Malik, he showed how to take a bracket of ordinary photographs at different exposures, work out the camera’s response curve from the photos themselves, and merge them into one radiance map: a single image whose numbers are proportional to the light in the scene, from the deepest shadow to the sun. Scene-referred, before most of us had the word for it. A year later he used those maps to light computer graphics, photographing a mirrored ball to capture all the light arriving at one point and wrapping it around a synthetic object. That is image-based lighting, and the HDRI you drop into a dome light today is its direct descendant. His light probe of the Uffizi Gallery in Florence, assembled in 1999 from eighteen photographs and used to light the middle of his short film Fiat Lux, spent years as one of the standard test environments in rendering; if you learned 3D in the 2000s, you have probably seen a chrome sphere reflecting those arches. His pages are still some of the clearest writing on the subject. A few of them are in Extra reading below.]
The accuracy of numbers.
As you likely saw in the widget in part two, floating point numbers do not spread its values evenly. The gap between neighbors doubles every power of two, so precision falls off the farther you get from zero, and for light that turns out to be very convienent in how light is relevant to us, the humans experiencing the light. Unfortunatly this convienence comes at a cost, and that is accuracy. When doing math with these non-perfect numbers it is possible to achieve to do math the computer is unable to represent.
These errors are commonly referred to as ‘floating point errors’. While it does seem a little escoteric, if not handled with care, these errors can have some quite serious concequences. Including a missile defense system error that resulted in the death of 28 service members.
So, these floating point numbers, how are they built? Well we divide our bits up into [How a float is built: a sign bit, an exponent that picks the power of two, and a mantissa that picks a position within it. A half float has 5 exponent bits and 10 mantissa bits, so every power of two, every stop, gets the same 1024 values, across about 30 stops. Between 1 and 2 the gap is about 0.001. Between 1024 and 2048 it is 1. Between 32,768 and 65,504 it is 32.]
[The twist: the absolute gap grows, but the relative gap stays the same, about a tenth of a percent in half. Equal steps per stop is the definition of a log encoding. A float is a piecewise-linear log curve with the curve built into the number format, which is why ACEScg can be stored linear in a half-float EXR without the banding linear integers suffer from, as part two showed. This is also why the log curve above is not needed once the numbers are float.]
[What floats buy beyond precision: values above 1.0, so a highlight can be brighter than white, and values below 0, which in a linear wide-gamut space are colors outside the primaries. Link back to the previous guide’s imaginary primaries.]
[Denormals near zero, and why the bottom of the half range fades out gradually instead of stopping dead. One sentence, for the computer scientists.]
- 32-bitsingle float
- 32 bits: 1 sign, 8 exponent, 23 mantissa. The 32-bit format in the bits widget above, and what renderers and compositors do their math in. About four billion values, topping out near 3.4 × 1038.
- 16-bithalf float
- 16 bits: 1 sign, 5 exponent, 10 mantissa. The 16-bit format in the bits widget above, and what a half-float EXR stores. Tops out at 65,504.
- 8-bitinteger
- Not a float. 256 whole numbers, 0 to 255, divided by 255 to read as 0 to 1. Evenly spaced, and nothing past 1.0. JPEG, PNG and most of the web.
[Zoom in on any single number and the two formats part ways. Half runs out of ticks first, single holds on longer, and neither ever lands exactly on most numbers you can type.]
| holds exactly | off by | gap to next | |
|---|---|---|---|
| true | 0 | none | |
| 32-bitsingle float | |||
| 16-bithalf float | |||
| 8-bitinteger |
So how is this page drawing the "true" numbers, if computers can't hold them? It isn't, quite. Your browser does its math in 64-bit floats, with 52 mantissa bits. Its ticks are there too, just about 500 million times closer together than single's, so at every zoom here they blur into one solid line. The truth on this page is a finer liar. Even your 0.1 is really 0.1000000000000000055511151231257827021181583404541015625.
Far from the origin [For color, the growing gap is harmless. For numbers that are not colors, it is not. A position pass, a depth pass or an object ID stored in half float runs out of precision fast: above 2048, half cannot hold every integer, so IDs collide and positions snap to a grid. The same thing happens to whole worlds. Walk far enough from the origin in older Minecraft and things start to come apart: about 12.5 million blocks out, the terrain generator’s scaled coordinates outgrow the numbers it was storing them in, and the landscape breaks into the warped walls players named the Far Lands. Keep going and plain float precision takes over, and movement and block positions start to jitter and snap.]
The practical version [Keep values precise enough for what they are. Color in half float is fine. Positions, depth, IDs and anything that counts belong in 32-bit float, and EXR lets you store those channels at full float while the beauty stays half. A link here to further reading on choosing precision.]
[Bridge into the working space: float holds the whole scene, past 1.0 and below 0, with a log’s worth of precision built in. That is what lets the working space stay linear, which is where the math wants it.]
Linear is for math: the working space
Storage wants a curve. Arithmetic on light wants none. The space an operation is done in decides whether the math is right.
In linear light, 0.36 is twice as much light as 0.18. That makes it the right space for any math on light: rendering, compositing, blurring, defocusing, mixing two lights. Part two showed linear integers are a bad way to store light. Both things are true. Wrong for integer storage, correct for arithmetic, and float storage lets you have both.
[Introduce ACES properly here, as the room we have been in all along. ACES is a family of encodings, not one space. ACEScg is linear, for math. ACEScct is the same primaries with a log curve, for grading, because grading controls assume a fixed move produces a similar visible change anywhere in the range. ACES2065-1 is for archive and interchange. Pick the working space by the verb.]
[Not an ACES guide: one line that this is the working space we chose for the guide, and that the full ACES story (versions, ACES 2 output transforms, configs) is for another day.]
The working space should match the operation. Pick by the verb, not by habit.
Interns get this wrong The tell that someone is grading in linear is a colorist fighting the controls: every move in the shadows overshoots, every move in the highlights does nothing. The tell that someone is compositing in a display or log space is soft edges with dark fringes and a multiply that darkens more than it should. Neither is a skill problem. Both are the wrong room.
Up next
So, why was it gray? Because it was keeping everything.
Log holds the whole scene in a file that looks flat on purpose. Float holds it with no ceiling, colors brighter than white included, and a log’s worth of precision built into the number itself. The linear working space is where all of it gets added, blurred and lit, with the math done right. All that is left is getting it back out of the computer without ruining it.
Which raises a fair question. All these curves, spaces and conversions: is all this color stuff worth it? Yes, if nobody breaks it. Alpha, video, files moving between programs, and the scopes that tell you when something went wrong are where it usually breaks.
That is part four.
Glossary
Key terms used in this guide. In the prose, underlined-dotted terms show their short definition on hover or focus, and jump here on click.
- Log encoding
- A logarithmic transfer function that gives every stop a similar share of the codes, fitting a camera's twelve or more stops into 0 to 1.
- Dynamic range
- The span between the darkest and brightest values a scene, sensor, file or display can hold, counted in stops.
- Scene-referred
- Values proportional to the light in the scene, with no decision about a display made yet. They can go past 1.0.
- Display-referred
- Values that describe what a display should emit, with the tone decisions baked in. 1.0 is display white.
- Linear light
- An encoding where doubling the value doubles the light. Correct for math on light, wasteful for storing it in integers.
- Working space
- The colorspace an operation is performed in, as distinct from how a file is stored or displayed.
- ACES
- The Academy Color Encoding System: a family of scene-linear and log encodings on wide gamuts, with defined transforms in from every source and out to every display.
- ACEScg
- The scene-linear, wide-gamut (AP1) ACES working space, for rendering, compositing and any other math on light.
- ACEScct
- ACEScg's AP1 primaries with a log curve and a small linear toe. Built for grading, where controls should feel even across the range.
- ACES2065-1
- The widest ACES encoding: linear, on the AP0 primaries, which enclose every visible color. For archive and interchange, not for working in.
- IDT
- Input transform: brings a specific source into the working space by undoing its transfer function and converting its primaries.
- ODT
- Output transform: takes the working space to a specific display by tone mapping the scene range, then applying the display curve. Apply it exactly once.
- Tone mapping
- Compressing a scene's many stops into the few a display can show, rolling highlights off instead of clipping them.
Extra reading
- Floating-point arithmetic: accuracy problemsWhy the gap between representable numbers grows with distance from zero.en.wikipedia.org ↗
- Greg Ward: High Dynamic Range Imaging (PDF)The other half of the story, from the author of Radiance and the .hdr format: how HDR pixels get encoded at all. Hosted on Debevec’s page.pauldebevec.com ↗
- OpenEXR documentationThe half-float image format the working space lives in.openexr.com ↗
- Paul Debevec: Recovering High Dynamic Range Radiance Maps from PhotographsWhere scene-referred images start. Bracketed exposures merged into one radiance map, with sample HDR images, the source photos for Memorial Church, and the software he wrote to make and view them.pauldebevec.com ↗
- Fiat Lux (1999)The short film that put the light probes to work, lit by St. Peter’s Basilica and the Uffizi Gallery.pauldebevec.com ↗
- ACES documentationThe working space used throughout, in full.docs.acescentral.com ↗