Chapter 1: Color Management

Introduction

You cannot talk about cinematography without addressing the color issue. It is essential to know within which primaries (or gamut, that is the same thing) you are rendering and what is your display target. Chapter 1 and 1.5 are the only technical chapters of the book. Color management is a pain in the arse, but it will give you strong foundations to build a proper lighting later on.

It is not the easiest way to start but I would rather evacuate all the technical stuff first. Lighting in computer graphics is so connected to technology that a good understanding of these concepts is important. I have tried to make it easy to understand to anybody. We will focus on the artistic side in the next chapters. Don’t be scared !

If you don’t feel like starting by a technical chapter, I don’t blame you. You can skip directly to chapter 2.

Most of my data comes from this amazing article by Thomas Mansencal. As it is a bit technical, I have tried to simplify it for readers who are not familiar with the subject. Let’s start with this great quote from Mark D. Fairchild :

“Why should it be particularly difficult to agree upon consistent terminology in the field of color appearance ? Perhaps the answer lies in the very nature of the subject. Almost everyone knows what color is. After all, they have had firsthand experience of it since shortly after birth. However, very few can precisely describe their color experiences or even precisely define color.”

To define the subject of this chapter has been a tough one : what is color management about ? Are we talking about Primaries ? Or LUTs (Lookup Tables) ? Or Wide Gamut Rendering ? Actually, a bit of all this stuff…

Optical Illusions

There are three things to take in account when we talk about color :

  • The subject
  • The eye
  • The brain

Here are a few examples that will show you that our brain can be easily tricked and that we should speak about color with humility.

previous arrow
next arrow
Full screenExit full screen
Slider

You can find plenty of optical illusions on internet, like our last example : Is the dress blue or white ?

Human eye

First thing to know is that the human eye is an incredibly complex and advanced technology. We are poorly trying to replicate its reconstruction process with cameras and screens. How does it work ?

Full screenExit full screen
Slider

Science really amazes me.

The cornea is the clear, transparent front covering which admits light. Its refractive power bends the light rays in such a way that they pass freely through the pupil. The pupil is the opening in the center of the iris and works like a shutter in a camera. It is an adjustable opening that controls the intensity of light permitted to strike the crystalline lens. It has the ability to enlarge and shrink, depending on how much light is entering the eye.

After passing through the iris, the light rays pass thru the eye’s natural crystalline lens. This clear, flexible structure works like the lens in a camera, shortening and lengthening its width in order to focus light rays properly. The crystalline lens focuses light through the vitreous humor, a dense, transparent gel-like substance, that fills the globe of the eyeball and supports the retina.

The retina functions much like the film in a camera. It receives the image that the cornea focuses through the eye’s internal lens and transforms this image into electrical impulses that are carried by the optic nerve to the brain. Retinas are made of photoreceptors, which come in two kinds : rods and cones. We will come back to them later.

The vitreous also absorbs the UVs to protect the retina from these wavelengths.

The mantis shrimp

Mantis shrimps, or stomatopods, are marine crustaceans of the order Stomatopoda. They are among the most important predators in many shallow, tropical and subtropical marine habitats. However, despite being common, they are poorly understood, as many species spend most of their lives tucked away in burrows and holes.

The creator of Guerilla Render, Ben, actually explained to me : our eyes actually only see in red, green and blue. They are crap ! Nothing compared to the mantis shrimp. Here are some pretty amazing eyes ! They have twelve photoreceptors, when humans only have three ! It can even see UV and Infrared, like the Predator !

Trichromatic system.
previous arrow
next arrow
Full screenExit full screen
Slider

Mantis shrimp is a reference for color scientists.

Finally the brain is responsible for managing all this data. When the image hits the retina, it actually is upside down. The brain put its back correctly :

What we really see is our mind’s reconstruction of objects based on input provided by the eyes, not the actual light received by our eyes.

From this article.

What is color ? And what is light ?

To define color, you must first define light because no color is perceptible without light.

  • Light is a type of energy.
  • Light energy travels in waves.

Some light travels in short, “choppy” waves. Other light travels in long, lazy waves. Blue light waves are shorter than red light waves.

From Cinematic Color : a study of color science begins with the spectrum. One measures light energy as a function of wavelengths. […] Light towards the middle of this range (yellow-green) is perceived as being most luminous.

