SweetFX icon indicating copy to clipboard operation
SweetFX copied to clipboard

Gamma behaves differently in LiftGammaGain.fx than Tonemap.fx

Open EricBanker12 opened this issue 1 year ago • 4 comments

LiftGammaGain.fx line 39 applies gamma input using formula: color = pow(abs(color), 1.0 / RGB_Gamma);

However, Tonemap.fx line 43 uses the formula color = pow(color, Gamma);

Is one of these implementations wrong?

EricBanker12 avatar Jul 26 '23 18:07 EricBanker12

According to wikipedia, the LiftGammaGain.fx implementation is wrong because smaller values should be lighter, larger values darker, which is the opposite of the shader's observed behavior.

EricBanker12 avatar Jul 26 '23 18:07 EricBanker12

They're both technically right.

Gamma is a stupidly convoluted term.

Sometimes it means x^g, sometimes it means x^(1/g), sometimes it even just means xg. It's for this reason the actual sRGB spec completely abstains from using the term gamma—because of its stupidly complex variant definitions to wrangle through.

Ambiguity in the definition of the term “gamma” Historically, both the photographic and television industries claim integral use of the term “gamma” for different effects. Hurter and Driffield first used the term in the 1890s in describing the straight-line portion of the density versus log exposure curves that describe photographic sensitometry. The photographic sensitometry field has used several interrelated terms to describe similar effects, including gamma, slope, gradient, and contrast. Both Languimier in the 1910s and Oliver in the 1940s defined “gamma” for the television industry (and thus the computer graphics industry) as the exponential value in both simple and complex power functions that describe the relationship between gun voltage and intensity (or luminance). In fact, even within the television industry, there are multiple, conflicting definitions of “gamma”. These include differences in describing physical aspects (such as gun “gamma” and phosphor “gamma”). These also include differences in equations for the same physical aspect (there are currently at least three commonly used equations in the computer graphics industry to describe the relationship between gun voltage and intensity, all of which provide significantly different results). After significant insightful feedback from many industries, this standard has explicitly chosen to avoid the use of the term “gamma”. Furthermore, it appears that the usefulness of the term in unambiguous, constructive standard terminology is zero and its continued use is detrimental to consistent cross-reference between standards and unambiguous communication.

Regardless of it being an error or not, people have adapted to using it and "fixing" it may simply make life harder for people who already use Tonemap.fx and LiftGammaGain.fx. Their configurations (presets) will be incorrect after an update.

nullfrctl avatar Jul 26 '23 19:07 nullfrctl

Furthermore, the ASC CDL (American Society of Cinematographers Color Decision List) doesn't include the term gamma either, lift or gain too.

It calls gain "slope", because it's multiplying the color—modifying its slope. It calls lift "offset", because it's adding to the color—offsetting it. Finally, it calls gamma "power", because it's a direct power to the color.

Maybe a new shader called ASC CDL could solve these ambiguity issues. There could be a tooltip or clarifying part of the label (e.g. "Slope (Gain)") to make sure it is understood.

nullfrctl avatar Jul 26 '23 19:07 nullfrctl

I agree. I've never had any user complaints about it and by now the way they work is in all presets that use them so changing them would break the presets.

CeeJayDK avatar Jul 26 '23 20:07 CeeJayDK