Skip to content

TSL: Remove transformed* prefix - WIP #31177

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

Closed
wants to merge 9 commits into from
Closed

Conversation

sunag
Copy link
Collaborator

@sunag sunag commented May 26, 2025

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
Copy link

github-actions bot commented May 26, 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 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
Copy link
Owner

mrdoob commented May 27, 2025

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

@sunag
Copy link
Collaborator Author

sunag commented May 27, 2025

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
Copy link
Owner

mrdoob commented May 28, 2025

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.
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.
const { node, name, readOnly } = this;
const { renderer } = builder;

const name = builder.getNodeProperty( this, this.name );

Check failure

Code scanning / CodeQL

Assignment to constant Error

Assignment to variable name, which is
declared
constant.
@sunag
Copy link
Collaborator Author

sunag commented Jun 13, 2025

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
Copy link
Owner

mrdoob commented Jun 13, 2025

Sound good!

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