EEVEE: Use OpenColorIO for luminance

Color to grayscale conversions should take into account the colorspace,
and these are considered to be in scene linear colorspace.

Note the RBG to BW node implementation is used for implicit conversions,
so that is covered as well.

No change with the default configuration.

Pull Request: https://projects.blender.org/blender/blender/pulls/133368
This commit is contained in:
Brecht Van Lommel 2025-01-21 09:31:59 +01:00
parent e0479e2fb4
commit 5e02b4e6f1
2 changed files with 9 additions and 4 deletions

View file

@ -2,8 +2,7 @@
*
* SPDX-License-Identifier: GPL-2.0-or-later */
void rgbtobw(vec4 color, out float outval)
void rgbtobw(vec4 color, vec3 luminance_coefficients, out float outval)
{
vec3 factors = vec3(0.2126, 0.7152, 0.0722);
outval = dot(color.rgb, factors);
outval = dot(color.rgb, luminance_coefficients);
}

View file

@ -6,6 +6,10 @@
* \ingroup shdnodes
*/
#include "GPU_material.hh"
#include "IMB_colormanagement.hh"
#include "node_shader_util.hh"
namespace blender::nodes::node_shader_rgb_to_bw_cc {
@ -22,7 +26,9 @@ static int gpu_shader_rgbtobw(GPUMaterial *mat,
GPUNodeStack *in,
GPUNodeStack *out)
{
return GPU_stack_link(mat, node, "rgbtobw", in, out);
float coefficients[3];
IMB_colormanagement_get_luminance_coefficients(coefficients);
return GPU_stack_link(mat, node, "rgbtobw", in, out, GPU_constant(coefficients));
}
NODE_SHADER_MATERIALX_BEGIN