Tone Correction

Dynamic range correction

The differences between the straight gamma 2.2 tone curve and the camera RAW or the Nikon 5700 tone curves are not just some added fancyness, although there is a bit of that. The most important difference is actually to compensate for the additional dynamic range that is available from the digital camera sensor.

To help understand that, it is interesting to observe that the Camera RAW and the Nikon 5700 transfer curves can be viewed as a specific f-curve multiplied by a Gamma 2.2 curve.

In both cases, the curves are designed to compress the camera dynamic range without loosing too much details in the highlights and the shadows areas.

The camera image sensor have around 1 f-stop of additional data than will be stored in the jpeg file. My Nikon 5700 only have around 2/3 f-stop of additional captured light. Some camera have almost 2 f-stops more and as the camera technology improve, we will undoubtedly see more dynamic ranges.

Dealing with the additional f-stop is probably the aspect that have the most illusive consequence for 3D CG artists. It is important to understand what is going on in order to emulate this with our 3D renders.

A 3D renderer acts like a virtual digital camera and the light data that is computed in a renderer are also linear, just like the camera sensor data. Thus, if we want our rendered scenes to look more like a real photo, the same kind of tone correction must be applied to them.

There is one extremely important difference, though. In order to record and store this higher dynamic range, the camera must save the image sensor data in a 12-bits format. Some camera use even more bits. And when the image sensor data, in the form of a RAW data file, is loaded in a Paint application, the resulting image is saved and manipulated in 16-bits mode to try to keep as much as possible of the original data even after the application of the severe tone curve.

The least a 3D CG artist should do is to save the renderer output in a 16-bit file format such as PNG 16-bits format (PNG also allows to store the alpha channel) or even better, save the renderer output in a floating point format such as OpenEXR.

I strongly recommend storing the renderer output in an OpenEXR file using the half-float format since this format will record all the available dynamic range of the rendered scene and will allow later post manipulation at will.

But storing in 16-bits format or OpenEXR is only a small part of the whole picture. What should be stored and how is much more important. So back to the tone curves and how we can implement those in our rendering pipeline.

As shown above, a typical camera tone curve can be decomposed into two different tone curves. One is a dynamic range squashing f-curve and the other is the gamma 2.2 curve.

The dynamic range squashing curve is designed to bring the camera higher dynamic range back into a range that is suitable for CRT display. The red arrows, superposed on the curves to the right, indicates the approximate dynamic range squashing that is going on. Not quite one f-stop is cutoff.

In effect, CRT displays only have 7 or 8 f-stops of dynamic range. If we were simply to display the 9 or 10 f-stops coming out of the camera sensor onto a 8 f-stops display, the resulting image would loose all its contrast. And that is why, when we apply a gamma correction directly to the camera sensor data, the resulting image looks bland and washed out.

So something needs to be done to reduce the dynamic range of the sensor data before we apply a gamma correction. But at the same time, we want to preserve as much as possible of that original dynamic range.

Here to the right is an example of simply cutting off the excess in dynamic range (the center column) compared to squashing the dynamic range with an f-curve (the rightmost column).

The result of simply cutting off the high lights and the shadows, is that, after the gamma curve was applied, all the subtle details on the floor, in the right-bottom most part of the image are burned out to white. And a lot of shadow details on the front of the crate are also lost. The f-curve squashing recovers those details thanks to the much smoother slopes in the shadow and highlight parts of the curve.

This f-curve can be designed to suit any purpose or artistic preferences. We are not limited to using f-curves as supplied by camera manufacturers or software manufacturers. As mentioned earlier, a lot of professional photographers take their digital photos in raw mode and design their own tone curve. There is no reason we couldn't do the same thing for our 3D renders.

Now we have enough background knowledge as to what we need to do to our 3D renders. The next step is to apply that knowledge.