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

Extend mix node to allow per channel mixing #1077

Conversation

friedererdmann
Copy link
Contributor

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.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Sep 14, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: friedererdmann / name: Frieder Erdmann (c0cd1a6)

@jstone-lucasfilm jstone-lucasfilm marked this pull request as ready for review September 25, 2022 01:14
@jstone-lucasfilm jstone-lucasfilm changed the title WIP: Extending mix node to allow per channel mixing Extend mix node to allow per channel mixing Sep 25, 2022
@jstone-lucasfilm
Copy link
Member

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

@niklasharrysson
Copy link
Contributor

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

Copy link
Contributor

@niklasharrysson niklasharrysson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks @friedererdmann

@dbsmythe
Copy link
Contributor

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.

@friedererdmann
Copy link
Contributor Author

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?

@jstone-lucasfilm jstone-lucasfilm changed the title Extend mix node to allow per channel mixing Extend mix node to allow per channel mixing Sep 28, 2022
@jstone-lucasfilm jstone-lucasfilm merged commit 99a0658 into AcademySoftwareFoundation:main Sep 28, 2022
Michaelredaa pushed a commit to Michaelredaa/MaterialX that referenced this pull request Oct 21, 2023
…n#1077)

The mix node's mix input should allow for all data formats as input and do a per element linear interpolation, not just float.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants