Skip to content

TSL: Remove transformed* prefix - WIP#31177

Closed
sunag wants to merge 9 commits into
mrdoob:devfrom
sunag:dev-normals-rev-1
Closed

TSL: Remove transformed* prefix - WIP#31177
sunag wants to merge 9 commits into
mrdoob:devfrom
sunag:dev-normals-rev-1

Conversation

@sunag

@sunag sunag commented May 26, 2025

Copy link
Copy Markdown
Collaborator

Related issue: #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 Apr 22, 2025
12 tasks
@github-actions

github-actions Bot commented May 26, 2025

Copy link
Copy Markdown

📦 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 553.97
153.41
554.82
153.6
+849 B
+190 B
WebGPU Nodes 553.32
153.26
554.17
153.45
+849 B
+189 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 629.59
170.31
630.81
170.59
+1.22 kB
+282 B
WebGPU Nodes 584.44
159.66
585.85
159.93
+1.41 kB
+265 B

@sunag sunag added this to the r177 milestone May 26, 2025
@mrdoob

mrdoob commented May 27, 2025

Copy link
Copy Markdown
Owner

Curious about why you called it "namespace". Wondering if there are more intuitive names...

@sunag

sunag commented May 27, 2025

Copy link
Copy Markdown
Collaborator Author

Curious about why you called it "namespace". Wondering if there are more intuitive names...

I slept thinking about it too hehe. Namespace is used to separate blocks and generate prefixes, it is one of the things that happens although the execution behavior is very specific, executing within one namespace and another. It is a named flow control referring to the input of the material, perhaps we could link it to a naming referring to this process.

@mrdoob

mrdoob commented May 28, 2025

Copy link
Copy Markdown
Owner

Yeah, are there alternatives? Would block be an alternative?

@sunag sunag modified the milestones: r177, r178 May 28, 2025
<script type="module">

import * as THREE from 'three';
import { Fn, time, vec2, vec3, uv, texture, mix, checker, normalLocal, namespace, positionLocal, color, oscSine, attribute } from 'three/tsl';

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused imports attribute, checker, color, mix, normalLocal, oscSine, positionLocal, texture, time, uv, vec2.
import * as THREE from 'three';
import { Fn, time, vec2, vec3, uv, texture, mix, checker, normalLocal, namespace, positionLocal, color, oscSine, attribute } from 'three/tsl';

import { KTX2Loader } from 'three/addons/loaders/KTX2Loader.js';

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused import KTX2Loader.
Comment thread examples/webgpu_sandbox_test.html Fixed
import { normalView } from './Normal.js';
import { tangentView } from './Tangent.js';
import { mat3 } from '../tsl/TSLBase.js';
import { Fn, mat3 } from '../tsl/TSLBase.js';

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused import Fn.
Comment thread src/nodes/core/VarNode.js
const name = builder.getNodeProperty( this, this.name );

const isWebGPUBackend = renderer.backend.isWebGPUBackend === true;

Check failure

Code scanning / CodeQL

Assignment to constant Error

Assignment to variable name, which is
declared
constant.
@sunag

sunag commented Jun 13, 2025

Copy link
Copy Markdown
Collaborator Author

I need to simplify this approach, I'm making little progress even after working all these days, at least the decisions I'll have to make are clearer now. I'm going to redo this implementation and revert the namespace implementation to something that can relate the material input and sub-build layers.

@sunag sunag closed this Jun 13, 2025
@sunag sunag removed this from the r178 milestone Jun 13, 2025
@mrdoob

mrdoob commented Jun 13, 2025

Copy link
Copy Markdown
Owner

Sound good!

@Mugen87 Mugen87 added this to the r178 milestone Aug 6, 2025
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