Full screenExit full screen
Slider

Light is an electromagnetic radiation which is visible to the human eye.

All light travels in a straight line unless something gets in the way and does one of these things :

  • Reflect it (like a mirror).
  • Refract it (bend like a prism).
  • Scatter it (like molecules of the gases in the atmosphere).

Light is the source of all colors. It is actually stunning how important light is in our lives. When a lemon appears yellow, it is because its surface reflects the yellow color rather than because it is really yellow. It is something that has confused me a lot but pigments appear colored because they selectively reflect and absorb certain wavelengths of visible light.

Most of these notions come from Wikipedia. And you can find plenty of articles on this topic online. I have never been very good at physics but here is a more technical description :

Light is an electromagnetic radiation which is visible to the human eye. Visible light is usually defined as having wavelengths in the range of 400-700 nanometres between the infrared (with longer wavelengths) and the ultraviolet (with shorter wavelengths). These waves are made of photons.

The CIE 1931 Color Matching Functions

After reading the amazing Cinematic Color by Jeremy Selan, the guy who invented OCIO, I felt like it was necessary to add a text about the Color Matching Functions. I cannot explain it more clearly than him, so I’ll just quote :

The human visual system […] is trichromatic. Thus, color can be fully specified as a function of three variables. Through a series of perceptual experiments, the color community has derived three curves, the CIE1931 color matching functions, which allow for the conversion of spectral energy into a measure of color.

Full screenExit full screen
Slider

The CIE 1931 Color Matching Functions convert spectral energy distributions into a measure of color, XYZ. XYZ predicts if two spectral distributions appear identical to an average human observer.

The output is referred to as CIE XYZ tristumulus values, with the individual components being labelled X, Y and Z (the capitalization is important). […] When one converts all possible spectra into x,y,Y space and plots x,y they fall into a horse-shoe shaped region on the chromaticity chart.

Chromaticity diagrams are the subject of our next paragraph.

The CIE Chromaticity Diagrams from 1931 and 1976

We are going now to dig deep in the color subject. It has taken me more than six months to understand the whole process and there are still many blurry areas. But this journey through color, made with my colleague Christophe Verspieren, has been a very interesting one.

The CIE XYZ is a Chromaticity Diagram defined by the International Commission on Illumination (CIE) in 1931. It is the first step to describe colors based on human vision.

Full screenExit full screen
Slider

The two main CIE diagrams from 1931 and 1976.

CIE scientists met in 1931 to represent the colors as we see them. The CIE XYZ chromaticity diagram was born ! They met 45 years later to improve it : CIE U’V’ was created. Even if the CIE U’V’ from 1976 is more accurate, the one from 1931 is still the most used in the color community. Old habits die hard.

The research of David L. MacAdam (1942) showed that the CIE 1931 xy chromaticity diagram did not offer perceptual uniformity. What this means is that the relation between the measurable chromaticity of a color and the error margin in observation, was not consistent within the CIE 1931 xy chromaticity diagram.

From this amazing article.
  • These chromaticity diagrams are the visualization of all chromaticities perceivable by the human eye.
  • 2 axis are available to give each color an unique coordinate on this diagram.

From Cinematic Color : the region inside the horseshoe represents all possible integrated color spectra; the region outside does not correspond to physically-possible colors.

Horseshoe or tongue shaped area. It really depends.

The CIE XYZ serves as a standard reference against which many other color spaces are defined. Keep these diagrams in mind because we are going to constantly refer to them later on.

RGB Colorspace and its components

An RGB colorspace is composed of all the colors available in our workspace. It is defined by three components :

This is what an RGB colorspace looks like :

Full screenExit full screen
Slider

This screenshot comes from colour-science.

On the image above, there are three important things to notice :

  • RGB color spaces actually exist in the 3D space (screen left).
  • To make it easier to visualize, we generally only use a 2D slice, at a given luminosity (bottom screen right). In this example you can see the Rec. 709 colorspace against the CIE 1931 diagram.
  • Notice the black points ? They represent the pixel values of the image (top screen right) within an RGB colorspace (in this case Rec. 709). It is called to plot the gamut.

Primaries

“The primaries chromaticity coordinates define the gamut (the triangle of colors) that can be encoded by a given RGB colorspace.”

