New experimental version of "Filmic" tone mapping in Photoflow

While the current tone mapping module in Photoflow works quite well, I was not entirely satisfied by the shape of the resulting tone mapping curve and the behavior of the available controls. After getting some inspiration from Darktable’s “Filmic RGB v4” code, I went ahead and re-wrote an (hopefully) improved module.

Like DT’s implementation, the new tone mapping curve actually works on log-encoded values. However, this is mostly because working in log space greatly simplifies the math, especially since power conversions in linear space are “mapped” to simple multiplications in log space.

Compared to DT’s implementation, there are some important differences:

  • the module can be configured to generate an “identity” mapping, that is an output identical to the input.
  • the slope of the tone mapping curve at the black and white points is adjustable; above 1 the values are extrapolated linearly (in log space, which means they are mapped with a power function at constant exponent in linear space) and are still editable by additional modules, if needed. As far as understand, DT’s filmic curve instead flattens at both ends of the output range.

Here is a screenshot of the new module:

The UI shows the tone mapping curve in linear space. The two points correspond to the mid-grey output value and the “diffuse white” input value.

The new tone mapping module is accessible in the “experimental” tools group. This means that the behavior of the tool is not yet finalized, and future versions might not be backward compatible. Therefore I strongly suggest not to use the module for any edit that you would like to keep, at least not for the moment…

Below you can find some plots explaining the meaning of the various parameters.

Any feedback would be very much appreciated!

White level
It defines the input value that gets mapped to output=1. The scale is in EV relative to input=1.
In other words, “white level = 0, 1, 2, …” corresponds respectively to “input = 1, 2, 4, …”

It controls the extent of the linear portion of the tone curve around the mid-grey point (in log space).

It controls the linear slope of the lower end of the curve, up to the latitude upper limit.
Increasing the exposure value allows to rise the brightness of the shadows and mid-tones without changing the white point.

Highlights slope:
It controls the slope of the tone curve at the white point. Negative slope values correspond to a flattened curve when approaching the white level, while positive values correspond to a steep curve.
The transition point from the linear portion to the highlights shoulder is controlled by the latitude value. When latitude = 0 the transition starts just above the mid-grey point.

Mid-tones slope:
Controls the slope of the tone curve at the mid-grey point. Positive values correspond to an increased mid-tones contrast, negative values to a contrast decrease. The linear portion of the curve around the mid-grey point (in log space) is controlled by the latency parameter.

Shadows slope:
It gives fine control over the the shape of the tone curve near the black point. Positive values produce a darker output in deep shadows and a brighter output in the mid-tones range.