Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nodes: Fix recursion with environment nodes. #30277

Merged
merged 3 commits into from
Jan 7, 2025
Merged

Nodes: Fix recursion with environment nodes. #30277

merged 3 commits into from
Jan 7, 2025

Conversation

Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Jan 7, 2025

Fixed #30255.

Description

This fixes the recursion issue when using NormalMapNode with EnvironmentNode.

The root cause is that EnvironmentNode modifies the builder's context with a custom getUV() which relies on transformedNormalView. Using this TSL object triggers setupNormal() which consequently triggers the build of NormalMapNode which now uses an invalid getUV() implementation.

@sunag Granted this is a bit of an edge case but this kind of context behavior might be unexpected in other scenarios as well. It would be great to limit the scope of context() somehow so code like in NormalMapNode wouldn't be necessary.

Copy link

github-actions bot commented Jan 7, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 339.49
79.09
339.49
79.09
+0 B
+0 B
WebGPU 489.97
135.94
489.97
135.94
+0 B
-3 B
WebGPU Nodes 489.44
135.82
489.44
135.82
+0 B
-2 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 465.35
112.14
465.35
112.14
+0 B
+0 B
WebGPU 559.35
151.41
559.35
151.41
+0 B
-3 B
WebGPU Nodes 515.42
141.19
515.45
141.2
+20 B
+4 B

@sunag
Copy link
Collaborator

sunag commented Jan 7, 2025

I removed context inheritance for setupNormal() and setupClearcoatNormal() . Previously this was only being applied to non-node materials. I think this way it will get a larger scope in use cases like bumpMap for example.

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Jan 7, 2025

LGTM!

@Mugen87 Mugen87 added this to the r173 milestone Jan 7, 2025
@sunag sunag changed the title NormalMapNode: Fix recursion with environment nodes. Nodes: Fix recursion with environment nodes. Jan 7, 2025
@sunag sunag merged commit be84ecf into mrdoob:dev Jan 7, 2025
12 checks passed
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.

Uncaught RangeError: Maximum call stack size exceeded when using normalNode with only scene environment
2 participants