@needle-tools/three 0.162.12 → 0.169.2
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 +3 -3
- package/build/three.cjs +29789 -1941
- package/build/three.module.js +29095 -1933
- package/build/three.module.min.js +2 -2
- package/build/three.webgpu.js +80003 -0
- package/build/three.webgpu.min.js +6 -0
- package/build/three.webgpu.nodes.js +79951 -0
- package/build/three.webgpu.nodes.min.js +6 -0
- package/examples/jsm/Addons.js +2 -5
- package/examples/jsm/animation/AnimationClipCreator.js +1 -1
- package/examples/jsm/animation/CCDIKSolver.js +4 -2
- package/examples/jsm/capabilities/WebGL.js +27 -21
- package/examples/jsm/controls/ArcballControls.js +174 -158
- package/examples/jsm/controls/DragControls.js +260 -132
- package/examples/jsm/controls/FirstPersonControls.js +175 -163
- package/examples/jsm/controls/FlyControls.js +194 -188
- package/examples/jsm/controls/OrbitControls.js +790 -797
- package/examples/jsm/controls/PointerLockControls.js +24 -15
- package/examples/jsm/controls/TrackballControls.js +469 -448
- package/examples/jsm/controls/TransformControls.js +98 -63
- package/examples/jsm/csm/CSMShader.js +4 -4
- package/examples/jsm/effects/AnaglyphEffect.js +6 -13
- package/examples/jsm/effects/ParallaxBarrierEffect.js +17 -11
- package/examples/jsm/effects/StereoEffect.js +6 -1
- package/examples/jsm/environments/RoomEnvironment.js +2 -6
- package/examples/jsm/exporters/DRACOExporter.js +4 -2
- package/examples/jsm/exporters/EXRExporter.js +19 -11
- package/examples/jsm/exporters/GLTFExporter.js +77 -8
- package/examples/jsm/exporters/KTX2Exporter.js +21 -13
- package/examples/jsm/exporters/OBJExporter.js +5 -1
- package/examples/jsm/exporters/PLYExporter.js +9 -7
- package/examples/jsm/exporters/USDZExporter.js +55 -11
- package/examples/jsm/geometries/DecalGeometry.js +4 -1
- package/examples/jsm/geometries/InstancedPointsGeometry.js +1 -1
- package/examples/jsm/geometries/TeapotGeometry.js +1 -1
- package/examples/jsm/geometries/TextGeometry.js +10 -2
- package/examples/jsm/helpers/LightProbeHelper.js +43 -44
- package/examples/jsm/helpers/LightProbeHelperGPU.js +65 -0
- package/examples/jsm/helpers/ViewHelper.js +75 -61
- package/examples/jsm/interactive/HTMLMesh.js +7 -9
- package/examples/jsm/libs/basis/basis_transcoder.js +8 -10
- package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
- package/examples/jsm/libs/draco/README.md +2 -2
- package/examples/jsm/libs/fflate.module.js +694 -496
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/lights/LightProbeGenerator.js +24 -10
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +91 -0
- package/examples/jsm/lights/RectAreaLightUniformsLib.js +8 -63
- package/examples/jsm/lines/LineMaterial.js +1 -17
- package/examples/jsm/lines/LineSegments2.js +15 -0
- package/examples/jsm/lines/Wireframe.js +16 -1
- package/examples/jsm/lines/webgpu/Line2.js +20 -0
- package/examples/jsm/lines/webgpu/LineSegments2.js +376 -0
- package/examples/jsm/loaders/3MFLoader.js +2 -0
- package/examples/jsm/loaders/ColladaLoader.js +9 -6
- package/examples/jsm/loaders/DRACOLoader.js +4 -2
- package/examples/jsm/loaders/EXRLoader.js +351 -97
- package/examples/jsm/loaders/FBXLoader.js +77 -78
- package/examples/jsm/loaders/GLTFLoader.js +76 -14
- package/examples/jsm/loaders/KTX2Loader.js +30 -22
- package/examples/jsm/loaders/LDrawLoader.js +3 -2
- package/examples/jsm/loaders/LUT3dlLoader.js +0 -15
- package/examples/jsm/loaders/LUTCubeLoader.js +0 -14
- package/examples/jsm/loaders/LUTImageLoader.js +0 -14
- package/examples/jsm/loaders/MMDLoader.js +31 -12
- package/examples/jsm/loaders/MTLLoader.js +4 -3
- package/examples/jsm/loaders/MaterialXLoader.js +45 -21
- package/examples/jsm/loaders/OBJLoader.js +5 -3
- package/examples/jsm/loaders/PCDLoader.js +14 -13
- package/examples/jsm/loaders/PDBLoader.js +3 -2
- package/examples/jsm/loaders/PLYLoader.js +8 -5
- package/examples/jsm/loaders/RGBMLoader.js +16 -0
- package/examples/jsm/loaders/STLLoader.js +3 -2
- package/examples/jsm/loaders/USDZLoader.js +124 -76
- package/examples/jsm/loaders/UltraHDRLoader.js +583 -0
- package/examples/jsm/loaders/VRMLLoader.js +11 -11
- package/examples/jsm/loaders/VTKLoader.js +80 -6
- package/examples/jsm/loaders/XYZLoader.js +3 -2
- package/examples/jsm/loaders/lwo/IFFParser.js +8 -5
- package/examples/jsm/materials/MeshGouraudMaterial.js +7 -1
- package/examples/jsm/math/Octree.js +26 -20
- package/examples/jsm/misc/GPUComputationRenderer.js +9 -25
- package/examples/jsm/misc/Timer.js +1 -1
- package/examples/jsm/modifiers/CurveModifier.js +11 -9
- package/examples/jsm/modifiers/CurveModifierGPU.js +233 -0
- package/examples/jsm/modifiers/SimplifyModifier.js +2 -1
- package/examples/jsm/objects/InstancedPoints.js +2 -2
- package/examples/jsm/objects/Lensflare.js +2 -2
- package/examples/jsm/objects/LensflareMesh.js +322 -0
- package/examples/jsm/objects/SkyMesh.js +187 -0
- package/examples/jsm/objects/Water2Mesh.js +158 -0
- package/examples/jsm/objects/WaterMesh.js +101 -0
- package/examples/jsm/physics/JoltPhysics.js +281 -0
- package/examples/jsm/physics/RapierPhysics.js +25 -5
- package/examples/jsm/postprocessing/GlitchPass.js +0 -3
- package/examples/jsm/postprocessing/LUTPass.js +5 -71
- package/examples/jsm/postprocessing/OutlinePass.js +31 -46
- package/examples/jsm/postprocessing/RenderPass.js +1 -1
- package/examples/jsm/postprocessing/RenderTransitionPass.js +168 -0
- package/examples/jsm/postprocessing/SAOPass.js +0 -1
- package/examples/jsm/postprocessing/SSAARenderPass.js +3 -1
- package/examples/jsm/postprocessing/SSAOPass.js +6 -12
- package/examples/jsm/postprocessing/UnrealBloomPass.js +4 -4
- package/examples/jsm/renderers/CSS2DRenderer.js +25 -5
- package/examples/jsm/renderers/CSS3DRenderer.js +24 -3
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +1 -3
- package/examples/jsm/renderers/webgl-legacy/nodes/SlotNode.js +1 -1
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +7 -4
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodes.js +19 -5
- package/examples/jsm/shaders/BleachBypassShader.js +1 -2
- package/examples/jsm/shaders/ColorifyShader.js +1 -2
- package/examples/jsm/shaders/FXAAShader.js +0 -2
- package/examples/jsm/shaders/GTAOShader.js +1 -1
- package/examples/jsm/shaders/LuminosityHighPassShader.js +1 -3
- package/examples/jsm/shaders/OutputShader.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +47 -5
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -2
- package/examples/jsm/transpiler/TSLEncoder.js +24 -22
- package/examples/jsm/utils/BufferGeometryUtils.js +18 -16
- package/examples/jsm/utils/GeometryCompressionUtils.js +37 -122
- package/examples/jsm/utils/SceneUtils.js +60 -1
- package/examples/jsm/utils/ShadowMapViewer.js +3 -8
- package/examples/jsm/utils/ShadowMapViewerGPU.js +201 -0
- package/examples/jsm/utils/SkeletonUtils.js +84 -66
- package/examples/jsm/utils/SortUtils.js +8 -5
- package/examples/jsm/utils/TextureUtils.js +3 -2
- package/examples/jsm/utils/TextureUtilsGPU.js +63 -0
- package/examples/jsm/webxr/OculusHandModel.js +3 -2
- package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
- package/examples/jsm/webxr/XRHandModelFactory.js +4 -2
- package/package.json +11 -8
- package/src/Three.WebGPU.Nodes.js +200 -0
- package/src/Three.WebGPU.js +201 -0
- package/src/Three.js +23 -1
- package/src/animation/AnimationClip.js +1 -1
- package/src/animation/tracks/BooleanKeyframeTrack.js +10 -1
- package/src/animation/tracks/QuaternionKeyframeTrack.js +1 -2
- package/src/animation/tracks/StringKeyframeTrack.js +10 -1
- package/src/audio/Audio.js +2 -2
- package/src/constants.js +6 -7
- package/src/core/BufferAttribute.js +0 -9
- package/src/core/Clock.js +1 -1
- package/src/core/InterleavedBuffer.js +0 -9
- package/src/core/Object3D.js +34 -29
- package/src/core/Raycaster.js +6 -2
- package/src/core/RenderTarget.js +8 -0
- package/src/extras/Controls.js +32 -0
- package/src/extras/PMREMGenerator.js +12 -11
- package/src/extras/TextureUtils.js +210 -0
- package/src/geometries/CylinderGeometry.js +11 -4
- package/src/lights/Light.js +1 -0
- package/src/lights/LightShadow.js +5 -0
- package/{examples/jsm/lights → src/lights/webgpu}/IESSpotLight.js +1 -1
- package/src/loaders/FileLoader.js +5 -1
- package/src/loaders/LoaderUtils.js +3 -1
- package/src/loaders/MaterialLoader.js +8 -1
- package/src/loaders/ObjectLoader.js +36 -2
- package/{examples/jsm/nodes/loaders → src/loaders/nodes}/NodeLoader.js +27 -5
- package/{examples/jsm/nodes/loaders → src/loaders/nodes}/NodeMaterialLoader.js +22 -18
- package/{examples/jsm/nodes/loaders → src/loaders/nodes}/NodeObjectLoader.js +21 -1
- package/src/materials/Material.js +4 -0
- package/src/materials/MeshPhysicalMaterial.js +20 -0
- package/src/materials/ShaderMaterial.js +0 -4
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +156 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/Line2NodeMaterial.js +69 -68
- package/src/materials/nodes/LineBasicNodeMaterial.js +31 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/LineDashedNodeMaterial.js +15 -12
- package/src/materials/nodes/MeshBasicNodeMaterial.js +77 -0
- package/src/materials/nodes/MeshLambertNodeMaterial.js +47 -0
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +57 -0
- package/src/materials/nodes/MeshNormalNodeMaterial.js +44 -0
- package/src/materials/nodes/MeshPhongNodeMaterial.js +78 -0
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +248 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/MeshSSSNodeMaterial.js +10 -7
- package/src/materials/nodes/MeshStandardNodeMaterial.js +108 -0
- package/src/materials/nodes/MeshToonNodeMaterial.js +38 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/NodeMaterial.js +198 -157
- package/{examples/jsm/nodes/materials/Materials.js → src/materials/nodes/NodeMaterials.js} +7 -1
- package/{examples/jsm/nodes/materials → src/materials/nodes}/PointsNodeMaterial.js +10 -7
- package/src/materials/nodes/ShadowNodeMaterial.js +38 -0
- package/src/materials/nodes/SpriteNodeMaterial.js +123 -0
- package/src/materials/nodes/VolumeNodeMaterial.js +108 -0
- package/src/materials/nodes/manager/NodeMaterialObserver.js +302 -0
- package/src/math/Box2.js +4 -4
- package/src/math/Box3.js +6 -6
- package/src/math/ColorManagement.js +10 -0
- package/src/math/Matrix2.js +54 -0
- package/src/math/Spherical.js +4 -5
- package/src/math/Triangle.js +24 -0
- package/src/math/Vector4.js +13 -0
- package/src/nodes/Nodes.js +164 -0
- package/src/nodes/TSL.js +179 -0
- package/src/nodes/accessors/AccessorsUtils.js +25 -0
- package/src/nodes/accessors/BatchNode.js +128 -0
- package/src/nodes/accessors/Bitangent.js +13 -0
- package/{examples/jsm → src}/nodes/accessors/BufferAttributeNode.js +44 -6
- package/{examples/jsm → src}/nodes/accessors/BufferNode.js +13 -4
- package/src/nodes/accessors/Camera.js +13 -0
- package/{examples/jsm → src}/nodes/accessors/ClippingNode.js +22 -15
- package/src/nodes/accessors/CubeTextureNode.js +79 -0
- package/src/nodes/accessors/InstanceNode.js +144 -0
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +24 -0
- package/src/nodes/accessors/Lights.js +51 -0
- package/src/nodes/accessors/MaterialNode.js +441 -0
- package/src/nodes/accessors/MaterialProperties.js +3 -0
- package/{examples/jsm → src}/nodes/accessors/MaterialReferenceNode.js +10 -5
- package/src/nodes/accessors/ModelNode.js +72 -0
- package/src/nodes/accessors/ModelViewProjectionNode.js +42 -0
- package/{examples/jsm → src}/nodes/accessors/MorphNode.js +51 -33
- package/src/nodes/accessors/Normal.js +88 -0
- package/{examples/jsm → src}/nodes/accessors/Object3DNode.js +18 -34
- package/src/nodes/accessors/PointUVNode.js +30 -0
- package/src/nodes/accessors/Position.js +10 -0
- package/src/nodes/accessors/ReferenceBaseNode.js +171 -0
- package/{examples/jsm → src}/nodes/accessors/ReferenceNode.js +58 -9
- package/src/nodes/accessors/ReflectVector.js +10 -0
- package/src/nodes/accessors/RendererReferenceNode.js +35 -0
- package/{examples/jsm → src}/nodes/accessors/SceneNode.js +9 -6
- package/src/nodes/accessors/SkinningNode.js +191 -0
- package/src/nodes/accessors/StorageBufferNode.js +147 -0
- package/{examples/jsm/nodes/accessors/TextureStoreNode.js → src/nodes/accessors/StorageTextureNode.js} +35 -10
- package/src/nodes/accessors/Tangent.js +22 -0
- package/src/nodes/accessors/Texture3DNode.js +103 -0
- package/{examples/jsm/nodes/accessors/TextureBicubicNode.js → src/nodes/accessors/TextureBicubic.js} +3 -32
- package/{examples/jsm → src}/nodes/accessors/TextureNode.js +123 -39
- package/src/nodes/accessors/TextureSizeNode.js +36 -0
- package/src/nodes/accessors/UV.js +3 -0
- package/{examples/jsm/nodes/accessors/UniformsNode.js → src/nodes/accessors/UniformArrayNode.js} +33 -15
- package/{examples/jsm → src}/nodes/accessors/UserDataNode.js +10 -7
- package/src/nodes/accessors/VelocityNode.js +134 -0
- package/{examples/jsm → src}/nodes/accessors/VertexColorNode.js +9 -5
- package/{examples/jsm → src}/nodes/code/CodeNode.js +9 -5
- package/{examples/jsm → src}/nodes/code/ExpressionNode.js +10 -6
- package/{examples/jsm → src}/nodes/code/FunctionCallNode.js +8 -5
- package/{examples/jsm → src}/nodes/code/FunctionNode.js +8 -31
- package/{examples/jsm → src}/nodes/code/ScriptableNode.js +24 -7
- package/{examples/jsm → src}/nodes/code/ScriptableValueNode.js +11 -8
- package/{examples/jsm → src}/nodes/core/AssignNode.js +12 -9
- package/{examples/jsm → src}/nodes/core/AttributeNode.js +29 -12
- package/{examples/jsm → src}/nodes/core/BypassNode.js +11 -7
- package/src/nodes/core/CacheNode.js +50 -0
- package/{examples/jsm → src}/nodes/core/ConstNode.js +6 -3
- package/{examples/jsm → src}/nodes/core/ContextNode.js +27 -11
- package/src/nodes/core/IndexNode.js +99 -0
- package/{examples/jsm → src}/nodes/core/InputNode.js +7 -3
- package/{examples/jsm → src}/nodes/core/LightingModel.js +2 -2
- package/src/nodes/core/MRTNode.js +85 -0
- package/{examples/jsm → src}/nodes/core/Node.js +114 -57
- package/{examples/jsm → src}/nodes/core/NodeBuilder.js +327 -90
- package/src/nodes/core/NodeCache.js +36 -0
- package/{examples/jsm → src}/nodes/core/NodeFrame.js +52 -10
- package/{examples/jsm → src}/nodes/core/NodeFunction.js +2 -2
- package/{examples/jsm → src}/nodes/core/NodeUniform.js +1 -2
- package/{examples/jsm → src}/nodes/core/NodeUtils.js +56 -8
- package/{examples/jsm → src}/nodes/core/OutputStructNode.js +13 -12
- package/{examples/jsm → src}/nodes/core/ParameterNode.js +7 -4
- package/src/nodes/core/PropertyNode.js +88 -0
- package/{examples/jsm → src}/nodes/core/StackNode.js +31 -11
- package/{examples/jsm → src}/nodes/core/StructTypeNode.js +7 -3
- package/{examples/jsm → src}/nodes/core/TempNode.js +10 -6
- package/src/nodes/core/UniformGroupNode.js +59 -0
- package/{examples/jsm → src}/nodes/core/UniformNode.js +37 -5
- package/{examples/jsm → src}/nodes/core/VarNode.js +14 -14
- package/src/nodes/core/VaryingNode.js +108 -0
- package/{examples/jsm → src}/nodes/display/AfterImageNode.js +38 -28
- package/src/nodes/display/AnaglyphPassNode.js +67 -0
- package/{examples/jsm → src}/nodes/display/AnamorphicNode.js +33 -30
- package/src/nodes/display/BleachBypass.js +26 -0
- package/src/nodes/display/BlendMode.js +54 -0
- package/src/nodes/display/BloomNode.js +341 -0
- package/{examples/jsm → src}/nodes/display/BumpMapNode.js +20 -38
- package/src/nodes/display/ColorAdjustment.js +46 -0
- package/src/nodes/display/ColorSpaceFunctions.js +38 -0
- package/src/nodes/display/ColorSpaceNode.js +114 -0
- package/src/nodes/display/DenoiseNode.js +204 -0
- package/src/nodes/display/DepthOfFieldNode.js +124 -0
- package/src/nodes/display/DotScreenNode.js +66 -0
- package/src/nodes/display/FXAANode.js +332 -0
- package/src/nodes/display/FilmNode.js +56 -0
- package/src/nodes/display/FrontFacingNode.js +45 -0
- package/src/nodes/display/GTAONode.js +331 -0
- package/{examples/jsm → src}/nodes/display/GaussianBlurNode.js +47 -24
- package/src/nodes/display/Lut3DNode.js +57 -0
- package/src/nodes/display/MotionBlur.js +25 -0
- package/{examples/jsm → src}/nodes/display/NormalMapNode.js +14 -14
- package/src/nodes/display/ParallaxBarrierPassNode.js +58 -0
- package/src/nodes/display/PassNode.js +378 -0
- package/src/nodes/display/PixelationPassNode.js +213 -0
- package/{examples/jsm → src}/nodes/display/PosterizeNode.js +8 -7
- package/src/nodes/display/RGBShiftNode.js +53 -0
- package/src/nodes/display/RenderOutputNode.js +60 -0
- package/src/nodes/display/SSAAPassNode.js +287 -0
- package/src/nodes/display/ScreenNode.js +181 -0
- package/src/nodes/display/Sepia.js +17 -0
- package/src/nodes/display/SobelOperatorNode.js +126 -0
- package/src/nodes/display/StereoCompositePassNode.js +110 -0
- package/src/nodes/display/StereoPassNode.js +83 -0
- package/src/nodes/display/ToneMappingFunctions.js +190 -0
- package/src/nodes/display/ToneMappingNode.js +67 -0
- package/src/nodes/display/ToonOutlinePassNode.js +111 -0
- package/src/nodes/display/TransitionNode.js +80 -0
- package/src/nodes/display/ViewportDepthNode.js +125 -0
- package/src/nodes/display/ViewportDepthTextureNode.js +33 -0
- package/src/nodes/display/ViewportSharedTextureNode.js +39 -0
- package/{examples/jsm → src}/nodes/display/ViewportTextureNode.js +20 -14
- package/src/nodes/fog/FogExp2Node.js +35 -0
- package/src/nodes/fog/FogNode.js +50 -0
- package/src/nodes/fog/FogRangeNode.js +36 -0
- package/src/nodes/functions/BSDF/BRDF_GGX.js +59 -0
- package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_Sheen.js +6 -6
- package/{examples/jsm → src}/nodes/functions/BSDF/DFGApprox.js +2 -2
- package/{examples/jsm → src}/nodes/functions/BSDF/D_GGX.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +28 -0
- package/{examples/jsm → src}/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/{examples/jsm → src}/nodes/functions/BSDF/F_Schlick.js +2 -2
- package/src/nodes/functions/BSDF/LTC.js +131 -0
- package/{examples/jsm → src}/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
- package/{examples/jsm → src}/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -4
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +29 -0
- package/src/nodes/functions/BasicLightingModel.js +78 -0
- package/{examples/jsm → src}/nodes/functions/PhongLightingModel.js +11 -9
- package/src/nodes/functions/PhysicalLightingModel.js +633 -0
- package/src/nodes/functions/ShadowMaskModel.js +31 -0
- package/src/nodes/functions/ToonLightingModel.js +51 -0
- package/src/nodes/functions/material/getGeometryRoughness.js +13 -0
- package/{examples/jsm → src}/nodes/functions/material/getRoughness.js +2 -2
- package/src/nodes/functions/material/getShIrradianceAt.js +28 -0
- package/{examples/jsm → src}/nodes/geometry/RangeNode.js +28 -11
- package/src/nodes/gpgpu/AtomicFunctionNode.js +99 -0
- package/src/nodes/gpgpu/BarrierNode.js +40 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +98 -0
- package/{examples/jsm → src}/nodes/gpgpu/ComputeNode.js +10 -6
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +100 -0
- package/src/nodes/lighting/AONode.js +27 -0
- package/{examples/jsm → src}/nodes/lighting/AmbientLightNode.js +6 -8
- package/src/nodes/lighting/AnalyticLightNode.js +522 -0
- package/src/nodes/lighting/BasicEnvironmentNode.js +30 -0
- package/src/nodes/lighting/BasicLightMapNode.js +32 -0
- package/{examples/jsm → src}/nodes/lighting/DirectionalLightNode.js +7 -9
- package/src/nodes/lighting/EnvironmentNode.js +138 -0
- package/{examples/jsm → src}/nodes/lighting/HemisphereLightNode.js +12 -11
- package/{examples/jsm → src}/nodes/lighting/IESSpotLightNode.js +7 -9
- package/src/nodes/lighting/IrradianceNode.js +27 -0
- package/src/nodes/lighting/LightProbeNode.js +53 -0
- package/{examples/jsm → src}/nodes/lighting/LightUtils.js +3 -3
- package/src/nodes/lighting/LightingContextNode.js +67 -0
- package/{examples/jsm → src}/nodes/lighting/LightingNode.js +9 -3
- package/src/nodes/lighting/LightsNode.js +250 -0
- package/{examples/jsm → src}/nodes/lighting/PointLightNode.js +12 -13
- package/src/nodes/lighting/RectAreaLightNode.js +97 -0
- package/{examples/jsm → src}/nodes/lighting/SpotLightNode.js +14 -16
- package/{examples/jsm → src}/nodes/materialx/MaterialXNodes.js +2 -2
- package/src/nodes/materialx/lib/mx_hsv.js +127 -0
- package/{examples/jsm → src}/nodes/materialx/lib/mx_noise.js +500 -603
- package/{examples/jsm → src}/nodes/materialx/lib/mx_transform_color.js +3 -9
- package/{examples/jsm/nodes/math/CondNode.js → src/nodes/math/ConditionalNode.js} +48 -13
- package/src/nodes/math/Hash.js +13 -0
- package/src/nodes/math/MathNode.js +407 -0
- package/{examples/jsm → src}/nodes/math/MathUtils.js +0 -7
- package/src/nodes/math/OperatorNode.js +319 -0
- package/{examples/jsm → src}/nodes/math/TriNoise3D.js +19 -29
- package/{examples/jsm → src}/nodes/parsers/GLSLNodeFunction.js +7 -7
- package/src/nodes/pmrem/PMREMNode.js +240 -0
- package/src/nodes/pmrem/PMREMUtils.js +288 -0
- package/src/nodes/procedural/Checker.js +14 -0
- package/src/nodes/tsl/TSLBase.js +30 -0
- package/{examples/jsm/nodes/shadernode/ShaderNode.js → src/nodes/tsl/TSLCore.js} +122 -96
- package/{examples/jsm → src}/nodes/utils/ArrayElementNode.js +9 -5
- package/{examples/jsm → src}/nodes/utils/ConvertNode.js +7 -3
- package/src/nodes/utils/CubeMapNode.js +160 -0
- package/src/nodes/utils/Discard.js +8 -0
- package/src/nodes/utils/EquirectUVNode.js +36 -0
- package/src/nodes/utils/FlipNode.js +68 -0
- package/{examples/jsm → src}/nodes/utils/FunctionOverloadingNode.js +11 -5
- package/{examples/jsm → src}/nodes/utils/JoinNode.js +6 -3
- package/{examples/jsm → src}/nodes/utils/LoopNode.js +23 -12
- package/src/nodes/utils/MatcapUVNode.js +33 -0
- package/{examples/jsm → src}/nodes/utils/MaxMipLevelNode.js +16 -7
- package/{examples/jsm → src}/nodes/utils/OscNode.js +12 -8
- package/src/nodes/utils/Packing.js +4 -0
- package/src/nodes/utils/RTTNode.js +133 -0
- package/{examples/jsm → src}/nodes/utils/ReflectorNode.js +21 -5
- package/{examples/jsm → src}/nodes/utils/RemapNode.js +12 -8
- package/{examples/jsm → src}/nodes/utils/RotateNode.js +8 -13
- package/{examples/jsm → src}/nodes/utils/SetNode.js +7 -4
- package/{examples/jsm → src}/nodes/utils/SplitNode.js +7 -3
- package/{examples/jsm → src}/nodes/utils/SpriteSheetUVNode.js +10 -6
- package/src/nodes/utils/SpriteUtils.js +47 -0
- package/{examples/jsm → src}/nodes/utils/StorageArrayElementNode.js +11 -12
- package/{examples/jsm → src}/nodes/utils/TimerNode.js +8 -5
- package/{examples/jsm → src}/nodes/utils/TriplanarTexturesNode.js +11 -9
- package/src/nodes/utils/UVUtils.js +19 -0
- package/src/nodes/utils/ViewportUtils.js +14 -0
- package/src/objects/BatchedMesh.js +302 -144
- package/src/objects/InstancedMesh.js +11 -1
- package/src/objects/LOD.js +21 -0
- package/src/objects/Line.js +67 -43
- package/src/objects/Mesh.js +7 -23
- package/src/objects/Points.js +2 -0
- package/src/renderers/WebGLRenderer.js +473 -224
- package/{examples/jsm → src}/renderers/common/Animation.js +3 -0
- package/{examples/jsm → src}/renderers/common/Attributes.js +4 -1
- package/{examples/jsm → src}/renderers/common/Backend.js +30 -27
- package/{examples/jsm → src}/renderers/common/Background.js +18 -10
- package/src/renderers/common/BindGroup.js +18 -0
- package/src/renderers/common/Bindings.js +203 -0
- package/src/renderers/common/BundleGroup.js +26 -0
- package/src/renderers/common/ChainMap.js +59 -0
- package/{examples/jsm → src}/renderers/common/ClippingContext.js +24 -12
- package/{examples/jsm → src}/renderers/common/Color4.js +1 -1
- package/{examples/jsm → src}/renderers/common/CubeRenderTarget.js +16 -4
- package/{examples/jsm → src}/renderers/common/Geometries.js +37 -5
- package/{examples/jsm → src}/renderers/common/Info.js +35 -15
- package/{examples/jsm → src}/renderers/common/Pipelines.js +2 -2
- package/src/renderers/common/PostProcessing.js +90 -0
- package/src/renderers/common/QuadMesh.js +55 -0
- package/src/renderers/common/RenderBundle.js +18 -0
- package/src/renderers/common/RenderBundles.js +38 -0
- package/{examples/jsm → src}/renderers/common/RenderContext.js +25 -2
- package/{examples/jsm → src}/renderers/common/RenderContexts.js +1 -1
- package/{examples/jsm → src}/renderers/common/RenderList.js +11 -2
- package/src/renderers/common/RenderObject.js +413 -0
- package/{examples/jsm → src}/renderers/common/RenderObjects.js +9 -2
- package/{examples/jsm → src}/renderers/common/Renderer.js +431 -83
- package/{examples/jsm → src}/renderers/common/SampledTexture.js +14 -5
- package/{examples/jsm → src}/renderers/common/StorageBufferAttribute.js +1 -1
- package/{examples/jsm → src}/renderers/common/StorageInstancedBufferAttribute.js +1 -1
- package/{examples/jsm → src}/renderers/common/StorageTexture.js +2 -1
- package/{examples/jsm → src}/renderers/common/Textures.js +15 -15
- package/{examples/jsm → src}/renderers/common/Uniform.js +10 -5
- package/{examples/jsm → src}/renderers/common/UniformsGroup.js +69 -31
- package/src/renderers/common/extras/PMREMGenerator.js +771 -0
- package/src/renderers/common/nodes/NodeBuilderState.js +58 -0
- package/src/renderers/common/nodes/NodeLibrary.js +118 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +64 -0
- package/{examples/jsm → src}/renderers/common/nodes/NodeSampler.js +8 -1
- package/{examples/jsm → src}/renderers/common/nodes/NodeStorageBuffer.js +5 -1
- package/{examples/jsm → src}/renderers/common/nodes/NodeUniform.js +3 -3
- package/{examples/jsm → src}/renderers/common/nodes/NodeUniformBuffer.js +2 -1
- package/{examples/jsm → src}/renderers/common/nodes/NodeUniformsGroup.js +2 -8
- package/{examples/jsm → src}/renderers/common/nodes/Nodes.js +106 -68
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +31 -1
- package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +9 -1
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +0 -9
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -10
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +3 -3
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +8 -22
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +1 -0
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +2 -10
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +2 -16
- package/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +3 -14
- package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +10 -31
- package/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js +3 -23
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +45 -13
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +38 -25
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +3 -0
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +3 -3
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +19 -11
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +47 -13
- package/src/renderers/shaders/ShaderChunk.js +0 -2
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +8 -0
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -0
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +2 -4
- package/src/renderers/shaders/ShaderLib.js +2 -1
- package/src/renderers/shaders/UniformsLib.js +3 -0
- package/src/renderers/shaders/UniformsUtils.js +10 -1
- package/src/renderers/webgl/WebGLAttributes.js +42 -38
- package/src/renderers/webgl/WebGLBackground.js +24 -3
- package/src/renderers/webgl/WebGLBindingStates.js +14 -51
- package/src/renderers/webgl/WebGLBufferRenderer.js +23 -22
- package/src/renderers/webgl/WebGLCapabilities.js +44 -13
- package/src/renderers/webgl/WebGLCubeUVMaps.js +10 -6
- package/src/renderers/webgl/WebGLExtensions.js +7 -20
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +23 -21
- package/src/renderers/webgl/WebGLLights.js +21 -44
- package/src/renderers/webgl/WebGLMaterials.js +9 -8
- package/src/renderers/webgl/WebGLMorphtargets.js +78 -217
- package/src/renderers/webgl/WebGLProgram.js +46 -78
- package/src/renderers/webgl/WebGLPrograms.js +37 -40
- package/src/renderers/webgl/WebGLProperties.js +7 -0
- package/src/renderers/webgl/WebGLRenderStates.js +15 -9
- package/src/renderers/webgl/WebGLShadowMap.js +25 -25
- package/src/renderers/webgl/WebGLState.js +35 -58
- package/src/renderers/webgl/WebGLTextures.js +313 -358
- package/src/renderers/webgl/WebGLUniforms.js +12 -2
- package/src/renderers/webgl/WebGLUniformsGroups.js +8 -8
- package/src/renderers/webgl/WebGLUtils.js +9 -78
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/WebGLBackend.js +389 -152
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +145 -0
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/nodes/GLSLNodeBuilder.js +245 -44
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLAttributeUtils.js +7 -1
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLConstants.js +2 -0
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLExtensions.js +2 -0
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLState.js +21 -3
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLTextureUtils.js +271 -43
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLUtils.js +6 -23
- package/{examples/jsm → src}/renderers/webgpu/WebGPUBackend.js +318 -141
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +42 -0
- package/{examples/jsm → src}/renderers/webgpu/WebGPURenderer.js +10 -7
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +59 -0
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +105 -0
- package/{examples/jsm → src}/renderers/webgpu/nodes/WGSLNodeBuilder.js +424 -95
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +159 -0
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUAttributeUtils.js +37 -18
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUBindingUtils.js +86 -32
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUConstants.js +10 -1
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUPipelineUtils.js +68 -27
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUTextureUtils.js +235 -68
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUUtils.js +43 -5
- package/src/renderers/webxr/WebXRDepthSensing.js +11 -6
- package/src/renderers/webxr/WebXRManager.js +53 -38
- package/src/scenes/Scene.js +7 -1
- package/src/textures/CompressedArrayTexture.js +14 -0
- package/src/textures/DataArrayTexture.js +14 -0
- package/src/textures/DepthTexture.js +1 -3
- package/src/textures/Texture.js +12 -2
- package/src/utils.js +62 -1
- package/examples/jsm/geometries/SDFGeometryGenerator.js +0 -144
- package/examples/jsm/loaders/LogLuvLoader.js +0 -606
- package/examples/jsm/loaders/TiltLoader.js +0 -520
- package/examples/jsm/nodes/Nodes.js +0 -195
- package/examples/jsm/nodes/accessors/AccessorsUtils.js +0 -10
- package/examples/jsm/nodes/accessors/BitangentNode.js +0 -89
- package/examples/jsm/nodes/accessors/CameraNode.js +0 -119
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +0 -61
- package/examples/jsm/nodes/accessors/InstanceNode.js +0 -71
- package/examples/jsm/nodes/accessors/InstancedPointsMaterialNode.js +0 -21
- package/examples/jsm/nodes/accessors/MaterialNode.js +0 -314
- package/examples/jsm/nodes/accessors/ModelNode.js +0 -33
- package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +0 -39
- package/examples/jsm/nodes/accessors/NormalNode.js +0 -96
- package/examples/jsm/nodes/accessors/PointUVNode.js +0 -26
- package/examples/jsm/nodes/accessors/PositionNode.js +0 -104
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +0 -35
- package/examples/jsm/nodes/accessors/SkinningNode.js +0 -124
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +0 -72
- package/examples/jsm/nodes/accessors/TangentNode.js +0 -109
- package/examples/jsm/nodes/accessors/TextureSizeNode.js +0 -35
- package/examples/jsm/nodes/accessors/UVNode.js +0 -47
- package/examples/jsm/nodes/core/CacheNode.js +0 -49
- package/examples/jsm/nodes/core/IndexNode.js +0 -66
- package/examples/jsm/nodes/core/NodeCache.js +0 -26
- package/examples/jsm/nodes/core/NodeKeywords.js +0 -80
- package/examples/jsm/nodes/core/PropertyNode.js +0 -72
- package/examples/jsm/nodes/core/UniformGroupNode.js +0 -36
- package/examples/jsm/nodes/core/VaryingNode.js +0 -65
- package/examples/jsm/nodes/display/BlendModeNode.js +0 -128
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +0 -99
- package/examples/jsm/nodes/display/ColorSpaceNode.js +0 -108
- package/examples/jsm/nodes/display/FrontFacingNode.js +0 -27
- package/examples/jsm/nodes/display/PassNode.js +0 -183
- package/examples/jsm/nodes/display/ToneMappingNode.js +0 -184
- package/examples/jsm/nodes/display/ViewportDepthNode.js +0 -97
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +0 -31
- package/examples/jsm/nodes/display/ViewportNode.js +0 -134
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +0 -31
- package/examples/jsm/nodes/fog/FogExp2Node.js +0 -35
- package/examples/jsm/nodes/fog/FogNode.js +0 -38
- package/examples/jsm/nodes/fog/FogRangeNode.js +0 -34
- package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +0 -40
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +0 -393
- package/examples/jsm/nodes/functions/material/getGeometryRoughness.js +0 -13
- package/examples/jsm/nodes/lighting/AONode.js +0 -27
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +0 -241
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +0 -181
- package/examples/jsm/nodes/lighting/LightNode.js +0 -57
- package/examples/jsm/nodes/lighting/LightingContextNode.js +0 -66
- package/examples/jsm/nodes/lighting/LightsNode.js +0 -188
- package/examples/jsm/nodes/materials/InstancedPointsNodeMaterial.js +0 -162
- package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +0 -28
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +0 -28
- package/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +0 -34
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +0 -40
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +0 -65
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +0 -155
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +0 -80
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +0 -90
- package/examples/jsm/nodes/materialx/lib/mx_hsv.js +0 -130
- package/examples/jsm/nodes/math/HashNode.js +0 -34
- package/examples/jsm/nodes/math/MathNode.js +0 -391
- package/examples/jsm/nodes/math/OperatorNode.js +0 -274
- package/examples/jsm/nodes/procedural/CheckerNode.js +0 -42
- package/examples/jsm/nodes/utils/DiscardNode.js +0 -27
- package/examples/jsm/nodes/utils/EquirectUVNode.js +0 -33
- package/examples/jsm/nodes/utils/MatcapUVNode.js +0 -30
- package/examples/jsm/nodes/utils/PackingNode.js +0 -55
- package/examples/jsm/nodes/utils/RotateUVNode.js +0 -35
- package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +0 -37
- package/examples/jsm/objects/QuadMesh.js +0 -66
- package/examples/jsm/renderers/common/Bindings.js +0 -173
- package/examples/jsm/renderers/common/ChainMap.js +0 -89
- package/examples/jsm/renderers/common/PostProcessing.js +0 -25
- package/examples/jsm/renderers/common/RenderObject.js +0 -221
- package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +0 -44
- package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +0 -49
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +0 -104
- package/examples/jsm/utils/GPUStatsPanel.js +0 -128
- package/examples/jsm/utils/PackedPhongMaterial.js +0 -178
- package/src/renderers/WebGL1Renderer.js +0 -7
- package/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +0 -10
- /package/{examples/jsm → src}/nodes/core/NodeAttribute.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeCode.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeFunctionInput.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeParser.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeVar.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeVarying.js +0 -0
- /package/{examples/jsm → src}/nodes/core/UniformGroup.js +0 -0
- /package/{examples/jsm → src}/nodes/core/constants.js +0 -0
- /package/{examples/jsm → src}/nodes/materialx/DISCLAIMER.md +0 -0
- /package/{examples/jsm → src}/nodes/parsers/GLSLNodeParser.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Binding.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Buffer.js +0 -0
- /package/{examples/jsm → src}/renderers/common/BufferUtils.js +0 -0
- /package/{examples/jsm → src}/renderers/common/ComputePipeline.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Constants.js +0 -0
- /package/{examples/jsm → src}/renderers/common/DataMap.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Pipeline.js +0 -0
- /package/{examples/jsm → src}/renderers/common/ProgrammableStage.js +0 -0
- /package/{examples/jsm → src}/renderers/common/RenderLists.js +0 -0
- /package/{examples/jsm → src}/renderers/common/RenderPipeline.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Sampler.js +0 -0
- /package/{examples/jsm → src}/renderers/common/StorageBuffer.js +0 -0
- /package/{examples/jsm → src}/renderers/common/UniformBuffer.js +0 -0
- /package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLCapabilities.js +0 -0
- /package/{examples/jsm → src}/renderers/webgpu/nodes/WGSLNodeParser.js +0 -0
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
import 'https://greggman.github.io/webgpu-avoid-redundant-state-setting/webgpu-check-redundant-state-setting.js';
|
|
3
3
|
//*/
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import { GPUFeatureName, GPUTextureFormat, GPULoadOp, GPUStoreOp, GPUIndexFormat, GPUTextureViewDimension } from './utils/WebGPUConstants.js';
|
|
5
|
+
import { GPUFeatureName, GPULoadOp, GPUStoreOp, GPUIndexFormat, GPUTextureViewDimension } from './utils/WebGPUConstants.js';
|
|
8
6
|
|
|
9
7
|
import WGSLNodeBuilder from './nodes/WGSLNodeBuilder.js';
|
|
10
8
|
import Backend from '../common/Backend.js';
|
|
@@ -14,7 +12,8 @@ import WebGPUAttributeUtils from './utils/WebGPUAttributeUtils.js';
|
|
|
14
12
|
import WebGPUBindingUtils from './utils/WebGPUBindingUtils.js';
|
|
15
13
|
import WebGPUPipelineUtils from './utils/WebGPUPipelineUtils.js';
|
|
16
14
|
import WebGPUTextureUtils from './utils/WebGPUTextureUtils.js';
|
|
17
|
-
|
|
15
|
+
|
|
16
|
+
import { WebGPUCoordinateSystem } from '../../constants.js';
|
|
18
17
|
|
|
19
18
|
//
|
|
20
19
|
|
|
@@ -29,23 +28,10 @@ class WebGPUBackend extends Backend {
|
|
|
29
28
|
// some parameters require default values other than "undefined"
|
|
30
29
|
this.parameters.alpha = ( parameters.alpha === undefined ) ? true : parameters.alpha;
|
|
31
30
|
|
|
32
|
-
this.parameters.antialias = ( parameters.antialias === true );
|
|
33
|
-
|
|
34
|
-
if ( this.parameters.antialias === true ) {
|
|
35
|
-
|
|
36
|
-
this.parameters.sampleCount = ( parameters.sampleCount === undefined ) ? 4 : parameters.sampleCount;
|
|
37
|
-
|
|
38
|
-
} else {
|
|
39
|
-
|
|
40
|
-
this.parameters.sampleCount = 1;
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
31
|
this.parameters.requiredLimits = ( parameters.requiredLimits === undefined ) ? {} : parameters.requiredLimits;
|
|
45
32
|
|
|
46
33
|
this.trackTimestamp = ( parameters.trackTimestamp === true );
|
|
47
34
|
|
|
48
|
-
this.adapter = null;
|
|
49
35
|
this.device = null;
|
|
50
36
|
this.context = null;
|
|
51
37
|
this.colorBuffer = null;
|
|
@@ -68,52 +54,65 @@ class WebGPUBackend extends Backend {
|
|
|
68
54
|
|
|
69
55
|
const parameters = this.parameters;
|
|
70
56
|
|
|
71
|
-
|
|
72
|
-
powerPreference: parameters.powerPreference
|
|
73
|
-
};
|
|
57
|
+
// create the device if it is not passed with parameters
|
|
74
58
|
|
|
75
|
-
|
|
59
|
+
let device;
|
|
76
60
|
|
|
77
|
-
if (
|
|
61
|
+
if ( parameters.device === undefined ) {
|
|
78
62
|
|
|
79
|
-
|
|
63
|
+
const adapterOptions = {
|
|
64
|
+
powerPreference: parameters.powerPreference
|
|
65
|
+
};
|
|
80
66
|
|
|
81
|
-
|
|
67
|
+
const adapter = await navigator.gpu.requestAdapter( adapterOptions );
|
|
68
|
+
|
|
69
|
+
if ( adapter === null ) {
|
|
70
|
+
|
|
71
|
+
throw new Error( 'WebGPUBackend: Unable to create WebGPU adapter.' );
|
|
82
72
|
|
|
83
|
-
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// feature support
|
|
84
76
|
|
|
85
|
-
|
|
77
|
+
const features = Object.values( GPUFeatureName );
|
|
86
78
|
|
|
87
|
-
|
|
79
|
+
const supportedFeatures = [];
|
|
88
80
|
|
|
89
|
-
|
|
81
|
+
for ( const name of features ) {
|
|
90
82
|
|
|
91
|
-
|
|
83
|
+
if ( adapter.features.has( name ) ) {
|
|
92
84
|
|
|
93
|
-
|
|
85
|
+
supportedFeatures.push( name );
|
|
86
|
+
|
|
87
|
+
}
|
|
94
88
|
|
|
95
89
|
}
|
|
96
90
|
|
|
97
|
-
|
|
91
|
+
const deviceDescriptor = {
|
|
92
|
+
requiredFeatures: supportedFeatures,
|
|
93
|
+
requiredLimits: parameters.requiredLimits
|
|
94
|
+
};
|
|
98
95
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
96
|
+
device = await adapter.requestDevice( deviceDescriptor );
|
|
97
|
+
|
|
98
|
+
} else {
|
|
99
|
+
|
|
100
|
+
device = parameters.device;
|
|
103
101
|
|
|
104
|
-
|
|
102
|
+
}
|
|
105
103
|
|
|
106
104
|
const context = ( parameters.context !== undefined ) ? parameters.context : renderer.domElement.getContext( 'webgpu' );
|
|
107
105
|
|
|
108
|
-
this.adapter = adapter;
|
|
109
106
|
this.device = device;
|
|
110
107
|
this.context = context;
|
|
111
108
|
|
|
112
109
|
const alphaMode = parameters.alpha ? 'premultiplied' : 'opaque';
|
|
113
110
|
|
|
111
|
+
this.trackTimestamp = this.trackTimestamp && this.hasFeature( GPUFeatureName.TimestampQuery );
|
|
112
|
+
|
|
114
113
|
this.context.configure( {
|
|
115
114
|
device: this.device,
|
|
116
|
-
format:
|
|
115
|
+
format: this.utils.getPreferredCanvasFormat(),
|
|
117
116
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC,
|
|
118
117
|
alphaMode: alphaMode
|
|
119
118
|
} );
|
|
@@ -144,8 +143,6 @@ class WebGPUBackend extends Backend {
|
|
|
144
143
|
|
|
145
144
|
let descriptor = this.defaultRenderPassdescriptor;
|
|
146
145
|
|
|
147
|
-
const antialias = this.parameters.antialias;
|
|
148
|
-
|
|
149
146
|
if ( descriptor === null ) {
|
|
150
147
|
|
|
151
148
|
const renderer = this.renderer;
|
|
@@ -161,7 +158,7 @@ class WebGPUBackend extends Backend {
|
|
|
161
158
|
|
|
162
159
|
const colorAttachment = descriptor.colorAttachments[ 0 ];
|
|
163
160
|
|
|
164
|
-
if (
|
|
161
|
+
if ( this.renderer.samples > 0 ) {
|
|
165
162
|
|
|
166
163
|
colorAttachment.view = this.colorBuffer.createView();
|
|
167
164
|
|
|
@@ -177,7 +174,7 @@ class WebGPUBackend extends Backend {
|
|
|
177
174
|
|
|
178
175
|
const colorAttachment = descriptor.colorAttachments[ 0 ];
|
|
179
176
|
|
|
180
|
-
if (
|
|
177
|
+
if ( this.renderer.samples > 0 ) {
|
|
181
178
|
|
|
182
179
|
colorAttachment.resolveTarget = this.context.getCurrentTexture().createView();
|
|
183
180
|
|
|
@@ -198,25 +195,34 @@ class WebGPUBackend extends Backend {
|
|
|
198
195
|
|
|
199
196
|
let descriptors = renderTargetData.descriptors;
|
|
200
197
|
|
|
201
|
-
if ( descriptors === undefined
|
|
198
|
+
if ( descriptors === undefined ||
|
|
199
|
+
renderTargetData.width !== renderTarget.width ||
|
|
200
|
+
renderTargetData.height !== renderTarget.height ||
|
|
201
|
+
renderTargetData.activeMipmapLevel !== renderTarget.activeMipmapLevel ||
|
|
202
|
+
renderTargetData.samples !== renderTarget.samples
|
|
203
|
+
) {
|
|
202
204
|
|
|
203
|
-
descriptors =
|
|
205
|
+
descriptors = {};
|
|
204
206
|
|
|
205
207
|
renderTargetData.descriptors = descriptors;
|
|
206
208
|
|
|
207
|
-
|
|
209
|
+
// dispose
|
|
208
210
|
|
|
209
|
-
|
|
210
|
-
renderTargetData.height !== renderTarget.height ||
|
|
211
|
-
renderTargetData.activeMipmapLevel !== renderTarget.activeMipmapLevel ||
|
|
212
|
-
renderTargetData.samples !== renderTarget.samples
|
|
213
|
-
) {
|
|
211
|
+
const onDispose = () => {
|
|
214
212
|
|
|
215
|
-
|
|
213
|
+
renderTarget.removeEventListener( 'dispose', onDispose );
|
|
214
|
+
|
|
215
|
+
this.delete( renderTarget );
|
|
216
|
+
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
renderTarget.addEventListener( 'dispose', onDispose );
|
|
216
220
|
|
|
217
221
|
}
|
|
218
222
|
|
|
219
|
-
|
|
223
|
+
const cacheKey = renderContext.getCacheKey();
|
|
224
|
+
|
|
225
|
+
let descriptor = descriptors[ cacheKey ];
|
|
220
226
|
|
|
221
227
|
if ( descriptor === undefined ) {
|
|
222
228
|
|
|
@@ -260,7 +266,7 @@ class WebGPUBackend extends Backend {
|
|
|
260
266
|
const depthTextureData = this.get( renderContext.depthTexture );
|
|
261
267
|
|
|
262
268
|
const depthStencilAttachment = {
|
|
263
|
-
view: depthTextureData.texture.createView()
|
|
269
|
+
view: depthTextureData.texture.createView()
|
|
264
270
|
};
|
|
265
271
|
|
|
266
272
|
descriptor = {
|
|
@@ -268,7 +274,7 @@ class WebGPUBackend extends Backend {
|
|
|
268
274
|
depthStencilAttachment
|
|
269
275
|
};
|
|
270
276
|
|
|
271
|
-
descriptors[
|
|
277
|
+
descriptors[ cacheKey ] = descriptor;
|
|
272
278
|
|
|
273
279
|
renderTargetData.width = renderTarget.width;
|
|
274
280
|
renderTargetData.height = renderTarget.height;
|
|
@@ -341,7 +347,7 @@ class WebGPUBackend extends Backend {
|
|
|
341
347
|
|
|
342
348
|
if ( renderContext.clearColor ) {
|
|
343
349
|
|
|
344
|
-
colorAttachment.clearValue = renderContext.clearColorValue;
|
|
350
|
+
colorAttachment.clearValue = i === 0 ? renderContext.clearColorValue : { r: 0, g: 0, b: 0, a: 1 };
|
|
345
351
|
colorAttachment.loadOp = GPULoadOp.Clear;
|
|
346
352
|
colorAttachment.storeOp = GPUStoreOp.Store;
|
|
347
353
|
|
|
@@ -419,7 +425,8 @@ class WebGPUBackend extends Backend {
|
|
|
419
425
|
renderContextData.descriptor = descriptor;
|
|
420
426
|
renderContextData.encoder = encoder;
|
|
421
427
|
renderContextData.currentPass = currentPass;
|
|
422
|
-
renderContextData.currentSets = { attributes: {} };
|
|
428
|
+
renderContextData.currentSets = { attributes: {}, bindingGroups: [], pipeline: null, index: null };
|
|
429
|
+
renderContextData.renderBundles = [];
|
|
423
430
|
|
|
424
431
|
//
|
|
425
432
|
|
|
@@ -433,7 +440,7 @@ class WebGPUBackend extends Backend {
|
|
|
433
440
|
|
|
434
441
|
const { x, y, width, height } = renderContext.scissorValue;
|
|
435
442
|
|
|
436
|
-
currentPass.setScissorRect( x,
|
|
443
|
+
currentPass.setScissorRect( x, y, width, height );
|
|
437
444
|
|
|
438
445
|
}
|
|
439
446
|
|
|
@@ -444,6 +451,12 @@ class WebGPUBackend extends Backend {
|
|
|
444
451
|
const renderContextData = this.get( renderContext );
|
|
445
452
|
const occlusionQueryCount = renderContext.occlusionQueryCount;
|
|
446
453
|
|
|
454
|
+
if ( renderContextData.renderBundles.length > 0 ) {
|
|
455
|
+
|
|
456
|
+
renderContextData.currentPass.executeBundles( renderContextData.renderBundles );
|
|
457
|
+
|
|
458
|
+
}
|
|
459
|
+
|
|
447
460
|
if ( occlusionQueryCount > renderContextData.occlusionQueryIndex ) {
|
|
448
461
|
|
|
449
462
|
renderContextData.currentPass.endOcclusionQuery();
|
|
@@ -551,7 +564,7 @@ class WebGPUBackend extends Backend {
|
|
|
551
564
|
|
|
552
565
|
for ( let i = 0; i < currentOcclusionQueryObjects.length; i ++ ) {
|
|
553
566
|
|
|
554
|
-
if ( results[ i ] !==
|
|
567
|
+
if ( results[ i ] !== BigInt( 0 ) ) {
|
|
555
568
|
|
|
556
569
|
occluded.add( currentOcclusionQueryObjects[ i ] );
|
|
557
570
|
|
|
@@ -572,7 +585,7 @@ class WebGPUBackend extends Backend {
|
|
|
572
585
|
const { currentPass } = this.get( renderContext );
|
|
573
586
|
const { x, y, width, height, minDepth, maxDepth } = renderContext.viewportValue;
|
|
574
587
|
|
|
575
|
-
currentPass.setViewport( x,
|
|
588
|
+
currentPass.setViewport( x, y, width, height, minDepth, maxDepth );
|
|
576
589
|
|
|
577
590
|
}
|
|
578
591
|
|
|
@@ -593,7 +606,19 @@ class WebGPUBackend extends Backend {
|
|
|
593
606
|
|
|
594
607
|
const clearColor = this.getClearColor();
|
|
595
608
|
|
|
596
|
-
|
|
609
|
+
if ( this.renderer.alpha === true ) {
|
|
610
|
+
|
|
611
|
+
// premultiply alpha
|
|
612
|
+
|
|
613
|
+
const a = clearColor.a;
|
|
614
|
+
|
|
615
|
+
clearValue = { r: clearColor.r * a, g: clearColor.g * a, b: clearColor.b * a, a: a };
|
|
616
|
+
|
|
617
|
+
} else {
|
|
618
|
+
|
|
619
|
+
clearValue = { r: clearColor.r, g: clearColor.g, b: clearColor.b, a: clearColor.a };
|
|
620
|
+
|
|
621
|
+
}
|
|
597
622
|
|
|
598
623
|
}
|
|
599
624
|
|
|
@@ -750,12 +775,41 @@ class WebGPUBackend extends Backend {
|
|
|
750
775
|
const pipelineGPU = this.get( pipeline ).pipeline;
|
|
751
776
|
passEncoderGPU.setPipeline( pipelineGPU );
|
|
752
777
|
|
|
753
|
-
// bind
|
|
778
|
+
// bind groups
|
|
779
|
+
|
|
780
|
+
for ( let i = 0, l = bindings.length; i < l; i ++ ) {
|
|
781
|
+
|
|
782
|
+
const bindGroup = bindings[ i ];
|
|
783
|
+
const bindingsData = this.get( bindGroup );
|
|
784
|
+
|
|
785
|
+
passEncoderGPU.setBindGroup( i, bindingsData.group );
|
|
786
|
+
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
const maxComputeWorkgroupsPerDimension = this.device.limits.maxComputeWorkgroupsPerDimension;
|
|
790
|
+
|
|
791
|
+
const computeNodeData = this.get( computeNode );
|
|
792
|
+
|
|
793
|
+
if ( computeNodeData.dispatchSize === undefined ) computeNodeData.dispatchSize = { x: 0, y: 1, z: 1 };
|
|
794
|
+
|
|
795
|
+
const { dispatchSize } = computeNodeData;
|
|
754
796
|
|
|
755
|
-
|
|
756
|
-
passEncoderGPU.setBindGroup( 0, bindGroupGPU );
|
|
797
|
+
if ( computeNode.dispatchCount > maxComputeWorkgroupsPerDimension ) {
|
|
757
798
|
|
|
758
|
-
|
|
799
|
+
dispatchSize.x = Math.min( computeNode.dispatchCount, maxComputeWorkgroupsPerDimension );
|
|
800
|
+
dispatchSize.y = Math.ceil( computeNode.dispatchCount / maxComputeWorkgroupsPerDimension );
|
|
801
|
+
|
|
802
|
+
} else {
|
|
803
|
+
|
|
804
|
+
dispatchSize.x = computeNode.dispatchCount;
|
|
805
|
+
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
passEncoderGPU.dispatchWorkgroups(
|
|
809
|
+
dispatchSize.x,
|
|
810
|
+
dispatchSize.y,
|
|
811
|
+
dispatchSize.z
|
|
812
|
+
);
|
|
759
813
|
|
|
760
814
|
}
|
|
761
815
|
|
|
@@ -775,16 +829,18 @@ class WebGPUBackend extends Backend {
|
|
|
775
829
|
|
|
776
830
|
draw( renderObject, info ) {
|
|
777
831
|
|
|
778
|
-
const { object,
|
|
779
|
-
|
|
780
|
-
const
|
|
781
|
-
const contextData = this.get( context );
|
|
832
|
+
const { object, context, pipeline } = renderObject;
|
|
833
|
+
const bindings = renderObject.getBindings();
|
|
834
|
+
const renderContextData = this.get( context );
|
|
782
835
|
const pipelineGPU = this.get( pipeline ).pipeline;
|
|
783
|
-
const currentSets =
|
|
836
|
+
const currentSets = renderContextData.currentSets;
|
|
837
|
+
const passEncoderGPU = renderContextData.currentPass;
|
|
784
838
|
|
|
785
|
-
|
|
839
|
+
const drawParms = renderObject.getDrawParameters();
|
|
786
840
|
|
|
787
|
-
|
|
841
|
+
if ( drawParms === null ) return;
|
|
842
|
+
|
|
843
|
+
// pipeline
|
|
788
844
|
|
|
789
845
|
if ( currentSets.pipeline !== pipelineGPU ) {
|
|
790
846
|
|
|
@@ -794,10 +850,23 @@ class WebGPUBackend extends Backend {
|
|
|
794
850
|
|
|
795
851
|
}
|
|
796
852
|
|
|
797
|
-
// bind
|
|
853
|
+
// bind groups
|
|
854
|
+
|
|
855
|
+
const currentBindingGroups = currentSets.bindingGroups;
|
|
856
|
+
|
|
857
|
+
for ( let i = 0, l = bindings.length; i < l; i ++ ) {
|
|
858
|
+
|
|
859
|
+
const bindGroup = bindings[ i ];
|
|
860
|
+
const bindingsData = this.get( bindGroup );
|
|
798
861
|
|
|
799
|
-
|
|
800
|
-
|
|
862
|
+
if ( currentBindingGroups[ bindGroup.index ] !== bindGroup.id ) {
|
|
863
|
+
|
|
864
|
+
passEncoderGPU.setBindGroup( bindGroup.index, bindingsData.group );
|
|
865
|
+
currentBindingGroups[ bindGroup.index ] = bindGroup.id;
|
|
866
|
+
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
}
|
|
801
870
|
|
|
802
871
|
// attributes
|
|
803
872
|
|
|
@@ -843,27 +912,27 @@ class WebGPUBackend extends Backend {
|
|
|
843
912
|
|
|
844
913
|
// occlusion queries - handle multiple consecutive draw calls for an object
|
|
845
914
|
|
|
846
|
-
if (
|
|
915
|
+
if ( renderContextData.occlusionQuerySet !== undefined ) {
|
|
847
916
|
|
|
848
|
-
const lastObject =
|
|
917
|
+
const lastObject = renderContextData.lastOcclusionObject;
|
|
849
918
|
|
|
850
919
|
if ( lastObject !== object ) {
|
|
851
920
|
|
|
852
921
|
if ( lastObject !== null && lastObject.occlusionTest === true ) {
|
|
853
922
|
|
|
854
923
|
passEncoderGPU.endOcclusionQuery();
|
|
855
|
-
|
|
924
|
+
renderContextData.occlusionQueryIndex ++;
|
|
856
925
|
|
|
857
926
|
}
|
|
858
927
|
|
|
859
928
|
if ( object.occlusionTest === true ) {
|
|
860
929
|
|
|
861
|
-
passEncoderGPU.beginOcclusionQuery(
|
|
862
|
-
|
|
930
|
+
passEncoderGPU.beginOcclusionQuery( renderContextData.occlusionQueryIndex );
|
|
931
|
+
renderContextData.occlusionQueryObjects[ renderContextData.occlusionQueryIndex ] = object;
|
|
863
932
|
|
|
864
933
|
}
|
|
865
934
|
|
|
866
|
-
|
|
935
|
+
renderContextData.lastOcclusionObject = object;
|
|
867
936
|
|
|
868
937
|
}
|
|
869
938
|
|
|
@@ -871,24 +940,35 @@ class WebGPUBackend extends Backend {
|
|
|
871
940
|
|
|
872
941
|
// draw
|
|
873
942
|
|
|
874
|
-
|
|
875
|
-
const firstVertex = drawRange.start;
|
|
943
|
+
if ( object.isBatchedMesh === true ) {
|
|
876
944
|
|
|
877
|
-
|
|
878
|
-
|
|
945
|
+
const starts = object._multiDrawStarts;
|
|
946
|
+
const counts = object._multiDrawCounts;
|
|
947
|
+
const drawCount = object._multiDrawCount;
|
|
948
|
+
const drawInstances = object._multiDrawInstances;
|
|
879
949
|
|
|
880
|
-
|
|
950
|
+
const bytesPerElement = hasIndex ? index.array.BYTES_PER_ELEMENT : 1;
|
|
951
|
+
|
|
952
|
+
for ( let i = 0; i < drawCount; i ++ ) {
|
|
953
|
+
|
|
954
|
+
const count = drawInstances ? drawInstances[ i ] : 1;
|
|
955
|
+
const firstInstance = count > 1 ? 0 : i;
|
|
881
956
|
|
|
882
|
-
|
|
957
|
+
passEncoderGPU.drawIndexed( counts[ i ], count, starts[ i ] / bytesPerElement, 0, firstInstance );
|
|
958
|
+
|
|
959
|
+
}
|
|
883
960
|
|
|
884
|
-
|
|
961
|
+
} else if ( hasIndex === true ) {
|
|
962
|
+
|
|
963
|
+
const { vertexCount: indexCount, instanceCount, firstVertex: firstIndex } = drawParms;
|
|
964
|
+
|
|
965
|
+
passEncoderGPU.drawIndexed( indexCount, instanceCount, firstIndex, 0, 0 );
|
|
885
966
|
|
|
886
967
|
info.update( object, indexCount, instanceCount );
|
|
887
968
|
|
|
888
969
|
} else {
|
|
889
970
|
|
|
890
|
-
const
|
|
891
|
-
const vertexCount = ( drawRange.count !== Infinity ) ? drawRange.count : positionAttribute.count;
|
|
971
|
+
const { vertexCount, instanceCount, firstVertex } = drawParms;
|
|
892
972
|
|
|
893
973
|
passEncoderGPU.draw( vertexCount, instanceCount, firstVertex, 0 );
|
|
894
974
|
|
|
@@ -908,7 +988,7 @@ class WebGPUBackend extends Backend {
|
|
|
908
988
|
|
|
909
989
|
const utils = this.utils;
|
|
910
990
|
|
|
911
|
-
const sampleCount = utils.
|
|
991
|
+
const sampleCount = utils.getSampleCountRenderContext( renderObject.context );
|
|
912
992
|
const colorSpace = utils.getCurrentColorSpace( renderObject.context );
|
|
913
993
|
const colorFormat = utils.getCurrentColorFormat( renderObject.context );
|
|
914
994
|
const depthStencilFormat = utils.getCurrentDepthStencilFormat( renderObject.context );
|
|
@@ -928,7 +1008,7 @@ class WebGPUBackend extends Backend {
|
|
|
928
1008
|
data.sampleCount !== sampleCount || data.colorSpace !== colorSpace ||
|
|
929
1009
|
data.colorFormat !== colorFormat || data.depthStencilFormat !== depthStencilFormat ||
|
|
930
1010
|
data.primitiveTopology !== primitiveTopology ||
|
|
931
|
-
data.
|
|
1011
|
+
data.clippingContextCacheKey !== renderObject.clippingContext.cacheKey
|
|
932
1012
|
) {
|
|
933
1013
|
|
|
934
1014
|
data.material = material; data.materialVersion = material.version;
|
|
@@ -946,7 +1026,7 @@ class WebGPUBackend extends Backend {
|
|
|
946
1026
|
data.colorFormat = colorFormat;
|
|
947
1027
|
data.depthStencilFormat = depthStencilFormat;
|
|
948
1028
|
data.primitiveTopology = primitiveTopology;
|
|
949
|
-
data.
|
|
1029
|
+
data.clippingContextCacheKey = renderObject.clippingContext.cacheKey;
|
|
950
1030
|
|
|
951
1031
|
needsUpdate = true;
|
|
952
1032
|
|
|
@@ -973,10 +1053,10 @@ class WebGPUBackend extends Backend {
|
|
|
973
1053
|
material.stencilFail, material.stencilZFail, material.stencilZPass,
|
|
974
1054
|
material.stencilFuncMask, material.stencilWriteMask,
|
|
975
1055
|
material.side,
|
|
976
|
-
utils.
|
|
1056
|
+
utils.getSampleCountRenderContext( renderContext ),
|
|
977
1057
|
utils.getCurrentColorSpace( renderContext ), utils.getCurrentColorFormat( renderContext ), utils.getCurrentDepthStencilFormat( renderContext ),
|
|
978
1058
|
utils.getPrimitiveTopology( object, material ),
|
|
979
|
-
renderObject.
|
|
1059
|
+
renderObject.clippingContext.cacheKey
|
|
980
1060
|
].join();
|
|
981
1061
|
|
|
982
1062
|
}
|
|
@@ -1025,16 +1105,16 @@ class WebGPUBackend extends Backend {
|
|
|
1025
1105
|
|
|
1026
1106
|
}
|
|
1027
1107
|
|
|
1028
|
-
copyTextureToBuffer( texture, x, y, width, height ) {
|
|
1108
|
+
copyTextureToBuffer( texture, x, y, width, height, faceIndex ) {
|
|
1029
1109
|
|
|
1030
|
-
return this.textureUtils.copyTextureToBuffer( texture, x, y, width, height );
|
|
1110
|
+
return this.textureUtils.copyTextureToBuffer( texture, x, y, width, height, faceIndex );
|
|
1031
1111
|
|
|
1032
1112
|
}
|
|
1033
1113
|
|
|
1034
1114
|
|
|
1035
1115
|
initTimestampQuery( renderContext, descriptor ) {
|
|
1036
1116
|
|
|
1037
|
-
if ( ! this.
|
|
1117
|
+
if ( ! this.trackTimestamp ) return;
|
|
1038
1118
|
|
|
1039
1119
|
const renderContextData = this.get( renderContext );
|
|
1040
1120
|
|
|
@@ -1049,9 +1129,11 @@ class WebGPUBackend extends Backend {
|
|
|
1049
1129
|
beginningOfPassWriteIndex: 0, // Write timestamp in index 0 when pass begins.
|
|
1050
1130
|
endOfPassWriteIndex: 1, // Write timestamp in index 1 when pass ends.
|
|
1051
1131
|
};
|
|
1132
|
+
|
|
1052
1133
|
Object.assign( descriptor, {
|
|
1053
1134
|
timestampWrites,
|
|
1054
1135
|
} );
|
|
1136
|
+
|
|
1055
1137
|
renderContextData.timeStampQuerySet = timeStampQuerySet;
|
|
1056
1138
|
|
|
1057
1139
|
}
|
|
@@ -1062,61 +1144,75 @@ class WebGPUBackend extends Backend {
|
|
|
1062
1144
|
|
|
1063
1145
|
prepareTimestampBuffer( renderContext, encoder ) {
|
|
1064
1146
|
|
|
1065
|
-
if ( ! this.
|
|
1147
|
+
if ( ! this.trackTimestamp ) return;
|
|
1066
1148
|
|
|
1067
1149
|
const renderContextData = this.get( renderContext );
|
|
1068
1150
|
|
|
1151
|
+
|
|
1069
1152
|
const size = 2 * BigInt64Array.BYTES_PER_ELEMENT;
|
|
1070
|
-
const resolveBuffer = this.device.createBuffer( {
|
|
1071
|
-
size,
|
|
1072
|
-
usage: GPUBufferUsage.QUERY_RESOLVE | GPUBufferUsage.COPY_SRC,
|
|
1073
|
-
} );
|
|
1074
1153
|
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1154
|
+
if ( renderContextData.currentTimestampQueryBuffers === undefined ) {
|
|
1155
|
+
|
|
1156
|
+
renderContextData.currentTimestampQueryBuffers = {
|
|
1157
|
+
resolveBuffer: this.device.createBuffer( {
|
|
1158
|
+
label: 'timestamp resolve buffer',
|
|
1159
|
+
size: size,
|
|
1160
|
+
usage: GPUBufferUsage.QUERY_RESOLVE | GPUBufferUsage.COPY_SRC,
|
|
1161
|
+
} ),
|
|
1162
|
+
resultBuffer: this.device.createBuffer( {
|
|
1163
|
+
label: 'timestamp result buffer',
|
|
1164
|
+
size: size,
|
|
1165
|
+
usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ,
|
|
1166
|
+
} ),
|
|
1167
|
+
isMappingPending: false,
|
|
1168
|
+
};
|
|
1169
|
+
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
const { resolveBuffer, resultBuffer, isMappingPending } = renderContextData.currentTimestampQueryBuffers;
|
|
1173
|
+
|
|
1174
|
+
if ( isMappingPending === true ) return;
|
|
1079
1175
|
|
|
1080
1176
|
encoder.resolveQuerySet( renderContextData.timeStampQuerySet, 0, 2, resolveBuffer, 0 );
|
|
1081
1177
|
encoder.copyBufferToBuffer( resolveBuffer, 0, resultBuffer, 0, size );
|
|
1082
1178
|
|
|
1083
|
-
renderContextData.currentTimestampQueryBuffer = resultBuffer;
|
|
1084
|
-
|
|
1085
1179
|
}
|
|
1086
1180
|
|
|
1087
1181
|
async resolveTimestampAsync( renderContext, type = 'render' ) {
|
|
1088
1182
|
|
|
1089
|
-
if ( ! this.
|
|
1183
|
+
if ( ! this.trackTimestamp ) return;
|
|
1090
1184
|
|
|
1091
1185
|
const renderContextData = this.get( renderContext );
|
|
1092
1186
|
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
const { currentTimestampQueryBuffer } = renderContextData;
|
|
1187
|
+
if ( renderContextData.currentTimestampQueryBuffers === undefined ) return;
|
|
1096
1188
|
|
|
1097
|
-
|
|
1189
|
+
const { resultBuffer, isMappingPending } = renderContextData.currentTimestampQueryBuffers;
|
|
1098
1190
|
|
|
1099
|
-
|
|
1191
|
+
if ( isMappingPending === true ) return;
|
|
1100
1192
|
|
|
1101
|
-
|
|
1193
|
+
renderContextData.currentTimestampQueryBuffers.isMappingPending = true;
|
|
1102
1194
|
|
|
1103
|
-
|
|
1195
|
+
resultBuffer.mapAsync( GPUMapMode.READ ).then( () => {
|
|
1104
1196
|
|
|
1197
|
+
const times = new BigUint64Array( resultBuffer.getMappedRange() );
|
|
1105
1198
|
const duration = Number( times[ 1 ] - times[ 0 ] ) / 1000000;
|
|
1106
|
-
|
|
1199
|
+
|
|
1200
|
+
|
|
1107
1201
|
this.renderer.info.updateTimestamp( type, duration );
|
|
1108
1202
|
|
|
1109
|
-
|
|
1203
|
+
resultBuffer.unmap();
|
|
1110
1204
|
|
|
1111
|
-
|
|
1205
|
+
renderContextData.currentTimestampQueryBuffers.isMappingPending = false;
|
|
1206
|
+
|
|
1207
|
+
} );
|
|
1112
1208
|
|
|
1113
1209
|
}
|
|
1114
1210
|
|
|
1115
1211
|
// node builder
|
|
1116
1212
|
|
|
1117
|
-
createNodeBuilder( object, renderer
|
|
1213
|
+
createNodeBuilder( object, renderer ) {
|
|
1118
1214
|
|
|
1119
|
-
return new WGSLNodeBuilder( object, renderer
|
|
1215
|
+
return new WGSLNodeBuilder( object, renderer );
|
|
1120
1216
|
|
|
1121
1217
|
}
|
|
1122
1218
|
|
|
@@ -1153,17 +1249,53 @@ class WebGPUBackend extends Backend {
|
|
|
1153
1249
|
|
|
1154
1250
|
}
|
|
1155
1251
|
|
|
1252
|
+
beginBundle( renderContext ) {
|
|
1253
|
+
|
|
1254
|
+
const renderContextData = this.get( renderContext );
|
|
1255
|
+
|
|
1256
|
+
renderContextData._currentPass = renderContextData.currentPass;
|
|
1257
|
+
renderContextData._currentSets = renderContextData.currentSets;
|
|
1258
|
+
|
|
1259
|
+
renderContextData.currentSets = { attributes: {}, bindingGroups: [], pipeline: null, index: null };
|
|
1260
|
+
renderContextData.currentPass = this.pipelineUtils.createBundleEncoder( renderContext );
|
|
1261
|
+
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
finishBundle( renderContext, bundle ) {
|
|
1265
|
+
|
|
1266
|
+
const renderContextData = this.get( renderContext );
|
|
1267
|
+
|
|
1268
|
+
const bundleEncoder = renderContextData.currentPass;
|
|
1269
|
+
const bundleGPU = bundleEncoder.finish();
|
|
1270
|
+
|
|
1271
|
+
this.get( bundle ).bundleGPU = bundleGPU;
|
|
1272
|
+
|
|
1273
|
+
// restore render pass state
|
|
1274
|
+
|
|
1275
|
+
renderContextData.currentSets = renderContextData._currentSets;
|
|
1276
|
+
renderContextData.currentPass = renderContextData._currentPass;
|
|
1277
|
+
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
addBundle( renderContext, bundle ) {
|
|
1281
|
+
|
|
1282
|
+
const renderContextData = this.get( renderContext );
|
|
1283
|
+
|
|
1284
|
+
renderContextData.renderBundles.push( this.get( bundle ).bundleGPU );
|
|
1285
|
+
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1156
1288
|
// bindings
|
|
1157
1289
|
|
|
1158
|
-
createBindings(
|
|
1290
|
+
createBindings( bindGroup ) {
|
|
1159
1291
|
|
|
1160
|
-
this.bindingUtils.createBindings(
|
|
1292
|
+
this.bindingUtils.createBindings( bindGroup );
|
|
1161
1293
|
|
|
1162
1294
|
}
|
|
1163
1295
|
|
|
1164
|
-
updateBindings(
|
|
1296
|
+
updateBindings( bindGroup ) {
|
|
1165
1297
|
|
|
1166
|
-
this.bindingUtils.createBindings(
|
|
1298
|
+
this.bindingUtils.createBindings( bindGroup );
|
|
1167
1299
|
|
|
1168
1300
|
}
|
|
1169
1301
|
|
|
@@ -1222,31 +1354,71 @@ class WebGPUBackend extends Backend {
|
|
|
1222
1354
|
|
|
1223
1355
|
}
|
|
1224
1356
|
|
|
1225
|
-
|
|
1357
|
+
hasFeature( name ) {
|
|
1226
1358
|
|
|
1227
|
-
|
|
1359
|
+
return this.device.features.has( name );
|
|
1228
1360
|
|
|
1229
|
-
|
|
1361
|
+
}
|
|
1230
1362
|
|
|
1231
|
-
|
|
1363
|
+
copyTextureToTexture( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) {
|
|
1232
1364
|
|
|
1233
|
-
|
|
1365
|
+
let dstX = 0;
|
|
1366
|
+
let dstY = 0;
|
|
1367
|
+
let dstLayer = 0;
|
|
1234
1368
|
|
|
1235
|
-
|
|
1369
|
+
let srcX = 0;
|
|
1370
|
+
let srcY = 0;
|
|
1371
|
+
let srcLayer = 0;
|
|
1372
|
+
|
|
1373
|
+
let srcWidth = srcTexture.image.width;
|
|
1374
|
+
let srcHeight = srcTexture.image.height;
|
|
1236
1375
|
|
|
1237
|
-
if (
|
|
1376
|
+
if ( srcRegion !== null ) {
|
|
1238
1377
|
|
|
1239
|
-
|
|
1378
|
+
srcX = srcRegion.x;
|
|
1379
|
+
srcY = srcRegion.y;
|
|
1380
|
+
srcLayer = srcRegion.z || 0;
|
|
1381
|
+
srcWidth = srcRegion.width;
|
|
1382
|
+
srcHeight = srcRegion.height;
|
|
1240
1383
|
|
|
1241
|
-
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
if ( dstPosition !== null ) {
|
|
1387
|
+
|
|
1388
|
+
dstX = dstPosition.x;
|
|
1389
|
+
dstY = dstPosition.y;
|
|
1390
|
+
dstLayer = dstPosition.z || 0;
|
|
1242
1391
|
|
|
1243
1392
|
}
|
|
1244
1393
|
|
|
1245
|
-
|
|
1394
|
+
const encoder = this.device.createCommandEncoder( { label: 'copyTextureToTexture_' + srcTexture.id + '_' + dstTexture.id } );
|
|
1395
|
+
|
|
1396
|
+
const sourceGPU = this.get( srcTexture ).texture;
|
|
1397
|
+
const destinationGPU = this.get( dstTexture ).texture;
|
|
1398
|
+
|
|
1399
|
+
encoder.copyTextureToTexture(
|
|
1400
|
+
{
|
|
1401
|
+
texture: sourceGPU,
|
|
1402
|
+
mipLevel: level,
|
|
1403
|
+
origin: { x: srcX, y: srcY, z: srcLayer }
|
|
1404
|
+
},
|
|
1405
|
+
{
|
|
1406
|
+
texture: destinationGPU,
|
|
1407
|
+
mipLevel: level,
|
|
1408
|
+
origin: { x: dstX, y: dstY, z: dstLayer }
|
|
1409
|
+
},
|
|
1410
|
+
[
|
|
1411
|
+
srcWidth,
|
|
1412
|
+
srcHeight,
|
|
1413
|
+
1
|
|
1414
|
+
]
|
|
1415
|
+
);
|
|
1416
|
+
|
|
1417
|
+
this.device.queue.submit( [ encoder.finish() ] );
|
|
1246
1418
|
|
|
1247
1419
|
}
|
|
1248
1420
|
|
|
1249
|
-
copyFramebufferToTexture( texture, renderContext ) {
|
|
1421
|
+
copyFramebufferToTexture( texture, renderContext, rectangle ) {
|
|
1250
1422
|
|
|
1251
1423
|
const renderContextData = this.get( renderContext );
|
|
1252
1424
|
|
|
@@ -1295,25 +1467,30 @@ class WebGPUBackend extends Backend {
|
|
|
1295
1467
|
encoder.copyTextureToTexture(
|
|
1296
1468
|
{
|
|
1297
1469
|
texture: sourceGPU,
|
|
1298
|
-
origin: { x:
|
|
1470
|
+
origin: { x: rectangle.x, y: rectangle.y, z: 0 }
|
|
1299
1471
|
},
|
|
1300
1472
|
{
|
|
1301
1473
|
texture: destinationGPU
|
|
1302
1474
|
},
|
|
1303
1475
|
[
|
|
1304
|
-
|
|
1305
|
-
|
|
1476
|
+
rectangle.z,
|
|
1477
|
+
rectangle.w
|
|
1306
1478
|
]
|
|
1307
1479
|
);
|
|
1308
1480
|
|
|
1309
1481
|
if ( texture.generateMipmaps ) this.textureUtils.generateMipmaps( texture );
|
|
1310
1482
|
|
|
1311
|
-
descriptor.colorAttachments
|
|
1483
|
+
for ( let i = 0; i < descriptor.colorAttachments.length; i ++ ) {
|
|
1484
|
+
|
|
1485
|
+
descriptor.colorAttachments[ i ].loadOp = GPULoadOp.Load;
|
|
1486
|
+
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1312
1489
|
if ( renderContext.depth ) descriptor.depthStencilAttachment.depthLoadOp = GPULoadOp.Load;
|
|
1313
1490
|
if ( renderContext.stencil ) descriptor.depthStencilAttachment.stencilLoadOp = GPULoadOp.Load;
|
|
1314
1491
|
|
|
1315
1492
|
renderContextData.currentPass = encoder.beginRenderPass( descriptor );
|
|
1316
|
-
renderContextData.currentSets = { attributes: {} };
|
|
1493
|
+
renderContextData.currentSets = { attributes: {}, bindingGroups: [], pipeline: null, index: null };
|
|
1317
1494
|
|
|
1318
1495
|
}
|
|
1319
1496
|
|