super-three 0.177.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 +959 -231
- package/build/three.core.js +751 -170
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +210 -64
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +78 -29
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +3269 -1545
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +3093 -1545
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +1 -2
- package/examples/jsm/capabilities/WebGL.js +0 -27
- package/examples/jsm/capabilities/WebGPU.js +1 -1
- package/examples/jsm/controls/ArcballControls.js +1 -1
- package/examples/jsm/controls/TransformControls.js +61 -14
- 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/ColladaLoader.js +1 -1
- package/examples/jsm/loaders/EXRLoader.js +210 -22
- package/examples/jsm/loaders/FBXLoader.js +2 -2
- 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 +95 -16
- 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/AST.js +381 -30
- package/examples/jsm/transpiler/GLSLDecoder.js +226 -86
- package/examples/jsm/transpiler/Linker.js +327 -0
- package/examples/jsm/transpiler/TSLEncoder.js +197 -92
- package/examples/jsm/transpiler/Transpiler.js +17 -1
- package/examples/jsm/transpiler/TranspilerUtils.js +29 -0
- package/examples/jsm/transpiler/WGSLEncoder.js +788 -0
- package/examples/jsm/tsl/display/BloomNode.js +8 -7
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +206 -0
- package/examples/jsm/tsl/display/GaussianBlurNode.js +8 -10
- package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
- package/examples/jsm/tsl/display/{TRAAPassNode.js → TRAANode.js} +181 -172
- package/examples/jsm/tsl/display/hashBlur.js +3 -3
- 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 +77 -28
- package/src/Three.WebGPU.js +2 -0
- 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 +3 -3
- package/src/core/BufferAttribute.js +3 -3
- package/src/core/Clock.js +2 -8
- package/src/core/GLBufferAttribute.js +13 -1
- package/src/core/Object3D.js +1 -1
- package/{examples/jsm/misc → src/core}/Timer.js +4 -42
- package/src/extras/PMREMGenerator.js +11 -0
- package/src/extras/core/Path.js +22 -22
- 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 +27 -4
- package/src/loaders/ImageBitmapLoader.js +27 -4
- package/src/loaders/ImageLoader.js +55 -8
- 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/MeshBasicNodeMaterial.js +4 -3
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +1 -1
- package/src/materials/nodes/MeshNormalNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +2 -1
- package/src/materials/nodes/MeshSSSNodeMaterial.js +2 -2
- package/src/materials/nodes/NodeMaterial.js +28 -5
- package/src/materials/nodes/PointsNodeMaterial.js +5 -0
- package/src/materials/nodes/manager/NodeMaterialObserver.js +87 -2
- package/src/math/Frustum.js +25 -9
- package/src/math/FrustumArray.js +10 -5
- package/src/math/Line3.js +129 -2
- package/src/math/Matrix4.js +48 -27
- package/src/math/Quaternion.js +1 -1
- package/src/math/Spherical.js +2 -2
- package/src/nodes/Nodes.js +2 -3
- package/src/nodes/TSL.js +5 -3
- package/src/nodes/accessors/AccessorsUtils.js +7 -8
- package/src/nodes/accessors/Bitangent.js +31 -25
- package/src/nodes/accessors/Camera.js +12 -12
- package/src/nodes/accessors/Normal.js +95 -29
- package/src/nodes/accessors/Object3DNode.js +1 -1
- package/src/nodes/accessors/Position.js +7 -7
- package/src/nodes/accessors/ReferenceNode.js +18 -3
- package/src/nodes/accessors/ReflectVector.js +3 -3
- package/src/nodes/accessors/SceneNode.js +1 -1
- package/src/nodes/accessors/StorageTextureNode.js +1 -1
- package/src/nodes/accessors/Tangent.js +25 -17
- package/src/nodes/accessors/TangentUtils.js +46 -0
- package/src/nodes/accessors/TextureBicubic.js +21 -3
- package/src/nodes/accessors/TextureNode.js +12 -0
- package/src/nodes/accessors/UniformArrayNode.js +0 -16
- package/src/nodes/core/ArrayNode.js +12 -0
- package/src/nodes/core/AssignNode.js +3 -0
- package/src/nodes/core/CacheNode.js +0 -14
- package/src/nodes/core/ContextNode.js +20 -1
- package/src/nodes/core/Node.js +15 -3
- package/src/nodes/core/NodeBuilder.js +228 -92
- package/src/nodes/core/NodeUtils.js +4 -1
- package/src/nodes/core/StackNode.js +49 -29
- package/src/nodes/core/SubBuildNode.js +89 -0
- package/src/nodes/core/UniformNode.js +63 -5
- package/src/nodes/core/VarNode.js +91 -2
- package/src/nodes/core/VaryingNode.js +6 -4
- package/src/nodes/display/BlendModes.js +2 -2
- package/src/nodes/display/FrontFacingNode.js +34 -2
- package/src/nodes/display/NormalMapNode.js +19 -50
- package/src/nodes/display/PassNode.js +157 -9
- package/src/nodes/display/ScreenNode.js +0 -26
- package/src/nodes/display/ViewportTextureNode.js +67 -7
- package/src/nodes/functions/BSDF/BRDF_GGX.js +2 -6
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +4 -4
- package/src/nodes/functions/PhongLightingModel.js +3 -3
- package/src/nodes/functions/PhysicalLightingModel.js +16 -16
- package/src/nodes/functions/material/getGeometryRoughness.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/EnvironmentNode.js +5 -5
- package/src/nodes/lighting/LightsNode.js +4 -4
- package/src/nodes/lighting/ProjectorLightNode.js +19 -6
- package/src/nodes/lighting/ShadowFilterNode.js +1 -1
- package/src/nodes/lighting/ShadowNode.js +2 -2
- 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 -20
- package/src/nodes/math/MathNode.js +90 -55
- package/src/nodes/math/OperatorNode.js +22 -39
- package/src/nodes/tsl/TSLBase.js +1 -0
- package/src/nodes/tsl/TSLCore.js +114 -55
- package/src/nodes/utils/DebugNode.js +1 -1
- package/src/nodes/utils/EquirectUV.js +27 -0
- package/src/nodes/utils/EventNode.js +83 -0
- package/src/nodes/utils/LoopNode.js +0 -17
- package/src/nodes/utils/MatcapUV.js +22 -0
- package/src/nodes/utils/RTTNode.js +22 -5
- package/src/nodes/utils/ReflectorNode.js +11 -4
- package/src/nodes/utils/SampleNode.js +81 -0
- package/src/nodes/utils/TriplanarTextures.js +65 -0
- package/src/objects/BatchedMesh.js +4 -2
- package/src/renderers/WebGLRenderer.js +26 -24
- package/src/renderers/common/Background.js +2 -2
- package/src/renderers/common/Bindings.js +19 -18
- package/src/renderers/common/Color4.js +2 -2
- package/src/renderers/common/CubeRenderTarget.js +1 -1
- package/src/renderers/common/PostProcessing.js +60 -5
- package/src/renderers/common/RenderObject.js +68 -3
- package/src/renderers/common/Renderer.js +19 -16
- package/src/renderers/common/SampledTexture.js +3 -71
- package/src/renderers/common/Sampler.js +79 -0
- package/src/renderers/common/Storage3DTexture.js +100 -0
- package/src/renderers/common/StorageArrayTexture.js +84 -0
- package/src/renderers/common/StorageTexture.js +19 -0
- package/src/renderers/common/Textures.js +19 -3
- package/src/renderers/common/XRManager.js +31 -12
- package/src/renderers/common/XRRenderTarget.js +21 -4
- package/src/renderers/common/extras/PMREMGenerator.js +1 -1
- 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/WebGLAttributes.js +4 -0
- package/src/renderers/webgl/WebGLCapabilities.js +2 -2
- package/src/renderers/webgl/WebGLProgram.js +12 -6
- package/src/renderers/webgl/WebGLPrograms.js +6 -4
- package/src/renderers/webgl/WebGLShadowMap.js +11 -1
- package/src/renderers/webgl/WebGLState.js +4 -4
- package/src/renderers/webgl/WebGLTextures.js +19 -7
- package/src/renderers/webgl-fallback/WebGLBackend.js +103 -72
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +3 -5
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +4 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +4 -4
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +2 -0
- package/src/renderers/webgpu/WebGPUBackend.js +63 -16
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +64 -79
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +6 -0
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -31
- package/src/renderers/webgpu/utils/WebGPUConstants.js +7 -1
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +5 -5
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +12 -65
- package/src/renderers/webgpu/utils/WebGPUUtils.js +2 -17
- package/src/renderers/webxr/WebXRDepthSensing.js +6 -10
- package/src/renderers/webxr/WebXRManager.js +68 -6
- 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
- package/src/nodes/utils/EquirectUVNode.js +0 -65
- package/src/nodes/utils/MatcapUVNode.js +0 -49
- package/src/nodes/utils/TriplanarTexturesNode.js +0 -148
|
@@ -16,7 +16,7 @@ import { NodeAccess } from '../../../nodes/core/constants.js';
|
|
|
16
16
|
import VarNode from '../../../nodes/core/VarNode.js';
|
|
17
17
|
import ExpressionNode from '../../../nodes/code/ExpressionNode.js';
|
|
18
18
|
|
|
19
|
-
import {
|
|
19
|
+
import { FloatType, RepeatWrapping, ClampToEdgeWrapping, MirroredRepeatWrapping, NearestFilter } from '../../../constants.js';
|
|
20
20
|
|
|
21
21
|
// GPUShaderStage is not defined in browsers not supporting WebGPU
|
|
22
22
|
const GPUShaderStage = ( typeof self !== 'undefined' ) ? self.GPUShaderStage : { VERTEX: 1, FRAGMENT: 2, COMPUTE: 4 };
|
|
@@ -211,18 +211,6 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
211
211
|
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
-
/**
|
|
215
|
-
* Checks if the given texture requires a manual conversion to the working color space.
|
|
216
|
-
*
|
|
217
|
-
* @param {Texture} texture - The texture to check.
|
|
218
|
-
* @return {boolean} Whether the given texture requires a conversion to working color space or not.
|
|
219
|
-
*/
|
|
220
|
-
needsToWorkingColorSpace( texture ) {
|
|
221
|
-
|
|
222
|
-
return texture.isVideoTexture === true && texture.colorSpace !== NoColorSpace;
|
|
223
|
-
|
|
224
|
-
}
|
|
225
|
-
|
|
226
214
|
/**
|
|
227
215
|
* Generates the WGSL snippet for sampled textures.
|
|
228
216
|
*
|
|
@@ -250,30 +238,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
250
238
|
|
|
251
239
|
} else {
|
|
252
240
|
|
|
253
|
-
return this.
|
|
254
|
-
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Generates the WGSL snippet when sampling video textures.
|
|
261
|
-
*
|
|
262
|
-
* @private
|
|
263
|
-
* @param {string} textureProperty - The name of the video texture uniform in the shader.
|
|
264
|
-
* @param {string} uvSnippet - A WGSL snippet that represents texture coordinates used for sampling.
|
|
265
|
-
* @param {string} [shaderStage=this.shaderStage] - The shader stage this code snippet is generated for.
|
|
266
|
-
* @return {string} The WGSL snippet.
|
|
267
|
-
*/
|
|
268
|
-
_generateVideoSample( textureProperty, uvSnippet, shaderStage = this.shaderStage ) {
|
|
269
|
-
|
|
270
|
-
if ( shaderStage === 'fragment' ) {
|
|
271
|
-
|
|
272
|
-
return `textureSampleBaseClampToEdge( ${ textureProperty }, ${ textureProperty }_sampler, vec2<f32>( ${ uvSnippet }.x, 1.0 - ${ uvSnippet }.y ) )`;
|
|
273
|
-
|
|
274
|
-
} else {
|
|
275
|
-
|
|
276
|
-
console.error( `WebGPURenderer: THREE.VideoTexture does not support ${ shaderStage } shader.` );
|
|
241
|
+
return this.generateTextureSampleLevel( texture, textureProperty, uvSnippet, '0', depthSnippet );
|
|
277
242
|
|
|
278
243
|
}
|
|
279
244
|
|
|
@@ -290,7 +255,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
290
255
|
* @param {string} depthSnippet - A WGSL snippet that represents 0-based texture array index to sample.
|
|
291
256
|
* @return {string} The WGSL snippet.
|
|
292
257
|
*/
|
|
293
|
-
|
|
258
|
+
generateTextureSampleLevel( texture, textureProperty, uvSnippet, levelSnippet, depthSnippet ) {
|
|
294
259
|
|
|
295
260
|
if ( this.isUnfilterable( texture ) === false ) {
|
|
296
261
|
|
|
@@ -434,7 +399,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
434
399
|
}
|
|
435
400
|
|
|
436
401
|
// Build parameters string based on texture type and multisampling
|
|
437
|
-
if ( isMultisampled || texture.
|
|
402
|
+
if ( isMultisampled || texture.isStorageTexture ) {
|
|
438
403
|
|
|
439
404
|
textureDimensionsParams = textureProperty;
|
|
440
405
|
|
|
@@ -531,11 +496,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
531
496
|
|
|
532
497
|
let snippet;
|
|
533
498
|
|
|
534
|
-
if (
|
|
535
|
-
|
|
536
|
-
snippet = `textureLoad( ${ textureProperty }, ${ uvIndexSnippet } )`;
|
|
537
|
-
|
|
538
|
-
} else if ( depthSnippet ) {
|
|
499
|
+
if ( depthSnippet ) {
|
|
539
500
|
|
|
540
501
|
snippet = `textureLoad( ${ textureProperty }, ${ uvIndexSnippet }, ${ depthSnippet }, u32( ${ levelSnippet } ) )`;
|
|
541
502
|
|
|
@@ -624,11 +585,7 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
624
585
|
|
|
625
586
|
let snippet = null;
|
|
626
587
|
|
|
627
|
-
if (
|
|
628
|
-
|
|
629
|
-
snippet = this._generateVideoSample( textureProperty, uvSnippet, shaderStage );
|
|
630
|
-
|
|
631
|
-
} else if ( this.isUnfilterable( texture ) ) {
|
|
588
|
+
if ( this.isUnfilterable( texture ) ) {
|
|
632
589
|
|
|
633
590
|
snippet = this.generateTextureLod( texture, textureProperty, uvSnippet, depthSnippet, '0', shaderStage );
|
|
634
591
|
|
|
@@ -711,22 +668,22 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
711
668
|
* @param {string} [shaderStage=this.shaderStage] - The shader stage this code snippet is generated for.
|
|
712
669
|
* @return {string} The WGSL snippet.
|
|
713
670
|
*/
|
|
714
|
-
generateTextureLevel( texture, textureProperty, uvSnippet, levelSnippet, depthSnippet
|
|
671
|
+
generateTextureLevel( texture, textureProperty, uvSnippet, levelSnippet, depthSnippet ) {
|
|
715
672
|
|
|
716
|
-
|
|
673
|
+
if ( this.isUnfilterable( texture ) === false ) {
|
|
717
674
|
|
|
718
|
-
|
|
675
|
+
return `textureSampleLevel( ${ textureProperty }, ${ textureProperty }_sampler, ${ uvSnippet }, ${ levelSnippet } )`;
|
|
719
676
|
|
|
720
|
-
|
|
677
|
+
} else if ( this.isFilteredTexture( texture ) ) {
|
|
678
|
+
|
|
679
|
+
return this.generateFilteredTexture( texture, textureProperty, uvSnippet, levelSnippet );
|
|
721
680
|
|
|
722
681
|
} else {
|
|
723
682
|
|
|
724
|
-
|
|
683
|
+
return this.generateTextureLod( texture, textureProperty, uvSnippet, depthSnippet, levelSnippet );
|
|
725
684
|
|
|
726
685
|
}
|
|
727
686
|
|
|
728
|
-
return snippet;
|
|
729
|
-
|
|
730
687
|
}
|
|
731
688
|
|
|
732
689
|
/**
|
|
@@ -844,9 +801,20 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
844
801
|
*/
|
|
845
802
|
getNodeAccess( node, shaderStage ) {
|
|
846
803
|
|
|
847
|
-
if ( shaderStage !== 'compute' )
|
|
804
|
+
if ( shaderStage !== 'compute' ) {
|
|
805
|
+
|
|
806
|
+
if ( node.isAtomic === true ) {
|
|
807
|
+
|
|
808
|
+
console.warn( 'WebGPURenderer: Atomic operations are only supported in compute shaders.' );
|
|
809
|
+
|
|
810
|
+
return NodeAccess.READ_WRITE;
|
|
811
|
+
|
|
812
|
+
}
|
|
813
|
+
|
|
848
814
|
return NodeAccess.READ_ONLY;
|
|
849
815
|
|
|
816
|
+
}
|
|
817
|
+
|
|
850
818
|
return node.access;
|
|
851
819
|
|
|
852
820
|
}
|
|
@@ -899,7 +867,15 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
899
867
|
|
|
900
868
|
if ( type === 'texture' || type === 'storageTexture' ) {
|
|
901
869
|
|
|
902
|
-
|
|
870
|
+
if ( node.value.is3DTexture === true ) {
|
|
871
|
+
|
|
872
|
+
texture = new NodeSampledTexture3D( uniformNode.name, uniformNode.node, group, access );
|
|
873
|
+
|
|
874
|
+
} else {
|
|
875
|
+
|
|
876
|
+
texture = new NodeSampledTexture( uniformNode.name, uniformNode.node, group, access );
|
|
877
|
+
|
|
878
|
+
}
|
|
903
879
|
|
|
904
880
|
} else if ( type === 'cubeTexture' ) {
|
|
905
881
|
|
|
@@ -1701,24 +1677,25 @@ ${ flowData.code }
|
|
|
1701
1677
|
|
|
1702
1678
|
}
|
|
1703
1679
|
|
|
1704
|
-
} else if (
|
|
1680
|
+
} else if ( uniform.node.isStorageTextureNode === true ) {
|
|
1705
1681
|
|
|
1706
|
-
|
|
1682
|
+
const format = getFormat( texture );
|
|
1683
|
+
const access = this.getStorageAccess( uniform.node, shaderStage );
|
|
1707
1684
|
|
|
1708
|
-
|
|
1685
|
+
const is3D = uniform.node.value.is3DTexture;
|
|
1686
|
+
const isArrayTexture = uniform.node.value.isArrayTexture;
|
|
1709
1687
|
|
|
1710
|
-
|
|
1688
|
+
const dimension = is3D ? '3d' : `2d${ isArrayTexture ? '_array' : '' }`;
|
|
1711
1689
|
|
|
1712
|
-
|
|
1690
|
+
textureType = `texture_storage_${ dimension }<${ format }, ${ access }>`;
|
|
1713
1691
|
|
|
1714
|
-
|
|
1692
|
+
} else if ( texture.isArrayTexture === true || texture.isDataArrayTexture === true || texture.isCompressedArrayTexture === true ) {
|
|
1715
1693
|
|
|
1716
|
-
|
|
1694
|
+
textureType = 'texture_2d_array<f32>';
|
|
1717
1695
|
|
|
1718
|
-
|
|
1719
|
-
const access = this.getStorageAccess( uniform.node, shaderStage );
|
|
1696
|
+
} else if ( texture.is3DTexture === true || texture.isData3DTexture === true ) {
|
|
1720
1697
|
|
|
1721
|
-
textureType =
|
|
1698
|
+
textureType = 'texture_3d<f32>';
|
|
1722
1699
|
|
|
1723
1700
|
} else {
|
|
1724
1701
|
|
|
@@ -1885,7 +1862,11 @@ ${ flowData.code }
|
|
|
1885
1862
|
|
|
1886
1863
|
} else {
|
|
1887
1864
|
|
|
1888
|
-
|
|
1865
|
+
// Early strictly validated in computeNode
|
|
1866
|
+
|
|
1867
|
+
const workgroupSize = this.object.workgroupSize;
|
|
1868
|
+
|
|
1869
|
+
this.computeShader = this._getWGSLComputeCode( shadersData.compute, workgroupSize );
|
|
1889
1870
|
|
|
1890
1871
|
}
|
|
1891
1872
|
|
|
@@ -2090,36 +2071,40 @@ fn main( ${shaderData.varyings} ) -> ${shaderData.returnType} {
|
|
|
2090
2071
|
*/
|
|
2091
2072
|
_getWGSLComputeCode( shaderData, workgroupSize ) {
|
|
2092
2073
|
|
|
2074
|
+
const [ workgroupSizeX, workgroupSizeY, workgroupSizeZ ] = workgroupSize;
|
|
2075
|
+
|
|
2093
2076
|
return `${ this.getSignature() }
|
|
2094
2077
|
// directives
|
|
2095
|
-
${shaderData.directives}
|
|
2078
|
+
${ shaderData.directives }
|
|
2096
2079
|
|
|
2097
2080
|
// system
|
|
2098
2081
|
var<private> instanceIndex : u32;
|
|
2099
2082
|
|
|
2100
2083
|
// locals
|
|
2101
|
-
${shaderData.scopedArrays}
|
|
2084
|
+
${ shaderData.scopedArrays }
|
|
2102
2085
|
|
|
2103
2086
|
// structs
|
|
2104
|
-
${shaderData.structs}
|
|
2087
|
+
${ shaderData.structs }
|
|
2105
2088
|
|
|
2106
2089
|
// uniforms
|
|
2107
|
-
${shaderData.uniforms}
|
|
2090
|
+
${ shaderData.uniforms }
|
|
2108
2091
|
|
|
2109
2092
|
// codes
|
|
2110
|
-
${shaderData.codes}
|
|
2093
|
+
${ shaderData.codes }
|
|
2111
2094
|
|
|
2112
|
-
@compute @workgroup_size( ${
|
|
2113
|
-
fn main( ${shaderData.attributes} ) {
|
|
2095
|
+
@compute @workgroup_size( ${ workgroupSizeX }, ${ workgroupSizeY }, ${ workgroupSizeZ } )
|
|
2096
|
+
fn main( ${ shaderData.attributes } ) {
|
|
2114
2097
|
|
|
2115
2098
|
// system
|
|
2116
|
-
instanceIndex = globalId.x
|
|
2099
|
+
instanceIndex = globalId.x
|
|
2100
|
+
+ globalId.y * ( ${ workgroupSizeX } * numWorkgroups.x )
|
|
2101
|
+
+ globalId.z * ( ${ workgroupSizeX } * numWorkgroups.x ) * ( ${ workgroupSizeY } * numWorkgroups.y );
|
|
2117
2102
|
|
|
2118
2103
|
// vars
|
|
2119
|
-
${shaderData.vars}
|
|
2104
|
+
${ shaderData.vars }
|
|
2120
2105
|
|
|
2121
2106
|
// flow
|
|
2122
|
-
${shaderData.flow}
|
|
2107
|
+
${ shaderData.flow }
|
|
2123
2108
|
|
|
2124
2109
|
}
|
|
2125
2110
|
`;
|
|
@@ -12,6 +12,12 @@ const typedArraysToVertexFormatPrefix = new Map( [
|
|
|
12
12
|
[ Float32Array, [ 'float32', ]],
|
|
13
13
|
] );
|
|
14
14
|
|
|
15
|
+
if ( typeof Float16Array !== 'undefined' ) {
|
|
16
|
+
|
|
17
|
+
typedArraysToVertexFormatPrefix.set( Float16Array, [ 'float16' ] );
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
|
|
15
21
|
const typedAttributeToVertexFormatPrefix = new Map( [
|
|
16
22
|
[ Float16BufferAttribute, [ 'float16', ]],
|
|
17
23
|
] );
|
|
@@ -93,30 +93,6 @@ class WebGPUBindingUtils {
|
|
|
93
93
|
|
|
94
94
|
bindingGPU.buffer = buffer;
|
|
95
95
|
|
|
96
|
-
} else if ( binding.isSampler ) {
|
|
97
|
-
|
|
98
|
-
const sampler = {}; // GPUSamplerBindingLayout
|
|
99
|
-
|
|
100
|
-
if ( binding.texture.isDepthTexture ) {
|
|
101
|
-
|
|
102
|
-
if ( binding.texture.compareFunction !== null ) {
|
|
103
|
-
|
|
104
|
-
sampler.type = GPUSamplerBindingType.Comparison;
|
|
105
|
-
|
|
106
|
-
} else if ( backend.compatibilityMode ) {
|
|
107
|
-
|
|
108
|
-
sampler.type = GPUSamplerBindingType.NonFiltering;
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
bindingGPU.sampler = sampler;
|
|
115
|
-
|
|
116
|
-
} else if ( binding.isSampledTexture && binding.texture.isVideoTexture ) {
|
|
117
|
-
|
|
118
|
-
bindingGPU.externalTexture = {}; // GPUExternalTextureBindingLayout
|
|
119
|
-
|
|
120
96
|
} else if ( binding.isSampledTexture && binding.store ) {
|
|
121
97
|
|
|
122
98
|
const storageTexture = {}; // GPUStorageTextureBindingLayout
|
|
@@ -138,6 +114,16 @@ class WebGPUBindingUtils {
|
|
|
138
114
|
|
|
139
115
|
}
|
|
140
116
|
|
|
117
|
+
if ( binding.texture.isArrayTexture ) {
|
|
118
|
+
|
|
119
|
+
storageTexture.viewDimension = GPUTextureViewDimension.TwoDArray;
|
|
120
|
+
|
|
121
|
+
} else if ( binding.texture.is3DTexture ) {
|
|
122
|
+
|
|
123
|
+
storageTexture.viewDimension = GPUTextureViewDimension.ThreeD;
|
|
124
|
+
|
|
125
|
+
}
|
|
126
|
+
|
|
141
127
|
bindingGPU.storageTexture = storageTexture;
|
|
142
128
|
|
|
143
129
|
} else if ( binding.isSampledTexture ) {
|
|
@@ -214,6 +200,26 @@ class WebGPUBindingUtils {
|
|
|
214
200
|
|
|
215
201
|
bindingGPU.texture = texture;
|
|
216
202
|
|
|
203
|
+
} else if ( binding.isSampler ) {
|
|
204
|
+
|
|
205
|
+
const sampler = {}; // GPUSamplerBindingLayout
|
|
206
|
+
|
|
207
|
+
if ( binding.texture.isDepthTexture ) {
|
|
208
|
+
|
|
209
|
+
if ( binding.texture.compareFunction !== null ) {
|
|
210
|
+
|
|
211
|
+
sampler.type = GPUSamplerBindingType.Comparison;
|
|
212
|
+
|
|
213
|
+
} else if ( backend.compatibilityMode ) {
|
|
214
|
+
|
|
215
|
+
sampler.type = GPUSamplerBindingType.NonFiltering;
|
|
216
|
+
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
bindingGPU.sampler = sampler;
|
|
222
|
+
|
|
217
223
|
} else {
|
|
218
224
|
|
|
219
225
|
console.error( `WebGPUBindingUtils: Unsupported binding "${ binding }".` );
|
|
@@ -395,12 +401,6 @@ class WebGPUBindingUtils {
|
|
|
395
401
|
|
|
396
402
|
entriesGPU.push( { binding: bindingPoint, resource: { buffer: bindingData.buffer } } );
|
|
397
403
|
|
|
398
|
-
} else if ( binding.isSampler ) {
|
|
399
|
-
|
|
400
|
-
const textureGPU = backend.get( binding.texture );
|
|
401
|
-
|
|
402
|
-
entriesGPU.push( { binding: bindingPoint, resource: textureGPU.sampler } );
|
|
403
|
-
|
|
404
404
|
} else if ( binding.isSampledTexture ) {
|
|
405
405
|
|
|
406
406
|
const textureData = backend.get( binding.texture );
|
|
@@ -414,7 +414,15 @@ class WebGPUBindingUtils {
|
|
|
414
414
|
} else {
|
|
415
415
|
|
|
416
416
|
const mipLevelCount = binding.store ? 1 : textureData.texture.mipLevelCount;
|
|
417
|
-
|
|
417
|
+
let propertyName = `view-${ textureData.texture.width }-${ textureData.texture.height }`;
|
|
418
|
+
|
|
419
|
+
if ( textureData.texture.depthOrArrayLayers > 1 ) {
|
|
420
|
+
|
|
421
|
+
propertyName += `-${ textureData.texture.depthOrArrayLayers }`;
|
|
422
|
+
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
propertyName += `-${ mipLevelCount }`;
|
|
418
426
|
|
|
419
427
|
resourceGPU = textureData[ propertyName ];
|
|
420
428
|
|
|
@@ -450,6 +458,12 @@ class WebGPUBindingUtils {
|
|
|
450
458
|
|
|
451
459
|
entriesGPU.push( { binding: bindingPoint, resource: resourceGPU } );
|
|
452
460
|
|
|
461
|
+
} else if ( binding.isSampler ) {
|
|
462
|
+
|
|
463
|
+
const textureGPU = backend.get( binding.texture );
|
|
464
|
+
|
|
465
|
+
entriesGPU.push( { binding: bindingPoint, resource: textureGPU.sampler } );
|
|
466
|
+
|
|
453
467
|
}
|
|
454
468
|
|
|
455
469
|
bindingPoint ++;
|
|
@@ -316,18 +316,24 @@ export const GPUInputStepMode = {
|
|
|
316
316
|
};
|
|
317
317
|
|
|
318
318
|
export const GPUFeatureName = {
|
|
319
|
+
CoreFeaturesAndLimits: 'core-features-and-limits',
|
|
319
320
|
DepthClipControl: 'depth-clip-control',
|
|
320
321
|
Depth32FloatStencil8: 'depth32float-stencil8',
|
|
321
322
|
TextureCompressionBC: 'texture-compression-bc',
|
|
323
|
+
TextureCompressionBCSliced3D: 'texture-compression-bc-sliced-3d',
|
|
322
324
|
TextureCompressionETC2: 'texture-compression-etc2',
|
|
323
325
|
TextureCompressionASTC: 'texture-compression-astc',
|
|
326
|
+
TextureCompressionASTCSliced3D: 'texture-compression-astc-sliced-3d',
|
|
324
327
|
TimestampQuery: 'timestamp-query',
|
|
325
328
|
IndirectFirstInstance: 'indirect-first-instance',
|
|
326
329
|
ShaderF16: 'shader-f16',
|
|
327
330
|
RG11B10UFloat: 'rg11b10ufloat-renderable',
|
|
328
331
|
BGRA8UNormStorage: 'bgra8unorm-storage',
|
|
329
332
|
Float32Filterable: 'float32-filterable',
|
|
333
|
+
Float32Blendable: 'float32-blendable',
|
|
330
334
|
ClipDistances: 'clip-distances',
|
|
331
335
|
DualSourceBlending: 'dual-source-blending',
|
|
332
|
-
Subgroups: 'subgroups'
|
|
336
|
+
Subgroups: 'subgroups',
|
|
337
|
+
TextureFormatsTier1: 'texture-formats-tier1',
|
|
338
|
+
TextureFormatsTier2: 'texture-formats-tier2'
|
|
333
339
|
};
|
|
@@ -389,7 +389,7 @@ class WebGPUPipelineUtils {
|
|
|
389
389
|
break;
|
|
390
390
|
|
|
391
391
|
case MultiplyBlending:
|
|
392
|
-
setBlend( GPUBlendFactor.
|
|
392
|
+
setBlend( GPUBlendFactor.Dst, GPUBlendFactor.OneMinusSrcAlpha, GPUBlendFactor.Zero, GPUBlendFactor.One );
|
|
393
393
|
break;
|
|
394
394
|
|
|
395
395
|
}
|
|
@@ -403,15 +403,15 @@ class WebGPUPipelineUtils {
|
|
|
403
403
|
break;
|
|
404
404
|
|
|
405
405
|
case AdditiveBlending:
|
|
406
|
-
setBlend( GPUBlendFactor.SrcAlpha, GPUBlendFactor.One, GPUBlendFactor.
|
|
406
|
+
setBlend( GPUBlendFactor.SrcAlpha, GPUBlendFactor.One, GPUBlendFactor.One, GPUBlendFactor.One );
|
|
407
407
|
break;
|
|
408
408
|
|
|
409
409
|
case SubtractiveBlending:
|
|
410
|
-
|
|
410
|
+
console.error( 'THREE.WebGPURenderer: SubtractiveBlending requires material.premultipliedAlpha = true' );
|
|
411
411
|
break;
|
|
412
412
|
|
|
413
413
|
case MultiplyBlending:
|
|
414
|
-
|
|
414
|
+
console.error( 'THREE.WebGPURenderer: MultiplyBlending requires material.premultipliedAlpha = true' );
|
|
415
415
|
break;
|
|
416
416
|
|
|
417
417
|
}
|
|
@@ -712,7 +712,7 @@ class WebGPUPipelineUtils {
|
|
|
712
712
|
*
|
|
713
713
|
* @private
|
|
714
714
|
* @param {Material} material - The material.
|
|
715
|
-
* @return {
|
|
715
|
+
* @return {number} The GPU color write mask.
|
|
716
716
|
*/
|
|
717
717
|
_getColorWriteMask( material ) {
|
|
718
718
|
|
|
@@ -159,10 +159,6 @@ class WebGPUTextureUtils {
|
|
|
159
159
|
|
|
160
160
|
textureGPU = this._getDefaultCubeTextureGPU( format );
|
|
161
161
|
|
|
162
|
-
} else if ( texture.isVideoTexture ) {
|
|
163
|
-
|
|
164
|
-
this.backend.get( texture ).externalTexture = this._getDefaultVideoFrame();
|
|
165
|
-
|
|
166
162
|
} else {
|
|
167
163
|
|
|
168
164
|
textureGPU = this._getDefaultTextureGPU( format );
|
|
@@ -247,39 +243,23 @@ class WebGPUTextureUtils {
|
|
|
247
243
|
|
|
248
244
|
// texture creation
|
|
249
245
|
|
|
250
|
-
if (
|
|
251
|
-
|
|
252
|
-
const video = texture.source.data;
|
|
253
|
-
const videoFrame = new VideoFrame( video );
|
|
254
|
-
|
|
255
|
-
textureDescriptorGPU.size.width = videoFrame.displayWidth;
|
|
256
|
-
textureDescriptorGPU.size.height = videoFrame.displayHeight;
|
|
257
|
-
|
|
258
|
-
videoFrame.close();
|
|
259
|
-
|
|
260
|
-
textureData.externalTexture = video;
|
|
261
|
-
|
|
262
|
-
} else {
|
|
263
|
-
|
|
264
|
-
if ( format === undefined ) {
|
|
246
|
+
if ( format === undefined ) {
|
|
265
247
|
|
|
266
|
-
|
|
248
|
+
console.warn( 'WebGPURenderer: Texture format not supported.' );
|
|
267
249
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
if ( texture.isCubeTexture ) {
|
|
250
|
+
this.createDefaultTexture( texture );
|
|
251
|
+
return;
|
|
274
252
|
|
|
275
|
-
|
|
253
|
+
}
|
|
276
254
|
|
|
277
|
-
|
|
255
|
+
if ( texture.isCubeTexture ) {
|
|
278
256
|
|
|
279
|
-
|
|
257
|
+
textureDescriptorGPU.textureBindingViewDimension = GPUTextureViewDimension.Cube;
|
|
280
258
|
|
|
281
259
|
}
|
|
282
260
|
|
|
261
|
+
textureData.texture = backend.device.createTexture( textureDescriptorGPU );
|
|
262
|
+
|
|
283
263
|
if ( isMSAA ) {
|
|
284
264
|
|
|
285
265
|
const msaaTextureDescriptorGPU = Object.assign( {}, textureDescriptorGPU );
|
|
@@ -480,12 +460,6 @@ class WebGPUTextureUtils {
|
|
|
480
460
|
|
|
481
461
|
this._copyCubeMapToTexture( options.images, textureData.texture, textureDescriptorGPU, texture.flipY, texture.premultiplyAlpha );
|
|
482
462
|
|
|
483
|
-
} else if ( texture.isVideoTexture ) {
|
|
484
|
-
|
|
485
|
-
const video = texture.source.data;
|
|
486
|
-
|
|
487
|
-
textureData.externalTexture = video;
|
|
488
|
-
|
|
489
463
|
} else {
|
|
490
464
|
|
|
491
465
|
this._copyImageToTexture( options.image, textureData.texture, textureDescriptorGPU, 0, texture.flipY, texture.premultiplyAlpha );
|
|
@@ -615,33 +589,6 @@ class WebGPUTextureUtils {
|
|
|
615
589
|
|
|
616
590
|
}
|
|
617
591
|
|
|
618
|
-
/**
|
|
619
|
-
* Returns the default video frame used as default data in context of video textures.
|
|
620
|
-
*
|
|
621
|
-
* @private
|
|
622
|
-
* @return {VideoFrame} The video frame.
|
|
623
|
-
*/
|
|
624
|
-
_getDefaultVideoFrame() {
|
|
625
|
-
|
|
626
|
-
let defaultVideoFrame = this.defaultVideoFrame;
|
|
627
|
-
|
|
628
|
-
if ( defaultVideoFrame === null ) {
|
|
629
|
-
|
|
630
|
-
const init = {
|
|
631
|
-
timestamp: 0,
|
|
632
|
-
codedWidth: 1,
|
|
633
|
-
codedHeight: 1,
|
|
634
|
-
format: 'RGBA',
|
|
635
|
-
};
|
|
636
|
-
|
|
637
|
-
this.defaultVideoFrame = defaultVideoFrame = new VideoFrame( new Uint8Array( [ 0, 0, 0, 0xff ] ), init );
|
|
638
|
-
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
return defaultVideoFrame;
|
|
642
|
-
|
|
643
|
-
}
|
|
644
|
-
|
|
645
592
|
/**
|
|
646
593
|
* Uploads cube texture image data to the GPU memory.
|
|
647
594
|
*
|
|
@@ -699,8 +646,8 @@ class WebGPUTextureUtils {
|
|
|
699
646
|
origin: { x: 0, y: 0, z: originDepth },
|
|
700
647
|
premultipliedAlpha: premultiplyAlpha
|
|
701
648
|
}, {
|
|
702
|
-
width:
|
|
703
|
-
height:
|
|
649
|
+
width: textureDescriptorGPU.size.width,
|
|
650
|
+
height: textureDescriptorGPU.size.height,
|
|
704
651
|
depthOrArrayLayers: 1
|
|
705
652
|
}
|
|
706
653
|
);
|
|
@@ -1078,7 +1025,7 @@ class WebGPUTextureUtils {
|
|
|
1078
1025
|
|
|
1079
1026
|
let dimension;
|
|
1080
1027
|
|
|
1081
|
-
if ( texture.isData3DTexture ) {
|
|
1028
|
+
if ( texture.is3DTexture || texture.isData3DTexture ) {
|
|
1082
1029
|
|
|
1083
1030
|
dimension = GPUTextureDimension.ThreeD;
|
|
1084
1031
|
|
|
@@ -161,29 +161,14 @@ class WebGPUUtils {
|
|
|
161
161
|
/**
|
|
162
162
|
* Returns a modified sample count from the given sample count value.
|
|
163
163
|
*
|
|
164
|
-
* That is required since WebGPU
|
|
164
|
+
* That is required since WebGPU only supports either 1 or 4.
|
|
165
165
|
*
|
|
166
166
|
* @param {number} sampleCount - The input sample count.
|
|
167
167
|
* @return {number} The (potentially updated) output sample count.
|
|
168
168
|
*/
|
|
169
169
|
getSampleCount( sampleCount ) {
|
|
170
170
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
if ( sampleCount > 1 ) {
|
|
174
|
-
|
|
175
|
-
// WebGPU only supports power-of-two sample counts and 2 is not a valid value
|
|
176
|
-
count = Math.pow( 2, Math.floor( Math.log2( sampleCount ) ) );
|
|
177
|
-
|
|
178
|
-
if ( count === 2 ) {
|
|
179
|
-
|
|
180
|
-
count = 4;
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
return count;
|
|
171
|
+
return sampleCount >= 4 ? 4 : 1;
|
|
187
172
|
|
|
188
173
|
}
|
|
189
174
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PlaneGeometry } from '../../geometries/PlaneGeometry.js';
|
|
2
2
|
import { ShaderMaterial } from '../../materials/ShaderMaterial.js';
|
|
3
3
|
import { Mesh } from '../../objects/Mesh.js';
|
|
4
|
-
import {
|
|
4
|
+
import { ExternalTexture } from '../../textures/ExternalTexture.js';
|
|
5
5
|
|
|
6
6
|
const _occlusion_vertex = `
|
|
7
7
|
void main() {
|
|
@@ -42,9 +42,9 @@ class WebXRDepthSensing {
|
|
|
42
42
|
constructor() {
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
45
|
+
* An opaque texture representing the depth of the user's environment.
|
|
46
46
|
*
|
|
47
|
-
* @type {?
|
|
47
|
+
* @type {?ExternalTexture}
|
|
48
48
|
*/
|
|
49
49
|
this.texture = null;
|
|
50
50
|
|
|
@@ -74,18 +74,14 @@ class WebXRDepthSensing {
|
|
|
74
74
|
/**
|
|
75
75
|
* Inits the depth sensing module
|
|
76
76
|
*
|
|
77
|
-
* @param {WebGLRenderer} renderer - The renderer.
|
|
78
77
|
* @param {XRWebGLDepthInformation} depthData - The XR depth data.
|
|
79
78
|
* @param {XRRenderState} renderState - The XR render state.
|
|
80
79
|
*/
|
|
81
|
-
init(
|
|
80
|
+
init( depthData, renderState ) {
|
|
82
81
|
|
|
83
82
|
if ( this.texture === null ) {
|
|
84
83
|
|
|
85
|
-
const texture = new
|
|
86
|
-
|
|
87
|
-
const texProps = renderer.properties.get( texture );
|
|
88
|
-
texProps.__webglTexture = depthData.texture;
|
|
84
|
+
const texture = new ExternalTexture( depthData.texture );
|
|
89
85
|
|
|
90
86
|
if ( ( depthData.depthNear !== renderState.depthNear ) || ( depthData.depthFar !== renderState.depthFar ) ) {
|
|
91
87
|
|
|
@@ -146,7 +142,7 @@ class WebXRDepthSensing {
|
|
|
146
142
|
/**
|
|
147
143
|
* Returns a texture representing the depth of the user's environment.
|
|
148
144
|
*
|
|
149
|
-
* @return {?
|
|
145
|
+
* @return {?ExternalTexture} The depth texture.
|
|
150
146
|
*/
|
|
151
147
|
getDepthTexture() {
|
|
152
148
|
|