Primaries and gamut are the same thing.

In other words, the primaries are the vertices of the triangle. We are going to complicate things a bit… Pay attention ! Each of these vertices has a pure RGB value :

  • Red = 1,0,0
  • Green = 0,1,0
  • Blue = 0,0,1

But each of these vertices has an unique xy coordinate on the CIE diagram. That is how we are able to compare them. The only way to define a color (independently from its luminance) in an universal way is to give its xy coordinates. In this chart, you can see the coordinates for different color spaces :

Full screenExit full screen
Slider

I have chosen my favorite RGB colorspaces.

Working in a wider color space gives us access to more saturated values. That actually makes a big visual difference !

Full screenExit full screen
Slider

I have used both diagrams for comparison.

In this image, you can clearly see the different primaries of each color space :

  • Different xy coordinates.
  • Same RGB values.

Do we always want to work in the biggest color space possible ? Not necessarily…

We will come back to that later.

Whitepoint

The whitepoint defines the white color for a given RGB colorspace. Any set of colors lying on the neutral axis passing through the whitepoint, no matter their Luminance, will be neutral to that RGB colorspace.

Full screenExit full screen
Slider

D65 corresponds roughly to the average midday light in Western Europe.

There are several white points. When a white point is supplied with a set of primaries, it’s used to balance the primaries. But a viewing environment will have a white point too which may be the same or different. So there is a notion of a calibration white point and a creative white point.

An example of where they are different is for digital cinema which is calibrated to the DCI white point, but often movies will use another white point (D60 or D65) as the creative white point.

An RGB color space can have different whitepoints depending its context usage. It can be creative choice :

  • If you wish to simulate the light quality of a standard viewing booth, choose D50. Selecting a warm color temperature such as D50 will create a warm-colored white.
  • If you wish to simulate the quality of daylight at noon, choose D65. A higher temperature setting such as D65 will create a white that is slightly cooler.
  • If you prefer cooler daylight, choose D75.

Transfer functions (OETF and EOTF)

The transfer functions perform the mapping between the linear light components (tristimulus values) and a non-linear R’G’B’ video signal (most of the time for coding optimisation and bandwidth performance).

Okay. Here things get a bit more complicated… We have seen earlier what the tristimulus values are. But what about coding optimization and bandwidth performance ? Here is the answer :

From Substance PBR guide : The Human Visual System (HVS) is more sensitive to relative differences in darker tones rather than brighter tones. Because of this, not using a gamma correction is wasteful as too many bits will be allocated to tonal regions where the HVS cannot distinguish between tones.

Transfer functions or gamma help to encode better the bits, thus increasing performance. There are two transfer functions :

  • OETF : the opto-electronic transfer function, converts linear scene light into the video signal, typically within a camera. When you shoot or scan.
  • EOTF : electro-optical transfer function, which converts the video signal into the linear light output of the display. When you send a signal to the screen.
Full screenExit full screen
Slider

There are also logarithmic transfer functions but that’s another topic.

Common mistakes

Important stuff to notice is that :

  • Linear is not a color space.
  • Linear is not necessarily wide gamut and certainly not infinite.
  • It is a transfer function which is 100% gamut dependent.

That is a very common mistake among even veteran VFX sups in the industry. Secondly, to simplify, let’s say that these transfer functions are related to gamma and tv signal :

A common belief is that a non-linear Optical to Electrical Transfer Function is needed because of the non-linearity of the human visual system. It is true that the human visual system is very complex and lightness perception is non-linear, approximating to a cube-root power law.

We are going back to our first point : human vision is incredibly complex. And that we need these transfer functions for our visual comfort.

One of the biggest fight I ever had was to convince my supervisors that linear was NOT some kind of infinite color space.

In this case infinite means access to all colors of the spectrum.

Properties of a color space

Two properties are also necessary in order to properly interpret a set of RGB values : image state and viewing environment.

Image State

Image State is defined in international standard ISO 22028-1. This is basically the international standard for how to define an RGB Colorspace.

Scene-referred

A scene referred image is one whose light values are recorded as they existed at the camera focal plane before any kind of in-camera processing. These linear light values are directly proportional to the objective, physical light of the scene exposure. By extension, if an image is scene referred then the camera that captured it is little more than a photon measuring device.

