Skip to content

TSL: Remove transformed* prefix #31271

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

Merged
merged 8 commits into from
Jun 16, 2025
Merged

TSL: Remove transformed* prefix #31271

merged 8 commits into from
Jun 16, 2025

Conversation

sunag
Copy link
Collaborator

@sunag sunag commented Jun 15, 2025

Related issue: #31177, #31260, #30849

Description

Removing the transformed prefix from normals also simplifies the shader creation process, making it less confusing.

For those who need normals without the fine surface transformations (fragment), a suffix called Geometry has been added, such as normalViewGeometry.

With the implementation of namespace, the normalView node, for example, will return the same as normalViewGeometry if used inside the material.normalNode input, and if used outside, it will use the final calculation.

This is also more in line with the strategy of moving the vertex calculations from skinning and morph to compute() and leaving it with the fewest possible modifications, perhaps none for the target developer.

@sunag sunag mentioned this pull request Jun 15, 2025
12 tasks
Copy link

github-actions bot commented Jun 15, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 337.54
78.73
337.54
78.73
+0 B
+0 B
WebGPU 555.73
153.92
556.32
154.12
+591 B
+205 B
WebGPU Nodes 555.08
153.76
555.67
153.97
+591 B
+204 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 468.74
113.38
468.74
113.38
+0 B
+0 B
WebGPU 631.33
170.79
632.24
171.08
+911 B
+291 B
WebGPU Nodes 586.18
160.12
587.24
160.39
+1.06 kB
+267 B

@sunag sunag added this to the r178 milestone Jun 15, 2025
@sunag sunag marked this pull request as ready for review June 15, 2025 19:15
@sunag
Copy link
Collaborator Author

sunag commented Jun 16, 2025

If a normalMap is used, the normalWorld cannot calculate surface reliefs during the vertex stage or while constructing normals, as this would lead to recursive computation issues. Therefore, in both cases, normalWorld behaves according to the logic defined in each specific build and sub-build stage of the shader.

Vertex Stage or Normal Sub-Build Stage Fragment Stage
image image
// Examples of Vertex-Stage
material.positionNode = normalWorld /*... no logic considering only for example ...*/
material.colorNode = normalWorld.toVertexStage(); // run normalWorld completely in vertex-stage

// Example of Normal Sub-Build Stage
material.normalNode = normalWorld  /*... no logic considering only for example ...*/

// Examples of Fragment-Stage
material.colorNode = normalWorld;
material.opacityNode = normalWorld;
material.roughnessNode = normalWorld;
material.metalnessNode = normalWorld;
// etc

/cc @mrdoob @Mugen87

@sunag sunag merged commit db897c4 into mrdoob:dev Jun 16, 2025
12 checks passed
@sunag sunag deleted the dev-normals branch June 16, 2025 19:48
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.

1 participant