Hello everyone,
I need to calculate the luminance of a cubemap. Now I am a bit confused about the included Luminance function in UnityCG.cginc: Unity - Manual: Built-in shader helper functions. I can’t find any reference why the RGB values in gamma or linear space are chosen like they are.
The only function I know a reference for is the LinearRgbToLuminance one, it is the ITU-R Recommendation 709. But this function is not even mentioned on the manual page for UnityCG.cginc.
// Converts color to luminance (grayscale)
inline half Luminance(half3 rgb)
{
return dot(rgb, unity_ColorSpaceLuminance.rgb);
}
// Convert rgb to luminance
// with rgb in linear space with sRGB primaries and D65 white point
half LinearRgbToLuminance(half3 linearRgb)
{
return dot(linearRgb, half3(0.2126729f, 0.7151522f, 0.0721750f));
}
Could someone help me get clarity on this? I am currently working on my thesis with Unity, so I would like to reference an official source why the luminance calculation is done this way and not differently.
The Linear space value is simply this gamma space values mentioned above, passed through Unity’s “GammeToLinearSpace” function in the UnityCG.cginc file (using the commented out “Precise version” inside it, which it references this page for the formula: