MaterialX icon indicating copy to clipboard operation
MaterialX copied to clipboard

WIP: Extending `mix` node to allow per channel mixing

Open friedererdmann opened this issue 2 years ago • 1 comments

Extending mix node to allow per channel mixing

The mix node's mix input should allow for all data formats as input and do a per element linear interpolation, not just float. Example given:

in1 = Vector2(1,1)
in2 = Vector2(0,0)
mix = Vector2(1,0)
out = Vector2(1,0)

For backwards compatibility float mixing remains supported.

Adding node definitions with the extra suffix of the mix data type like ND_mix_color3_color3.

Note: So far I've only tested in MaterialX Viewer, I'm still working on some tests and will try to see results in other renderers.

friedererdmann avatar Sep 14 '22 20:09 friedererdmann

CLA Signed

The committers listed above are authorized under a signed CLA.

  • :white_check_mark: login: friedererdmann / name: Frieder Erdmann (c0cd1a61eed6d6de46ead0c28e927facd5457776)

This proposal looks good to me, thanks @friedererdmann. I'm CC'ing @dbsmythe and @niklasharrysson for their thoughts.

jstone-lucasfilm avatar Sep 25 '22 01:09 jstone-lucasfilm

Looks good for GLSL and OSL. See attached renders from the testsuite. For MDL there is a small change needed, see above.

mix_nodes.pdf

niklasharrysson avatar Sep 26 '22 12:09 niklasharrysson

I've updated the v1.39 Spec document to mention support for per-channel operations: The Mix node takes two 1-4 channel inputs fg and bg plus a separate 1-channel (float) or N-channel (same type and number of channels as fg and bg) mix input and mixes the fg and bg according to the mix value, either uniformly for a "float" mix type, or per-channel for non-float mix types.

dbsmythe avatar Sep 27 '22 16:09 dbsmythe

Looks good! Thanks @friedererdmann

Thanks Niklas for your review and feedback! I don't seem to be able to merge myself, will you merge the PR?

friedererdmann avatar Sep 27 '22 18:09 friedererdmann