# how does cycles calculate RGB to BW

There are many ways to calculate RGB to BW. Which of those ways does Cycles use in the RGB to BW node? (I took a quick look at the git repository, but it's not searchable and I couldn't find the node source code.)

Black and white, or more appropriately greyscale, is based on the luminance weights of the primary lights for a given reference. That is, not physical energy, but visual energy. If one were to project equal energy sRGB values from a screen, despite being equal physical energy, the visual energy would appear as though the sRGB green channel was most luminous, with red following, and blue seeming the least luminous.

As one can clearly see from the above example, luminance is not an equal average of each channel. There are countless clueless formulas for calculating greyscale imagery based off of equally clueless offerings, including such averaging and other misinformed foolishness.

The default reference space for Blender is based upon REC.709 primaries, as those are the primaries that define the sRGB specification. As such, to properly calculate greyscale, we use the normalized luminance, or the normalized Y value for each primary as given under the CIE XYZ model, to weight the sRGB values.

Those weights are typically represented as 0.2126*R + 0.7152*G + 0.0722*B. Blender utilizes the values from the OpenColorIO configuration as given on the "luma" line in https://git.blender.org/gitweb/gitweb.cgi/blender.git/blob_plain/HEAD:/release/datafiles/colormanagement/config.ocio.

For any given RGB colourspace such as sRGB, there is exactly one correct method to derive average luminance.

Casual Discussion

If we have a RGB Triple (r,g,b) and we want another RGB Triple (s,s,s) There are various methods

01. s = average(r,g,b) = (r + g + b) / 3 ... factor of 1/3 or .333 ad infinitum

Sensible with no preference for human vision.

02. s = .21 r + .72 g + .07 b

Preference for human vision.

There are other ways documented in Wikipedia and serious documents on color.

I am not looking at Python or C or C++ Code for Blender.