@plastic-software/three 0.178.0 → 0.180.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 +950 -230
- package/build/three.core.js +754 -138
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +197 -96
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +99 -25
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +4586 -1499
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +4544 -1499
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +2 -3
- package/examples/jsm/capabilities/WebGPU.js +1 -1
- package/examples/jsm/controls/ArcballControls.js +7 -7
- package/examples/jsm/controls/DragControls.js +6 -56
- package/examples/jsm/controls/FirstPersonControls.js +2 -2
- package/examples/jsm/controls/PointerLockControls.js +0 -8
- package/examples/jsm/csm/CSMShadowNode.js +4 -4
- package/examples/jsm/environments/RoomEnvironment.js +8 -3
- package/examples/jsm/exporters/GLTFExporter.js +30 -22
- package/examples/jsm/exporters/KTX2Exporter.js +4 -2
- package/examples/jsm/exporters/PLYExporter.js +1 -1
- 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/ktx-parse.module.js +1 -1
- package/examples/jsm/libs/meshopt_decoder.module.js +75 -58
- package/examples/jsm/lights/LightProbeGenerator.js +14 -3
- package/examples/jsm/lines/Line2.js +3 -3
- package/examples/jsm/lines/LineGeometry.js +1 -1
- package/examples/jsm/lines/LineSegments2.js +2 -2
- package/examples/jsm/lines/Wireframe.js +2 -2
- package/examples/jsm/lines/WireframeGeometry2.js +1 -1
- package/examples/jsm/lines/webgpu/LineSegments2.js +1 -1
- package/examples/jsm/lines/webgpu/Wireframe.js +1 -1
- package/examples/jsm/loaders/ColladaLoader.js +1 -1
- package/examples/jsm/loaders/EXRLoader.js +210 -22
- package/examples/jsm/loaders/FBXLoader.js +1 -1
- package/examples/jsm/loaders/GLTFLoader.js +9 -5
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +5 -5
- package/examples/jsm/loaders/HDRLoader.js +486 -0
- package/examples/jsm/loaders/KTX2Loader.js +112 -32
- package/examples/jsm/loaders/MaterialXLoader.js +212 -30
- package/examples/jsm/loaders/RGBELoader.js +7 -473
- 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/UltraHDRLoader.js +1 -1
- package/examples/jsm/loaders/lwo/IFFParser.js +1 -1
- package/examples/jsm/loaders/usd/USDAParser.js +741 -0
- package/examples/jsm/loaders/usd/USDCParser.js +17 -0
- package/examples/jsm/materials/WoodNodeMaterial.js +533 -0
- package/examples/jsm/math/ColorSpaces.js +19 -1
- package/examples/jsm/math/ConvexHull.js +2 -2
- package/examples/jsm/math/Lut.js +2 -2
- package/examples/jsm/misc/MD2CharacterComplex.js +1 -1
- package/examples/jsm/misc/ProgressiveLightMap.js +1 -1
- package/examples/jsm/misc/Volume.js +1 -1
- 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/postprocessing/SSRPass.js +37 -8
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +11 -2
- package/examples/jsm/transpiler/GLSLDecoder.js +23 -20
- package/examples/jsm/transpiler/TSLEncoder.js +2 -10
- package/examples/jsm/transpiler/WGSLEncoder.js +24 -0
- package/examples/jsm/tsl/display/AnamorphicNode.js +27 -4
- package/examples/jsm/tsl/display/BloomNode.js +7 -6
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +2 -1
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +439 -90
- package/examples/jsm/tsl/display/GTAONode.js +8 -0
- package/examples/jsm/tsl/display/GaussianBlurNode.js +51 -41
- package/examples/jsm/tsl/display/OutlineNode.js +2 -2
- package/examples/jsm/tsl/display/SSRNode.js +180 -65
- package/examples/jsm/tsl/display/{TRAAPassNode.js → TRAANode.js} +181 -172
- package/examples/jsm/tsl/display/boxBlur.js +64 -0
- package/examples/jsm/tsl/display/hashBlur.js +15 -18
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +1 -1
- package/examples/jsm/utils/BufferGeometryUtils.js +1 -1
- package/examples/jsm/utils/ShadowMapViewerGPU.js +12 -5
- package/examples/jsm/webxr/OculusHandModel.js +1 -1
- package/package.json +1 -1
- package/src/Three.Core.js +2 -0
- package/src/Three.TSL.js +98 -24
- package/src/animation/AnimationClip.js +17 -2
- 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 +11 -3
- package/src/core/BufferGeometry.js +2 -2
- package/{examples/jsm/misc → src/core}/Timer.js +4 -42
- package/src/extras/PMREMGenerator.js +11 -0
- package/src/extras/TextureUtils.js +2 -1
- package/src/extras/lib/earcut.js +1 -1
- 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/lights/webgpu/ProjectorLight.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/Material.js +12 -0
- package/src/materials/MeshBasicMaterial.js +1 -1
- package/src/materials/MeshDistanceMaterial.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 +86 -28
- package/src/materials/nodes/SpriteNodeMaterial.js +3 -15
- package/src/materials/nodes/manager/NodeMaterialObserver.js +87 -2
- package/src/math/ColorManagement.js +7 -1
- 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 +4 -0
- package/src/nodes/TSL.js +4 -0
- package/src/nodes/accessors/BufferNode.js +1 -1
- package/src/nodes/accessors/Camera.js +142 -16
- package/src/nodes/accessors/ClippingNode.js +6 -5
- package/src/nodes/accessors/CubeTextureNode.js +2 -2
- package/src/nodes/accessors/InstanceNode.js +3 -1
- package/src/nodes/accessors/Normal.js +11 -11
- package/src/nodes/accessors/Object3DNode.js +1 -1
- package/src/nodes/accessors/ReferenceBaseNode.js +1 -1
- package/src/nodes/accessors/ReferenceNode.js +19 -4
- package/src/nodes/accessors/SceneNode.js +1 -1
- package/src/nodes/accessors/StorageTextureNode.js +1 -1
- package/src/nodes/accessors/Texture3DNode.js +13 -0
- package/src/nodes/accessors/TextureNode.js +83 -19
- package/src/nodes/code/FunctionCallNode.js +19 -0
- package/src/nodes/code/FunctionNode.js +23 -0
- package/src/nodes/core/ArrayNode.js +12 -0
- package/src/nodes/core/AssignNode.js +6 -2
- package/src/nodes/core/ContextNode.js +44 -1
- package/src/nodes/core/Node.js +30 -22
- package/src/nodes/core/NodeBuilder.js +71 -32
- package/src/nodes/core/NodeFrame.js +1 -1
- package/src/nodes/core/NodeUniform.js +1 -1
- package/src/nodes/core/NodeUtils.js +5 -3
- package/src/nodes/core/StackNode.js +71 -4
- package/src/nodes/core/StructNode.js +5 -5
- package/src/nodes/core/StructTypeNode.js +1 -0
- package/src/nodes/core/SubBuildNode.js +2 -2
- package/src/nodes/core/UniformNode.js +79 -14
- package/src/nodes/core/VarNode.js +83 -15
- package/src/nodes/display/FrontFacingNode.js +4 -8
- package/src/nodes/display/PassNode.js +148 -2
- package/src/nodes/display/ScreenNode.js +42 -13
- package/src/nodes/display/ViewportDepthTextureNode.js +16 -4
- package/src/nodes/display/ViewportSharedTextureNode.js +12 -0
- package/src/nodes/display/ViewportTextureNode.js +94 -4
- 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/SubgroupFunctionNode.js +430 -0
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +28 -3
- package/src/nodes/lighting/LightsNode.js +1 -1
- 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/BitcastNode.js +156 -0
- package/src/nodes/math/ConditionalNode.js +19 -3
- package/src/nodes/math/MathNode.js +72 -60
- package/src/nodes/math/OperatorNode.js +26 -25
- package/src/nodes/tsl/TSLCore.js +477 -142
- package/src/nodes/utils/DebugNode.js +1 -1
- package/src/nodes/utils/EventNode.js +83 -0
- package/src/nodes/utils/JoinNode.js +3 -1
- package/src/nodes/utils/MemberNode.js +58 -7
- package/src/nodes/utils/RTTNode.js +10 -1
- package/src/nodes/utils/ReflectorNode.js +51 -7
- package/src/nodes/utils/SampleNode.js +12 -2
- package/src/nodes/utils/SplitNode.js +11 -0
- package/src/nodes/utils/Timer.js +0 -47
- package/src/objects/BatchedMesh.js +6 -4
- package/src/objects/LOD.js +1 -1
- package/src/objects/Sprite.js +2 -2
- package/src/renderers/WebGLRenderer.js +21 -31
- package/src/renderers/common/Attributes.js +1 -1
- package/src/renderers/common/Backend.js +19 -1
- package/src/renderers/common/Bindings.js +21 -18
- package/src/renderers/common/ChainMap.js +1 -1
- package/src/renderers/common/Color4.js +2 -2
- package/src/renderers/common/DataMap.js +1 -1
- package/src/renderers/common/Pipelines.js +1 -1
- package/src/renderers/common/PostProcessing.js +60 -5
- package/src/renderers/common/RenderContext.js +2 -2
- package/src/renderers/common/RenderObject.js +14 -2
- package/src/renderers/common/Renderer.js +55 -32
- package/src/renderers/common/SampledTexture.js +4 -72
- package/src/renderers/common/Sampler.js +91 -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 +52 -14
- package/src/renderers/common/TimestampQueryPool.js +3 -3
- package/src/renderers/common/XRManager.js +51 -17
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/NodeLibrary.js +5 -5
- package/src/renderers/common/nodes/NodeSampledTexture.js +0 -12
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +21 -11
- 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 +24 -18
- package/src/renderers/webgl/WebGLPrograms.js +4 -4
- package/src/renderers/webgl/WebGLShadowMap.js +11 -1
- package/src/renderers/webgl/WebGLTextures.js +20 -7
- package/src/renderers/webgl/WebGLUtils.js +3 -2
- package/src/renderers/webgl-fallback/WebGLBackend.js +207 -146
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +112 -19
- package/src/renderers/webgl-fallback/utils/WebGLState.js +1 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +52 -3
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +9 -10
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +3 -2
- package/src/renderers/webgpu/WebGPUBackend.js +87 -44
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +169 -99
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +35 -31
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -2
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +10 -19
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +120 -84
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +3 -3
- package/src/renderers/webgpu/utils/WebGPUUtils.js +2 -17
- package/src/renderers/webxr/WebXRDepthSensing.js +6 -10
- package/src/renderers/webxr/WebXRManager.js +86 -11
- package/src/textures/ExternalTexture.js +56 -0
- package/src/textures/FramebufferTexture.js +2 -2
- package/src/textures/Source.js +12 -2
- package/src/textures/VideoTexture.js +27 -2
- package/examples/jsm/loaders/RGBMLoader.js +0 -1148
|
@@ -15,7 +15,16 @@ function getShape( geometry ) {
|
|
|
15
15
|
|
|
16
16
|
// TODO change type to is*
|
|
17
17
|
|
|
18
|
-
if ( geometry.type === '
|
|
18
|
+
if ( geometry.type === 'RoundedBoxGeometry' ) {
|
|
19
|
+
|
|
20
|
+
const sx = parameters.width !== undefined ? parameters.width / 2 : 0.5;
|
|
21
|
+
const sy = parameters.height !== undefined ? parameters.height / 2 : 0.5;
|
|
22
|
+
const sz = parameters.depth !== undefined ? parameters.depth / 2 : 0.5;
|
|
23
|
+
const radius = parameters.radius !== undefined ? parameters.radius : 0.1;
|
|
24
|
+
|
|
25
|
+
return RAPIER.ColliderDesc.roundCuboid( sx - radius, sy - radius, sz - radius, radius );
|
|
26
|
+
|
|
27
|
+
} else if ( geometry.type === 'BoxGeometry' ) {
|
|
19
28
|
|
|
20
29
|
const sx = parameters.width !== undefined ? parameters.width / 2 : 0.5;
|
|
21
30
|
const sy = parameters.height !== undefined ? parameters.height / 2 : 0.5;
|
|
@@ -273,17 +282,17 @@ async function RapierPhysics() {
|
|
|
273
282
|
function addHeightfield( mesh, width, depth, heights, scale ) {
|
|
274
283
|
|
|
275
284
|
const shape = RAPIER.ColliderDesc.heightfield( width, depth, heights, scale );
|
|
276
|
-
|
|
285
|
+
|
|
277
286
|
const bodyDesc = RAPIER.RigidBodyDesc.fixed();
|
|
278
287
|
bodyDesc.setTranslation( mesh.position.x, mesh.position.y, mesh.position.z );
|
|
279
288
|
bodyDesc.setRotation( mesh.quaternion );
|
|
280
|
-
|
|
289
|
+
|
|
281
290
|
const body = world.createRigidBody( bodyDesc );
|
|
282
291
|
world.createCollider( shape, body );
|
|
283
|
-
|
|
292
|
+
|
|
284
293
|
if ( ! mesh.userData.physics ) mesh.userData.physics = {};
|
|
285
294
|
mesh.userData.physics.body = body;
|
|
286
|
-
|
|
295
|
+
|
|
287
296
|
return body;
|
|
288
297
|
|
|
289
298
|
}
|
|
@@ -103,7 +103,7 @@ class GTAOPass extends Pass {
|
|
|
103
103
|
*/
|
|
104
104
|
this.output = 0;
|
|
105
105
|
this._renderGBuffer = true;
|
|
106
|
-
this._visibilityCache =
|
|
106
|
+
this._visibilityCache = [];
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
109
|
* The AO blend intensity.
|
|
@@ -655,9 +655,12 @@ class GTAOPass extends Pass {
|
|
|
655
655
|
|
|
656
656
|
scene.traverse( function ( object ) {
|
|
657
657
|
|
|
658
|
-
|
|
658
|
+
if ( ( object.isPoints || object.isLine || object.isLine2 ) && object.visible ) {
|
|
659
659
|
|
|
660
|
-
|
|
660
|
+
object.visible = false;
|
|
661
|
+
cache.push( object );
|
|
662
|
+
|
|
663
|
+
}
|
|
661
664
|
|
|
662
665
|
} );
|
|
663
666
|
|
|
@@ -665,17 +668,15 @@ class GTAOPass extends Pass {
|
|
|
665
668
|
|
|
666
669
|
_restoreVisibility() {
|
|
667
670
|
|
|
668
|
-
const scene = this.scene;
|
|
669
671
|
const cache = this._visibilityCache;
|
|
670
672
|
|
|
671
|
-
|
|
673
|
+
for ( let i = 0; i < cache.length; i ++ ) {
|
|
672
674
|
|
|
673
|
-
|
|
674
|
-
object.visible = visible;
|
|
675
|
+
cache[ i ].visible = true;
|
|
675
676
|
|
|
676
|
-
}
|
|
677
|
+
}
|
|
677
678
|
|
|
678
|
-
cache.
|
|
679
|
+
cache.length = 0;
|
|
679
680
|
|
|
680
681
|
}
|
|
681
682
|
|
|
@@ -494,37 +494,37 @@ class OutlinePass extends Pass {
|
|
|
494
494
|
|
|
495
495
|
function VisibilityChangeCallBack( object ) {
|
|
496
496
|
|
|
497
|
-
if ( object.
|
|
497
|
+
if ( object.isPoints || object.isLine || object.isLine2 ) {
|
|
498
498
|
|
|
499
|
-
//
|
|
499
|
+
// the visibility of points and lines is always set to false in order to
|
|
500
|
+
// not affect the outline computation
|
|
500
501
|
|
|
501
|
-
if (
|
|
502
|
+
if ( bVisible === true ) {
|
|
502
503
|
|
|
503
|
-
|
|
504
|
+
object.visible = visibilityCache.get( object ); // restore
|
|
504
505
|
|
|
505
|
-
|
|
506
|
+
} else {
|
|
506
507
|
|
|
507
|
-
|
|
508
|
+
visibilityCache.set( object, object.visible );
|
|
509
|
+
object.visible = bVisible;
|
|
508
510
|
|
|
509
|
-
|
|
511
|
+
}
|
|
510
512
|
|
|
511
|
-
|
|
513
|
+
} else if ( object.isMesh || object.isSprite ) {
|
|
512
514
|
|
|
513
|
-
|
|
515
|
+
// only meshes and sprites are supported by OutlinePass
|
|
514
516
|
|
|
515
|
-
|
|
517
|
+
if ( ! selectionCache.has( object ) ) {
|
|
516
518
|
|
|
517
|
-
|
|
518
|
-
// not affect the outline computation
|
|
519
|
+
const visibility = object.visible;
|
|
519
520
|
|
|
520
|
-
|
|
521
|
+
if ( bVisible === false || visibilityCache.get( object ) === true ) {
|
|
521
522
|
|
|
522
|
-
|
|
523
|
+
object.visible = bVisible;
|
|
523
524
|
|
|
524
|
-
|
|
525
|
+
}
|
|
525
526
|
|
|
526
|
-
visibilityCache.set( object,
|
|
527
|
-
object.visible = bVisible;
|
|
527
|
+
visibilityCache.set( object, visibility );
|
|
528
528
|
|
|
529
529
|
}
|
|
530
530
|
|
|
@@ -139,7 +139,7 @@ class SSAOPass extends Pass {
|
|
|
139
139
|
*/
|
|
140
140
|
this.maxDistance = 0.1;
|
|
141
141
|
|
|
142
|
-
this._visibilityCache =
|
|
142
|
+
this._visibilityCache = [];
|
|
143
143
|
|
|
144
144
|
//
|
|
145
145
|
|
|
@@ -489,9 +489,12 @@ class SSAOPass extends Pass {
|
|
|
489
489
|
|
|
490
490
|
scene.traverse( function ( object ) {
|
|
491
491
|
|
|
492
|
-
|
|
492
|
+
if ( ( object.isPoints || object.isLine || object.isLine2 ) && object.visible ) {
|
|
493
493
|
|
|
494
|
-
|
|
494
|
+
object.visible = false;
|
|
495
|
+
cache.push( object );
|
|
496
|
+
|
|
497
|
+
}
|
|
495
498
|
|
|
496
499
|
} );
|
|
497
500
|
|
|
@@ -499,17 +502,15 @@ class SSAOPass extends Pass {
|
|
|
499
502
|
|
|
500
503
|
_restoreVisibility() {
|
|
501
504
|
|
|
502
|
-
const scene = this.scene;
|
|
503
505
|
const cache = this._visibilityCache;
|
|
504
506
|
|
|
505
|
-
|
|
507
|
+
for ( let i = 0; i < cache.length; i ++ ) {
|
|
506
508
|
|
|
507
|
-
|
|
508
|
-
object.visible = visible;
|
|
509
|
+
cache[ i ].visible = true;
|
|
509
510
|
|
|
510
|
-
}
|
|
511
|
+
}
|
|
511
512
|
|
|
512
|
-
cache.
|
|
513
|
+
cache.length = 0;
|
|
513
514
|
|
|
514
515
|
}
|
|
515
516
|
|
|
@@ -137,6 +137,8 @@ class SSRPass extends Pass {
|
|
|
137
137
|
|
|
138
138
|
this._selects = selects;
|
|
139
139
|
|
|
140
|
+
this._resolutionScale = 1;
|
|
141
|
+
|
|
140
142
|
/**
|
|
141
143
|
* Whether the pass is selective or not.
|
|
142
144
|
*
|
|
@@ -457,6 +459,29 @@ class SSRPass extends Pass {
|
|
|
457
459
|
|
|
458
460
|
}
|
|
459
461
|
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* The resolution scale. Valid values are in the range
|
|
465
|
+
* `[0,1]`. `1` means best quality but also results in
|
|
466
|
+
* more computational overhead. Setting to `0.5` means
|
|
467
|
+
* the effect is computed in half-resolution.
|
|
468
|
+
*
|
|
469
|
+
* @type {number}
|
|
470
|
+
* @default 1
|
|
471
|
+
*/
|
|
472
|
+
get resolutionScale() {
|
|
473
|
+
|
|
474
|
+
return this._resolutionScale;
|
|
475
|
+
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
set resolutionScale( value ) {
|
|
479
|
+
|
|
480
|
+
this._resolutionScale = value;
|
|
481
|
+
this.setSize( this.width, this.height ); // force a resize when resolution scaling changes
|
|
482
|
+
|
|
483
|
+
}
|
|
484
|
+
|
|
460
485
|
/**
|
|
461
486
|
* Frees the GPU-related resources allocated by this instance. Call this
|
|
462
487
|
* method whenever the pass is no longer used in your app.
|
|
@@ -661,23 +686,27 @@ class SSRPass extends Pass {
|
|
|
661
686
|
this.width = width;
|
|
662
687
|
this.height = height;
|
|
663
688
|
|
|
664
|
-
|
|
689
|
+
const effectiveWidth = Math.round( this.resolutionScale * width );
|
|
690
|
+
const effectiveHeight = Math.round( this.resolutionScale * height );
|
|
691
|
+
|
|
692
|
+
this.ssrMaterial.defines.MAX_STEP = Math.sqrt( effectiveWidth * effectiveWidth + effectiveHeight * effectiveHeight );
|
|
665
693
|
this.ssrMaterial.needsUpdate = true;
|
|
694
|
+
|
|
666
695
|
this.beautyRenderTarget.setSize( width, height );
|
|
667
|
-
this.prevRenderTarget.setSize( width, height );
|
|
668
|
-
this.ssrRenderTarget.setSize( width, height );
|
|
669
696
|
this.normalRenderTarget.setSize( width, height );
|
|
670
697
|
this.metalnessRenderTarget.setSize( width, height );
|
|
671
|
-
this.
|
|
672
|
-
this.
|
|
698
|
+
this.ssrRenderTarget.setSize( effectiveWidth, effectiveHeight );
|
|
699
|
+
this.prevRenderTarget.setSize( effectiveWidth, effectiveHeight );
|
|
700
|
+
this.blurRenderTarget.setSize( effectiveWidth, effectiveHeight );
|
|
701
|
+
this.blurRenderTarget2.setSize( effectiveWidth, effectiveHeight );
|
|
673
702
|
// this.blurRenderTarget3.setSize(width, height);
|
|
674
703
|
|
|
675
|
-
this.ssrMaterial.uniforms[ 'resolution' ].value.set(
|
|
704
|
+
this.ssrMaterial.uniforms[ 'resolution' ].value.set( effectiveWidth, effectiveHeight );
|
|
676
705
|
this.ssrMaterial.uniforms[ 'cameraProjectionMatrix' ].value.copy( this.camera.projectionMatrix );
|
|
677
706
|
this.ssrMaterial.uniforms[ 'cameraInverseProjectionMatrix' ].value.copy( this.camera.projectionMatrixInverse );
|
|
678
707
|
|
|
679
|
-
this.blurMaterial.uniforms[ 'resolution' ].value.set(
|
|
680
|
-
this.blurMaterial2.uniforms[ 'resolution' ].value.set(
|
|
708
|
+
this.blurMaterial.uniforms[ 'resolution' ].value.set( effectiveWidth, effectiveHeight );
|
|
709
|
+
this.blurMaterial2.uniforms[ 'resolution' ].value.set( effectiveWidth, effectiveHeight );
|
|
681
710
|
|
|
682
711
|
}
|
|
683
712
|
|
|
@@ -43,8 +43,17 @@ const UnpackDepthRGBAShader = {
|
|
|
43
43
|
|
|
44
44
|
void main() {
|
|
45
45
|
|
|
46
|
-
float depth =
|
|
47
|
-
|
|
46
|
+
float depth = unpackRGBAToDepth( texture2D( tDiffuse, vUv ) );
|
|
47
|
+
|
|
48
|
+
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
49
|
+
|
|
50
|
+
gl_FragColor = vec4( vec3( depth ), opacity );
|
|
51
|
+
|
|
52
|
+
#else
|
|
53
|
+
|
|
54
|
+
gl_FragColor = vec4( vec3( 1.0 - depth ), opacity );
|
|
55
|
+
|
|
56
|
+
#endif
|
|
48
57
|
|
|
49
58
|
}`
|
|
50
59
|
|
|
@@ -11,22 +11,21 @@ const arithmeticOperators = [
|
|
|
11
11
|
];
|
|
12
12
|
|
|
13
13
|
const precedenceOperators = [
|
|
14
|
-
'
|
|
15
|
-
'
|
|
16
|
-
'
|
|
17
|
-
|
|
18
|
-
'
|
|
19
|
-
'
|
|
20
|
-
'
|
|
21
|
-
'
|
|
22
|
-
'
|
|
23
|
-
'
|
|
24
|
-
'
|
|
25
|
-
'
|
|
26
|
-
'
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
].reverse();
|
|
14
|
+
[ ',' ],
|
|
15
|
+
[ '=', '+=', '-=', '*=', '/=', '%=', '^=', '&=', '|=', '<<=', '>>=' ],
|
|
16
|
+
[ '?' ],
|
|
17
|
+
[ '||' ],
|
|
18
|
+
[ '^^' ],
|
|
19
|
+
[ '&&' ],
|
|
20
|
+
[ '|' ],
|
|
21
|
+
[ '^' ],
|
|
22
|
+
[ '&' ],
|
|
23
|
+
[ '==', '!=' ],
|
|
24
|
+
[ '<', '>', '<=', '>=' ],
|
|
25
|
+
[ '<<', '>>' ],
|
|
26
|
+
[ '+', '-' ],
|
|
27
|
+
[ '*', '/', '%' ]
|
|
28
|
+
];
|
|
30
29
|
|
|
31
30
|
const associativityRightToLeft = [
|
|
32
31
|
'=',
|
|
@@ -334,7 +333,7 @@ class GLSLDecoder {
|
|
|
334
333
|
|
|
335
334
|
let groupIndex = 0;
|
|
336
335
|
|
|
337
|
-
for ( const
|
|
336
|
+
for ( const operators of precedenceOperators ) {
|
|
338
337
|
|
|
339
338
|
const parseToken = ( i, inverse = false ) => {
|
|
340
339
|
|
|
@@ -351,7 +350,9 @@ class GLSLDecoder {
|
|
|
351
350
|
|
|
352
351
|
}
|
|
353
352
|
|
|
354
|
-
if ( groupIndex === 0 && token.str
|
|
353
|
+
if ( groupIndex === 0 && operators.includes( token.str ) ) {
|
|
354
|
+
|
|
355
|
+
const operator = token.str;
|
|
355
356
|
|
|
356
357
|
if ( operator === '?' ) {
|
|
357
358
|
|
|
@@ -396,7 +397,9 @@ class GLSLDecoder {
|
|
|
396
397
|
|
|
397
398
|
};
|
|
398
399
|
|
|
399
|
-
|
|
400
|
+
const isRightAssociative = operators.some( op => associativityRightToLeft.includes( op ) );
|
|
401
|
+
|
|
402
|
+
if ( isRightAssociative ) {
|
|
400
403
|
|
|
401
404
|
for ( let i = 0; i < tokens.length; i ++ ) {
|
|
402
405
|
|
|
@@ -861,7 +864,7 @@ class GLSLDecoder {
|
|
|
861
864
|
|
|
862
865
|
const switchDeterminantTokens = this.readTokensUntil( ')' );
|
|
863
866
|
|
|
864
|
-
// Parse
|
|
867
|
+
// Parse expression between parentheses. Index 1: char after '('. Index -1: char before ')'
|
|
865
868
|
const discriminant = this.parseExpressionFromTokens( switchDeterminantTokens.slice( 1, - 1 ) );
|
|
866
869
|
|
|
867
870
|
// Validate curly braces
|
|
@@ -340,7 +340,7 @@ class TSLEncoder {
|
|
|
340
340
|
|
|
341
341
|
if ( node.hasAssignment ) {
|
|
342
342
|
|
|
343
|
-
if ( node.after === false ) {
|
|
343
|
+
if ( node.after === false && ( node.type === '++' || node.type === '--' ) ) {
|
|
344
344
|
|
|
345
345
|
type += 'Before';
|
|
346
346
|
|
|
@@ -665,15 +665,7 @@ ${ this.tab }} )`;
|
|
|
665
665
|
|
|
666
666
|
}
|
|
667
667
|
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
varStr += ' = ' + valueStr + '.toVar()';
|
|
671
|
-
|
|
672
|
-
} else {
|
|
673
|
-
|
|
674
|
-
varStr += ' = ' + valueStr;
|
|
675
|
-
|
|
676
|
-
}
|
|
668
|
+
varStr += ' = ' + valueStr;
|
|
677
669
|
|
|
678
670
|
} else {
|
|
679
671
|
|
|
@@ -80,6 +80,10 @@ const wgslLib = {
|
|
|
80
80
|
'textureLod': 'textureSampleLevel',
|
|
81
81
|
'texelFetch': 'textureLoad',
|
|
82
82
|
'textureGrad': 'textureSampleGrad',
|
|
83
|
+
'floatBitsToInt': 'bitcast<i32>',
|
|
84
|
+
'floatBitsToUint': 'bitcast<u32>',
|
|
85
|
+
'intBitsToFloat': 'bitcast<f32>',
|
|
86
|
+
'uintBitsToFloat': 'bitcast<f32>',
|
|
83
87
|
};
|
|
84
88
|
|
|
85
89
|
class WGSLEncoder {
|
|
@@ -170,6 +174,26 @@ class WGSLEncoder {
|
|
|
170
174
|
|
|
171
175
|
code = `${ modFnName }( ${ snippets.join( ', ' ) } )`;
|
|
172
176
|
|
|
177
|
+
} else if ( fnName.startsWith( 'bitcast' ) ) {
|
|
178
|
+
|
|
179
|
+
const params = node.params.map( p => this.emitExpression( p ) ).join( ',' );
|
|
180
|
+
const types = node.params.map( p => p.getType() );
|
|
181
|
+
|
|
182
|
+
if ( /.*vec[234]/.test( types[ 0 ] ) ) {
|
|
183
|
+
|
|
184
|
+
const conversionType = fnName.substring( 8, fnName.length - 1 );
|
|
185
|
+
const vectorType = types[ 0 ].substring( - 1 );
|
|
186
|
+
|
|
187
|
+
code = `bitcast<${ vectorType }<${ conversionType }>>`;
|
|
188
|
+
|
|
189
|
+
} else {
|
|
190
|
+
|
|
191
|
+
code = fnName;
|
|
192
|
+
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
code += `( ${ params } )`;
|
|
196
|
+
|
|
173
197
|
} else if ( fnName.startsWith( 'texture' ) ) {
|
|
174
198
|
|
|
175
199
|
// Handle texture functions separately due to sampler handling
|
|
@@ -69,9 +69,9 @@ class AnamorphicNode extends TempNode {
|
|
|
69
69
|
/**
|
|
70
70
|
* The resolution scale.
|
|
71
71
|
*
|
|
72
|
-
* @type {
|
|
72
|
+
* @type {float}
|
|
73
73
|
*/
|
|
74
|
-
this.
|
|
74
|
+
this.resolutionScale = 1;
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
77
|
* The internal render target of the effect.
|
|
@@ -130,8 +130,8 @@ class AnamorphicNode extends TempNode {
|
|
|
130
130
|
|
|
131
131
|
this._invSize.value.set( 1 / width, 1 / height );
|
|
132
132
|
|
|
133
|
-
width = Math.max( Math.round( width * this.
|
|
134
|
-
height = Math.max( Math.round( height * this.
|
|
133
|
+
width = Math.max( Math.round( width * this.resolutionScale ), 1 );
|
|
134
|
+
height = Math.max( Math.round( height * this.resolutionScale ), 1 );
|
|
135
135
|
|
|
136
136
|
this._renderTarget.setSize( width, height );
|
|
137
137
|
|
|
@@ -240,6 +240,29 @@ class AnamorphicNode extends TempNode {
|
|
|
240
240
|
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
+
/**
|
|
244
|
+
* The resolution scale.
|
|
245
|
+
*
|
|
246
|
+
* @deprecated
|
|
247
|
+
* @type {Vector2}
|
|
248
|
+
* @default {(1,1)}
|
|
249
|
+
*/
|
|
250
|
+
get resolution() {
|
|
251
|
+
|
|
252
|
+
console.warn( 'THREE.AnamorphicNode: The "resolution" property has been renamed to "resolutionScale" and is now of type `number`.' ); // @deprecated r180
|
|
253
|
+
|
|
254
|
+
return new Vector2( this.resolutionScale, this.resolutionScale );
|
|
255
|
+
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
set resolution( value ) {
|
|
259
|
+
|
|
260
|
+
console.warn( 'THREE.AnamorphicNode: The "resolution" property has been renamed to "resolutionScale" and is now of type `number`.' ); // @deprecated r180
|
|
261
|
+
|
|
262
|
+
this.resolutionScale = value.x;
|
|
263
|
+
|
|
264
|
+
}
|
|
265
|
+
|
|
243
266
|
}
|
|
244
267
|
|
|
245
268
|
/**
|
|
@@ -364,7 +364,9 @@ class BloomNode extends TempNode {
|
|
|
364
364
|
|
|
365
365
|
// gaussian blur materials
|
|
366
366
|
|
|
367
|
-
|
|
367
|
+
// These sizes have been changed to account for the altered coefficients-calculation to avoid blockiness,
|
|
368
|
+
// while retaining the same blur-strength. For details see https://github.com/mrdoob/three.js/pull/31528
|
|
369
|
+
const kernelSizeArray = [ 6, 10, 14, 18, 22 ];
|
|
368
370
|
|
|
369
371
|
for ( let i = 0; i < this._nMips; i ++ ) {
|
|
370
372
|
|
|
@@ -449,10 +451,11 @@ class BloomNode extends TempNode {
|
|
|
449
451
|
_getSeparableBlurMaterial( builder, kernelRadius ) {
|
|
450
452
|
|
|
451
453
|
const coefficients = [];
|
|
454
|
+
const sigma = kernelRadius / 3;
|
|
452
455
|
|
|
453
456
|
for ( let i = 0; i < kernelRadius; i ++ ) {
|
|
454
457
|
|
|
455
|
-
coefficients.push( 0.39894 * Math.exp( - 0.5 * i * i / (
|
|
458
|
+
coefficients.push( 0.39894 * Math.exp( - 0.5 * i * i / ( sigma * sigma ) ) / sigma );
|
|
456
459
|
|
|
457
460
|
}
|
|
458
461
|
|
|
@@ -468,8 +471,7 @@ class BloomNode extends TempNode {
|
|
|
468
471
|
|
|
469
472
|
const separableBlurPass = Fn( () => {
|
|
470
473
|
|
|
471
|
-
const
|
|
472
|
-
const diffuseSum = sampleTexel( uvNode ).rgb.mul( weightSum ).toVar();
|
|
474
|
+
const diffuseSum = sampleTexel( uvNode ).rgb.mul( gaussianCoefficients.element( 0 ) ).toVar();
|
|
473
475
|
|
|
474
476
|
Loop( { start: int( 1 ), end: int( kernelRadius ), type: 'int', condition: '<' }, ( { i } ) => {
|
|
475
477
|
|
|
@@ -479,11 +481,10 @@ class BloomNode extends TempNode {
|
|
|
479
481
|
const sample1 = sampleTexel( uvNode.add( uvOffset ) ).rgb;
|
|
480
482
|
const sample2 = sampleTexel( uvNode.sub( uvOffset ) ).rgb;
|
|
481
483
|
diffuseSum.addAssign( add( sample1, sample2 ).mul( w ) );
|
|
482
|
-
weightSum.addAssign( float( 2.0 ).mul( w ) );
|
|
483
484
|
|
|
484
485
|
} );
|
|
485
486
|
|
|
486
|
-
return vec4( diffuseSum
|
|
487
|
+
return vec4( diffuseSum, 1.0 );
|
|
487
488
|
|
|
488
489
|
} );
|
|
489
490
|
|
|
@@ -189,7 +189,7 @@ export default ChromaticAberrationNode;
|
|
|
189
189
|
* @function
|
|
190
190
|
* @param {Node<vec4>} node - The node that represents the input of the effect.
|
|
191
191
|
* @param {Node|number} [strength=1.0] - The strength of the chromatic aberration effect as a node or value.
|
|
192
|
-
* @param {Node|Vector2} [center=null] - The center point of the effect as a node or value. If null, uses screen center (0.5, 0.5).
|
|
192
|
+
* @param {?(Node|Vector2)} [center=null] - The center point of the effect as a node or value. If null, uses screen center (0.5, 0.5).
|
|
193
193
|
* @param {Node|number} [scale=1.1] - The scale factor for stepped scaling from center as a node or value.
|
|
194
194
|
* @returns {ChromaticAberrationNode}
|
|
195
195
|
*/
|
|
@@ -203,4 +203,5 @@ export const chromaticAberration = ( node, strength = 1.0, center = null, scale
|
|
|
203
203
|
nodeObject( scale )
|
|
204
204
|
)
|
|
205
205
|
);
|
|
206
|
+
|
|
206
207
|
};
|