Why Is It Like This?
The original sins of computer graphics.
Every industry has its haunted houses: the defaults nobody set, the numbers everyone uses, the conventions that made sense once and now just live here. Here’s the tour.
[The pattern: every number here was a reasonable fix for a real problem. Then the problem went away and the number didn’t. Each entry stands alone and has its own link.]
The Utah teapot
[1975, University of Utah. Martin Newell sketched his Melitta teapot on graph paper and entered the Bézier control points by hand. It became the test object: curved everywhere, concave and convex, saddle points, a handle with a hole, a spout that occludes the body. And no bottom, which is why so many renders never show one.]
[The teapot you know is about 25% shorter than the real one (the real one is roughly 4:3 taller). The story everyone tells: Jim Blinn squashed the data to cancel his framebuffer’s non-square pixels, then passed the squashed file around. What Blinn says: he scaled it during a demo to show they could, everyone liked it better, and that’s the file that got saved. Newell: “Everybody, including me, liked the teapot squished.” The myth survives because it fits suspiciously well: Alvy Ray Smith’s memo gives a pixel spacing ratio of 1.25 for that 512×480 framebuffer on a 4:3 monitor.]
Y-up vs Z-up
[Max is Z-up because CAD and architecture are: Z is elevation off the plan. Maya, Houdini, Unity and glTF are Y-up because screen space was. Then handedness on top. Every FBX export you’ve ever rotated by 90°.]
0x5f3759df: fast inverse square root
[Every lit pixel in a 3D game needs a surface direction of length exactly 1, and getting there means dividing by a square root: 1/√x. In the late ’90s both the square root and the divide were slow. The Quake III Arena source (id Software, 1999) did it with no square root and no divide: read the float’s bits as an integer, shift them right one place, subtract the result from a magic number, read it back as a float, and polish it with one step of Newton’s method. The comments next to it, “evil floating point bit level hacking” and “what the f***?”, became famous when id released the code in 2005.]
[Why it works: a float is stored as a power of two and a fraction inside it, so its bits, read as one integer, are already a rough logarithm of the number (the How numbers are stored widget shows the integer climbing one step at a time). In log land a square root is halving and 1/x is negating. The shift halves. The subtraction negates and puts the exponent offset back. The magic number is mostly that offset, with a small tuned correction.]
[Whodunit: not Carmack, who has said it wasn’t his, and not DOOM, which ran on integer fixed-point math and barely touched floats. The code traces back through Gary Tarolli (SGI, later 3dfx) to Greg Walsh at Ardent Computer in the late 1980s, and the idea of guessing a square root from a float’s bits is older still. 0x5f3759df isn’t even the best constant: Chris Lomont found slightly better ones in 2003.]
[Where it went: nowhere, and everywhere. Nobody ships this code any more. Intel added an approximate reciprocal square root instruction to SSE (rsqrtss, in the Pentium III) the same year Quake III came out, and every GPU has one. They are not this trick in silicon; they use lookup tables. But they are the same bargain: a fast answer good to a few digits, sharpened with a Newton step only if you need it. Normalizing vectors for shading, and for rays in a raytracer, still runs on that bargain.]
y = number;
i = * ( long * ) &y; // evil floating point bit level hacking
i = 0x5f3759df - ( i >> 1 ); // what the f***?
y = * ( float * ) &i;
y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration | true 1/√x | |
|---|---|
| this step's answer | |
| error |
23.976 and 2:3 pulldown
[Film is 24. 24 frames into 60 fields goes A A B B B, the 2:3 pulldown. Into 59.94 fields it only fits if the film runs 0.1% slow: 24000/1001 = 23.976. “23.98” is the rounded label for the same number.]
| A is on screen for | |
|---|---|
| B is on screen for | |
| one hour of film (86,400 frames) takes | |
| film speed that keeps step |
Interlacing and field order
[The problem: 30 full frames a second flickers badly on a CRT. The fix: send alternate lines in each field, 60 refreshes a second for the bandwidth of 30 frames. The bonus nobody planned: a video camera samples each field at a different instant, so 60i is 60 moments in time a second.]
[Where it bites: weave two fields on a progressive screen and anything moving combs. Get the field order backwards and motion plays 2, 1, 4, 3: one step back for every two forward. Do that to 2:3 pulldown and you get both at once.]
The hum bar: 60 Hz vs 50 Hz
[Black-and-white NTSC (1941) ran exactly 60 fields a second because the wall did. Poorly filtered power supplies put a ripple on the picture, a hum bar. Lock the field rate to the mains and the bar sits still where nobody notices; don’t, and it rolls. Europe’s grid is 50 Hz, so PAL and SECAM are 50 fields, 25 frames, and never needed a fudge.]
[Exceptions worth one line each: Japan runs a 50 Hz east and a 60 Hz west and uses NTSC everywhere; Brazil’s PAL-M is PAL color at 60 Hz. Your HDMI menu still offers 59.94 Hz.]
29.97 fps
[1953. Color had to fit into the same 6 MHz channel and still play on every black-and-white set already sold. The color subcarrier sits at 455/2 times the line rate, so its energy falls between the teeth of the luma comb. But it also beat against the 4.5 MHz sound carrier, at about 920 kHz, and that beat needed to fall between the teeth too. Moving the sound carrier would have broken existing TVs. So they moved everything else: line rate = 4.5 MHz / 286 = 15,734.27 Hz, down from 15,750. That’s 1000/1001. Fields 59.94, frames 29.97.]
[Matt Parker’s Stand-up Maths video tells this one well; link it here.]
| line rate | Hz |
|---|---|
| field rate (÷ 262.5) | |
| frame rate (÷ 525) | |
| color subcarrier (× 227.5) | MHz |
| sound ÷ line rate | |
| beat (sound − subcarrier) | kHz |
| beat ÷ line rate |
Drop-frame timecode
[Count 29.97 as if it were 30 and the timecode falls 108 frames (3.6 s) behind the clock every hour. Drop-frame skips the numbers ;00 and ;01 at the top of each minute except every tenth: 2 × 54 = 108. Numbers, never frames.]
Overscan and title-safe
[Overscan is gone; the margins it forced on us never left.]
Non-square pixels
[Standard definition was sampled at 13.5 MHz, chosen because it divides cleanly into both the NTSC and PAL line rates. That gives 720 samples per line, of which about 704 are picture. Which width you call “4:3” is why two sets of pixel aspect ratios are in circulation (10/11 vs 0.9 for NTSC 4:3). Calls back to the teapot.]
Guard bands and signal bleed
[A real signal isn’t a point on the dial; it has skirts. Push it harder than the transmitter can follow and it clips, and clipping makes new frequencies that land in someone else’s channel. The guard band is the whole idea: leave room, because nothing is as clean as the spec.]
| modulation depth | % |
|---|---|
| power in our slot | |
| power in the neighbors' slots |
Broadcast-safe color
[In composite video the color rides on top of the brightness as a 3.58 MHz sine. Bright saturated colors (yellow, cyan) swing the signal above the 120 IRE ceiling; dark saturated colors (blue, red) dip below −20 into sync territory.]
[Too bright: NTSC transmitters use negative modulation (white means the least carrier), so the peak cuts the carrier off entirely. TV sound is recovered by beating against that carrier, so the picture comes out of the speaker as a buzz. Too dark: the set can mistake picture for sync and lose lock. That’s what the “legal colors” filter in your NLE is protecting.]
[Side note: US NTSC put black at 7.5 IRE (“setup”); Japan and PAL at 0. One reason your black was gray on someone else’s deck.]
[Sound has its own version. TV audio is FM: louder means a wider swing in frequency, and pre-emphasis boosts the highs before they go out, so a hot, bright mix swings past its allotted deviation and into the neighbors. The loudness specs you deliver to today (ATSC A/85, EBU R128, measured in LUFS) are a different story: people complained that ads were louder than the shows, and in the US the 2010 CALM Act made it law.]
| luma | peak | trough | least carrier | |
|---|---|---|---|---|
| asked for |
Legal range (16–235)
[Video levels keep codes in reserve. Below black and above white is room for filter ringing on hard edges; the very ends (0 and 255 in 8-bit) are reserved for timing codes in SDI. Full range clips the ringing; legal range keeps it.]
44.1 kHz audio
[Early digital audio was mastered on PCM adaptors recording onto video tape. 3 samples per line × 245 lines × 60 fields = 44,100. PAL gets there too: 3 × 294 × 50. (On 59.94 NTSC it was really 44,056.) Broadcast and film went with 48 kHz. Your sample rate mismatch is a television artifact.]
| samples per line, per channel | 3 |
|---|---|
| usable lines per field | |
| fields per second | |
| sample rate | |
| samples so far, per channel |
sRGB vs gamma 2.2
[Everyone’s been doing it slightly wrong, and the wrongness is small enough nobody notices, except in the deep shadows. The curve explorer in So, the colors are in the computer? puts the two curves side by side.]
| code | |
|---|---|
| light, sRGB | |
| light, gamma 2.2 | |
| difference |
Color temperature: warm is cold
[Physics isn’t backwards; our words are. A hotter blackbody glows bluer, so 10,000 K is the “cool” one and 2,700 K is “warm”.]
| temperature | |
|---|---|
| mired (10⁶ ÷ K) | |
| looks like |
The queue
[Candidates awaiting a yes or no; numbers match the plan.]
- 18. 24 fps: the cheapest speed sound-on-film would tolerate
- 19. 4:3 from Edison’s film gauge; 16:9 as the geometric mean of 4:3 and 2.35
- 20. The “4” in 4:2:0 is four times the NTSC subcarrier
- 21. Luma isn’t luminance: Rec.601 vs Rec.709 coefficients
- 22. 1080 is stored as 1088
- 23. The 0.5 pixel center offset
- 24. Powers-of-two textures
- 25. 72 dpi
- 26. 18% gray vs what light meters assume
- 27. Never Twice the Same Color, and how PAL fixed it
- 28. Test objects: the Stanford bunny, the Cornell box, Lenna
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.
- Field
- One pass of an interlaced picture: only the odd lines, or only the even. NTSC sends 59.94 a second, PAL 50.
- Field order
- Whether the upper or lower field comes first in time. Backwards, motion steps back every other field.
- Line rate
- Lines drawn per second. Black-and-white NTSC: 15,750. Color NTSC: 15,734.27, slowed by 1000/1001.
- Color subcarrier
- A sine wave (3.579545 MHz in NTSC, 4.43361875 MHz in PAL) whose phase and amplitude carry hue and saturation on top of the black-and-white signal.
- Hum bar
- A dark band from power supply ripple at mains frequency. It sits still when the field rate is locked to the mains, and rolls when it is not.
- Pulldown
- Spreading 24 film frames across 60 video fields by holding them alternately for 2 and 3 fields (2:3).
- Drop-frame
- Timecode that skips frame numbers ;00 and ;01 each minute except every tenth, so 29.97 keeps up with the clock. No picture is dropped.
- Pixel aspect ratio
- A pixel’s displayed width over its height. Standard-definition pixels were not square: 10/11 for NTSC 4:3, by one convention.
- Overscan
- The outer edge of the picture that old TVs cropped. Title-safe and action-safe margins exist to survive it.
- IRE
- A unit of composite video level: 0 is blanking, 100 is reference white. US NTSC put black at 7.5 (“setup”).
- Newton's method
- Refining an approximate answer by following the slope of the error back toward zero. Each step roughly doubles the correct digits.
- Guard band
- Unused frequency left between channels so real, leaky signals don’t bleed into their neighbors.
Extra reading
- Why is TV 29.97 frames per second?Stand-up Maths (2016) on the color-carrier compromise behind 29.97.youtube.com ↗
- NTSCThe analog color standard behind most of the sins on this page.en.wikipedia.org ↗
- Utah teapotThe history of graphics’ most rendered object.en.wikipedia.org ↗
- Utah teapot: artifact, history, datasetsThe original data and the many versions made from it.geometrian.com ↗
- Broadcast-safeWhy broadcast limits the colors and levels a picture may use.en.wikipedia.org ↗
- Digital Video and HD: Algorithms and InterfacesCharles Poynton’s reference for video levels, gamma and the rest.book