super-three 0.164.0 → 0.167.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/build/three.cjs +1273 -503
- package/build/three.module.js +1269 -504
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +76086 -0
- package/build/three.webgpu.min.js +6 -0
- package/examples/jsm/Addons.js +2 -1
- package/examples/jsm/controls/TransformControls.js +1 -1
- package/examples/jsm/csm/CSMShader.js +4 -4
- package/examples/jsm/environments/RoomEnvironment.js +1 -5
- package/examples/jsm/exporters/GLTFExporter.js +8 -4
- package/examples/jsm/exporters/USDZExporter.js +6 -4
- package/examples/jsm/geometries/TeapotGeometry.js +1 -1
- package/examples/jsm/helpers/ViewHelper.js +75 -61
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +91 -0
- package/examples/jsm/lights/RectAreaLightUniformsLib.js +8 -63
- package/examples/jsm/lines/LineMaterial.js +1 -15
- 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/DRACOLoader.js +1 -1
- package/examples/jsm/loaders/FBXLoader.js +47 -58
- package/examples/jsm/loaders/GLTFLoader.js +12 -4
- package/examples/jsm/loaders/LDrawLoader.js +3 -2
- package/examples/jsm/loaders/MMDLoader.js +31 -12
- package/examples/jsm/loaders/MaterialXLoader.js +2 -9
- package/examples/jsm/loaders/USDZLoader.js +124 -76
- package/examples/jsm/loaders/UltraHDRLoader.js +583 -0
- package/examples/jsm/loaders/VTKLoader.js +76 -3
- package/examples/jsm/misc/GPUComputationRenderer.js +9 -19
- package/examples/jsm/modifiers/CurveModifier.js +11 -9
- 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/postprocessing/RenderPass.js +1 -1
- package/examples/jsm/postprocessing/RenderTransitionPass.js +13 -38
- package/examples/jsm/postprocessing/SSAOPass.js +6 -9
- 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/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/transpiler/GLSLDecoder.js +46 -4
- package/examples/jsm/transpiler/TSLEncoder.js +17 -15
- package/examples/jsm/utils/BufferGeometryUtils.js +18 -16
- package/examples/jsm/utils/GPUStatsPanel.js +2 -0
- package/examples/jsm/utils/SortUtils.js +8 -5
- package/package.json +9 -7
- package/src/Three.WebGPU.js +194 -0
- package/src/Three.js +2 -0
- 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/constants.js +4 -1
- package/src/core/Object3D.js +24 -22
- package/src/core/Raycaster.js +6 -2
- package/src/extras/TextureUtils.js +210 -0
- 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 +4 -0
- package/src/loaders/LoaderUtils.js +3 -1
- package/src/loaders/ObjectLoader.js +34 -2
- package/src/materials/Material.js +13 -4
- 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/Vector4.js +13 -0
- package/{examples/jsm → src}/nodes/Nodes.js +39 -20
- package/{examples/jsm → src}/nodes/accessors/BatchNode.js +28 -10
- package/src/nodes/accessors/BitangentNode.js +13 -0
- package/{examples/jsm → src}/nodes/accessors/BufferAttributeNode.js +36 -1
- package/{examples/jsm → src}/nodes/accessors/BufferNode.js +6 -0
- package/src/nodes/accessors/CameraNode.js +19 -0
- package/{examples/jsm → src}/nodes/accessors/CubeTextureNode.js +22 -5
- package/src/nodes/accessors/InstanceNode.js +140 -0
- package/{examples/jsm → src}/nodes/accessors/MaterialNode.js +24 -2
- package/{examples/jsm → src}/nodes/accessors/ModelNode.js +4 -0
- package/{examples/jsm → src}/nodes/accessors/MorphNode.js +24 -20
- package/src/nodes/accessors/NormalNode.js +14 -0
- package/{examples/jsm → src}/nodes/accessors/Object3DNode.js +1 -1
- package/src/nodes/accessors/PositionNode.js +10 -0
- package/{examples/jsm → src}/nodes/accessors/ReferenceNode.js +7 -1
- package/src/nodes/accessors/ReflectVectorNode.js +10 -0
- package/{examples/jsm → src}/nodes/accessors/StorageBufferNode.js +50 -1
- package/{examples/jsm/nodes/accessors/TextureStoreNode.js → src/nodes/accessors/StorageTextureNode.js} +28 -6
- package/src/nodes/accessors/TangentNode.js +23 -0
- package/src/nodes/accessors/Texture3DNode.js +100 -0
- package/{examples/jsm → src}/nodes/accessors/TextureNode.js +55 -18
- package/src/nodes/accessors/UVNode.js +3 -0
- package/{examples/jsm → src}/nodes/accessors/UniformsNode.js +7 -1
- package/{examples/jsm → src}/nodes/accessors/VertexColorNode.js +2 -1
- package/{examples/jsm → src}/nodes/code/ScriptableNode.js +14 -0
- package/{examples/jsm → src}/nodes/code/ScriptableValueNode.js +2 -1
- package/{examples/jsm → src}/nodes/core/AttributeNode.js +34 -8
- package/{examples/jsm → src}/nodes/core/CacheNode.js +7 -10
- package/{examples/jsm → src}/nodes/core/ContextNode.js +6 -0
- package/{examples/jsm → src}/nodes/core/IndexNode.js +6 -0
- package/{examples/jsm → src}/nodes/core/LightingModel.js +2 -2
- package/src/nodes/core/MRTNode.js +76 -0
- package/{examples/jsm → src}/nodes/core/Node.js +33 -14
- package/{examples/jsm → src}/nodes/core/NodeBuilder.js +194 -45
- package/src/nodes/core/NodeCache.js +36 -0
- package/{examples/jsm → src}/nodes/core/NodeFrame.js +42 -0
- package/{examples/jsm → src}/nodes/core/NodeFunction.js +2 -2
- package/{examples/jsm → src}/nodes/core/NodeKeywords.js +1 -1
- package/{examples/jsm → src}/nodes/core/NodeUniform.js +1 -2
- package/{examples/jsm → src}/nodes/core/NodeUtils.js +6 -1
- package/{examples/jsm → src}/nodes/core/OutputStructNode.js +1 -5
- package/{examples/jsm → src}/nodes/core/PropertyNode.js +2 -0
- package/{examples/jsm → src}/nodes/core/TempNode.js +2 -2
- package/{examples/jsm → src}/nodes/core/UniformGroupNode.js +20 -0
- package/{examples/jsm → src}/nodes/core/UniformNode.js +10 -1
- package/{examples/jsm → src}/nodes/core/VarNode.js +2 -6
- package/src/nodes/core/VaryingNode.js +104 -0
- package/{examples/jsm → src}/nodes/display/AfterImageNode.js +24 -20
- package/{examples/jsm → src}/nodes/display/AnamorphicNode.js +18 -21
- package/src/nodes/display/BloomNode.js +333 -0
- package/{examples/jsm → src}/nodes/display/ColorAdjustmentNode.js +7 -2
- package/{examples/jsm → src}/nodes/display/ColorSpaceNode.js +1 -1
- package/src/nodes/display/DenoiseNode.js +198 -0
- package/src/nodes/display/DepthOfFieldNode.js +119 -0
- package/src/nodes/display/DotScreenNode.js +75 -0
- package/src/nodes/display/FXAANode.js +327 -0
- package/src/nodes/display/FilmNode.js +52 -0
- package/{examples/jsm → src}/nodes/display/FrontFacingNode.js +2 -1
- package/src/nodes/display/GTAONode.js +324 -0
- package/{examples/jsm → src}/nodes/display/GaussianBlurNode.js +34 -17
- package/src/nodes/display/Lut3DNode.js +53 -0
- package/{examples/jsm → src}/nodes/display/NormalMapNode.js +1 -1
- package/src/nodes/display/PassNode.js +291 -0
- package/src/nodes/display/PixelationPassNode.js +201 -0
- package/src/nodes/display/RGBShiftNode.js +49 -0
- package/src/nodes/display/RenderOutputNode.js +56 -0
- package/src/nodes/display/SobelOperatorNode.js +121 -0
- package/{examples/jsm → src}/nodes/display/ToneMappingNode.js +44 -5
- package/src/nodes/display/TransitionNode.js +76 -0
- package/{examples/jsm → src}/nodes/display/ViewportDepthNode.js +39 -16
- package/{examples/jsm → src}/nodes/display/ViewportDepthTextureNode.js +2 -1
- package/{examples/jsm → src}/nodes/display/ViewportNode.js +3 -2
- package/{examples/jsm → src}/nodes/display/ViewportSharedTextureNode.js +2 -1
- package/{examples/jsm → src}/nodes/display/ViewportTextureNode.js +5 -2
- package/src/nodes/functions/BSDF/LTC.js +131 -0
- package/src/nodes/functions/BasicLightingModel.js +78 -0
- package/{examples/jsm → src}/nodes/functions/PhongLightingModel.js +5 -3
- package/{examples/jsm → src}/nodes/functions/PhysicalLightingModel.js +103 -18
- package/src/nodes/functions/ToonLightingModel.js +51 -0
- package/{examples/jsm → src}/nodes/geometry/RangeNode.js +19 -6
- package/{examples/jsm → src}/nodes/lighting/AONode.js +1 -4
- package/{examples/jsm → src}/nodes/lighting/AmbientLightNode.js +1 -1
- package/src/nodes/lighting/AnalyticLightNode.js +333 -0
- package/src/nodes/lighting/BasicEnvironmentNode.js +26 -0
- package/src/nodes/lighting/BasicLightMapNode.js +29 -0
- package/{examples/jsm → src}/nodes/lighting/DirectionalLightNode.js +2 -3
- package/{examples/jsm → src}/nodes/lighting/EnvironmentNode.js +5 -4
- package/{examples/jsm → src}/nodes/lighting/HemisphereLightNode.js +2 -1
- package/{examples/jsm → src}/nodes/lighting/IESSpotLightNode.js +1 -1
- package/{examples/jsm → src}/nodes/lighting/LightingNode.js +2 -0
- package/{examples/jsm → src}/nodes/lighting/LightsNode.js +18 -3
- package/{examples/jsm → src}/nodes/lighting/PointLightNode.js +2 -3
- package/src/nodes/lighting/RectAreaLightNode.js +97 -0
- package/{examples/jsm → src}/nodes/lighting/SpotLightNode.js +2 -3
- package/{examples/jsm → src}/nodes/loaders/NodeLoader.js +3 -1
- package/{examples/jsm → src}/nodes/loaders/NodeMaterialLoader.js +2 -1
- package/{examples/jsm → src}/nodes/loaders/NodeObjectLoader.js +2 -1
- package/{examples/jsm → src}/nodes/materials/InstancedPointsNodeMaterial.js +3 -3
- package/{examples/jsm → src}/nodes/materials/Line2NodeMaterial.js +4 -4
- package/{examples/jsm → src}/nodes/materials/LineBasicNodeMaterial.js +3 -3
- package/{examples/jsm → src}/nodes/materials/LineDashedNodeMaterial.js +4 -3
- package/{examples/jsm → src}/nodes/materials/Materials.js +3 -0
- package/src/nodes/materials/MeshBasicNodeMaterial.js +73 -0
- package/{examples/jsm → src}/nodes/materials/MeshLambertNodeMaterial.js +12 -3
- package/src/nodes/materials/MeshMatcapNodeMaterial.js +53 -0
- package/{examples/jsm → src}/nodes/materials/MeshNormalNodeMaterial.js +5 -3
- package/{examples/jsm → src}/nodes/materials/MeshPhongNodeMaterial.js +11 -3
- package/{examples/jsm → src}/nodes/materials/MeshPhysicalNodeMaterial.js +26 -8
- package/{examples/jsm → src}/nodes/materials/MeshStandardNodeMaterial.js +14 -3
- package/src/nodes/materials/MeshToonNodeMaterial.js +34 -0
- package/{examples/jsm → src}/nodes/materials/NodeMaterial.js +97 -24
- package/{examples/jsm → src}/nodes/materials/PointsNodeMaterial.js +3 -3
- package/{examples/jsm → src}/nodes/materials/ShadowNodeMaterial.js +3 -3
- package/{examples/jsm → src}/nodes/materials/SpriteNodeMaterial.js +3 -3
- package/src/nodes/materials/VolumeNodeMaterial.js +106 -0
- package/{examples/jsm → src}/nodes/materialx/lib/mx_hsv.js +9 -17
- package/{examples/jsm → src}/nodes/materialx/lib/mx_noise.js +474 -577
- package/{examples/jsm → src}/nodes/materialx/lib/mx_transform_color.js +2 -8
- package/{examples/jsm → src}/nodes/math/CondNode.js +13 -6
- package/{examples/jsm → src}/nodes/math/HashNode.js +2 -2
- package/{examples/jsm → src}/nodes/math/MathNode.js +14 -1
- package/{examples/jsm → src}/nodes/math/OperatorNode.js +6 -6
- package/{examples/jsm → src}/nodes/parsers/GLSLNodeFunction.js +7 -7
- package/{examples/jsm → src}/nodes/pmrem/PMREMNode.js +2 -1
- package/{examples/jsm → src}/nodes/shadernode/ShaderNode.js +57 -33
- package/{examples/jsm → src}/nodes/utils/ArrayElementNode.js +1 -1
- package/{examples/jsm → src}/nodes/utils/DiscardNode.js +1 -0
- package/{examples/jsm → src}/nodes/utils/FunctionOverloadingNode.js +2 -0
- package/{examples/jsm → src}/nodes/utils/LoopNode.js +7 -6
- package/{examples/jsm → src}/nodes/utils/MatcapUVNode.js +1 -1
- package/{examples/jsm → src}/nodes/utils/MaxMipLevelNode.js +8 -2
- package/src/nodes/utils/RTTNode.js +130 -0
- package/{examples/jsm → src}/nodes/utils/ReflectorNode.js +9 -1
- package/{examples/jsm → src}/nodes/utils/TimerNode.js +1 -1
- package/src/objects/BatchedMesh.js +232 -162
- package/src/objects/InstancedMesh.js +1 -1
- package/src/renderers/WebGLRenderer.js +312 -68
- 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 +9 -3
- package/src/renderers/common/BindGroup.js +16 -0
- package/{examples/jsm → src}/renderers/common/Bindings.js +54 -22
- package/src/renderers/common/ChainMap.js +59 -0
- package/{examples/jsm → src}/renderers/common/ClippingContext.js +8 -6
- package/{examples/jsm → src}/renderers/common/Color4.js +1 -1
- package/{examples/jsm → src}/renderers/common/CubeRenderTarget.js +7 -1
- package/{examples/jsm → src}/renderers/common/Geometries.js +37 -5
- package/{examples/jsm → src}/renderers/common/Info.js +34 -6
- package/{examples/jsm → src}/renderers/common/Pipelines.js +2 -2
- package/src/renderers/common/PostProcessing.js +87 -0
- package/{examples/jsm/objects → src/renderers/common}/QuadMesh.js +6 -3
- package/src/renderers/common/RenderBundle.js +18 -0
- package/src/renderers/common/RenderBundles.js +38 -0
- package/{examples/jsm → src}/renderers/common/RenderContext.js +1 -1
- package/{examples/jsm → src}/renderers/common/RenderContexts.js +1 -1
- package/{examples/jsm → src}/renderers/common/RenderList.js +9 -0
- package/{examples/jsm → src}/renderers/common/RenderObject.js +50 -11
- package/{examples/jsm → src}/renderers/common/Renderer.js +220 -40
- package/{examples/jsm → src}/renderers/common/SampledTexture.js +2 -2
- 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 +6 -2
- package/{examples/jsm → src}/renderers/common/Uniform.js +10 -5
- package/{examples/jsm → src}/renderers/common/UniformsGroup.js +69 -31
- package/{examples/jsm → src}/renderers/common/extras/PMREMGenerator.js +13 -12
- package/src/renderers/common/nodes/NodeBuilderState.js +58 -0
- package/{examples/jsm → src}/renderers/common/nodes/NodeSampledTexture.js +19 -4
- 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 +37 -16
- 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/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 +7 -4
- 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/ShaderLib/depth.glsl.js +8 -0
- package/src/renderers/shaders/UniformsLib.js +3 -0
- package/src/renderers/webgl/WebGLAttributes.js +2 -2
- package/src/renderers/webgl/WebGLBackground.js +6 -0
- package/src/renderers/webgl/WebGLBufferRenderer.js +6 -19
- package/src/renderers/webgl/WebGLExtensions.js +3 -1
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +6 -18
- package/src/renderers/webgl/WebGLLights.js +15 -12
- package/src/renderers/webgl/WebGLMaterials.js +1 -5
- package/src/renderers/webgl/WebGLMorphtargets.js +1 -2
- package/src/renderers/webgl/WebGLProgram.js +28 -31
- package/src/renderers/webgl/WebGLPrograms.js +15 -15
- package/src/renderers/webgl/WebGLRenderStates.js +2 -2
- package/src/renderers/webgl/WebGLTextures.js +100 -70
- package/src/renderers/webgl/WebGLUniforms.js +12 -2
- package/src/renderers/webgl/WebGLUniformsGroups.js +7 -7
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/WebGLBackend.js +156 -54
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/nodes/GLSLNodeBuilder.js +188 -41
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLAttributeUtils.js +2 -2
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLConstants.js +1 -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 +1 -1
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLTextureUtils.js +126 -7
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLUtils.js +1 -1
- package/{examples/jsm → src}/renderers/webgpu/WebGPUBackend.js +212 -78
- package/{examples/jsm → src}/renderers/webgpu/WebGPURenderer.js +2 -2
- package/{examples/jsm → src}/renderers/webgpu/nodes/WGSLNodeBuilder.js +245 -49
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +159 -0
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUAttributeUtils.js +2 -1
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUBindingUtils.js +30 -14
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUConstants.js +9 -1
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUPipelineUtils.js +74 -24
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUTextureUtils.js +101 -25
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUUtils.js +24 -3
- package/src/renderers/webxr/WebXRDepthSensing.js +9 -3
- package/src/renderers/webxr/WebXRManager.js +12 -2
- package/src/textures/CompressedArrayTexture.js +14 -0
- package/src/textures/DataArrayTexture.js +14 -0
- package/src/textures/DepthTexture.js +1 -3
- package/src/utils.js +30 -1
- package/examples/jsm/nodes/accessors/BitangentNode.js +0 -89
- package/examples/jsm/nodes/accessors/CameraNode.js +0 -119
- package/examples/jsm/nodes/accessors/InstanceNode.js +0 -94
- package/examples/jsm/nodes/accessors/NormalNode.js +0 -106
- package/examples/jsm/nodes/accessors/PositionNode.js +0 -104
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +0 -35
- package/examples/jsm/nodes/accessors/TangentNode.js +0 -109
- package/examples/jsm/nodes/accessors/UVNode.js +0 -47
- package/examples/jsm/nodes/core/NodeCache.js +0 -26
- package/examples/jsm/nodes/core/VaryingNode.js +0 -65
- package/examples/jsm/nodes/display/PassNode.js +0 -199
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +0 -255
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +0 -28
- package/examples/jsm/renderers/common/ChainMap.js +0 -89
- package/examples/jsm/renderers/common/PostProcessing.js +0 -33
- package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +0 -44
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +0 -104
- /package/{examples/jsm → src}/nodes/accessors/AccessorsUtils.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/ClippingNode.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/InstancedPointsMaterialNode.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/MaterialReferenceNode.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/ModelViewProjectionNode.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/PointUVNode.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/RendererReferenceNode.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/SceneNode.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/SkinningNode.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/TextureBicubicNode.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/TextureSizeNode.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/UserDataNode.js +0 -0
- /package/{examples/jsm → src}/nodes/code/CodeNode.js +0 -0
- /package/{examples/jsm → src}/nodes/code/ExpressionNode.js +0 -0
- /package/{examples/jsm → src}/nodes/code/FunctionCallNode.js +0 -0
- /package/{examples/jsm → src}/nodes/code/FunctionNode.js +0 -0
- /package/{examples/jsm → src}/nodes/core/AssignNode.js +0 -0
- /package/{examples/jsm → src}/nodes/core/BypassNode.js +0 -0
- /package/{examples/jsm → src}/nodes/core/ConstNode.js +0 -0
- /package/{examples/jsm → src}/nodes/core/InputNode.js +0 -0
- /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/ParameterNode.js +0 -0
- /package/{examples/jsm → src}/nodes/core/StackNode.js +0 -0
- /package/{examples/jsm → src}/nodes/core/StructTypeNode.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/display/BlendModeNode.js +0 -0
- /package/{examples/jsm → src}/nodes/display/BumpMapNode.js +0 -0
- /package/{examples/jsm → src}/nodes/display/PosterizeNode.js +0 -0
- /package/{examples/jsm → src}/nodes/fog/FogExp2Node.js +0 -0
- /package/{examples/jsm → src}/nodes/fog/FogNode.js +0 -0
- /package/{examples/jsm → src}/nodes/fog/FogRangeNode.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_GGX.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_Lambert.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_Sheen.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/BSDF/DFGApprox.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/BSDF/D_GGX.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/BSDF/D_GGX_Anisotropic.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/BSDF/EnvironmentBRDF.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/BSDF/F_Schlick.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/BSDF/Schlick_to_F0.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/ShadowMaskModel.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/material/getGeometryRoughness.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/material/getRoughness.js +0 -0
- /package/{examples/jsm → src}/nodes/gpgpu/ComputeNode.js +0 -0
- /package/{examples/jsm → src}/nodes/lighting/IrradianceNode.js +0 -0
- /package/{examples/jsm → src}/nodes/lighting/LightNode.js +0 -0
- /package/{examples/jsm → src}/nodes/lighting/LightUtils.js +0 -0
- /package/{examples/jsm → src}/nodes/lighting/LightingContextNode.js +0 -0
- /package/{examples/jsm → src}/nodes/materials/MeshSSSNodeMaterial.js +0 -0
- /package/{examples/jsm → src}/nodes/materialx/DISCLAIMER.md +0 -0
- /package/{examples/jsm → src}/nodes/materialx/MaterialXNodes.js +0 -0
- /package/{examples/jsm → src}/nodes/math/MathUtils.js +0 -0
- /package/{examples/jsm → src}/nodes/math/TriNoise3D.js +0 -0
- /package/{examples/jsm → src}/nodes/parsers/GLSLNodeParser.js +0 -0
- /package/{examples/jsm → src}/nodes/pmrem/PMREMUtils.js +0 -0
- /package/{examples/jsm → src}/nodes/procedural/CheckerNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/ConvertNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/EquirectUVNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/JoinNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/OscNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/PackingNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/RemapNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/RotateNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/RotateUVNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/SetNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/SplitNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/SpriteSheetUVNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/StorageArrayElementNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/TriplanarTexturesNode.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Animation.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/RenderObjects.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}/WebGLBufferRenderer.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
- /package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUTexturePassUtils.js +0 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import NodeFunction from '../../../nodes/core/NodeFunction.js';
|
|
2
|
+
import NodeFunctionInput from '../../../nodes/core/NodeFunctionInput.js';
|
|
3
|
+
|
|
4
|
+
const declarationRegexp = /^[fn]*\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)\s*[\-\>]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i;
|
|
5
|
+
const propertiesRegexp = /([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/ig;
|
|
6
|
+
|
|
7
|
+
const wgslTypeLib = {
|
|
8
|
+
'f32': 'float',
|
|
9
|
+
'i32': 'int',
|
|
10
|
+
'u32': 'uint',
|
|
11
|
+
'bool': 'bool',
|
|
12
|
+
|
|
13
|
+
'vec2<f32>': 'vec2',
|
|
14
|
+
'vec2<i32>': 'ivec2',
|
|
15
|
+
'vec2<u32>': 'uvec2',
|
|
16
|
+
'vec2<bool>': 'bvec2',
|
|
17
|
+
|
|
18
|
+
'vec2f': 'vec2',
|
|
19
|
+
'vec2i': 'ivec2',
|
|
20
|
+
'vec2u': 'uvec2',
|
|
21
|
+
'vec2b': 'bvec2',
|
|
22
|
+
|
|
23
|
+
'vec3<f32>': 'vec3',
|
|
24
|
+
'vec3<i32>': 'ivec3',
|
|
25
|
+
'vec3<u32>': 'uvec3',
|
|
26
|
+
'vec3<bool>': 'bvec3',
|
|
27
|
+
|
|
28
|
+
'vec3f': 'vec3',
|
|
29
|
+
'vec3i': 'ivec3',
|
|
30
|
+
'vec3u': 'uvec3',
|
|
31
|
+
'vec3b': 'bvec3',
|
|
32
|
+
|
|
33
|
+
'vec4<f32>': 'vec4',
|
|
34
|
+
'vec4<i32>': 'ivec4',
|
|
35
|
+
'vec4<u32>': 'uvec4',
|
|
36
|
+
'vec4<bool>': 'bvec4',
|
|
37
|
+
|
|
38
|
+
'vec4f': 'vec4',
|
|
39
|
+
'vec4i': 'ivec4',
|
|
40
|
+
'vec4u': 'uvec4',
|
|
41
|
+
'vec4b': 'bvec4',
|
|
42
|
+
|
|
43
|
+
'mat2x2<f32>': 'mat2',
|
|
44
|
+
'mat2x2f': 'mat2',
|
|
45
|
+
|
|
46
|
+
'mat3x3<f32>': 'mat3',
|
|
47
|
+
'mat3x3f': 'mat3',
|
|
48
|
+
|
|
49
|
+
'mat4x4<f32>': 'mat4',
|
|
50
|
+
'mat4x4f': 'mat4',
|
|
51
|
+
|
|
52
|
+
'sampler': 'sampler',
|
|
53
|
+
|
|
54
|
+
'texture_1d': 'texture',
|
|
55
|
+
|
|
56
|
+
'texture_2d': 'texture',
|
|
57
|
+
'texture_2d_array': 'texture',
|
|
58
|
+
'texture_multisampled_2d': 'cubeTexture',
|
|
59
|
+
|
|
60
|
+
'texture_depth_2d': 'depthTexture',
|
|
61
|
+
|
|
62
|
+
'texture_3d': 'texture3D',
|
|
63
|
+
|
|
64
|
+
'texture_cube': 'cubeTexture',
|
|
65
|
+
'texture_cube_array': 'cubeTexture',
|
|
66
|
+
|
|
67
|
+
'texture_storage_1d': 'storageTexture',
|
|
68
|
+
'texture_storage_2d': 'storageTexture',
|
|
69
|
+
'texture_storage_2d_array': 'storageTexture',
|
|
70
|
+
'texture_storage_3d': 'storageTexture'
|
|
71
|
+
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const parse = ( source ) => {
|
|
75
|
+
|
|
76
|
+
source = source.trim();
|
|
77
|
+
|
|
78
|
+
const declaration = source.match( declarationRegexp );
|
|
79
|
+
|
|
80
|
+
if ( declaration !== null && declaration.length === 4 ) {
|
|
81
|
+
|
|
82
|
+
const inputsCode = declaration[ 2 ];
|
|
83
|
+
const propsMatches = [];
|
|
84
|
+
let match = null;
|
|
85
|
+
|
|
86
|
+
while ( ( match = propertiesRegexp.exec( inputsCode ) ) !== null ) {
|
|
87
|
+
|
|
88
|
+
propsMatches.push( { name: match[ 1 ], type: match[ 2 ] } );
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Process matches to correctly pair names and types
|
|
93
|
+
const inputs = [];
|
|
94
|
+
for ( let i = 0; i < propsMatches.length; i ++ ) {
|
|
95
|
+
|
|
96
|
+
const { name, type } = propsMatches[ i ];
|
|
97
|
+
|
|
98
|
+
let resolvedType = type;
|
|
99
|
+
|
|
100
|
+
if ( resolvedType.startsWith( 'texture' ) ) {
|
|
101
|
+
|
|
102
|
+
resolvedType = type.split( '<' )[ 0 ];
|
|
103
|
+
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
resolvedType = wgslTypeLib[ resolvedType ] || resolvedType;
|
|
107
|
+
|
|
108
|
+
inputs.push( new NodeFunctionInput( resolvedType, name ) );
|
|
109
|
+
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const blockCode = source.substring( declaration[ 0 ].length );
|
|
113
|
+
const outputType = declaration[ 3 ] || 'void';
|
|
114
|
+
|
|
115
|
+
const name = declaration[ 1 ] !== undefined ? declaration[ 1 ] : '';
|
|
116
|
+
const type = wgslTypeLib[ outputType ] || outputType;
|
|
117
|
+
|
|
118
|
+
return {
|
|
119
|
+
type,
|
|
120
|
+
inputs,
|
|
121
|
+
name,
|
|
122
|
+
inputsCode,
|
|
123
|
+
blockCode,
|
|
124
|
+
outputType
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
} else {
|
|
128
|
+
|
|
129
|
+
throw new Error( 'FunctionNode: Function is not a WGSL code.' );
|
|
130
|
+
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
class WGSLNodeFunction extends NodeFunction {
|
|
136
|
+
|
|
137
|
+
constructor( source ) {
|
|
138
|
+
|
|
139
|
+
const { type, inputs, name, inputsCode, blockCode, outputType } = parse( source );
|
|
140
|
+
|
|
141
|
+
super( type, inputs, name );
|
|
142
|
+
|
|
143
|
+
this.inputsCode = inputsCode;
|
|
144
|
+
this.blockCode = blockCode;
|
|
145
|
+
this.outputType = outputType;
|
|
146
|
+
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
getCode( name = this.name ) {
|
|
150
|
+
|
|
151
|
+
const outputType = this.outputType !== 'void' ? '-> ' + this.outputType : '';
|
|
152
|
+
|
|
153
|
+
return `fn ${ name } ( ${ this.inputsCode.trim() } ) ${ outputType }` + this.blockCode;
|
|
154
|
+
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export default WGSLNodeFunction;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Float16BufferAttribute } from 'three';
|
|
2
1
|
import { GPUInputStepMode } from './WebGPUConstants.js';
|
|
3
2
|
|
|
3
|
+
import { Float16BufferAttribute } from '../../../core/BufferAttribute.js';
|
|
4
|
+
|
|
4
5
|
const typedArraysToVertexFormatPrefix = new Map( [
|
|
5
6
|
[ Int8Array, [ 'sint8', 'snorm8' ]],
|
|
6
7
|
[ Uint8Array, [ 'uint8', 'unorm8' ]],
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
GPUTextureAspect, GPUTextureViewDimension,
|
|
2
|
+
GPUTextureAspect, GPUTextureViewDimension, GPUTextureSampleType
|
|
3
3
|
} from './WebGPUConstants.js';
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
import { FloatType, IntType, UnsignedIntType } from '../../../constants.js';
|
|
5
6
|
|
|
6
7
|
class WebGPUBindingUtils {
|
|
7
8
|
|
|
@@ -11,7 +12,7 @@ class WebGPUBindingUtils {
|
|
|
11
12
|
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
createBindingsLayout(
|
|
15
|
+
createBindingsLayout( bindGroup ) {
|
|
15
16
|
|
|
16
17
|
const backend = this.backend;
|
|
17
18
|
const device = backend.device;
|
|
@@ -20,7 +21,7 @@ class WebGPUBindingUtils {
|
|
|
20
21
|
|
|
21
22
|
let index = 0;
|
|
22
23
|
|
|
23
|
-
for ( const binding of bindings ) {
|
|
24
|
+
for ( const binding of bindGroup.bindings ) {
|
|
24
25
|
|
|
25
26
|
const bindingGPU = {
|
|
26
27
|
binding: index ++,
|
|
@@ -33,7 +34,7 @@ class WebGPUBindingUtils {
|
|
|
33
34
|
|
|
34
35
|
if ( binding.isStorageBuffer ) {
|
|
35
36
|
|
|
36
|
-
buffer.type =
|
|
37
|
+
buffer.type = binding.access;
|
|
37
38
|
|
|
38
39
|
}
|
|
39
40
|
|
|
@@ -62,18 +63,25 @@ class WebGPUBindingUtils {
|
|
|
62
63
|
} else if ( binding.isSampledTexture && binding.store ) {
|
|
63
64
|
|
|
64
65
|
const format = this.backend.get( binding.texture ).texture.format;
|
|
66
|
+
const access = binding.access;
|
|
65
67
|
|
|
66
|
-
bindingGPU.storageTexture = { format }; // GPUStorageTextureBindingLayout
|
|
68
|
+
bindingGPU.storageTexture = { format, access }; // GPUStorageTextureBindingLayout
|
|
67
69
|
|
|
68
70
|
} else if ( binding.isSampledTexture ) {
|
|
69
71
|
|
|
70
72
|
const texture = {}; // GPUTextureBindingLayout
|
|
71
73
|
|
|
74
|
+
if ( binding.texture.isMultisampleRenderTargetTexture === true ) {
|
|
75
|
+
|
|
76
|
+
texture.multisampled = true;
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
|
|
72
80
|
if ( binding.texture.isDepthTexture ) {
|
|
73
81
|
|
|
74
82
|
texture.sampleType = GPUTextureSampleType.Depth;
|
|
75
83
|
|
|
76
|
-
} else if ( binding.texture.isDataTexture ) {
|
|
84
|
+
} else if ( binding.texture.isDataTexture || binding.texture.isDataArrayTexture || binding.texture.isData3DTexture ) {
|
|
77
85
|
|
|
78
86
|
const type = binding.texture.type;
|
|
79
87
|
|
|
@@ -103,6 +111,10 @@ class WebGPUBindingUtils {
|
|
|
103
111
|
|
|
104
112
|
texture.viewDimension = GPUTextureViewDimension.TwoDArray;
|
|
105
113
|
|
|
114
|
+
} else if ( binding.isSampledTexture3D ) {
|
|
115
|
+
|
|
116
|
+
texture.viewDimension = GPUTextureViewDimension.ThreeD;
|
|
117
|
+
|
|
106
118
|
}
|
|
107
119
|
|
|
108
120
|
bindingGPU.texture = texture;
|
|
@@ -121,19 +133,18 @@ class WebGPUBindingUtils {
|
|
|
121
133
|
|
|
122
134
|
}
|
|
123
135
|
|
|
124
|
-
createBindings(
|
|
136
|
+
createBindings( bindGroup ) {
|
|
125
137
|
|
|
126
138
|
const backend = this.backend;
|
|
127
|
-
const bindingsData = backend.get(
|
|
139
|
+
const bindingsData = backend.get( bindGroup );
|
|
128
140
|
|
|
129
141
|
// setup (static) binding layout and (dynamic) binding group
|
|
130
142
|
|
|
131
|
-
const bindLayoutGPU = this.createBindingsLayout(
|
|
132
|
-
const bindGroupGPU = this.createBindGroup(
|
|
143
|
+
const bindLayoutGPU = this.createBindingsLayout( bindGroup );
|
|
144
|
+
const bindGroupGPU = this.createBindGroup( bindGroup, bindLayoutGPU );
|
|
133
145
|
|
|
134
146
|
bindingsData.layout = bindLayoutGPU;
|
|
135
147
|
bindingsData.group = bindGroupGPU;
|
|
136
|
-
bindingsData.bindings = bindings;
|
|
137
148
|
|
|
138
149
|
}
|
|
139
150
|
|
|
@@ -149,7 +160,7 @@ class WebGPUBindingUtils {
|
|
|
149
160
|
|
|
150
161
|
}
|
|
151
162
|
|
|
152
|
-
createBindGroup(
|
|
163
|
+
createBindGroup( bindGroup, layoutGPU ) {
|
|
153
164
|
|
|
154
165
|
const backend = this.backend;
|
|
155
166
|
const device = backend.device;
|
|
@@ -157,7 +168,7 @@ class WebGPUBindingUtils {
|
|
|
157
168
|
let bindingPoint = 0;
|
|
158
169
|
const entriesGPU = [];
|
|
159
170
|
|
|
160
|
-
for ( const binding of bindings ) {
|
|
171
|
+
for ( const binding of bindGroup.bindings ) {
|
|
161
172
|
|
|
162
173
|
if ( binding.isUniformBuffer ) {
|
|
163
174
|
|
|
@@ -214,6 +225,10 @@ class WebGPUBindingUtils {
|
|
|
214
225
|
|
|
215
226
|
dimensionViewGPU = GPUTextureViewDimension.Cube;
|
|
216
227
|
|
|
228
|
+
} else if ( binding.isSampledTexture3D ) {
|
|
229
|
+
|
|
230
|
+
dimensionViewGPU = GPUTextureViewDimension.ThreeD;
|
|
231
|
+
|
|
217
232
|
} else if ( binding.texture.isDataArrayTexture ) {
|
|
218
233
|
|
|
219
234
|
dimensionViewGPU = GPUTextureViewDimension.TwoDArray;
|
|
@@ -247,6 +262,7 @@ class WebGPUBindingUtils {
|
|
|
247
262
|
}
|
|
248
263
|
|
|
249
264
|
return device.createBindGroup( {
|
|
265
|
+
label: 'bindGroup_' + bindGroup.name,
|
|
250
266
|
layout: layoutGPU,
|
|
251
267
|
entries: entriesGPU
|
|
252
268
|
} );
|
|
@@ -269,6 +269,12 @@ export const GPUBufferBindingType = {
|
|
|
269
269
|
ReadOnlyStorage: 'read-only-storage'
|
|
270
270
|
};
|
|
271
271
|
|
|
272
|
+
export const GPUStorageTextureAccess = {
|
|
273
|
+
WriteOnly: 'write-only',
|
|
274
|
+
ReadOnly: 'read-only',
|
|
275
|
+
ReadWrite: 'read-write',
|
|
276
|
+
};
|
|
277
|
+
|
|
272
278
|
export const GPUSamplerBindingType = {
|
|
273
279
|
Filtering: 'filtering',
|
|
274
280
|
NonFiltering: 'non-filtering',
|
|
@@ -320,5 +326,7 @@ export const GPUFeatureName = {
|
|
|
320
326
|
ShaderF16: 'shader-f16',
|
|
321
327
|
RG11B10UFloat: 'rg11b10ufloat-renderable',
|
|
322
328
|
BGRA8UNormStorage: 'bgra8unorm-storage',
|
|
323
|
-
Float32Filterable: 'float32-filterable'
|
|
329
|
+
Float32Filterable: 'float32-filterable',
|
|
330
|
+
ClipDistances: 'clip-distances',
|
|
331
|
+
DualSourceBlending: 'dual-source-blending'
|
|
324
332
|
};
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
AddEquation, SubtractEquation, ReverseSubtractEquation, MinEquation, MaxEquation,
|
|
14
14
|
KeepStencilOp, ZeroStencilOp, ReplaceStencilOp, InvertStencilOp, IncrementStencilOp, DecrementStencilOp, IncrementWrapStencilOp, DecrementWrapStencilOp,
|
|
15
15
|
NeverStencilFunc, AlwaysStencilFunc, LessStencilFunc, LessEqualStencilFunc, EqualStencilFunc, GreaterEqualStencilFunc, GreaterStencilFunc, NotEqualStencilFunc
|
|
16
|
-
} from '
|
|
16
|
+
} from '../../../constants.js';
|
|
17
17
|
|
|
18
18
|
class WebGPUPipelineUtils {
|
|
19
19
|
|
|
@@ -23,6 +23,12 @@ class WebGPUPipelineUtils {
|
|
|
23
23
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
_getSampleCount( renderObjectContext ) {
|
|
27
|
+
|
|
28
|
+
return this.backend.utils.getSampleCountRenderContext( renderObjectContext );
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
26
32
|
createRenderPipeline( renderObject, promises ) {
|
|
27
33
|
|
|
28
34
|
const { object, material, geometry, pipeline } = renderObject;
|
|
@@ -33,7 +39,18 @@ class WebGPUPipelineUtils {
|
|
|
33
39
|
const utils = backend.utils;
|
|
34
40
|
|
|
35
41
|
const pipelineData = backend.get( pipeline );
|
|
36
|
-
|
|
42
|
+
|
|
43
|
+
// bind group layouts
|
|
44
|
+
|
|
45
|
+
const bindGroupLayouts = [];
|
|
46
|
+
|
|
47
|
+
for ( const bindGroup of renderObject.getBindings() ) {
|
|
48
|
+
|
|
49
|
+
const bindingsData = backend.get( bindGroup );
|
|
50
|
+
|
|
51
|
+
bindGroupLayouts.push( bindingsData.layout );
|
|
52
|
+
|
|
53
|
+
}
|
|
37
54
|
|
|
38
55
|
// vertex buffers
|
|
39
56
|
|
|
@@ -102,22 +119,11 @@ class WebGPUPipelineUtils {
|
|
|
102
119
|
const primitiveState = this._getPrimitiveState( object, geometry, material );
|
|
103
120
|
const depthCompare = this._getDepthCompare( material );
|
|
104
121
|
const depthStencilFormat = utils.getCurrentDepthStencilFormat( renderObject.context );
|
|
105
|
-
let sampleCount = utils.getSampleCount( renderObject.context );
|
|
106
|
-
|
|
107
|
-
if ( sampleCount > 1 ) {
|
|
108
|
-
|
|
109
|
-
// WebGPU only supports power-of-two sample counts and 2 is not a valid value
|
|
110
|
-
sampleCount = Math.pow( 2, Math.floor( Math.log2( sampleCount ) ) );
|
|
111
122
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
sampleCount = 4;
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
}
|
|
123
|
+
const sampleCount = this._getSampleCount( renderObject.context );
|
|
119
124
|
|
|
120
125
|
const pipelineDescriptor = {
|
|
126
|
+
label: 'renderPipeline',
|
|
121
127
|
vertex: Object.assign( {}, vertexModule, { buffers: vertexBuffers } ),
|
|
122
128
|
fragment: Object.assign( {}, fragmentModule, { targets } ),
|
|
123
129
|
primitive: primitiveState,
|
|
@@ -135,7 +141,7 @@ class WebGPUPipelineUtils {
|
|
|
135
141
|
alphaToCoverageEnabled: material.alphaToCoverage
|
|
136
142
|
},
|
|
137
143
|
layout: device.createPipelineLayout( {
|
|
138
|
-
bindGroupLayouts
|
|
144
|
+
bindGroupLayouts
|
|
139
145
|
} )
|
|
140
146
|
};
|
|
141
147
|
|
|
@@ -162,6 +168,35 @@ class WebGPUPipelineUtils {
|
|
|
162
168
|
|
|
163
169
|
}
|
|
164
170
|
|
|
171
|
+
createBundleEncoder( renderContext, renderObject ) {
|
|
172
|
+
|
|
173
|
+
const backend = this.backend;
|
|
174
|
+
const { utils, device } = backend;
|
|
175
|
+
|
|
176
|
+
const renderContextData = backend.get( renderContext );
|
|
177
|
+
const renderObjectData = backend.get( renderObject );
|
|
178
|
+
|
|
179
|
+
const depthStencilFormat = utils.getCurrentDepthStencilFormat( renderContext );
|
|
180
|
+
const colorFormat = utils.getCurrentColorFormat( renderContext );
|
|
181
|
+
const sampleCount = this._getSampleCount( renderObject.context );
|
|
182
|
+
|
|
183
|
+
const descriptor = {
|
|
184
|
+
label: 'renderBundleEncoder',
|
|
185
|
+
colorFormats: [ colorFormat ],
|
|
186
|
+
depthStencilFormat,
|
|
187
|
+
sampleCount
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
const bundleEncoder = device.createRenderBundleEncoder( descriptor );
|
|
191
|
+
|
|
192
|
+
renderObjectData.bundleEncoder = bundleEncoder;
|
|
193
|
+
renderContextData.currentSets = { attributes: {} };
|
|
194
|
+
renderContextData._renderBundleViewport = renderContext.width + '_' + renderContext.height;
|
|
195
|
+
|
|
196
|
+
return bundleEncoder;
|
|
197
|
+
|
|
198
|
+
}
|
|
199
|
+
|
|
165
200
|
createComputePipeline( pipeline, bindings ) {
|
|
166
201
|
|
|
167
202
|
const backend = this.backend;
|
|
@@ -170,12 +205,23 @@ class WebGPUPipelineUtils {
|
|
|
170
205
|
const computeProgram = backend.get( pipeline.computeProgram ).module;
|
|
171
206
|
|
|
172
207
|
const pipelineGPU = backend.get( pipeline );
|
|
173
|
-
|
|
208
|
+
|
|
209
|
+
// bind group layouts
|
|
210
|
+
|
|
211
|
+
const bindGroupLayouts = [];
|
|
212
|
+
|
|
213
|
+
for ( const bindingsGroup of bindings ) {
|
|
214
|
+
|
|
215
|
+
const bindingsData = backend.get( bindingsGroup );
|
|
216
|
+
|
|
217
|
+
bindGroupLayouts.push( bindingsData.layout );
|
|
218
|
+
|
|
219
|
+
}
|
|
174
220
|
|
|
175
221
|
pipelineGPU.pipeline = device.createComputePipeline( {
|
|
176
222
|
compute: computeProgram,
|
|
177
223
|
layout: device.createPipelineLayout( {
|
|
178
|
-
bindGroupLayouts
|
|
224
|
+
bindGroupLayouts
|
|
179
225
|
} )
|
|
180
226
|
} );
|
|
181
227
|
|
|
@@ -186,17 +232,21 @@ class WebGPUPipelineUtils {
|
|
|
186
232
|
let color, alpha;
|
|
187
233
|
|
|
188
234
|
const blending = material.blending;
|
|
235
|
+
const blendSrc = material.blendSrc;
|
|
236
|
+
const blendDst = material.blendDst;
|
|
237
|
+
const blendEquation = material.blendEquation;
|
|
238
|
+
|
|
189
239
|
|
|
190
240
|
if ( blending === CustomBlending ) {
|
|
191
241
|
|
|
192
|
-
const blendSrcAlpha = material.blendSrcAlpha !== null ? material.blendSrcAlpha :
|
|
193
|
-
const blendDstAlpha = material.blendDstAlpha !== null ? material.blendDstAlpha :
|
|
194
|
-
const blendEquationAlpha = material.blendEquationAlpha !== null ? material.blendEquationAlpha :
|
|
242
|
+
const blendSrcAlpha = material.blendSrcAlpha !== null ? material.blendSrcAlpha : blendSrc;
|
|
243
|
+
const blendDstAlpha = material.blendDstAlpha !== null ? material.blendDstAlpha : blendDst;
|
|
244
|
+
const blendEquationAlpha = material.blendEquationAlpha !== null ? material.blendEquationAlpha : blendEquation;
|
|
195
245
|
|
|
196
246
|
color = {
|
|
197
|
-
srcFactor: this._getBlendFactor(
|
|
198
|
-
dstFactor: this._getBlendFactor(
|
|
199
|
-
operation: this._getBlendOperation(
|
|
247
|
+
srcFactor: this._getBlendFactor( blendSrc ),
|
|
248
|
+
dstFactor: this._getBlendFactor( blendDst ),
|
|
249
|
+
operation: this._getBlendOperation( blendEquation )
|
|
200
250
|
};
|
|
201
251
|
|
|
202
252
|
alpha = {
|
|
@@ -2,20 +2,22 @@ import {
|
|
|
2
2
|
GPUTextureFormat, GPUAddressMode, GPUFilterMode, GPUTextureDimension, GPUFeatureName
|
|
3
3
|
} from './WebGPUConstants.js';
|
|
4
4
|
|
|
5
|
+
import WebGPUTexturePassUtils from './WebGPUTexturePassUtils.js';
|
|
6
|
+
|
|
5
7
|
import {
|
|
6
|
-
|
|
8
|
+
ByteType, ShortType,
|
|
7
9
|
NearestFilter, NearestMipmapNearestFilter, NearestMipmapLinearFilter,
|
|
8
10
|
RepeatWrapping, MirroredRepeatWrapping,
|
|
9
11
|
RGB_ETC2_Format, RGBA_ETC2_EAC_Format,
|
|
10
12
|
RGBAFormat, RGBFormat, RedFormat, RGFormat, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, UnsignedByteType, FloatType, HalfFloatType, SRGBColorSpace, DepthFormat, DepthStencilFormat,
|
|
11
13
|
RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format,
|
|
12
14
|
RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, UnsignedIntType, UnsignedShortType, UnsignedInt248Type, UnsignedInt5999Type,
|
|
13
|
-
NeverCompare, AlwaysCompare, LessCompare, LessEqualCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare, IntType, RedIntegerFormat, RGIntegerFormat, RGBAIntegerFormat
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
import
|
|
15
|
+
NeverCompare, AlwaysCompare, LessCompare, LessEqualCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare, IntType, RedIntegerFormat, RGIntegerFormat, RGBAIntegerFormat,
|
|
16
|
+
CubeReflectionMapping, CubeRefractionMapping, EquirectangularReflectionMapping, EquirectangularRefractionMapping
|
|
17
|
+
} from '../../../constants.js';
|
|
18
|
+
import { CubeTexture } from '../../../textures/CubeTexture.js';
|
|
19
|
+
import { DepthTexture } from '../../../textures/DepthTexture.js';
|
|
20
|
+
import { Texture } from '../../../textures/Texture.js';
|
|
19
21
|
|
|
20
22
|
const _compareToWebGPU = {
|
|
21
23
|
[ NeverCompare ]: 'never',
|
|
@@ -40,6 +42,7 @@ class WebGPUTextureUtils {
|
|
|
40
42
|
|
|
41
43
|
this.defaultTexture = {};
|
|
42
44
|
this.defaultCubeTexture = {};
|
|
45
|
+
this.defaultVideoFrame = null;
|
|
43
46
|
|
|
44
47
|
this.colorBuffer = null;
|
|
45
48
|
|
|
@@ -85,6 +88,10 @@ class WebGPUTextureUtils {
|
|
|
85
88
|
|
|
86
89
|
textureGPU = this._getDefaultCubeTextureGPU( format );
|
|
87
90
|
|
|
91
|
+
} else if ( texture.isVideoTexture ) {
|
|
92
|
+
|
|
93
|
+
this.backend.get( texture ).externalTexture = this._getDefaultVideoFrame();
|
|
94
|
+
|
|
88
95
|
} else {
|
|
89
96
|
|
|
90
97
|
textureGPU = this._getDefaultTextureGPU( format );
|
|
@@ -117,20 +124,9 @@ class WebGPUTextureUtils {
|
|
|
117
124
|
|
|
118
125
|
let sampleCount = options.sampleCount !== undefined ? options.sampleCount : 1;
|
|
119
126
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
// WebGPU only supports power-of-two sample counts and 2 is not a valid value
|
|
123
|
-
sampleCount = Math.pow( 2, Math.floor( Math.log2( sampleCount ) ) );
|
|
127
|
+
sampleCount = backend.utils.getSampleCount( sampleCount );
|
|
124
128
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
sampleCount = 4;
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const primarySampleCount = texture.isRenderTargetTexture ? 1 : sampleCount;
|
|
129
|
+
const primarySampleCount = texture.isRenderTargetTexture && ! texture.isMultisampleRenderTargetTexture ? 1 : sampleCount;
|
|
134
130
|
|
|
135
131
|
let usage = GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.COPY_SRC;
|
|
136
132
|
|
|
@@ -188,7 +184,7 @@ class WebGPUTextureUtils {
|
|
|
188
184
|
|
|
189
185
|
}
|
|
190
186
|
|
|
191
|
-
if ( texture.isRenderTargetTexture && sampleCount > 1 ) {
|
|
187
|
+
if ( texture.isRenderTargetTexture && sampleCount > 1 && ! texture.isMultisampleRenderTargetTexture ) {
|
|
192
188
|
|
|
193
189
|
const msaaTextureDescriptorGPU = Object.assign( {}, textureDescriptorGPU );
|
|
194
190
|
|
|
@@ -261,7 +257,7 @@ class WebGPUTextureUtils {
|
|
|
261
257
|
height: height,
|
|
262
258
|
depthOrArrayLayers: 1
|
|
263
259
|
},
|
|
264
|
-
sampleCount: backend.
|
|
260
|
+
sampleCount: backend.utils.getSampleCount( backend.renderer.samples ),
|
|
265
261
|
format: GPUTextureFormat.BGRA8Unorm,
|
|
266
262
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC
|
|
267
263
|
} );
|
|
@@ -310,7 +306,7 @@ class WebGPUTextureUtils {
|
|
|
310
306
|
depthTexture.image.width = width;
|
|
311
307
|
depthTexture.image.height = height;
|
|
312
308
|
|
|
313
|
-
this.createTexture( depthTexture, { sampleCount: backend.
|
|
309
|
+
this.createTexture( depthTexture, { sampleCount: backend.utils.getSampleCount( backend.renderer.samples ), width, height } );
|
|
314
310
|
|
|
315
311
|
return backend.get( depthTexture ).texture;
|
|
316
312
|
|
|
@@ -327,11 +323,11 @@ class WebGPUTextureUtils {
|
|
|
327
323
|
|
|
328
324
|
// transfer texture data
|
|
329
325
|
|
|
330
|
-
if ( texture.isDataTexture
|
|
326
|
+
if ( texture.isDataTexture ) {
|
|
331
327
|
|
|
332
328
|
this._copyBufferToTexture( options.image, textureData.texture, textureDescriptorGPU, 0, texture.flipY );
|
|
333
329
|
|
|
334
|
-
} else if ( texture.isDataArrayTexture ) {
|
|
330
|
+
} else if ( texture.isDataArrayTexture || texture.isData3DTexture ) {
|
|
335
331
|
|
|
336
332
|
for ( let i = 0; i < options.image.depth; i ++ ) {
|
|
337
333
|
|
|
@@ -464,6 +460,27 @@ class WebGPUTextureUtils {
|
|
|
464
460
|
|
|
465
461
|
}
|
|
466
462
|
|
|
463
|
+
_getDefaultVideoFrame() {
|
|
464
|
+
|
|
465
|
+
let defaultVideoFrame = this.defaultVideoFrame;
|
|
466
|
+
|
|
467
|
+
if ( defaultVideoFrame === null ) {
|
|
468
|
+
|
|
469
|
+
const init = {
|
|
470
|
+
timestamp: 0,
|
|
471
|
+
codedWidth: 1,
|
|
472
|
+
codedHeight: 1,
|
|
473
|
+
format: 'RGBA',
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
this.defaultVideoFrame = defaultVideoFrame = new VideoFrame( new Uint8Array( [ 0, 0, 0, 0xff ] ), init );
|
|
477
|
+
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
return defaultVideoFrame;
|
|
481
|
+
|
|
482
|
+
}
|
|
483
|
+
|
|
467
484
|
_copyCubeMapToTexture( images, textureGPU, textureDescriptorGPU, flipY ) {
|
|
468
485
|
|
|
469
486
|
for ( let i = 0; i < 6; i ++ ) {
|
|
@@ -913,6 +930,25 @@ export function getFormat( texture, device = null ) {
|
|
|
913
930
|
|
|
914
931
|
switch ( type ) {
|
|
915
932
|
|
|
933
|
+
case ByteType:
|
|
934
|
+
formatGPU = GPUTextureFormat.RGBA8Snorm;
|
|
935
|
+
break;
|
|
936
|
+
|
|
937
|
+
case ShortType:
|
|
938
|
+
formatGPU = GPUTextureFormat.RGBA16Sint;
|
|
939
|
+
break;
|
|
940
|
+
|
|
941
|
+
case UnsignedShortType:
|
|
942
|
+
formatGPU = GPUTextureFormat.RGBA16Uint;
|
|
943
|
+
break;
|
|
944
|
+
case UnsignedIntType:
|
|
945
|
+
formatGPU = GPUTextureFormat.RGBA32Uint;
|
|
946
|
+
break;
|
|
947
|
+
|
|
948
|
+
case IntType:
|
|
949
|
+
formatGPU = GPUTextureFormat.RGBA32Sint;
|
|
950
|
+
break;
|
|
951
|
+
|
|
916
952
|
case UnsignedByteType:
|
|
917
953
|
formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.RGBA8UnormSRGB : GPUTextureFormat.RGBA8Unorm;
|
|
918
954
|
break;
|
|
@@ -951,6 +987,26 @@ export function getFormat( texture, device = null ) {
|
|
|
951
987
|
|
|
952
988
|
switch ( type ) {
|
|
953
989
|
|
|
990
|
+
case ByteType:
|
|
991
|
+
formatGPU = GPUTextureFormat.R8Snorm;
|
|
992
|
+
break;
|
|
993
|
+
|
|
994
|
+
case ShortType:
|
|
995
|
+
formatGPU = GPUTextureFormat.R16Sint;
|
|
996
|
+
break;
|
|
997
|
+
|
|
998
|
+
case UnsignedShortType:
|
|
999
|
+
formatGPU = GPUTextureFormat.R16Uint;
|
|
1000
|
+
break;
|
|
1001
|
+
|
|
1002
|
+
case UnsignedIntType:
|
|
1003
|
+
formatGPU = GPUTextureFormat.R32Uint;
|
|
1004
|
+
break;
|
|
1005
|
+
|
|
1006
|
+
case IntType:
|
|
1007
|
+
formatGPU = GPUTextureFormat.R32Sint;
|
|
1008
|
+
break;
|
|
1009
|
+
|
|
954
1010
|
case UnsignedByteType:
|
|
955
1011
|
formatGPU = GPUTextureFormat.R8Unorm;
|
|
956
1012
|
break;
|
|
@@ -974,6 +1030,26 @@ export function getFormat( texture, device = null ) {
|
|
|
974
1030
|
|
|
975
1031
|
switch ( type ) {
|
|
976
1032
|
|
|
1033
|
+
case ByteType:
|
|
1034
|
+
formatGPU = GPUTextureFormat.RG8Snorm;
|
|
1035
|
+
break;
|
|
1036
|
+
|
|
1037
|
+
case ShortType:
|
|
1038
|
+
formatGPU = GPUTextureFormat.RG16Sint;
|
|
1039
|
+
break;
|
|
1040
|
+
|
|
1041
|
+
case UnsignedShortType:
|
|
1042
|
+
formatGPU = GPUTextureFormat.RG16Uint;
|
|
1043
|
+
break;
|
|
1044
|
+
|
|
1045
|
+
case UnsignedIntType:
|
|
1046
|
+
formatGPU = GPUTextureFormat.RG32Uint;
|
|
1047
|
+
break;
|
|
1048
|
+
|
|
1049
|
+
case IntType:
|
|
1050
|
+
formatGPU = GPUTextureFormat.RG32Sint;
|
|
1051
|
+
break;
|
|
1052
|
+
|
|
977
1053
|
case UnsignedByteType:
|
|
978
1054
|
formatGPU = GPUTextureFormat.RG8Unorm;
|
|
979
1055
|
break;
|