super-three 0.165.0 → 0.168.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/build/three.cjs +854 -410
- package/build/three.module.js +849 -411
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +77755 -0
- package/build/three.webgpu.min.js +6 -0
- package/examples/jsm/Addons.js +5 -2
- package/examples/jsm/animation/AnimationClipCreator.js +1 -1
- 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 +777 -786
- package/examples/jsm/controls/PointerLockControls.js +24 -15
- package/examples/jsm/controls/TrackballControls.js +453 -452
- 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 +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +13 -4
- package/examples/jsm/exporters/USDZExporter.js +29 -8
- package/examples/jsm/geometries/TeapotGeometry.js +1 -1
- package/examples/jsm/helpers/LightProbeHelper.js +42 -43
- package/examples/jsm/helpers/ViewHelper.js +51 -2
- package/examples/jsm/libs/tween.module.js +64 -75
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +91 -0
- package/examples/jsm/lights/RectAreaLightUniformsLib.js +8 -63
- package/examples/jsm/lines/webgpu/Line2.js +20 -0
- package/examples/jsm/lines/webgpu/LineSegments2.js +376 -0
- package/examples/jsm/loaders/FBXLoader.js +23 -45
- package/examples/jsm/loaders/GLTFLoader.js +10 -4
- package/examples/jsm/loaders/KTX2Loader.js +19 -7
- package/examples/jsm/loaders/MaterialXLoader.js +10 -10
- package/examples/jsm/loaders/PCDLoader.js +9 -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/SimplifyModifier.js +2 -1
- package/examples/jsm/objects/InstancedPoints.js +2 -2
- package/examples/jsm/objects/SkyMesh.js +188 -0
- package/examples/jsm/objects/Water2Mesh.js +159 -0
- package/examples/jsm/objects/WaterMesh.js +102 -0
- package/examples/jsm/physics/RapierPhysics.js +20 -0
- package/examples/jsm/postprocessing/OutlinePass.js +31 -46
- package/examples/jsm/postprocessing/RenderTransitionPass.js +13 -38
- package/examples/jsm/postprocessing/SSAARenderPass.js +3 -1
- package/examples/jsm/postprocessing/SSAOPass.js +6 -9
- package/examples/jsm/postprocessing/UnrealBloomPass.js +4 -4
- 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 +46 -4
- package/examples/jsm/transpiler/TSLEncoder.js +24 -22
- package/examples/jsm/utils/TextureUtils.js +1 -1
- package/package.json +8 -6
- package/src/Three.WebGPU.js +200 -0
- package/src/Three.js +3 -0
- package/src/constants.js +4 -1
- package/src/core/Object3D.js +22 -22
- package/src/extras/Controls.js +32 -0
- 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/ObjectLoader.js +33 -2
- package/{examples/jsm/nodes/loaders → src/loaders/nodes}/NodeLoader.js +6 -4
- package/{examples/jsm/nodes/loaders → src/loaders/nodes}/NodeMaterialLoader.js +2 -2
- package/{examples/jsm/nodes/loaders → src/loaders/nodes}/NodeObjectLoader.js +2 -1
- package/src/materials/Material.js +7 -1
- package/{examples/jsm/nodes/materials → src/materials/nodes}/InstancedPointsNodeMaterial.js +36 -27
- package/{examples/jsm/nodes/materials → src/materials/nodes}/Line2NodeMaterial.js +37 -40
- package/src/materials/nodes/LineBasicNodeMaterial.js +27 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/LineDashedNodeMaterial.js +10 -11
- package/src/materials/nodes/MeshBasicNodeMaterial.js +73 -0
- package/src/materials/nodes/MeshLambertNodeMaterial.js +43 -0
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +53 -0
- package/src/materials/nodes/MeshNormalNodeMaterial.js +40 -0
- package/src/materials/nodes/MeshPhongNodeMaterial.js +74 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/MeshPhysicalNodeMaterial.js +22 -20
- package/{examples/jsm/nodes/materials → src/materials/nodes}/MeshSSSNodeMaterial.js +6 -6
- package/{examples/jsm/nodes/materials → src/materials/nodes}/MeshStandardNodeMaterial.js +28 -11
- package/src/materials/nodes/MeshToonNodeMaterial.js +34 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/NodeMaterial.js +142 -96
- package/{examples/jsm/nodes/materials/Materials.js → src/materials/nodes/NodeMaterials.js} +1 -1
- package/{examples/jsm/nodes/materials → src/materials/nodes}/PointsNodeMaterial.js +5 -6
- package/src/materials/nodes/ShadowNodeMaterial.js +34 -0
- package/{examples/jsm/nodes/materials → src/materials/nodes}/SpriteNodeMaterial.js +13 -13
- package/{examples/jsm/nodes/materials → src/materials/nodes}/VolumeNodeMaterial.js +14 -16
- 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/src/nodes/Nodes.js +164 -0
- package/src/nodes/TSL.js +176 -0
- package/{examples/jsm → src}/nodes/accessors/AccessorsUtils.js +8 -8
- package/src/nodes/accessors/BatchNode.js +124 -0
- package/{examples/jsm/nodes/accessors/BitangentNode.js → src/nodes/accessors/Bitangent.js} +9 -9
- package/{examples/jsm → src}/nodes/accessors/BufferAttributeNode.js +41 -6
- package/{examples/jsm → src}/nodes/accessors/BufferNode.js +4 -4
- package/src/nodes/accessors/Camera.js +19 -0
- package/{examples/jsm → src}/nodes/accessors/ClippingNode.js +16 -14
- package/src/nodes/accessors/CubeTextureNode.js +76 -0
- package/src/nodes/accessors/InstanceNode.js +144 -0
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +21 -0
- package/{examples/jsm → src}/nodes/accessors/MaterialNode.js +66 -49
- package/src/nodes/accessors/MaterialProperties.js +3 -0
- package/{examples/jsm → src}/nodes/accessors/MaterialReferenceNode.js +6 -4
- package/src/nodes/accessors/ModelNode.js +37 -0
- package/{examples/jsm → src}/nodes/accessors/ModelViewProjectionNode.js +6 -7
- package/{examples/jsm → src}/nodes/accessors/MorphNode.js +35 -31
- package/src/nodes/accessors/Normal.js +62 -0
- package/{examples/jsm → src}/nodes/accessors/Object3DNode.js +11 -11
- package/src/nodes/accessors/PointUVNode.js +26 -0
- package/src/nodes/accessors/Position.js +10 -0
- package/src/nodes/accessors/ReferenceBaseNode.js +143 -0
- package/{examples/jsm → src}/nodes/accessors/ReferenceNode.js +14 -8
- package/src/nodes/accessors/ReflectVector.js +10 -0
- package/{examples/jsm → src}/nodes/accessors/RendererReferenceNode.js +6 -6
- package/{examples/jsm → src}/nodes/accessors/SceneNode.js +5 -6
- package/src/nodes/accessors/SkinningNode.js +187 -0
- package/{examples/jsm → src}/nodes/accessors/StorageBufferNode.js +54 -6
- package/{examples/jsm → src}/nodes/accessors/StorageTextureNode.js +16 -7
- package/src/nodes/accessors/Tangent.js +22 -0
- package/{examples/jsm → src}/nodes/accessors/Texture3DNode.js +11 -11
- package/{examples/jsm/nodes/accessors/TextureBicubicNode.js → src/nodes/accessors/TextureBicubic.js} +3 -32
- package/{examples/jsm → src}/nodes/accessors/TextureNode.js +69 -37
- package/{examples/jsm → src}/nodes/accessors/TextureSizeNode.js +4 -6
- package/{examples/jsm/nodes/accessors/UniformsNode.js → src/nodes/accessors/UniformArrayNode.js} +24 -9
- package/{examples/jsm → src}/nodes/accessors/UserDataNode.js +4 -4
- package/src/nodes/accessors/VelocityNode.js +83 -0
- package/{examples/jsm → src}/nodes/accessors/VertexColorNode.js +6 -5
- package/{examples/jsm → src}/nodes/code/CodeNode.js +5 -5
- package/{examples/jsm → src}/nodes/code/ExpressionNode.js +4 -4
- package/{examples/jsm → src}/nodes/code/FunctionCallNode.js +5 -5
- package/{examples/jsm → src}/nodes/code/FunctionNode.js +5 -23
- package/{examples/jsm → src}/nodes/code/ScriptableNode.js +18 -6
- package/{examples/jsm → src}/nodes/code/ScriptableValueNode.js +6 -7
- package/{examples/jsm → src}/nodes/core/AssignNode.js +5 -5
- package/{examples/jsm → src}/nodes/core/AttributeNode.js +22 -21
- package/{examples/jsm → src}/nodes/core/BypassNode.js +5 -5
- package/src/nodes/core/CacheNode.js +46 -0
- package/{examples/jsm → src}/nodes/core/ConstNode.js +2 -2
- package/{examples/jsm → src}/nodes/core/ContextNode.js +17 -11
- package/{examples/jsm → src}/nodes/core/IndexNode.js +17 -6
- package/{examples/jsm → src}/nodes/core/InputNode.js +2 -2
- package/{examples/jsm → src}/nodes/core/LightingModel.js +2 -2
- package/src/nodes/core/MRTNode.js +82 -0
- package/{examples/jsm → src}/nodes/core/Node.js +57 -31
- package/{examples/jsm → src}/nodes/core/NodeBuilder.js +216 -65
- 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/NodeUniform.js +1 -2
- package/{examples/jsm → src}/nodes/core/NodeUtils.js +7 -1
- package/{examples/jsm → src}/nodes/core/OutputStructNode.js +4 -4
- package/{examples/jsm → src}/nodes/core/ParameterNode.js +4 -4
- package/src/nodes/core/PropertyNode.js +84 -0
- package/{examples/jsm → src}/nodes/core/StackNode.js +26 -10
- package/{examples/jsm → src}/nodes/core/StructTypeNode.js +2 -2
- package/{examples/jsm → src}/nodes/core/TempNode.js +4 -4
- package/src/nodes/core/UniformGroupNode.js +55 -0
- package/{examples/jsm → src}/nodes/core/UniformNode.js +14 -5
- package/{examples/jsm → src}/nodes/core/VarNode.js +8 -12
- package/{examples/jsm → src}/nodes/core/VaryingNode.js +13 -5
- package/{examples/jsm → src}/nodes/display/AfterImageNode.js +27 -35
- package/src/nodes/display/AnaglyphPassNode.js +61 -0
- package/{examples/jsm → src}/nodes/display/AnamorphicNode.js +27 -30
- package/src/nodes/display/BleachBypass.js +26 -0
- package/src/nodes/display/BlendMode.js +54 -0
- package/src/nodes/display/BloomNode.js +335 -0
- package/{examples/jsm → src}/nodes/display/BumpMapNode.js +7 -12
- package/src/nodes/display/ColorAdjustment.js +46 -0
- package/src/nodes/display/ColorSpaceFunctions.js +38 -0
- package/src/nodes/display/ColorSpaceNode.js +85 -0
- package/src/nodes/display/DenoiseNode.js +201 -0
- package/src/nodes/display/DepthOfFieldNode.js +121 -0
- package/src/nodes/display/DotScreenNode.js +63 -0
- package/src/nodes/display/FXAANode.js +329 -0
- package/src/nodes/display/FilmNode.js +53 -0
- package/src/nodes/display/FrontFacingNode.js +41 -0
- package/src/nodes/display/GTAONode.js +328 -0
- package/{examples/jsm → src}/nodes/display/GaussianBlurNode.js +44 -24
- package/src/nodes/display/Lut3DNode.js +54 -0
- package/src/nodes/display/MotionBlur.js +25 -0
- package/{examples/jsm → src}/nodes/display/NormalMapNode.js +9 -11
- package/src/nodes/display/ParallaxBarrierPassNode.js +55 -0
- package/src/nodes/display/PassNode.js +367 -0
- package/src/nodes/display/PixelationPassNode.js +206 -0
- package/{examples/jsm → src}/nodes/display/PosterizeNode.js +4 -6
- package/src/nodes/display/RGBShiftNode.js +50 -0
- package/src/nodes/display/RenderOutputNode.js +56 -0
- package/src/nodes/display/SSAAPassNode.js +284 -0
- package/src/nodes/display/Sepia.js +17 -0
- package/src/nodes/display/SobelOperatorNode.js +123 -0
- package/src/nodes/display/StereoCompositePassNode.js +107 -0
- package/src/nodes/display/StereoPassNode.js +80 -0
- package/src/nodes/display/ToneMappingFunctions.js +190 -0
- package/src/nodes/display/ToneMappingNode.js +66 -0
- package/src/nodes/display/TransitionNode.js +77 -0
- package/src/nodes/display/ViewportDepthNode.js +121 -0
- package/src/nodes/display/ViewportDepthTextureNode.js +30 -0
- package/{examples/jsm → src}/nodes/display/ViewportNode.js +28 -26
- package/src/nodes/display/ViewportSharedTextureNode.js +36 -0
- package/{examples/jsm → src}/nodes/display/ViewportTextureNode.js +12 -12
- package/{examples/jsm → src}/nodes/fog/FogExp2Node.js +4 -6
- package/{examples/jsm → src}/nodes/fog/FogNode.js +5 -7
- package/{examples/jsm → src}/nodes/fog/FogRangeNode.js +4 -6
- package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_GGX.js +4 -4
- 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/{examples/jsm → src}/nodes/functions/BSDF/D_GGX_Anisotropic.js +3 -3
- 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 -2
- package/{examples/jsm → src}/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
- package/src/nodes/functions/BasicLightingModel.js +78 -0
- package/{examples/jsm → src}/nodes/functions/PhongLightingModel.js +10 -8
- package/{examples/jsm → src}/nodes/functions/PhysicalLightingModel.js +73 -31
- package/{examples/jsm → src}/nodes/functions/ShadowMaskModel.js +1 -1
- package/{examples/jsm → src}/nodes/functions/ToonLightingModel.js +6 -4
- package/src/nodes/functions/material/getGeometryRoughness.js +13 -0
- package/{examples/jsm → src}/nodes/functions/material/getRoughness.js +2 -2
- package/{examples/jsm → src}/nodes/geometry/RangeNode.js +23 -10
- package/{examples/jsm → src}/nodes/gpgpu/ComputeNode.js +5 -5
- package/src/nodes/lighting/AONode.js +24 -0
- package/{examples/jsm → src}/nodes/lighting/AmbientLightNode.js +2 -7
- package/src/nodes/lighting/AnalyticLightNode.js +354 -0
- package/src/nodes/lighting/BasicEnvironmentNode.js +27 -0
- package/src/nodes/lighting/BasicLightMapNode.js +29 -0
- package/{examples/jsm → src}/nodes/lighting/DirectionalLightNode.js +3 -9
- package/{examples/jsm → src}/nodes/lighting/EnvironmentNode.js +23 -21
- package/{examples/jsm → src}/nodes/lighting/HemisphereLightNode.js +4 -7
- package/{examples/jsm → src}/nodes/lighting/IESSpotLightNode.js +3 -8
- package/{examples/jsm → src}/nodes/lighting/IrradianceNode.js +2 -2
- package/{examples/jsm → src}/nodes/lighting/LightNode.js +5 -5
- package/src/nodes/lighting/LightProbeNode.js +76 -0
- package/{examples/jsm → src}/nodes/lighting/LightUtils.js +3 -3
- package/src/nodes/lighting/LightingContextNode.js +64 -0
- package/{examples/jsm → src}/nodes/lighting/LightingNode.js +4 -2
- package/src/nodes/lighting/LightsNode.js +231 -0
- package/{examples/jsm → src}/nodes/lighting/PointLightNode.js +4 -10
- package/src/nodes/lighting/RectAreaLightNode.js +93 -0
- package/{examples/jsm → src}/nodes/lighting/SpotLightNode.js +4 -10
- package/{examples/jsm → src}/nodes/materialx/MaterialXNodes.js +2 -2
- package/{examples/jsm → src}/nodes/materialx/lib/mx_hsv.js +43 -46
- 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} +31 -13
- package/src/nodes/math/Hash.js +13 -0
- package/src/nodes/math/MathNode.js +404 -0
- package/{examples/jsm → src}/nodes/math/MathUtils.js +0 -7
- package/{examples/jsm → src}/nodes/math/OperatorNode.js +100 -58
- package/{examples/jsm → src}/nodes/math/TriNoise3D.js +19 -29
- package/{examples/jsm → src}/nodes/parsers/GLSLNodeFunction.js +7 -7
- package/{examples/jsm → src}/nodes/pmrem/PMREMNode.js +60 -16
- package/{examples/jsm → src}/nodes/pmrem/PMREMUtils.js +46 -46
- 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} +106 -96
- package/{examples/jsm → src}/nodes/utils/ArrayElementNode.js +2 -2
- package/{examples/jsm → src}/nodes/utils/ConvertNode.js +2 -2
- package/src/nodes/utils/CubeMapNode.js +157 -0
- package/src/nodes/utils/Discard.js +8 -0
- package/{examples/jsm → src}/nodes/utils/EquirectUVNode.js +5 -5
- package/src/nodes/utils/FlipNode.js +65 -0
- package/{examples/jsm → src}/nodes/utils/FunctionOverloadingNode.js +7 -5
- package/{examples/jsm → src}/nodes/utils/JoinNode.js +2 -2
- package/{examples/jsm → src}/nodes/utils/LoopNode.js +19 -12
- package/{examples/jsm → src}/nodes/utils/MatcapUVNode.js +6 -6
- package/{examples/jsm → src}/nodes/utils/MaxMipLevelNode.js +12 -6
- package/{examples/jsm → src}/nodes/utils/OscNode.js +7 -7
- package/src/nodes/utils/Packing.js +4 -0
- package/src/nodes/utils/RTTNode.js +130 -0
- package/{examples/jsm → src}/nodes/utils/ReflectorNode.js +17 -4
- package/{examples/jsm → src}/nodes/utils/RemapNode.js +7 -7
- package/{examples/jsm → src}/nodes/utils/RotateNode.js +4 -12
- package/{examples/jsm → src}/nodes/utils/SetNode.js +2 -2
- package/{examples/jsm → src}/nodes/utils/SplitNode.js +2 -2
- package/{examples/jsm → src}/nodes/utils/SpriteSheetUVNode.js +5 -5
- package/src/nodes/utils/SpriteUtils.js +47 -0
- package/{examples/jsm → src}/nodes/utils/StorageArrayElementNode.js +4 -6
- package/{examples/jsm → src}/nodes/utils/TimerNode.js +5 -5
- package/{examples/jsm → src}/nodes/utils/TriplanarTexturesNode.js +7 -9
- package/src/nodes/utils/UVUtils.js +19 -0
- package/src/nodes/utils/ViewportUtils.js +14 -0
- package/src/objects/BatchedMesh.js +169 -190
- package/src/objects/InstancedMesh.js +1 -1
- package/src/renderers/WebGLRenderer.js +60 -23
- package/{examples/jsm → src}/renderers/common/Attributes.js +2 -1
- package/{examples/jsm → src}/renderers/common/Backend.js +30 -27
- package/{examples/jsm → src}/renderers/common/Background.js +12 -4
- package/src/renderers/common/BindGroup.js +18 -0
- package/{examples/jsm → src}/renderers/common/Bindings.js +45 -32
- package/{examples/jsm → src}/renderers/common/ClippingContext.js +18 -7
- 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 +34 -6
- package/src/renderers/common/PostProcessing.js +90 -0
- package/{examples/jsm/objects → src/renderers/common}/QuadMesh.js +8 -3
- package/{examples/jsm → src}/renderers/common/RenderContext.js +25 -1
- package/{examples/jsm → src}/renderers/common/RenderContexts.js +1 -1
- package/{examples/jsm → src}/renderers/common/RenderList.js +1 -1
- package/{examples/jsm → src}/renderers/common/RenderObject.js +45 -12
- package/{examples/jsm → src}/renderers/common/Renderer.js +151 -73
- package/{examples/jsm → src}/renderers/common/SampledTexture.js +14 -5
- package/src/renderers/common/StandardRenderer.js +18 -0
- 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 +14 -14
- package/{examples/jsm → src}/renderers/common/Uniform.js +9 -4
- package/{examples/jsm → src}/renderers/common/UniformsGroup.js +69 -31
- package/{examples/jsm → src}/renderers/common/extras/PMREMGenerator.js +25 -25
- package/src/renderers/common/nodes/NodeBuilderState.js +58 -0
- package/src/renderers/common/nodes/NodeLibrary.js +118 -0
- package/{examples/jsm → src}/renderers/common/nodes/NodeSampledTexture.js +8 -7
- package/{examples/jsm → src}/renderers/common/nodes/NodeSampler.js +2 -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 +69 -21
- package/src/renderers/common/nodes/StandardNodeLibrary.js +105 -0
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +16 -1
- package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +1 -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/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/ShaderChunk/tonemapping_pars_fragment.glsl.js +2 -2
- 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/WebGLBufferRenderer.js +6 -19
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +6 -18
- package/src/renderers/webgl/WebGLLights.js +6 -0
- package/src/renderers/webgl/WebGLProgram.js +27 -1
- package/src/renderers/webgl/WebGLPrograms.js +1 -1
- package/src/renderers/webgl/WebGLProperties.js +7 -0
- package/src/renderers/webgl/WebGLTextures.js +75 -57
- 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 +242 -120
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/nodes/GLSLNodeBuilder.js +227 -44
- 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 +22 -1
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLTextureUtils.js +62 -23
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLUtils.js +1 -1
- package/{examples/jsm → src}/renderers/webgpu/WebGPUBackend.js +242 -136
- package/{examples/jsm → src}/renderers/webgpu/WebGPURenderer.js +9 -9
- package/{examples/jsm → src}/renderers/webgpu/nodes/WGSLNodeBuilder.js +281 -107
- 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 +64 -33
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUConstants.js +4 -1
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUPipelineUtils.js +34 -36
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUTextureUtils.js +76 -44
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUUtils.js +42 -4
- package/src/renderers/webxr/WebXRDepthSensing.js +6 -0
- package/src/renderers/webxr/WebXRManager.js +37 -24
- package/src/textures/CompressedArrayTexture.js +1 -1
- package/examples/jsm/loaders/LogLuvLoader.js +0 -606
- package/examples/jsm/nodes/Nodes.js +0 -202
- package/examples/jsm/nodes/accessors/BatchNode.js +0 -78
- package/examples/jsm/nodes/accessors/CameraNode.js +0 -12
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +0 -61
- package/examples/jsm/nodes/accessors/InstanceNode.js +0 -94
- package/examples/jsm/nodes/accessors/InstancedPointsMaterialNode.js +0 -21
- package/examples/jsm/nodes/accessors/ModelNode.js +0 -36
- package/examples/jsm/nodes/accessors/NormalNode.js +0 -14
- package/examples/jsm/nodes/accessors/PointUVNode.js +0 -26
- package/examples/jsm/nodes/accessors/PositionNode.js +0 -10
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +0 -6
- package/examples/jsm/nodes/accessors/SkinningNode.js +0 -124
- package/examples/jsm/nodes/accessors/TangentNode.js +0 -23
- package/examples/jsm/nodes/core/CacheNode.js +0 -49
- 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 -83
- package/examples/jsm/nodes/core/UniformGroupNode.js +0 -36
- 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 -40
- package/examples/jsm/nodes/display/PassNode.js +0 -201
- package/examples/jsm/nodes/display/ToneMappingNode.js +0 -188
- package/examples/jsm/nodes/display/ViewportDepthNode.js +0 -97
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +0 -31
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +0 -37
- 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 -256
- package/examples/jsm/nodes/lighting/LightingContextNode.js +0 -66
- package/examples/jsm/nodes/lighting/LightsNode.js +0 -215
- 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/MeshMatcapNodeMaterial.js +0 -52
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +0 -38
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +0 -65
- package/examples/jsm/nodes/materials/MeshToonNodeMaterial.js +0 -34
- package/examples/jsm/nodes/materials/ShadowNodeMaterial.js +0 -34
- package/examples/jsm/nodes/math/HashNode.js +0 -34
- package/examples/jsm/nodes/math/MathNode.js +0 -391
- package/examples/jsm/nodes/procedural/CheckerNode.js +0 -42
- package/examples/jsm/nodes/utils/DiscardNode.js +0 -27
- package/examples/jsm/nodes/utils/PackingNode.js +0 -55
- package/examples/jsm/nodes/utils/RotateUVNode.js +0 -35
- 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/nodes/accessors/UVNode.js → src/nodes/accessors/UV.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/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/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/ChainMap.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/Pipelines.js +0 -0
- /package/{examples/jsm → src}/renderers/common/ProgrammableStage.js +0 -0
- /package/{examples/jsm → src}/renderers/common/RenderBundle.js +0 -0
- /package/{examples/jsm → src}/renderers/common/RenderBundles.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
|
@@ -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,17 +1,19 @@
|
|
|
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
|
|
|
8
9
|
constructor( backend ) {
|
|
9
10
|
|
|
10
11
|
this.backend = backend;
|
|
12
|
+
this.bindGroupLayoutCache = new WeakMap();
|
|
11
13
|
|
|
12
14
|
}
|
|
13
15
|
|
|
14
|
-
createBindingsLayout(
|
|
16
|
+
createBindingsLayout( bindGroup ) {
|
|
15
17
|
|
|
16
18
|
const backend = this.backend;
|
|
17
19
|
const device = backend.device;
|
|
@@ -20,7 +22,7 @@ class WebGPUBindingUtils {
|
|
|
20
22
|
|
|
21
23
|
let index = 0;
|
|
22
24
|
|
|
23
|
-
for ( const binding of bindings ) {
|
|
25
|
+
for ( const binding of bindGroup.bindings ) {
|
|
24
26
|
|
|
25
27
|
const bindingGPU = {
|
|
26
28
|
binding: index ++,
|
|
@@ -33,7 +35,7 @@ class WebGPUBindingUtils {
|
|
|
33
35
|
|
|
34
36
|
if ( binding.isStorageBuffer ) {
|
|
35
37
|
|
|
36
|
-
buffer.type =
|
|
38
|
+
buffer.type = binding.access;
|
|
37
39
|
|
|
38
40
|
}
|
|
39
41
|
|
|
@@ -70,11 +72,17 @@ class WebGPUBindingUtils {
|
|
|
70
72
|
|
|
71
73
|
const texture = {}; // GPUTextureBindingLayout
|
|
72
74
|
|
|
75
|
+
if ( binding.texture.isMultisampleRenderTargetTexture === true ) {
|
|
76
|
+
|
|
77
|
+
texture.multisampled = true;
|
|
78
|
+
|
|
79
|
+
}
|
|
80
|
+
|
|
73
81
|
if ( binding.texture.isDepthTexture ) {
|
|
74
82
|
|
|
75
83
|
texture.sampleType = GPUTextureSampleType.Depth;
|
|
76
84
|
|
|
77
|
-
} else if ( binding.texture.isDataTexture ) {
|
|
85
|
+
} else if ( binding.texture.isDataTexture || binding.texture.isDataArrayTexture || binding.texture.isData3DTexture ) {
|
|
78
86
|
|
|
79
87
|
const type = binding.texture.type;
|
|
80
88
|
|
|
@@ -88,9 +96,15 @@ class WebGPUBindingUtils {
|
|
|
88
96
|
|
|
89
97
|
} else if ( type === FloatType ) {
|
|
90
98
|
|
|
91
|
-
|
|
99
|
+
if ( this.backend.hasFeature( 'float32-filterable' ) ) {
|
|
100
|
+
|
|
101
|
+
texture.sampleType = GPUTextureSampleType.Float;
|
|
102
|
+
|
|
103
|
+
} else {
|
|
104
|
+
|
|
105
|
+
texture.sampleType = GPUTextureSampleType.UnfilterableFloat;
|
|
92
106
|
|
|
93
|
-
|
|
107
|
+
}
|
|
94
108
|
|
|
95
109
|
}
|
|
96
110
|
|
|
@@ -100,7 +114,7 @@ class WebGPUBindingUtils {
|
|
|
100
114
|
|
|
101
115
|
texture.viewDimension = GPUTextureViewDimension.Cube;
|
|
102
116
|
|
|
103
|
-
} else if ( binding.texture.isDataArrayTexture ) {
|
|
117
|
+
} else if ( binding.texture.isDataArrayTexture || binding.texture.isCompressedArrayTexture ) {
|
|
104
118
|
|
|
105
119
|
texture.viewDimension = GPUTextureViewDimension.TwoDArray;
|
|
106
120
|
|
|
@@ -126,19 +140,26 @@ class WebGPUBindingUtils {
|
|
|
126
140
|
|
|
127
141
|
}
|
|
128
142
|
|
|
129
|
-
createBindings(
|
|
143
|
+
createBindings( bindGroup ) {
|
|
130
144
|
|
|
131
|
-
const backend = this
|
|
132
|
-
const bindingsData = backend.get(
|
|
145
|
+
const { backend, bindGroupLayoutCache } = this;
|
|
146
|
+
const bindingsData = backend.get( bindGroup );
|
|
133
147
|
|
|
134
148
|
// setup (static) binding layout and (dynamic) binding group
|
|
135
149
|
|
|
136
|
-
|
|
137
|
-
|
|
150
|
+
let bindLayoutGPU = bindGroupLayoutCache.get( bindGroup.bindingsReference );
|
|
151
|
+
|
|
152
|
+
if ( bindLayoutGPU === undefined ) {
|
|
153
|
+
|
|
154
|
+
bindLayoutGPU = this.createBindingsLayout( bindGroup );
|
|
155
|
+
bindGroupLayoutCache.set( bindGroup.bindingsReference, bindLayoutGPU );
|
|
156
|
+
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const bindGroupGPU = this.createBindGroup( bindGroup, bindLayoutGPU );
|
|
138
160
|
|
|
139
161
|
bindingsData.layout = bindLayoutGPU;
|
|
140
162
|
bindingsData.group = bindGroupGPU;
|
|
141
|
-
bindingsData.bindings = bindings;
|
|
142
163
|
|
|
143
164
|
}
|
|
144
165
|
|
|
@@ -154,7 +175,7 @@ class WebGPUBindingUtils {
|
|
|
154
175
|
|
|
155
176
|
}
|
|
156
177
|
|
|
157
|
-
createBindGroup(
|
|
178
|
+
createBindGroup( bindGroup, layoutGPU ) {
|
|
158
179
|
|
|
159
180
|
const backend = this.backend;
|
|
160
181
|
const device = backend.device;
|
|
@@ -162,7 +183,7 @@ class WebGPUBindingUtils {
|
|
|
162
183
|
let bindingPoint = 0;
|
|
163
184
|
const entriesGPU = [];
|
|
164
185
|
|
|
165
|
-
for ( const binding of bindings ) {
|
|
186
|
+
for ( const binding of bindGroup.bindings ) {
|
|
166
187
|
|
|
167
188
|
if ( binding.isUniformBuffer ) {
|
|
168
189
|
|
|
@@ -213,37 +234,46 @@ class WebGPUBindingUtils {
|
|
|
213
234
|
|
|
214
235
|
const textureData = backend.get( binding.texture );
|
|
215
236
|
|
|
216
|
-
let
|
|
237
|
+
let resourceGPU;
|
|
217
238
|
|
|
218
|
-
if (
|
|
239
|
+
if ( textureData.externalTexture !== undefined ) {
|
|
219
240
|
|
|
220
|
-
|
|
241
|
+
resourceGPU = device.importExternalTexture( { source: textureData.externalTexture } );
|
|
221
242
|
|
|
222
|
-
} else
|
|
243
|
+
} else {
|
|
223
244
|
|
|
224
|
-
|
|
245
|
+
const mipLevelCount = binding.store ? 1 : textureData.texture.mipLevelCount;
|
|
246
|
+
const propertyName = `view-${ textureData.texture.width }-${ textureData.texture.height }-${ mipLevelCount }`;
|
|
225
247
|
|
|
226
|
-
|
|
248
|
+
resourceGPU = textureData[ propertyName ];
|
|
227
249
|
|
|
228
|
-
|
|
250
|
+
if ( resourceGPU === undefined ) {
|
|
229
251
|
|
|
230
|
-
|
|
252
|
+
const aspectGPU = GPUTextureAspect.All;
|
|
231
253
|
|
|
232
|
-
|
|
254
|
+
let dimensionViewGPU;
|
|
233
255
|
|
|
234
|
-
|
|
256
|
+
if ( binding.isSampledCubeTexture ) {
|
|
235
257
|
|
|
236
|
-
|
|
258
|
+
dimensionViewGPU = GPUTextureViewDimension.Cube;
|
|
237
259
|
|
|
238
|
-
|
|
260
|
+
} else if ( binding.isSampledTexture3D ) {
|
|
239
261
|
|
|
240
|
-
|
|
262
|
+
dimensionViewGPU = GPUTextureViewDimension.ThreeD;
|
|
241
263
|
|
|
242
|
-
|
|
264
|
+
} else if ( binding.texture.isDataArrayTexture || binding.texture.isCompressedArrayTexture ) {
|
|
265
|
+
|
|
266
|
+
dimensionViewGPU = GPUTextureViewDimension.TwoDArray;
|
|
267
|
+
|
|
268
|
+
} else {
|
|
243
269
|
|
|
244
|
-
|
|
270
|
+
dimensionViewGPU = GPUTextureViewDimension.TwoD;
|
|
245
271
|
|
|
246
|
-
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
resourceGPU = textureData[ propertyName ] = textureData.texture.createView( { aspect: aspectGPU, dimension: dimensionViewGPU, mipLevelCount } );
|
|
275
|
+
|
|
276
|
+
}
|
|
247
277
|
|
|
248
278
|
}
|
|
249
279
|
|
|
@@ -256,6 +286,7 @@ class WebGPUBindingUtils {
|
|
|
256
286
|
}
|
|
257
287
|
|
|
258
288
|
return device.createBindGroup( {
|
|
289
|
+
label: 'bindGroup_' + bindGroup.name,
|
|
259
290
|
layout: layoutGPU,
|
|
260
291
|
entries: entriesGPU
|
|
261
292
|
} );
|
|
@@ -326,5 +326,8 @@ export const GPUFeatureName = {
|
|
|
326
326
|
ShaderF16: 'shader-f16',
|
|
327
327
|
RG11B10UFloat: 'rg11b10ufloat-renderable',
|
|
328
328
|
BGRA8UNormStorage: 'bgra8unorm-storage',
|
|
329
|
-
Float32Filterable: 'float32-filterable'
|
|
329
|
+
Float32Filterable: 'float32-filterable',
|
|
330
|
+
ClipDistances: 'clip-distances',
|
|
331
|
+
DualSourceBlending: 'dual-source-blending',
|
|
332
|
+
Subgroups: 'subgroups'
|
|
330
333
|
};
|
|
@@ -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
|
|
|
@@ -25,22 +25,7 @@ class WebGPUPipelineUtils {
|
|
|
25
25
|
|
|
26
26
|
_getSampleCount( renderObjectContext ) {
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if ( sampleCount > 1 ) {
|
|
31
|
-
|
|
32
|
-
// WebGPU only supports power-of-two sample counts and 2 is not a valid value
|
|
33
|
-
sampleCount = Math.pow( 2, Math.floor( Math.log2( sampleCount ) ) );
|
|
34
|
-
|
|
35
|
-
if ( sampleCount === 2 ) {
|
|
36
|
-
|
|
37
|
-
sampleCount = 4;
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return sampleCount;
|
|
28
|
+
return this.backend.utils.getSampleCountRenderContext( renderObjectContext );
|
|
44
29
|
|
|
45
30
|
}
|
|
46
31
|
|
|
@@ -54,7 +39,18 @@ class WebGPUPipelineUtils {
|
|
|
54
39
|
const utils = backend.utils;
|
|
55
40
|
|
|
56
41
|
const pipelineData = backend.get( pipeline );
|
|
57
|
-
|
|
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
|
+
}
|
|
58
54
|
|
|
59
55
|
// vertex buffers
|
|
60
56
|
|
|
@@ -127,7 +123,7 @@ class WebGPUPipelineUtils {
|
|
|
127
123
|
const sampleCount = this._getSampleCount( renderObject.context );
|
|
128
124
|
|
|
129
125
|
const pipelineDescriptor = {
|
|
130
|
-
label:
|
|
126
|
+
label: `renderPipeline_${ material.name || material.type }_${ material.id }`,
|
|
131
127
|
vertex: Object.assign( {}, vertexModule, { buffers: vertexBuffers } ),
|
|
132
128
|
fragment: Object.assign( {}, fragmentModule, { targets } ),
|
|
133
129
|
primitive: primitiveState,
|
|
@@ -145,7 +141,7 @@ class WebGPUPipelineUtils {
|
|
|
145
141
|
alphaToCoverageEnabled: material.alphaToCoverage
|
|
146
142
|
},
|
|
147
143
|
layout: device.createPipelineLayout( {
|
|
148
|
-
bindGroupLayouts
|
|
144
|
+
bindGroupLayouts
|
|
149
145
|
} )
|
|
150
146
|
};
|
|
151
147
|
|
|
@@ -172,17 +168,14 @@ class WebGPUPipelineUtils {
|
|
|
172
168
|
|
|
173
169
|
}
|
|
174
170
|
|
|
175
|
-
createBundleEncoder( renderContext
|
|
171
|
+
createBundleEncoder( renderContext ) {
|
|
176
172
|
|
|
177
173
|
const backend = this.backend;
|
|
178
174
|
const { utils, device } = backend;
|
|
179
175
|
|
|
180
|
-
const renderContextData = backend.get( renderContext );
|
|
181
|
-
const renderObjectData = backend.get( renderObject );
|
|
182
|
-
|
|
183
176
|
const depthStencilFormat = utils.getCurrentDepthStencilFormat( renderContext );
|
|
184
177
|
const colorFormat = utils.getCurrentColorFormat( renderContext );
|
|
185
|
-
const sampleCount = this._getSampleCount(
|
|
178
|
+
const sampleCount = this._getSampleCount( renderContext );
|
|
186
179
|
|
|
187
180
|
const descriptor = {
|
|
188
181
|
label: 'renderBundleEncoder',
|
|
@@ -191,13 +184,7 @@ class WebGPUPipelineUtils {
|
|
|
191
184
|
sampleCount
|
|
192
185
|
};
|
|
193
186
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
renderObjectData.bundleEncoder = bundleEncoder;
|
|
197
|
-
renderContextData.currentSets = { attributes: {} };
|
|
198
|
-
renderContextData._renderBundleViewport = renderContext.width + '_' + renderContext.height;
|
|
199
|
-
|
|
200
|
-
return bundleEncoder;
|
|
187
|
+
return device.createRenderBundleEncoder( descriptor );
|
|
201
188
|
|
|
202
189
|
}
|
|
203
190
|
|
|
@@ -209,12 +196,23 @@ class WebGPUPipelineUtils {
|
|
|
209
196
|
const computeProgram = backend.get( pipeline.computeProgram ).module;
|
|
210
197
|
|
|
211
198
|
const pipelineGPU = backend.get( pipeline );
|
|
212
|
-
|
|
199
|
+
|
|
200
|
+
// bind group layouts
|
|
201
|
+
|
|
202
|
+
const bindGroupLayouts = [];
|
|
203
|
+
|
|
204
|
+
for ( const bindingsGroup of bindings ) {
|
|
205
|
+
|
|
206
|
+
const bindingsData = backend.get( bindingsGroup );
|
|
207
|
+
|
|
208
|
+
bindGroupLayouts.push( bindingsData.layout );
|
|
209
|
+
|
|
210
|
+
}
|
|
213
211
|
|
|
214
212
|
pipelineGPU.pipeline = device.createComputePipeline( {
|
|
215
213
|
compute: computeProgram,
|
|
216
214
|
layout: device.createPipelineLayout( {
|
|
217
|
-
bindGroupLayouts
|
|
215
|
+
bindGroupLayouts
|
|
218
216
|
} )
|
|
219
217
|
} );
|
|
220
218
|
|
|
@@ -273,11 +271,11 @@ class WebGPUPipelineUtils {
|
|
|
273
271
|
switch ( blending ) {
|
|
274
272
|
|
|
275
273
|
case NormalBlending:
|
|
276
|
-
setBlend( GPUBlendFactor.
|
|
274
|
+
setBlend( GPUBlendFactor.One, GPUBlendFactor.OneMinusSrcAlpha, GPUBlendFactor.One, GPUBlendFactor.OneMinusSrcAlpha );
|
|
277
275
|
break;
|
|
278
276
|
|
|
279
277
|
case AdditiveBlending:
|
|
280
|
-
setBlend( GPUBlendFactor.
|
|
278
|
+
setBlend( GPUBlendFactor.One, GPUBlendFactor.One, GPUBlendFactor.One, GPUBlendFactor.One );
|
|
281
279
|
break;
|
|
282
280
|
|
|
283
281
|
case SubtractiveBlending:
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import DataMap from '../../common/DataMap.js';
|
|
1
2
|
import { GPUTextureViewDimension, GPUIndexFormat, GPUFilterMode, GPUPrimitiveTopology, GPULoadOp, GPUStoreOp } from './WebGPUConstants.js';
|
|
2
3
|
|
|
3
|
-
class WebGPUTexturePassUtils {
|
|
4
|
+
class WebGPUTexturePassUtils extends DataMap {
|
|
4
5
|
|
|
5
6
|
constructor( device ) {
|
|
6
7
|
|
|
8
|
+
super();
|
|
9
|
+
|
|
7
10
|
this.device = device;
|
|
8
11
|
|
|
9
12
|
const mipmapVertexSource = `
|
|
@@ -99,6 +102,7 @@ fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {
|
|
|
99
102
|
if ( pipeline === undefined ) {
|
|
100
103
|
|
|
101
104
|
pipeline = this.device.createRenderPipeline( {
|
|
105
|
+
label: `mipmap-${ format }`,
|
|
102
106
|
vertex: {
|
|
103
107
|
module: this.mipmapVertexShaderModule,
|
|
104
108
|
entryPoint: 'main'
|
|
@@ -130,6 +134,7 @@ fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {
|
|
|
130
134
|
if ( pipeline === undefined ) {
|
|
131
135
|
|
|
132
136
|
pipeline = this.device.createRenderPipeline( {
|
|
137
|
+
label: `flipY-${ format }`,
|
|
133
138
|
vertex: {
|
|
134
139
|
module: this.mipmapVertexShaderModule,
|
|
135
140
|
entryPoint: 'main'
|
|
@@ -226,9 +231,33 @@ fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {
|
|
|
226
231
|
|
|
227
232
|
generateMipmaps( textureGPU, textureGPUDescriptor, baseArrayLayer = 0 ) {
|
|
228
233
|
|
|
229
|
-
const
|
|
234
|
+
const textureData = this.get( textureGPU );
|
|
235
|
+
|
|
236
|
+
if ( textureData.useCount === undefined ) {
|
|
237
|
+
|
|
238
|
+
textureData.useCount = 0;
|
|
239
|
+
textureData.layers = [];
|
|
240
|
+
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
const passes = textureData.layers[ baseArrayLayer ] || this._mipmapCreateBundles( textureGPU, textureGPUDescriptor, baseArrayLayer );
|
|
230
244
|
|
|
231
245
|
const commandEncoder = this.device.createCommandEncoder( {} );
|
|
246
|
+
|
|
247
|
+
this._mipmapRunBundles( commandEncoder, passes );
|
|
248
|
+
|
|
249
|
+
this.device.queue.submit( [ commandEncoder.finish() ] );
|
|
250
|
+
|
|
251
|
+
if ( textureData.useCount !== 0 ) textureData.layers[ baseArrayLayer ] = passes;
|
|
252
|
+
|
|
253
|
+
textureData.useCount ++;
|
|
254
|
+
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
_mipmapCreateBundles( textureGPU, textureGPUDescriptor, baseArrayLayer ) {
|
|
258
|
+
|
|
259
|
+
const pipeline = this.getTransferPipeline( textureGPUDescriptor.format );
|
|
260
|
+
|
|
232
261
|
const bindGroupLayout = pipeline.getBindGroupLayout( 0 ); // @TODO: Consider making this static.
|
|
233
262
|
|
|
234
263
|
let srcView = textureGPU.createView( {
|
|
@@ -238,6 +267,8 @@ fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {
|
|
|
238
267
|
baseArrayLayer
|
|
239
268
|
} );
|
|
240
269
|
|
|
270
|
+
const passes = [];
|
|
271
|
+
|
|
241
272
|
for ( let i = 1; i < textureGPUDescriptor.mipLevelCount; i ++ ) {
|
|
242
273
|
|
|
243
274
|
const bindGroup = this.device.createBindGroup( {
|
|
@@ -258,25 +289,51 @@ fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {
|
|
|
258
289
|
baseArrayLayer
|
|
259
290
|
} );
|
|
260
291
|
|
|
261
|
-
const
|
|
292
|
+
const passDescriptor = {
|
|
262
293
|
colorAttachments: [ {
|
|
263
294
|
view: dstView,
|
|
264
295
|
loadOp: GPULoadOp.Clear,
|
|
265
296
|
storeOp: GPUStoreOp.Store,
|
|
266
297
|
clearValue: [ 0, 0, 0, 0 ]
|
|
267
298
|
} ]
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
const passEncoder = this.device.createRenderBundleEncoder( {
|
|
302
|
+
colorFormats: [ textureGPUDescriptor.format ]
|
|
268
303
|
} );
|
|
269
304
|
|
|
270
305
|
passEncoder.setPipeline( pipeline );
|
|
271
306
|
passEncoder.setBindGroup( 0, bindGroup );
|
|
272
307
|
passEncoder.draw( 4, 1, 0, 0 );
|
|
273
|
-
|
|
308
|
+
|
|
309
|
+
passes.push( {
|
|
310
|
+
renderBundles: [ passEncoder.finish() ],
|
|
311
|
+
passDescriptor
|
|
312
|
+
} );
|
|
274
313
|
|
|
275
314
|
srcView = dstView;
|
|
276
315
|
|
|
277
316
|
}
|
|
278
317
|
|
|
279
|
-
|
|
318
|
+
return passes;
|
|
319
|
+
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
_mipmapRunBundles( commandEncoder, passes ) {
|
|
323
|
+
|
|
324
|
+
const levels = passes.length;
|
|
325
|
+
|
|
326
|
+
for ( let i = 0; i < levels; i ++ ) {
|
|
327
|
+
|
|
328
|
+
const pass = passes[ i ];
|
|
329
|
+
|
|
330
|
+
const passEncoder = commandEncoder.beginRenderPass( pass.passDescriptor );
|
|
331
|
+
|
|
332
|
+
passEncoder.executeBundles( pass.renderBundles );
|
|
333
|
+
|
|
334
|
+
passEncoder.end();
|
|
335
|
+
|
|
336
|
+
}
|
|
280
337
|
|
|
281
338
|
}
|
|
282
339
|
|