Bug fix: genmsl image node handling for MaterialX constant texture address#2891
Open
bhouston wants to merge 1 commit into
Open
Bug fix: genmsl image node handling for MaterialX constant texture address#2891bhouston wants to merge 1 commit into
bhouston wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Metal previously relied on
MTLSamplerAddressModeClampToBorderColorforconstantaddressing. Metal samplers only support opaque black/white border colors, so arbitrary MaterialX imagedefaultvalues, for example bright green-yellow, rendered incorrectly as white.Fix
float,color3,color4,vector2,vector3, andvector4.mx_image_coord_out_of_bounds, that checks transformed UVs against[0, 1]only for axes usingconstantaddress mode.defaultinput; otherwise it samples the texture normally.stdlib_genmsl_impl.mtlxto use these MSL image implementations instead of reusing the GLSL versions.How It Was Realized
This was found through fidelity samples that set
uaddressmodeandvaddressmodetoconstantwith a non-white default color. GLSL, OSL, Three.js, and Blender produced the expected default color outside the valid UV range, while Metal showed white. InspectingMetalTextureHandler.mmshowed the Metal backend mapsconstantto sampler border color and chooses only black or white based ondefaultColor[0], which cannot represent arbitrary defaults (such as purple in this example.(Validation
Rendered the focused address-mode samples through
materialx-metal:pnpm cli render --materials "re:image_addressmode_(constant|clamp|periodic|mirror)$" --renderers materialx-metalAll 4 renders succeeded, and the constant-mode sample now shows the expected magenta default region.