Skip to content

Materialx upgrade#33485

Open
bhouston wants to merge 40 commits into
mrdoob:devfrom
bhouston:materialx-upgrade
Open

Materialx upgrade#33485
bhouston wants to merge 40 commits into
mrdoob:devfrom
bhouston:materialx-upgrade

Conversation

@bhouston
Copy link
Copy Markdown
Contributor

@bhouston bhouston commented Apr 27, 2026

Description

fixes #20541

The goal is to increase the parity of the MaterialX implementation. I guided this improvement via this Fidelity Test website that compared, using +300 MAterialX samples, the reference MaterialX Viewer compared to the current Three.JS MaterialXLoader and my improved MaterialXLoader.

https://material-fidelity.ben3d.ca

Preview

You can see that the new loader has basically perfect MaterialX reproducibility for pretty much everything:

The number of bugs addressed is quite massive:

  • Most noise implementations were incorrect compared to reference, so they have all been improved.
  • Dozens of minor fixes to the mx_* functions, and updating their defaults to match MaterialX expectations.
  • The conditions, mx_ifgreater/mx_ifgreatereq/mx_ifequal, were giving the opposite intended result.
  • Rotate 2d, rotate 3d, place 2d were all reimplemented to match reference.

It also introduces these new features:

  • A modular design with a separate node registry.
  • New surfaces open_pbr_surface, and gltf_pbr in addition to standard_surface.
  • Archive support, the ability to load .mtlx.zip files, such as those from AMD Material Library and PolyHaven directly.
  • Generates a report if there are warnings/errors.
  • Properly handling of default values.
  • Add support for hextile and hextilenormapmap.

Updated MaterialX noise example with all noise types showcased:

Screenshot 2026-05-01 at 10 05 45 PM

This contribution is funded by Land of Assets

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 27, 2026

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 365.32
86.78
365.32
86.78
+0 B
+0 B
WebGPU 656.3
181.39
659.93
182.55
+3.63 kB
+1.16 kB
WebGPU Nodes 654.42
181.11
658.05
182.27
+3.63 kB
+1.16 kB

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 498.04
121.5
498.04
121.5
+0 B
+0 B
WebGPU 728.29
196.33
728.29
196.33
+0 B
+0 B
WebGPU Nodes 677.5
183.73
677.5
183.73
+0 B
+0 B

Comment thread examples/jsm/loaders/materialx/MaterialXDocument.js Fixed
@bhouston bhouston changed the title Materialx upgrade WIP: Materialx upgrade Apr 27, 2026
@mrdoob mrdoob requested a review from sunag April 28, 2026 03:36
@sunag sunag added this to the r185 milestone Apr 28, 2026
@bhouston bhouston changed the title WIP: Materialx upgrade Materialx upgrade May 4, 2026
@bhouston
Copy link
Copy Markdown
Contributor Author

bhouston commented May 4, 2026

This is ready for review: @sunag. I just added textile support.

Screenshot 2026-05-04 at 10 40 20 AM

@bhouston
Copy link
Copy Markdown
Contributor Author

bhouston commented May 5, 2026

FYI: I've just identified a bug in the reference renderer MaterialXView with regards to some UV issues: AcademySoftwareFoundation/MaterialX#2881. This bug has likely leaked into ThreeJS because I was trying to match those results exactly. I will try to patch this in the next day or so.

@bhouston
Copy link
Copy Markdown
Contributor Author

bhouston commented May 5, 2026

Okay, I've completed my investigation of the UV space differences between MaterialX, Blender, ThreeJS. It turns out that ThreeJS allows both "bottom-left" and "top-left" UV spaces depending on how you load the assets.

If you load glTF assets (meshes/textures), you get "top-left" which is the glTF native uV space, but if you create ThreeJS native assets and materials outside of the glTF loader, you get "bottom-left" uv space.

Full details here: #33531

What this means is I will support both UV spaces in the MaterialXLoader so it can work on glTF and native ThreeJS assets.

}

const defaultInput = nodeX.getNodeByName( 'default' );
let fallback = float( 0 );
@bhouston bhouston force-pushed the materialx-upgrade branch from 6add2e7 to 6cc970a Compare May 11, 2026 14:02
@mrdoob
Copy link
Copy Markdown
Owner

mrdoob commented May 12, 2026

Amazing work here Ben!

@sunag
Copy link
Copy Markdown
Collaborator

sunag commented May 18, 2026

Some materials like standard_surface_color3_vec3_cm, standard_surface_brick_procedural and some others they are no longer working as expected in webgpu_loader_materialx, unlike your test link.

Could there be some difference in the code or material sample here?

webgpu_loader_materialx

image

https://material-fidelity.ben3d.ca/

image image

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.

NodeMaterial: Support MaterialX Standard Nodes

4 participants