Skip to content

Add extract node support for matrix33 and matrix44 types#2812

Merged
jstone-lucasfilm merged 10 commits intoAcademySoftwareFoundation:mainfrom
JHUbisoft:extract-matrix-support
Mar 17, 2026
Merged

Add extract node support for matrix33 and matrix44 types#2812
jstone-lucasfilm merged 10 commits intoAcademySoftwareFoundation:mainfrom
JHUbisoft:extract-matrix-support

Conversation

@JHUbisoft
Copy link
Contributor

Add extract node definitions for matrix33 and matrix44 types, enabling
row vector extraction by index from matrices.

  • matrix33 extract returns vector3 (row index 0-2)
  • matrix44 extract returns vector4 (row index 0-3)

Includes node definitions, implementations for GLSL, MDL, and OSL
backends, and corresponding unit tests.

  Add extract node definitions for matrix33 and matrix44 types, enabling
  row vector extraction by index from matrices.

  - matrix33 extract returns vector3 (row index 0-2)
  - matrix44 extract returns vector4 (row index 0-3)

  Includes node definitions, implementations for GLSL, MDL, and OSL
  backends, and corresponding unit tests.
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Mar 10, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: JHUbisoft / name: JH (a196076)

@dbsmythe
Copy link
Contributor

In the MaterialX Proposals document https://github.com/AcademySoftwareFoundation/MaterialX/blob/main/documents/Specification/MaterialX.Proposals.md#propose-stdlib-nodes something essentially identical to this is proposed for addition to the spec, although there it was called <extractrowvector> which is marginally clearer. Is there a strong feeling from the community which node naming would be preferred for this?

@dbsmythe
Copy link
Contributor

Also noting that if we add a new node or new signatures for an existing node, the MaterialX.Specification.md document must also be updated to keep them in sync.

@JHUbisoft
Copy link
Contributor Author

JHUbisoft commented Mar 11, 2026

About the documentation : it would mean that extract purpose instead of extracting float from vectors, it would be more : extract a n-1 dimension subpart from a n dimension aggregate. What do you think ?
By the way, I have updated the standardnodes documentation consequently.

Add documentation for the new extract node variants that operate on matrix33 and matrix44 types (extracting row vectors by index)
@dbsmythe
Copy link
Contributor

The changes to MaterialX.Specification.md look good to me; I'll let other reviewers approve the code changes.

@jstone-lucasfilm
Copy link
Member

This looks really promising, @JHUbisoft, and thanks to @dbsmythe for the specification language review.

Let's plan to take a close look at the implementations soon, so that we have the option of including this work in v1.39.5 if it's ready to merge.

@jstone-lucasfilm
Copy link
Member

@JHUbisoft The GLSL and MDL implementations look correct to me, but am I right in my observation that the mx_extract overloads for matrix types are missing in OSL? Without those, I don't believe the generated OSL code will compile after this PR is merged, but let me know if I'm missing an important detail.

  Add two overloads in mx_funcs.h:
  - vector mx_extract(matrix33, int): extracts row by index
  - vector4 mx_extract(matrix, int): extracts row by index
@JHUbisoft
Copy link
Contributor Author

@JHUbisoft The GLSL and MDL implementations look correct to me, but am I right in my observation that the mx_extract overloads for matrix types are missing in OSL? Without those, I don't believe the generated OSL code will compile after this PR is merged, but let me know if I'm missing an important detail.

Oups, you are right. I have added OSL code.

Copy link
Member

@jstone-lucasfilm jstone-lucasfilm left a comment

Choose a reason for hiding this comment

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

This looks good to me, thanks @JHUbisoft!

@jstone-lucasfilm jstone-lucasfilm merged commit 5e0e578 into AcademySoftwareFoundation:main Mar 17, 2026
36 checks passed
@JHUbisoft
Copy link
Contributor Author

Thank you

@JHUbisoft JHUbisoft deleted the extract-matrix-support branch March 18, 2026 16:50
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.

3 participants