Great definition from this blog.

Display-referred

A display referred image is one defined by how it will be displayed. Rec.709 for example is a display referred color space meaning, the contrast range of Rec.709 images is mapped to the contrast range of the display device, a HD television.

Viewing environment

Section coming Q4 2020. Thanks for your patience !

This article explains it otherwise. And this one by Autodesk as well.

Industry Standards

Screen manufacturers and Cinema majors have agreed on some standards. Their characteristics change the way our images are displayed and rendered. Here are the four most important for us :

  • sRGB for internet, Windows and camera photos.
  • Rec. 709 has the same primaries than sRGB but differs on gamma. This is because the target use of Rec.709 is video where it’s supposed to be viewed on a dim surround.
  • DCI-P3 for cinema projectors.
  • Rec. 2020, also called UHD TV, the future of colorimetry.
  • AdobeRGB for printing projects.
Full screenExit full screen
Slider

sRGB and Rec.709 do have the same primaries.

What are these color spaces for ? For two things :

  • Rendering Space : also called working space, for our lighting calculation.
  • Display Space : should match our monitors, which obviously need proper calibration.

These are just CG words to define scene-referred and display-referred.

They are basically the same thing.

Rendering and Display spaces

Rendering and display spaces do NOT have to be the same. It is really important to understand the distinction between those two. In CG, the rendering space will always have to be with a linear transfer function. We will detail linear workflow in a bit.

And for the Display Space, when you work on a project, you have to ask yourself : are my images going to be seen on a smartphone, on a TV set or in a theater ? This is where Color Management really comes in handy. In a CG workflow, it is vital to know for every single step which primaries you are working in.

When you buy a monitor, you should check the coverage of these color spaces. For example the monitors used at a famous Parisian studio only cover 93,7% of the P3 gamut. That’s too low ! We will never match perfectly the projectors from theaters. There is no point on working in a Display Space that does not match exactly the specifics of your monitor or needs of your project.

P3 is a common RGB color space for digital movie projection, defined by the Digital Cinema Initiatives (DCI) organization and published by the Society of Motion Picture and Television Engineers (SMPTE).

What is sRGB ?

As this has been explained brilliantly in the article from Thomas Mansencal, sRGB is still a confused notion for many artists. Whats is sRGB ?

  • Some say : “It is a color space !
  • Others reply : “It is a transfer function !

sRGB is actually both ! It is a color space that includes a transfer function which is a slight tweaking of the simple gamma 2.2 curve. This is why you can also use gamma corrections (0.454 / 2.2) to be in linear or not.

From the Substance PBR guide : “It is critically important to disambiguate the sRGB OETF from the sRGB colorspace; the OETF is only one of the three components that make an RGB colorspace.”

Linear workflow

This is for me the biggest step between a student work and a professional work. Linear workflow is compulsory in the industry. I do not know any respectable studio that does not use it.

Jeremy Selan : it is often preferable to carry over those aspects of the traditional film workflow which are beneficial even in a fully-CG context. We thus advocate thinking of an animated feature as creating a “virtual movie-set” within the computer, complete with a virtual camera, virtual negative stock, and virtual print stock.

Full screenExit full screen
Slider

Please note that the input on the left side is scene-referred but the viewed output is display-referred.

As seen earlier, monitors have a gamma correction to display the images correctly. It is an industry standard for visual comfort since we had CRT monitors (because the light intensity does not change linearly with the voltage).

In most cases, if a computer runs the Windows operating system, we can achieve close to ideal colors by using a monitor with a gamma value of 2.2. This is because Windows assumes a monitor with a gamma value of 2.2, the standard gamma value for Windows.

From Eizo’s website.

We correct this problem by saving a transfer function into the sRGB images. This is why we need to put an inverted gamma curve (0.454) or inverted sRGB curve to compensate for that. This is a very important point : your renders will NEVER be correct if you do not use a linear transfer function for your rendering space. Rendering (and displaying) in plain sRGB are just wrong !

Example of linear rendering space

The following example is using a sRGB display transform with no LUT, like most rendering softwares offer by default. We will see why this is pretty much wrong.

  • Display Space : I put 0.5 as I want to see a middle gray on my screen.
  • Rendering Space : Since I am working in a linear workflow, middle gray in my render will be 0.214 in Autodesk Maya which makes my calculation correct.
