super-three 0.169.1 → 0.170.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/three.cjs +24628 -24228
- package/build/three.core.js +37002 -0
- package/build/three.core.min.js +6 -0
- package/build/three.module.js +10519 -47108
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +533 -0
- package/build/three.tsl.min.js +6 -0
- package/build/three.webgpu.js +17071 -53583
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +17134 -53623
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +3 -3
- package/examples/jsm/animation/MMDAnimationHelper.js +2 -0
- package/examples/jsm/animation/MMDPhysics.js +2 -0
- package/examples/jsm/capabilities/WebGPU.js +1 -10
- package/examples/jsm/controls/ArcballControls.js +25 -21
- package/examples/jsm/controls/OrbitControls.js +41 -9
- package/examples/jsm/controls/PointerLockControls.js +2 -5
- package/examples/jsm/controls/TransformControls.js +22 -6
- package/examples/jsm/csm/CSM.js +2 -2
- package/examples/jsm/csm/CSMFrustum.js +7 -4
- package/examples/jsm/csm/CSMHelper.js +2 -0
- package/examples/jsm/csm/CSMShadowNode.js +437 -0
- package/examples/jsm/curves/NURBSCurve.js +34 -3
- package/examples/jsm/exporters/GLTFExporter.js +138 -71
- package/examples/jsm/exporters/KTX2Exporter.js +35 -12
- package/examples/jsm/exporters/MMDExporter.js +6 -0
- package/examples/jsm/exporters/USDZExporter.js +21 -3
- package/examples/jsm/geometries/DecalGeometry.js +70 -21
- package/examples/jsm/geometries/InstancedPointsGeometry.js +2 -0
- package/examples/jsm/helpers/TextureHelperGPU.js +175 -0
- package/examples/jsm/interactive/HTMLMesh.js +1 -0
- package/examples/jsm/lighting/TiledLighting.js +18 -0
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +1 -1
- package/examples/jsm/lines/LineGeometry.js +25 -0
- package/examples/jsm/lines/LineMaterial.js +0 -1
- package/examples/jsm/lines/LineSegmentsGeometry.js +2 -0
- package/examples/jsm/lines/webgpu/Line2.js +2 -1
- package/examples/jsm/lines/webgpu/LineSegments2.js +2 -16
- package/examples/jsm/lines/webgpu/Wireframe.js +57 -0
- package/examples/jsm/loaders/3DMLoader.js +1 -0
- package/examples/jsm/loaders/3MFLoader.js +91 -0
- package/examples/jsm/loaders/FBXLoader.js +12 -2
- package/examples/jsm/loaders/GLTFLoader.js +2 -0
- package/examples/jsm/loaders/KTX2Loader.js +143 -49
- package/examples/jsm/loaders/LDrawLoader.js +22 -136
- package/examples/jsm/loaders/LottieLoader.js +1 -0
- package/examples/jsm/loaders/MMDLoader.js +3 -0
- package/examples/jsm/loaders/MaterialXLoader.js +2 -2
- package/examples/jsm/materials/LDrawConditionalLineMaterial.js +143 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +114 -0
- package/examples/jsm/math/ColorSpaces.js +76 -0
- package/examples/jsm/misc/ProgressiveLightMap.js +52 -40
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +293 -0
- package/examples/jsm/misc/VolumeSlice.js +1 -0
- package/examples/jsm/objects/InstancedPoints.js +2 -4
- package/examples/jsm/objects/LensflareMesh.js +4 -2
- package/examples/jsm/objects/SkyMesh.js +5 -3
- package/examples/jsm/objects/Water2Mesh.js +7 -3
- package/examples/jsm/objects/WaterMesh.js +12 -10
- package/examples/jsm/postprocessing/AfterimagePass.js +14 -3
- package/examples/jsm/postprocessing/SSRPass.js +6 -0
- package/examples/jsm/renderers/CSS2DRenderer.js +6 -3
- package/examples/jsm/renderers/CSS3DRenderer.js +7 -4
- package/examples/jsm/shaders/FXAAShader.js +225 -224
- package/examples/jsm/transpiler/AST.js +2 -2
- package/examples/jsm/transpiler/GLSLDecoder.js +57 -25
- package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
- package/examples/jsm/transpiler/TSLEncoder.js +11 -6
- package/{src/nodes → examples/jsm/tsl}/display/AfterImageNode.js +18 -21
- package/{src/nodes → examples/jsm/tsl}/display/AnaglyphPassNode.js +2 -6
- package/{src/nodes → examples/jsm/tsl}/display/AnamorphicNode.js +12 -18
- package/{src/nodes → examples/jsm/tsl}/display/BleachBypass.js +1 -3
- package/{src/nodes → examples/jsm/tsl}/display/BloomNode.js +12 -41
- package/{src/nodes → examples/jsm/tsl}/display/DenoiseNode.js +60 -47
- package/{src/nodes → examples/jsm/tsl}/display/DepthOfFieldNode.js +4 -9
- package/{src/nodes → examples/jsm/tsl}/display/DotScreenNode.js +2 -9
- package/examples/jsm/tsl/display/FXAANode.js +316 -0
- package/{src/nodes → examples/jsm/tsl}/display/FilmNode.js +4 -7
- package/{src/nodes → examples/jsm/tsl}/display/GTAONode.js +73 -78
- package/{src/nodes → examples/jsm/tsl}/display/GaussianBlurNode.js +78 -42
- package/examples/jsm/tsl/display/LensflareNode.js +161 -0
- package/{src/nodes → examples/jsm/tsl}/display/Lut3DNode.js +3 -5
- package/{src/nodes → examples/jsm/tsl}/display/MotionBlur.js +2 -3
- package/examples/jsm/tsl/display/OutlineNode.js +434 -0
- package/{src/nodes → examples/jsm/tsl}/display/ParallaxBarrierPassNode.js +2 -5
- package/{src/nodes → examples/jsm/tsl}/display/PixelationPassNode.js +5 -17
- package/{src/nodes → examples/jsm/tsl}/display/RGBShiftNode.js +2 -6
- package/examples/jsm/tsl/display/SMAANode.js +620 -0
- package/{src/nodes → examples/jsm/tsl}/display/SSAAPassNode.js +10 -25
- package/examples/jsm/tsl/display/SSRNode.js +366 -0
- package/{src/nodes → examples/jsm/tsl}/display/Sepia.js +1 -2
- package/{src/nodes → examples/jsm/tsl}/display/SobelOperatorNode.js +4 -12
- package/{src/nodes → examples/jsm/tsl}/display/StereoCompositePassNode.js +9 -11
- package/{src/nodes → examples/jsm/tsl}/display/StereoPassNode.js +10 -11
- package/examples/jsm/tsl/display/TRAAPassNode.js +355 -0
- package/{src/nodes → examples/jsm/tsl}/display/TransitionNode.js +3 -7
- package/examples/jsm/tsl/display/hashBlur.js +24 -0
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +389 -0
- package/examples/jsm/utils/SceneOptimizer.js +410 -0
- package/examples/jsm/utils/UVsDebug.js +1 -1
- package/examples/jsm/utils/{TextureUtilsGPU.js → WebGPUTextureUtils.js} +2 -1
- package/examples/jsm/webxr/OculusHandPointerModel.js +21 -21
- package/examples/jsm/webxr/Text2D.js +6 -6
- package/package.json +4 -4
- package/src/Three.Core.js +178 -0
- package/src/Three.TSL.js +526 -0
- package/src/Three.WebGPU.Nodes.js +9 -186
- package/src/Three.WebGPU.js +8 -186
- package/src/Three.js +1 -177
- package/src/animation/AnimationClip.js +2 -2
- package/src/animation/AnimationObjectGroup.js +2 -2
- package/src/audio/Audio.js +38 -0
- package/src/cameras/PerspectiveCamera.js +6 -6
- package/src/cameras/StereoCamera.js +2 -2
- package/src/constants.js +1 -6
- package/src/core/BufferGeometry.js +48 -8
- package/src/core/InterleavedBuffer.js +4 -4
- package/src/core/Object3D.js +2 -2
- package/src/extras/core/Curve.js +3 -3
- package/src/extras/core/Shape.js +2 -2
- package/src/geometries/CylinderGeometry.js +2 -2
- package/src/geometries/EdgesGeometry.js +2 -2
- package/src/geometries/LatheGeometry.js +2 -2
- package/src/lights/SpotLightShadow.js +2 -2
- package/src/materials/LineDashedMaterial.js +0 -1
- package/src/materials/Material.js +2 -2
- package/src/materials/MeshPhongMaterial.js +1 -1
- package/src/materials/MeshPhysicalMaterial.js +2 -2
- package/src/materials/MeshStandardMaterial.js +2 -2
- package/src/materials/nodes/Line2NodeMaterial.js +32 -13
- package/src/materials/nodes/LineDashedNodeMaterial.js +4 -2
- package/src/materials/nodes/NodeMaterial.js +93 -23
- package/src/materials/nodes/SpriteNodeMaterial.js +11 -2
- package/src/materials/nodes/manager/NodeMaterialObserver.js +119 -7
- package/src/math/ColorManagement.js +143 -102
- package/src/math/Line3.js +2 -2
- package/src/math/Quaternion.js +2 -2
- package/src/math/Spherical.js +3 -3
- package/src/math/Vector2.js +7 -7
- package/src/math/Vector3.js +9 -9
- package/src/math/Vector4.js +22 -9
- package/src/nodes/Nodes.js +2 -21
- package/src/nodes/TSL.js +9 -25
- package/src/nodes/accessors/Arrays.js +27 -0
- package/src/nodes/accessors/BuiltinNode.js +26 -0
- package/src/nodes/accessors/Camera.js +0 -1
- package/src/nodes/accessors/ClippingNode.js +76 -42
- package/src/nodes/accessors/InstanceNode.js +17 -20
- package/src/nodes/accessors/InstancedMeshNode.js +26 -0
- package/src/nodes/accessors/Lights.js +32 -0
- package/src/nodes/accessors/SceneNode.js +35 -1
- package/src/nodes/accessors/StorageBufferNode.js +61 -19
- package/src/nodes/accessors/StorageTextureNode.js +10 -4
- package/src/nodes/accessors/TextureNode.js +1 -1
- package/src/nodes/accessors/VelocityNode.js +13 -3
- package/src/nodes/code/FunctionCallNode.js +16 -5
- package/src/nodes/code/ScriptableNode.js +4 -4
- package/src/nodes/core/Node.js +1 -0
- package/src/nodes/core/NodeBuilder.js +31 -14
- package/src/nodes/core/NodeUtils.js +28 -0
- package/src/nodes/core/VarNode.js +15 -3
- package/src/nodes/core/constants.js +6 -0
- package/src/nodes/display/BlendModes.js +99 -0
- package/src/nodes/display/ColorAdjustment.js +53 -4
- package/src/nodes/display/ColorSpaceFunctions.js +5 -5
- package/src/nodes/display/ColorSpaceNode.js +27 -39
- package/src/nodes/display/PassNode.js +6 -4
- package/src/nodes/display/ToneMappingNode.js +1 -1
- package/src/nodes/display/ToonOutlinePassNode.js +3 -3
- package/src/nodes/display/ViewportDepthNode.js +48 -1
- package/src/nodes/functions/PhysicalLightingModel.js +21 -15
- package/src/nodes/functions/material/getAlphaHashThreshold.js +70 -0
- package/src/nodes/functions/material/getGeometryRoughness.js +8 -2
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +22 -0
- package/src/nodes/gpgpu/ComputeNode.js +9 -1
- package/src/nodes/lighting/AnalyticLightNode.js +23 -419
- package/src/nodes/lighting/LightsNode.js +24 -12
- package/src/nodes/lighting/PointLightNode.js +41 -22
- package/src/nodes/lighting/PointShadowNode.js +254 -0
- package/src/nodes/lighting/RectAreaLightNode.js +3 -0
- package/src/nodes/lighting/ShadowNode.js +593 -0
- package/src/nodes/lighting/SpotLightNode.js +14 -2
- package/src/nodes/utils/LoopNode.js +2 -2
- package/src/nodes/utils/Oscillators.js +6 -0
- package/src/nodes/utils/PostProcessingUtils.js +89 -0
- package/src/nodes/utils/RTTNode.js +9 -1
- package/src/nodes/utils/ReflectorNode.js +101 -15
- package/src/nodes/utils/StorageArrayElementNode.js +2 -2
- package/src/nodes/utils/Timer.js +29 -0
- package/src/objects/BatchedMesh.js +472 -296
- package/src/objects/ClippingGroup.js +19 -0
- package/src/objects/Skeleton.js +2 -2
- package/src/renderers/WebGLRenderer.js +183 -109
- package/src/renderers/common/Animation.js +23 -11
- package/src/renderers/common/Attributes.js +4 -0
- package/src/renderers/common/Backend.js +2 -0
- package/src/renderers/common/Background.js +15 -5
- package/src/renderers/common/Bindings.js +23 -6
- package/src/renderers/common/ClippingContext.js +77 -85
- package/src/renderers/common/Constants.js +2 -1
- package/src/renderers/common/Geometries.js +20 -0
- package/src/renderers/common/IndirectStorageBufferAttribute.js +15 -0
- package/src/renderers/common/Lighting.js +45 -0
- package/src/renderers/common/PostProcessingUtils.js +86 -0
- package/src/renderers/common/RenderList.js +48 -17
- package/src/renderers/common/RenderLists.js +4 -2
- package/src/renderers/common/RenderObject.js +45 -28
- package/src/renderers/common/RenderObjects.js +12 -6
- package/src/renderers/common/Renderer.js +222 -77
- package/src/renderers/common/Textures.js +41 -17
- package/src/renderers/common/UniformsGroup.js +16 -4
- package/src/renderers/common/extras/PMREMGenerator.js +89 -13
- package/src/renderers/common/nodes/NodeLibrary.js +2 -15
- package/src/renderers/common/nodes/NodeStorageBuffer.js +2 -3
- package/src/renderers/common/nodes/NodeUniform.js +42 -0
- package/src/renderers/common/nodes/Nodes.js +2 -2
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +4 -24
- package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +2 -2
- package/src/renderers/webgl/WebGLBackground.js +20 -1
- package/src/renderers/webgl/WebGLBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLCapabilities.js +0 -7
- package/src/renderers/webgl/WebGLGeometries.js +0 -28
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLProgram.js +24 -28
- package/src/renderers/webgl/WebGLPrograms.js +5 -2
- package/src/renderers/webgl/WebGLState.js +37 -1
- package/src/renderers/webgl/WebGLTextures.js +29 -12
- package/src/renderers/webgl-fallback/WebGLBackend.js +111 -37
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +2 -7
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +43 -12
- package/src/renderers/webgl-fallback/utils/WebGLState.js +26 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +37 -9
- package/src/renderers/webgpu/WebGPUBackend.js +152 -56
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +1 -1
- package/src/renderers/webgpu/WebGPURenderer.js +1 -1
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +0 -8
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +13 -34
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +192 -92
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +12 -4
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +15 -2
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +72 -7
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +29 -9
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +29 -7
- package/src/renderers/webgpu/utils/WebGPUUtils.js +0 -1
- package/src/renderers/webxr/WebXRManager.js +4 -4
- package/src/textures/Source.js +2 -2
- package/src/textures/Texture.js +2 -2
- package/examples/jsm/cameras/CinematicCamera.js +0 -208
- package/src/nodes/display/BlendMode.js +0 -54
- package/src/nodes/display/FXAANode.js +0 -332
- package/src/nodes/utils/OscNode.js +0 -85
- package/src/nodes/utils/TimerNode.js +0 -97
- /package/examples/jsm/utils/{TextureUtils.js → WebGLTextureUtils.js} +0 -0
|
@@ -55,12 +55,13 @@ class GLSLNodeBuilder extends NodeBuilder {
|
|
|
55
55
|
this.uniformGroups = {};
|
|
56
56
|
this.transforms = [];
|
|
57
57
|
this.extensions = {};
|
|
58
|
+
this.builtins = { vertex: [], fragment: [], compute: [] };
|
|
58
59
|
|
|
59
60
|
this.useComparisonMethod = true;
|
|
60
61
|
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
|
|
64
|
+
needsToWorkingColorSpace( texture ) {
|
|
64
65
|
|
|
65
66
|
return texture.isVideoTexture === true && texture.colorSpace !== NoColorSpace;
|
|
66
67
|
|
|
@@ -123,7 +124,6 @@ ${ flowData.code }
|
|
|
123
124
|
|
|
124
125
|
let format = isInteger ? RedIntegerFormat : RedFormat;
|
|
125
126
|
|
|
126
|
-
|
|
127
127
|
if ( itemSize === 2 ) {
|
|
128
128
|
|
|
129
129
|
format = isInteger ? RGIntegerFormat : RGFormat;
|
|
@@ -201,7 +201,6 @@ ${ flowData.code }
|
|
|
201
201
|
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
-
|
|
205
204
|
const nodeUniform = this.getUniformFromNode( attribute.pboNode, 'texture', this.shaderStage, this.context.label );
|
|
206
205
|
const textureName = this.getPropertyName( nodeUniform );
|
|
207
206
|
|
|
@@ -571,7 +570,7 @@ ${ flowData.code }
|
|
|
571
570
|
for ( const varying of varyings ) {
|
|
572
571
|
|
|
573
572
|
if ( shaderStage === 'compute' ) varying.needsInterpolation = true;
|
|
574
|
-
const type = varying.type;
|
|
573
|
+
const type = this.getType( varying.type );
|
|
575
574
|
const flat = type.includes( 'int' ) || type.includes( 'uv' ) || type.includes( 'iv' ) ? 'flat ' : '';
|
|
576
575
|
|
|
577
576
|
snippet += `${flat}${varying.needsInterpolation ? 'out' : '/*out*/'} ${type} ${varying.name};\n`;
|
|
@@ -584,7 +583,7 @@ ${ flowData.code }
|
|
|
584
583
|
|
|
585
584
|
if ( varying.needsInterpolation ) {
|
|
586
585
|
|
|
587
|
-
const type = varying.type;
|
|
586
|
+
const type = this.getType( varying.type );
|
|
588
587
|
const flat = type.includes( 'int' ) || type.includes( 'uv' ) || type.includes( 'iv' ) ? 'flat ' : '';
|
|
589
588
|
|
|
590
589
|
snippet += `${flat}in ${type} ${varying.name};\n`;
|
|
@@ -595,6 +594,12 @@ ${ flowData.code }
|
|
|
595
594
|
|
|
596
595
|
}
|
|
597
596
|
|
|
597
|
+
for ( const builtin of this.builtins[ shaderStage ] ) {
|
|
598
|
+
|
|
599
|
+
snippet += `${builtin};\n`;
|
|
600
|
+
|
|
601
|
+
}
|
|
602
|
+
|
|
598
603
|
return snippet;
|
|
599
604
|
|
|
600
605
|
}
|
|
@@ -701,24 +706,42 @@ ${ flowData.code }
|
|
|
701
706
|
|
|
702
707
|
}
|
|
703
708
|
|
|
709
|
+
getClipDistance() {
|
|
710
|
+
|
|
711
|
+
return 'gl_ClipDistance';
|
|
712
|
+
|
|
713
|
+
}
|
|
714
|
+
|
|
704
715
|
isAvailable( name ) {
|
|
705
716
|
|
|
706
717
|
let result = supports[ name ];
|
|
707
718
|
|
|
708
719
|
if ( result === undefined ) {
|
|
709
720
|
|
|
710
|
-
|
|
721
|
+
let extensionName;
|
|
711
722
|
|
|
712
|
-
|
|
723
|
+
result = false;
|
|
713
724
|
|
|
714
|
-
|
|
725
|
+
switch ( name ) {
|
|
715
726
|
|
|
716
|
-
|
|
717
|
-
|
|
727
|
+
case 'float32Filterable':
|
|
728
|
+
extensionName = 'OES_texture_float_linear';
|
|
729
|
+
break;
|
|
718
730
|
|
|
719
|
-
|
|
731
|
+
case 'clipDistance':
|
|
732
|
+
extensionName = 'WEBGL_clip_cull_distance';
|
|
733
|
+
break;
|
|
720
734
|
|
|
721
|
-
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
if ( extensionName !== undefined ) {
|
|
738
|
+
|
|
739
|
+
const extensions = this.renderer.backend.extensions;
|
|
740
|
+
|
|
741
|
+
if ( extensions.has( extensionName ) ) {
|
|
742
|
+
|
|
743
|
+
extensions.get( extensionName );
|
|
744
|
+
result = true;
|
|
722
745
|
|
|
723
746
|
}
|
|
724
747
|
|
|
@@ -738,6 +761,14 @@ ${ flowData.code }
|
|
|
738
761
|
|
|
739
762
|
}
|
|
740
763
|
|
|
764
|
+
enableHardwareClipping( planeCount ) {
|
|
765
|
+
|
|
766
|
+
this.enableExtension( 'GL_ANGLE_clip_cull_distance', 'require' );
|
|
767
|
+
|
|
768
|
+
this.builtins[ 'vertex' ].push( `out float gl_ClipDistance[ ${ planeCount } ]` );
|
|
769
|
+
|
|
770
|
+
}
|
|
771
|
+
|
|
741
772
|
registerTransform( varyingName, attributeNode ) {
|
|
742
773
|
|
|
743
774
|
this.transforms.push( { varyingName, attributeNode } );
|
|
@@ -41,6 +41,7 @@ class WebGLState {
|
|
|
41
41
|
this.currentStencilZPass = null;
|
|
42
42
|
this.currentStencilMask = null;
|
|
43
43
|
this.currentLineWidth = null;
|
|
44
|
+
this.currentClippingPlanes = 0;
|
|
44
45
|
|
|
45
46
|
this.currentBoundFramebuffers = {};
|
|
46
47
|
this.currentDrawbuffers = new WeakMap();
|
|
@@ -478,7 +479,7 @@ class WebGLState {
|
|
|
478
479
|
|
|
479
480
|
}
|
|
480
481
|
|
|
481
|
-
setMaterial( material, frontFaceCW ) {
|
|
482
|
+
setMaterial( material, frontFaceCW, hardwareClippingPlanes ) {
|
|
482
483
|
|
|
483
484
|
const { gl } = this;
|
|
484
485
|
|
|
@@ -516,6 +517,30 @@ class WebGLState {
|
|
|
516
517
|
? this.enable( gl.SAMPLE_ALPHA_TO_COVERAGE )
|
|
517
518
|
: this.disable( gl.SAMPLE_ALPHA_TO_COVERAGE );
|
|
518
519
|
|
|
520
|
+
if ( hardwareClippingPlanes > 0 ) {
|
|
521
|
+
|
|
522
|
+
if ( this.currentClippingPlanes !== hardwareClippingPlanes ) {
|
|
523
|
+
|
|
524
|
+
const CLIP_DISTANCE0_WEBGL = 0x3000;
|
|
525
|
+
|
|
526
|
+
for ( let i = 0; i < 8; i ++ ) {
|
|
527
|
+
|
|
528
|
+
if ( i < hardwareClippingPlanes ) {
|
|
529
|
+
|
|
530
|
+
this.enable( CLIP_DISTANCE0_WEBGL + i );
|
|
531
|
+
|
|
532
|
+
} else {
|
|
533
|
+
|
|
534
|
+
this.disable( CLIP_DISTANCE0_WEBGL + i );
|
|
535
|
+
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
}
|
|
543
|
+
|
|
519
544
|
}
|
|
520
545
|
|
|
521
546
|
setPolygonOffset( polygonOffset, factor, units ) {
|
|
@@ -415,7 +415,10 @@ class WebGLTextureUtils {
|
|
|
415
415
|
|
|
416
416
|
return source.image.data;
|
|
417
417
|
|
|
418
|
-
} else if (
|
|
418
|
+
} else if ( ( typeof HTMLImageElement !== 'undefined' && source instanceof HTMLImageElement ) ||
|
|
419
|
+
( typeof HTMLCanvasElement !== 'undefined' && source instanceof HTMLCanvasElement ) ||
|
|
420
|
+
( typeof ImageBitmap !== 'undefined' && source instanceof ImageBitmap ) ||
|
|
421
|
+
source instanceof OffscreenCanvas ) {
|
|
419
422
|
|
|
420
423
|
return source;
|
|
421
424
|
|
|
@@ -445,8 +448,7 @@ class WebGLTextureUtils {
|
|
|
445
448
|
|
|
446
449
|
if ( glFormat !== null ) {
|
|
447
450
|
|
|
448
|
-
gl.compressedTexSubImage3D( gl.TEXTURE_2D_ARRAY, i, 0, 0, 0, mipmap.width, mipmap.height, image.depth, glFormat, mipmap.data
|
|
449
|
-
|
|
451
|
+
gl.compressedTexSubImage3D( gl.TEXTURE_2D_ARRAY, i, 0, 0, 0, mipmap.width, mipmap.height, image.depth, glFormat, mipmap.data );
|
|
450
452
|
|
|
451
453
|
} else {
|
|
452
454
|
|
|
@@ -607,9 +609,9 @@ class WebGLTextureUtils {
|
|
|
607
609
|
|
|
608
610
|
const { textureGPU: dstTextureGPU, glTextureType, glType, glFormat } = backend.get( dstTexture );
|
|
609
611
|
|
|
610
|
-
|
|
611
612
|
let width, height, minX, minY;
|
|
612
613
|
let dstX, dstY;
|
|
614
|
+
|
|
613
615
|
if ( srcRegion !== null ) {
|
|
614
616
|
|
|
615
617
|
width = srcRegion.max.x - srcRegion.min.x;
|
|
@@ -660,20 +662,46 @@ class WebGLTextureUtils {
|
|
|
660
662
|
gl.pixelStorei( gl.UNPACK_SKIP_PIXELS, minX );
|
|
661
663
|
gl.pixelStorei( gl.UNPACK_SKIP_ROWS, minY );
|
|
662
664
|
|
|
665
|
+
if ( srcTexture.isRenderTargetTexture || srcTexture.isDepthTexture ) {
|
|
666
|
+
|
|
667
|
+
const srcTextureData = backend.get( srcTexture );
|
|
668
|
+
const dstTextureData = backend.get( dstTexture );
|
|
669
|
+
|
|
670
|
+
const srcRenderContextData = backend.get( srcTextureData.renderTarget );
|
|
671
|
+
const dstRenderContextData = backend.get( dstTextureData.renderTarget );
|
|
672
|
+
|
|
673
|
+
const srcFramebuffer = srcRenderContextData.framebuffers[ srcTextureData.cacheKey ];
|
|
674
|
+
const dstFramebuffer = dstRenderContextData.framebuffers[ dstTextureData.cacheKey ];
|
|
675
|
+
|
|
676
|
+
state.bindFramebuffer( gl.READ_FRAMEBUFFER, srcFramebuffer );
|
|
677
|
+
state.bindFramebuffer( gl.DRAW_FRAMEBUFFER, dstFramebuffer );
|
|
678
|
+
|
|
679
|
+
let mask = gl.COLOR_BUFFER_BIT;
|
|
663
680
|
|
|
664
|
-
|
|
681
|
+
if ( srcTexture.isDepthTexture ) mask = gl.DEPTH_BUFFER_BIT;
|
|
665
682
|
|
|
666
|
-
gl.
|
|
683
|
+
gl.blitFramebuffer( minX, minY, width, height, dstX, dstY, width, height, mask, gl.NEAREST );
|
|
684
|
+
|
|
685
|
+
state.bindFramebuffer( gl.READ_FRAMEBUFFER, null );
|
|
686
|
+
state.bindFramebuffer( gl.DRAW_FRAMEBUFFER, null );
|
|
667
687
|
|
|
668
688
|
} else {
|
|
669
689
|
|
|
670
|
-
if ( srcTexture.
|
|
690
|
+
if ( srcTexture.isDataTexture ) {
|
|
671
691
|
|
|
672
|
-
gl.
|
|
692
|
+
gl.texSubImage2D( gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image.data );
|
|
673
693
|
|
|
674
694
|
} else {
|
|
675
695
|
|
|
676
|
-
|
|
696
|
+
if ( srcTexture.isCompressedTexture ) {
|
|
697
|
+
|
|
698
|
+
gl.compressedTexSubImage2D( gl.TEXTURE_2D, level, dstX, dstY, image.width, image.height, glFormat, image.data );
|
|
699
|
+
|
|
700
|
+
} else {
|
|
701
|
+
|
|
702
|
+
gl.texSubImage2D( gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image );
|
|
703
|
+
|
|
704
|
+
}
|
|
677
705
|
|
|
678
706
|
}
|
|
679
707
|
|
|
@@ -64,7 +64,7 @@ class WebGPUBackend extends Backend {
|
|
|
64
64
|
powerPreference: parameters.powerPreference
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
-
const adapter = await navigator.gpu.requestAdapter( adapterOptions );
|
|
67
|
+
const adapter = ( typeof navigator !== 'undefined' ) ? await navigator.gpu.requestAdapter( adapterOptions ) : null;
|
|
68
68
|
|
|
69
69
|
if ( adapter === null ) {
|
|
70
70
|
|
|
@@ -101,6 +101,19 @@ class WebGPUBackend extends Backend {
|
|
|
101
101
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
device.lost.then( ( info ) => {
|
|
105
|
+
|
|
106
|
+
const deviceLossInfo = {
|
|
107
|
+
api: 'WebGPU',
|
|
108
|
+
message: info.message || 'Unknown reason',
|
|
109
|
+
reason: info.reason || null,
|
|
110
|
+
originalEvent: info
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
renderer.onDeviceLost( deviceLossInfo );
|
|
114
|
+
|
|
115
|
+
} );
|
|
116
|
+
|
|
104
117
|
const context = ( parameters.context !== undefined ) ? parameters.context : renderer.domElement.getContext( 'webgpu' );
|
|
105
118
|
|
|
106
119
|
this.device = device;
|
|
@@ -151,11 +164,16 @@ class WebGPUBackend extends Backend {
|
|
|
151
164
|
colorAttachments: [ {
|
|
152
165
|
view: null
|
|
153
166
|
} ],
|
|
154
|
-
depthStencilAttachment: {
|
|
155
|
-
view: this.textureUtils.getDepthBuffer( renderer.depth, renderer.stencil ).createView()
|
|
156
|
-
}
|
|
157
167
|
};
|
|
158
168
|
|
|
169
|
+
if ( this.renderer.depth === true || this.renderer.stencil === true ) {
|
|
170
|
+
|
|
171
|
+
descriptor.depthStencilAttachment = {
|
|
172
|
+
view: this.textureUtils.getDepthBuffer( renderer.depth, renderer.stencil ).createView()
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
}
|
|
176
|
+
|
|
159
177
|
const colorAttachment = descriptor.colorAttachments[ 0 ];
|
|
160
178
|
|
|
161
179
|
if ( this.renderer.samples > 0 ) {
|
|
@@ -263,17 +281,22 @@ class WebGPUBackend extends Backend {
|
|
|
263
281
|
|
|
264
282
|
}
|
|
265
283
|
|
|
266
|
-
const depthTextureData = this.get( renderContext.depthTexture );
|
|
267
|
-
|
|
268
|
-
const depthStencilAttachment = {
|
|
269
|
-
view: depthTextureData.texture.createView()
|
|
270
|
-
};
|
|
271
284
|
|
|
272
285
|
descriptor = {
|
|
273
286
|
colorAttachments,
|
|
274
|
-
depthStencilAttachment
|
|
275
287
|
};
|
|
276
288
|
|
|
289
|
+
if ( renderContext.depth ) {
|
|
290
|
+
|
|
291
|
+
const depthTextureData = this.get( renderContext.depthTexture );
|
|
292
|
+
|
|
293
|
+
const depthStencilAttachment = {
|
|
294
|
+
view: depthTextureData.texture.createView()
|
|
295
|
+
};
|
|
296
|
+
descriptor.depthStencilAttachment = depthStencilAttachment;
|
|
297
|
+
|
|
298
|
+
}
|
|
299
|
+
|
|
277
300
|
descriptors[ cacheKey ] = descriptor;
|
|
278
301
|
|
|
279
302
|
renderTargetData.width = renderTarget.width;
|
|
@@ -309,7 +332,7 @@ class WebGPUBackend extends Backend {
|
|
|
309
332
|
|
|
310
333
|
//
|
|
311
334
|
|
|
312
|
-
occlusionQuerySet = device.createQuerySet( { type: 'occlusion', count: occlusionQueryCount } );
|
|
335
|
+
occlusionQuerySet = device.createQuerySet( { type: 'occlusion', count: occlusionQueryCount, label: `occlusionQuerySet_${ renderContext.id }` } );
|
|
313
336
|
|
|
314
337
|
renderContextData.occlusionQuerySet = occlusionQuerySet;
|
|
315
338
|
renderContextData.occlusionQueryIndex = 0;
|
|
@@ -825,6 +848,12 @@ class WebGPUBackend extends Backend {
|
|
|
825
848
|
|
|
826
849
|
}
|
|
827
850
|
|
|
851
|
+
async waitForGPU() {
|
|
852
|
+
|
|
853
|
+
await this.device.queue.onSubmittedWorkDone();
|
|
854
|
+
|
|
855
|
+
}
|
|
856
|
+
|
|
828
857
|
// render object
|
|
829
858
|
|
|
830
859
|
draw( renderObject, info ) {
|
|
@@ -836,9 +865,9 @@ class WebGPUBackend extends Backend {
|
|
|
836
865
|
const currentSets = renderContextData.currentSets;
|
|
837
866
|
const passEncoderGPU = renderContextData.currentPass;
|
|
838
867
|
|
|
839
|
-
const
|
|
868
|
+
const drawParams = renderObject.getDrawParameters();
|
|
840
869
|
|
|
841
|
-
if (
|
|
870
|
+
if ( drawParams === null ) return;
|
|
842
871
|
|
|
843
872
|
// pipeline
|
|
844
873
|
|
|
@@ -960,17 +989,41 @@ class WebGPUBackend extends Backend {
|
|
|
960
989
|
|
|
961
990
|
} else if ( hasIndex === true ) {
|
|
962
991
|
|
|
963
|
-
const { vertexCount: indexCount, instanceCount, firstVertex: firstIndex } =
|
|
992
|
+
const { vertexCount: indexCount, instanceCount, firstVertex: firstIndex } = drawParams;
|
|
993
|
+
|
|
994
|
+
const indirect = renderObject.getIndirect();
|
|
995
|
+
|
|
996
|
+
if ( indirect !== null ) {
|
|
997
|
+
|
|
998
|
+
const buffer = this.get( indirect ).buffer;
|
|
999
|
+
|
|
1000
|
+
passEncoderGPU.drawIndexedIndirect( buffer, 0 );
|
|
1001
|
+
|
|
1002
|
+
} else {
|
|
1003
|
+
|
|
1004
|
+
passEncoderGPU.drawIndexed( indexCount, instanceCount, firstIndex, 0, 0 );
|
|
964
1005
|
|
|
965
|
-
|
|
1006
|
+
}
|
|
966
1007
|
|
|
967
1008
|
info.update( object, indexCount, instanceCount );
|
|
968
1009
|
|
|
969
1010
|
} else {
|
|
970
1011
|
|
|
971
|
-
const { vertexCount, instanceCount, firstVertex } =
|
|
1012
|
+
const { vertexCount, instanceCount, firstVertex } = drawParams;
|
|
1013
|
+
|
|
1014
|
+
const indirect = renderObject.getIndirect();
|
|
972
1015
|
|
|
973
|
-
|
|
1016
|
+
if ( indirect !== null ) {
|
|
1017
|
+
|
|
1018
|
+
const buffer = this.get( indirect ).buffer;
|
|
1019
|
+
|
|
1020
|
+
passEncoderGPU.drawIndirect( buffer, 0 );
|
|
1021
|
+
|
|
1022
|
+
} else {
|
|
1023
|
+
|
|
1024
|
+
passEncoderGPU.draw( vertexCount, instanceCount, firstVertex, 0 );
|
|
1025
|
+
|
|
1026
|
+
}
|
|
974
1027
|
|
|
975
1028
|
info.update( object, vertexCount, instanceCount );
|
|
976
1029
|
|
|
@@ -1008,7 +1061,7 @@ class WebGPUBackend extends Backend {
|
|
|
1008
1061
|
data.sampleCount !== sampleCount || data.colorSpace !== colorSpace ||
|
|
1009
1062
|
data.colorFormat !== colorFormat || data.depthStencilFormat !== depthStencilFormat ||
|
|
1010
1063
|
data.primitiveTopology !== primitiveTopology ||
|
|
1011
|
-
data.clippingContextCacheKey !== renderObject.
|
|
1064
|
+
data.clippingContextCacheKey !== renderObject.clippingContextCacheKey
|
|
1012
1065
|
) {
|
|
1013
1066
|
|
|
1014
1067
|
data.material = material; data.materialVersion = material.version;
|
|
@@ -1026,7 +1079,7 @@ class WebGPUBackend extends Backend {
|
|
|
1026
1079
|
data.colorFormat = colorFormat;
|
|
1027
1080
|
data.depthStencilFormat = depthStencilFormat;
|
|
1028
1081
|
data.primitiveTopology = primitiveTopology;
|
|
1029
|
-
data.clippingContextCacheKey = renderObject.
|
|
1082
|
+
data.clippingContextCacheKey = renderObject.clippingContextCacheKey;
|
|
1030
1083
|
|
|
1031
1084
|
needsUpdate = true;
|
|
1032
1085
|
|
|
@@ -1056,7 +1109,8 @@ class WebGPUBackend extends Backend {
|
|
|
1056
1109
|
utils.getSampleCountRenderContext( renderContext ),
|
|
1057
1110
|
utils.getCurrentColorSpace( renderContext ), utils.getCurrentColorFormat( renderContext ), utils.getCurrentDepthStencilFormat( renderContext ),
|
|
1058
1111
|
utils.getPrimitiveTopology( object, material ),
|
|
1059
|
-
renderObject.
|
|
1112
|
+
renderObject.getGeometryCacheKey(),
|
|
1113
|
+
renderObject.clippingContextCacheKey
|
|
1060
1114
|
].join();
|
|
1061
1115
|
|
|
1062
1116
|
}
|
|
@@ -1120,9 +1174,9 @@ class WebGPUBackend extends Backend {
|
|
|
1120
1174
|
|
|
1121
1175
|
if ( ! renderContextData.timeStampQuerySet ) {
|
|
1122
1176
|
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
const timeStampQuerySet = this.device.createQuerySet( { type: 'timestamp', count: 2 } );
|
|
1177
|
+
|
|
1178
|
+
const type = renderContext.isComputeNode ? 'compute' : 'render';
|
|
1179
|
+
const timeStampQuerySet = this.device.createQuerySet( { type: 'timestamp', count: 2, label: `timestamp_${type}_${renderContext.id}` } );
|
|
1126
1180
|
|
|
1127
1181
|
const timestampWrites = {
|
|
1128
1182
|
querySet: timeStampQuerySet,
|
|
@@ -1130,9 +1184,7 @@ class WebGPUBackend extends Backend {
|
|
|
1130
1184
|
endOfPassWriteIndex: 1, // Write timestamp in index 1 when pass ends.
|
|
1131
1185
|
};
|
|
1132
1186
|
|
|
1133
|
-
Object.assign( descriptor, {
|
|
1134
|
-
timestampWrites,
|
|
1135
|
-
} );
|
|
1187
|
+
Object.assign( descriptor, { timestampWrites } );
|
|
1136
1188
|
|
|
1137
1189
|
renderContextData.timeStampQuerySet = timeStampQuerySet;
|
|
1138
1190
|
|
|
@@ -1163,18 +1215,21 @@ class WebGPUBackend extends Backend {
|
|
|
1163
1215
|
label: 'timestamp result buffer',
|
|
1164
1216
|
size: size,
|
|
1165
1217
|
usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ,
|
|
1166
|
-
} )
|
|
1167
|
-
isMappingPending: false,
|
|
1218
|
+
} )
|
|
1168
1219
|
};
|
|
1169
1220
|
|
|
1170
1221
|
}
|
|
1171
1222
|
|
|
1172
|
-
const { resolveBuffer, resultBuffer
|
|
1223
|
+
const { resolveBuffer, resultBuffer } = renderContextData.currentTimestampQueryBuffers;
|
|
1173
1224
|
|
|
1174
|
-
if ( isMappingPending === true ) return;
|
|
1175
1225
|
|
|
1176
1226
|
encoder.resolveQuerySet( renderContextData.timeStampQuerySet, 0, 2, resolveBuffer, 0 );
|
|
1177
|
-
|
|
1227
|
+
|
|
1228
|
+
if ( resultBuffer.mapState === 'unmapped' ) {
|
|
1229
|
+
|
|
1230
|
+
encoder.copyBufferToBuffer( resolveBuffer, 0, resultBuffer, 0, size );
|
|
1231
|
+
|
|
1232
|
+
}
|
|
1178
1233
|
|
|
1179
1234
|
}
|
|
1180
1235
|
|
|
@@ -1186,25 +1241,26 @@ class WebGPUBackend extends Backend {
|
|
|
1186
1241
|
|
|
1187
1242
|
if ( renderContextData.currentTimestampQueryBuffers === undefined ) return;
|
|
1188
1243
|
|
|
1189
|
-
const { resultBuffer
|
|
1244
|
+
const { resultBuffer } = renderContextData.currentTimestampQueryBuffers;
|
|
1190
1245
|
|
|
1191
|
-
|
|
1246
|
+
await this.device.queue.onSubmittedWorkDone();
|
|
1192
1247
|
|
|
1193
|
-
|
|
1248
|
+
if ( resultBuffer.mapState === 'unmapped' ) {
|
|
1194
1249
|
|
|
1195
|
-
|
|
1250
|
+
resultBuffer.mapAsync( GPUMapMode.READ ).then( () => {
|
|
1196
1251
|
|
|
1197
|
-
|
|
1198
|
-
|
|
1252
|
+
const times = new BigUint64Array( resultBuffer.getMappedRange() );
|
|
1253
|
+
const duration = Number( times[ 1 ] - times[ 0 ] ) / 1000000;
|
|
1199
1254
|
|
|
1200
1255
|
|
|
1201
|
-
|
|
1256
|
+
this.renderer.info.updateTimestamp( type, duration );
|
|
1202
1257
|
|
|
1203
|
-
|
|
1258
|
+
resultBuffer.unmap();
|
|
1204
1259
|
|
|
1205
|
-
renderContextData.currentTimestampQueryBuffers.isMappingPending = false;
|
|
1206
1260
|
|
|
1207
|
-
|
|
1261
|
+
} );
|
|
1262
|
+
|
|
1263
|
+
}
|
|
1208
1264
|
|
|
1209
1265
|
}
|
|
1210
1266
|
|
|
@@ -1287,15 +1343,15 @@ class WebGPUBackend extends Backend {
|
|
|
1287
1343
|
|
|
1288
1344
|
// bindings
|
|
1289
1345
|
|
|
1290
|
-
createBindings( bindGroup ) {
|
|
1346
|
+
createBindings( bindGroup, bindings, cacheIndex, version ) {
|
|
1291
1347
|
|
|
1292
|
-
this.bindingUtils.createBindings( bindGroup );
|
|
1348
|
+
this.bindingUtils.createBindings( bindGroup, bindings, cacheIndex, version );
|
|
1293
1349
|
|
|
1294
1350
|
}
|
|
1295
1351
|
|
|
1296
|
-
updateBindings( bindGroup ) {
|
|
1352
|
+
updateBindings( bindGroup, bindings, cacheIndex, version ) {
|
|
1297
1353
|
|
|
1298
|
-
this.bindingUtils.createBindings( bindGroup );
|
|
1354
|
+
this.bindingUtils.createBindings( bindGroup, bindings, cacheIndex, version );
|
|
1299
1355
|
|
|
1300
1356
|
}
|
|
1301
1357
|
|
|
@@ -1325,6 +1381,12 @@ class WebGPUBackend extends Backend {
|
|
|
1325
1381
|
|
|
1326
1382
|
}
|
|
1327
1383
|
|
|
1384
|
+
createIndirectStorageAttribute( attribute ) {
|
|
1385
|
+
|
|
1386
|
+
this.attributeUtils.createAttribute( attribute, GPUBufferUsage.STORAGE | GPUBufferUsage.INDIRECT | GPUBufferUsage.COPY_SRC | GPUBufferUsage.COPY_DST );
|
|
1387
|
+
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1328
1390
|
updateAttribute( attribute ) {
|
|
1329
1391
|
|
|
1330
1392
|
this.attributeUtils.updateAttribute( attribute );
|
|
@@ -1422,8 +1484,6 @@ class WebGPUBackend extends Backend {
|
|
|
1422
1484
|
|
|
1423
1485
|
const renderContextData = this.get( renderContext );
|
|
1424
1486
|
|
|
1425
|
-
const { encoder, descriptor } = renderContextData;
|
|
1426
|
-
|
|
1427
1487
|
let sourceGPU = null;
|
|
1428
1488
|
|
|
1429
1489
|
if ( renderContext.renderTarget ) {
|
|
@@ -1462,12 +1522,24 @@ class WebGPUBackend extends Backend {
|
|
|
1462
1522
|
|
|
1463
1523
|
}
|
|
1464
1524
|
|
|
1465
|
-
|
|
1525
|
+
let encoder;
|
|
1526
|
+
|
|
1527
|
+
if ( renderContextData.currentPass ) {
|
|
1528
|
+
|
|
1529
|
+
renderContextData.currentPass.end();
|
|
1530
|
+
|
|
1531
|
+
encoder = renderContextData.encoder;
|
|
1532
|
+
|
|
1533
|
+
} else {
|
|
1534
|
+
|
|
1535
|
+
encoder = this.device.createCommandEncoder( { label: 'copyFramebufferToTexture_' + texture.id } );
|
|
1536
|
+
|
|
1537
|
+
}
|
|
1466
1538
|
|
|
1467
1539
|
encoder.copyTextureToTexture(
|
|
1468
1540
|
{
|
|
1469
1541
|
texture: sourceGPU,
|
|
1470
|
-
origin:
|
|
1542
|
+
origin: [ rectangle.x, rectangle.y, 0 ],
|
|
1471
1543
|
},
|
|
1472
1544
|
{
|
|
1473
1545
|
texture: destinationGPU
|
|
@@ -1480,17 +1552,41 @@ class WebGPUBackend extends Backend {
|
|
|
1480
1552
|
|
|
1481
1553
|
if ( texture.generateMipmaps ) this.textureUtils.generateMipmaps( texture );
|
|
1482
1554
|
|
|
1483
|
-
|
|
1555
|
+
if ( renderContextData.currentPass ) {
|
|
1484
1556
|
|
|
1485
|
-
descriptor
|
|
1557
|
+
const { descriptor } = renderContextData;
|
|
1486
1558
|
|
|
1487
|
-
|
|
1559
|
+
for ( let i = 0; i < descriptor.colorAttachments.length; i ++ ) {
|
|
1488
1560
|
|
|
1489
|
-
|
|
1490
|
-
if ( renderContext.stencil ) descriptor.depthStencilAttachment.stencilLoadOp = GPULoadOp.Load;
|
|
1561
|
+
descriptor.colorAttachments[ i ].loadOp = GPULoadOp.Load;
|
|
1491
1562
|
|
|
1492
|
-
|
|
1493
|
-
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
if ( renderContext.depth ) descriptor.depthStencilAttachment.depthLoadOp = GPULoadOp.Load;
|
|
1566
|
+
if ( renderContext.stencil ) descriptor.depthStencilAttachment.stencilLoadOp = GPULoadOp.Load;
|
|
1567
|
+
|
|
1568
|
+
renderContextData.currentPass = encoder.beginRenderPass( descriptor );
|
|
1569
|
+
renderContextData.currentSets = { attributes: {}, bindingGroups: [], pipeline: null, index: null };
|
|
1570
|
+
|
|
1571
|
+
if ( renderContext.viewport ) {
|
|
1572
|
+
|
|
1573
|
+
this.updateViewport( renderContext );
|
|
1574
|
+
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1577
|
+
if ( renderContext.scissor ) {
|
|
1578
|
+
|
|
1579
|
+
const { x, y, width, height } = renderContext.scissorValue;
|
|
1580
|
+
|
|
1581
|
+
renderContextData.currentPass.setScissorRect( x, y, width, height );
|
|
1582
|
+
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
} else {
|
|
1586
|
+
|
|
1587
|
+
this.device.queue.submit( [ encoder.finish() ] );
|
|
1588
|
+
|
|
1589
|
+
}
|
|
1494
1590
|
|
|
1495
1591
|
}
|
|
1496
1592
|
|
|
@@ -45,7 +45,7 @@ class WebGPURenderer extends Renderer {
|
|
|
45
45
|
//super( new Proxy( backend, debugHandler ) );
|
|
46
46
|
super( backend, parameters );
|
|
47
47
|
|
|
48
|
-
this.
|
|
48
|
+
this.library = new StandardNodeLibrary();
|
|
49
49
|
|
|
50
50
|
this.isWebGPURenderer = true;
|
|
51
51
|
|
|
@@ -22,11 +22,6 @@ import { IESSpotLightNode } from '../../../nodes/Nodes.js';
|
|
|
22
22
|
import { LinearToneMapping, ReinhardToneMapping, CineonToneMapping, ACESFilmicToneMapping, AgXToneMapping, NeutralToneMapping } from '../../../constants.js';
|
|
23
23
|
import { linearToneMapping, reinhardToneMapping, cineonToneMapping, acesFilmicToneMapping, agxToneMapping, neutralToneMapping } from '../../../nodes/display/ToneMappingFunctions.js';
|
|
24
24
|
|
|
25
|
-
// Color Space
|
|
26
|
-
import { LinearSRGBColorSpace, SRGBColorSpace } from '../../../constants.js';
|
|
27
|
-
import { linearSRGBTosRGB, sRGBToLinearSRGB } from '../../../nodes/display/ColorSpaceFunctions.js';
|
|
28
|
-
import { getColorSpaceMethod } from '../../../nodes/display/ColorSpaceNode.js';
|
|
29
|
-
|
|
30
25
|
class BasicNodeLibrary extends NodeLibrary {
|
|
31
26
|
|
|
32
27
|
constructor() {
|
|
@@ -49,9 +44,6 @@ class BasicNodeLibrary extends NodeLibrary {
|
|
|
49
44
|
this.addToneMapping( agxToneMapping, AgXToneMapping );
|
|
50
45
|
this.addToneMapping( neutralToneMapping, NeutralToneMapping );
|
|
51
46
|
|
|
52
|
-
this.addColorSpace( linearSRGBTosRGB, getColorSpaceMethod( LinearSRGBColorSpace, SRGBColorSpace ) );
|
|
53
|
-
this.addColorSpace( sRGBToLinearSRGB, getColorSpaceMethod( SRGBColorSpace, LinearSRGBColorSpace ) );
|
|
54
|
-
|
|
55
47
|
}
|
|
56
48
|
|
|
57
49
|
}
|