Tone Correction

Tone correcting 3D renders - Is it necessary?

After reviewing tone correction on digital photography, it is instructive to compare digital photography with 3D CG renders and see where are the differences and how tone correcting can be applied.

Here to the right is a set of comparisons between a digital photo of a scene and the 3D CG render of the same reproduced scene. In the top row are the photos and in the bottom row are the rendered CG scene. The scene is 3 balls on a black floor, illuminated by one single small halogen lamp.

The first column shows that a render of the scene looks exactly like the image as captured by the camera image sensor. Both the renderer and the camera image sensor are outputing linear lighting capture or calculations. The light, in the 3D CG scene is set with a physically correct inverse square attenuation. Both the photo and the render look similar. Observe, in particular, the further ball illumination intensity. The light attenuation difference between the front ball and back wall are the same.

The second and third columns compares renders with Camera RAW corrected photos. In other words, the renders are compared to photos of the scene as it is output from the camera on a jpeg file with tone correction.

The second column, bottom image is there to show a trick that is often used in CG scene setups to try to correct the lack of gamma correction inherent in 3D renderers. The trick is to use linear attenuation on the lights in the scene instead of the physically correct inverse square attenuation. Comparing with the tone corrected photo, it can be observed that the difference in light attenuations between the front ball and the bacxk ball are almost the same as in the photo. The observable difference is in the quality of the balls surface shadings. As will be demonstrated next, the linear attenuation on lights can fake tone corrected photos for the effect distance will have on light intensity but it cannot fake all shading effects.

The third column, bottom image shows that, as it should be expected, when tone correction is applied on the render, then we obtain renders that look very similar to the digital photo of the same scene.

The image to the right is designed to demonstrate that setting the scene's light attenuation to linear will not solve all lighting and shading issues. This is a scene of one ball illuminated by one single small halogen lamp.

The first column compares a photo coming out directly from the camera image sensor, non tone-corrected, with a render coming out directly from the renderer with the light set to the physically correct inverse square attenuation. Observe, in particular, how the gradient of the ball's shading varies smoothly at the terminator (the terminator is the border between light and shadow on the object.)

The second column compares the same non-tone corrected photo with the same 3D CG scene. This time, the light attenuation is set to "linear". Observe that, although the "Linear" attenuation solved the shading difference due to distance from light, it still does not solve the shading difference due to angle between light and surface. This is what the shading gradient shows. Although the shading gradient at the shadow terminal is very smooth, this is not how it would look in reality.

The third column compares the photo with Camera RAW tone correction with the render with a 2.2 gamma correction. Observe that in both the photo and the gamma corrected render, the shade gradient at the terminator is much sharper, or quicker, than in the previous renders. This is indeed, how it would look in reality and this is how it would be output out of the camera in a jpeg file.

Using a linear attenuation on lights in 3D CG scene is a trick designed to make renders look more like digital photos. However, it only works for shaing differences due to the distance between the light and the objects in the scene. It cannot solve the shading difference due to the angle between the light and the surfaces in the scene.

At this point, you may want to visit "Light Behavior", a web page I wrote that demonstrates those two phenomenons known as 1) the inverse square law driving the shading on object as a function of the distance from light and 2) the cosine law, driving the shading on objects as a function of the angle from light. This will be usefull to help understand the following explanation.

Normally, in reality, light intensity attenuates by the inverse square of the distance from light. So s = d0.5, where s is the shading intensity on a surface and d is the distance from light. And adding a 2.0 gamma correction to the image can translate to s = (d0.5)2. So the square root coming from the gamma 2.0 correction cancels the inverse square root for the light attenuation which becomes equivalent to using a linear light attenuation. Linear light attenuation means that the light that is received by a surface, attenuates linearly with distance from light. But this only works for shading coming from distance from light. The cosine law will not be corrected by that.

The important point to understand here is that the 3D CG industry and artists have recognized that the renders coming out from a physically correct renderer are not suitable for reproducing real scenes. But the solution that is often used, which is to set the light attenuation to linear, is not the right solution because it cannot solve all shading issues. Of course, the cosine law can be corrected by using customized shaders but this is only pushing the problems a little bit further.

A few more examples

Next, are a few more examples demonstrating the effect of tone correction on 3D CG renders. This section may be skipped but some demonstrations may be revealing.

This is a scene with a few primitives illuminated by two lights, one yellowish and the other bluish.

The first render is what we get out of the renderer, without any tone correction. The lights have the physically correct normal attenuation (which is the inverse square attenuation). Things to observe are 1) Hot light spots on the ground and on the edge of the leftmost cylindrical object. 2) Very dark shadows. 3) Very quick shading gradients from light to shadows. 4) The top of the objects are quite dark.

The second render uses linear attenuation on the two lights. Things to observe are 1) Hot spots still very clear on the ground and on the edge of the cylindrical object. 2) Shadows are still quite dark. 3) Shading gradients are mixed. On one hand, the gradients on the wall and on the floor are slow but the gradients on the surface of the cylinders and the ball are still quite fast. 4) The top of the objects are still quite dark which creates unbalance between lights and shadows.

The third render uses the normal light attenuation but the render is tone corrected with a simple gamma of 2.2. Things to observe are 1) Hot spots are still there but because the gradients are much smoother, they are less offensive. 2) Shadows are much lighter. 3) Shading gradients are smooth everywhere, on the ground and the wall but also on the surface of rounded objects. 4) The top of the objects are much lighter and well balanced and integrated with the rest of the scene. The scene almost have an "ambiance occlusion render" feeling to it although ambiance occlusion was never used.