previous arrow
next arrow
Full screenExit full screen
Slider

Warning : a linear workflow is only complete with a tone mapping step.

Check three things :

  • You burn less in linear workflow.
  • You get a better bounce.
  • Shadows look more accurate.

From Cinematic Color : Why is scene-linear preferred for lighting ? First, the render itself benefits. Physically plausible light transport […] such as global illumination yield natural results when given scenes with high dynamic ranges. […] Light shaders also benefit from working with scene-referred linear, specifically in the area of light falloff. […] when combined with physically-based shading models, using an r² light falloff behaves naturally.

r2 light falloff is just another term for quadratic decay.

Basically the linear rendering provides the correct math for lighting. There are plenty of websites that show examples of linear workflow.

Linear confusion

Scene-referred confusion

That is really the original sin from the VFX industry : thinking that linear was a color space. The error is still quite common, even among VFX industry veterans. And even some softwares are wrong about it !

Full screenExit full screen
Slider

These options have confused me for a very long time.

In Nuke, this is particularly disturbing : linear is listed as a color space, same as sRGB or Rec.709. In the support pages from The Foundry, you can find an explanation : “However, Nuke’s colorspace isn’t a standard colourspace.” Guys, this should be written in BIG RED LETTERS !

After a couple of e-mails following the release of my website, I thought it would be worth mentioning that working in linear does not give you magically access to infinite color ranges. You still have to take in account the primaries (or gamut) you are working in.

We will see in the next chapter how all of this gamut confusion gets clarified thanks to ACES !

Display-referred confusion

I recently (April 2020) had the chance to talk with Doug Walker about linear issues regarding scene-referred and display-referred :

The way that Linear Workflow is often described contains a crucial error. Usually the description implies that the viewing process simply inverts the gamma adjustment applied on the input side. However, this is wrong and will lead to results that are too low in contrast, have too light a mid-gray, and have clipped highlights, therefore requiring artists to compensate by biasing the lighting and material decisions in unnatural ways.

By Doug Walker, Technology lead for color science at Autodesk.

Basically what most schools and students do is… Wrong ! The sRGB view transform maps 1.0 in the rendering space to 1.0 in the display space. This is one of the problems with using that as a view transform, it does not leave room for anything above 1.0 and those values are simply clamped.

In order to correct this, the viewing transform must account for the fact that the input is what color scientists call “scene-referred” whereas the image being viewed on the monitor is “display-referred”. This means that the viewing transform should not be a simple inverse gamma and instead needs to incorporate what is sometimes called a tone mapping step.

Which is the topic of our next chapter.

Lookup table (LUT)

From Cinematic Color : Lookup tables (LUT) are a technique for optimizing the evaluation of functions that are expensive to compute and inexpensive to cache.

LUTs originally come from live-action cameras. Thanks to a list of values (table), they allow to display high-dynamic range images (HDR) on low-dynamic range monitors (LDR). Our monitors and film projectors are not able to display the entire HDR range. A LUT is the best way to display pixels on a screen and to get a nice filmic look. This is called tone mapping.

Tone mapping

Until now we have mostly focused on the scene-referred part of the process aka the rendering space. We are now going to detail the part that converts from scene-referred to display-referred. Most artists know this process as “tone mapping“.

In any case, if you just apply an sRGB LUT, your contrast will be wrong, your highlights will be clipped and your mid-grays will be in the wrong place. Most CG artists will compensate for this error by biasing their lighting and material values to make it look better but that is not necessary if a proper color management system is used.

“Friends don’t let friends view scene-linear without an S-shaped viewing transform”.

By Thomas Mansencal.

LUT description

There are two kinds of LUT :

  • 1D LUT (left image) : it contains only one column of numbers as it affects RGB pixels the same way. They are also called Display LUT, generally using a S-Curve Shape to display better values. I used the vd16.spi1d from the spi-anim (Sony Pictures Imageworks Animation) config as an example. If the gamut of your image is Rec. 709, a 1D LUT will NOT change it.
  • 3D LUT (right image) : it contains three columns of numbers as it affects RGB pixels differently. They are used to map one color space to another. It actually modifies the primaries ! I used the Rec. 709 for ACEScg Maya.csp from the ACES 1.0.3 (Academy Color Encoding System) config as an example. A 3D LUT allows you to switch from one gamut to another. That is a very powerful tool !

