Skip to content

Fix some obscure swizzle upgrade bugs - #2637

Merged
jstone-lucasfilm merged 4 commits into
AcademySoftwareFoundation:mainfrom
autodesk-forks:gamaj/fix_swizzle_upgrade_corner_cases
Nov 12, 2025
Merged

Fix some obscure swizzle upgrade bugs#2637
jstone-lucasfilm merged 4 commits into
AcademySoftwareFoundation:mainfrom
autodesk-forks:gamaj/fix_swizzle_upgrade_corner_cases

Conversation

@JGamache-autodesk

Copy link
Copy Markdown
Contributor

Was working on upgrading a MaterialX material when it is written using UsdShade data model, and that required reviewing the current upgrade code to convert it to Python/USD. Also was working on a unit test, which forced me to put on my QA hat and start devising devious ways to fail the code.

This resulted in the following two fixes for extremely rare corner cases.

Comment thread source/MaterialXCore/Version.cpp Outdated
Comment thread source/MaterialXCore/Version.cpp
@JGamache-autodesk

Copy link
Copy Markdown
Contributor Author

Hmmm, while writing test cases I found out that a freshly created swizzle node gets completely ignored. Not good. We need to convert that into a constant 0 node of the right type since that node has a default value for in of zero and for channels something like "always first channel".

@JGamache-autodesk

Copy link
Copy Markdown
Contributor Author

Tested against
upgrade_to_1_39_test_cases.zip
Which hits 100% coverage of the node section of the 1.38 to 1.39 update and resolves as expected.

Still one remaining issue of the nitpick type. The { "rgb", 4 } and { "xyz", 4 } in CHANNEL_CONVERT_PATTERNS fail in a very subtle way when the source type is color3 or vector3. In these cases, the swizzle resolves the missing last channel to r or x while the convert resolves to 1. I can create a scene where the upgrade will cause a look change, but I don't think we will ever see this case in the wild.

@jstone-lucasfilm jstone-lucasfilm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for diving into these tricky edge cases, @JGamache-autodesk, and the changes look good to me!

@jstone-lucasfilm
jstone-lucasfilm merged commit 32bdd68 into AcademySoftwareFoundation:main Nov 12, 2025
32 checks passed
@JGamache-autodesk
JGamache-autodesk deleted the gamaj/fix_swizzle_upgrade_corner_cases branch November 12, 2025 14:12
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.

2 participants