@unikia/upe-renderer 0.186.110 → 0.187.11
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 +5 -7
- package/UPSTREAM.md +4 -4
- package/build/three.core.js +853 -277
- package/build/three.module.js +1098 -1280
- package/build/three.tsl.js +41938 -686
- package/build/three.webgpu.js +10604 -49055
- package/build/three.webgpu.nodes.js +9249 -5788
- package/examples/jsm/Addons.js +2 -0
- package/examples/jsm/animation/CCDIKSolver.js +17 -5
- package/examples/jsm/controls/FirstPersonControls.js +1 -1
- package/examples/jsm/controls/OrbitControls.js +27 -14
- package/examples/jsm/csm/CSMShader.js +74 -3
- package/examples/jsm/curves/CurveExtras.js +4 -4
- package/examples/jsm/curves/NURBSCurve.js +14 -0
- package/examples/jsm/exporters/EXRExporter.js +673 -16
- package/examples/jsm/exporters/GLTFExporter.js +4 -4
- package/examples/jsm/exporters/KTX2Exporter.js +1 -1
- package/examples/jsm/exporters/OBJExporter.js +48 -5
- package/examples/jsm/exporters/PLYExporter.js +22 -11
- package/examples/jsm/generators/CityGenerator.js +3 -2
- package/examples/jsm/generators/city/SkyscraperGenerator.js +63 -21
- package/examples/jsm/gpgpu/BitonicSort.js +30 -23
- package/examples/jsm/helpers/VertexTangentsHelper.js +1 -1
- package/examples/jsm/inspector/Extension.js +1 -1
- package/examples/jsm/inspector/Inspector.js +6 -46
- package/examples/jsm/inspector/RendererInspector.js +43 -8
- package/examples/jsm/inspector/Storage.js +49 -0
- package/examples/jsm/inspector/extensions/color-grading/ColorGrading.js +32 -27
- package/examples/jsm/inspector/tabs/Parameters.js +5 -1
- package/examples/jsm/inspector/tabs/Performance.js +22 -7
- package/examples/jsm/inspector/tabs/Settings.js +1 -1
- package/examples/jsm/inspector/tabs/Timeline.js +83 -7
- package/examples/jsm/inspector/tabs/Viewer.js +25 -10
- package/examples/jsm/inspector/ui/Profiler.js +1 -1
- package/examples/jsm/inspector/ui/Style.js +21 -53
- package/examples/jsm/inspector/ui/Values.js +28 -3
- package/examples/jsm/libs/fflate.module.js +83 -56
- package/examples/jsm/libs/mikktspace.README.md +27 -0
- package/examples/jsm/libs/mikktspace.module.js +721 -109
- package/examples/jsm/lighting/ClusteredLighting.js +100 -2
- package/examples/jsm/lighting/LightMapper.js +295 -0
- package/examples/jsm/lighting/LightProbeGrid.js +242 -139
- package/examples/jsm/lighting/LightProbeGridWebGL.js +30 -14
- package/examples/jsm/lighting/vxgi/VXGIConeTracer.js +54 -5
- package/examples/jsm/lighting/vxgi/VXGIIrradiance.js +43 -0
- package/examples/jsm/lighting/vxgi/VXGINode.js +13 -56
- package/examples/jsm/lighting/vxgi/VXGISceneCollector.js +316 -1
- package/examples/jsm/lighting/vxgi/VXGIVolume.js +69 -59
- package/examples/jsm/lights/SunLight.js +9 -4
- package/examples/jsm/lights/SunLightNode.js +3 -3
- package/examples/jsm/lines/LineMaterial.js +26 -10
- package/examples/jsm/loaders/3DMLoader.js +10 -1
- package/examples/jsm/loaders/3MFLoader.js +5 -1
- package/examples/jsm/loaders/AMFLoader.js +2 -0
- package/examples/jsm/loaders/BVHLoader.js +2 -0
- package/examples/jsm/loaders/ColladaLoader.js +8 -0
- package/examples/jsm/loaders/DDSLoader.js +1 -1
- package/examples/jsm/loaders/DRACOLoader.js +5 -1
- package/examples/jsm/loaders/EXRLoader.js +120 -104
- package/examples/jsm/loaders/FBXLoader.js +4 -0
- package/examples/jsm/loaders/FontLoader.js +2 -0
- package/examples/jsm/loaders/GCodeLoader.js +5 -9
- package/examples/jsm/loaders/GLTFLoader.js +112 -31
- package/examples/jsm/loaders/GaussianSplatPLYLoader.js +2 -0
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +3 -0
- package/examples/jsm/loaders/IESLoader.js +46 -12
- package/examples/jsm/loaders/JXLLoader.js +159 -0
- package/examples/jsm/loaders/KMZLoader.js +6 -0
- package/examples/jsm/loaders/KSPLATLoader.js +2 -0
- package/examples/jsm/loaders/KTX2Loader.js +49 -4
- package/examples/jsm/loaders/KTXLoader.js +5 -3
- package/examples/jsm/loaders/LDrawLoader.js +15 -22
- package/examples/jsm/loaders/LUT3dlLoader.js +5 -1
- package/examples/jsm/loaders/LUTCubeLoader.js +6 -2
- package/examples/jsm/loaders/LUTImageLoader.js +2 -0
- package/examples/jsm/loaders/LWOLoader.js +6 -0
- package/examples/jsm/loaders/MD2Loader.js +2 -0
- package/examples/jsm/loaders/MDDLoader.js +4 -0
- package/examples/jsm/loaders/MTLLoader.js +8 -0
- package/examples/jsm/loaders/MaterialXLoader.js +57 -5
- package/examples/jsm/loaders/NRRDLoader.js +4 -2
- package/examples/jsm/loaders/OBJLoader.js +10 -4
- package/examples/jsm/loaders/PCDLoader.js +6 -2
- package/examples/jsm/loaders/PDBLoader.js +5 -3
- package/examples/jsm/loaders/PLYLoader.js +39 -15
- package/examples/jsm/loaders/PVRLoader.js +2 -2
- package/examples/jsm/loaders/SPLATLoader.js +2 -0
- package/examples/jsm/loaders/SPZLoader.js +2 -0
- package/examples/jsm/loaders/STLLoader.js +3 -1
- package/examples/jsm/loaders/SVGLoader.js +27 -49
- package/examples/jsm/loaders/TDSLoader.js +4 -0
- package/examples/jsm/loaders/TGALoader.js +6 -5
- package/examples/jsm/loaders/TTFLoader.js +2 -0
- package/examples/jsm/loaders/USDLoader.js +14 -0
- package/examples/jsm/loaders/UltraHDRLoader.js +2 -0
- package/examples/jsm/loaders/VOXLoader.js +3 -0
- package/examples/jsm/loaders/VRMLLoader.js +4 -0
- package/examples/jsm/loaders/VTKLoader.js +2 -0
- package/examples/jsm/loaders/XYZLoader.js +2 -0
- package/examples/jsm/loaders/collada/ColladaComposer.js +15 -8
- package/examples/jsm/loaders/materialx/MaterialXDocument.js +610 -138
- package/examples/jsm/loaders/materialx/MaterialXInterfaceValidation.js +12 -95
- package/examples/jsm/loaders/materialx/MaterialXLog.js +4 -0
- package/examples/jsm/loaders/materialx/MaterialXNodeDefs.js +99 -0
- package/examples/jsm/loaders/materialx/MaterialXNodeInterfaceRegistry.js +760 -1
- package/examples/jsm/loaders/materialx/MaterialXNodeLibrary.js +222 -372
- package/examples/jsm/loaders/materialx/MaterialXSurfaceMappings.js +163 -259
- package/examples/jsm/loaders/materialx/MaterialXUtils.js +25 -0
- package/examples/jsm/loaders/materialx/compile/MaterialXCompileRegistry.js +161 -159
- package/examples/jsm/loaders/usd/USDAParser.js +56 -47
- package/examples/jsm/loaders/usd/USDComposer.js +25 -30
- package/examples/jsm/math/ColorConverter.js +7 -3
- package/examples/jsm/math/Lut.js +2 -2
- package/examples/jsm/math/OBB.js +3 -3
- package/examples/jsm/math/Octree.js +20 -17
- package/examples/jsm/objects/GaussianSplat.js +5 -4
- package/examples/jsm/objects/Reflector.js +5 -0
- package/examples/jsm/objects/SkyMesh.js +14 -7
- package/examples/jsm/objects/Water2Mesh.js +2 -2
- package/examples/jsm/physics/RapierPhysics.js +2 -2
- package/examples/jsm/pipelines/MeshletDrawingPipeline.js +5571 -0
- package/examples/jsm/pipelines/VisibilityBufferDrawingPipeline.js +954 -0
- package/examples/jsm/postprocessing/BokehPass.js +1 -1
- package/examples/jsm/postprocessing/GTAOPass.js +26 -18
- package/examples/jsm/renderers/SVGRenderer.js +3 -2
- package/examples/jsm/shaders/GTAOShader.js +7 -4
- package/examples/jsm/shaders/PoissonDenoiseShader.js +1 -10
- package/examples/jsm/tsl/WebGLNodesHandler.js +21 -9
- package/examples/jsm/tsl/display/AfterImageNode.js +3 -3
- package/examples/jsm/tsl/display/BilateralBlurNode.js +3 -3
- package/examples/jsm/tsl/display/BloomNode.js +3 -3
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +8 -19
- package/examples/jsm/tsl/display/DenoiseNode.js +5 -5
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +3 -3
- package/examples/jsm/tsl/display/DotScreenNode.js +3 -3
- package/examples/jsm/tsl/display/FSR1Node.js +3 -3
- package/examples/jsm/tsl/display/FXAANode.js +3 -10
- package/examples/jsm/tsl/display/FilmNode.js +3 -3
- package/examples/jsm/tsl/display/GTAONode.js +33 -25
- package/examples/jsm/tsl/display/GaussianBlurNode.js +3 -3
- package/examples/jsm/tsl/display/GodraysNode.js +5 -19
- package/examples/jsm/tsl/display/ImportanceSampledEnvironment.js +8 -4
- package/examples/jsm/tsl/display/LensflareNode.js +3 -3
- package/examples/jsm/tsl/display/Lut3DNode.js +3 -3
- package/examples/jsm/tsl/display/OITPassNode.js +0 -11
- package/examples/jsm/tsl/display/OutlineNode.js +107 -5
- package/examples/jsm/tsl/display/PixelationPassNode.js +85 -193
- package/examples/jsm/tsl/display/RGBShiftNode.js +3 -3
- package/examples/jsm/tsl/display/RecurrentDenoiseNode.js +23 -126
- package/examples/jsm/tsl/display/SMAANode.js +3 -3
- package/examples/jsm/tsl/display/SSAONode.js +6 -20
- package/examples/jsm/tsl/display/SSGINode.js +36 -29
- package/examples/jsm/tsl/display/SSRNode.js +135 -63
- package/examples/jsm/tsl/display/SSSNode.js +6 -20
- package/examples/jsm/tsl/display/SharpenNode.js +3 -3
- package/examples/jsm/tsl/display/SobelOperatorNode.js +3 -3
- package/examples/jsm/tsl/display/TAAUNode.js +10 -42
- package/examples/jsm/tsl/display/TRAANode.js +11 -43
- package/examples/jsm/tsl/display/TemporalReprojectNode.js +42 -47
- package/examples/jsm/tsl/display/TransitionNode.js +3 -3
- package/examples/jsm/tsl/display/lensDirt.js +30 -0
- package/examples/jsm/tsl/lighting/ClusteredLightsNode.js +482 -121
- package/examples/jsm/tsl/lighting/DynamicLightsNode.js +41 -140
- package/examples/jsm/tsl/lighting/LightProbeGridNode.js +72 -25
- package/examples/jsm/tsl/lighting/data/AmbientLightDataNode.js +6 -0
- package/examples/jsm/tsl/lighting/data/DirectionalLightDataNode.js +6 -0
- package/examples/jsm/tsl/lighting/data/HemisphereLightDataNode.js +6 -0
- package/examples/jsm/tsl/lighting/data/PointLightDataNode.js +6 -0
- package/examples/jsm/tsl/lighting/data/SpotLightDataNode.js +6 -0
- package/examples/jsm/tsl/shadows/TileShadowNode.js +102 -14
- package/examples/jsm/tsl/utils/Raymarching.js +1 -1
- package/examples/jsm/tsl/utils/SoftParticles.js +5 -12
- package/examples/jsm/tsl/utils/SpecularHelpers.js +47 -70
- package/examples/jsm/tsl/utils/TAAUtils.js +6 -17
- package/examples/jsm/utils/BufferGeometryUtils.js +110 -88
- package/examples/jsm/utils/MeshletGeometryUtils.js +417 -0
- package/examples/jsm/utils/SceneOptimizer.js +2 -1
- package/examples/jsm/utils/SceneUtils.js +1 -1
- package/examples/jsm/utils/unwrapUVs.js +865 -0
- package/examples/jsm/webxr/XREstimatedLight.js +11 -4
- package/package.json +3 -3
- package/src/Three.TSL.js +2 -683
- package/src/Three.WebGPU.Nodes.js +2 -1
- package/src/Three.WebGPU.js +2 -1
- package/src/animation/AnimationAction.js +1 -1
- package/src/animation/AnimationUtils.js +1 -3
- package/src/animation/KeyframeTrack.js +19 -0
- package/src/cameras/ArrayCamera.js +12 -0
- package/src/cameras/CubeCamera.js +3 -3
- package/src/constants.js +1 -9
- package/src/core/BufferAttribute.js +57 -21
- package/src/core/BufferGeometry.js +5 -13
- package/src/core/Clock.js +1 -1
- package/src/core/InterleavedBuffer.js +28 -18
- package/src/core/InterleavedBufferAttribute.js +54 -20
- package/src/core/Object3D.js +19 -9
- package/src/core/Raycaster.js +2 -0
- package/src/core/RenderTarget.js +11 -5
- package/src/core/UniformsGroup.js +7 -3
- package/src/extras/PMREMGenerator.js +392 -685
- package/src/extras/core/Curve.js +4 -0
- package/src/extras/core/CurvePath.js +13 -0
- package/src/extras/core/ShapePath.js +1 -1
- package/src/geometries/EdgesGeometry.js +12 -10
- package/src/geometries/LatheGeometry.js +2 -0
- package/src/helpers/PolarGridHelper.js +1 -1
- package/src/lights/Light.js +11 -0
- package/src/lights/LightProbe.js +2 -0
- package/src/lights/LightShadow.js +2 -0
- package/src/loaders/AnimationLoader.js +2 -0
- package/src/loaders/AudioLoader.js +2 -0
- package/src/loaders/BufferGeometryLoader.js +2 -0
- package/src/loaders/CompressedTextureLoader.js +2 -0
- package/src/loaders/CubeTextureLoader.js +2 -0
- package/src/loaders/DataTextureLoader.js +2 -0
- package/src/loaders/FileLoader.js +2 -0
- package/src/loaders/ImageBitmapLoader.js +3 -1
- package/src/loaders/ImageLoader.js +1 -0
- package/src/loaders/Loader.js +47 -0
- package/src/loaders/MaterialLoader.js +2 -0
- package/src/loaders/ObjectLoader.js +27 -8
- package/src/loaders/TextureLoader.js +5 -3
- package/src/loaders/nodes/NodeLoader.js +2 -0
- package/src/materials/Material.js +21 -2
- package/src/materials/MeshDepthMaterial.js +1 -1
- package/src/materials/MeshDistanceMaterial.js +1 -1
- package/src/materials/MeshLambertMaterial.js +1 -1
- package/src/materials/MeshMatcapMaterial.js +1 -1
- package/src/materials/MeshNormalMaterial.js +1 -1
- package/src/materials/MeshPhongMaterial.js +1 -1
- package/src/materials/MeshPhysicalMaterial.js +90 -11
- package/src/materials/MeshStandardMaterial.js +1 -1
- package/src/materials/MeshToonMaterial.js +1 -1
- package/src/materials/nodes/Line2NodeMaterial.js +32 -10
- package/src/materials/nodes/MeshLambertNodeMaterial.js +13 -0
- package/src/materials/nodes/MeshPhongNodeMaterial.js +13 -0
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +40 -5
- package/src/materials/nodes/MeshToonNodeMaterial.js +13 -0
- package/src/materials/nodes/NodeMaterial.js +36 -16
- package/src/materials/nodes/NodeMaterialInstance.js +193 -0
- package/src/materials/nodes/NodeMaterials.js +1 -0
- package/src/materials/nodes/PointsNodeMaterial.js +1 -1
- package/src/materials/nodes/SpriteNodeMaterial.js +3 -3
- package/src/materials/nodes/manager/NodeMaterialObserver.js +191 -22
- package/src/math/Box3.js +2 -2
- package/src/math/Color.js +8 -8
- package/src/math/ColorManagement.js +2 -21
- package/src/math/FrustumArray.js +12 -0
- package/src/math/Interpolant.js +1 -1
- package/src/math/Line3.js +2 -4
- package/src/math/MathUtils.js +33 -46
- package/src/math/Matrix2.js +1 -1
- package/src/math/Matrix3.js +1 -1
- package/src/math/Matrix4.js +1 -1
- package/src/math/Triangle.js +2 -1
- package/src/math/Vector2.js +1 -1
- package/src/math/Vector3.js +1 -1
- package/src/math/Vector4.js +1 -1
- package/src/nodes/Nodes.js +1 -0
- package/src/nodes/TSL.js +2 -0
- package/src/nodes/accessors/Arrays.js +1 -1
- package/src/nodes/accessors/Batch.js +29 -23
- package/src/nodes/accessors/BufferAttributeNode.js +21 -1
- package/src/nodes/accessors/BuiltinNode.js +6 -0
- package/src/nodes/accessors/Camera.js +100 -93
- package/src/nodes/accessors/ClippingNode.js +17 -6
- package/src/nodes/accessors/CubeTextureNode.js +12 -24
- package/src/nodes/accessors/Instance.js +198 -160
- package/src/nodes/accessors/Lights.js +19 -6
- package/src/nodes/accessors/MaterialNode.js +33 -4
- package/src/nodes/accessors/Morph.js +81 -22
- package/src/nodes/accessors/Normal.js +0 -42
- package/src/nodes/accessors/Object3DNode.js +6 -0
- package/src/nodes/accessors/PointUVNode.js +6 -0
- package/src/nodes/accessors/ReferenceAttributeNode.js +279 -0
- package/src/nodes/accessors/ReferenceBaseNode.js +6 -0
- package/src/nodes/accessors/ReferenceNode.js +6 -0
- package/src/nodes/accessors/Skinning.js +57 -52
- package/src/nodes/accessors/StorageBufferNode.js +3 -12
- package/src/nodes/accessors/TextureBicubic.js +30 -27
- package/src/nodes/accessors/TextureNode.js +164 -78
- package/src/nodes/accessors/TextureSizeNode.js +6 -0
- package/src/nodes/accessors/UniformArrayNode.js +8 -15
- package/src/nodes/accessors/VelocityNode.js +13 -8
- package/src/nodes/code/CodeNode.js +6 -0
- package/src/nodes/code/ExpressionNode.js +6 -0
- package/src/nodes/code/FunctionCallNode.js +3 -3
- package/src/nodes/code/FunctionNode.js +15 -13
- package/src/nodes/core/ArrayNode.js +3 -3
- package/src/nodes/core/AssignNode.js +10 -9
- package/src/nodes/core/AttributeNode.js +39 -0
- package/src/nodes/core/BypassNode.js +6 -0
- package/src/nodes/core/ConstNode.js +31 -1
- package/src/nodes/core/ContextNode.js +11 -6
- package/src/nodes/core/IndexNode.js +6 -0
- package/src/nodes/core/InputNode.js +6 -0
- package/src/nodes/core/InspectorNode.js +17 -31
- package/src/nodes/core/IsolateNode.js +8 -0
- package/src/nodes/core/Node.js +367 -67
- package/src/nodes/core/NodeBuilder.js +664 -222
- package/src/nodes/core/NodeUtils.js +25 -0
- package/src/nodes/core/NodeVar.js +10 -1
- package/src/nodes/core/OutputStructNode.js +6 -0
- package/src/nodes/core/OverrideContextNode.js +38 -37
- package/src/nodes/core/PropertyNode.js +14 -0
- package/src/nodes/core/StackNode.js +33 -21
- package/src/nodes/core/StructNode.js +6 -0
- package/src/nodes/core/StructTypeNode.js +6 -0
- package/src/nodes/core/SubBuildNode.js +8 -0
- package/src/nodes/core/TempNode.js +10 -35
- package/src/nodes/core/UniformGroupNode.js +6 -0
- package/src/nodes/core/VarNode.js +43 -135
- package/src/nodes/core/VaryingNode.js +33 -2
- package/src/nodes/display/BlendModes.js +5 -40
- package/src/nodes/display/BumpMapNode.js +17 -7
- package/src/nodes/display/ColorAdjustment.js +22 -10
- package/src/nodes/display/ColorSpaceFunctions.js +2 -14
- package/src/nodes/display/ColorSpaceNode.js +3 -3
- package/src/nodes/display/FrontFacingNode.js +6 -0
- package/src/nodes/display/NormalMapNode.js +3 -3
- package/src/nodes/display/PassNode.js +75 -16
- package/src/nodes/display/RenderOutputNode.js +22 -5
- package/src/nodes/display/ScreenNode.js +6 -0
- package/src/nodes/display/ToneMappingFunctions.js +9 -51
- package/src/nodes/display/ToneMappingNode.js +3 -3
- package/src/nodes/display/ToonOutlinePassNode.js +66 -2
- package/src/nodes/display/ViewportDepthNode.js +34 -4
- package/src/nodes/functions/BSDF/BRDF_EON.js +65 -0
- package/src/nodes/functions/BSDF/BRDF_GGX.js +5 -3
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +2 -16
- package/src/nodes/functions/BSDF/D_GGX.js +1 -8
- package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +7 -10
- package/src/nodes/functions/BSDF/LTC.js +20 -47
- package/src/nodes/functions/BSDF/Schlick_to_F0.js +1 -9
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +1 -9
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +10 -13
- package/src/nodes/functions/PhysicalLightingModel.js +84 -51
- package/src/nodes/functions/VolumetricLightingModel.js +1 -1
- package/src/nodes/functions/material/getAlphaHashThreshold.js +3 -9
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +10 -11
- package/src/nodes/functions/material/getRoughness.js +3 -1
- package/src/nodes/geometry/RangeNode.js +52 -69
- package/src/nodes/gpgpu/AtomicFunctionNode.js +11 -6
- package/src/nodes/gpgpu/BarrierNode.js +6 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +6 -0
- package/src/nodes/gpgpu/ComputeNode.js +6 -0
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +38 -29
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +6 -0
- package/src/nodes/lighting/AnalyticLightNode.js +7 -14
- package/src/nodes/lighting/BasicEnvironmentNode.js +5 -1
- package/src/nodes/lighting/EnvironmentNode.js +58 -8
- package/src/nodes/lighting/IESSpotLightNode.js +19 -4
- package/src/nodes/lighting/LightProbeNode.js +2 -1
- package/src/nodes/lighting/LightUtils.js +2 -2
- package/src/nodes/lighting/LightingNode.js +6 -0
- package/src/nodes/lighting/LightsNode.js +26 -32
- package/src/nodes/lighting/PointShadowNode.js +92 -48
- package/src/nodes/lighting/ProjectorLightNode.js +1 -1
- package/src/nodes/lighting/RectAreaLightNode.js +13 -14
- package/src/nodes/lighting/ShadowBaseNode.js +9 -17
- package/src/nodes/lighting/ShadowFilterNode.js +26 -3
- package/src/nodes/lighting/ShadowNode.js +13 -11
- package/src/nodes/materialx/MaterialXColor.js +2 -14
- package/src/nodes/materialx/MaterialXColorTransform.js +1 -7
- package/src/nodes/materialx/MaterialXNodes.js +8 -11
- package/src/nodes/materialx/MaterialXNoise.js +195 -454
- package/src/nodes/math/BitcastNode.js +5 -5
- package/src/nodes/math/BitcountNode.js +18 -46
- package/src/nodes/math/ConditionalNode.js +92 -22
- package/src/nodes/math/Hash.js +1 -1
- package/src/nodes/math/MathNode.js +86 -64
- package/src/nodes/math/MathUtils.js +2 -2
- package/src/nodes/math/OperatorNode.js +42 -59
- package/src/nodes/math/PackFloatNode.js +9 -9
- package/src/nodes/math/Packed4x8IntegerNode.js +20 -52
- package/src/nodes/math/TriNoise3D.js +3 -23
- package/src/nodes/math/UnpackFloatNode.js +9 -9
- package/src/nodes/pmrem/PMREMNode.js +38 -75
- package/src/nodes/pmrem/PMREMUtils.js +108 -272
- package/src/nodes/procedural/Checker.js +1 -1
- package/src/nodes/tsl/TSLCore.js +199 -74
- package/src/nodes/utils/ArrayElementNode.js +19 -1
- package/src/nodes/utils/CubeMapNode.js +3 -3
- package/src/nodes/utils/DebugNode.js +2 -2
- package/src/nodes/utils/EventNode.js +6 -0
- package/src/nodes/utils/FlipNode.js +3 -3
- package/src/nodes/utils/FunctionOverloadingNode.js +7 -1
- package/src/nodes/utils/JoinNode.js +3 -3
- package/src/nodes/utils/LoopNode.js +14 -9
- package/src/nodes/utils/MemberNode.js +18 -0
- package/src/nodes/utils/PostProcessingUtils.js +20 -25
- package/src/nodes/utils/RTTNode.js +2 -0
- package/src/nodes/utils/ReflectorNode.js +24 -0
- package/src/nodes/utils/RotateNode.js +3 -3
- package/src/nodes/utils/SampleNode.js +6 -0
- package/src/nodes/utils/SetNode.js +3 -3
- package/src/nodes/utils/SplitNode.js +6 -0
- package/src/nodes/utils/UVUtils.js +2 -2
- package/src/objects/BatchedMesh.js +146 -15
- package/src/objects/InstancedMesh.js +12 -4
- package/src/objects/Line.js +20 -0
- package/src/objects/Mesh.js +8 -0
- package/src/objects/Points.js +20 -0
- package/src/objects/Skeleton.js +26 -0
- package/src/objects/SkinnedMesh.js +3 -3
- package/src/objects/Sprite.js +10 -0
- package/src/renderers/WebGLRenderer.js +104 -70
- package/src/renderers/common/Animation.js +5 -1
- package/src/renderers/common/Attributes.js +67 -57
- package/src/renderers/common/Backend.js +78 -3
- package/src/renderers/common/BindGroup.js +11 -0
- package/src/renderers/common/Binding.js +0 -11
- package/src/renderers/common/Bindings.js +116 -10
- package/src/renderers/common/Buffer.js +1 -1
- package/src/renderers/common/ClippingContext.js +12 -1
- package/src/renderers/common/ComputePipeline.js +17 -1
- package/src/renderers/common/DirectRenderPipeline.js +7 -3
- package/src/renderers/common/Geometries.js +170 -132
- package/src/renderers/common/Info.js +1 -1
- package/src/renderers/common/InspectorBase.js +5 -5
- package/src/renderers/common/Lighting.js +59 -0
- package/src/renderers/common/Pipelines.js +26 -12
- package/src/renderers/common/ProgrammableStage.js +1 -17
- package/src/renderers/common/RenderContext.js +21 -0
- package/src/renderers/common/RenderContexts.js +13 -4
- package/src/renderers/common/RenderObject.js +111 -35
- package/src/renderers/common/RenderObjects.js +37 -19
- package/src/renderers/common/Renderer.js +537 -295
- package/src/renderers/common/RendererUtils.js +15 -0
- package/src/renderers/common/StandardDrawingPipeline.js +343 -0
- package/src/renderers/common/Storage3DTexture.js +11 -0
- package/src/renderers/common/StorageArrayTexture.js +10 -0
- package/src/renderers/common/StorageTexture.js +0 -9
- package/src/renderers/common/Textures.js +144 -37
- package/src/renderers/common/UniformsGroup.js +19 -0
- package/src/renderers/common/XRManager.js +10 -91
- package/src/renderers/common/extras/PMREMGenerator.js +298 -576
- package/src/renderers/common/nodes/NodeBuilderState.js +7 -5
- package/src/renderers/common/nodes/NodeLibrary.js +11 -35
- package/src/renderers/common/nodes/NodeManager.js +80 -31
- package/src/renderers/common/nodes/NodeSampledTexture.js +14 -0
- package/src/renderers/common/nodes/NodeSampler.js +14 -0
- package/src/renderers/common/nodes/NodeStorageBuffer.js +1 -1
- package/src/renderers/common/nodes/NodeUniformBuffer.js +1 -14
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +13 -4
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +8 -8
- package/src/renderers/shaders/ShaderChunk/lightprobes_pars_fragment.glsl.js +23 -11
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +21 -2
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +18 -2
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +104 -7
- package/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js +11 -2
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +36 -20
- package/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js +5 -0
- package/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js +5 -0
- package/src/renderers/shaders/ShaderChunk.js +0 -2
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +4 -18
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +8 -1
- package/src/renderers/shaders/ShaderLib.js +3 -0
- package/src/renderers/shaders/UniformsLib.js +4 -5
- package/src/renderers/webgl/WebGLBackground.js +3 -3
- package/src/renderers/webgl/WebGLBindingStates.js +4 -2
- package/src/renderers/webgl/WebGLCapabilities.js +7 -1
- package/src/renderers/webgl/WebGLEnvironments.js +2 -2
- package/src/renderers/webgl/WebGLGeometries.js +42 -14
- package/src/renderers/webgl/WebGLMaterials.js +15 -2
- package/src/renderers/webgl/WebGLOutput.js +37 -1
- package/src/renderers/webgl/WebGLProgram.js +13 -54
- package/src/renderers/webgl/WebGLPrograms.js +22 -8
- package/src/renderers/webgl/WebGLRenderStates.js +11 -8
- package/src/renderers/webgl/WebGLShadowMap.js +6 -4
- package/src/renderers/webgl/WebGLState.js +10 -6
- package/src/renderers/webgl/WebGLTextures.js +129 -77
- package/src/renderers/webgl/WebGLUniforms.js +44 -6
- package/src/renderers/webgl/WebGLUniformsGroups.js +75 -69
- package/src/renderers/webgl-fallback/WebGLBackend.js +206 -278
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +154 -20
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +45 -42
- package/src/renderers/webgl-fallback/utils/WebGLState.js +29 -4
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +129 -49
- package/src/renderers/webgl-fallback/utils/WebGLVertexArrayUtils.js +346 -0
- package/src/renderers/webgpu/WebGPUBackend.js +140 -82
- package/src/renderers/webgpu/WebGPURenderer.js +1 -1
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +10 -10
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +10 -10
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +135 -60
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +128 -55
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +15 -12
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +55 -19
- package/src/renderers/webgpu/utils/WebGPUUtils.js +20 -3
- package/src/renderers/webxr/WebXRController.js +3 -3
- package/src/renderers/webxr/WebXRManager.js +5 -90
- package/src/scenes/Scene.js +4 -4
- package/src/textures/CompressedTexture.js +2 -2
- package/src/textures/DepthTexture.js +2 -2
- package/src/textures/FramebufferTexture.js +11 -0
- package/src/textures/Texture.js +29 -1
- package/src/textures/TextureSource.js +1 -1
- package/src/upe.js +1 -1
- package/src/utils.js +4 -4
- package/examples/jsm/libs/surfaceNet.js +0 -201
- package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +0 -186
|
@@ -909,6 +909,11 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
909
909
|
|
|
910
910
|
if ( shaderStage === 'fragment' ) {
|
|
911
911
|
|
|
912
|
+
// Unfilterable textures have no sampler binding. Use the same texel lookup as regular
|
|
913
|
+
// sampling, preserving nearest filtering, wrapping and offsets.
|
|
914
|
+
|
|
915
|
+
if ( this.isUnfilterable( texture ) ) return this.generateTexture( texture, textureProperty, uvSnippet, depthSnippet, offsetSnippet, shaderStage );
|
|
916
|
+
|
|
912
917
|
if ( depthSnippet ) {
|
|
913
918
|
|
|
914
919
|
if ( offsetSnippet ) {
|
|
@@ -997,6 +1002,42 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
997
1002
|
*/
|
|
998
1003
|
generateTextureGather( texture, textureProperty, uvSnippet, gatherSnippet, depthSnippet, offsetSnippet ) {
|
|
999
1004
|
|
|
1005
|
+
const { primarySamples } = this.renderer.backend.utils.getTextureSampleData( texture );
|
|
1006
|
+
|
|
1007
|
+
if ( primarySamples > 1 ) {
|
|
1008
|
+
|
|
1009
|
+
// textureGather() has no overload for multisampled textures (e.g. the depth
|
|
1010
|
+
// of a MSAA render target), so the four texels are fetched with textureLoad()
|
|
1011
|
+
|
|
1012
|
+
const textureDimension = this.generateTextureDimension( texture, textureProperty, '0u' );
|
|
1013
|
+
|
|
1014
|
+
let coordSnippet = `vec2<i32>( floor( ${ uvSnippet } * vec2<f32>( ${ textureDimension } ) - 0.5 ) )`;
|
|
1015
|
+
|
|
1016
|
+
if ( offsetSnippet ) {
|
|
1017
|
+
|
|
1018
|
+
coordSnippet = `${ coordSnippet } + ${ offsetSnippet }`;
|
|
1019
|
+
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
const coord = new VarNode( new ExpressionNode( coordSnippet, 'ivec2' ) ).build( this );
|
|
1023
|
+
const coordMax = `vec2<i32>( ${ textureDimension } ) - 1`;
|
|
1024
|
+
|
|
1025
|
+
const load = ( x, y ) => {
|
|
1026
|
+
|
|
1027
|
+
const snippet = this.generateTextureLoad( texture, textureProperty, `clamp( ${ coord } + vec2<i32>( ${ x }, ${ y } ), vec2<i32>( 0 ), ${ coordMax } )`, null, null, null );
|
|
1028
|
+
|
|
1029
|
+
return texture.isDepthTexture === true ? snippet : `${ snippet }[ ${ gatherSnippet } ]`;
|
|
1030
|
+
|
|
1031
|
+
};
|
|
1032
|
+
|
|
1033
|
+
// same texel order as textureGather()
|
|
1034
|
+
|
|
1035
|
+
const componentPrefix = this.getComponentTypeFromTexture( texture ).charAt( 0 );
|
|
1036
|
+
|
|
1037
|
+
return `vec4<${ componentPrefix }32>( ${ load( 0, 1 ) }, ${ load( 1, 1 ) }, ${ load( 1, 0 ) }, ${ load( 0, 0 ) } )`;
|
|
1038
|
+
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1000
1041
|
const componentSnippet = texture.isDepthTexture === true ? '' : `${gatherSnippet}, `;
|
|
1001
1042
|
|
|
1002
1043
|
if ( depthSnippet ) {
|
|
@@ -1179,12 +1220,6 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
1179
1220
|
|
|
1180
1221
|
} else if ( type === 'buffer' || type === 'storageBuffer' || type === 'indirectStorageBuffer' ) {
|
|
1181
1222
|
|
|
1182
|
-
if ( this.isCustomStruct( node ) ) {
|
|
1183
|
-
|
|
1184
|
-
return name;
|
|
1185
|
-
|
|
1186
|
-
}
|
|
1187
|
-
|
|
1188
1223
|
return name + '.value';
|
|
1189
1224
|
|
|
1190
1225
|
} else {
|
|
@@ -1199,6 +1234,31 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
1199
1234
|
|
|
1200
1235
|
}
|
|
1201
1236
|
|
|
1237
|
+
/**
|
|
1238
|
+
* Returns the identifier the given node declares in the shader. Buffers are
|
|
1239
|
+
* accessed via `name.value` but declare `name` in the module scope.
|
|
1240
|
+
*
|
|
1241
|
+
* @param {Object} node - The node.
|
|
1242
|
+
* @return {string} The declaration name.
|
|
1243
|
+
*/
|
|
1244
|
+
getDeclarationName( node ) {
|
|
1245
|
+
|
|
1246
|
+
if ( node.isNodeUniform === true ) {
|
|
1247
|
+
|
|
1248
|
+
const type = node.type;
|
|
1249
|
+
|
|
1250
|
+
if ( type === 'buffer' || type === 'storageBuffer' || type === 'indirectStorageBuffer' ) {
|
|
1251
|
+
|
|
1252
|
+
return node.name;
|
|
1253
|
+
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
return super.getDeclarationName( node );
|
|
1259
|
+
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1202
1262
|
/**
|
|
1203
1263
|
* Returns whether the given name is a reserved keyword of WGSL.
|
|
1204
1264
|
*
|
|
@@ -1272,6 +1332,14 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
1272
1332
|
|
|
1273
1333
|
}
|
|
1274
1334
|
|
|
1335
|
+
// Honor read-write for storage texture in the fragment stage.
|
|
1336
|
+
|
|
1337
|
+
if ( shaderStage === 'fragment' && node.isStorageTextureNode === true && node.access === NodeAccess.READ_WRITE ) {
|
|
1338
|
+
|
|
1339
|
+
return NodeAccess.READ_WRITE;
|
|
1340
|
+
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1275
1343
|
return NodeAccess.READ_ONLY;
|
|
1276
1344
|
|
|
1277
1345
|
}
|
|
@@ -1375,28 +1443,15 @@ class WGSLNodeBuilder extends NodeBuilder {
|
|
|
1375
1443
|
|
|
1376
1444
|
} else if ( type === 'buffer' || type === 'storageBuffer' || type === 'indirectStorageBuffer' ) {
|
|
1377
1445
|
|
|
1378
|
-
const
|
|
1379
|
-
|
|
1380
|
-
let buffer = sharedData.buffer;
|
|
1381
|
-
|
|
1382
|
-
if ( buffer === undefined ) {
|
|
1383
|
-
|
|
1384
|
-
const bufferClass = type === 'buffer' ? NodeUniformBuffer : NodeStorageBuffer;
|
|
1385
|
-
|
|
1386
|
-
buffer = new bufferClass( node, group );
|
|
1387
|
-
|
|
1388
|
-
sharedData.buffer = buffer;
|
|
1389
|
-
|
|
1390
|
-
}
|
|
1446
|
+
const bufferClass = type === 'buffer' ? NodeUniformBuffer : NodeStorageBuffer;
|
|
1391
1447
|
|
|
1392
|
-
|
|
1448
|
+
const buffer = new bufferClass( node, group );
|
|
1449
|
+
buffer.setVisibility( gpuShaderStageLib[ shaderStage ] );
|
|
1393
1450
|
|
|
1394
1451
|
bindings.push( buffer );
|
|
1395
1452
|
|
|
1396
1453
|
uniformGPU = buffer;
|
|
1397
1454
|
|
|
1398
|
-
uniformNode.name = name ? name : 'NodeBuffer_' + uniformNode.id;
|
|
1399
|
-
|
|
1400
1455
|
} else {
|
|
1401
1456
|
|
|
1402
1457
|
let uniformsGroup = this.uniformGroups[ groupName ];
|
|
@@ -1712,20 +1767,17 @@ ${ flowData.code }
|
|
|
1712
1767
|
}
|
|
1713
1768
|
|
|
1714
1769
|
/**
|
|
1715
|
-
* Enables
|
|
1770
|
+
* Enables subgroups.
|
|
1716
1771
|
*/
|
|
1717
1772
|
enableSubGroups() {
|
|
1718
1773
|
|
|
1719
|
-
this.
|
|
1774
|
+
if ( this.renderer.hasFeature( 'subgroups' ) === false ) {
|
|
1720
1775
|
|
|
1721
|
-
|
|
1776
|
+
error( 'WGSLNodeBuilder: The \'subgroups\' feature is not supported by the current device.' );
|
|
1722
1777
|
|
|
1723
|
-
|
|
1724
|
-
* Enables the 'subgroups-f16' directive.
|
|
1725
|
-
*/
|
|
1726
|
-
enableSubgroupsF16() {
|
|
1778
|
+
}
|
|
1727
1779
|
|
|
1728
|
-
this.enableDirective( 'subgroups
|
|
1780
|
+
this.enableDirective( 'subgroups' );
|
|
1729
1781
|
|
|
1730
1782
|
}
|
|
1731
1783
|
|
|
@@ -1739,7 +1791,7 @@ ${ flowData.code }
|
|
|
1739
1791
|
}
|
|
1740
1792
|
|
|
1741
1793
|
/**
|
|
1742
|
-
* Enables
|
|
1794
|
+
* Enables 16 bit floats.
|
|
1743
1795
|
*/
|
|
1744
1796
|
enableShaderF16() {
|
|
1745
1797
|
|
|
@@ -1748,7 +1800,7 @@ ${ flowData.code }
|
|
|
1748
1800
|
}
|
|
1749
1801
|
|
|
1750
1802
|
/**
|
|
1751
|
-
* Enables
|
|
1803
|
+
* Enables dual source blending.
|
|
1752
1804
|
*/
|
|
1753
1805
|
enableDualSourceBlending() {
|
|
1754
1806
|
|
|
@@ -1783,7 +1835,9 @@ ${ flowData.code }
|
|
|
1783
1835
|
|
|
1784
1836
|
for ( const { name, property, type } of builtins.values() ) {
|
|
1785
1837
|
|
|
1786
|
-
|
|
1838
|
+
const invariant = this.context.invariant === true && shaderStage === 'vertex' && name === 'position' ? '@invariant ' : '';
|
|
1839
|
+
|
|
1840
|
+
snippets.push( `${ invariant }@builtin( ${name} ) ${property} : ${type}` );
|
|
1787
1841
|
|
|
1788
1842
|
}
|
|
1789
1843
|
|
|
@@ -2001,6 +2055,48 @@ ${ flowData.code }
|
|
|
2001
2055
|
|
|
2002
2056
|
}
|
|
2003
2057
|
|
|
2058
|
+
/**
|
|
2059
|
+
* Returns a single const variable statement as a WGSL string for the given variable type and name.
|
|
2060
|
+
*
|
|
2061
|
+
* @param {string} type - The variable's type.
|
|
2062
|
+
* @param {string} name - The variable's name.
|
|
2063
|
+
* @param {?number} [count=null] - The array length.
|
|
2064
|
+
* @return {string} The WGSL snippet that defines a const variable.
|
|
2065
|
+
*/
|
|
2066
|
+
generateConstStatement( type, name/*, count = null*/ ) {
|
|
2067
|
+
|
|
2068
|
+
return `const ${ name }`;
|
|
2069
|
+
|
|
2070
|
+
}
|
|
2071
|
+
|
|
2072
|
+
/**
|
|
2073
|
+
* Returns a single variable statement as a WGSL string for the given variable type and name.
|
|
2074
|
+
*
|
|
2075
|
+
* @param {string} type - The variable's type.
|
|
2076
|
+
* @param {string} name - The variable's name.
|
|
2077
|
+
* @param {?number} [count=null] - The array length.
|
|
2078
|
+
* @return {string} The WGSL snippet that defines a variable.
|
|
2079
|
+
*/
|
|
2080
|
+
generateVarStatement( type, name, count = null ) {
|
|
2081
|
+
|
|
2082
|
+
return this.getVar( type, name, count );
|
|
2083
|
+
|
|
2084
|
+
}
|
|
2085
|
+
|
|
2086
|
+
/**
|
|
2087
|
+
* Returns a runtime read-only variable statement as a WGSL string.
|
|
2088
|
+
*
|
|
2089
|
+
* @param {string} type - The variable's type.
|
|
2090
|
+
* @param {string} name - The variable's name.
|
|
2091
|
+
* @param {?number} [count=null] - The array length.
|
|
2092
|
+
* @return {string} The WGSL snippet that defines a let variable.
|
|
2093
|
+
*/
|
|
2094
|
+
generateLetStatement( type, name/*, count = null*/ ) {
|
|
2095
|
+
|
|
2096
|
+
return `let ${ name }`;
|
|
2097
|
+
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2004
2100
|
/**
|
|
2005
2101
|
* Returns the variables of the given shader stage as a WGSL string.
|
|
2006
2102
|
*
|
|
@@ -2101,21 +2197,6 @@ ${ flowData.code }
|
|
|
2101
2197
|
|
|
2102
2198
|
}
|
|
2103
2199
|
|
|
2104
|
-
isCustomStruct( nodeUniform ) {
|
|
2105
|
-
|
|
2106
|
-
const attribute = nodeUniform.value;
|
|
2107
|
-
const bufferNode = nodeUniform.node;
|
|
2108
|
-
|
|
2109
|
-
const isAttributeStructType = ( attribute.isBufferAttribute || attribute.isInstancedBufferAttribute ) && bufferNode.structTypeNode !== null;
|
|
2110
|
-
|
|
2111
|
-
const isStructArray =
|
|
2112
|
-
( bufferNode.value && bufferNode.value.array ) &&
|
|
2113
|
-
( typeof bufferNode.value.itemSize === 'number' && bufferNode.value.array.length > bufferNode.value.itemSize );
|
|
2114
|
-
|
|
2115
|
-
return isAttributeStructType && ! isStructArray;
|
|
2116
|
-
|
|
2117
|
-
}
|
|
2118
|
-
|
|
2119
2200
|
/**
|
|
2120
2201
|
* Returns the uniforms of the given shader stage as a WGSL string.
|
|
2121
2202
|
*
|
|
@@ -2231,19 +2312,10 @@ ${ flowData.code }
|
|
|
2231
2312
|
const bufferCount = bufferNode.bufferCount;
|
|
2232
2313
|
const bufferCountSnippet = bufferCount > 0 && uniform.type === 'buffer' ? ', ' + bufferCount : '';
|
|
2233
2314
|
const bufferAccessMode = bufferNode.isStorageBufferNode ? `storage, ${ this.getStorageAccess( bufferNode, shaderStage ) }` : 'uniform';
|
|
2315
|
+
const bufferTypeSnippet = bufferNode.isAtomic ? `atomic<${ bufferType }>` : `${ bufferType }`;
|
|
2316
|
+
const bufferSnippet = `\tvalue : array< ${ bufferTypeSnippet }${ bufferCountSnippet } >`;
|
|
2234
2317
|
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
bufferSnippets.push( `@binding( ${ uniformIndexes.binding ++ } ) @group( ${ uniformIndexes.group } ) var<${ bufferAccessMode }> ${ uniform.name } : ${ bufferType };` );
|
|
2238
|
-
|
|
2239
|
-
} else {
|
|
2240
|
-
|
|
2241
|
-
const bufferTypeSnippet = bufferNode.isAtomic ? `atomic<${ bufferType }>` : `${ bufferType }`;
|
|
2242
|
-
const bufferSnippet = `\tvalue : array< ${ bufferTypeSnippet }${ bufferCountSnippet } >`;
|
|
2243
|
-
|
|
2244
|
-
bufferSnippets.push( this._getWGSLStructBinding( uniform.name, bufferSnippet, bufferAccessMode, uniformIndexes.binding ++, uniformIndexes.group ) );
|
|
2245
|
-
|
|
2246
|
-
}
|
|
2318
|
+
bufferSnippets.push( this._getWGSLStructBinding( uniform.name, bufferSnippet, bufferAccessMode, uniformIndexes.binding ++, uniformIndexes.group ) );
|
|
2247
2319
|
|
|
2248
2320
|
} else {
|
|
2249
2321
|
|
|
@@ -2639,6 +2711,9 @@ fn main( ${shaderData.attributes} ) -> VaryingsStruct {
|
|
|
2639
2711
|
// global
|
|
2640
2712
|
${ diagnostics }
|
|
2641
2713
|
|
|
2714
|
+
// directives
|
|
2715
|
+
${shaderData.directives}
|
|
2716
|
+
|
|
2642
2717
|
// structs
|
|
2643
2718
|
${shaderData.structs}
|
|
2644
2719
|
|
|
@@ -35,6 +35,43 @@ const typeArraysToVertexFormatPrefixForItemSize1 = new Map( [
|
|
|
35
35
|
[ Float32Array, 'float32' ]
|
|
36
36
|
] );
|
|
37
37
|
|
|
38
|
+
const _tail = new Uint8Array( 4 );
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Writes a range of a typed array into the given GPU buffer. `writeBuffer()` requires
|
|
42
|
+
* the offset and size to be multiples of 4 bytes, so the range is expanded to the
|
|
43
|
+
* element boundaries of the surrounding 4-byte word. The function assumes
|
|
44
|
+
* that the buffer is already properly sized to a multiple of 4 bytes.
|
|
45
|
+
*
|
|
46
|
+
* @private
|
|
47
|
+
* @function
|
|
48
|
+
* @param {GPUDevice} device - The GPU device calling `writeBuffer()`.
|
|
49
|
+
* @param {GPUBuffer} buffer - The GPU buffer, properly sized to a multiple of 4 bytes.
|
|
50
|
+
* @param {TypedArray} array - The source array.
|
|
51
|
+
* @param {number} start - The index of the first element to write.
|
|
52
|
+
* @param {number} count - The number of elements to write.
|
|
53
|
+
*/
|
|
54
|
+
function writeBufferAligned( device, buffer, array, start, count ) {
|
|
55
|
+
|
|
56
|
+
const bytes = new Uint8Array( array.buffer, array.byteOffset, array.byteLength );
|
|
57
|
+
|
|
58
|
+
const byteStart = Math.floor( start * array.BYTES_PER_ELEMENT / 4 ) * 4;
|
|
59
|
+
const byteEnd = ( start + count ) * array.BYTES_PER_ELEMENT;
|
|
60
|
+
const alignedEnd = Math.floor( byteEnd / 4 ) * 4;
|
|
61
|
+
|
|
62
|
+
if ( alignedEnd > byteStart ) device.queue.writeBuffer( buffer, byteStart, bytes, byteStart, alignedEnd - byteStart );
|
|
63
|
+
|
|
64
|
+
if ( byteEnd > alignedEnd ) {
|
|
65
|
+
|
|
66
|
+
_tail.fill( 0 );
|
|
67
|
+
_tail.set( bytes.subarray( alignedEnd, alignedEnd + 4 ) );
|
|
68
|
+
|
|
69
|
+
device.queue.writeBuffer( buffer, alignedEnd, _tail );
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
}
|
|
74
|
+
|
|
38
75
|
/**
|
|
39
76
|
* A WebGPU backend utility module for managing shader attributes.
|
|
40
77
|
*
|
|
@@ -66,9 +103,9 @@ class WebGPUAttributeUtils {
|
|
|
66
103
|
*/
|
|
67
104
|
createAttribute( attribute, usage ) {
|
|
68
105
|
|
|
69
|
-
const bufferAttribute = this._getBufferAttribute( attribute );
|
|
70
|
-
|
|
71
106
|
const backend = this.backend;
|
|
107
|
+
|
|
108
|
+
const bufferAttribute = backend.getBufferAttribute( attribute );
|
|
72
109
|
const bufferData = backend.get( bufferAttribute );
|
|
73
110
|
|
|
74
111
|
let buffer = bufferData.buffer;
|
|
@@ -79,7 +116,9 @@ class WebGPUAttributeUtils {
|
|
|
79
116
|
|
|
80
117
|
let array = bufferAttribute.array;
|
|
81
118
|
|
|
82
|
-
//
|
|
119
|
+
// WGSL has no 8 or 16 bit integer types and vertex strides must be a multiple of 4 bytes,
|
|
120
|
+
// so widen these integers to 32 bit. index buffers only need uint16 unless used as storage
|
|
121
|
+
|
|
83
122
|
if ( attribute.normalized === false && attribute.isInterleavedBufferAttribute !== true ) {
|
|
84
123
|
|
|
85
124
|
if ( array.constructor === Int16Array || array.constructor === Int8Array ) {
|
|
@@ -88,13 +127,24 @@ class WebGPUAttributeUtils {
|
|
|
88
127
|
|
|
89
128
|
} else if ( array.constructor === Uint16Array || array.constructor === Uint8Array ) {
|
|
90
129
|
|
|
91
|
-
|
|
130
|
+
const isIndexBuffer = ( usage & GPUBufferUsage.INDEX );
|
|
131
|
+
const isStorageBuffer = ( usage & GPUBufferUsage.STORAGE );
|
|
132
|
+
|
|
133
|
+
const UintConstructor = ( isIndexBuffer && ! isStorageBuffer ) ? Uint16Array : Uint32Array;
|
|
92
134
|
|
|
93
|
-
if (
|
|
135
|
+
if ( array.constructor !== UintConstructor ) {
|
|
136
|
+
|
|
137
|
+
array = new UintConstructor( array );
|
|
138
|
+
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// widened indices need the uint32 primitive restart value
|
|
142
|
+
|
|
143
|
+
if ( isIndexBuffer && isStorageBuffer ) {
|
|
94
144
|
|
|
95
145
|
for ( let i = 0; i < array.length; i ++ ) {
|
|
96
146
|
|
|
97
|
-
if ( array[ i ] === 0xffff ) array[ i ] = 0xffffffff;
|
|
147
|
+
if ( array[ i ] === 0xffff ) array[ i ] = 0xffffffff;
|
|
98
148
|
|
|
99
149
|
}
|
|
100
150
|
|
|
@@ -184,11 +234,10 @@ class WebGPUAttributeUtils {
|
|
|
184
234
|
*/
|
|
185
235
|
updateAttribute( attribute ) {
|
|
186
236
|
|
|
187
|
-
const bufferAttribute = this._getBufferAttribute( attribute );
|
|
188
|
-
|
|
189
237
|
const backend = this.backend;
|
|
190
238
|
const device = backend.device;
|
|
191
239
|
|
|
240
|
+
const bufferAttribute = backend.getBufferAttribute( attribute );
|
|
192
241
|
const bufferData = backend.get( bufferAttribute );
|
|
193
242
|
const buffer = backend.get( bufferAttribute ).buffer;
|
|
194
243
|
|
|
@@ -222,16 +271,21 @@ class WebGPUAttributeUtils {
|
|
|
222
271
|
|
|
223
272
|
const updateRanges = bufferAttribute.updateRanges;
|
|
224
273
|
|
|
274
|
+
const needsAlignment = isTypedArray( array ) && array.BYTES_PER_ELEMENT < 4;
|
|
275
|
+
|
|
225
276
|
if ( updateRanges.length === 0 ) {
|
|
226
277
|
|
|
227
278
|
// Not using update ranges
|
|
228
279
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
0,
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
280
|
+
if ( needsAlignment ) {
|
|
281
|
+
|
|
282
|
+
writeBufferAligned( device, buffer, array, 0, array.length );
|
|
283
|
+
|
|
284
|
+
} else {
|
|
285
|
+
|
|
286
|
+
device.queue.writeBuffer( buffer, 0, array, 0 );
|
|
287
|
+
|
|
288
|
+
}
|
|
235
289
|
|
|
236
290
|
} else {
|
|
237
291
|
|
|
@@ -257,15 +311,17 @@ class WebGPUAttributeUtils {
|
|
|
257
311
|
|
|
258
312
|
}
|
|
259
313
|
|
|
260
|
-
|
|
314
|
+
if ( needsAlignment ) {
|
|
315
|
+
|
|
316
|
+
writeBufferAligned( device, buffer, array, dataOffset, size );
|
|
261
317
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
bufferOffset
|
|
265
|
-
|
|
266
|
-
dataOffset,
|
|
267
|
-
|
|
268
|
-
|
|
318
|
+
} else {
|
|
319
|
+
|
|
320
|
+
const bufferOffset = dataOffset * ( isTyped ? array.BYTES_PER_ELEMENT : 1 ); // bufferOffset is always in bytes
|
|
321
|
+
|
|
322
|
+
device.queue.writeBuffer( buffer, bufferOffset, array, dataOffset, size );
|
|
323
|
+
|
|
324
|
+
}
|
|
269
325
|
|
|
270
326
|
}
|
|
271
327
|
|
|
@@ -276,13 +332,13 @@ class WebGPUAttributeUtils {
|
|
|
276
332
|
}
|
|
277
333
|
|
|
278
334
|
/**
|
|
279
|
-
*
|
|
280
|
-
*
|
|
335
|
+
* Returns the vertex buffer layout data which are required
|
|
336
|
+
* when creating a render pipeline for the given render object.
|
|
281
337
|
*
|
|
282
338
|
* @param {RenderObject} renderObject - The render object.
|
|
283
339
|
* @return {Array<Object>} An array holding objects which describe the vertex buffer layout.
|
|
284
340
|
*/
|
|
285
|
-
|
|
341
|
+
getVertexBufferLayout( renderObject ) {
|
|
286
342
|
|
|
287
343
|
const attributes = renderObject.getAttributes();
|
|
288
344
|
const vertexBuffers = new Map();
|
|
@@ -291,7 +347,7 @@ class WebGPUAttributeUtils {
|
|
|
291
347
|
|
|
292
348
|
const geometryAttribute = attributes[ slot ];
|
|
293
349
|
const bytesPerElement = geometryAttribute.array.BYTES_PER_ELEMENT;
|
|
294
|
-
const bufferAttribute = this.
|
|
350
|
+
const bufferAttribute = this.backend.getBufferAttribute( geometryAttribute );
|
|
295
351
|
|
|
296
352
|
let vertexBufferLayout = vertexBuffers.get( bufferAttribute );
|
|
297
353
|
|
|
@@ -299,17 +355,19 @@ class WebGPUAttributeUtils {
|
|
|
299
355
|
|
|
300
356
|
let arrayStride, stepMode;
|
|
301
357
|
|
|
302
|
-
|
|
358
|
+
// the layout is defined by the buffer, interleaved attributes can also view a buffer attribute
|
|
303
359
|
|
|
304
|
-
|
|
305
|
-
|
|
360
|
+
if ( bufferAttribute.isInterleavedBuffer === true ) {
|
|
361
|
+
|
|
362
|
+
arrayStride = bufferAttribute.stride * bytesPerElement;
|
|
363
|
+
stepMode = bufferAttribute.isInstancedInterleavedBuffer ? GPUInputStepMode.Instance : GPUInputStepMode.Vertex;
|
|
306
364
|
|
|
307
365
|
} else {
|
|
308
366
|
|
|
309
|
-
arrayStride =
|
|
310
|
-
stepMode =
|
|
367
|
+
arrayStride = bufferAttribute.itemSize * bytesPerElement;
|
|
368
|
+
stepMode = bufferAttribute.isInstancedBufferAttribute ? GPUInputStepMode.Instance : GPUInputStepMode.Vertex;
|
|
311
369
|
|
|
312
|
-
if (
|
|
370
|
+
if ( bufferAttribute.itemSize > 1 && arrayStride % 4 !== 0 ) {
|
|
313
371
|
|
|
314
372
|
// packed attribute data are padded per vertex on upload
|
|
315
373
|
|
|
@@ -344,6 +402,35 @@ class WebGPUAttributeUtils {
|
|
|
344
402
|
|
|
345
403
|
}
|
|
346
404
|
|
|
405
|
+
/**
|
|
406
|
+
* Returns a cache key that represents the vertex buffer layout data
|
|
407
|
+
* of the given render object.
|
|
408
|
+
*
|
|
409
|
+
* @param {RenderObject} renderObject - The render object.
|
|
410
|
+
* @return {string} The cache key.
|
|
411
|
+
*/
|
|
412
|
+
getVertexBufferLayoutCacheKey( renderObject ) {
|
|
413
|
+
|
|
414
|
+
const vertexBufferLayout = this.getVertexBufferLayout( renderObject );
|
|
415
|
+
|
|
416
|
+
let cacheKey = '';
|
|
417
|
+
|
|
418
|
+
for ( const entry of vertexBufferLayout ) {
|
|
419
|
+
|
|
420
|
+
cacheKey += entry.arrayStride + ',' + entry.stepMode + ',';
|
|
421
|
+
|
|
422
|
+
for ( const attribute of entry.attributes ) {
|
|
423
|
+
|
|
424
|
+
cacheKey += attribute.shaderLocation + ',' + attribute.offset + ',' + attribute.format + ',';
|
|
425
|
+
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
return cacheKey;
|
|
431
|
+
|
|
432
|
+
}
|
|
433
|
+
|
|
347
434
|
/**
|
|
348
435
|
* Destroys the GPU buffer of the given buffer attribute.
|
|
349
436
|
*
|
|
@@ -352,11 +439,13 @@ class WebGPUAttributeUtils {
|
|
|
352
439
|
destroyAttribute( attribute ) {
|
|
353
440
|
|
|
354
441
|
const backend = this.backend;
|
|
355
|
-
|
|
442
|
+
|
|
443
|
+
const bufferAttribute = backend.getBufferAttribute( attribute );
|
|
444
|
+
const data = backend.get( bufferAttribute );
|
|
356
445
|
|
|
357
446
|
data.buffer.destroy();
|
|
358
447
|
|
|
359
|
-
backend.delete(
|
|
448
|
+
backend.delete( bufferAttribute );
|
|
360
449
|
|
|
361
450
|
}
|
|
362
451
|
|
|
@@ -367,10 +456,10 @@ class WebGPUAttributeUtils {
|
|
|
367
456
|
* new allocation.
|
|
368
457
|
*
|
|
369
458
|
* @async
|
|
370
|
-
* @param {BufferAttribute} attribute - The storage buffer attribute to read
|
|
371
|
-
* @param {
|
|
372
|
-
* @param {number} offset - The
|
|
373
|
-
* @param {
|
|
459
|
+
* @param {BufferAttribute} attribute - The storage buffer attribute to read from.
|
|
460
|
+
* @param {?(ReadbackBuffer|ArrayBuffer)} [target=null] - The readback buffer or array buffer that receives the data. If `null`, a new array buffer is returned.
|
|
461
|
+
* @param {number} [offset=0] - The byte offset to start reading from. Must be a multiple of 4.
|
|
462
|
+
* @param {number} [count=-1] - The number of bytes to read. Must be a multiple of 4, or `-1` to read to the end of the buffer.
|
|
374
463
|
* @return {Promise<ArrayBuffer|ReadbackBuffer>} A promise that resolves with the buffer data when the data are ready.
|
|
375
464
|
*/
|
|
376
465
|
async getArrayBufferAsync( attribute, target = null, offset = 0, count = - 1 ) {
|
|
@@ -378,7 +467,7 @@ class WebGPUAttributeUtils {
|
|
|
378
467
|
const backend = this.backend;
|
|
379
468
|
const device = backend.device;
|
|
380
469
|
|
|
381
|
-
const data = backend.get(
|
|
470
|
+
const data = backend.get( backend.getBufferAttribute( attribute ) );
|
|
382
471
|
const bufferGPU = data.buffer;
|
|
383
472
|
const byteLength = count === - 1 ? bufferGPU.size - offset : count;
|
|
384
473
|
|
|
@@ -552,22 +641,6 @@ class WebGPUAttributeUtils {
|
|
|
552
641
|
|
|
553
642
|
}
|
|
554
643
|
|
|
555
|
-
/**
|
|
556
|
-
* Utility method for handling interleaved buffer attributes correctly.
|
|
557
|
-
* To process them, their `InterleavedBuffer` is returned.
|
|
558
|
-
*
|
|
559
|
-
* @private
|
|
560
|
-
* @param {BufferAttribute} attribute - The attribute.
|
|
561
|
-
* @return {BufferAttribute|InterleavedBuffer}
|
|
562
|
-
*/
|
|
563
|
-
_getBufferAttribute( attribute ) {
|
|
564
|
-
|
|
565
|
-
if ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data;
|
|
566
|
-
|
|
567
|
-
return attribute;
|
|
568
|
-
|
|
569
|
-
}
|
|
570
|
-
|
|
571
644
|
}
|
|
572
645
|
|
|
573
646
|
export default WebGPUAttributeUtils;
|
|
@@ -378,7 +378,7 @@ class WebGPUBindingUtils {
|
|
|
378
378
|
|
|
379
379
|
if ( resourceGPU === undefined ) {
|
|
380
380
|
|
|
381
|
-
const aspectGPU = GPUTextureAspect.All;
|
|
381
|
+
const aspectGPU = binding.texture.isDepthTexture ? GPUTextureAspect.DepthOnly : GPUTextureAspect.All;
|
|
382
382
|
|
|
383
383
|
let dimensionViewGPU;
|
|
384
384
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
GPUFrontFace, GPUCullMode, GPUColorWriteFlags, GPUCompareFunction, GPUBlendFactor, GPUBlendOperation,
|
|
2
|
+
GPUFrontFace, GPUCullMode, GPUColorWriteFlags, GPUCompareFunction, GPUBlendFactor, GPUBlendOperation, GPUStencilOperation, GPUPrimitiveTopology
|
|
3
3
|
} from './WebGPUConstants.js';
|
|
4
4
|
|
|
5
5
|
import {
|
|
@@ -94,7 +94,7 @@ class WebGPUPipelineUtils {
|
|
|
94
94
|
|
|
95
95
|
// vertex buffers
|
|
96
96
|
|
|
97
|
-
const vertexBuffers = backend.attributeUtils.
|
|
97
|
+
const vertexBuffers = backend.attributeUtils.getVertexBufferLayout( renderObject );
|
|
98
98
|
|
|
99
99
|
// material blending
|
|
100
100
|
|
|
@@ -237,8 +237,8 @@ class WebGPUPipelineUtils {
|
|
|
237
237
|
|
|
238
238
|
if ( material.polygonOffset === true && ( primitiveState.topology === GPUPrimitiveTopology.TriangleList ) ) {
|
|
239
239
|
|
|
240
|
-
depthStencil.depthBias = material.polygonOffsetUnits;
|
|
241
|
-
depthStencil.depthBiasSlopeScale = material.polygonOffsetFactor;
|
|
240
|
+
depthStencil.depthBias = ( this.backend.parameters.reversedDepthBuffer ) ? - material.polygonOffsetUnits : material.polygonOffsetUnits;
|
|
241
|
+
depthStencil.depthBiasSlopeScale = ( this.backend.parameters.reversedDepthBuffer ) ? - material.polygonOffsetFactor : material.polygonOffsetFactor;
|
|
242
242
|
depthStencil.depthBiasClamp = 0; // three.js does not provide an API to configure this value
|
|
243
243
|
|
|
244
244
|
}
|
|
@@ -298,6 +298,10 @@ class WebGPUPipelineUtils {
|
|
|
298
298
|
|
|
299
299
|
_renderPipelineDescriptor.reset();
|
|
300
300
|
|
|
301
|
+
// Pop the error scope before awaiting the pipeline, so several pipelines
|
|
302
|
+
// can be created at the same time without mixing their error scopes.
|
|
303
|
+
const errorScopePromise = device.popErrorScope();
|
|
304
|
+
|
|
301
305
|
if ( pipelinePromise !== null ) {
|
|
302
306
|
|
|
303
307
|
try {
|
|
@@ -312,7 +316,7 @@ class WebGPUPipelineUtils {
|
|
|
312
316
|
|
|
313
317
|
}
|
|
314
318
|
|
|
315
|
-
const errorScope = await
|
|
319
|
+
const errorScope = await errorScopePromise;
|
|
316
320
|
|
|
317
321
|
if ( errorScope !== null || asyncError !== null ) {
|
|
318
322
|
|
|
@@ -455,6 +459,10 @@ class WebGPUPipelineUtils {
|
|
|
455
459
|
|
|
456
460
|
_computePipelineDescriptor.reset();
|
|
457
461
|
|
|
462
|
+
// Pop the error scope before awaiting the pipeline, so several pipelines
|
|
463
|
+
// can be created at the same time without mixing their error scopes.
|
|
464
|
+
const errorScopePromise = device.popErrorScope();
|
|
465
|
+
|
|
458
466
|
if ( pipelinePromise !== null ) {
|
|
459
467
|
|
|
460
468
|
try {
|
|
@@ -469,7 +477,7 @@ class WebGPUPipelineUtils {
|
|
|
469
477
|
|
|
470
478
|
}
|
|
471
479
|
|
|
472
|
-
const errorScope = await
|
|
480
|
+
const errorScope = await errorScopePromise;
|
|
473
481
|
|
|
474
482
|
if ( errorScope !== null || asyncError !== null ) {
|
|
475
483
|
|
|
@@ -902,12 +910,7 @@ class WebGPUPipelineUtils {
|
|
|
902
910
|
//
|
|
903
911
|
|
|
904
912
|
descriptor.topology = utils.getPrimitiveTopology( object, material );
|
|
905
|
-
|
|
906
|
-
if ( geometry.index !== null && object.isLine === true && object.isLineSegments !== true ) {
|
|
907
|
-
|
|
908
|
-
descriptor.stripIndexFormat = ( geometry.index.array instanceof Uint16Array ) ? GPUIndexFormat.Uint16 : GPUIndexFormat.Uint32;
|
|
909
|
-
|
|
910
|
-
}
|
|
913
|
+
descriptor.stripIndexFormat = utils.getStripIndexFormat( object, geometry );
|
|
911
914
|
|
|
912
915
|
//
|
|
913
916
|
|