From Cinematic Color : A lookup table (LUT) is characterized by its dimensionality, that is, the number of indices necessary to index an output value.

Full screenExit full screen
Slider

I have shortened the files on purpose for display convenience. These files actually have hundred of thousand of lines.

We also divide LUTs in two categories :

  • Technical LUTs : to get the best display possible of your images.
  • Artistic LUTs : to shift hue, luminosity and saturation based on your personal taste.

OCIO (OpenColorIO)

OCIO is an open source framework for configuring and applying colour transformations. […] It is designed for rolling out complex colour pipeline decisions to lots of people who might not individually understand what’s going on (ie : not colourists).

Great OCIO definition that I copied from this post.

To load a LUT into Maya, Nuke, Guerilla Render or Mari, we will use a OCIO configuration. The OCIO config is the easiest way to share a LUT between different programs. And guess what ? They are also available for free.

Here is what the OCIO config from Sony Picture Imageworks (left side) and ACES 1.2 (right side) look like :

Full screenExit full screen
Slider

I have also shortened the files on purpose for display convenience.

  • Different roles like color picking, texture painting or compositing are predefined.
  • Different displays are also available between DCI-P3 and sRGB.
  • Setup for Film look loads the file vd16.spi1d with a quick description.

There are several file formats for LUTs : spi1d, spi3d, csp, cube… Photoshop only accepts cube files. Otherwise you can use an ICC profile. Adobe softwares are not OCIO friendly unfortunately.

It is crucial that anyone doing look development or rendering uses the same LUT. Artists from the Surfacing, Lighting and Compositing departments need to see the same thing. Texturing in plain sRGB but rendering with a s-curve LUT will give issues. There are plenty of solutions for Mari, Substance or Photoshop to make your work consistent.

The OCIO configs are very handy because you can share them between softwares. You can use the official ones or build your own in Python. LUTs in animated movies have arrived pretty late compared to visual effects (VFX). But they are kind of a game changer in the industry. Naughty Dog has done some really good papers about them.

1D LUT example

What happens if you do not use a LUT ? Every time your shot is overexposed, you will have to manually “fix” it. That is just wrong.

Without a LUT, you will decrease your light’s intensity if it burns out. BUT you will loose some bouncing from Global Illumination (GI), some Sub-Surface Scattering (SSS)…

So you will probably have to create plenty of lights to compensate for the loss of energy. And this is how you end up with a complicated rig of 50 lights ! You want to be able to put as much energy as you need in a shot.

Check the example below : this is the SAME render displayed differently ! I repeat : the exr from the render engine does not change, it is just the way we view it.

previous arrow
next arrow
Full screenExit full screen
Slider

This is the proper way to display a linear render.

Filmic look

As a student I was obsessed to get a filmic look and pure blacks without making my renders look dirty. The only solution to that is to use a LUT. It will give you contrast and fix any overexposed areas. Here is what a “filmic” s-curve for tone mapping looks like :

Full screenExit full screen
Slider

All this vocabulary helps us to communicate more accurately.

From Cinematic Color : most tone renderings map a traditional scene gray exposure to a central value on the output display. […] one adds a reconstruction slope greater than 1:1 to bump the midtone contrast. Of course, with this increase in contrast the shadows and highlights are severely clipped, so a rolloff in contrast of lower than 1:1 is applied on both the high and low ends to allow for highlight and shadow detail to have smooth transitions. With this high contrast portion in middle, and low contrast portions at the extrema, the final curve resembles an “S” shape as shown below.

The rolloff of the highlights is pretty clear : all the values between 1 and 10 will be displayed in a range from 0.8 to 1.

You can even download these neutral luts from Arri for free.

Thanks Harry for the link !

The Zone System

Before going any further, we will do a quick turn-around to speak about exposure, stops and middle gray.

In 1939-1940 Ansel Adams and Fred Archer described the Zone System which is a photographic technique for determining optimal film exposure and development. The different zones represent different exposures (one stop on a camera). We also pass from one zone to another with a factor of two.

Full screenExit full screen
Slider

You can find plenty of Zone System on the internet.

