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
|
@@ -7,7 +7,7 @@ class ShaderToyDecoder extends GLSLDecoder {
|
|
|
7
7
|
|
|
8
8
|
super();
|
|
9
9
|
|
|
10
|
-
this.addPolyfill( 'iTime', 'float iTime =
|
|
10
|
+
this.addPolyfill( 'iTime', 'float iTime = time;' );
|
|
11
11
|
this.addPolyfill( 'iResolution', 'vec2 iResolution = screenSize;' );
|
|
12
12
|
this.addPolyfill( 'fragCoord', 'vec3 fragCoord = vec3( screenCoordinate.x, screenSize.y - screenCoordinate.y, screenCoordinate.z );' );
|
|
13
13
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { REVISION } from 'three/webgpu';
|
|
2
|
+
import * as TSL from 'three/tsl';
|
|
2
3
|
|
|
3
4
|
import { VariableDeclaration, Accessor } from './AST.js';
|
|
4
5
|
|
|
@@ -43,7 +44,7 @@ const unaryLib = {
|
|
|
43
44
|
'--': 'decrement' // decrementBefore
|
|
44
45
|
};
|
|
45
46
|
|
|
46
|
-
const isPrimitive = ( value ) => /^(true|false
|
|
47
|
+
const isPrimitive = ( value ) => /^(true|false|-?(\d|\.\d))/.test( value );
|
|
47
48
|
|
|
48
49
|
class TSLEncoder {
|
|
49
50
|
|
|
@@ -68,7 +69,7 @@ class TSLEncoder {
|
|
|
68
69
|
|
|
69
70
|
name = name.split( '.' )[ 0 ];
|
|
70
71
|
|
|
71
|
-
if (
|
|
72
|
+
if ( TSL[ name ] !== undefined && this.global.has( name ) === false && this._currentProperties[ name ] === undefined ) {
|
|
72
73
|
|
|
73
74
|
this.imports.add( name );
|
|
74
75
|
|
|
@@ -158,6 +159,10 @@ class TSLEncoder {
|
|
|
158
159
|
|
|
159
160
|
this.addImport( opFn );
|
|
160
161
|
|
|
162
|
+
} else if ( opFn === '.' ) {
|
|
163
|
+
|
|
164
|
+
code = left + opFn + right;
|
|
165
|
+
|
|
161
166
|
} else {
|
|
162
167
|
|
|
163
168
|
code = left + '.' + opFn + '( ' + right + ' )';
|
|
@@ -192,7 +197,7 @@ class TSLEncoder {
|
|
|
192
197
|
|
|
193
198
|
} else if ( node.isAccessorElements ) {
|
|
194
199
|
|
|
195
|
-
code = node.
|
|
200
|
+
code = this.emitExpression( node.object );
|
|
196
201
|
|
|
197
202
|
for ( const element of node.elements ) {
|
|
198
203
|
|
|
@@ -248,7 +253,7 @@ class TSLEncoder {
|
|
|
248
253
|
|
|
249
254
|
} else if ( node.isUnary && node.expression.isNumber ) {
|
|
250
255
|
|
|
251
|
-
code = node.type + ' ' + node.expression.value;
|
|
256
|
+
code = node.expression.type + '( ' + node.type + ' ' + node.expression.value + ' )';
|
|
252
257
|
|
|
253
258
|
} else if ( node.isUnary ) {
|
|
254
259
|
|
|
@@ -690,7 +695,7 @@ ${ this.tab }} )`;
|
|
|
690
695
|
const imports = [ ...this.imports ];
|
|
691
696
|
const exports = [ ...this.global ];
|
|
692
697
|
|
|
693
|
-
let header = '// Three.js Transpiler r' +
|
|
698
|
+
let header = '// Three.js Transpiler r' + REVISION + '\n\n';
|
|
694
699
|
let footer = '';
|
|
695
700
|
|
|
696
701
|
if ( this.iife ) {
|
|
@@ -1,22 +1,11 @@
|
|
|
1
|
-
import TempNode from '
|
|
2
|
-
import { nodeObject, Fn, float, vec4 } from '
|
|
3
|
-
import { NodeUpdateType } from '../core/constants.js';
|
|
4
|
-
import { uv } from '../accessors/UV.js';
|
|
5
|
-
import { texture } from '../accessors/TextureNode.js';
|
|
6
|
-
import { passTexture } from './PassNode.js';
|
|
7
|
-
import { uniform } from '../core/UniformNode.js';
|
|
8
|
-
import { sign, max } from '../math/MathNode.js';
|
|
9
|
-
import { convertToTexture } from '../utils/RTTNode.js';
|
|
10
|
-
import QuadMesh from '../../renderers/common/QuadMesh.js';
|
|
11
|
-
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
|
12
|
-
|
|
13
|
-
import { Vector2 } from '../../math/Vector2.js';
|
|
14
|
-
import { RenderTarget } from '../../core/RenderTarget.js';
|
|
1
|
+
import { RenderTarget, Vector2, QuadMesh, NodeMaterial, PostProcessingUtils, TempNode, NodeUpdateType } from 'three/webgpu';
|
|
2
|
+
import { nodeObject, Fn, float, vec4, uv, texture, passTexture, uniform, sign, max, convertToTexture } from 'three/tsl';
|
|
15
3
|
|
|
16
4
|
const _size = /*@__PURE__*/ new Vector2();
|
|
17
|
-
|
|
18
5
|
const _quadMeshComp = /*@__PURE__*/ new QuadMesh();
|
|
19
6
|
|
|
7
|
+
let _rendererState;
|
|
8
|
+
|
|
20
9
|
class AfterImageNode extends TempNode {
|
|
21
10
|
|
|
22
11
|
static get type() {
|
|
@@ -27,21 +16,21 @@ class AfterImageNode extends TempNode {
|
|
|
27
16
|
|
|
28
17
|
constructor( textureNode, damp = 0.96 ) {
|
|
29
18
|
|
|
30
|
-
super(
|
|
19
|
+
super( 'vec4' );
|
|
31
20
|
|
|
32
21
|
this.textureNode = textureNode;
|
|
33
22
|
this.textureNodeOld = texture();
|
|
34
23
|
this.damp = uniform( damp );
|
|
35
24
|
|
|
36
|
-
this._compRT = new RenderTarget();
|
|
25
|
+
this._compRT = new RenderTarget( 1, 1, { depthBuffer: false } );
|
|
37
26
|
this._compRT.texture.name = 'AfterImageNode.comp';
|
|
38
27
|
|
|
39
|
-
this._oldRT = new RenderTarget();
|
|
28
|
+
this._oldRT = new RenderTarget( 1, 1, { depthBuffer: false } );
|
|
40
29
|
this._oldRT.texture.name = 'AfterImageNode.old';
|
|
41
30
|
|
|
42
31
|
this._textureNode = passTexture( this, this._compRT.texture );
|
|
43
32
|
|
|
44
|
-
this.updateBeforeType = NodeUpdateType.
|
|
33
|
+
this.updateBeforeType = NodeUpdateType.FRAME;
|
|
45
34
|
|
|
46
35
|
}
|
|
47
36
|
|
|
@@ -62,6 +51,10 @@ class AfterImageNode extends TempNode {
|
|
|
62
51
|
|
|
63
52
|
const { renderer } = frame;
|
|
64
53
|
|
|
54
|
+
_rendererState = PostProcessingUtils.resetRendererState( renderer, _rendererState );
|
|
55
|
+
|
|
56
|
+
//
|
|
57
|
+
|
|
65
58
|
const textureNode = this.textureNode;
|
|
66
59
|
const map = textureNode.value;
|
|
67
60
|
|
|
@@ -74,23 +67,27 @@ class AfterImageNode extends TempNode {
|
|
|
74
67
|
|
|
75
68
|
this.setSize( _size.x, _size.y );
|
|
76
69
|
|
|
77
|
-
const currentRenderTarget = renderer.getRenderTarget();
|
|
78
70
|
const currentTexture = textureNode.value;
|
|
79
71
|
|
|
80
72
|
this.textureNodeOld.value = this._oldRT.texture;
|
|
81
73
|
|
|
82
74
|
// comp
|
|
75
|
+
|
|
83
76
|
renderer.setRenderTarget( this._compRT );
|
|
84
77
|
_quadMeshComp.render( renderer );
|
|
85
78
|
|
|
86
79
|
// Swap the textures
|
|
80
|
+
|
|
87
81
|
const temp = this._oldRT;
|
|
88
82
|
this._oldRT = this._compRT;
|
|
89
83
|
this._compRT = temp;
|
|
90
84
|
|
|
91
|
-
|
|
85
|
+
//
|
|
86
|
+
|
|
92
87
|
textureNode.value = currentTexture;
|
|
93
88
|
|
|
89
|
+
PostProcessingUtils.restoreRendererState( renderer, _rendererState );
|
|
90
|
+
|
|
94
91
|
}
|
|
95
92
|
|
|
96
93
|
setup( builder ) {
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { uniform } from '../core/UniformNode.js';
|
|
4
|
-
import { uv } from '../accessors/UV.js';
|
|
5
|
-
import { clamp, max } from '../math/MathNode.js';
|
|
1
|
+
import { Matrix3, NodeMaterial } from 'three/webgpu';
|
|
2
|
+
import { clamp, nodeObject, Fn, vec4, uv, uniform, max } from 'three/tsl';
|
|
6
3
|
import StereoCompositePassNode from './StereoCompositePassNode.js';
|
|
7
|
-
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
|
8
4
|
|
|
9
5
|
class AnaglyphPassNode extends StereoCompositePassNode {
|
|
10
6
|
|
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
import TempNode from '
|
|
2
|
-
import { nodeObject, Fn, float, vec2, vec3 } from '
|
|
3
|
-
import { Loop } from '../utils/LoopNode.js';
|
|
4
|
-
import { uniform } from '../core/UniformNode.js';
|
|
5
|
-
import { NodeUpdateType } from '../core/constants.js';
|
|
6
|
-
import { threshold } from './ColorAdjustment.js';
|
|
7
|
-
import { uv } from '../accessors/UV.js';
|
|
8
|
-
import { passTexture } from './PassNode.js';
|
|
9
|
-
import { convertToTexture } from '../utils/RTTNode.js';
|
|
10
|
-
import QuadMesh from '../../renderers/common/QuadMesh.js';
|
|
11
|
-
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
|
12
|
-
|
|
13
|
-
import { Vector2 } from '../../math/Vector2.js';
|
|
14
|
-
import { RenderTarget } from '../../core/RenderTarget.js';
|
|
1
|
+
import { RenderTarget, Vector2, TempNode, QuadMesh, NodeMaterial, PostProcessingUtils } from 'three/webgpu';
|
|
2
|
+
import { nodeObject, Fn, float, NodeUpdateType, uv, passTexture, uniform, convertToTexture, vec2, vec3, Loop, threshold } from 'three/tsl';
|
|
15
3
|
|
|
16
4
|
const _quadMesh = /*@__PURE__*/ new QuadMesh();
|
|
17
5
|
|
|
6
|
+
let _rendererState;
|
|
7
|
+
|
|
18
8
|
class AnamorphicNode extends TempNode {
|
|
19
9
|
|
|
20
10
|
static get type() {
|
|
@@ -34,14 +24,14 @@ class AnamorphicNode extends TempNode {
|
|
|
34
24
|
this.samples = samples;
|
|
35
25
|
this.resolution = new Vector2( 1, 1 );
|
|
36
26
|
|
|
37
|
-
this._renderTarget = new RenderTarget();
|
|
27
|
+
this._renderTarget = new RenderTarget( 1, 1, { depthBuffer: false } );
|
|
38
28
|
this._renderTarget.texture.name = 'anamorphic';
|
|
39
29
|
|
|
40
30
|
this._invSize = uniform( new Vector2() );
|
|
41
31
|
|
|
42
32
|
this._textureNode = passTexture( this, this._renderTarget.texture );
|
|
43
33
|
|
|
44
|
-
this.updateBeforeType = NodeUpdateType.
|
|
34
|
+
this.updateBeforeType = NodeUpdateType.FRAME;
|
|
45
35
|
|
|
46
36
|
}
|
|
47
37
|
|
|
@@ -66,12 +56,15 @@ class AnamorphicNode extends TempNode {
|
|
|
66
56
|
|
|
67
57
|
const { renderer } = frame;
|
|
68
58
|
|
|
59
|
+
_rendererState = PostProcessingUtils.resetRendererState( renderer, _rendererState );
|
|
60
|
+
|
|
61
|
+
//
|
|
62
|
+
|
|
69
63
|
const textureNode = this.textureNode;
|
|
70
64
|
const map = textureNode.value;
|
|
71
65
|
|
|
72
66
|
this._renderTarget.texture.type = map.type;
|
|
73
67
|
|
|
74
|
-
const currentRenderTarget = renderer.getRenderTarget();
|
|
75
68
|
const currentTexture = textureNode.value;
|
|
76
69
|
|
|
77
70
|
_quadMesh.material = this._material;
|
|
@@ -86,9 +79,10 @@ class AnamorphicNode extends TempNode {
|
|
|
86
79
|
|
|
87
80
|
// restore
|
|
88
81
|
|
|
89
|
-
renderer.setRenderTarget( currentRenderTarget );
|
|
90
82
|
textureNode.value = currentTexture;
|
|
91
83
|
|
|
84
|
+
PostProcessingUtils.restoreRendererState( renderer, _rendererState );
|
|
85
|
+
|
|
92
86
|
}
|
|
93
87
|
|
|
94
88
|
setup( builder ) {
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { float, Fn, vec3, vec4 } from '
|
|
2
|
-
import { min, max, mix } from '../math/MathNode.js';
|
|
3
|
-
import { luminance } from './ColorAdjustment.js';
|
|
1
|
+
import { float, Fn, vec3, vec4, min, max, mix, luminance } from 'three/tsl';
|
|
4
2
|
|
|
5
3
|
export const bleach = /*@__PURE__*/ Fn( ( [ color, opacity = 1 ] ) => {
|
|
6
4
|
|
|
@@ -1,32 +1,14 @@
|
|
|
1
|
-
import TempNode from '
|
|
2
|
-
import {
|
|
3
|
-
import { mix, smoothstep } from '../math/MathNode.js';
|
|
4
|
-
import { luminance } from './ColorAdjustment.js';
|
|
5
|
-
import { uniform } from '../core/UniformNode.js';
|
|
6
|
-
import { uniformArray } from '../accessors/UniformArrayNode.js';
|
|
7
|
-
import { uv } from '../accessors/UV.js';
|
|
8
|
-
import { Color } from '../../math/Color.js';
|
|
9
|
-
import { passTexture } from './PassNode.js';
|
|
10
|
-
import { RenderTarget } from '../../core/RenderTarget.js';
|
|
11
|
-
import { HalfFloatType } from '../../constants.js';
|
|
12
|
-
import { NodeUpdateType } from '../core/constants.js';
|
|
13
|
-
import { Vector2 } from '../../math/Vector2.js';
|
|
14
|
-
import { Loop } from '../utils/LoopNode.js';
|
|
15
|
-
import { add } from '../math/OperatorNode.js';
|
|
16
|
-
import QuadMesh from '../../renderers/common/QuadMesh.js';
|
|
17
|
-
import { texture } from '../accessors/TextureNode.js';
|
|
18
|
-
import { Vector3 } from '../../math/Vector3.js';
|
|
19
|
-
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
|
1
|
+
import { HalfFloatType, RenderTarget, Vector2, Vector3, TempNode, QuadMesh, NodeMaterial, PostProcessingUtils, NodeUpdateType } from 'three/webgpu';
|
|
2
|
+
import { nodeObject, Fn, float, uv, passTexture, uniform, Loop, texture, luminance, smoothstep, mix, vec4, uniformArray, add, int } from 'three/tsl';
|
|
20
3
|
|
|
21
4
|
const _quadMesh = /*@__PURE__*/ new QuadMesh();
|
|
22
|
-
|
|
23
|
-
const _clearColor = /*@__PURE__*/ new Color( 0, 0, 0 );
|
|
24
|
-
const _currentClearColor = /*@__PURE__*/ new Color();
|
|
25
5
|
const _size = /*@__PURE__*/ new Vector2();
|
|
26
6
|
|
|
27
7
|
const _BlurDirectionX = /*@__PURE__*/ new Vector2( 1.0, 0.0 );
|
|
28
8
|
const _BlurDirectionY = /*@__PURE__*/ new Vector2( 0.0, 1.0 );
|
|
29
9
|
|
|
10
|
+
let _rendererState;
|
|
11
|
+
|
|
30
12
|
class BloomNode extends TempNode {
|
|
31
13
|
|
|
32
14
|
static get type() {
|
|
@@ -37,7 +19,7 @@ class BloomNode extends TempNode {
|
|
|
37
19
|
|
|
38
20
|
constructor( inputNode, strength = 1, radius = 0, threshold = 0 ) {
|
|
39
21
|
|
|
40
|
-
super();
|
|
22
|
+
super( 'vec4' );
|
|
41
23
|
|
|
42
24
|
this.inputNode = inputNode;
|
|
43
25
|
this.strength = uniform( strength );
|
|
@@ -54,20 +36,20 @@ class BloomNode extends TempNode {
|
|
|
54
36
|
|
|
55
37
|
// render targets
|
|
56
38
|
|
|
57
|
-
this._renderTargetBright = new RenderTarget( 1, 1, { type: HalfFloatType } );
|
|
39
|
+
this._renderTargetBright = new RenderTarget( 1, 1, { depthBuffer: false, type: HalfFloatType } );
|
|
58
40
|
this._renderTargetBright.texture.name = 'UnrealBloomPass.bright';
|
|
59
41
|
this._renderTargetBright.texture.generateMipmaps = false;
|
|
60
42
|
|
|
61
43
|
for ( let i = 0; i < this._nMips; i ++ ) {
|
|
62
44
|
|
|
63
|
-
const renderTargetHorizontal = new RenderTarget( 1, 1, { type: HalfFloatType } );
|
|
45
|
+
const renderTargetHorizontal = new RenderTarget( 1, 1, { depthBuffer: false, type: HalfFloatType } );
|
|
64
46
|
|
|
65
47
|
renderTargetHorizontal.texture.name = 'UnrealBloomPass.h' + i;
|
|
66
48
|
renderTargetHorizontal.texture.generateMipmaps = false;
|
|
67
49
|
|
|
68
50
|
this._renderTargetsHorizontal.push( renderTargetHorizontal );
|
|
69
51
|
|
|
70
|
-
const renderTargetVertical = new RenderTarget( 1, 1, { type: HalfFloatType } );
|
|
52
|
+
const renderTargetVertical = new RenderTarget( 1, 1, { depthBuffer: false, type: HalfFloatType } );
|
|
71
53
|
|
|
72
54
|
renderTargetVertical.texture.name = 'UnrealBloomPass.v' + i;
|
|
73
55
|
renderTargetVertical.texture.generateMipmaps = false;
|
|
@@ -128,19 +110,13 @@ class BloomNode extends TempNode {
|
|
|
128
110
|
|
|
129
111
|
const { renderer } = frame;
|
|
130
112
|
|
|
131
|
-
|
|
132
|
-
this.setSize( size.width, size.height );
|
|
113
|
+
_rendererState = PostProcessingUtils.resetRendererState( renderer, _rendererState );
|
|
133
114
|
|
|
134
|
-
|
|
135
|
-
const currentMRT = renderer.getMRT();
|
|
136
|
-
renderer.getClearColor( _currentClearColor );
|
|
137
|
-
const currentClearAlpha = renderer.getClearAlpha();
|
|
115
|
+
//
|
|
138
116
|
|
|
117
|
+
const size = renderer.getDrawingBufferSize( _size );
|
|
139
118
|
this.setSize( size.width, size.height );
|
|
140
119
|
|
|
141
|
-
renderer.setMRT( null );
|
|
142
|
-
renderer.setClearColor( _clearColor, 0 );
|
|
143
|
-
|
|
144
120
|
// 1. Extract Bright Areas
|
|
145
121
|
|
|
146
122
|
renderer.setRenderTarget( this._renderTargetBright );
|
|
@@ -158,13 +134,11 @@ class BloomNode extends TempNode {
|
|
|
158
134
|
this._separableBlurMaterials[ i ].colorTexture.value = inputRenderTarget.texture;
|
|
159
135
|
this._separableBlurMaterials[ i ].direction.value = _BlurDirectionX;
|
|
160
136
|
renderer.setRenderTarget( this._renderTargetsHorizontal[ i ] );
|
|
161
|
-
renderer.clear();
|
|
162
137
|
_quadMesh.render( renderer );
|
|
163
138
|
|
|
164
139
|
this._separableBlurMaterials[ i ].colorTexture.value = this._renderTargetsHorizontal[ i ].texture;
|
|
165
140
|
this._separableBlurMaterials[ i ].direction.value = _BlurDirectionY;
|
|
166
141
|
renderer.setRenderTarget( this._renderTargetsVertical[ i ] );
|
|
167
|
-
renderer.clear();
|
|
168
142
|
_quadMesh.render( renderer );
|
|
169
143
|
|
|
170
144
|
inputRenderTarget = this._renderTargetsVertical[ i ];
|
|
@@ -174,15 +148,12 @@ class BloomNode extends TempNode {
|
|
|
174
148
|
// 3. Composite All the mips
|
|
175
149
|
|
|
176
150
|
renderer.setRenderTarget( this._renderTargetsHorizontal[ 0 ] );
|
|
177
|
-
renderer.clear();
|
|
178
151
|
_quadMesh.material = this._compositeMaterial;
|
|
179
152
|
_quadMesh.render( renderer );
|
|
180
153
|
|
|
181
154
|
// restore
|
|
182
155
|
|
|
183
|
-
|
|
184
|
-
renderer.setMRT( currentMRT );
|
|
185
|
-
renderer.setClearColor( _currentClearColor, currentClearAlpha );
|
|
156
|
+
PostProcessingUtils.restoreRendererState( renderer, _rendererState );
|
|
186
157
|
|
|
187
158
|
}
|
|
188
159
|
|
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
import TempNode from '
|
|
2
|
-
import { uv } from '
|
|
3
|
-
import {
|
|
4
|
-
import { NodeUpdateType } from '../core/constants.js';
|
|
5
|
-
import { uniform } from '../core/UniformNode.js';
|
|
6
|
-
import { uniformArray } from '../accessors/UniformArrayNode.js';
|
|
7
|
-
import { abs, dot, sin, cos, PI, pow, max } from '../math/MathNode.js';
|
|
8
|
-
import { Loop } from '../utils/LoopNode.js';
|
|
9
|
-
import { luminance } from './ColorAdjustment.js';
|
|
10
|
-
import { textureSize } from '../accessors/TextureSizeNode.js';
|
|
11
|
-
import { convertToTexture } from '../utils/RTTNode.js';
|
|
12
|
-
|
|
13
|
-
import { Vector2 } from '../../math/Vector2.js';
|
|
14
|
-
import { Vector3 } from '../../math/Vector3.js';
|
|
1
|
+
import { DataTexture, RepeatWrapping, Vector2, Vector3, TempNode } from 'three/webgpu';
|
|
2
|
+
import { texture, getNormalFromDepth, getViewPosition, convertToTexture, nodeObject, Fn, float, NodeUpdateType, uv, uniform, Loop, luminance, vec2, vec3, vec4, uniformArray, int, dot, max, pow, abs, If, textureSize, sin, cos, mat2, PI } from 'three/tsl';
|
|
3
|
+
import { SimplexNoise } from '../../math/SimplexNoise.js';
|
|
15
4
|
|
|
16
5
|
class DenoiseNode extends TempNode {
|
|
17
6
|
|
|
@@ -21,26 +10,29 @@ class DenoiseNode extends TempNode {
|
|
|
21
10
|
|
|
22
11
|
}
|
|
23
12
|
|
|
24
|
-
constructor( textureNode, depthNode, normalNode,
|
|
13
|
+
constructor( textureNode, depthNode, normalNode, camera ) {
|
|
25
14
|
|
|
26
|
-
super();
|
|
15
|
+
super( 'vec4' );
|
|
27
16
|
|
|
28
17
|
this.textureNode = textureNode;
|
|
29
18
|
this.depthNode = depthNode;
|
|
30
19
|
this.normalNode = normalNode;
|
|
31
|
-
this.noiseNode = noiseNode;
|
|
32
20
|
|
|
33
|
-
this.
|
|
21
|
+
this.noiseNode = texture( generateDefaultNoise() );
|
|
22
|
+
|
|
34
23
|
this.lumaPhi = uniform( 5 );
|
|
35
24
|
this.depthPhi = uniform( 5 );
|
|
36
25
|
this.normalPhi = uniform( 5 );
|
|
37
26
|
this.radius = uniform( 5 );
|
|
38
27
|
this.index = uniform( 0 );
|
|
39
28
|
|
|
29
|
+
this.updateBeforeType = NodeUpdateType.FRAME;
|
|
30
|
+
|
|
31
|
+
// uniforms
|
|
32
|
+
|
|
40
33
|
this._resolution = uniform( new Vector2() );
|
|
41
34
|
this._sampleVectors = uniformArray( generatePdSamplePointInitializer( 16, 2, 1 ) );
|
|
42
|
-
|
|
43
|
-
this.updateBeforeType = NodeUpdateType.RENDER;
|
|
35
|
+
this._cameraProjectionMatrixInverse = uniform( camera.projectionMatrixInverse );
|
|
44
36
|
|
|
45
37
|
}
|
|
46
38
|
|
|
@@ -58,27 +50,16 @@ class DenoiseNode extends TempNode {
|
|
|
58
50
|
|
|
59
51
|
const sampleTexture = ( uv ) => this.textureNode.uv( uv );
|
|
60
52
|
const sampleDepth = ( uv ) => this.depthNode.uv( uv ).x;
|
|
61
|
-
const sampleNormal = ( uv ) => this.normalNode.uv( uv );
|
|
53
|
+
const sampleNormal = ( uv ) => ( this.normalNode !== null ) ? this.normalNode.uv( uv ).rgb.normalize() : getNormalFromDepth( uv, this.depthNode.value, this._cameraProjectionMatrixInverse );
|
|
62
54
|
const sampleNoise = ( uv ) => this.noiseNode.uv( uv );
|
|
63
55
|
|
|
64
|
-
const getViewPosition = Fn( ( [ screenPosition, depth ] ) => {
|
|
65
|
-
|
|
66
|
-
screenPosition = vec2( screenPosition.x, screenPosition.y.oneMinus() ).mul( 2.0 ).sub( 1.0 );
|
|
67
|
-
|
|
68
|
-
const clipSpacePosition = vec4( vec3( screenPosition, depth ), 1.0 );
|
|
69
|
-
const viewSpacePosition = vec4( this.cameraProjectionMatrixInverse.mul( clipSpacePosition ) );
|
|
70
|
-
|
|
71
|
-
return viewSpacePosition.xyz.div( viewSpacePosition.w );
|
|
72
|
-
|
|
73
|
-
} );
|
|
74
|
-
|
|
75
56
|
const denoiseSample = Fn( ( [ center, viewNormal, viewPosition, sampleUv ] ) => {
|
|
76
57
|
|
|
77
|
-
const texel = sampleTexture( sampleUv );
|
|
78
|
-
const depth = sampleDepth( sampleUv );
|
|
79
|
-
const normal = sampleNormal( sampleUv ).
|
|
58
|
+
const texel = sampleTexture( sampleUv ).toVar();
|
|
59
|
+
const depth = sampleDepth( sampleUv ).toVar();
|
|
60
|
+
const normal = sampleNormal( sampleUv ).toVar();
|
|
80
61
|
const neighborColor = texel.rgb;
|
|
81
|
-
const viewPos = getViewPosition( sampleUv, depth );
|
|
62
|
+
const viewPos = getViewPosition( sampleUv, depth, this._cameraProjectionMatrixInverse ).toVar();
|
|
82
63
|
|
|
83
64
|
const normalDiff = dot( viewNormal, normal ).toVar();
|
|
84
65
|
const normalSimilarity = pow( max( normalDiff, 0 ), this.normalPhi ).toVar();
|
|
@@ -94,10 +75,10 @@ class DenoiseNode extends TempNode {
|
|
|
94
75
|
|
|
95
76
|
const denoise = Fn( ( [ uvNode ] ) => {
|
|
96
77
|
|
|
97
|
-
const depth = sampleDepth( uvNode );
|
|
98
|
-
const viewNormal = sampleNormal( uvNode ).
|
|
78
|
+
const depth = sampleDepth( uvNode ).toVar();
|
|
79
|
+
const viewNormal = sampleNormal( uvNode ).toVar();
|
|
99
80
|
|
|
100
|
-
const texel = sampleTexture( uvNode );
|
|
81
|
+
const texel = sampleTexture( uvNode ).toVar();
|
|
101
82
|
|
|
102
83
|
If( depth.greaterThanEqual( 1.0 ).or( dot( viewNormal, viewNormal ).equal( 0.0 ) ), () => {
|
|
103
84
|
|
|
@@ -105,20 +86,20 @@ class DenoiseNode extends TempNode {
|
|
|
105
86
|
|
|
106
87
|
} );
|
|
107
88
|
|
|
108
|
-
const center = vec3( texel.rgb );
|
|
89
|
+
const center = vec3( texel.rgb ).toVar();
|
|
109
90
|
|
|
110
|
-
const viewPosition = getViewPosition( uvNode, depth );
|
|
91
|
+
const viewPosition = getViewPosition( uvNode, depth, this._cameraProjectionMatrixInverse ).toVar();
|
|
111
92
|
|
|
112
93
|
const noiseResolution = textureSize( this.noiseNode, 0 );
|
|
113
94
|
let noiseUv = vec2( uvNode.x, uvNode.y.oneMinus() );
|
|
114
95
|
noiseUv = noiseUv.mul( this._resolution.div( noiseResolution ) );
|
|
115
|
-
const noiseTexel = sampleNoise( noiseUv );
|
|
96
|
+
const noiseTexel = sampleNoise( noiseUv ).toVar();
|
|
116
97
|
|
|
117
|
-
const x = sin( noiseTexel.element( this.index.mod( 4 ).mul( 2 ).mul( PI ) ) );
|
|
118
|
-
const y = cos( noiseTexel.element( this.index.mod( 4 ).mul( 2 ).mul( PI ) ) );
|
|
98
|
+
const x = sin( noiseTexel.element( this.index.mod( 4 ).mul( 2 ).mul( PI ) ) ).toVar();
|
|
99
|
+
const y = cos( noiseTexel.element( this.index.mod( 4 ).mul( 2 ).mul( PI ) ) ).toVar();
|
|
119
100
|
|
|
120
|
-
const noiseVec = vec2( x, y );
|
|
121
|
-
const rotationMatrix = mat2( noiseVec.x, noiseVec.y.negate(), noiseVec.x, noiseVec.y );
|
|
101
|
+
const noiseVec = vec2( x, y ).toVar();
|
|
102
|
+
const rotationMatrix = mat2( noiseVec.x, noiseVec.y.negate(), noiseVec.x, noiseVec.y ).toVar();
|
|
122
103
|
|
|
123
104
|
const totalWeight = float( 1.0 ).toVar();
|
|
124
105
|
const denoised = vec3( texel.rgb ).toVar();
|
|
@@ -201,4 +182,36 @@ function generateDenoiseSamples( numSamples, numRings, radiusExponent ) {
|
|
|
201
182
|
|
|
202
183
|
}
|
|
203
184
|
|
|
204
|
-
|
|
185
|
+
function generateDefaultNoise( size = 64 ) {
|
|
186
|
+
|
|
187
|
+
const simplex = new SimplexNoise();
|
|
188
|
+
|
|
189
|
+
const arraySize = size * size * 4;
|
|
190
|
+
const data = new Uint8Array( arraySize );
|
|
191
|
+
|
|
192
|
+
for ( let i = 0; i < size; i ++ ) {
|
|
193
|
+
|
|
194
|
+
for ( let j = 0; j < size; j ++ ) {
|
|
195
|
+
|
|
196
|
+
const x = i;
|
|
197
|
+
const y = j;
|
|
198
|
+
|
|
199
|
+
data[ ( i * size + j ) * 4 ] = ( simplex.noise( x, y ) * 0.5 + 0.5 ) * 255;
|
|
200
|
+
data[ ( i * size + j ) * 4 + 1 ] = ( simplex.noise( x + size, y ) * 0.5 + 0.5 ) * 255;
|
|
201
|
+
data[ ( i * size + j ) * 4 + 2 ] = ( simplex.noise( x, y + size ) * 0.5 + 0.5 ) * 255;
|
|
202
|
+
data[ ( i * size + j ) * 4 + 3 ] = ( simplex.noise( x + size, y + size ) * 0.5 + 0.5 ) * 255;
|
|
203
|
+
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const noiseTexture = new DataTexture( data, size, size );
|
|
209
|
+
noiseTexture.wrapS = RepeatWrapping;
|
|
210
|
+
noiseTexture.wrapT = RepeatWrapping;
|
|
211
|
+
noiseTexture.needsUpdate = true;
|
|
212
|
+
|
|
213
|
+
return noiseTexture;
|
|
214
|
+
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export const denoise = ( node, depthNode, normalNode, camera ) => nodeObject( new DenoiseNode( convertToTexture( node ), nodeObject( depthNode ), nodeObject( normalNode ), camera ) );
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import TempNode from '
|
|
2
|
-
import { uv } from '
|
|
3
|
-
import { Fn, nodeObject, vec2, vec4 } from '../tsl/TSLBase.js';
|
|
4
|
-
import { NodeUpdateType } from '../core/constants.js';
|
|
5
|
-
import { uniform } from '../core/UniformNode.js';
|
|
6
|
-
import { clamp } from '../math/MathNode.js';
|
|
7
|
-
import { convertToTexture } from '../utils/RTTNode.js';
|
|
1
|
+
import { TempNode, NodeUpdateType } from 'three/webgpu';
|
|
2
|
+
import { convertToTexture, nodeObject, Fn, uv, uniform, vec2, vec4, clamp } from 'three/tsl';
|
|
8
3
|
|
|
9
4
|
class DepthOfFieldNode extends TempNode {
|
|
10
5
|
|
|
@@ -16,7 +11,7 @@ class DepthOfFieldNode extends TempNode {
|
|
|
16
11
|
|
|
17
12
|
constructor( textureNode, viewZNode, focusNode, apertureNode, maxblurNode ) {
|
|
18
13
|
|
|
19
|
-
super();
|
|
14
|
+
super( 'vec4' );
|
|
20
15
|
|
|
21
16
|
this.textureNode = textureNode;
|
|
22
17
|
this.viewZNode = viewZNode;
|
|
@@ -27,7 +22,7 @@ class DepthOfFieldNode extends TempNode {
|
|
|
27
22
|
|
|
28
23
|
this._aspect = uniform( 0 );
|
|
29
24
|
|
|
30
|
-
this.updateBeforeType = NodeUpdateType.
|
|
25
|
+
this.updateBeforeType = NodeUpdateType.FRAME;
|
|
31
26
|
|
|
32
27
|
}
|
|
33
28
|
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import TempNode from '
|
|
2
|
-
import { nodeObject, Fn, vec2, vec3, vec4 } from '
|
|
3
|
-
import { uniform } from '../core/UniformNode.js';
|
|
4
|
-
import { uv } from '../accessors/UV.js';
|
|
5
|
-
import { sin, cos } from '../math/MathNode.js';
|
|
6
|
-
import { add } from '../math/OperatorNode.js';
|
|
7
|
-
import { screenSize } from './ScreenNode.js';
|
|
8
|
-
|
|
9
|
-
import { Vector2 } from '../../math/Vector2.js';
|
|
1
|
+
import { Vector2, TempNode } from 'three/webgpu';
|
|
2
|
+
import { nodeObject, Fn, uv, uniform, vec2, vec3, sin, cos, add, vec4, screenSize } from 'three/tsl';
|
|
10
3
|
|
|
11
4
|
class DotScreenNode extends TempNode {
|
|
12
5
|
|