@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
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from './WebGPUConstants.js';
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
|
-
|
|
8
|
+
BackSide, DoubleSide,
|
|
9
9
|
NeverDepth, AlwaysDepth, LessDepth, LessEqualDepth, EqualDepth, GreaterEqualDepth, GreaterDepth, NotEqualDepth,
|
|
10
10
|
NoBlending, NormalBlending, AdditiveBlending, SubtractiveBlending, MultiplyBlending, CustomBlending,
|
|
11
11
|
ZeroFactor, OneFactor, SrcColorFactor, OneMinusSrcColorFactor, SrcAlphaFactor, OneMinusSrcAlphaFactor, DstColorFactor,
|
|
@@ -672,6 +672,8 @@ class WebGPUPipelineUtils {
|
|
|
672
672
|
const descriptor = {};
|
|
673
673
|
const utils = this.backend.utils;
|
|
674
674
|
|
|
675
|
+
//
|
|
676
|
+
|
|
675
677
|
descriptor.topology = utils.getPrimitiveTopology( object, material );
|
|
676
678
|
|
|
677
679
|
if ( geometry.index !== null && object.isLine === true && object.isLineSegments !== true ) {
|
|
@@ -680,28 +682,17 @@ class WebGPUPipelineUtils {
|
|
|
680
682
|
|
|
681
683
|
}
|
|
682
684
|
|
|
683
|
-
|
|
685
|
+
//
|
|
684
686
|
|
|
685
|
-
|
|
686
|
-
descriptor.frontFace = GPUFrontFace.CCW;
|
|
687
|
-
descriptor.cullMode = GPUCullMode.Back;
|
|
688
|
-
break;
|
|
687
|
+
let flipSided = ( material.side === BackSide );
|
|
689
688
|
|
|
690
|
-
|
|
691
|
-
descriptor.frontFace = GPUFrontFace.CCW;
|
|
692
|
-
descriptor.cullMode = GPUCullMode.Front;
|
|
693
|
-
break;
|
|
689
|
+
if ( object.isMesh && object.matrixWorld.determinant() < 0 ) flipSided = ! flipSided;
|
|
694
690
|
|
|
695
|
-
|
|
696
|
-
descriptor.frontFace = GPUFrontFace.CCW;
|
|
697
|
-
descriptor.cullMode = GPUCullMode.None;
|
|
698
|
-
break;
|
|
691
|
+
descriptor.frontFace = ( flipSided === true ) ? GPUFrontFace.CW : GPUFrontFace.CCW;
|
|
699
692
|
|
|
700
|
-
|
|
701
|
-
console.error( 'THREE.WebGPUPipelineUtils: Unknown material.side value.', material.side );
|
|
702
|
-
break;
|
|
693
|
+
//
|
|
703
694
|
|
|
704
|
-
|
|
695
|
+
descriptor.cullMode = ( material.side === DoubleSide ) ? GPUCullMode.None : GPUCullMode.Back;
|
|
705
696
|
|
|
706
697
|
return descriptor;
|
|
707
698
|
|
|
@@ -712,7 +703,7 @@ class WebGPUPipelineUtils {
|
|
|
712
703
|
*
|
|
713
704
|
* @private
|
|
714
705
|
* @param {Material} material - The material.
|
|
715
|
-
* @return {
|
|
706
|
+
* @return {number} The GPU color write mask.
|
|
716
707
|
*/
|
|
717
708
|
_getColorWriteMask( material ) {
|
|
718
709
|
|
|
@@ -13,7 +13,8 @@ import {
|
|
|
13
13
|
RGBAFormat, RGBFormat, RedFormat, RGFormat, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, UnsignedByteType, FloatType, HalfFloatType, SRGBTransfer, DepthFormat, DepthStencilFormat,
|
|
14
14
|
RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format,
|
|
15
15
|
RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, UnsignedIntType, UnsignedShortType, UnsignedInt248Type, UnsignedInt5999Type,
|
|
16
|
-
NeverCompare, AlwaysCompare, LessCompare, LessEqualCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare, IntType, RedIntegerFormat, RGIntegerFormat, RGBAIntegerFormat
|
|
16
|
+
NeverCompare, AlwaysCompare, LessCompare, LessEqualCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare, IntType, RedIntegerFormat, RGIntegerFormat, RGBAIntegerFormat,
|
|
17
|
+
UnsignedInt101111Type, RGBA_BPTC_Format, RGB_ETC1_Format, RGB_S3TC_DXT1_Format, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format
|
|
17
18
|
} from '../../../constants.js';
|
|
18
19
|
import { CubeTexture } from '../../../textures/CubeTexture.js';
|
|
19
20
|
import { DepthTexture } from '../../../textures/DepthTexture.js';
|
|
@@ -159,10 +160,6 @@ class WebGPUTextureUtils {
|
|
|
159
160
|
|
|
160
161
|
textureGPU = this._getDefaultCubeTextureGPU( format );
|
|
161
162
|
|
|
162
|
-
} else if ( texture.isVideoTexture ) {
|
|
163
|
-
|
|
164
|
-
this.backend.get( texture ).externalTexture = this._getDefaultVideoFrame();
|
|
165
|
-
|
|
166
163
|
} else {
|
|
167
164
|
|
|
168
165
|
textureGPU = this._getDefaultTextureGPU( format );
|
|
@@ -190,6 +187,15 @@ class WebGPUTextureUtils {
|
|
|
190
187
|
|
|
191
188
|
}
|
|
192
189
|
|
|
190
|
+
if ( texture.isExternalTexture ) {
|
|
191
|
+
|
|
192
|
+
textureData.texture = texture.sourceTexture;
|
|
193
|
+
textureData.initialized = true;
|
|
194
|
+
|
|
195
|
+
return;
|
|
196
|
+
|
|
197
|
+
}
|
|
198
|
+
|
|
193
199
|
if ( options.needsMipmaps === undefined ) options.needsMipmaps = false;
|
|
194
200
|
if ( options.levels === undefined ) options.levels = 1;
|
|
195
201
|
if ( options.depth === undefined ) options.depth = 1;
|
|
@@ -225,7 +231,7 @@ class WebGPUTextureUtils {
|
|
|
225
231
|
|
|
226
232
|
}
|
|
227
233
|
|
|
228
|
-
if ( texture.isCompressedTexture !== true && texture.isCompressedArrayTexture !== true ) {
|
|
234
|
+
if ( texture.isCompressedTexture !== true && texture.isCompressedArrayTexture !== true && format !== GPUTextureFormat.RGB9E5UFloat ) {
|
|
229
235
|
|
|
230
236
|
usage |= GPUTextureUsage.RENDER_ATTACHMENT;
|
|
231
237
|
|
|
@@ -247,45 +253,30 @@ class WebGPUTextureUtils {
|
|
|
247
253
|
|
|
248
254
|
// texture creation
|
|
249
255
|
|
|
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();
|
|
256
|
+
if ( format === undefined ) {
|
|
259
257
|
|
|
260
|
-
|
|
258
|
+
console.warn( 'WebGPURenderer: Texture format not supported.' );
|
|
261
259
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
if ( format === undefined ) {
|
|
265
|
-
|
|
266
|
-
console.warn( 'WebGPURenderer: Texture format not supported.' );
|
|
267
|
-
|
|
268
|
-
this.createDefaultTexture( texture );
|
|
269
|
-
return;
|
|
270
|
-
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
if ( texture.isCubeTexture ) {
|
|
260
|
+
this.createDefaultTexture( texture );
|
|
261
|
+
return;
|
|
274
262
|
|
|
275
|
-
|
|
263
|
+
}
|
|
276
264
|
|
|
277
|
-
|
|
265
|
+
if ( texture.isCubeTexture ) {
|
|
278
266
|
|
|
279
|
-
|
|
267
|
+
textureDescriptorGPU.textureBindingViewDimension = GPUTextureViewDimension.Cube;
|
|
280
268
|
|
|
281
269
|
}
|
|
282
270
|
|
|
271
|
+
textureData.texture = backend.device.createTexture( textureDescriptorGPU );
|
|
272
|
+
|
|
283
273
|
if ( isMSAA ) {
|
|
284
274
|
|
|
285
275
|
const msaaTextureDescriptorGPU = Object.assign( {}, textureDescriptorGPU );
|
|
286
276
|
|
|
287
277
|
msaaTextureDescriptorGPU.label = msaaTextureDescriptorGPU.label + '-msaa';
|
|
288
278
|
msaaTextureDescriptorGPU.sampleCount = samples;
|
|
279
|
+
msaaTextureDescriptorGPU.mipLevelCount = 1; // See https://www.w3.org/TR/webgpu/#texture-creation
|
|
289
280
|
|
|
290
281
|
textureData.msaaTexture = backend.device.createTexture( msaaTextureDescriptorGPU );
|
|
291
282
|
|
|
@@ -452,6 +443,7 @@ class WebGPUTextureUtils {
|
|
|
452
443
|
updateTexture( texture, options ) {
|
|
453
444
|
|
|
454
445
|
const textureData = this.backend.get( texture );
|
|
446
|
+
const mipmaps = texture.mipmaps;
|
|
455
447
|
|
|
456
448
|
const { textureDescriptorGPU } = textureData;
|
|
457
449
|
|
|
@@ -462,7 +454,22 @@ class WebGPUTextureUtils {
|
|
|
462
454
|
|
|
463
455
|
if ( texture.isDataTexture ) {
|
|
464
456
|
|
|
465
|
-
|
|
457
|
+
if ( mipmaps.length > 0 ) {
|
|
458
|
+
|
|
459
|
+
for ( let i = 0, il = mipmaps.length; i < il; i ++ ) {
|
|
460
|
+
|
|
461
|
+
const mipmap = mipmaps[ i ];
|
|
462
|
+
|
|
463
|
+
this._copyBufferToTexture( mipmap, textureData.texture, textureDescriptorGPU, 0, texture.flipY, 0, i );
|
|
464
|
+
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
} else {
|
|
469
|
+
|
|
470
|
+
this._copyBufferToTexture( options.image, textureData.texture, textureDescriptorGPU, 0, texture.flipY );
|
|
471
|
+
|
|
472
|
+
}
|
|
466
473
|
|
|
467
474
|
} else if ( texture.isArrayTexture || texture.isDataArrayTexture || texture.isData3DTexture ) {
|
|
468
475
|
|
|
@@ -478,17 +485,26 @@ class WebGPUTextureUtils {
|
|
|
478
485
|
|
|
479
486
|
} else if ( texture.isCubeTexture ) {
|
|
480
487
|
|
|
481
|
-
this._copyCubeMapToTexture(
|
|
488
|
+
this._copyCubeMapToTexture( texture, textureData.texture, textureDescriptorGPU );
|
|
482
489
|
|
|
483
|
-
} else
|
|
490
|
+
} else {
|
|
484
491
|
|
|
485
|
-
|
|
492
|
+
if ( mipmaps.length > 0 ) {
|
|
486
493
|
|
|
487
|
-
|
|
494
|
+
for ( let i = 0, il = mipmaps.length; i < il; i ++ ) {
|
|
488
495
|
|
|
489
|
-
|
|
496
|
+
const mipmap = mipmaps[ i ];
|
|
497
|
+
|
|
498
|
+
this._copyImageToTexture( mipmap, textureData.texture, textureDescriptorGPU, 0, texture.flipY, texture.premultiplyAlpha, i );
|
|
499
|
+
|
|
500
|
+
}
|
|
490
501
|
|
|
491
|
-
|
|
502
|
+
|
|
503
|
+
} else {
|
|
504
|
+
|
|
505
|
+
this._copyImageToTexture( options.image, textureData.texture, textureDescriptorGPU, 0, texture.flipY, texture.premultiplyAlpha );
|
|
506
|
+
|
|
507
|
+
}
|
|
492
508
|
|
|
493
509
|
}
|
|
494
510
|
|
|
@@ -496,8 +512,6 @@ class WebGPUTextureUtils {
|
|
|
496
512
|
|
|
497
513
|
textureData.version = texture.version;
|
|
498
514
|
|
|
499
|
-
if ( texture.onUpdate ) texture.onUpdate( texture );
|
|
500
|
-
|
|
501
515
|
}
|
|
502
516
|
|
|
503
517
|
/**
|
|
@@ -526,7 +540,7 @@ class WebGPUTextureUtils {
|
|
|
526
540
|
|
|
527
541
|
const readBuffer = device.createBuffer(
|
|
528
542
|
{
|
|
529
|
-
size:
|
|
543
|
+
size: ( ( height - 1 ) * bytesPerRow ) + ( width * bytesPerTexel ), // see https://github.com/mrdoob/three.js/issues/31658#issuecomment-3229442010
|
|
530
544
|
usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ
|
|
531
545
|
}
|
|
532
546
|
);
|
|
@@ -616,57 +630,49 @@ class WebGPUTextureUtils {
|
|
|
616
630
|
}
|
|
617
631
|
|
|
618
632
|
/**
|
|
619
|
-
*
|
|
633
|
+
* Uploads cube texture image data to the GPU memory.
|
|
620
634
|
*
|
|
621
635
|
* @private
|
|
622
|
-
* @
|
|
636
|
+
* @param {CubeTexture} texture - The cube texture.
|
|
637
|
+
* @param {GPUTexture} textureGPU - The GPU texture.
|
|
638
|
+
* @param {Object} textureDescriptorGPU - The GPU texture descriptor.
|
|
623
639
|
*/
|
|
624
|
-
|
|
640
|
+
_copyCubeMapToTexture( texture, textureGPU, textureDescriptorGPU ) {
|
|
625
641
|
|
|
626
|
-
|
|
642
|
+
const images = texture.images;
|
|
643
|
+
const mipmaps = texture.mipmaps;
|
|
627
644
|
|
|
628
|
-
|
|
645
|
+
for ( let i = 0; i < 6; i ++ ) {
|
|
629
646
|
|
|
630
|
-
const
|
|
631
|
-
timestamp: 0,
|
|
632
|
-
codedWidth: 1,
|
|
633
|
-
codedHeight: 1,
|
|
634
|
-
format: 'RGBA',
|
|
635
|
-
};
|
|
647
|
+
const image = images[ i ];
|
|
636
648
|
|
|
637
|
-
|
|
649
|
+
const flipIndex = texture.flipY === true ? _flipMap[ i ] : i;
|
|
638
650
|
|
|
639
|
-
|
|
651
|
+
if ( image.isDataTexture ) {
|
|
640
652
|
|
|
641
|
-
|
|
653
|
+
this._copyBufferToTexture( image.image, textureGPU, textureDescriptorGPU, flipIndex, texture.flipY );
|
|
642
654
|
|
|
643
|
-
|
|
655
|
+
} else {
|
|
644
656
|
|
|
645
|
-
|
|
646
|
-
* Uploads cube texture image data to the GPU memory.
|
|
647
|
-
*
|
|
648
|
-
* @private
|
|
649
|
-
* @param {Array} images - The cube image data.
|
|
650
|
-
* @param {GPUTexture} textureGPU - The GPU texture.
|
|
651
|
-
* @param {Object} textureDescriptorGPU - The GPU texture descriptor.
|
|
652
|
-
* @param {boolean} flipY - Whether to flip texture data along their vertical axis or not.
|
|
653
|
-
* @param {boolean} premultiplyAlpha - Whether the texture should have its RGB channels premultiplied by the alpha channel or not.
|
|
654
|
-
*/
|
|
655
|
-
_copyCubeMapToTexture( images, textureGPU, textureDescriptorGPU, flipY, premultiplyAlpha ) {
|
|
657
|
+
this._copyImageToTexture( image, textureGPU, textureDescriptorGPU, flipIndex, texture.flipY, texture.premultiplyAlpha );
|
|
656
658
|
|
|
657
|
-
|
|
659
|
+
}
|
|
658
660
|
|
|
659
|
-
|
|
661
|
+
for ( let j = 0; j < mipmaps.length; j ++ ) {
|
|
660
662
|
|
|
661
|
-
|
|
663
|
+
const mipmap = mipmaps[ j ];
|
|
664
|
+
const image = mipmap.images[ i ];
|
|
662
665
|
|
|
663
|
-
|
|
666
|
+
if ( image.isDataTexture ) {
|
|
664
667
|
|
|
665
|
-
|
|
668
|
+
this._copyBufferToTexture( image.image, textureGPU, textureDescriptorGPU, flipIndex, texture.flipY, 0, j + 1 );
|
|
666
669
|
|
|
667
|
-
|
|
670
|
+
} else {
|
|
671
|
+
|
|
672
|
+
this._copyImageToTexture( image, textureGPU, textureDescriptorGPU, flipIndex, texture.flipY, texture.premultiplyAlpha, j + 1 );
|
|
673
|
+
|
|
674
|
+
}
|
|
668
675
|
|
|
669
|
-
this._copyImageToTexture( image, textureGPU, textureDescriptorGPU, flipIndex, flipY, premultiplyAlpha );
|
|
670
676
|
|
|
671
677
|
}
|
|
672
678
|
|
|
@@ -684,23 +690,27 @@ class WebGPUTextureUtils {
|
|
|
684
690
|
* @param {number} originDepth - The origin depth.
|
|
685
691
|
* @param {boolean} flipY - Whether to flip texture data along their vertical axis or not.
|
|
686
692
|
* @param {boolean} premultiplyAlpha - Whether the texture should have its RGB channels premultiplied by the alpha channel or not.
|
|
693
|
+
* @param {number} [mipLevel=0] - The mip level where the data should be copied to.
|
|
687
694
|
*/
|
|
688
|
-
_copyImageToTexture( image, textureGPU, textureDescriptorGPU, originDepth, flipY, premultiplyAlpha ) {
|
|
695
|
+
_copyImageToTexture( image, textureGPU, textureDescriptorGPU, originDepth, flipY, premultiplyAlpha, mipLevel = 0 ) {
|
|
689
696
|
|
|
690
697
|
const device = this.backend.device;
|
|
691
698
|
|
|
699
|
+
const width = ( mipLevel > 0 ) ? image.width : textureDescriptorGPU.size.width;
|
|
700
|
+
const height = ( mipLevel > 0 ) ? image.height : textureDescriptorGPU.size.height;
|
|
701
|
+
|
|
692
702
|
device.queue.copyExternalImageToTexture(
|
|
693
703
|
{
|
|
694
704
|
source: image,
|
|
695
705
|
flipY: flipY
|
|
696
706
|
}, {
|
|
697
707
|
texture: textureGPU,
|
|
698
|
-
mipLevel:
|
|
708
|
+
mipLevel: mipLevel,
|
|
699
709
|
origin: { x: 0, y: 0, z: originDepth },
|
|
700
710
|
premultipliedAlpha: premultiplyAlpha
|
|
701
711
|
}, {
|
|
702
|
-
width:
|
|
703
|
-
height:
|
|
712
|
+
width: width,
|
|
713
|
+
height: height,
|
|
704
714
|
depthOrArrayLayers: 1
|
|
705
715
|
}
|
|
706
716
|
);
|
|
@@ -764,9 +774,10 @@ class WebGPUTextureUtils {
|
|
|
764
774
|
* @param {Object} textureDescriptorGPU - The GPU texture descriptor.
|
|
765
775
|
* @param {number} originDepth - The origin depth.
|
|
766
776
|
* @param {boolean} flipY - Whether to flip texture data along their vertical axis or not.
|
|
767
|
-
* @param {number} [depth=0] -
|
|
777
|
+
* @param {number} [depth=0] - The depth offset when copying array or 3D texture data.
|
|
778
|
+
* @param {number} [mipLevel=0] - The mip level where the data should be copied to.
|
|
768
779
|
*/
|
|
769
|
-
_copyBufferToTexture( image, textureGPU, textureDescriptorGPU, originDepth, flipY, depth = 0 ) {
|
|
780
|
+
_copyBufferToTexture( image, textureGPU, textureDescriptorGPU, originDepth, flipY, depth = 0, mipLevel = 0 ) {
|
|
770
781
|
|
|
771
782
|
// @TODO: Consider to use GPUCommandEncoder.copyBufferToTexture()
|
|
772
783
|
// @TODO: Consider to support valid buffer layouts with other formats like RGB
|
|
@@ -781,7 +792,7 @@ class WebGPUTextureUtils {
|
|
|
781
792
|
device.queue.writeTexture(
|
|
782
793
|
{
|
|
783
794
|
texture: textureGPU,
|
|
784
|
-
mipLevel:
|
|
795
|
+
mipLevel: mipLevel,
|
|
785
796
|
origin: { x: 0, y: 0, z: originDepth }
|
|
786
797
|
},
|
|
787
798
|
data,
|
|
@@ -1029,7 +1040,7 @@ class WebGPUTextureUtils {
|
|
|
1029
1040
|
if ( format === GPUTextureFormat.RG8Snorm ) return Int8Array;
|
|
1030
1041
|
if ( format === GPUTextureFormat.RGBA8Uint ) return Uint8Array;
|
|
1031
1042
|
if ( format === GPUTextureFormat.RGBA8Sint ) return Int8Array;
|
|
1032
|
-
if ( format === GPUTextureFormat.RGBA8Unorm ) return Uint8Array;
|
|
1043
|
+
if ( format === GPUTextureFormat.RGBA8Unorm || format === GPUTextureFormat.RGBA8UnormSRGB ) return Uint8Array;
|
|
1033
1044
|
if ( format === GPUTextureFormat.RGBA8Snorm ) return Int8Array;
|
|
1034
1045
|
|
|
1035
1046
|
|
|
@@ -1054,8 +1065,7 @@ class WebGPUTextureUtils {
|
|
|
1054
1065
|
if ( format === GPUTextureFormat.RGBA32Sint ) return Int32Array;
|
|
1055
1066
|
if ( format === GPUTextureFormat.RGBA32Float ) return Float32Array;
|
|
1056
1067
|
|
|
1057
|
-
if ( format === GPUTextureFormat.BGRA8Unorm ) return Uint8Array;
|
|
1058
|
-
if ( format === GPUTextureFormat.BGRA8UnormSRGB ) return Uint8Array;
|
|
1068
|
+
if ( format === GPUTextureFormat.BGRA8Unorm || format === GPUTextureFormat.BGRA8UnormSRGB ) return Uint8Array;
|
|
1059
1069
|
if ( format === GPUTextureFormat.RGB10A2Unorm ) return Uint32Array;
|
|
1060
1070
|
if ( format === GPUTextureFormat.RGB9E5UFloat ) return Uint32Array;
|
|
1061
1071
|
if ( format === GPUTextureFormat.RG11B10UFloat ) return Uint32Array;
|
|
@@ -1115,6 +1125,7 @@ export function getFormat( texture, device = null ) {
|
|
|
1115
1125
|
|
|
1116
1126
|
switch ( format ) {
|
|
1117
1127
|
|
|
1128
|
+
case RGB_S3TC_DXT1_Format:
|
|
1118
1129
|
case RGBA_S3TC_DXT1_Format:
|
|
1119
1130
|
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.BC1RGBAUnormSRGB : GPUTextureFormat.BC1RGBAUnorm;
|
|
1120
1131
|
break;
|
|
@@ -1127,7 +1138,28 @@ export function getFormat( texture, device = null ) {
|
|
|
1127
1138
|
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.BC3RGBAUnormSRGB : GPUTextureFormat.BC3RGBAUnorm;
|
|
1128
1139
|
break;
|
|
1129
1140
|
|
|
1141
|
+
case RED_RGTC1_Format:
|
|
1142
|
+
formatGPU = GPUTextureFormat.BC4RUnorm;
|
|
1143
|
+
break;
|
|
1144
|
+
|
|
1145
|
+
case SIGNED_RED_RGTC1_Format:
|
|
1146
|
+
formatGPU = GPUTextureFormat.BC4RSnorm;
|
|
1147
|
+
break;
|
|
1148
|
+
|
|
1149
|
+
case RED_GREEN_RGTC2_Format:
|
|
1150
|
+
formatGPU = GPUTextureFormat.BC5RGUnorm;
|
|
1151
|
+
break;
|
|
1152
|
+
|
|
1153
|
+
case SIGNED_RED_GREEN_RGTC2_Format:
|
|
1154
|
+
formatGPU = GPUTextureFormat.BC5RGSnorm;
|
|
1155
|
+
break;
|
|
1156
|
+
|
|
1157
|
+
case RGBA_BPTC_Format:
|
|
1158
|
+
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.BC7RGBAUnormSRGB : GPUTextureFormat.BC7RGBAUnorm;
|
|
1159
|
+
break;
|
|
1160
|
+
|
|
1130
1161
|
case RGB_ETC2_Format:
|
|
1162
|
+
case RGB_ETC1_Format:
|
|
1131
1163
|
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ETC2RGB8UnormSRGB : GPUTextureFormat.ETC2RGB8Unorm;
|
|
1132
1164
|
break;
|
|
1133
1165
|
|
|
@@ -1254,6 +1286,10 @@ export function getFormat( texture, device = null ) {
|
|
|
1254
1286
|
formatGPU = GPUTextureFormat.RGB9E5UFloat;
|
|
1255
1287
|
break;
|
|
1256
1288
|
|
|
1289
|
+
case UnsignedInt101111Type:
|
|
1290
|
+
formatGPU = GPUTextureFormat.RG11B10UFloat;
|
|
1291
|
+
break;
|
|
1292
|
+
|
|
1257
1293
|
default:
|
|
1258
1294
|
console.error( 'WebGPURenderer: Unsupported texture type with RGBFormat.', type );
|
|
1259
1295
|
|
|
@@ -46,10 +46,10 @@ class WebGPUTimestampQueryPool extends TimestampQueryPool {
|
|
|
46
46
|
/**
|
|
47
47
|
* Allocates a pair of queries for a given render context.
|
|
48
48
|
*
|
|
49
|
-
* @param {
|
|
49
|
+
* @param {string} uid - A unique identifier for the render context.
|
|
50
50
|
* @returns {?number} The base offset for the allocated queries, or null if allocation failed.
|
|
51
51
|
*/
|
|
52
|
-
allocateQueriesForContext(
|
|
52
|
+
allocateQueriesForContext( uid ) {
|
|
53
53
|
|
|
54
54
|
if ( ! this.trackTimestamp || this.isDisposed ) return null;
|
|
55
55
|
|
|
@@ -63,7 +63,7 @@ class WebGPUTimestampQueryPool extends TimestampQueryPool {
|
|
|
63
63
|
const baseOffset = this.currentQueryIndex;
|
|
64
64
|
this.currentQueryIndex += 2;
|
|
65
65
|
|
|
66
|
-
this.queryOffsets.set(
|
|
66
|
+
this.queryOffsets.set( uid, baseOffset );
|
|
67
67
|
return baseOffset;
|
|
68
68
|
|
|
69
69
|
}
|
|
@@ -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
|
|