In cinema we often to refer to mid gray as the one from the Zone V. This is a gray with an average luminous sensation (brightness) and allows photos to be properly exposed.

Brightness and Luminance are not the same thing ! Brightness is an attribute of visual perception and Luminance is a photometric measure.

Very important to distinguish those two.

The mid gray issue

Artists are confronted with a variety of different numbers for middle gray. In order to untangle the confusion, it is helpful to think about this from the perspective of both a gray material in a scene and a gray on a display.

Linear mid gray values (scene-referred)

Spoiler alert : Mid gray is a complicated topic. There are different mid gray linear values but canonically in VFX, on a color checker and a lot of applications, it is 0.18.

We will compare different values right below.

The 0.214 value

A great effort has been put to have a decent color management in Maya. And you may have noticed that linear middle gray in Autodesk Maya is set at 0.214. Why is that ?

Full screenExit full screen
Slider

Switching from Display Space to Rendering Space is automatic ! Handy !

In the Maya color picker, when the Mixing Color Space is set to Display Space, Maya converts the RGB value you enter into the Rendering Space by inverting the view transform. By default Maya is using sRGB as the viewing transform option. By sending 0.5 through the sRGB curve, you get 0.214. This value is not an Autodesk recommendation, it is just how things work out given the default sRGB viewing transform.

By Doug Walker, Technology lead for color science at Autodesk.

This value of 0.214 in Autodesk Maya is related to historical naive 1D sRGB VLUTs as shown here (from colour-science) :

>>> colour.models.eotf_sRGB(0.5)
0.21404114048223255

One of the problems with sRGB as a viewing transform is that it does not impose the contrast boost necessary to account for the perceptual differences between scene-referred and display-referred viewing. Once you factor those in, you get a number closer to 0.18. So I do think 0.18 is the best number for middle grey in a scene-referred space.

By Doug Walker, Technology lead for color science at Autodesk.

The 0.18 value

Historically, an 18% gray card has been used by photographers as a middle gray reference. The 18% value is a good choice since the CIE L* lightness value of this is 49.5 (where 100 is an ideal matte white, 0 is perfect black, and 50 is perceptually half way between them). An object that reflects 18% of the light hitting it has an albedo of 0.18. So if you are setting the value of a material in a linear rendering color space that you want to look mid-gray, 0.18 would be a good value to use.

There are many many many many articles on this topic. I’ll let you check them if you want to dig on the subject.

It is endless, really.

The 0.218 value

Middle gray can even be 0.218 (like on the curves below) as it is extremely close to pow(0.5, 2.2) = 0.2176.

If you want to know more about this topic, check this link.
Full screenExit full screen
Slider

It only took me a couple of years to figure this out.

Summary of linear mid gray values

Here a summary on the different mid gray values :

  • 0.18 is a great scene-referred value since it gives an L* of 49.496 once put through the CIE L* function .
  • 0.214 is a mid gray value of 0.5 sent through an inverted sRGB transfer function.
  • 0.218 is mid gray value of 0.5 sent through a gamma 2.2 curve.

Display mid gray values (display-referred)

Mid gray and gamma

The other way to think about the problem is to consider starting from a mid-gray on a display rather than what is a mid-gray object in a scene. In this case, one might start by picking a color value that is half way between the RGB code values for white and black. One minor problem with this is that the gamma of your monitor is probably not exactly equal to CIE L* lightness, although it is usually not terribly far off.

The display gamma is not exactly a description of perceptual lightness. So perceptually it is not exactly half way between monitor black and monitor white.

Using an RGB value 50% between black and white with the sRGB curve gives an L* value of 53.4, and using a pure 2.2 gamma gives an L* value of 53.8, so slightly too light in both cases. However even if we were to use a value with an exact L* of 50, the bigger question is whether middle gray on the monitor even corresponds with middle gray in the scene. It turns out that it does not !

There seems to be an embedded assumption that 0.5 in the display color encoding equals middle grey.

There are a few problems with that.

The way to convert a value on the monitor (a display-referred value) to a value in the rendering space (a scene-referred value) is to invert the viewing transform. For example, this is what the Maya color picker does to convert a value from the display space to the rendering space. The most basic viewing transform is just a simple gamma such as the sRGB curve. In this case, a display RGB value of 0.5 becomes a rendering space value of 0.214 (or 0.218 if using a pure 2.2 gamma).

