3D renders as a virtual camera
A 3D renderer is actually a virtual camera looking at a virtual scene lit by virtual lights. To help understand what we need to do with our 3D scene, let's take a look at how this gamma correction process is done in a digital camera. This is very simple.
As I mentioned earlier, digital camera jpeg files are tone corrected in order for them to display correctly on a computer CRT display. The simplest tone correction is a 2.2 gamma correction but in practice, every camera manufacturer adds a tweak to their tone curves.
Digital cameras are light capturing devices. Every camera pixel is a light sensor that captures one tiny spot of light in the scene. This sensor works by counting, so to speak, the number of photons that it receives. The voltage that each sensor outputs is roughly linearly proportional to the number of photons that it receives.
Some cameras have a RAW file format. The RAW file format is essentially, a direct dump of the image sensor data without any kind of processing. So the RAW file contains a linear recording of the light that is in the photographed scene. In the column to the right are a few examples of scenes as recorded by the camera sensor and the resulting gamma corrected jpeg files as everyone would see them.
Actually, the camera firmware will apply a color correction according to the "mode" the camera was set when the photo was taken. Modes such as "Sunlight", "Cloudy", "Incandescent", etc., plus some proprietary tweaks to the transfer curve usually designed to boost contrast and saturation. So the actual jpeg photo that will get out of the camera will not quite look like the gamma corrected ones I'm showing here. But it will be similar enough. Anyway, just by comparing the linear vs the gamma corrected photos, one can immediately see that the gamma corrected photos look much more natural than the linear ones.
Here, to the right is a set of transfer curves as seen in a typical Paint application "Curve" editor along with the resulting photo.
The first one is the linear transfer curve which does not change the photo data at all. The accompanying photo directly came out of the camera sensor. It is very contrasty and the shadow portions are very dark.
The second curve is the straight Gamma 2.2 transfer curve. The resulting tone corrected photo shows much more details in the shadow portions of the image.
The third curve is the Photoshop "Camera RAW" transfer curve (I haven't tested Camera RAW with other cameras but I would not be surprised if that curve was more or less specific to each camera). This transfer curve adds some punch to the shadow portions of the photo by increasing the contrast in the shadows. This is the result of a much smoother slope in the lower part of the transfer curve.
The last curve is an example of a typical digital camera transfer curve. In this case, it is the transfer curve from a Nikon CoolPix 5700 (just because this is the digital camera model I own and, thus, I can experiment with). Other cameras have different transfer curves. The accompanying photo is more contrasty. It considerably darkens the shadows and flattens the highlights.
The important aspect to observe here is that the photo data coming out of the image sensor contains linear light readings and that this linear data does not, in itself, produce photos that look like the real scene.
A tone correction curve must be applied to every digital photos. This tone curve is usually applied directly by the camera firmware or it may be applied to the RAW data through an additional software. Digital camera manufacturers design their own tone curves and professional photographers also design their own tone curves and there may be different tone curves for different photographed subjects or different lighting conditions.
|