Skip to content

Commit

Permalink
PR AcademySoftwareFoundation#2224 - MDL: improve mx_luminance_color* …
Browse files Browse the repository at this point in the history
…implementation
  • Loading branch information
krohmerNV committed Feb 12, 2025
1 parent 7f92cc8 commit c765ce5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
4 changes: 2 additions & 2 deletions libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,8 @@
<!-- <saturate> implemented by nodegraph -->

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

<!-- <rgbtohsv> -->
<implementation name="IM_rgbtohsv_color3_genmdl" nodedef="ND_rgbtohsv_color3" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_rgbtohsv_color3({{in}})" target="genmdl" />
Expand Down
18 changes: 7 additions & 11 deletions source/MaterialXGenMdl/mdl/materialx/stdlib_1_6.mdl
Original file line number Diff line number Diff line change
Expand Up @@ -2653,35 +2653,31 @@ export float4 mx_curveadjust_vector4(

export color mx_luminance_color3(
color mxp_in = color(0.0, 0.0, 0.0),
uniform color mxp_lumacoeffs = color(0.2722287, 0.6740818, 0.0536895)
color mxp_lumacoeffs = color(0.2722287, 0.6740818, 0.0536895)
[[
anno::description("Enumeration {acescg, rec709, rec2020, rec2100}."),
anno::unused()
anno::description("Enumeration {acescg, rec709, rec2020, rec2100}.")
]]
)
[[
anno::description("Node Group: adjustment")
]]
{
return color(::math::luminance(mxp_in));

return color(::math::dot(float3(mxp_in), float3(mxp_lumacoeffs)));
}

export core::color4 mx_luminance_color4(
core::color4 mxp_in = core::mk_color4(0.0, 0.0, 0.0, 0.0),
uniform color mxp_lumacoeffs = color(0.2722287, 0.6740818, 0.0536895)
color mxp_lumacoeffs = color(0.2722287, 0.6740818, 0.0536895)
[[
anno::description("Enumeration {acescg, rec709, rec2020, rec2100}."),
anno::unused()
anno::description("Enumeration {acescg, rec709, rec2020, rec2100}.")
]]
)
[[
anno::description("Node Group: adjustment")
]]
{
color rgb = color(mxp_in.rgb);
core::color4 returnValue = core::mk_color4(::math::luminance(rgb));
returnValue.a = mxp_in.a;
return returnValue;
return core::mk_color4(color(::math::dot(float3(mxp_in.rgb), float3(mxp_lumacoeffs))), mxp_in.a);
}

export color mx_rgbtohsv_color3(
Expand Down

0 comments on commit c765ce5

Please sign in to comment.