Q100149: Why the mix luminance slider in the Grade node is not a linear mix

SUMMARY

The Grade node mix luminance slider is not a linear mix. Here is an explanation of the mathematics behind the mix luminance slider in the Grade node in Nuke. 
 

MORE INFORMATION

The mix_luminance calculation in Nuke's Grade node is achieved by first converting the RGB values to digitized YPbPr, using the conversion formulae detailed in ITU-R BT.709, which includes a non-linear gamma encoding. The mixed luminance is obtained with mix_luminance as the linear ratio between color-corrected and non-color-corrected luminance values, and then we finally convert back to RGB.

In the this example with RGB values of (0.5, 0.5, 0.5), the non-color-corrected luminance works out to be 0.694, and the color-corrected luminance works out to be 0.524. The blended luminance is then:

0.5 * 0.694 + (1 - 0.5) * 0.524 = 0.609.

Converting this back to RGB values then gives approximately (0.362, 0.362, 0.362).

The the example script compares the Grade node with a straight dissolve of two Constants, where the blending is being done on the RGB values, rather than against the luminance. This is why the results are different, since the luminance conversion is non-linear.

If you paste this example script into Nuke, it will help to illustrate the difference in values.

set cut_paste_input [stack 0]
Constant {
 inputs 0
 channels rgb
 color 0.25
 name Constant3
 selected true
 xpos -37
 ypos -54
}
Constant {
 inputs 0
 channels rgb
 color 0.5
 name Constant2
 selected true
 xpos -128
 ypos -52
}
Dissolve {
 inputs 2
 channels rgb
 which 0.5
 name Dissolve1
 selected true
 xpos -87
 ypos 55
}
Constant {
 inputs 0
 channels rgb
 color {0.5 0.5 0.5 0}
 name Constant1
 selected true
 xpos -291
 ypos -53
}
Grade {
 white 0.5
 mix_luminance 0.5
 name Grade1
 selected true
 xpos -291
 ypos 26
}

    We're sorry to hear that

    Please tell us why