Skip to content

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

@github-actions
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
11 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