Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve MDL implementation of luminance #2224

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
17 changes: 6 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,30 @@ 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