Mid gray and tone mapping

However, these simple gamma transforms are inadequate. A proper viewing transform, such as one of the ACES Output Transforms, applies a range of corrections beyond simply accounting for the monitor calibration. For example, it corrects for differences in perceptual contrast caused by the difference in the scene-referred and display-referred viewing environments.

Also, it reserves some room at the bright end for specular highlights (so that values don’t clip harshly at 1.0). Both of these corrections cause a mid-gray in the scene to map to a value darker than mid-gray in the display space :

  • For example, inverting the ACES Output Transform for an sRGB monitor we find that 50% in display space becomes a value of 0.310 in the rendering space (much brighter than an 18% gray card).
  • Going in the other direction, if we start with a rendering space value of 0.18 and send that forward through the same ACES viewing transform, we get a value in sRGB of 0.349 (quite darker than 0.5).

In summary, do not expect that 50% in display RGB space corresponds to a middle gray object in the scene — it is actually lighter than mid-gray. If you need a display RGB value for a mid-gray to use in a color picker, start with a value of 0.18 in the rendering space, and send it through the viewing transform being used for the project.

Format

We are all set for proper Color Management and ready to make some beautiful renders. But how do we keep all these values, especially above 1, in a proper format ? We can thank ILM to have invented the OpenEXR.

Full screenExit full screen
Slider

Settings from my beloved Guerilla render.

OpenEXR allows you to save in 16 bits half float to avoid any banding/clamping issue. You will also be able to write some Arbitrary Output Variable (AOV) for your compositing process.

From Cinematic Color : It is important to remember when dealing with float-16 data, that the bits are allocated very differently from integer encodings. Whereas integer encodings have a uniform allocation of bits over the entire coding space, the floating-point encodings have increased precision in the low end, and decreased precision in the high end.

After a couple of e-mails following the release of my website, I thought it would be worth mentioning that 16 or 32 bits files do not give you magically access to infinite color ranges. You still have to take in account the primaries (or gamut) you are working in.

We did render some AOVs in 32 bits on Playmobil : Ncam, Pcam and Pworld for better precision.

For Z Depth and position.

Range

Finally we have to take care of our range. This topic is subject to controversy in many studios ! Basically you want to go as low as possible without affecting the rendering. There are two settings to take care of :

  • Clamp Pre Filter (also called Indirect Clamp Value) : Clamp the sample values.
  • Clamp Post Filter (also called AA Clamp Value) : Clamp the pixel values.
Full screenExit full screen
Slider

Similar settings may apply to any CPU renderer.

Clamping the sample values will help you to reduce fireflies and noise. The lowest value I ever used was 10 and it helped me greatly. Clamping the pixel values will help your anti-aliasing for a smoother result. If you have a very dark pixel next to an overexposed pixel, you do NOT want the overexposed pixel to blow out every other pixel next to it. This is why we clamp our renders.

It may also depend on your scene and your render engine. Some studios clamp their renders at 50. I have tried a couple of times as low as 30… I guess you need to try and see for yourself. Solid Angle explains pretty well the topic of clamping if you want to read more about the subject. We will see in chapter 9 why clamping pixel values can be an issue.

Summary

We have seen some important notions in this chapter. A color space has three components :

  • Three primaries.
  • A white point.
  • A transfer function.

We have also seen that your rendering space (or scene-referred) should always have a linear transfer function and that you should NEVER display a linear image without a proper display transform.

Conclusion

Color Management is a never-ending topic that I continue to explore almost on a daily basis. I have tried to sum it up in an easily understandable post. A good color management is when you see the same thing along the color pipeline and in different softwares.

If your colors or your contrast shift when you go from Substance to Maya, it may be worth to analyze the issue. A good color pipeline is all about controlling the gamut from the first sketches (probably done by the Art Department) to final delivery. Constancy is the key.

Here are my thoughts on Color Management. It has been a great and long (a year !) journey through color for me. But it doesn’t end here. That would be too easy. If you are still up for it, we can move to chapter 1.5 about the Academy Color Encoding System : ACES.

If you are saturated with this technical talk, I don’t blame you at all ! You can just skip to chapter 2.

Sources