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

TSL: Support defined color spaces in ColorSpaceNode #29694

Merged
merged 4 commits into from
Oct 20, 2024

Conversation

donmccurdy
Copy link
Collaborator

@donmccurdy donmccurdy commented Oct 19, 2024

Adds support to 'ColorSpaceNode' (and related chaining helpers) for any color space registered on THREE.ColorManagement. Adds a generic X-to-Y chaining TSL node:

import {
  DisplayP3ColorSpace,
  DisplayP3ColorSpaceImpl,
  LinearDisplayP3ColorSpace,
  LinearDisplayP3ColorSpaceImpl
} from 'three/addons/math/ColorSpaces.js';
import { convertColorSpace } from 'three/tsl';

THREE.ColorManagement.define( {
  [ DisplayP3ColorSpace ]: DisplayP3ColorSpaceImpl,
  [ LinearDisplayP3ColorSpace ]: LinearDisplayP3ColorSpaceImpl,
} );

const color1 = convertColorSpace( color2, LinearDisplayP3ColorSpace, DisplayP3ColorSpace );

Related:

/cc @WestLangley @sunag

Copy link

github-actions bot commented Oct 19, 2024

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 692.71
171.44
692.71
171.44
+0 B
+0 B
WebGPU 818.16
220.56
817.89
220.55
-273 B
-5 B
WebGPU Nodes 817.67
220.43
817.4
220.42
-273 B
-6 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 464.93
112.2
464.93
112.2
+0 B
+0 B
WebGPU 539.13
145.56
538.83
145.53
-305 B
-35 B
WebGPU Nodes 495.16
135.43
494.86
135.37
-305 B
-59 B

@donmccurdy
Copy link
Collaborator Author

donmccurdy commented Oct 19, 2024

Hm, I'm not sure what to do with this circular dependency:

  • src/nodes/tsl/TSLBase.js
    • src/nodes/display/ColorSpaceNode.js
      • src/nodes/display/ColorSpaceFunctions.js
        • src/nodes/tsl/TSLBase.js

I'm tempted to move the EOTF and OETF implementations into ColorSpaceNode.js. @sunag do you have a preference?

Resolved, thanks @sunag!

@sunag sunag added this to the r170 milestone Oct 20, 2024
@sunag sunag merged commit cb29f6f into mrdoob:dev Oct 20, 2024
12 checks passed
@donmccurdy donmccurdy deleted the feat/colorspacenode-generalization branch October 21, 2024 01:09
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.

3 participants