From 1b795894be58dbf06b235aec436335227118bbfc Mon Sep 17 00:00:00 2001 From: Rasmus Bonnedal Date: Sat, 22 Oct 2022 22:50:54 +0200 Subject: [PATCH] Fix implementation of screen node (#1111) The parentheses were incorrectly placed in the implementation of the screen compositing node. Changes from this: (mix * ((1 - (1 - fg)) * (1 - bg))) + ((1 - mix) * bg) to this: (mix * ((1 - (1 - fg) * (1 - bg)))) + ((1 - mix) * bg) --- libraries/stdlib/genglsl/mx_screen.inline | 2 +- libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx | 4 ++-- libraries/stdlib/genosl/mx_screen.inline | 2 +- source/MaterialXGenMdl/mdl/materialx/stdlib.mdl | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/stdlib/genglsl/mx_screen.inline b/libraries/stdlib/genglsl/mx_screen.inline index cbfa5872e1..a3bbccf7af 100644 --- a/libraries/stdlib/genglsl/mx_screen.inline +++ b/libraries/stdlib/genglsl/mx_screen.inline @@ -1 +1 @@ -({{mix}}*((1.0 - (1.0 - {{fg}})) * (1.0 - {{bg}}))) + ((1.0-{{mix}})*{{bg}}) +({{mix}}*((1.0 - (1.0 - {{fg}}) * (1.0 - {{bg}})))) + ((1.0-{{mix}})*{{bg}}) diff --git a/libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx b/libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx index bb792523b1..bf848d7b3d 100644 --- a/libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx +++ b/libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx @@ -562,8 +562,8 @@ - - + + diff --git a/libraries/stdlib/genosl/mx_screen.inline b/libraries/stdlib/genosl/mx_screen.inline index 741b58d953..3a741aaba3 100644 --- a/libraries/stdlib/genosl/mx_screen.inline +++ b/libraries/stdlib/genosl/mx_screen.inline @@ -1 +1 @@ -({{mix}}*((1.0 - (1.0 - {{fg}})) * (1 - {{bg}}))) + ((1.0-{{mix}})*{{bg}}) +({{mix}}*((1.0 - (1.0 - {{fg}}) * (1 - {{bg}})))) + ((1.0-{{mix}})*{{bg}}) diff --git a/source/MaterialXGenMdl/mdl/materialx/stdlib.mdl b/source/MaterialXGenMdl/mdl/materialx/stdlib.mdl index 5e022ec7d7..3df67214ba 100644 --- a/source/MaterialXGenMdl/mdl/materialx/stdlib.mdl +++ b/source/MaterialXGenMdl/mdl/materialx/stdlib.mdl @@ -2770,8 +2770,8 @@ export color4 mx_screen_color4( anno::description("Node Group: compositing") ]] { - color rgb = (mxp_mix*((1.0 - (1.0 - mxp_fg.rgb)) * (1 - mxp_bg.rgb))) + ((1.0-mxp_mix)*mxp_bg.rgb); - float a = (mxp_mix*((1.0 - (1.0 - mxp_fg.a )) * (1 - mxp_bg.a ))) + ((1.0-mxp_mix)*mxp_bg.a ); + color rgb = (mxp_mix*((1.0 - (1.0 - mxp_fg.rgb) * (1 - mxp_bg.rgb)))) + ((1.0-mxp_mix)*mxp_bg.rgb); + float a = (mxp_mix*((1.0 - (1.0 - mxp_fg.a ) * (1 - mxp_bg.a )))) + ((1.0-mxp_mix)*mxp_bg.a ); return color4(rgb,a); }