super-three 0.169.1 → 0.170.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/three.cjs +24628 -24228
- package/build/three.core.js +37002 -0
- package/build/three.core.min.js +6 -0
- package/build/three.module.js +10519 -47108
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +533 -0
- package/build/three.tsl.min.js +6 -0
- package/build/three.webgpu.js +17071 -53583
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +17134 -53623
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +3 -3
- package/examples/jsm/animation/MMDAnimationHelper.js +2 -0
- package/examples/jsm/animation/MMDPhysics.js +2 -0
- package/examples/jsm/capabilities/WebGPU.js +1 -10
- package/examples/jsm/controls/ArcballControls.js +25 -21
- package/examples/jsm/controls/OrbitControls.js +41 -9
- package/examples/jsm/controls/PointerLockControls.js +2 -5
- package/examples/jsm/controls/TransformControls.js +22 -6
- package/examples/jsm/csm/CSM.js +2 -2
- package/examples/jsm/csm/CSMFrustum.js +7 -4
- package/examples/jsm/csm/CSMHelper.js +2 -0
- package/examples/jsm/csm/CSMShadowNode.js +437 -0
- package/examples/jsm/curves/NURBSCurve.js +34 -3
- package/examples/jsm/exporters/GLTFExporter.js +138 -71
- package/examples/jsm/exporters/KTX2Exporter.js +35 -12
- package/examples/jsm/exporters/MMDExporter.js +6 -0
- package/examples/jsm/exporters/USDZExporter.js +21 -3
- package/examples/jsm/geometries/DecalGeometry.js +70 -21
- package/examples/jsm/geometries/InstancedPointsGeometry.js +2 -0
- package/examples/jsm/helpers/TextureHelperGPU.js +175 -0
- package/examples/jsm/interactive/HTMLMesh.js +1 -0
- package/examples/jsm/lighting/TiledLighting.js +18 -0
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +1 -1
- package/examples/jsm/lines/LineGeometry.js +25 -0
- package/examples/jsm/lines/LineMaterial.js +0 -1
- package/examples/jsm/lines/LineSegmentsGeometry.js +2 -0
- package/examples/jsm/lines/webgpu/Line2.js +2 -1
- package/examples/jsm/lines/webgpu/LineSegments2.js +2 -16
- package/examples/jsm/lines/webgpu/Wireframe.js +57 -0
- package/examples/jsm/loaders/3DMLoader.js +1 -0
- package/examples/jsm/loaders/3MFLoader.js +91 -0
- package/examples/jsm/loaders/FBXLoader.js +12 -2
- package/examples/jsm/loaders/GLTFLoader.js +2 -0
- package/examples/jsm/loaders/KTX2Loader.js +143 -49
- package/examples/jsm/loaders/LDrawLoader.js +22 -136
- package/examples/jsm/loaders/LottieLoader.js +1 -0
- package/examples/jsm/loaders/MMDLoader.js +3 -0
- package/examples/jsm/loaders/MaterialXLoader.js +2 -2
- package/examples/jsm/materials/LDrawConditionalLineMaterial.js +143 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +114 -0
- package/examples/jsm/math/ColorSpaces.js +76 -0
- package/examples/jsm/misc/ProgressiveLightMap.js +52 -40
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +293 -0
- package/examples/jsm/misc/VolumeSlice.js +1 -0
- package/examples/jsm/objects/InstancedPoints.js +2 -4
- package/examples/jsm/objects/LensflareMesh.js +4 -2
- package/examples/jsm/objects/SkyMesh.js +5 -3
- package/examples/jsm/objects/Water2Mesh.js +7 -3
- package/examples/jsm/objects/WaterMesh.js +12 -10
- package/examples/jsm/postprocessing/AfterimagePass.js +14 -3
- package/examples/jsm/postprocessing/SSRPass.js +6 -0
- package/examples/jsm/renderers/CSS2DRenderer.js +6 -3
- package/examples/jsm/renderers/CSS3DRenderer.js +7 -4
- package/examples/jsm/shaders/FXAAShader.js +225 -224
- package/examples/jsm/transpiler/AST.js +2 -2
- package/examples/jsm/transpiler/GLSLDecoder.js +57 -25
- package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
- package/examples/jsm/transpiler/TSLEncoder.js +11 -6
- package/{src/nodes → examples/jsm/tsl}/display/AfterImageNode.js +18 -21
- package/{src/nodes → examples/jsm/tsl}/display/AnaglyphPassNode.js +2 -6
- package/{src/nodes → examples/jsm/tsl}/display/AnamorphicNode.js +12 -18
- package/{src/nodes → examples/jsm/tsl}/display/BleachBypass.js +1 -3
- package/{src/nodes → examples/jsm/tsl}/display/BloomNode.js +12 -41
- package/{src/nodes → examples/jsm/tsl}/display/DenoiseNode.js +60 -47
- package/{src/nodes → examples/jsm/tsl}/display/DepthOfFieldNode.js +4 -9
- package/{src/nodes → examples/jsm/tsl}/display/DotScreenNode.js +2 -9
- package/examples/jsm/tsl/display/FXAANode.js +316 -0
- package/{src/nodes → examples/jsm/tsl}/display/FilmNode.js +4 -7
- package/{src/nodes → examples/jsm/tsl}/display/GTAONode.js +73 -78
- package/{src/nodes → examples/jsm/tsl}/display/GaussianBlurNode.js +78 -42
- package/examples/jsm/tsl/display/LensflareNode.js +161 -0
- package/{src/nodes → examples/jsm/tsl}/display/Lut3DNode.js +3 -5
- package/{src/nodes → examples/jsm/tsl}/display/MotionBlur.js +2 -3
- package/examples/jsm/tsl/display/OutlineNode.js +434 -0
- package/{src/nodes → examples/jsm/tsl}/display/ParallaxBarrierPassNode.js +2 -5
- package/{src/nodes → examples/jsm/tsl}/display/PixelationPassNode.js +5 -17
- package/{src/nodes → examples/jsm/tsl}/display/RGBShiftNode.js +2 -6
- package/examples/jsm/tsl/display/SMAANode.js +620 -0
- package/{src/nodes → examples/jsm/tsl}/display/SSAAPassNode.js +10 -25
- package/examples/jsm/tsl/display/SSRNode.js +366 -0
- package/{src/nodes → examples/jsm/tsl}/display/Sepia.js +1 -2
- package/{src/nodes → examples/jsm/tsl}/display/SobelOperatorNode.js +4 -12
- package/{src/nodes → examples/jsm/tsl}/display/StereoCompositePassNode.js +9 -11
- package/{src/nodes → examples/jsm/tsl}/display/StereoPassNode.js +10 -11
- package/examples/jsm/tsl/display/TRAAPassNode.js +355 -0
- package/{src/nodes → examples/jsm/tsl}/display/TransitionNode.js +3 -7
- package/examples/jsm/tsl/display/hashBlur.js +24 -0
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +389 -0
- package/examples/jsm/utils/SceneOptimizer.js +410 -0
- package/examples/jsm/utils/UVsDebug.js +1 -1
- package/examples/jsm/utils/{TextureUtilsGPU.js → WebGPUTextureUtils.js} +2 -1
- package/examples/jsm/webxr/OculusHandPointerModel.js +21 -21
- package/examples/jsm/webxr/Text2D.js +6 -6
- package/package.json +4 -4
- package/src/Three.Core.js +178 -0
- package/src/Three.TSL.js +526 -0
- package/src/Three.WebGPU.Nodes.js +9 -186
- package/src/Three.WebGPU.js +8 -186
- package/src/Three.js +1 -177
- package/src/animation/AnimationClip.js +2 -2
- package/src/animation/AnimationObjectGroup.js +2 -2
- package/src/audio/Audio.js +38 -0
- package/src/cameras/PerspectiveCamera.js +6 -6
- package/src/cameras/StereoCamera.js +2 -2
- package/src/constants.js +1 -6
- package/src/core/BufferGeometry.js +48 -8
- package/src/core/InterleavedBuffer.js +4 -4
- package/src/core/Object3D.js +2 -2
- package/src/extras/core/Curve.js +3 -3
- package/src/extras/core/Shape.js +2 -2
- package/src/geometries/CylinderGeometry.js +2 -2
- package/src/geometries/EdgesGeometry.js +2 -2
- package/src/geometries/LatheGeometry.js +2 -2
- package/src/lights/SpotLightShadow.js +2 -2
- package/src/materials/LineDashedMaterial.js +0 -1
- package/src/materials/Material.js +2 -2
- package/src/materials/MeshPhongMaterial.js +1 -1
- package/src/materials/MeshPhysicalMaterial.js +2 -2
- package/src/materials/MeshStandardMaterial.js +2 -2
- package/src/materials/nodes/Line2NodeMaterial.js +32 -13
- package/src/materials/nodes/LineDashedNodeMaterial.js +4 -2
- package/src/materials/nodes/NodeMaterial.js +93 -23
- package/src/materials/nodes/SpriteNodeMaterial.js +11 -2
- package/src/materials/nodes/manager/NodeMaterialObserver.js +119 -7
- package/src/math/ColorManagement.js +143 -102
- package/src/math/Line3.js +2 -2
- package/src/math/Quaternion.js +2 -2
- package/src/math/Spherical.js +3 -3
- package/src/math/Vector2.js +7 -7
- package/src/math/Vector3.js +9 -9
- package/src/math/Vector4.js +22 -9
- package/src/nodes/Nodes.js +2 -21
- package/src/nodes/TSL.js +9 -25
- package/src/nodes/accessors/Arrays.js +27 -0
- package/src/nodes/accessors/BuiltinNode.js +26 -0
- package/src/nodes/accessors/Camera.js +0 -1
- package/src/nodes/accessors/ClippingNode.js +76 -42
- package/src/nodes/accessors/InstanceNode.js +17 -20
- package/src/nodes/accessors/InstancedMeshNode.js +26 -0
- package/src/nodes/accessors/Lights.js +32 -0
- package/src/nodes/accessors/SceneNode.js +35 -1
- package/src/nodes/accessors/StorageBufferNode.js +61 -19
- package/src/nodes/accessors/StorageTextureNode.js +10 -4
- package/src/nodes/accessors/TextureNode.js +1 -1
- package/src/nodes/accessors/VelocityNode.js +13 -3
- package/src/nodes/code/FunctionCallNode.js +16 -5
- package/src/nodes/code/ScriptableNode.js +4 -4
- package/src/nodes/core/Node.js +1 -0
- package/src/nodes/core/NodeBuilder.js +31 -14
- package/src/nodes/core/NodeUtils.js +28 -0
- package/src/nodes/core/VarNode.js +15 -3
- package/src/nodes/core/constants.js +6 -0
- package/src/nodes/display/BlendModes.js +99 -0
- package/src/nodes/display/ColorAdjustment.js +53 -4
- package/src/nodes/display/ColorSpaceFunctions.js +5 -5
- package/src/nodes/display/ColorSpaceNode.js +27 -39
- package/src/nodes/display/PassNode.js +6 -4
- package/src/nodes/display/ToneMappingNode.js +1 -1
- package/src/nodes/display/ToonOutlinePassNode.js +3 -3
- package/src/nodes/display/ViewportDepthNode.js +48 -1
- package/src/nodes/functions/PhysicalLightingModel.js +21 -15
- package/src/nodes/functions/material/getAlphaHashThreshold.js +70 -0
- package/src/nodes/functions/material/getGeometryRoughness.js +8 -2
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +22 -0
- package/src/nodes/gpgpu/ComputeNode.js +9 -1
- package/src/nodes/lighting/AnalyticLightNode.js +23 -419
- package/src/nodes/lighting/LightsNode.js +24 -12
- package/src/nodes/lighting/PointLightNode.js +41 -22
- package/src/nodes/lighting/PointShadowNode.js +254 -0
- package/src/nodes/lighting/RectAreaLightNode.js +3 -0
- package/src/nodes/lighting/ShadowNode.js +593 -0
- package/src/nodes/lighting/SpotLightNode.js +14 -2
- package/src/nodes/utils/LoopNode.js +2 -2
- package/src/nodes/utils/Oscillators.js +6 -0
- package/src/nodes/utils/PostProcessingUtils.js +89 -0
- package/src/nodes/utils/RTTNode.js +9 -1
- package/src/nodes/utils/ReflectorNode.js +101 -15
- package/src/nodes/utils/StorageArrayElementNode.js +2 -2
- package/src/nodes/utils/Timer.js +29 -0
- package/src/objects/BatchedMesh.js +472 -296
- package/src/objects/ClippingGroup.js +19 -0
- package/src/objects/Skeleton.js +2 -2
- package/src/renderers/WebGLRenderer.js +183 -109
- package/src/renderers/common/Animation.js +23 -11
- package/src/renderers/common/Attributes.js +4 -0
- package/src/renderers/common/Backend.js +2 -0
- package/src/renderers/common/Background.js +15 -5
- package/src/renderers/common/Bindings.js +23 -6
- package/src/renderers/common/ClippingContext.js +77 -85
- package/src/renderers/common/Constants.js +2 -1
- package/src/renderers/common/Geometries.js +20 -0
- package/src/renderers/common/IndirectStorageBufferAttribute.js +15 -0
- package/src/renderers/common/Lighting.js +45 -0
- package/src/renderers/common/PostProcessingUtils.js +86 -0
- package/src/renderers/common/RenderList.js +48 -17
- package/src/renderers/common/RenderLists.js +4 -2
- package/src/renderers/common/RenderObject.js +45 -28
- package/src/renderers/common/RenderObjects.js +12 -6
- package/src/renderers/common/Renderer.js +222 -77
- package/src/renderers/common/Textures.js +41 -17
- package/src/renderers/common/UniformsGroup.js +16 -4
- package/src/renderers/common/extras/PMREMGenerator.js +89 -13
- package/src/renderers/common/nodes/NodeLibrary.js +2 -15
- package/src/renderers/common/nodes/NodeStorageBuffer.js +2 -3
- package/src/renderers/common/nodes/NodeUniform.js +42 -0
- package/src/renderers/common/nodes/Nodes.js +2 -2
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +4 -24
- package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +2 -2
- package/src/renderers/webgl/WebGLBackground.js +20 -1
- package/src/renderers/webgl/WebGLBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLCapabilities.js +0 -7
- package/src/renderers/webgl/WebGLGeometries.js +0 -28
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLProgram.js +24 -28
- package/src/renderers/webgl/WebGLPrograms.js +5 -2
- package/src/renderers/webgl/WebGLState.js +37 -1
- package/src/renderers/webgl/WebGLTextures.js +29 -12
- package/src/renderers/webgl-fallback/WebGLBackend.js +111 -37
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +2 -7
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +43 -12
- package/src/renderers/webgl-fallback/utils/WebGLState.js +26 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +37 -9
- package/src/renderers/webgpu/WebGPUBackend.js +152 -56
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +1 -1
- package/src/renderers/webgpu/WebGPURenderer.js +1 -1
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +0 -8
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +13 -34
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +192 -92
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +12 -4
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +15 -2
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +72 -7
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +29 -9
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +29 -7
- package/src/renderers/webgpu/utils/WebGPUUtils.js +0 -1
- package/src/renderers/webxr/WebXRManager.js +4 -4
- package/src/textures/Source.js +2 -2
- package/src/textures/Texture.js +2 -2
- package/examples/jsm/cameras/CinematicCamera.js +0 -208
- package/src/nodes/display/BlendMode.js +0 -54
- package/src/nodes/display/FXAANode.js +0 -332
- package/src/nodes/utils/OscNode.js +0 -85
- package/src/nodes/utils/TimerNode.js +0 -97
- /package/examples/jsm/utils/{TextureUtils.js → WebGLTextureUtils.js} +0 -0
|
@@ -23,6 +23,8 @@ class VelocityNode extends TempNode {
|
|
|
23
23
|
|
|
24
24
|
super( 'vec2' );
|
|
25
25
|
|
|
26
|
+
this.projectionMatrix = null;
|
|
27
|
+
|
|
26
28
|
this.updateType = NodeUpdateType.OBJECT;
|
|
27
29
|
this.updateAfterType = NodeUpdateType.OBJECT;
|
|
28
30
|
|
|
@@ -32,6 +34,12 @@ class VelocityNode extends TempNode {
|
|
|
32
34
|
|
|
33
35
|
}
|
|
34
36
|
|
|
37
|
+
setProjectionMatrix( projectionMatrix ) {
|
|
38
|
+
|
|
39
|
+
this.projectionMatrix = projectionMatrix;
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
35
43
|
update( { frameId, camera, object } ) {
|
|
36
44
|
|
|
37
45
|
const previousModelMatrix = getPreviousMatrix( object );
|
|
@@ -54,7 +62,7 @@ class VelocityNode extends TempNode {
|
|
|
54
62
|
cameraData.currentProjectionMatrix = new Matrix4();
|
|
55
63
|
cameraData.currentCameraViewMatrix = new Matrix4();
|
|
56
64
|
|
|
57
|
-
cameraData.previousProjectionMatrix.copy( camera.projectionMatrix );
|
|
65
|
+
cameraData.previousProjectionMatrix.copy( this.projectionMatrix || camera.projectionMatrix );
|
|
58
66
|
cameraData.previousCameraViewMatrix.copy( camera.matrixWorldInverse );
|
|
59
67
|
|
|
60
68
|
} else {
|
|
@@ -64,7 +72,7 @@ class VelocityNode extends TempNode {
|
|
|
64
72
|
|
|
65
73
|
}
|
|
66
74
|
|
|
67
|
-
cameraData.currentProjectionMatrix.copy( camera.projectionMatrix );
|
|
75
|
+
cameraData.currentProjectionMatrix.copy( this.projectionMatrix || camera.projectionMatrix );
|
|
68
76
|
cameraData.currentCameraViewMatrix.copy( camera.matrixWorldInverse );
|
|
69
77
|
|
|
70
78
|
this.previousProjectionMatrix.value.copy( cameraData.previousProjectionMatrix );
|
|
@@ -82,9 +90,11 @@ class VelocityNode extends TempNode {
|
|
|
82
90
|
|
|
83
91
|
setup( /*builder*/ ) {
|
|
84
92
|
|
|
93
|
+
const projectionMatrix = ( this.projectionMatrix === null ) ? cameraProjectionMatrix : uniform( this.projectionMatrix );
|
|
94
|
+
|
|
85
95
|
const previousModelViewMatrix = this.previousCameraViewMatrix.mul( this.previousModelWorldMatrix );
|
|
86
96
|
|
|
87
|
-
const clipPositionCurrent =
|
|
97
|
+
const clipPositionCurrent = projectionMatrix.mul( modelViewMatrix ).mul( positionLocal );
|
|
88
98
|
const clipPositionPrevious = this.previousProjectionMatrix.mul( previousModelViewMatrix ).mul( positionPrevious );
|
|
89
99
|
|
|
90
100
|
const ndcPositionCurrent = clipPositionCurrent.xy.div( clipPositionCurrent.w );
|
|
@@ -47,14 +47,25 @@ class FunctionCallNode extends TempNode {
|
|
|
47
47
|
const inputs = functionNode.getInputs( builder );
|
|
48
48
|
const parameters = this.parameters;
|
|
49
49
|
|
|
50
|
+
const generateInput = ( node, inputNode ) => {
|
|
51
|
+
|
|
52
|
+
const type = inputNode.type;
|
|
53
|
+
const pointer = type === 'pointer';
|
|
54
|
+
|
|
55
|
+
let output;
|
|
56
|
+
|
|
57
|
+
if ( pointer ) output = '&' + node.build( builder );
|
|
58
|
+
else output = node.build( builder, type );
|
|
59
|
+
|
|
60
|
+
return output;
|
|
61
|
+
|
|
62
|
+
};
|
|
63
|
+
|
|
50
64
|
if ( Array.isArray( parameters ) ) {
|
|
51
65
|
|
|
52
66
|
for ( let i = 0; i < parameters.length; i ++ ) {
|
|
53
67
|
|
|
54
|
-
|
|
55
|
-
const node = parameters[ i ];
|
|
56
|
-
|
|
57
|
-
params.push( node.build( builder, inputNode.type ) );
|
|
68
|
+
params.push( generateInput( parameters[ i ], inputs[ i ] ) );
|
|
58
69
|
|
|
59
70
|
}
|
|
60
71
|
|
|
@@ -66,7 +77,7 @@ class FunctionCallNode extends TempNode {
|
|
|
66
77
|
|
|
67
78
|
if ( node !== undefined ) {
|
|
68
79
|
|
|
69
|
-
params.push(
|
|
80
|
+
params.push( generateInput( node, inputNode ) );
|
|
70
81
|
|
|
71
82
|
} else {
|
|
72
83
|
|
|
@@ -58,7 +58,7 @@ class Parameters {
|
|
|
58
58
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
export const
|
|
61
|
+
export const ScriptableNodeResources = new Resources();
|
|
62
62
|
|
|
63
63
|
class ScriptableNode extends Node {
|
|
64
64
|
|
|
@@ -299,11 +299,11 @@ class ScriptableNode extends Node {
|
|
|
299
299
|
|
|
300
300
|
const parameters = new Parameters( this );
|
|
301
301
|
|
|
302
|
-
const THREE =
|
|
303
|
-
const TSL =
|
|
302
|
+
const THREE = ScriptableNodeResources.get( 'THREE' );
|
|
303
|
+
const TSL = ScriptableNodeResources.get( 'TSL' );
|
|
304
304
|
|
|
305
305
|
const method = this.getMethod( this.codeNode );
|
|
306
|
-
const params = [ parameters, this._local,
|
|
306
|
+
const params = [ parameters, this._local, ScriptableNodeResources, refresh, setOutput, THREE, TSL ];
|
|
307
307
|
|
|
308
308
|
this._object = method( ...params );
|
|
309
309
|
|
package/src/nodes/core/Node.js
CHANGED
|
@@ -7,6 +7,7 @@ import NodeCache from './NodeCache.js';
|
|
|
7
7
|
import ParameterNode from './ParameterNode.js';
|
|
8
8
|
import FunctionNode from '../code/FunctionNode.js';
|
|
9
9
|
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
|
10
|
+
import { getTypeFromLength } from './NodeUtils.js';
|
|
10
11
|
import { NodeUpdateType, defaultBuildStages, shaderStages } from './constants.js';
|
|
11
12
|
|
|
12
13
|
import {
|
|
@@ -35,14 +36,6 @@ import { IntType, UnsignedIntType, LinearFilter, LinearMipmapNearestFilter, Near
|
|
|
35
36
|
|
|
36
37
|
const rendererCache = new WeakMap();
|
|
37
38
|
|
|
38
|
-
const typeFromLength = new Map( [
|
|
39
|
-
[ 2, 'vec2' ],
|
|
40
|
-
[ 3, 'vec3' ],
|
|
41
|
-
[ 4, 'vec4' ],
|
|
42
|
-
[ 9, 'mat3' ],
|
|
43
|
-
[ 16, 'mat4' ]
|
|
44
|
-
] );
|
|
45
|
-
|
|
46
39
|
const typeFromArray = new Map( [
|
|
47
40
|
[ Int8Array, 'int' ],
|
|
48
41
|
[ Int16Array, 'int' ],
|
|
@@ -55,9 +48,17 @@ const typeFromArray = new Map( [
|
|
|
55
48
|
|
|
56
49
|
const toFloat = ( value ) => {
|
|
57
50
|
|
|
58
|
-
|
|
51
|
+
if ( /e/g.test( value ) ) {
|
|
52
|
+
|
|
53
|
+
return String( value ).replace( /\+/g, '' );
|
|
59
54
|
|
|
60
|
-
|
|
55
|
+
} else {
|
|
56
|
+
|
|
57
|
+
value = Number( value );
|
|
58
|
+
|
|
59
|
+
return value + ( value % 1 ? '' : '.0' );
|
|
60
|
+
|
|
61
|
+
}
|
|
61
62
|
|
|
62
63
|
};
|
|
63
64
|
|
|
@@ -74,6 +75,7 @@ class NodeBuilder {
|
|
|
74
75
|
this.camera = null;
|
|
75
76
|
|
|
76
77
|
this.nodes = [];
|
|
78
|
+
this.sequentialNodes = [];
|
|
77
79
|
this.updateNodes = [];
|
|
78
80
|
this.updateBeforeNodes = [];
|
|
79
81
|
this.updateAfterNodes = [];
|
|
@@ -312,13 +314,21 @@ class NodeBuilder {
|
|
|
312
314
|
|
|
313
315
|
}
|
|
314
316
|
|
|
317
|
+
addSequentialNode( node ) {
|
|
318
|
+
|
|
319
|
+
if ( this.sequentialNodes.includes( node ) === false ) {
|
|
320
|
+
|
|
321
|
+
this.sequentialNodes.push( node );
|
|
322
|
+
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
}
|
|
326
|
+
|
|
315
327
|
buildUpdateNodes() {
|
|
316
328
|
|
|
317
329
|
for ( const node of this.nodes ) {
|
|
318
330
|
|
|
319
331
|
const updateType = node.getUpdateType();
|
|
320
|
-
const updateBeforeType = node.getUpdateBeforeType();
|
|
321
|
-
const updateAfterType = node.getUpdateAfterType();
|
|
322
332
|
|
|
323
333
|
if ( updateType !== NodeUpdateType.NONE ) {
|
|
324
334
|
|
|
@@ -326,6 +336,13 @@ class NodeBuilder {
|
|
|
326
336
|
|
|
327
337
|
}
|
|
328
338
|
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
for ( const node of this.sequentialNodes ) {
|
|
342
|
+
|
|
343
|
+
const updateBeforeType = node.getUpdateBeforeType();
|
|
344
|
+
const updateAfterType = node.getUpdateAfterType();
|
|
345
|
+
|
|
329
346
|
if ( updateBeforeType !== NodeUpdateType.NONE ) {
|
|
330
347
|
|
|
331
348
|
this.updateBeforeNodes.push( node.getSelf() );
|
|
@@ -684,7 +701,7 @@ class NodeBuilder {
|
|
|
684
701
|
|
|
685
702
|
if ( length === 1 ) return componentType;
|
|
686
703
|
|
|
687
|
-
const baseType =
|
|
704
|
+
const baseType = getTypeFromLength( length );
|
|
688
705
|
const prefix = componentType === 'float' ? '' : componentType[ 0 ];
|
|
689
706
|
|
|
690
707
|
return prefix + baseType;
|
|
@@ -1300,7 +1317,7 @@ class NodeBuilder {
|
|
|
1300
1317
|
|
|
1301
1318
|
if ( material !== null ) {
|
|
1302
1319
|
|
|
1303
|
-
let nodeMaterial = renderer.
|
|
1320
|
+
let nodeMaterial = renderer.library.fromMaterial( material );
|
|
1304
1321
|
|
|
1305
1322
|
if ( nodeMaterial === null ) {
|
|
1306
1323
|
|
|
@@ -117,6 +117,34 @@ export function* getNodeChildren( node, toJSON = false ) {
|
|
|
117
117
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
const typeFromLength = /*@__PURE__*/ new Map( [
|
|
121
|
+
[ 1, 'float' ],
|
|
122
|
+
[ 2, 'vec2' ],
|
|
123
|
+
[ 3, 'vec3' ],
|
|
124
|
+
[ 4, 'vec4' ],
|
|
125
|
+
[ 9, 'mat3' ],
|
|
126
|
+
[ 16, 'mat4' ]
|
|
127
|
+
] );
|
|
128
|
+
|
|
129
|
+
export function getTypeFromLength( length ) {
|
|
130
|
+
|
|
131
|
+
return typeFromLength.get( length );
|
|
132
|
+
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export function getLengthFromType( type ) {
|
|
136
|
+
|
|
137
|
+
if ( /float|int|uint/.test( type ) ) return 1;
|
|
138
|
+
if ( /vec2/.test( type ) ) return 2;
|
|
139
|
+
if ( /vec3/.test( type ) ) return 3;
|
|
140
|
+
if ( /vec4/.test( type ) ) return 4;
|
|
141
|
+
if ( /mat3/.test( type ) ) return 9;
|
|
142
|
+
if ( /mat4/.test( type ) ) return 16;
|
|
143
|
+
|
|
144
|
+
console.error( 'THREE.TSL: Unsupported type:', type );
|
|
145
|
+
|
|
146
|
+
}
|
|
147
|
+
|
|
120
148
|
export function getValueType( value ) {
|
|
121
149
|
|
|
122
150
|
if ( value === undefined || value === null ) return null;
|
|
@@ -54,7 +54,19 @@ class VarNode extends Node {
|
|
|
54
54
|
|
|
55
55
|
export default VarNode;
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
const createVar = /*@__PURE__*/ nodeProxy( VarNode );
|
|
58
|
+
|
|
59
|
+
addMethodChaining( 'toVar', ( ...params ) => createVar( ...params ).append() );
|
|
60
|
+
|
|
61
|
+
// Deprecated
|
|
62
|
+
|
|
63
|
+
export const temp = ( node ) => { // @deprecated, r170
|
|
64
|
+
|
|
65
|
+
console.warn( 'TSL: "temp" is deprecated. Use ".toVar()" instead.' );
|
|
66
|
+
|
|
67
|
+
return createVar( node );
|
|
68
|
+
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
addMethodChaining( 'temp', temp );
|
|
58
72
|
|
|
59
|
-
addMethodChaining( 'temp', temp ); // @TODO: Will be removed in the future
|
|
60
|
-
addMethodChaining( 'toVar', ( ...params ) => temp( ...params ).append() );
|
|
@@ -22,6 +22,12 @@ export const NodeType = {
|
|
|
22
22
|
MATRIX4: 'mat4'
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
+
export const NodeAccess = {
|
|
26
|
+
READ_ONLY: 'readOnly',
|
|
27
|
+
WRITE_ONLY: 'writeOnly',
|
|
28
|
+
READ_WRITE: 'readWrite',
|
|
29
|
+
};
|
|
30
|
+
|
|
25
31
|
export const defaultShaderStages = [ 'fragment', 'vertex' ];
|
|
26
32
|
export const defaultBuildStages = [ 'setup', 'analyze', 'generate' ];
|
|
27
33
|
export const shaderStages = [ ...defaultShaderStages, 'compute' ];
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Fn, vec4 } from '../tsl/TSLBase.js';
|
|
2
|
+
import { mix, min, step } from '../math/MathNode.js';
|
|
3
|
+
|
|
4
|
+
export const blendBurn = /*@__PURE__*/ Fn( ( [ base, blend ] ) => {
|
|
5
|
+
|
|
6
|
+
return min( 1.0, base.oneMinus().div( blend ) ).oneMinus();
|
|
7
|
+
|
|
8
|
+
} ).setLayout( {
|
|
9
|
+
name: 'blendBurn',
|
|
10
|
+
type: 'vec3',
|
|
11
|
+
inputs: [
|
|
12
|
+
{ name: 'base', type: 'vec3' },
|
|
13
|
+
{ name: 'blend', type: 'vec3' }
|
|
14
|
+
]
|
|
15
|
+
} );
|
|
16
|
+
|
|
17
|
+
export const blendDodge = /*@__PURE__*/ Fn( ( [ base, blend ] ) => {
|
|
18
|
+
|
|
19
|
+
return min( base.div( blend.oneMinus() ), 1.0 );
|
|
20
|
+
|
|
21
|
+
} ).setLayout( {
|
|
22
|
+
name: 'blendDodge',
|
|
23
|
+
type: 'vec3',
|
|
24
|
+
inputs: [
|
|
25
|
+
{ name: 'base', type: 'vec3' },
|
|
26
|
+
{ name: 'blend', type: 'vec3' }
|
|
27
|
+
]
|
|
28
|
+
} );
|
|
29
|
+
|
|
30
|
+
export const blendScreen = /*@__PURE__*/ Fn( ( [ base, blend ] ) => {
|
|
31
|
+
|
|
32
|
+
return base.oneMinus().mul( blend.oneMinus() ).oneMinus();
|
|
33
|
+
|
|
34
|
+
} ).setLayout( {
|
|
35
|
+
name: 'blendScreen',
|
|
36
|
+
type: 'vec3',
|
|
37
|
+
inputs: [
|
|
38
|
+
{ name: 'base', type: 'vec3' },
|
|
39
|
+
{ name: 'blend', type: 'vec3' }
|
|
40
|
+
]
|
|
41
|
+
} );
|
|
42
|
+
|
|
43
|
+
export const blendOverlay = /*@__PURE__*/ Fn( ( [ base, blend ] ) => {
|
|
44
|
+
|
|
45
|
+
return mix( base.mul( 2.0 ).mul( blend ), base.oneMinus().mul( 2.0 ).mul( blend.oneMinus() ).oneMinus(), step( 0.5, base ) );
|
|
46
|
+
|
|
47
|
+
} ).setLayout( {
|
|
48
|
+
name: 'blendOverlay',
|
|
49
|
+
type: 'vec3',
|
|
50
|
+
inputs: [
|
|
51
|
+
{ name: 'base', type: 'vec3' },
|
|
52
|
+
{ name: 'blend', type: 'vec3' }
|
|
53
|
+
]
|
|
54
|
+
} );
|
|
55
|
+
|
|
56
|
+
export const blendColor = /*@__PURE__*/ Fn( ( [ base, blend ] ) => {
|
|
57
|
+
|
|
58
|
+
const outAlpha = blend.a.add( base.a.mul( blend.a.oneMinus() ) );
|
|
59
|
+
|
|
60
|
+
return vec4( blend.rgb.mul( blend.a ).add( base.rgb.mul( base.a ).mul( blend.a.oneMinus() ) ).div( outAlpha ), outAlpha );
|
|
61
|
+
|
|
62
|
+
} ).setLayout( {
|
|
63
|
+
name: 'blendColor',
|
|
64
|
+
type: 'vec4',
|
|
65
|
+
inputs: [
|
|
66
|
+
{ name: 'base', type: 'vec4' },
|
|
67
|
+
{ name: 'blend', type: 'vec4' }
|
|
68
|
+
]
|
|
69
|
+
} );
|
|
70
|
+
|
|
71
|
+
// deprecated
|
|
72
|
+
|
|
73
|
+
export const burn = ( ...params ) => { // @deprecated, r171
|
|
74
|
+
|
|
75
|
+
console.warn( 'THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.' );
|
|
76
|
+
return blendBurn( params );
|
|
77
|
+
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export const dodge = ( ...params ) => { // @deprecated, r171
|
|
81
|
+
|
|
82
|
+
console.warn( 'THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.' );
|
|
83
|
+
return blendDodge( params );
|
|
84
|
+
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export const screen = ( ...params ) => { // @deprecated, r171
|
|
88
|
+
|
|
89
|
+
console.warn( 'THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.' );
|
|
90
|
+
return blendScreen( params );
|
|
91
|
+
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export const overlay = ( ...params ) => { // @deprecated, r171
|
|
95
|
+
|
|
96
|
+
console.warn( 'THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.' );
|
|
97
|
+
return blendOverlay( params );
|
|
98
|
+
|
|
99
|
+
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { dot, mix } from '../math/MathNode.js';
|
|
1
|
+
import { dot, max, mix } from '../math/MathNode.js';
|
|
2
2
|
import { add } from '../math/OperatorNode.js';
|
|
3
|
-
import { Fn, float, vec3 } from '../tsl/TSLBase.js';
|
|
3
|
+
import { Fn, If, float, vec3, vec4 } from '../tsl/TSLBase.js';
|
|
4
4
|
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
5
5
|
import { Vector3 } from '../../math/Vector3.js';
|
|
6
|
+
import { LinearSRGBColorSpace } from '../../constants.js';
|
|
6
7
|
|
|
7
8
|
export const grayscale = /*@__PURE__*/ Fn( ( [ color ] ) => {
|
|
8
9
|
|
|
@@ -37,10 +38,58 @@ export const hue = /*@__PURE__*/ Fn( ( [ color, adjustment = float( 1 ) ] ) => {
|
|
|
37
38
|
|
|
38
39
|
} );
|
|
39
40
|
|
|
40
|
-
const _luminanceCoefficients = /*@__PURE__*/ new Vector3();
|
|
41
41
|
export const luminance = (
|
|
42
42
|
color,
|
|
43
|
-
luminanceCoefficients = vec3(
|
|
43
|
+
luminanceCoefficients = vec3( ColorManagement.getLuminanceCoefficients( new Vector3() ) )
|
|
44
44
|
) => dot( color, luminanceCoefficients );
|
|
45
45
|
|
|
46
46
|
export const threshold = ( color, threshold ) => mix( vec3( 0.0 ), color, luminance( color ).sub( threshold ).max( 0 ) );
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Color Decision List (CDL) v1.2
|
|
50
|
+
*
|
|
51
|
+
* Compact representation of color grading information, defined by slope, offset, power, and
|
|
52
|
+
* saturation. The CDL should be typically be given input in a log space (such as LogC, ACEScc,
|
|
53
|
+
* or AgX Log), and will return output in the same space. Output may require clamping >=0.
|
|
54
|
+
*
|
|
55
|
+
* @param {vec4} color Input (-Infinity < input < +Infinity)
|
|
56
|
+
* @param {number | vec3} slope Slope (0 ≤ slope < +Infinity)
|
|
57
|
+
* @param {number | vec3} offset Offset (-Infinity < offset < +Infinity; typically -1 < offset < 1)
|
|
58
|
+
* @param {number | vec3} power Power (0 < power < +Infinity)
|
|
59
|
+
* @param {number} saturation Saturation (0 ≤ saturation < +Infinity; typically 0 ≤ saturation < 4)
|
|
60
|
+
* @param {vec3} luminanceCoefficients Luminance coefficients for saturation term, typically Rec. 709
|
|
61
|
+
* @return Output, -Infinity < output < +Infinity
|
|
62
|
+
*
|
|
63
|
+
* References:
|
|
64
|
+
* - ASC CDL v1.2
|
|
65
|
+
* - https://blender.stackexchange.com/a/55239/43930
|
|
66
|
+
* - https://docs.acescentral.com/specifications/acescc/
|
|
67
|
+
*/
|
|
68
|
+
export const cdl = /*@__PURE__*/ Fn( ( [
|
|
69
|
+
color,
|
|
70
|
+
slope = vec3( 1 ),
|
|
71
|
+
offset = vec3( 0 ),
|
|
72
|
+
power = vec3( 1 ),
|
|
73
|
+
saturation = float( 1 ),
|
|
74
|
+
// ASC CDL v1.2 explicitly requires Rec. 709 luminance coefficients.
|
|
75
|
+
luminanceCoefficients = vec3( ColorManagement.getLuminanceCoefficients( new Vector3(), LinearSRGBColorSpace ) )
|
|
76
|
+
] ) => {
|
|
77
|
+
|
|
78
|
+
// NOTE: The ASC CDL v1.2 defines a [0, 1] clamp on the slope+offset term, and another on the
|
|
79
|
+
// saturation term. Per the ACEScc specification and Filament, limits may be omitted to support
|
|
80
|
+
// values outside [0, 1], requiring a workaround for negative values in the power expression.
|
|
81
|
+
|
|
82
|
+
const luma = color.rgb.dot( vec3( luminanceCoefficients ) );
|
|
83
|
+
|
|
84
|
+
const v = max( color.rgb.mul( slope ).add( offset ), 0.0 ).toVar();
|
|
85
|
+
const pv = v.pow( power ).toVar();
|
|
86
|
+
|
|
87
|
+
If( v.r.greaterThan( 0.0 ), () => { v.r.assign( pv.r ); } ); // eslint-disable-line
|
|
88
|
+
If( v.g.greaterThan( 0.0 ), () => { v.g.assign( pv.g ); } ); // eslint-disable-line
|
|
89
|
+
If( v.b.greaterThan( 0.0 ), () => { v.b.assign( pv.b ); } ); // eslint-disable-line
|
|
90
|
+
|
|
91
|
+
v.assign( luma.add( v.sub( luma ).mul( saturation ) ) );
|
|
92
|
+
|
|
93
|
+
return vec4( v.rgb, color.a );
|
|
94
|
+
|
|
95
|
+
} );
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mix } from '../math/MathNode.js';
|
|
2
|
-
import { Fn } from '../tsl/
|
|
2
|
+
import { Fn } from '../tsl/TSLCore.js';
|
|
3
3
|
|
|
4
|
-
export const
|
|
4
|
+
export const sRGBTransferEOTF = /*@__PURE__*/ Fn( ( [ color ] ) => {
|
|
5
5
|
|
|
6
6
|
const a = color.mul( 0.9478672986 ).add( 0.0521327014 ).pow( 2.4 );
|
|
7
7
|
const b = color.mul( 0.0773993808 );
|
|
@@ -12,14 +12,14 @@ export const sRGBToLinearSRGB = /*@__PURE__*/ Fn( ( [ color ] ) => {
|
|
|
12
12
|
return rgbResult;
|
|
13
13
|
|
|
14
14
|
} ).setLayout( {
|
|
15
|
-
name: '
|
|
15
|
+
name: 'sRGBTransferEOTF',
|
|
16
16
|
type: 'vec3',
|
|
17
17
|
inputs: [
|
|
18
18
|
{ name: 'color', type: 'vec3' }
|
|
19
19
|
]
|
|
20
20
|
} );
|
|
21
21
|
|
|
22
|
-
export const
|
|
22
|
+
export const sRGBTransferOETF = /*@__PURE__*/ Fn( ( [ color ] ) => {
|
|
23
23
|
|
|
24
24
|
const a = color.pow( 0.41666 ).mul( 1.055 ).sub( 0.055 );
|
|
25
25
|
const b = color.mul( 12.92 );
|
|
@@ -30,7 +30,7 @@ export const linearSRGBTosRGB = /*@__PURE__*/ Fn( ( [ color ] ) => {
|
|
|
30
30
|
return rgbResult;
|
|
31
31
|
|
|
32
32
|
} ).setLayout( {
|
|
33
|
-
name: '
|
|
33
|
+
name: 'sRGBTransferOETF',
|
|
34
34
|
type: 'vec3',
|
|
35
35
|
inputs: [
|
|
36
36
|
{ name: 'color', type: 'vec3' }
|
|
@@ -1,36 +1,14 @@
|
|
|
1
1
|
import TempNode from '../core/TempNode.js';
|
|
2
|
-
import { addMethodChaining, nodeObject, vec4 } from '../tsl/TSLCore.js';
|
|
2
|
+
import { addMethodChaining, mat3, nodeObject, vec4 } from '../tsl/TSLCore.js';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { SRGBTransfer } from '../../constants.js';
|
|
5
5
|
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
6
|
+
import { sRGBTransferEOTF, sRGBTransferOETF } from './ColorSpaceFunctions.js';
|
|
7
|
+
import { Matrix3 } from '../../math/Matrix3.js';
|
|
6
8
|
|
|
7
9
|
const WORKING_COLOR_SPACE = 'WorkingColorSpace';
|
|
8
10
|
const OUTPUT_COLOR_SPACE = 'OutputColorSpace';
|
|
9
11
|
|
|
10
|
-
function getColorSpaceName( colorSpace ) {
|
|
11
|
-
|
|
12
|
-
let method = null;
|
|
13
|
-
|
|
14
|
-
if ( colorSpace === LinearSRGBColorSpace ) {
|
|
15
|
-
|
|
16
|
-
method = 'Linear';
|
|
17
|
-
|
|
18
|
-
} else if ( colorSpace === SRGBColorSpace ) {
|
|
19
|
-
|
|
20
|
-
method = 'sRGB';
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return method;
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function getColorSpaceMethod( source, target ) {
|
|
29
|
-
|
|
30
|
-
return getColorSpaceName( source ) + 'To' + getColorSpaceName( target );
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
12
|
class ColorSpaceNode extends TempNode {
|
|
35
13
|
|
|
36
14
|
static get type() {
|
|
@@ -49,7 +27,7 @@ class ColorSpaceNode extends TempNode {
|
|
|
49
27
|
|
|
50
28
|
}
|
|
51
29
|
|
|
52
|
-
|
|
30
|
+
resolveColorSpace( builder, colorSpace ) {
|
|
53
31
|
|
|
54
32
|
if ( colorSpace === WORKING_COLOR_SPACE ) {
|
|
55
33
|
|
|
@@ -67,29 +45,37 @@ class ColorSpaceNode extends TempNode {
|
|
|
67
45
|
|
|
68
46
|
setup( builder ) {
|
|
69
47
|
|
|
70
|
-
const { renderer } = builder;
|
|
71
48
|
const { colorNode } = this;
|
|
72
49
|
|
|
73
|
-
const source = this.
|
|
74
|
-
const target = this.
|
|
50
|
+
const source = this.resolveColorSpace( builder, this.source );
|
|
51
|
+
const target = this.resolveColorSpace( builder, this.target );
|
|
75
52
|
|
|
76
|
-
|
|
53
|
+
let outputNode = colorNode;
|
|
77
54
|
|
|
78
|
-
|
|
55
|
+
if ( ColorManagement.enabled === false || source === target || ! source || ! target ) {
|
|
79
56
|
|
|
80
|
-
|
|
57
|
+
return outputNode;
|
|
81
58
|
|
|
82
|
-
|
|
59
|
+
}
|
|
83
60
|
|
|
84
|
-
if (
|
|
61
|
+
if ( ColorManagement.getTransfer( source ) === SRGBTransfer ) {
|
|
85
62
|
|
|
86
|
-
outputNode = vec4(
|
|
63
|
+
outputNode = vec4( sRGBTransferEOTF( outputNode.rgb ), outputNode.a );
|
|
87
64
|
|
|
88
|
-
}
|
|
65
|
+
}
|
|
89
66
|
|
|
90
|
-
|
|
67
|
+
if ( ColorManagement.getPrimaries( source ) !== ColorManagement.getPrimaries( target ) ) {
|
|
91
68
|
|
|
92
|
-
outputNode =
|
|
69
|
+
outputNode = vec4(
|
|
70
|
+
mat3( ColorManagement._getMatrix( new Matrix3(), source, target ) ).mul( outputNode.rgb ),
|
|
71
|
+
outputNode.a
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if ( ColorManagement.getTransfer( target ) === SRGBTransfer ) {
|
|
77
|
+
|
|
78
|
+
outputNode = vec4( sRGBTransferOETF( outputNode.rgb ), outputNode.a );
|
|
93
79
|
|
|
94
80
|
}
|
|
95
81
|
|
|
@@ -107,6 +93,8 @@ export const toWorkingColorSpace = ( node ) => nodeObject( new ColorSpaceNode( n
|
|
|
107
93
|
export const workingToColorSpace = ( node, colorSpace ) => nodeObject( new ColorSpaceNode( nodeObject( node ), WORKING_COLOR_SPACE, colorSpace ) );
|
|
108
94
|
export const colorSpaceToWorking = ( node, colorSpace ) => nodeObject( new ColorSpaceNode( nodeObject( node ), colorSpace, WORKING_COLOR_SPACE ) );
|
|
109
95
|
|
|
96
|
+
export const convertColorSpace = ( node, sourceColorSpace, targetColorSpace ) => nodeObject( new ColorSpaceNode( nodeObject( node ), sourceColorSpace, targetColorSpace ) );
|
|
97
|
+
|
|
110
98
|
addMethodChaining( 'toOutputColorSpace', toOutputColorSpace );
|
|
111
99
|
addMethodChaining( 'toWorkingColorSpace', toWorkingColorSpace );
|
|
112
100
|
|
|
@@ -226,8 +226,9 @@ class PassNode extends TempNode {
|
|
|
226
226
|
|
|
227
227
|
if ( textureNode === undefined ) {
|
|
228
228
|
|
|
229
|
-
|
|
230
|
-
|
|
229
|
+
textureNode = nodeObject( new PassMultipleTextureNode( this, name ) );
|
|
230
|
+
textureNode.updateTexture();
|
|
231
|
+
this._textureNodes[ name ] = textureNode;
|
|
231
232
|
|
|
232
233
|
}
|
|
233
234
|
|
|
@@ -243,8 +244,9 @@ class PassNode extends TempNode {
|
|
|
243
244
|
|
|
244
245
|
if ( this._textureNodes[ name ] === undefined ) this.getTextureNode( name );
|
|
245
246
|
|
|
246
|
-
|
|
247
|
-
|
|
247
|
+
textureNode = nodeObject( new PassMultipleTextureNode( this, name, true ) );
|
|
248
|
+
textureNode.updateTexture();
|
|
249
|
+
this._previousTextureNodes[ name ] = textureNode;
|
|
248
250
|
|
|
249
251
|
}
|
|
250
252
|
|
|
@@ -39,7 +39,7 @@ class ToneMappingNode extends TempNode {
|
|
|
39
39
|
|
|
40
40
|
let outputNode = null;
|
|
41
41
|
|
|
42
|
-
const toneMappingFn = builder.renderer.
|
|
42
|
+
const toneMappingFn = builder.renderer.library.getToneMappingFunction( toneMapping );
|
|
43
43
|
|
|
44
44
|
if ( toneMappingFn !== null ) {
|
|
45
45
|
|
|
@@ -34,7 +34,7 @@ class ToonOutlinePassNode extends PassNode {
|
|
|
34
34
|
|
|
35
35
|
const currentRenderObjectFunction = renderer.getRenderObjectFunction();
|
|
36
36
|
|
|
37
|
-
renderer.setRenderObjectFunction( ( object, scene, camera, geometry, material, group, lightsNode ) => {
|
|
37
|
+
renderer.setRenderObjectFunction( ( object, scene, camera, geometry, material, group, lightsNode, clippingContext ) => {
|
|
38
38
|
|
|
39
39
|
// only render outline for supported materials
|
|
40
40
|
|
|
@@ -43,7 +43,7 @@ class ToonOutlinePassNode extends PassNode {
|
|
|
43
43
|
if ( material.wireframe === false ) {
|
|
44
44
|
|
|
45
45
|
const outlineMaterial = this._getOutlineMaterial( material );
|
|
46
|
-
renderer.renderObject( object, scene, camera, geometry, outlineMaterial, group, lightsNode );
|
|
46
|
+
renderer.renderObject( object, scene, camera, geometry, outlineMaterial, group, lightsNode, clippingContext );
|
|
47
47
|
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -51,7 +51,7 @@ class ToonOutlinePassNode extends PassNode {
|
|
|
51
51
|
|
|
52
52
|
// default
|
|
53
53
|
|
|
54
|
-
renderer.renderObject( object, scene, camera, geometry, material, group, lightsNode );
|
|
54
|
+
renderer.renderObject( object, scene, camera, geometry, material, group, lightsNode, clippingContext );
|
|
55
55
|
|
|
56
56
|
} );
|
|
57
57
|
|