The fourth render also uses normal light attenuation but the tone correction is done with a twist. The render was lowered by 1 f-stop. Then the Camera RAW f-curve was applied and then a gamma 2.2 was applied. Those 3 operations emulated the whole Camera RAW tone correction. Things to observe are 1) Light hot spots have completely disapeared. 2) Shadows are a tad bit darker than with a simple gamma 2.2 correction. 3) Shading gradients are just as smooth as with the simple gamma 2.2 tone correction. 4) The top of the objects are darker than the simple gamma 2.2 tone correction.

An important point to consider is that the f-curve correction can be tweaked at will by the artist in order to get the desired light vs shadows balance.

Next example scene is a very simple scene. Two lights in front of a wall. This scene is designed to show the effect of shading gradient due to the inverse square distance law and to the cosine law at the same time.

The first render comes directly out of the renderer without any tone correction. The lights are set with a normal (inverse square distance) attenuation. Things to observe are: 1) the hotspots behind the lights on the wall. 2) the very quick and short light attenuation from light to complete shadow. 3) Illumination of the ground is very dark even though the lights appear to be very bright.

The second render also have no tone corrections but the light attenuation was set to linear. Things to observe are: 1) Still the hot spots behind the lights on the wall. 2) Light attenuation on the wall are much slower. 3) Illumination on the ground is much brighter and seem to fit with the light intensities. 4) The large discrepancy between the illumination on the floor and on the wall right where the floor meets the wall.

In the third render, the light attenuation is set back to normal attenuation. But a gamma 2.2 tone correction is applied to the render. Things to observe are: 1) The hot spots on the wall behind the lights are still there but because of the much slower shade gradients, they are much less noticeable. 2) Light attenuation on the wall are quite much slower and now extends up to the top of the image. It is much slower here, compared to with linear attenuation, because the light attenuation, here, takes both distance and angle into account. 3) Illumination on the ground is as bright as with linear attenuation except in the corners. Light attenuation here is slower than with linear attenuation again because both distance and angle from light sources are taken into account. 4) The difference in shading between the floor and the wall where the floor meets the wall is much more natural.

In the fourth render, the light attenuation is also set to normal. The render was tone corrected by first reducing the exposure by 1 f-stop. Then adding a Camera RAW f-curve and then adding a Gamma 2.2 corection. The main things to observe are: 1) There are no more hot spots on the wall behind the lights. 2) Light attenuation on the wall are a little bit quicker than in the previous render. Note that the halo effects are due to the fact that the Red, Green and Blue components of the light on the wall don't have the same value and due to the gamma and f-curve correction, those components are decreasing at different speed.

The set of renders to the right is designed to demonstrate the effect of different corrections on the perception of light attenuation due to distance from light. The scene consist of one light and several flat planks placed at increasing distance from the light. Relative to the first plank distance from the light, the second plank is placed at twice this distance from the light, the third plank is placed at 3 times the distance from the light, etc. The second plank will thus receive four times less photons than the first plank, the third plank will receive 9 times less photons than the first one, etc. The sequence is 22 = 4 times less, 32 = 9 times less, 42 = 15, 52 = 25, 62 = 36, 72 = 49, 82 = 64, 92 = 91, 102 = 100.

The first render comes out from the renderer without any tone correction. The light attenuation is set to normal (inverse square). The render is mathematically correct but this is not how our eye would perceive this scene in reality nor how a photo of the scene would render it either.

In the second render, the light attenuation is set to linear. The render of the scene starts to look the way our eyes would perceive this scene. We can clearly distinguish all the planks down to the last one and the wall also receive some light.

In the third render, the light attenuation is set back to normal and a gamma 2.2 tone correction is applied to the render. This is essentiually the same render as the first image in this set, but with a gamma correction. The scene looks very much like the second image except for one notable difference: The illumination gradient on the floor is much smooter in this render than in the second render. That is because, as distance increases from the light, the angle between the light and the floor surface decreases but the linear attenuation in the second render cannot account for that effect.

In the fourth render, the light attenuation is also set to normal but a set of tone correction was applied: First an exposure reduction of 1 f-stop. Then an f-curve designed to emulate the Camera RAW f-curve but with a one f-stop overshoot. And then a straight gamma 2.2 curve. Notice that the hot spot on the ground have disapeared leaving a nice bright gradient. For this particular scene, I would modify the f-curve so that it does not alter the linearity of the dark areas in the image though. This way, the farthest planks and the back wall would look better illuminated.

The last set of renders is designed to show the effect of different corrections on the perception of the shading on object surface due to the cosine law. In this scene, there is one light and three spheres, all at equal distance from the light.

The first render is straight out of the renderer, without any tone correction applied. Light attenuation is normal. Note that the balls seem to be sitting in a void. The wall behind them completely disapear. And due to the very slow gradient on the ball terminator, the balls all look smaller than they really are.

The second render is straight out of the renderer without any tone correction. But the light attenuation is set to linear. Observe that the wall is now visible but the shading on the balls faces is still too soft which give the balls the appearance that they are squashed as if they actually had two lobes. This is much more apparent on the two balls facing the camera. The shadow part on the balls is just too long. Also note the shade gradient on the floor and the discrepancy between the shade value on the floor vs on the wall where the floor meets the wall.

The third render is essentially the first render on which a gamma 2.2 correction was applied. Light attenuation is normal. The shading on the balls look more natural and the back wall is well illuminated. The shade gradient on the floor is also more natural looking and thus, the shading values between the floor and the wall where the two meet together, look more balanced. The shading terminator on the ball is much quicker and looks the way this scene would look in a photo.

The fourth render takes the normal render but adds a reduction of the exposure by one f-stop, then an f-curve designed to emulate the Camera RAW correction and then a gamma 2.2 correction. The hot spot, on the ground, have disapeared but the walls are a little too dark. Once again, this can be corrected by hand adjusting the f-curve.