Renderer: Add NodeMaterial rebuild debug reporting by RenaudRohlinger · Pull Request #33311 · mrdoob/three.js · GitHub
Skip to content

Renderer: Add NodeMaterial rebuild debug reporting#33311

Open
RenaudRohlinger wants to merge 22 commits into
mrdoob:devfrom
RenaudRohlinger:features/materials_debug_rebuild
Open

Renderer: Add NodeMaterial rebuild debug reporting#33311
RenaudRohlinger wants to merge 22 commits into
mrdoob:devfrom
RenaudRohlinger:features/materials_debug_rebuild

Conversation

@RenaudRohlinger

@RenaudRohlinger RenaudRohlinger commented Apr 2, 2026

Copy link
Copy Markdown
Collaborator

This adds a renderer debug path to trace when a NodeMaterial needs rebuild and why. Today it can be very hard to
understand why a material suddenly rebuilds after a scene or material change, even though that rebuild is one of the
most expensive operations in the renderer.

With this change, renderer.debug can report the material name or type, the cache contributor that changed, and readable before/after values, including scene-driven causes such as light setup changes.

A small WebGPU example is included to demonstrate the feature visually, making rebuilds much easier to track and optimize:
image

This contribution is funded by Spawn

@github-actions

github-actions Bot commented Apr 2, 2026

Copy link
Copy Markdown

@RenaudRohlinger RenaudRohlinger force-pushed the features/materials_debug_rebuild branch from d794fad to 6b4d65d Compare April 2, 2026 01:59
@RenaudRohlinger RenaudRohlinger added this to the r184 milestone Apr 2, 2026
@RenaudRohlinger RenaudRohlinger marked this pull request as draft April 2, 2026 11:49
@sunag

sunag commented Apr 2, 2026

Copy link
Copy Markdown
Collaborator

Do you think we can move it to the Inspector as a new tab or extension?

@RenaudRohlinger

Copy link
Copy Markdown
Collaborator Author

A new tab could definitely use it yes, but I don't think the inspector should own the feature.

Or maybe the same logic as the checkbox options such as forceWebGL?

@sunag

sunag commented Apr 3, 2026

Copy link
Copy Markdown
Collaborator

but I don't think the inspector should own the feature.

Hmm.. Why do you think that? The first impression I had was that it would be an inspection tool; a UI that would accompany any example, without needing to be recreated, would be useful.

Another thing I would suggest in this regard is, let’s say you add an option in the Console tab; when enabled, I think it’s preferable to do monkey patching on the RenderObjects.prototype.get prototype or interception through an abstraction interface so that we don’t need to add NodeMaterialDebug.js and other configurations to the core.

I’ve been adding, through the inspector, this monkey patching to prevent complex debugging code from becoming incompatible with tree-shaking, a technique similar to what the WebGL Dev Extension does.

Comment thread examples/jsm/inspector/NodeMaterialDebugAnalyzer.js Fixed
@RenaudRohlinger RenaudRohlinger marked this pull request as ready for review April 10, 2026 02:19
Comment thread examples/jsm/inspector/NodeMaterialDebugAnalyzer.js Fixed
Comment thread examples/jsm/inspector/NodeMaterialDebugAnalyzer.js Fixed
Comment thread examples/jsm/inspector/NodeMaterialDebugAnalyzer.js Fixed
@RenaudRohlinger

Copy link
Copy Markdown
Collaborator Author

Comment thread examples/jsm/inspector/tabs/Settings.js Outdated
Comment thread examples/webgpu_materials_debug_rebuild.html Outdated
@mrdoob mrdoob modified the milestones: r184, r185 Apr 16, 2026
@mrdoob mrdoob modified the milestones: r185, r186 Jun 24, 2026
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