@plastic-software/three 0.178.0 → 0.179.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/build/three.cjs +856 -196
- package/build/three.core.js +647 -123
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +211 -76
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +70 -21
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +1796 -557
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +1754 -557
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +1 -2
- package/examples/jsm/capabilities/WebGPU.js +1 -1
- package/examples/jsm/csm/CSMShadowNode.js +4 -4
- package/examples/jsm/environments/RoomEnvironment.js +8 -3
- package/examples/jsm/exporters/USDZExporter.js +676 -299
- package/examples/jsm/geometries/RoundedBoxGeometry.js +47 -8
- package/examples/jsm/interactive/HTMLMesh.js +5 -3
- package/examples/jsm/libs/meshopt_decoder.module.js +75 -58
- package/examples/jsm/lights/LightProbeGenerator.js +14 -3
- package/examples/jsm/loaders/EXRLoader.js +210 -22
- package/examples/jsm/loaders/FBXLoader.js +1 -1
- package/examples/jsm/loaders/MaterialXLoader.js +212 -30
- package/examples/jsm/loaders/TTFLoader.js +13 -1
- package/examples/jsm/loaders/USDLoader.js +219 -0
- package/examples/jsm/loaders/USDZLoader.js +4 -892
- package/examples/jsm/loaders/usd/USDAParser.js +741 -0
- package/examples/jsm/loaders/usd/USDCParser.js +17 -0
- package/examples/jsm/objects/LensflareMesh.js +3 -3
- package/examples/jsm/objects/SkyMesh.js +2 -2
- package/examples/jsm/physics/RapierPhysics.js +14 -5
- package/examples/jsm/postprocessing/GTAOPass.js +10 -9
- package/examples/jsm/postprocessing/OutlinePass.js +17 -17
- package/examples/jsm/postprocessing/SSAOPass.js +10 -9
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +11 -2
- package/examples/jsm/transpiler/GLSLDecoder.js +2 -2
- package/examples/jsm/tsl/display/BloomNode.js +8 -7
- package/examples/jsm/tsl/display/GaussianBlurNode.js +6 -8
- package/examples/jsm/tsl/display/{TRAAPassNode.js → TRAANode.js} +181 -172
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +1 -1
- package/package.json +1 -1
- package/src/Three.Core.js +1 -0
- package/src/Three.TSL.js +69 -20
- package/src/animation/KeyframeTrack.js +1 -1
- package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
- package/src/animation/tracks/StringKeyframeTrack.js +1 -1
- package/src/cameras/Camera.js +14 -0
- package/src/cameras/OrthographicCamera.js +1 -1
- package/src/cameras/PerspectiveCamera.js +1 -1
- package/src/constants.js +1 -1
- package/{examples/jsm/misc → src/core}/Timer.js +4 -42
- package/src/extras/PMREMGenerator.js +11 -0
- package/src/helpers/CameraHelper.js +41 -11
- package/src/helpers/SkeletonHelper.js +35 -6
- package/src/lights/LightShadow.js +21 -8
- package/src/lights/PointLightShadow.js +1 -1
- package/src/loaders/FileLoader.js +25 -2
- package/src/loaders/ImageBitmapLoader.js +23 -0
- package/src/loaders/Loader.js +14 -0
- package/src/loaders/LoadingManager.js +23 -0
- package/src/materials/MeshBasicMaterial.js +1 -1
- package/src/materials/nodes/Line2NodeMaterial.js +0 -8
- package/src/materials/nodes/NodeMaterial.js +1 -1
- package/src/materials/nodes/PointsNodeMaterial.js +5 -0
- package/src/materials/nodes/manager/NodeMaterialObserver.js +87 -2
- package/src/math/Frustum.js +19 -8
- package/src/math/FrustumArray.js +10 -5
- package/src/math/Line3.js +129 -2
- package/src/math/Matrix4.js +48 -27
- package/src/math/Spherical.js +2 -2
- package/src/nodes/Nodes.js +1 -0
- package/src/nodes/TSL.js +1 -0
- package/src/nodes/accessors/Camera.js +12 -12
- package/src/nodes/accessors/Normal.js +11 -11
- package/src/nodes/accessors/ReferenceNode.js +18 -3
- package/src/nodes/accessors/SceneNode.js +1 -1
- package/src/nodes/accessors/StorageTextureNode.js +1 -1
- package/src/nodes/accessors/TextureNode.js +12 -0
- package/src/nodes/core/ArrayNode.js +12 -0
- package/src/nodes/core/AssignNode.js +3 -0
- package/src/nodes/core/ContextNode.js +20 -1
- package/src/nodes/core/Node.js +14 -2
- package/src/nodes/core/NodeBuilder.js +25 -20
- package/src/nodes/core/NodeUtils.js +4 -1
- package/src/nodes/core/StackNode.js +42 -0
- package/src/nodes/core/UniformNode.js +63 -5
- package/src/nodes/core/VarNode.js +91 -2
- package/src/nodes/display/PassNode.js +148 -2
- package/src/nodes/display/ViewportTextureNode.js +67 -7
- package/src/nodes/functions/PhysicalLightingModel.js +2 -2
- package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
- package/src/nodes/gpgpu/ComputeNode.js +67 -23
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +28 -3
- package/src/nodes/lighting/ProjectorLightNode.js +19 -6
- package/src/nodes/lighting/ShadowFilterNode.js +1 -1
- package/src/nodes/materialx/MaterialXNodes.js +131 -2
- package/src/nodes/materialx/lib/mx_noise.js +165 -1
- package/src/nodes/math/ConditionalNode.js +1 -1
- package/src/nodes/math/MathNode.js +78 -54
- package/src/nodes/math/OperatorNode.js +22 -22
- package/src/nodes/tsl/TSLCore.js +64 -9
- package/src/nodes/utils/DebugNode.js +1 -1
- package/src/nodes/utils/EventNode.js +83 -0
- package/src/nodes/utils/RTTNode.js +9 -0
- package/src/objects/BatchedMesh.js +4 -2
- package/src/renderers/WebGLRenderer.js +21 -22
- package/src/renderers/common/Bindings.js +19 -18
- package/src/renderers/common/Color4.js +2 -2
- package/src/renderers/common/PostProcessing.js +60 -5
- package/src/renderers/common/Renderer.js +18 -15
- package/src/renderers/common/SampledTexture.js +3 -71
- package/src/renderers/common/Sampler.js +79 -0
- package/src/renderers/common/Storage3DTexture.js +21 -0
- package/src/renderers/common/StorageArrayTexture.js +21 -0
- package/src/renderers/common/StorageTexture.js +19 -0
- package/src/renderers/common/Textures.js +19 -3
- package/src/renderers/common/XRManager.js +26 -8
- package/src/renderers/common/nodes/NodeSampledTexture.js +0 -12
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +20 -2
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +11 -2
- package/src/renderers/webgl/WebGLCapabilities.js +2 -2
- package/src/renderers/webgl/WebGLMaterials.js +6 -6
- package/src/renderers/webgl/WebGLProgram.js +22 -16
- package/src/renderers/webgl/WebGLPrograms.js +4 -4
- package/src/renderers/webgl/WebGLShadowMap.js +11 -1
- package/src/renderers/webgl/WebGLTextures.js +19 -7
- package/src/renderers/webgl-fallback/WebGLBackend.js +22 -12
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +2 -2
- package/src/renderers/webgpu/WebGPUBackend.js +54 -15
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +53 -73
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +35 -31
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +11 -64
- package/src/renderers/webgpu/utils/WebGPUUtils.js +2 -17
- package/src/renderers/webxr/WebXRDepthSensing.js +6 -10
- package/src/renderers/webxr/WebXRManager.js +68 -8
- package/src/textures/ExternalTexture.js +45 -0
- package/src/textures/FramebufferTexture.js +2 -2
- package/src/textures/Source.js +11 -1
- package/src/textures/VideoTexture.js +30 -2
|
@@ -81,8 +81,17 @@ void main() {
|
|
|
81
81
|
|
|
82
82
|
#include <logdepthbuf_fragment>
|
|
83
83
|
|
|
84
|
-
// Higher precision equivalent of gl_FragCoord.z
|
|
85
|
-
|
|
84
|
+
// Higher precision equivalent of gl_FragCoord.z
|
|
85
|
+
|
|
86
|
+
#ifdef USE_REVERSEDEPTHBUF
|
|
87
|
+
|
|
88
|
+
float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
|
|
89
|
+
|
|
90
|
+
#else
|
|
91
|
+
|
|
92
|
+
float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
|
|
93
|
+
|
|
94
|
+
#endif
|
|
86
95
|
|
|
87
96
|
#if DEPTH_PACKING == 3200
|
|
88
97
|
|
|
@@ -92,7 +92,7 @@ function WebGLCapabilities( gl, extensions, parameters, utils ) {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
const logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;
|
|
95
|
-
const
|
|
95
|
+
const reversedDepthBuffer = parameters.reversedDepthBuffer === true && extensions.has( 'EXT_clip_control' );
|
|
96
96
|
|
|
97
97
|
const maxTextures = gl.getParameter( gl.MAX_TEXTURE_IMAGE_UNITS );
|
|
98
98
|
const maxVertexTextures = gl.getParameter( gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS );
|
|
@@ -120,7 +120,7 @@ function WebGLCapabilities( gl, extensions, parameters, utils ) {
|
|
|
120
120
|
|
|
121
121
|
precision: precision,
|
|
122
122
|
logarithmicDepthBuffer: logarithmicDepthBuffer,
|
|
123
|
-
|
|
123
|
+
reversedDepthBuffer: reversedDepthBuffer,
|
|
124
124
|
|
|
125
125
|
maxTextures: maxTextures,
|
|
126
126
|
maxVertexTextures: maxVertexTextures,
|
|
@@ -141,17 +141,17 @@ function WebGLMaterials( renderer, properties ) {
|
|
|
141
141
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
|
|
144
|
+
if ( material.texture3DMatrix ) {
|
|
145
145
|
|
|
146
|
-
|
|
146
|
+
uniforms.texture3DMatrix.value.copy( material.texture3DMatrix );
|
|
147
147
|
|
|
148
|
-
|
|
148
|
+
}
|
|
149
149
|
|
|
150
|
-
|
|
150
|
+
if ( material.triplanarHardness ) {
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
uniforms.triplanarHardness.value = material.triplanarHardness;
|
|
153
153
|
|
|
154
|
-
|
|
154
|
+
}
|
|
155
155
|
|
|
156
156
|
if ( material.alphaMap ) {
|
|
157
157
|
|
|
@@ -57,7 +57,9 @@ function getEncodingComponents( colorSpace ) {
|
|
|
57
57
|
function getShaderErrors( gl, shader, type ) {
|
|
58
58
|
|
|
59
59
|
const status = gl.getShaderParameter( shader, gl.COMPILE_STATUS );
|
|
60
|
-
|
|
60
|
+
|
|
61
|
+
const shaderInfoLog = gl.getShaderInfoLog( shader ) || '';
|
|
62
|
+
const errors = shaderInfoLog.trim();
|
|
61
63
|
|
|
62
64
|
if ( status && errors === '' ) return '';
|
|
63
65
|
|
|
@@ -561,8 +563,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
561
563
|
parameters.bumpMap ? '#define USE_BUMPMAP' : '',
|
|
562
564
|
parameters.normalMap ? '#define USE_NORMALMAP' : '',
|
|
563
565
|
parameters.normalMapMode === TriPlanarMapping ? '#define USE_NORMALMAP_TRIPLANAR' : parameters.normalMapMode === CylindricalMapping ? '#define USE_NORMALMAP_CYLINDRICAL' : parameters.normalMapMode === UVMapping ? '#define USE_NORMALMAP_UV' : '',
|
|
564
|
-
parameters.normalMapObjectSpace && [UVMapping, CylindricalMapping].includes( parameters.normalMapMode ) ? '#define USE_NORMALMAP_OBJECTSPACE' : '',
|
|
565
|
-
parameters.normalMapTangentSpace && [UVMapping, CylindricalMapping].includes( parameters.normalMapMode ) ? '#define USE_NORMALMAP_TANGENTSPACE' : '',
|
|
566
|
+
parameters.normalMapObjectSpace && [ UVMapping, CylindricalMapping ].includes( parameters.normalMapMode ) ? '#define USE_NORMALMAP_OBJECTSPACE' : '',
|
|
567
|
+
parameters.normalMapTangentSpace && [ UVMapping, CylindricalMapping ].includes( parameters.normalMapMode ) ? '#define USE_NORMALMAP_TANGENTSPACE' : '',
|
|
566
568
|
parameters.displacementMap ? '#define USE_DISPLACEMENTMAP' : '',
|
|
567
569
|
parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '',
|
|
568
570
|
|
|
@@ -572,9 +574,9 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
572
574
|
parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '',
|
|
573
575
|
parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '',
|
|
574
576
|
parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '',
|
|
575
|
-
parameters.clearcoatNormalMapMode === TriPlanarMapping ? '#define USE_CLEARCOAT_NORMALMAP_TRIPLANAR'
|
|
576
|
-
|
|
577
|
-
|
|
577
|
+
parameters.clearcoatNormalMapMode === TriPlanarMapping ? '#define USE_CLEARCOAT_NORMALMAP_TRIPLANAR'
|
|
578
|
+
: parameters.clearcoatNormalMapMode === CylindricalMapping ? '#define USE_CLEARCOAT_NORMALMAP_CYLINDRICAL'
|
|
579
|
+
: parameters.clearcoatNormalMapMode === UVMapping ? '#define USE_CLEARCOAT_NORMALMAP_UV' : '',
|
|
578
580
|
|
|
579
581
|
parameters.iridescenceMap ? '#define USE_IRIDESCENCEMAP' : '',
|
|
580
582
|
parameters.iridescenceThicknessMap ? '#define USE_IRIDESCENCE_THICKNESSMAP' : '',
|
|
@@ -662,7 +664,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
662
664
|
parameters.numLightProbes > 0 ? '#define USE_LIGHT_PROBES' : '',
|
|
663
665
|
|
|
664
666
|
parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
|
|
665
|
-
parameters.
|
|
667
|
+
parameters.reversedDepthBuffer ? '#define USE_REVERSEDEPTHBUF' : '',
|
|
666
668
|
|
|
667
669
|
'uniform mat4 modelMatrix;',
|
|
668
670
|
'uniform mat4 modelViewMatrix;',
|
|
@@ -768,8 +770,8 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
768
770
|
parameters.bumpMap ? '#define USE_BUMPMAP' : '',
|
|
769
771
|
parameters.normalMap ? '#define USE_NORMALMAP' : '',
|
|
770
772
|
parameters.normalMapMode === TriPlanarMapping ? '#define USE_NORMALMAP_TRIPLANAR' : parameters.normalMapMode === CylindricalMapping ? '#define USE_NORMALMAP_CYLINDRICAL' : parameters.normalMapMode === UVMapping ? '#define USE_NORMALMAP_UV' : '',
|
|
771
|
-
parameters.normalMapObjectSpace && [UVMapping, CylindricalMapping].includes( parameters.normalMapMode ) ? '#define USE_NORMALMAP_OBJECTSPACE' : '',
|
|
772
|
-
parameters.normalMapTangentSpace && [UVMapping, CylindricalMapping].includes( parameters.normalMapMode ) ? '#define USE_NORMALMAP_TANGENTSPACE' : '',
|
|
773
|
+
parameters.normalMapObjectSpace && [ UVMapping, CylindricalMapping ].includes( parameters.normalMapMode ) ? '#define USE_NORMALMAP_OBJECTSPACE' : '',
|
|
774
|
+
parameters.normalMapTangentSpace && [ UVMapping, CylindricalMapping ].includes( parameters.normalMapMode ) ? '#define USE_NORMALMAP_TANGENTSPACE' : '',
|
|
773
775
|
parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '',
|
|
774
776
|
|
|
775
777
|
parameters.anisotropy ? '#define USE_ANISOTROPY' : '',
|
|
@@ -779,9 +781,9 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
779
781
|
parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '',
|
|
780
782
|
parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '',
|
|
781
783
|
parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '',
|
|
782
|
-
parameters.clearcoatNormalMapMode === TriPlanarMapping ? '#define USE_CLEARCOAT_NORMALMAP_TRIPLANAR'
|
|
783
|
-
|
|
784
|
-
|
|
784
|
+
parameters.clearcoatNormalMapMode === TriPlanarMapping ? '#define USE_CLEARCOAT_NORMALMAP_TRIPLANAR'
|
|
785
|
+
: parameters.clearcoatNormalMapMode === CylindricalMapping ? '#define USE_CLEARCOAT_NORMALMAP_CYLINDRICAL'
|
|
786
|
+
: parameters.clearcoatNormalMapMode === UVMapping ? '#define USE_CLEARCOAT_NORMALMAP_UV' : '',
|
|
785
787
|
|
|
786
788
|
parameters.dispersion ? '#define USE_DISPERSION' : '',
|
|
787
789
|
|
|
@@ -838,7 +840,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
838
840
|
parameters.decodeVideoTextureEmissive ? '#define DECODE_VIDEO_TEXTURE_EMISSIVE' : '',
|
|
839
841
|
|
|
840
842
|
parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
|
|
841
|
-
parameters.
|
|
843
|
+
parameters.reversedDepthBuffer ? '#define USE_REVERSEDEPTHBUF' : '',
|
|
842
844
|
|
|
843
845
|
'uniform mat4 modelViewMatrix;',
|
|
844
846
|
'uniform mat4 viewMatrix;',
|
|
@@ -939,9 +941,13 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
939
941
|
// check for link errors
|
|
940
942
|
if ( renderer.debug.checkShaderErrors ) {
|
|
941
943
|
|
|
942
|
-
const
|
|
943
|
-
const
|
|
944
|
-
const
|
|
944
|
+
const programInfoLog = gl.getProgramInfoLog( program ) || '';
|
|
945
|
+
const vertexShaderInfoLog = gl.getShaderInfoLog( glVertexShader ) || '';
|
|
946
|
+
const fragmentShaderInfoLog = gl.getShaderInfoLog( glFragmentShader ) || '';
|
|
947
|
+
|
|
948
|
+
const programLog = programInfoLog.trim();
|
|
949
|
+
const vertexLog = vertexShaderInfoLog.trim();
|
|
950
|
+
const fragmentLog = fragmentShaderInfoLog.trim();
|
|
945
951
|
|
|
946
952
|
let runnable = true;
|
|
947
953
|
let haveDiagnostics = true;
|
|
@@ -108,7 +108,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
const currentRenderTarget = renderer.getRenderTarget();
|
|
111
|
-
const
|
|
111
|
+
const reversedDepthBuffer = renderer.state.buffers.depth.getReversed();
|
|
112
112
|
|
|
113
113
|
const IS_INSTANCEDMESH = object.isInstancedMesh === true;
|
|
114
114
|
const IS_BATCHEDMESH = object.isBatchedMesh === true;
|
|
@@ -314,7 +314,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
314
314
|
|
|
315
315
|
sizeAttenuation: material.sizeAttenuation === true,
|
|
316
316
|
logarithmicDepthBuffer: logarithmicDepthBuffer,
|
|
317
|
-
|
|
317
|
+
reversedDepthBuffer: reversedDepthBuffer,
|
|
318
318
|
|
|
319
319
|
skinning: object.isSkinnedMesh === true,
|
|
320
320
|
|
|
@@ -447,7 +447,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
447
447
|
array.push( parameters.anisotropyMapUv );
|
|
448
448
|
array.push( parameters.clearcoatMapUv );
|
|
449
449
|
array.push( parameters.clearcoatNormalMapUv );
|
|
450
|
-
array.push( parameters.clearcoatNormalMapMode);
|
|
450
|
+
array.push( parameters.clearcoatNormalMapMode );
|
|
451
451
|
array.push( parameters.clearcoatRoughnessMapUv );
|
|
452
452
|
array.push( parameters.iridescenceMapUv );
|
|
453
453
|
array.push( parameters.iridescenceThicknessMapUv );
|
|
@@ -546,7 +546,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
546
546
|
_programLayers.enable( 2 );
|
|
547
547
|
if ( parameters.logarithmicDepthBuffer )
|
|
548
548
|
_programLayers.enable( 3 );
|
|
549
|
-
if ( parameters.
|
|
549
|
+
if ( parameters.reversedDepthBuffer )
|
|
550
550
|
_programLayers.enable( 4 );
|
|
551
551
|
if ( parameters.skinning )
|
|
552
552
|
_programLayers.enable( 5 );
|
|
@@ -84,7 +84,17 @@ function WebGLShadowMap( renderer, objects, capabilities ) {
|
|
|
84
84
|
|
|
85
85
|
// Set GL state for depth map.
|
|
86
86
|
_state.setBlending( NoBlending );
|
|
87
|
-
|
|
87
|
+
|
|
88
|
+
if ( _state.buffers.depth.getReversed() ) {
|
|
89
|
+
|
|
90
|
+
_state.buffers.color.setClear( 0, 0, 0, 0 );
|
|
91
|
+
|
|
92
|
+
} else {
|
|
93
|
+
|
|
94
|
+
_state.buffers.color.setClear( 1, 1, 1, 1 );
|
|
95
|
+
|
|
96
|
+
}
|
|
97
|
+
|
|
88
98
|
_state.buffers.depth.setTest( true );
|
|
89
99
|
_state.setScissorTest( false );
|
|
90
100
|
|
|
@@ -515,7 +515,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
515
515
|
|
|
516
516
|
if ( texture.isVideoTexture ) updateVideoTexture( texture );
|
|
517
517
|
|
|
518
|
-
if ( texture.isRenderTargetTexture === false && texture.version > 0 && textureProperties.__version !== texture.version ) {
|
|
518
|
+
if ( texture.isRenderTargetTexture === false && texture.isExternalTexture !== true && texture.version > 0 && textureProperties.__version !== texture.version ) {
|
|
519
519
|
|
|
520
520
|
const image = texture.image;
|
|
521
521
|
|
|
@@ -534,6 +534,10 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
534
534
|
|
|
535
535
|
}
|
|
536
536
|
|
|
537
|
+
} else if ( texture.isExternalTexture ) {
|
|
538
|
+
|
|
539
|
+
textureProperties.__webglTexture = texture.sourceTexture ? texture.sourceTexture : null;
|
|
540
|
+
|
|
537
541
|
}
|
|
538
542
|
|
|
539
543
|
state.bindTexture( _gl.TEXTURE_2D, textureProperties.__webglTexture, _gl.TEXTURE0 + slot );
|
|
@@ -544,7 +548,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
544
548
|
|
|
545
549
|
const textureProperties = properties.get( texture );
|
|
546
550
|
|
|
547
|
-
if ( texture.version > 0 && textureProperties.__version !== texture.version ) {
|
|
551
|
+
if ( texture.isRenderTargetTexture === false && texture.version > 0 && textureProperties.__version !== texture.version ) {
|
|
548
552
|
|
|
549
553
|
uploadTexture( textureProperties, texture, slot );
|
|
550
554
|
return;
|
|
@@ -559,7 +563,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
559
563
|
|
|
560
564
|
const textureProperties = properties.get( texture );
|
|
561
565
|
|
|
562
|
-
if ( texture.version > 0 && textureProperties.__version !== texture.version ) {
|
|
566
|
+
if ( texture.isRenderTargetTexture === false && texture.version > 0 && textureProperties.__version !== texture.version ) {
|
|
563
567
|
|
|
564
568
|
uploadTexture( textureProperties, texture, slot );
|
|
565
569
|
return;
|
|
@@ -2002,13 +2006,21 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2002
2006
|
const attachment = textures[ i ];
|
|
2003
2007
|
const attachmentProperties = properties.get( attachment );
|
|
2004
2008
|
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2009
|
+
let glTextureType = _gl.TEXTURE_2D;
|
|
2010
|
+
|
|
2011
|
+
if ( renderTarget.isWebGL3DRenderTarget || renderTarget.isWebGLArrayRenderTarget ) {
|
|
2012
|
+
|
|
2013
|
+
glTextureType = renderTarget.isWebGL3DRenderTarget ? _gl.TEXTURE_3D : _gl.TEXTURE_2D_ARRAY;
|
|
2014
|
+
|
|
2015
|
+
}
|
|
2016
|
+
|
|
2017
|
+
state.bindTexture( glTextureType, attachmentProperties.__webglTexture );
|
|
2018
|
+
setTextureParameters( glTextureType, attachment );
|
|
2019
|
+
setupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, attachment, _gl.COLOR_ATTACHMENT0 + i, glTextureType, 0 );
|
|
2008
2020
|
|
|
2009
2021
|
if ( textureNeedsGenerateMipmaps( attachment ) ) {
|
|
2010
2022
|
|
|
2011
|
-
generateMipmap(
|
|
2023
|
+
generateMipmap( glTextureType );
|
|
2012
2024
|
|
|
2013
2025
|
}
|
|
2014
2026
|
|
|
@@ -13,11 +13,8 @@ import { WebGLBufferRenderer } from './WebGLBufferRenderer.js';
|
|
|
13
13
|
|
|
14
14
|
import { warnOnce } from '../../utils.js';
|
|
15
15
|
import { WebGLCoordinateSystem } from '../../constants.js';
|
|
16
|
-
import { Vector2 } from '../../math/Vector2.js';
|
|
17
16
|
import WebGLTimestampQueryPool from './utils/WebGLTimestampQueryPool.js';
|
|
18
17
|
|
|
19
|
-
const _drawingBufferSize = /*@__PURE__*/ new Vector2();
|
|
20
|
-
|
|
21
18
|
/**
|
|
22
19
|
* A backend implementation targeting WebGL 2.
|
|
23
20
|
*
|
|
@@ -183,7 +180,7 @@ class WebGLBackend extends Backend {
|
|
|
183
180
|
* A unique collection of bindings.
|
|
184
181
|
*
|
|
185
182
|
* @private
|
|
186
|
-
* @type {WeakSet}
|
|
183
|
+
* @type {WeakSet<Array<BindGroup>>}
|
|
187
184
|
*/
|
|
188
185
|
this._knownBindings = new WeakSet();
|
|
189
186
|
|
|
@@ -455,7 +452,7 @@ class WebGLBackend extends Backend {
|
|
|
455
452
|
|
|
456
453
|
} else {
|
|
457
454
|
|
|
458
|
-
const { width, height } = this.getDrawingBufferSize(
|
|
455
|
+
const { width, height } = this.getDrawingBufferSize();
|
|
459
456
|
state.viewport( 0, 0, width, height );
|
|
460
457
|
|
|
461
458
|
}
|
|
@@ -655,7 +652,7 @@ class WebGLBackend extends Backend {
|
|
|
655
652
|
|
|
656
653
|
} else {
|
|
657
654
|
|
|
658
|
-
const { width, height } = this.getDrawingBufferSize(
|
|
655
|
+
const { width, height } = this.getDrawingBufferSize();
|
|
659
656
|
state.viewport( 0, 0, width, height );
|
|
660
657
|
|
|
661
658
|
}
|
|
@@ -915,8 +912,9 @@ class WebGLBackend extends Backend {
|
|
|
915
912
|
* @param {Node} computeNode - The compute node.
|
|
916
913
|
* @param {Array<BindGroup>} bindings - The bindings.
|
|
917
914
|
* @param {ComputePipeline} pipeline - The compute pipeline.
|
|
915
|
+
* @param {number|null} [count=null] - The count of compute invocations. If `null`, the count is determined by the compute node.
|
|
918
916
|
*/
|
|
919
|
-
compute( computeGroup, computeNode, bindings, pipeline ) {
|
|
917
|
+
compute( computeGroup, computeNode, bindings, pipeline, count = null ) {
|
|
920
918
|
|
|
921
919
|
const { state, gl } = this;
|
|
922
920
|
|
|
@@ -953,13 +951,23 @@ class WebGLBackend extends Backend {
|
|
|
953
951
|
gl.bindTransformFeedback( gl.TRANSFORM_FEEDBACK, transformFeedbackGPU );
|
|
954
952
|
gl.beginTransformFeedback( gl.POINTS );
|
|
955
953
|
|
|
954
|
+
count = ( count !== null ) ? count : computeNode.count;
|
|
955
|
+
|
|
956
|
+
if ( Array.isArray( count ) ) {
|
|
957
|
+
|
|
958
|
+
warnOnce( 'WebGLBackend.compute(): The count parameter must be a single number, not an array.' );
|
|
959
|
+
|
|
960
|
+
count = count[ 0 ];
|
|
961
|
+
|
|
962
|
+
}
|
|
963
|
+
|
|
956
964
|
if ( attributes[ 0 ].isStorageInstancedBufferAttribute ) {
|
|
957
965
|
|
|
958
|
-
gl.drawArraysInstanced( gl.POINTS, 0, 1,
|
|
966
|
+
gl.drawArraysInstanced( gl.POINTS, 0, 1, count );
|
|
959
967
|
|
|
960
968
|
} else {
|
|
961
969
|
|
|
962
|
-
gl.drawArrays( gl.POINTS, 0,
|
|
970
|
+
gl.drawArrays( gl.POINTS, 0, count );
|
|
963
971
|
|
|
964
972
|
}
|
|
965
973
|
|
|
@@ -1574,7 +1582,9 @@ class WebGLBackend extends Backend {
|
|
|
1574
1582
|
_getShaderErrors( gl, shader, type ) {
|
|
1575
1583
|
|
|
1576
1584
|
const status = gl.getShaderParameter( shader, gl.COMPILE_STATUS );
|
|
1577
|
-
|
|
1585
|
+
|
|
1586
|
+
const shaderInfoLog = gl.getShaderInfoLog( shader ) || '';
|
|
1587
|
+
const errors = shaderInfoLog.trim();
|
|
1578
1588
|
|
|
1579
1589
|
if ( status && errors === '' ) return '';
|
|
1580
1590
|
|
|
@@ -1606,11 +1616,11 @@ class WebGLBackend extends Backend {
|
|
|
1606
1616
|
|
|
1607
1617
|
const gl = this.gl;
|
|
1608
1618
|
|
|
1609
|
-
const
|
|
1619
|
+
const programInfoLog = gl.getProgramInfoLog( programGPU ) || '';
|
|
1620
|
+
const programLog = programInfoLog.trim();
|
|
1610
1621
|
|
|
1611
1622
|
if ( gl.getProgramParameter( programGPU, gl.LINK_STATUS ) === false ) {
|
|
1612
1623
|
|
|
1613
|
-
|
|
1614
1624
|
if ( typeof this.renderer.debug.onShaderError === 'function' ) {
|
|
1615
1625
|
|
|
1616
1626
|
this.renderer.debug.onShaderError( gl, programGPU, glVertexShader, glFragmentShader );
|
|
@@ -249,7 +249,7 @@ ${ flowData.code }
|
|
|
249
249
|
attribute.pboNode = pbo;
|
|
250
250
|
attribute.pbo = pbo.value;
|
|
251
251
|
|
|
252
|
-
this.getUniformFromNode( attribute.pboNode, 'texture', this.shaderStage, this.context.
|
|
252
|
+
this.getUniformFromNode( attribute.pboNode, 'texture', this.shaderStage, this.context.nodeName );
|
|
253
253
|
|
|
254
254
|
}
|
|
255
255
|
|
|
@@ -293,7 +293,7 @@ ${ flowData.code }
|
|
|
293
293
|
|
|
294
294
|
}
|
|
295
295
|
|
|
296
|
-
const nodeUniform = this.getUniformFromNode( attribute.pboNode, 'texture', this.shaderStage, this.context.
|
|
296
|
+
const nodeUniform = this.getUniformFromNode( attribute.pboNode, 'texture', this.shaderStage, this.context.nodeName );
|
|
297
297
|
const textureName = this.getPropertyName( nodeUniform );
|
|
298
298
|
|
|
299
299
|
this.increaseUsage( indexNode ); // force cache generate to be used as index in x,y
|
|
@@ -1236,7 +1236,7 @@ class WebGPUBackend extends Backend {
|
|
|
1236
1236
|
|
|
1237
1237
|
}
|
|
1238
1238
|
|
|
1239
|
-
if ( supportsDepth && depthStencilAttachment
|
|
1239
|
+
if ( supportsDepth && depthStencilAttachment ) {
|
|
1240
1240
|
|
|
1241
1241
|
if ( depth ) {
|
|
1242
1242
|
|
|
@@ -1255,7 +1255,7 @@ class WebGPUBackend extends Backend {
|
|
|
1255
1255
|
|
|
1256
1256
|
//
|
|
1257
1257
|
|
|
1258
|
-
if ( supportsStencil && depthStencilAttachment
|
|
1258
|
+
if ( supportsStencil && depthStencilAttachment ) {
|
|
1259
1259
|
|
|
1260
1260
|
if ( stencil ) {
|
|
1261
1261
|
|
|
@@ -1298,7 +1298,6 @@ class WebGPUBackend extends Backend {
|
|
|
1298
1298
|
|
|
1299
1299
|
const groupGPU = this.get( computeGroup );
|
|
1300
1300
|
|
|
1301
|
-
|
|
1302
1301
|
const descriptor = {
|
|
1303
1302
|
label: 'computeGroup_' + computeGroup.id
|
|
1304
1303
|
};
|
|
@@ -1318,9 +1317,11 @@ class WebGPUBackend extends Backend {
|
|
|
1318
1317
|
* @param {Node} computeNode - The compute node.
|
|
1319
1318
|
* @param {Array<BindGroup>} bindings - The bindings.
|
|
1320
1319
|
* @param {ComputePipeline} pipeline - The compute pipeline.
|
|
1320
|
+
* @param {Array<number>|number} [dispatchSizeOrCount=null] - Array with [ x, y, z ] values for dispatch or a single number for the count.
|
|
1321
1321
|
*/
|
|
1322
|
-
compute( computeGroup, computeNode, bindings, pipeline ) {
|
|
1322
|
+
compute( computeGroup, computeNode, bindings, pipeline, dispatchSizeOrCount = null ) {
|
|
1323
1323
|
|
|
1324
|
+
const computeNodeData = this.get( computeNode );
|
|
1324
1325
|
const { passEncoderGPU } = this.get( computeGroup );
|
|
1325
1326
|
|
|
1326
1327
|
// pipeline
|
|
@@ -1340,29 +1341,67 @@ class WebGPUBackend extends Backend {
|
|
|
1340
1341
|
|
|
1341
1342
|
}
|
|
1342
1343
|
|
|
1343
|
-
|
|
1344
|
+
let dispatchSize;
|
|
1344
1345
|
|
|
1345
|
-
|
|
1346
|
+
if ( dispatchSizeOrCount === null ) {
|
|
1347
|
+
|
|
1348
|
+
dispatchSizeOrCount = computeNode.count;
|
|
1349
|
+
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
if ( typeof dispatchSizeOrCount === 'number' ) {
|
|
1353
|
+
|
|
1354
|
+
// If a single number is given, we calculate the dispatch size based on the workgroup size
|
|
1355
|
+
|
|
1356
|
+
const count = dispatchSizeOrCount;
|
|
1357
|
+
|
|
1358
|
+
if ( computeNodeData.dispatchSize === undefined || computeNodeData.count !== count ) {
|
|
1359
|
+
|
|
1360
|
+
// cache dispatch size to avoid recalculating it every time
|
|
1361
|
+
|
|
1362
|
+
computeNodeData.dispatchSize = [ 0, 1, 1 ];
|
|
1363
|
+
computeNodeData.count = count;
|
|
1364
|
+
|
|
1365
|
+
const workgroupSize = computeNode.workgroupSize;
|
|
1346
1366
|
|
|
1347
|
-
|
|
1367
|
+
let size = workgroupSize[ 0 ];
|
|
1348
1368
|
|
|
1349
|
-
|
|
1369
|
+
for ( let i = 1; i < workgroupSize.length; i ++ )
|
|
1370
|
+
size *= workgroupSize[ i ];
|
|
1350
1371
|
|
|
1351
|
-
|
|
1372
|
+
const dispatchCount = Math.ceil( count / size );
|
|
1352
1373
|
|
|
1353
|
-
|
|
1354
|
-
|
|
1374
|
+
//
|
|
1375
|
+
|
|
1376
|
+
const maxComputeWorkgroupsPerDimension = this.device.limits.maxComputeWorkgroupsPerDimension;
|
|
1377
|
+
|
|
1378
|
+
dispatchSize = [ dispatchCount, 1, 1 ];
|
|
1379
|
+
|
|
1380
|
+
if ( dispatchCount > maxComputeWorkgroupsPerDimension ) {
|
|
1381
|
+
|
|
1382
|
+
dispatchSize[ 0 ] = Math.min( dispatchCount, maxComputeWorkgroupsPerDimension );
|
|
1383
|
+
dispatchSize[ 1 ] = Math.ceil( dispatchCount / maxComputeWorkgroupsPerDimension );
|
|
1384
|
+
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
computeNodeData.dispatchSize = dispatchSize;
|
|
1388
|
+
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
dispatchSize = computeNodeData.dispatchSize;
|
|
1355
1392
|
|
|
1356
1393
|
} else {
|
|
1357
1394
|
|
|
1358
|
-
dispatchSize
|
|
1395
|
+
dispatchSize = dispatchSizeOrCount;
|
|
1359
1396
|
|
|
1360
1397
|
}
|
|
1361
1398
|
|
|
1399
|
+
//
|
|
1400
|
+
|
|
1362
1401
|
passEncoderGPU.dispatchWorkgroups(
|
|
1363
|
-
dispatchSize
|
|
1364
|
-
dispatchSize
|
|
1365
|
-
dispatchSize
|
|
1402
|
+
dispatchSize[ 0 ],
|
|
1403
|
+
dispatchSize[ 1 ] || 1,
|
|
1404
|
+
dispatchSize[ 2 ] || 1
|
|
1366
1405
|
);
|
|
1367
1406
|
|
|
1368
1407
|
}
|