Nodes: Inject shader name into shader by WestLangley · Pull Request #31363 · mrdoob/three.js · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

Nodes: Inject shader name into shader #31363

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

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

WestLangley
Copy link
Collaborator

Adding a shader name to the Node-based shaders has been very helpful to me.

Perhaps the implementation in this PR can be improved, but I like the concept.

Copy link

github-actions bot commented Jul 4, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 337.69
78.76
337.69
78.76
+0 B
+0 B
WebGPU 557.69
154.41
557.84
154.46
+145 B
+46 B
WebGPU Nodes 556.61
154.19
556.76
154.24
+145 B
+45 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 468.91
113.45
468.91
113.45
+0 B
+0 B
WebGPU 633.32
171.43
633.42
171.45
+106 B
+27 B
WebGPU Nodes 588.45
160.78
588.56
160.81
+106 B
+29 B

this.vertexShader = this._getGLSLVertexCode( shadersData.vertex );
this.fragmentShader = this._getGLSLFragmentCode( shadersData.fragment );
const name = this.material.name;
const shaderName = ( name !== '' ) ? name : this.material.constructor.name;
Copy link
Collaborator

@Mugen87 Mugen87 Jul 4, 2025

Choose a reason for hiding this comment

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

How about adding name to the shadersData object (with '' as the default)?

const shadersData = this.material !== null ? { name: '', fragment: {}, vertex: {} } : { name: '', compute: {} };

In this way, there is no need to change the signature of _getGLSLVertexCode() and _getGLSLFragmentCode().

Copy link
Collaborator

Choose a reason for hiding this comment

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

WGSLNodeBuilder should also be updated.

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.

2 participants

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.