Skip to content

Commit cf87592

Browse files
authored
Improve MDL implementation of luminance (AcademySoftwareFoundation#2224)
Add the coefficient parameter and changed the implementation to match the other back-ends.
1 parent 9fa52ca commit cf87592

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx

+2-2
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,8 @@
505505
<!-- <saturate> implemented by nodegraph -->
506506

507507
<!-- <luminance> -->
508-
<implementation name="IM_luminance_color3_genmdl" nodedef="ND_luminance_color3" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_luminance_color3({{in}})" target="genmdl" />
509-
<implementation name="IM_luminance_color4_genmdl" nodedef="ND_luminance_color4" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_luminance_color4({{in}})" target="genmdl" />
508+
<implementation name="IM_luminance_color3_genmdl" nodedef="ND_luminance_color3" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_luminance_color3({{in}}, {{lumacoeffs}})" target="genmdl" />
509+
<implementation name="IM_luminance_color4_genmdl" nodedef="ND_luminance_color4" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_luminance_color4({{in}}, {{lumacoeffs}})" target="genmdl" />
510510

511511
<!-- <rgbtohsv> -->
512512
<implementation name="IM_rgbtohsv_color3_genmdl" nodedef="ND_rgbtohsv_color3" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_rgbtohsv_color3({{in}})" target="genmdl" />

source/MaterialXGenMdl/mdl/materialx/stdlib_1_6.mdl

+6-11
Original file line numberDiff line numberDiff line change
@@ -2653,35 +2653,30 @@ export float4 mx_curveadjust_vector4(
26532653

26542654
export color mx_luminance_color3(
26552655
color mxp_in = color(0.0, 0.0, 0.0),
2656-
uniform color mxp_lumacoeffs = color(0.2722287, 0.6740818, 0.0536895)
2656+
color mxp_lumacoeffs = color(0.2722287, 0.6740818, 0.0536895)
26572657
[[
2658-
anno::description("Enumeration {acescg, rec709, rec2020, rec2100}."),
2659-
anno::unused()
2658+
anno::description("Enumeration {acescg, rec709, rec2020, rec2100}.")
26602659
]]
26612660
)
26622661
[[
26632662
anno::description("Node Group: adjustment")
26642663
]]
26652664
{
2666-
return color(::math::luminance(mxp_in));
2665+
return color(::math::dot(float3(mxp_in), float3(mxp_lumacoeffs)));
26672666
}
26682667

26692668
export core::color4 mx_luminance_color4(
26702669
core::color4 mxp_in = core::mk_color4(0.0, 0.0, 0.0, 0.0),
2671-
uniform color mxp_lumacoeffs = color(0.2722287, 0.6740818, 0.0536895)
2670+
color mxp_lumacoeffs = color(0.2722287, 0.6740818, 0.0536895)
26722671
[[
2673-
anno::description("Enumeration {acescg, rec709, rec2020, rec2100}."),
2674-
anno::unused()
2672+
anno::description("Enumeration {acescg, rec709, rec2020, rec2100}.")
26752673
]]
26762674
)
26772675
[[
26782676
anno::description("Node Group: adjustment")
26792677
]]
26802678
{
2681-
color rgb = color(mxp_in.rgb);
2682-
core::color4 returnValue = core::mk_color4(::math::luminance(rgb));
2683-
returnValue.a = mxp_in.a;
2684-
return returnValue;
2679+
return core::mk_color4(color(::math::dot(float3(mxp_in.rgb), float3(mxp_lumacoeffs))), mxp_in.a);
26852680
}
26862681

26872682
export color mx_rgbtohsv_color3(

0 commit comments

Comments
 (0)