@plastic-software/three 0.178.0 → 0.179.0
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/README.md +1 -1
- package/build/three.cjs +856 -196
- package/build/three.core.js +647 -123
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +211 -76
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +70 -21
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +1796 -557
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +1754 -557
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +1 -2
- package/examples/jsm/capabilities/WebGPU.js +1 -1
- package/examples/jsm/csm/CSMShadowNode.js +4 -4
- package/examples/jsm/environments/RoomEnvironment.js +8 -3
- package/examples/jsm/exporters/USDZExporter.js +676 -299
- package/examples/jsm/geometries/RoundedBoxGeometry.js +47 -8
- package/examples/jsm/interactive/HTMLMesh.js +5 -3
- package/examples/jsm/libs/meshopt_decoder.module.js +75 -58
- package/examples/jsm/lights/LightProbeGenerator.js +14 -3
- package/examples/jsm/loaders/EXRLoader.js +210 -22
- package/examples/jsm/loaders/FBXLoader.js +1 -1
- package/examples/jsm/loaders/MaterialXLoader.js +212 -30
- package/examples/jsm/loaders/TTFLoader.js +13 -1
- package/examples/jsm/loaders/USDLoader.js +219 -0
- package/examples/jsm/loaders/USDZLoader.js +4 -892
- package/examples/jsm/loaders/usd/USDAParser.js +741 -0
- package/examples/jsm/loaders/usd/USDCParser.js +17 -0
- package/examples/jsm/objects/LensflareMesh.js +3 -3
- package/examples/jsm/objects/SkyMesh.js +2 -2
- package/examples/jsm/physics/RapierPhysics.js +14 -5
- package/examples/jsm/postprocessing/GTAOPass.js +10 -9
- package/examples/jsm/postprocessing/OutlinePass.js +17 -17
- package/examples/jsm/postprocessing/SSAOPass.js +10 -9
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +11 -2
- package/examples/jsm/transpiler/GLSLDecoder.js +2 -2
- package/examples/jsm/tsl/display/BloomNode.js +8 -7
- package/examples/jsm/tsl/display/GaussianBlurNode.js +6 -8
- package/examples/jsm/tsl/display/{TRAAPassNode.js → TRAANode.js} +181 -172
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +1 -1
- package/package.json +1 -1
- package/src/Three.Core.js +1 -0
- package/src/Three.TSL.js +69 -20
- package/src/animation/KeyframeTrack.js +1 -1
- package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
- package/src/animation/tracks/StringKeyframeTrack.js +1 -1
- package/src/cameras/Camera.js +14 -0
- package/src/cameras/OrthographicCamera.js +1 -1
- package/src/cameras/PerspectiveCamera.js +1 -1
- package/src/constants.js +1 -1
- package/{examples/jsm/misc → src/core}/Timer.js +4 -42
- package/src/extras/PMREMGenerator.js +11 -0
- package/src/helpers/CameraHelper.js +41 -11
- package/src/helpers/SkeletonHelper.js +35 -6
- package/src/lights/LightShadow.js +21 -8
- package/src/lights/PointLightShadow.js +1 -1
- package/src/loaders/FileLoader.js +25 -2
- package/src/loaders/ImageBitmapLoader.js +23 -0
- package/src/loaders/Loader.js +14 -0
- package/src/loaders/LoadingManager.js +23 -0
- package/src/materials/MeshBasicMaterial.js +1 -1
- package/src/materials/nodes/Line2NodeMaterial.js +0 -8
- package/src/materials/nodes/NodeMaterial.js +1 -1
- package/src/materials/nodes/PointsNodeMaterial.js +5 -0
- package/src/materials/nodes/manager/NodeMaterialObserver.js +87 -2
- package/src/math/Frustum.js +19 -8
- package/src/math/FrustumArray.js +10 -5
- package/src/math/Line3.js +129 -2
- package/src/math/Matrix4.js +48 -27
- package/src/math/Spherical.js +2 -2
- package/src/nodes/Nodes.js +1 -0
- package/src/nodes/TSL.js +1 -0
- package/src/nodes/accessors/Camera.js +12 -12
- package/src/nodes/accessors/Normal.js +11 -11
- package/src/nodes/accessors/ReferenceNode.js +18 -3
- package/src/nodes/accessors/SceneNode.js +1 -1
- package/src/nodes/accessors/StorageTextureNode.js +1 -1
- package/src/nodes/accessors/TextureNode.js +12 -0
- package/src/nodes/core/ArrayNode.js +12 -0
- package/src/nodes/core/AssignNode.js +3 -0
- package/src/nodes/core/ContextNode.js +20 -1
- package/src/nodes/core/Node.js +14 -2
- package/src/nodes/core/NodeBuilder.js +25 -20
- package/src/nodes/core/NodeUtils.js +4 -1
- package/src/nodes/core/StackNode.js +42 -0
- package/src/nodes/core/UniformNode.js +63 -5
- package/src/nodes/core/VarNode.js +91 -2
- package/src/nodes/display/PassNode.js +148 -2
- package/src/nodes/display/ViewportTextureNode.js +67 -7
- package/src/nodes/functions/PhysicalLightingModel.js +2 -2
- package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
- package/src/nodes/gpgpu/ComputeNode.js +67 -23
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +28 -3
- package/src/nodes/lighting/ProjectorLightNode.js +19 -6
- package/src/nodes/lighting/ShadowFilterNode.js +1 -1
- package/src/nodes/materialx/MaterialXNodes.js +131 -2
- package/src/nodes/materialx/lib/mx_noise.js +165 -1
- package/src/nodes/math/ConditionalNode.js +1 -1
- package/src/nodes/math/MathNode.js +78 -54
- package/src/nodes/math/OperatorNode.js +22 -22
- package/src/nodes/tsl/TSLCore.js +64 -9
- package/src/nodes/utils/DebugNode.js +1 -1
- package/src/nodes/utils/EventNode.js +83 -0
- package/src/nodes/utils/RTTNode.js +9 -0
- package/src/objects/BatchedMesh.js +4 -2
- package/src/renderers/WebGLRenderer.js +21 -22
- package/src/renderers/common/Bindings.js +19 -18
- package/src/renderers/common/Color4.js +2 -2
- package/src/renderers/common/PostProcessing.js +60 -5
- package/src/renderers/common/Renderer.js +18 -15
- package/src/renderers/common/SampledTexture.js +3 -71
- package/src/renderers/common/Sampler.js +79 -0
- package/src/renderers/common/Storage3DTexture.js +21 -0
- package/src/renderers/common/StorageArrayTexture.js +21 -0
- package/src/renderers/common/StorageTexture.js +19 -0
- package/src/renderers/common/Textures.js +19 -3
- package/src/renderers/common/XRManager.js +26 -8
- package/src/renderers/common/nodes/NodeSampledTexture.js +0 -12
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +20 -2
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +11 -2
- package/src/renderers/webgl/WebGLCapabilities.js +2 -2
- package/src/renderers/webgl/WebGLMaterials.js +6 -6
- package/src/renderers/webgl/WebGLProgram.js +22 -16
- package/src/renderers/webgl/WebGLPrograms.js +4 -4
- package/src/renderers/webgl/WebGLShadowMap.js +11 -1
- package/src/renderers/webgl/WebGLTextures.js +19 -7
- package/src/renderers/webgl-fallback/WebGLBackend.js +22 -12
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +2 -2
- package/src/renderers/webgpu/WebGPUBackend.js +54 -15
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +53 -73
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +35 -31
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +11 -64
- package/src/renderers/webgpu/utils/WebGPUUtils.js +2 -17
- package/src/renderers/webxr/WebXRDepthSensing.js +6 -10
- package/src/renderers/webxr/WebXRManager.js +68 -8
- package/src/textures/ExternalTexture.js +45 -0
- package/src/textures/FramebufferTexture.js +2 -2
- package/src/textures/Source.js +11 -1
- package/src/textures/VideoTexture.js +30 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { add, float, If, Loop, int, Fn, min, max, clamp, nodeObject, texture, uniform, uv, vec2, vec4, luminance } from 'three/tsl';
|
|
1
|
+
import { HalfFloatType, Vector2, RenderTarget, RendererUtils, QuadMesh, NodeMaterial, TempNode, NodeUpdateType, Matrix4 } from 'three/webgpu';
|
|
2
|
+
import { add, float, If, Loop, int, Fn, min, max, clamp, nodeObject, texture, uniform, uv, vec2, vec4, luminance, convertToTexture, passTexture, velocity } from 'three/tsl';
|
|
3
3
|
|
|
4
4
|
const _quadMesh = /*@__PURE__*/ new QuadMesh();
|
|
5
5
|
const _size = /*@__PURE__*/ new Vector2();
|
|
@@ -8,34 +8,34 @@ let _rendererState;
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* A special
|
|
12
|
-
*
|
|
13
|
-
* Note: The current implementation does not yet support MRT setups.
|
|
11
|
+
* A special node that applies TRAA (Temporal Reprojection Anti-Aliasing).
|
|
14
12
|
*
|
|
15
13
|
* References:
|
|
16
14
|
* - {@link https://alextardif.com/TAA.html}
|
|
17
15
|
* - {@link https://www.elopezr.com/temporal-aa-and-the-quest-for-the-holy-trail/}
|
|
18
16
|
*
|
|
19
|
-
* @augments
|
|
20
|
-
* @three_import import {
|
|
17
|
+
* @augments TempNode
|
|
18
|
+
* @three_import import { traa } from 'three/addons/tsl/display/TRAANode.js';
|
|
21
19
|
*/
|
|
22
|
-
class
|
|
20
|
+
class TRAANode extends TempNode {
|
|
23
21
|
|
|
24
22
|
static get type() {
|
|
25
23
|
|
|
26
|
-
return '
|
|
24
|
+
return 'TRAANode';
|
|
27
25
|
|
|
28
26
|
}
|
|
29
27
|
|
|
30
28
|
/**
|
|
31
|
-
* Constructs a new TRAA
|
|
29
|
+
* Constructs a new TRAA node.
|
|
32
30
|
*
|
|
33
|
-
* @param {
|
|
34
|
-
* @param {
|
|
31
|
+
* @param {TextureNode} beautyNode - The texture node that represents the input of the effect.
|
|
32
|
+
* @param {TextureNode} depthNode - A node that represents the scene's depth.
|
|
33
|
+
* @param {TextureNode} velocityNode - A node that represents the scene's velocity.
|
|
34
|
+
* @param {Camera} camera - The camera the scene is rendered with.
|
|
35
35
|
*/
|
|
36
|
-
constructor(
|
|
36
|
+
constructor( beautyNode, depthNode, velocityNode, camera ) {
|
|
37
37
|
|
|
38
|
-
super(
|
|
38
|
+
super( 'vec4' );
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* This flag can be used for type testing.
|
|
@@ -44,40 +44,53 @@ class TRAAPassNode extends PassNode {
|
|
|
44
44
|
* @readonly
|
|
45
45
|
* @default true
|
|
46
46
|
*/
|
|
47
|
-
this.
|
|
47
|
+
this.isTRAANode = true;
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
|
-
* The
|
|
50
|
+
* The `updateBeforeType` is set to `NodeUpdateType.FRAME` since the node renders
|
|
51
|
+
* its effect once per frame in `updateBefore()`.
|
|
51
52
|
*
|
|
52
|
-
* @type {
|
|
53
|
-
* @default
|
|
53
|
+
* @type {string}
|
|
54
|
+
* @default 'frame'
|
|
54
55
|
*/
|
|
55
|
-
this.
|
|
56
|
+
this.updateBeforeType = NodeUpdateType.FRAME;
|
|
56
57
|
|
|
57
58
|
/**
|
|
58
|
-
* The
|
|
59
|
+
* The texture node that represents the input of the effect.
|
|
59
60
|
*
|
|
60
|
-
* @type {
|
|
61
|
-
* @default 0
|
|
61
|
+
* @type {TextureNode}
|
|
62
62
|
*/
|
|
63
|
-
this.
|
|
63
|
+
this.beautyNode = beautyNode;
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
|
-
*
|
|
66
|
+
* A node that represents the scene's velocity.
|
|
67
67
|
*
|
|
68
|
-
* @
|
|
69
|
-
* @type {number}
|
|
70
|
-
* @default 0
|
|
68
|
+
* @type {TextureNode}
|
|
71
69
|
*/
|
|
72
|
-
this.
|
|
70
|
+
this.depthNode = depthNode;
|
|
73
71
|
|
|
74
72
|
/**
|
|
75
|
-
*
|
|
73
|
+
* A node that represents the scene's velocity.
|
|
74
|
+
*
|
|
75
|
+
* @type {TextureNode}
|
|
76
|
+
*/
|
|
77
|
+
this.velocityNode = velocityNode;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The camera the scene is rendered with.
|
|
81
|
+
*
|
|
82
|
+
* @type {TextureNode}
|
|
83
|
+
*/
|
|
84
|
+
this.camera = camera;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The jitter index selects the current camera offset value.
|
|
76
88
|
*
|
|
77
89
|
* @private
|
|
78
|
-
* @type {
|
|
90
|
+
* @type {number}
|
|
91
|
+
* @default 0
|
|
79
92
|
*/
|
|
80
|
-
this.
|
|
93
|
+
this._jitterIndex = 0;
|
|
81
94
|
|
|
82
95
|
/**
|
|
83
96
|
* A uniform node holding the inverse resolution value.
|
|
@@ -88,22 +101,22 @@ class TRAAPassNode extends PassNode {
|
|
|
88
101
|
this._invSize = uniform( new Vector2() );
|
|
89
102
|
|
|
90
103
|
/**
|
|
91
|
-
* The render target that
|
|
104
|
+
* The render target that represents the history of frame data.
|
|
92
105
|
*
|
|
93
106
|
* @private
|
|
94
107
|
* @type {?RenderTarget}
|
|
95
|
-
* @default null
|
|
96
108
|
*/
|
|
97
|
-
this.
|
|
109
|
+
this._historyRenderTarget = new RenderTarget( 1, 1, { depthBuffer: false, type: HalfFloatType } );
|
|
110
|
+
this._historyRenderTarget.texture.name = 'TRAANode.history';
|
|
98
111
|
|
|
99
112
|
/**
|
|
100
|
-
* The render target
|
|
113
|
+
* The render target for the resolve.
|
|
101
114
|
*
|
|
102
115
|
* @private
|
|
103
116
|
* @type {?RenderTarget}
|
|
104
|
-
* @default null
|
|
105
117
|
*/
|
|
106
|
-
this.
|
|
118
|
+
this._resolveRenderTarget = new RenderTarget( 1, 1, { depthBuffer: false, type: HalfFloatType } );
|
|
119
|
+
this._resolveRenderTarget.texture.name = 'TRAANode.resolve';
|
|
107
120
|
|
|
108
121
|
/**
|
|
109
122
|
* Material used for the resolve step.
|
|
@@ -112,7 +125,41 @@ class TRAAPassNode extends PassNode {
|
|
|
112
125
|
* @type {NodeMaterial}
|
|
113
126
|
*/
|
|
114
127
|
this._resolveMaterial = new NodeMaterial();
|
|
115
|
-
this._resolveMaterial.name = 'TRAA.
|
|
128
|
+
this._resolveMaterial.name = 'TRAA.resolve';
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* The result of the effect is represented as a separate texture node.
|
|
132
|
+
*
|
|
133
|
+
* @private
|
|
134
|
+
* @type {PassTextureNode}
|
|
135
|
+
*/
|
|
136
|
+
this._textureNode = passTexture( this, this._resolveRenderTarget.texture );
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Used to save the original/unjittered projection matrix.
|
|
140
|
+
*
|
|
141
|
+
* @private
|
|
142
|
+
* @type {Matrix4}
|
|
143
|
+
*/
|
|
144
|
+
this._originalProjectionMatrix = new Matrix4();
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Sync the post processing stack with the TRAA node.
|
|
148
|
+
* @private
|
|
149
|
+
* @type {boolean}
|
|
150
|
+
*/
|
|
151
|
+
this._needsPostProcessingSync = false;
|
|
152
|
+
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Returns the result of the effect as a texture node.
|
|
157
|
+
*
|
|
158
|
+
* @return {PassTextureNode} A texture node that represents the result of the effect.
|
|
159
|
+
*/
|
|
160
|
+
getTextureNode() {
|
|
161
|
+
|
|
162
|
+
return this._textureNode;
|
|
116
163
|
|
|
117
164
|
}
|
|
118
165
|
|
|
@@ -121,78 +168,48 @@ class TRAAPassNode extends PassNode {
|
|
|
121
168
|
*
|
|
122
169
|
* @param {number} width - The width of the effect.
|
|
123
170
|
* @param {number} height - The height of the effect.
|
|
124
|
-
* @return {boolean} Whether the TRAA needs a restart or not. That is required after a resize since buffer data with different sizes can't be resolved.
|
|
125
171
|
*/
|
|
126
172
|
setSize( width, height ) {
|
|
127
173
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
let needsRestart = false;
|
|
131
|
-
|
|
132
|
-
if ( this.renderTarget.width !== this._sampleRenderTarget.width || this.renderTarget.height !== this._sampleRenderTarget.height ) {
|
|
133
|
-
|
|
134
|
-
this._sampleRenderTarget.setSize( this.renderTarget.width, this.renderTarget.height );
|
|
135
|
-
this._historyRenderTarget.setSize( this.renderTarget.width, this.renderTarget.height );
|
|
136
|
-
|
|
137
|
-
this._invSize.value.set( 1 / this.renderTarget.width, 1 / this.renderTarget.height );
|
|
138
|
-
|
|
139
|
-
needsRestart = true;
|
|
140
|
-
|
|
141
|
-
}
|
|
174
|
+
this._historyRenderTarget.setSize( width, height );
|
|
175
|
+
this._resolveRenderTarget.setSize( width, height );
|
|
142
176
|
|
|
143
|
-
|
|
177
|
+
this._invSize.value.set( 1 / width, 1 / height );
|
|
144
178
|
|
|
145
179
|
}
|
|
146
180
|
|
|
147
181
|
/**
|
|
148
|
-
*
|
|
182
|
+
* Defines the TRAA's current jitter as a view offset
|
|
183
|
+
* to the scene's camera.
|
|
149
184
|
*
|
|
150
|
-
* @param {
|
|
185
|
+
* @param {number} width - The width of the effect.
|
|
186
|
+
* @param {number} height - The height of the effect.
|
|
151
187
|
*/
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
const { renderer } = frame;
|
|
155
|
-
const { scene, camera } = this;
|
|
156
|
-
|
|
157
|
-
_rendererState = RendererUtils.resetRendererState( renderer, _rendererState );
|
|
158
|
-
|
|
159
|
-
//
|
|
160
|
-
|
|
161
|
-
this._pixelRatio = renderer.getPixelRatio();
|
|
162
|
-
const size = renderer.getSize( _size );
|
|
163
|
-
|
|
164
|
-
const needsRestart = this.setSize( size.width, size.height );
|
|
188
|
+
setViewOffset( width, height ) {
|
|
165
189
|
|
|
166
190
|
// save original/unjittered projection matrix for velocity pass
|
|
167
191
|
|
|
168
|
-
camera.updateProjectionMatrix();
|
|
169
|
-
this._originalProjectionMatrix.copy( camera.projectionMatrix );
|
|
192
|
+
this.camera.updateProjectionMatrix();
|
|
193
|
+
this._originalProjectionMatrix.copy( this.camera.projectionMatrix );
|
|
170
194
|
|
|
171
|
-
|
|
195
|
+
velocity.setProjectionMatrix( this._originalProjectionMatrix );
|
|
172
196
|
|
|
173
|
-
|
|
174
|
-
this._cameraFar.value = camera.far;
|
|
175
|
-
|
|
176
|
-
// configure jitter as view offset
|
|
197
|
+
//
|
|
177
198
|
|
|
178
199
|
const viewOffset = {
|
|
179
200
|
|
|
180
|
-
fullWidth:
|
|
181
|
-
fullHeight:
|
|
201
|
+
fullWidth: width,
|
|
202
|
+
fullHeight: height,
|
|
182
203
|
offsetX: 0,
|
|
183
204
|
offsetY: 0,
|
|
184
|
-
width:
|
|
185
|
-
height:
|
|
205
|
+
width: width,
|
|
206
|
+
height: height
|
|
186
207
|
|
|
187
208
|
};
|
|
188
209
|
|
|
189
|
-
const originalViewOffset = Object.assign( {}, camera.view );
|
|
190
|
-
|
|
191
|
-
if ( originalViewOffset.enabled ) Object.assign( viewOffset, originalViewOffset );
|
|
192
|
-
|
|
193
210
|
const jitterOffset = _JitterVectors[ this._jitterIndex ];
|
|
194
211
|
|
|
195
|
-
camera.setViewOffset(
|
|
212
|
+
this.camera.setViewOffset(
|
|
196
213
|
|
|
197
214
|
viewOffset.fullWidth, viewOffset.fullHeight,
|
|
198
215
|
|
|
@@ -202,95 +219,88 @@ class TRAAPassNode extends PassNode {
|
|
|
202
219
|
|
|
203
220
|
);
|
|
204
221
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
const mrt = this.getMRT();
|
|
208
|
-
const velocityOutput = mrt.get( 'velocity' );
|
|
209
|
-
|
|
210
|
-
if ( velocityOutput !== undefined ) {
|
|
211
|
-
|
|
212
|
-
velocityOutput.setProjectionMatrix( this._originalProjectionMatrix );
|
|
213
|
-
|
|
214
|
-
} else {
|
|
215
|
-
|
|
216
|
-
throw new Error( 'THREE:TRAAPassNode: Missing velocity output in MRT configuration.' );
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
// render sample
|
|
222
|
+
}
|
|
221
223
|
|
|
222
|
-
|
|
224
|
+
/**
|
|
225
|
+
* Clears the view offset from the scene's camera.
|
|
226
|
+
*/
|
|
227
|
+
clearViewOffset() {
|
|
223
228
|
|
|
224
|
-
|
|
225
|
-
renderer.setRenderTarget( this._sampleRenderTarget );
|
|
226
|
-
renderer.render( scene, camera );
|
|
229
|
+
this.camera.clearViewOffset();
|
|
227
230
|
|
|
228
|
-
|
|
229
|
-
renderer.setMRT( null );
|
|
231
|
+
velocity.setProjectionMatrix( null );
|
|
230
232
|
|
|
231
|
-
//
|
|
232
|
-
// into the history and final render target (no AA happens at that point).
|
|
233
|
+
// update jitter index
|
|
233
234
|
|
|
234
|
-
|
|
235
|
+
this._jitterIndex ++;
|
|
236
|
+
this._jitterIndex = this._jitterIndex % ( _JitterVectors.length - 1 );
|
|
235
237
|
|
|
236
|
-
|
|
238
|
+
}
|
|
237
239
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
+
/**
|
|
241
|
+
* This method is used to render the effect once per frame.
|
|
242
|
+
*
|
|
243
|
+
* @param {NodeFrame} frame - The current node frame.
|
|
244
|
+
*/
|
|
245
|
+
updateBefore( frame ) {
|
|
240
246
|
|
|
241
|
-
|
|
242
|
-
renderer.clear();
|
|
247
|
+
const { renderer } = frame;
|
|
243
248
|
|
|
244
|
-
|
|
249
|
+
// keep the TRAA in sync with the dimensions of the beauty node
|
|
245
250
|
|
|
246
|
-
|
|
247
|
-
renderer.copyTextureToTexture( this._sampleRenderTarget.texture, this.renderTarget.texture );
|
|
251
|
+
const beautyRenderTarget = ( this.beautyNode.isRTTNode ) ? this.beautyNode.renderTarget : this.beautyNode.passNode.renderTarget;
|
|
248
252
|
|
|
249
|
-
|
|
253
|
+
const width = beautyRenderTarget.texture.width;
|
|
254
|
+
const height = beautyRenderTarget.texture.height;
|
|
250
255
|
|
|
251
|
-
|
|
256
|
+
//
|
|
252
257
|
|
|
253
|
-
|
|
254
|
-
_quadMesh.material = this._resolveMaterial;
|
|
255
|
-
_quadMesh.render( renderer );
|
|
256
|
-
renderer.setRenderTarget( null );
|
|
258
|
+
if ( this._needsPostProcessingSync === true ) {
|
|
257
259
|
|
|
258
|
-
|
|
260
|
+
this.setViewOffset( width, height );
|
|
259
261
|
|
|
260
|
-
|
|
262
|
+
this._needsPostProcessingSync = false;
|
|
261
263
|
|
|
262
264
|
}
|
|
263
265
|
|
|
264
|
-
|
|
266
|
+
_rendererState = RendererUtils.resetRendererState( renderer, _rendererState );
|
|
267
|
+
|
|
268
|
+
//
|
|
265
269
|
|
|
266
|
-
|
|
270
|
+
const needsRestart = this._historyRenderTarget.width !== width || this._historyRenderTarget.height !== height;
|
|
271
|
+
this.setSize( width, height );
|
|
267
272
|
|
|
268
|
-
//
|
|
273
|
+
// every time when the dimensions change we need fresh history data
|
|
269
274
|
|
|
270
|
-
|
|
271
|
-
this._jitterIndex = this._jitterIndex % ( _JitterVectors.length - 1 );
|
|
275
|
+
if ( needsRestart === true ) {
|
|
272
276
|
|
|
273
|
-
|
|
277
|
+
// bind and clear render target to make sure they are initialized after the resize which triggers a dispose()
|
|
274
278
|
|
|
275
|
-
|
|
279
|
+
renderer.setRenderTarget( this._historyRenderTarget );
|
|
280
|
+
renderer.clear();
|
|
276
281
|
|
|
277
|
-
|
|
282
|
+
renderer.setRenderTarget( this._resolveRenderTarget );
|
|
283
|
+
renderer.clear();
|
|
278
284
|
|
|
279
|
-
|
|
285
|
+
// make sure to reset the history with the contents of the beauty buffer otherwise subsequent frames after the
|
|
286
|
+
// resize will fade from a darker color to the correct one because the history was cleared with black.
|
|
280
287
|
|
|
281
|
-
|
|
288
|
+
renderer.copyTextureToTexture( beautyRenderTarget.texture, this._historyRenderTarget.texture );
|
|
282
289
|
|
|
283
|
-
|
|
290
|
+
}
|
|
284
291
|
|
|
285
|
-
|
|
292
|
+
// resolve
|
|
286
293
|
|
|
287
|
-
|
|
294
|
+
renderer.setRenderTarget( this._resolveRenderTarget );
|
|
295
|
+
_quadMesh.material = this._resolveMaterial;
|
|
296
|
+
_quadMesh.render( renderer );
|
|
297
|
+
renderer.setRenderTarget( null );
|
|
288
298
|
|
|
289
|
-
|
|
299
|
+
// update history
|
|
290
300
|
|
|
291
|
-
|
|
301
|
+
renderer.copyTextureToTexture( this._resolveRenderTarget.texture, this._historyRenderTarget.texture );
|
|
292
302
|
|
|
293
|
-
|
|
303
|
+
// restore
|
|
294
304
|
|
|
295
305
|
RendererUtils.restoreRendererState( renderer, _rendererState );
|
|
296
306
|
|
|
@@ -304,28 +314,31 @@ class TRAAPassNode extends PassNode {
|
|
|
304
314
|
*/
|
|
305
315
|
setup( builder ) {
|
|
306
316
|
|
|
307
|
-
|
|
317
|
+
const postProcessing = builder.context.postProcessing;
|
|
308
318
|
|
|
309
|
-
|
|
310
|
-
this._historyRenderTarget = this.renderTarget.clone();
|
|
319
|
+
if ( postProcessing ) {
|
|
311
320
|
|
|
312
|
-
this.
|
|
313
|
-
this._sampleRenderTarget.texture.magFilter = NearestFilter;
|
|
321
|
+
this._needsPostProcessingSync = true;
|
|
314
322
|
|
|
315
|
-
|
|
316
|
-
velocityTarget.isRenderTargetTexture = true;
|
|
317
|
-
velocityTarget.name = 'velocity';
|
|
323
|
+
postProcessing.context.onBeforePostProcessing = () => {
|
|
318
324
|
|
|
319
|
-
|
|
325
|
+
const size = builder.renderer.getDrawingBufferSize( _size );
|
|
326
|
+
this.setViewOffset( size.width, size.height );
|
|
320
327
|
|
|
321
|
-
|
|
328
|
+
};
|
|
322
329
|
|
|
323
|
-
|
|
330
|
+
postProcessing.context.onAfterPostProcessing = () => {
|
|
331
|
+
|
|
332
|
+
this.clearViewOffset();
|
|
333
|
+
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
}
|
|
324
337
|
|
|
325
338
|
const historyTexture = texture( this._historyRenderTarget.texture );
|
|
326
|
-
const sampleTexture =
|
|
327
|
-
const
|
|
328
|
-
const
|
|
339
|
+
const sampleTexture = this.beautyNode;
|
|
340
|
+
const depthTexture = this.depthNode;
|
|
341
|
+
const velocityTexture = this.velocityNode;
|
|
329
342
|
|
|
330
343
|
const resolve = Fn( () => {
|
|
331
344
|
|
|
@@ -395,9 +408,9 @@ class TRAAPassNode extends PassNode {
|
|
|
395
408
|
|
|
396
409
|
// materials
|
|
397
410
|
|
|
398
|
-
this._resolveMaterial.
|
|
411
|
+
this._resolveMaterial.colorNode = resolve();
|
|
399
412
|
|
|
400
|
-
return
|
|
413
|
+
return this._textureNode;
|
|
401
414
|
|
|
402
415
|
}
|
|
403
416
|
|
|
@@ -407,14 +420,8 @@ class TRAAPassNode extends PassNode {
|
|
|
407
420
|
*/
|
|
408
421
|
dispose() {
|
|
409
422
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
if ( this._sampleRenderTarget !== null ) {
|
|
413
|
-
|
|
414
|
-
this._sampleRenderTarget.dispose();
|
|
415
|
-
this._historyRenderTarget.dispose();
|
|
416
|
-
|
|
417
|
-
}
|
|
423
|
+
this._historyRenderTarget.dispose();
|
|
424
|
+
this._resolveRenderTarget.dispose();
|
|
418
425
|
|
|
419
426
|
this._resolveMaterial.dispose();
|
|
420
427
|
|
|
@@ -422,7 +429,7 @@ class TRAAPassNode extends PassNode {
|
|
|
422
429
|
|
|
423
430
|
}
|
|
424
431
|
|
|
425
|
-
export default
|
|
432
|
+
export default TRAANode;
|
|
426
433
|
|
|
427
434
|
// These jitter vectors are specified in integers because it is easier.
|
|
428
435
|
// I am assuming a [-8,8) integer grid, but it needs to be mapped onto [-0.5,0.5)
|
|
@@ -441,12 +448,14 @@ const _JitterVectors = [
|
|
|
441
448
|
];
|
|
442
449
|
|
|
443
450
|
/**
|
|
444
|
-
* TSL function for creating a TRAA
|
|
451
|
+
* TSL function for creating a TRAA node for Temporal Reprojection Anti-Aliasing.
|
|
445
452
|
*
|
|
446
453
|
* @tsl
|
|
447
454
|
* @function
|
|
448
|
-
* @param {
|
|
449
|
-
* @param {
|
|
450
|
-
* @
|
|
455
|
+
* @param {TextureNode} beautyNode - The texture node that represents the input of the effect.
|
|
456
|
+
* @param {TextureNode} depthNode - A node that represents the scene's depth.
|
|
457
|
+
* @param {TextureNode} velocityNode - A node that represents the scene's velocity.
|
|
458
|
+
* @param {Camera} camera - The camera the scene is rendered with.
|
|
459
|
+
* @returns {TRAANode}
|
|
451
460
|
*/
|
|
452
|
-
export const
|
|
461
|
+
export const traa = ( beautyNode, depthNode, velocityNode, camera ) => nodeObject( new TRAANode( convertToTexture( beautyNode ), depthNode, velocityNode, camera ) );
|
|
@@ -322,7 +322,7 @@ class TiledLightsNode extends LightsNode {
|
|
|
322
322
|
const lightsTexture = new DataTexture( lightsData, lightsData.length / 8, 2, RGBAFormat, FloatType );
|
|
323
323
|
|
|
324
324
|
const lightIndexesArray = new Int32Array( count * 4 * 2 );
|
|
325
|
-
const lightIndexes = attributeArray( lightIndexesArray, 'ivec4' ).
|
|
325
|
+
const lightIndexes = attributeArray( lightIndexesArray, 'ivec4' ).setName( 'lightIndexes' );
|
|
326
326
|
|
|
327
327
|
// compute
|
|
328
328
|
|
package/package.json
CHANGED
package/src/Three.Core.js
CHANGED
|
@@ -103,6 +103,7 @@ export { Raycaster } from './core/Raycaster.js';
|
|
|
103
103
|
export { Layers } from './core/Layers.js';
|
|
104
104
|
export { EventDispatcher } from './core/EventDispatcher.js';
|
|
105
105
|
export { Clock } from './core/Clock.js';
|
|
106
|
+
export { Timer } from './core/Timer.js';
|
|
106
107
|
export { QuaternionLinearInterpolant } from './math/interpolants/QuaternionLinearInterpolant.js';
|
|
107
108
|
export { LinearInterpolant } from './math/interpolants/LinearInterpolant.js';
|
|
108
109
|
export { DiscreteInterpolant } from './math/interpolants/DiscreteInterpolant.js';
|