@gnsx/three 0.185.15 → 0.186.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 +10 -82600
- package/build/three.core.js +1303 -728
- package/build/three.module.js +439 -338
- package/build/three.tsl.js +74 -44
- package/build/three.webgpu.js +6036 -2184
- package/build/three.webgpu.nodes.js +6020 -2184
- package/examples/jsm/Addons.js +6 -6
- package/examples/jsm/controls/ArcballControls.js +1 -1
- package/examples/jsm/controls/FirstPersonControls.js +44 -20
- package/examples/jsm/controls/OrbitControls.js +9 -0
- package/examples/jsm/controls/TrackballControls.js +109 -4
- package/examples/jsm/csm/CSMShadowNode.js +13 -0
- package/examples/jsm/exporters/GLTFExporter.js +23 -7
- package/examples/jsm/exporters/USDZExporter.js +2 -2
- package/examples/jsm/generators/CityGenerator.js +377 -45
- package/examples/jsm/generators/ForestGenerator.js +12 -12
- package/examples/jsm/generators/TerrainGenerator.js +49 -37
- package/examples/jsm/generators/TreeGenerator.js +70 -76
- package/examples/jsm/generators/city/BenchGenerator.js +127 -0
- package/examples/jsm/generators/city/CarGenerator.js +479 -0
- package/examples/jsm/generators/city/CityGeneratorUtils.js +31 -0
- package/examples/jsm/generators/city/HydrantGenerator.js +106 -0
- package/examples/jsm/generators/city/InstancedMeshGenerator.js +86 -0
- package/examples/jsm/generators/city/PersonGenerator.js +447 -0
- package/examples/jsm/generators/city/SidewalkGenerator.js +33 -38
- package/examples/jsm/generators/city/SkyscraperGenerator.js +448 -48
- package/examples/jsm/generators/city/StreetTreeGenerator.js +231 -0
- package/examples/jsm/generators/city/StreetlightGenerator.js +100 -0
- package/examples/jsm/generators/city/TrafficlightGenerator.js +106 -0
- package/examples/jsm/generators/city/TrashcanGenerator.js +100 -0
- package/examples/jsm/geometries/BoxLineGeometry.js +1 -1
- package/examples/jsm/geometries/ParametricGeometry.js +1 -1
- package/examples/jsm/geometries/RoundedBoxGeometry.js +1 -1
- package/examples/jsm/gpgpu/CountingSort.js +271 -0
- package/examples/jsm/helpers/LightProbeGridHelper.js +60 -239
- package/examples/jsm/helpers/LightProbeGridHelperWebGL.js +221 -0
- package/examples/jsm/inspector/Extension.js +94 -0
- package/examples/jsm/inspector/Inspector.js +145 -41
- package/examples/jsm/inspector/RendererInspector.js +100 -52
- package/examples/jsm/inspector/extensions/color-grading/ColorGrading.js +2609 -0
- package/examples/jsm/inspector/extensions/color-grading/ColorWheel.js +352 -0
- package/examples/jsm/inspector/extensions/color-grading/CurveEditor.js +599 -0
- package/examples/jsm/inspector/extensions/color-grading/LUT3DStyle.js +1201 -0
- package/examples/jsm/inspector/extensions/color-grading/LUTMath.js +788 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/BrightnessModule.js +72 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ColorWheelModule.js +112 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ContrastModule.js +82 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/CurvesModule.js +109 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ExposureHueModule.js +110 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ExposureModule.js +73 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/HueModule.js +78 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ImportedCubeModule.js +89 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/Module.js +285 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/OutputModule.js +101 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/RendererModule.js +225 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/SatVibranceModule.js +102 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/SaturationModule.js +76 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/VibranceModule.js +76 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/WhiteBalanceModule.js +86 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.js +26 -31
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.js +1 -0
- package/examples/jsm/inspector/tabs/Memory.js +0 -2
- package/examples/jsm/inspector/tabs/Settings.js +4 -0
- package/examples/jsm/inspector/tabs/Timeline.js +223 -171
- package/examples/jsm/inspector/tabs/Viewer.js +515 -21
- package/examples/jsm/inspector/ui/List.js +15 -9
- package/examples/jsm/inspector/ui/Profiler.js +170 -14
- package/examples/jsm/inspector/ui/Style.js +269 -23
- package/examples/jsm/inspector/ui/Tab.js +2 -0
- package/examples/jsm/inspector/ui/Values.js +14 -2
- package/examples/jsm/interactive/HTMLMesh.js +19 -3
- package/examples/jsm/lighting/LightProbeGrid.js +484 -889
- package/examples/jsm/lighting/LightProbeGridUtils.js +107 -0
- package/examples/jsm/lighting/LightProbeGridWebGL.js +841 -0
- package/examples/jsm/lighting/vxgi/VXGIConeTracer.js +194 -0
- package/examples/jsm/lighting/vxgi/VXGINode.js +660 -0
- package/examples/jsm/lighting/vxgi/VXGISceneCollector.js +478 -0
- package/examples/jsm/lighting/vxgi/VXGIVolume.js +1430 -0
- package/examples/jsm/lights/SunLight.js +95 -0
- package/examples/jsm/lights/SunLightNode.js +56 -0
- package/examples/jsm/lights/SunLightShadow.js +319 -0
- package/examples/jsm/lights/SunShadowNode.js +312 -0
- package/examples/jsm/loaders/3DMLoader.js +150 -49
- package/examples/jsm/loaders/3MFLoader.js +202 -1
- package/examples/jsm/loaders/FBXLoader.js +81 -5
- package/examples/jsm/loaders/GLTFGaussianSplatLoaderExtension.js +330 -0
- package/examples/jsm/loaders/GLTFLoader.js +79 -14
- package/examples/jsm/loaders/GaussianSplatPLYLoader.js +386 -0
- package/examples/jsm/loaders/KSPLATLoader.js +463 -0
- package/examples/jsm/loaders/MaterialXLoader.js +111 -1010
- package/examples/jsm/loaders/PCDLoader.js +1 -1
- package/examples/jsm/loaders/SPLATLoader.js +139 -0
- package/examples/jsm/loaders/SPZLoader.js +561 -0
- package/examples/jsm/loaders/materialx/MaterialXArchive.js +108 -0
- package/examples/jsm/loaders/materialx/MaterialXDocument.js +878 -0
- package/examples/jsm/loaders/materialx/MaterialXHextile.js +183 -0
- package/examples/jsm/loaders/materialx/MaterialXInterfaceValidation.js +376 -0
- package/examples/jsm/loaders/materialx/MaterialXLog.js +75 -0
- package/examples/jsm/loaders/materialx/MaterialXNodeInterfaceRegistry.js +4 -0
- package/examples/jsm/loaders/materialx/MaterialXNodeLibrary.js +1021 -0
- package/examples/jsm/loaders/materialx/MaterialXSurfaceMappings.js +661 -0
- package/examples/jsm/loaders/materialx/MaterialXUtils.js +57 -0
- package/examples/jsm/loaders/materialx/compile/MaterialXCompileRegistry.js +997 -0
- package/examples/jsm/loaders/materialx/parse/MaterialXParser.js +28 -0
- package/examples/jsm/loaders/usd/USDAParser.js +15 -2
- package/examples/jsm/loaders/usd/USDCParser.js +1 -4
- package/examples/jsm/loaders/usd/USDComposer.js +80 -42
- package/examples/jsm/materials/WoodNodeMaterial.js +6 -108
- package/examples/jsm/misc/RollerCoaster.js +2 -2
- package/examples/jsm/misc/SculptGL.LICENSE.txt +21 -0
- package/examples/jsm/misc/Sculptor.js +1679 -0
- package/examples/jsm/misc/SculptorMesh.js +1504 -0
- package/examples/jsm/misc/SculptorTools.js +1180 -0
- package/examples/jsm/misc/SculptorUtils.js +345 -0
- package/examples/jsm/misc/TubePainter.js +28 -16
- package/examples/jsm/misc/VolumeSlice.js +24 -24
- package/examples/jsm/modifiers/SimplifyModifier.js +63 -556
- package/examples/jsm/objects/GaussianSplat.js +1039 -0
- package/examples/jsm/objects/Sky.js +66 -45
- package/examples/jsm/objects/SkyMesh.js +70 -51
- package/examples/jsm/physics/JoltPhysics.js +1 -1
- package/examples/jsm/postprocessing/AfterimagePass.js +4 -2
- package/examples/jsm/postprocessing/BloomPass.js +2 -2
- package/examples/jsm/postprocessing/GTAOPass.js +1 -1
- package/examples/jsm/postprocessing/OutlinePass.js +5 -5
- package/examples/jsm/postprocessing/SAOPass.js +1 -1
- package/examples/jsm/postprocessing/SSAOPass.js +1 -1
- package/examples/jsm/postprocessing/SSRPass.js +4 -2
- package/examples/jsm/postprocessing/SavePass.js +1 -1
- package/examples/jsm/postprocessing/TAARenderPass.js +1 -1
- package/examples/jsm/postprocessing/UnrealBloomPass.js +30 -13
- package/examples/jsm/renderers/CSS2DRenderer.js +29 -5
- package/examples/jsm/shaders/DepthLimitedBlurShader.js +4 -1
- package/examples/jsm/shaders/ExposureShader.js +1 -1
- package/examples/jsm/shaders/FilmShader.js +2 -1
- package/examples/jsm/transpiler/AST.js +21 -2
- package/examples/jsm/transpiler/GLSLDecoder.js +498 -8
- package/examples/jsm/transpiler/TSLEncoder.js +82 -10
- package/examples/jsm/transpiler/WGSLEncoder.js +33 -4
- package/examples/jsm/tsl/WebGLNodesHandler.js +29 -39
- package/examples/jsm/tsl/display/AfterImageNode.js +2 -0
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +3 -2
- package/examples/jsm/tsl/display/BilateralBlurNode.js +5 -2
- package/examples/jsm/tsl/display/BloomNode.js +55 -30
- package/examples/jsm/tsl/display/DenoiseNode.js +21 -1
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +24 -6
- package/examples/jsm/tsl/display/DotScreenNode.js +11 -11
- package/examples/jsm/tsl/display/FSR1Node.js +8 -4
- package/examples/jsm/tsl/display/GTAONode.js +199 -86
- package/examples/jsm/tsl/display/GaussianBlurNode.js +65 -52
- package/examples/jsm/tsl/display/GodraysNode.js +5 -2
- package/examples/jsm/tsl/display/ImportanceSampledEnvironment.js +2 -2
- package/examples/jsm/tsl/display/LensflareNode.js +5 -2
- package/examples/jsm/tsl/display/OITPassNode.js +352 -0
- package/examples/jsm/tsl/display/OutlineNode.js +2 -0
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +3 -2
- package/examples/jsm/tsl/display/RGBShiftNode.js +9 -9
- package/examples/jsm/tsl/display/RecurrentDenoiseNode.js +7 -4
- package/examples/jsm/tsl/display/RetroPassNode.js +1 -1
- package/examples/jsm/tsl/display/SMAANode.js +22 -61
- package/examples/jsm/tsl/display/SSAAPassNode.js +2 -4
- package/examples/jsm/tsl/display/SSAONode.js +436 -0
- package/examples/jsm/tsl/display/SSGINode.js +5 -2
- package/examples/jsm/tsl/display/SSRNode.js +7 -2
- package/examples/jsm/tsl/display/SSSNode.js +5 -2
- package/examples/jsm/tsl/display/SharpenNode.js +5 -4
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +1 -3
- package/examples/jsm/tsl/display/StereoPassNode.js +1 -3
- package/examples/jsm/tsl/display/TAAUNode.js +22 -125
- package/examples/jsm/tsl/display/TRAANode.js +16 -142
- package/examples/jsm/tsl/display/TemporalReprojectNode.js +21 -15
- package/examples/jsm/tsl/display/depthAwareBlur.js +63 -0
- package/examples/jsm/tsl/display/hashBlur.js +3 -2
- package/examples/jsm/tsl/lighting/ClusteredLightsNode.js +38 -27
- package/examples/jsm/tsl/lighting/LightProbeGridNode.js +136 -0
- package/examples/jsm/tsl/math/voronoiNoise.js +112 -0
- package/examples/jsm/tsl/shadows/TileShadowNode.js +4 -6
- package/examples/jsm/tsl/utils/Raymarching.js +5 -5
- package/examples/jsm/tsl/utils/SoftParticles.js +60 -0
- package/examples/jsm/tsl/utils/TAAUtils.js +195 -0
- package/examples/jsm/utils/BufferGeometryUtils.js +14 -14
- package/examples/jsm/utils/GaussianSplatUtils.js +229 -0
- package/examples/jsm/utils/WebGLTextureUtils.js +1 -1
- package/examples/jsm/utils/WebGPUTextureUtils.js +1 -1
- package/examples/jsm/webxr/WebGLXRFallback.js +2 -16
- package/examples/jsm/webxr/XRControllerModelFactory.js +16 -4
- package/package.json +9 -16
- package/src/Three.Core.js +2 -1
- package/src/Three.TSL.js +73 -43
- package/src/Three.WebGPU.Nodes.js +1 -0
- package/src/Three.WebGPU.js +1 -0
- package/src/animation/AnimationClip.js +15 -2
- package/src/animation/AnimationObjectGroup.js +18 -6
- package/src/animation/AnimationUtils.js +26 -0
- package/src/animation/KeyframeTrack.js +37 -0
- package/src/constants.js +23 -1
- package/src/core/BufferAttribute.js +3 -2
- package/src/core/BufferGeometry.js +1 -1
- package/src/core/InterleavedBuffer.js +5 -1
- package/src/core/Object3D.js +40 -12
- package/src/core/Raycaster.js +4 -0
- package/src/core/RenderTarget.js +99 -9
- package/src/core/RenderTarget3D.js +12 -8
- package/src/extras/Controls.js +0 -8
- package/src/extras/PMREMGenerator.js +99 -205
- package/src/geometries/TorusGeometry.js +1 -1
- package/src/helpers/ArrowHelper.js +2 -0
- package/src/helpers/AxesHelper.js +2 -0
- package/src/helpers/Box3Helper.js +2 -0
- package/src/helpers/BoxHelper.js +2 -0
- package/src/helpers/CameraHelper.js +2 -0
- package/src/helpers/DirectionalLightHelper.js +2 -0
- package/src/helpers/GridHelper.js +2 -0
- package/src/helpers/HemisphereLightHelper.js +2 -0
- package/src/helpers/PlaneHelper.js +2 -0
- package/src/helpers/PointLightHelper.js +2 -0
- package/src/helpers/PolarGridHelper.js +2 -0
- package/src/helpers/SkeletonHelper.js +2 -0
- package/src/helpers/SpotLightHelper.js +2 -0
- package/src/lights/Light.js +0 -10
- package/src/lights/LightShadow.js +43 -12
- package/src/lights/SpotLightShadow.js +18 -0
- package/src/loaders/BufferGeometryLoader.js +5 -0
- package/src/loaders/ImageBitmapLoader.js +3 -1
- package/src/loaders/ObjectLoader.js +8 -5
- package/src/materials/Material.js +80 -57
- package/src/materials/MeshPhysicalMaterial.js +32 -0
- package/src/materials/nodes/Line2NodeMaterial.js +17 -8
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +42 -5
- package/src/materials/nodes/NodeMaterial.js +19 -13
- package/src/materials/nodes/PointsNodeMaterial.js +2 -1
- package/src/materials/nodes/manager/NodeMaterialObserver.js +282 -55
- package/src/math/Frustum.js +9 -0
- package/src/math/FrustumArray.js +1 -1
- package/src/math/MathUtils.js +5 -3
- package/src/math/Matrix4.js +2 -9
- package/src/math/Plane.js +30 -1
- package/src/math/Quaternion.js +0 -10
- package/src/math/Ray.js +95 -45
- package/src/math/Triangle.js +0 -2
- package/src/math/Vector3.js +2 -2
- package/src/math/Vector4.js +0 -4
- package/src/math/interpolants/BezierInterpolant.js +36 -23
- package/src/nodes/Nodes.js +2 -0
- package/src/nodes/TSL.js +11 -3
- package/src/nodes/accessors/Batch.js +85 -13
- package/src/nodes/accessors/BufferAttributeNode.js +1 -1
- package/src/nodes/accessors/BuiltinNode.js +1 -1
- package/src/nodes/accessors/Instance.js +19 -18
- package/src/nodes/accessors/MaterialNode.js +9 -0
- package/src/nodes/accessors/ModelNode.js +85 -9
- package/src/nodes/accessors/ReferenceBaseNode.js +1 -70
- package/src/nodes/accessors/ReferenceElementNode.js +72 -0
- package/src/nodes/accessors/ReferenceNode.js +1 -70
- package/src/nodes/accessors/Skinning.js +124 -12
- package/src/nodes/accessors/StorageTextureNode.js +7 -3
- package/src/nodes/accessors/Texture3DNode.js +1 -1
- package/src/nodes/accessors/TextureNode.js +51 -21
- package/src/nodes/accessors/TextureSizeNode.js +4 -2
- package/src/nodes/accessors/UniformArrayNode.js +30 -5
- package/src/nodes/code/CodeNode.js +1 -1
- package/src/nodes/code/FunctionNode.js +12 -2
- package/src/nodes/core/ArrayNode.js +2 -2
- package/src/nodes/core/ContextNode.js +57 -4
- package/src/nodes/core/IndexNode.js +69 -4
- package/src/nodes/core/InspectorNode.js +2 -2
- package/src/nodes/core/MRTNode.js +44 -2
- package/src/nodes/core/Node.js +6 -3
- package/src/nodes/core/NodeBuilder.js +65 -50
- package/src/nodes/core/NodeFrame.js +11 -3
- package/src/nodes/core/NodeUtils.js +88 -0
- package/src/nodes/core/PropertyNode.js +8 -0
- package/src/nodes/core/StackNode.js +0 -1
- package/src/nodes/core/StructNode.js +4 -3
- package/src/nodes/core/UniformGroupNode.js +3 -2
- package/src/nodes/core/UniformNode.js +26 -12
- package/src/nodes/core/VarNode.js +0 -1
- package/src/nodes/display/BumpMapNode.js +2 -2
- package/src/nodes/display/ColorAdjustment.js +1 -1
- package/src/nodes/display/PassNode.js +76 -15
- package/src/nodes/display/ScreenNode.js +22 -65
- package/src/nodes/fog/Fog.js +4 -4
- package/src/nodes/functions/BSDF/BRDF_GGX.js +6 -6
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +1 -1
- package/src/nodes/functions/BSDF/DFGLUT.js +2 -1
- package/src/nodes/functions/BSDF/LTC.js +1 -1
- package/src/nodes/functions/PhongLightingModel.js +1 -1
- package/src/nodes/functions/PhysicalLightingModel.js +83 -25
- package/src/nodes/functions/ToonLightingModel.js +2 -2
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +3 -3
- package/src/nodes/gpgpu/AtomicFunctionNode.js +64 -13
- package/src/nodes/gpgpu/BarrierNode.js +13 -4
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -1
- package/src/nodes/gpgpu/ComputeNode.js +20 -17
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +165 -37
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +44 -6
- package/src/nodes/lighting/EnvironmentNode.js +40 -4
- package/src/nodes/lighting/LightsNode.js +20 -4
- package/src/nodes/lighting/ShadowBaseNode.js +158 -1
- package/src/nodes/lighting/ShadowFilterNode.js +2 -106
- package/src/nodes/lighting/ShadowNode.js +22 -91
- package/src/nodes/materialx/{lib/mx_hsv.js → MaterialXColor.js} +3 -6
- package/src/nodes/materialx/{lib/mx_transform_color.js → MaterialXColorTransform.js} +3 -6
- package/src/nodes/materialx/MaterialXCore.js +37 -0
- package/src/nodes/materialx/MaterialXNodes.js +64 -72
- package/src/nodes/materialx/{lib/mx_noise.js → MaterialXNoise.js} +426 -197
- package/src/nodes/math/BitcountNode.js +24 -4
- package/src/nodes/math/MathNode.js +4 -4
- package/src/nodes/math/MathUtils.js +15 -4
- package/src/nodes/math/OperatorNode.js +2 -2
- package/src/nodes/math/PackFloatNode.js +29 -1
- package/src/nodes/math/Packed4x8IntegerNode.js +433 -0
- package/src/nodes/math/UnpackFloatNode.js +30 -2
- package/src/nodes/parsers/GLSLNodeFunction.js +1 -1
- package/src/nodes/pmrem/PMREMNode.js +1 -1
- package/src/nodes/pmrem/PMREMUtils.js +31 -74
- package/src/nodes/shapes/Shapes.js +1 -1
- package/src/nodes/tsl/TSLCore.js +1 -31
- package/src/nodes/utils/EventNode.js +75 -0
- package/src/nodes/utils/LoopNode.js +54 -13
- package/src/nodes/utils/PostProcessingUtils.js +23 -2
- package/src/nodes/utils/RTTNode.js +97 -32
- package/src/nodes/utils/ReflectorNode.js +8 -4
- package/src/nodes/utils/RotateNode.js +85 -8
- package/src/nodes/utils/SpriteUtils.js +58 -23
- package/src/objects/BatchedMesh.js +6 -0
- package/src/objects/InstancedMesh.js +1 -1
- package/src/objects/LOD.js +1 -1
- package/src/objects/Line.js +12 -0
- package/src/objects/Mesh.js +12 -0
- package/src/objects/Points.js +12 -0
- package/src/objects/Sprite.js +12 -0
- package/src/renderers/WebGLRenderer.js +93 -27
- package/src/renderers/common/Animation.js +12 -2
- package/src/renderers/common/Backend.js +38 -10
- package/src/renderers/common/BindGroup.js +0 -1
- package/src/renderers/common/Bindings.js +50 -4
- package/src/renderers/common/BundleGroup.js +4 -0
- package/src/renderers/common/ClippingContext.js +11 -1
- package/src/renderers/common/Color4.js +9 -0
- package/src/renderers/common/Constants.js +0 -5
- package/src/renderers/common/DirectRenderPipeline.js +233 -0
- package/src/renderers/common/Geometries.js +24 -3
- package/src/renderers/common/Info.js +3 -3
- package/src/renderers/common/InspectorBase.js +37 -8
- package/src/renderers/common/Lighting.js +11 -4
- package/src/renderers/common/Pipelines.js +6 -4
- package/src/renderers/common/QuadMesh.js +16 -2
- package/src/renderers/common/RenderContext.js +8 -0
- package/src/renderers/common/RenderList.js +53 -19
- package/src/renderers/common/RenderLists.js +58 -11
- package/src/renderers/common/RenderObject.js +14 -0
- package/src/renderers/common/RenderObjects.js +14 -9
- package/src/renderers/common/RenderPipeline.js +52 -44
- package/src/renderers/common/Renderer.js +226 -55
- package/src/renderers/common/Storage3DTexture.js +16 -0
- package/src/renderers/common/Textures.js +3 -3
- package/src/renderers/common/XRManager.js +79 -72
- package/src/renderers/common/extras/PMREMGenerator.js +76 -144
- package/src/renderers/common/nodes/NodeManager.js +144 -6
- package/src/renderers/common/nodes/NodeStorageBuffer.js +3 -1
- package/src/renderers/common/nodes/NodeUniformBuffer.js +3 -1
- package/src/renderers/shaders/DFGLUTData.js +2 -1
- package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +4 -2
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +48 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +53 -4
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +20 -2
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +20 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +61 -57
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +82 -0
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +9 -0
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +8 -1
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +15 -0
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -0
- package/src/renderers/shaders/ShaderLib.js +1 -0
- package/src/renderers/shaders/UniformsLib.js +16 -0
- package/src/renderers/webgl/WebGLAnimation.js +2 -2
- package/src/renderers/webgl/WebGLCapabilities.js +2 -2
- package/src/renderers/webgl/WebGLLights.js +74 -4
- package/src/renderers/webgl/WebGLMaterials.js +6 -0
- package/src/renderers/webgl/WebGLOutput.js +36 -24
- package/src/renderers/webgl/WebGLProgram.js +3 -0
- package/src/renderers/webgl/WebGLPrograms.js +8 -0
- package/src/renderers/webgl/WebGLRenderLists.js +6 -10
- package/src/renderers/webgl/WebGLShadowMap.js +47 -44
- package/src/renderers/webgl/WebGLTextures.js +7 -7
- package/src/renderers/webgl-fallback/WebGLBackend.js +153 -45
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +83 -29
- package/src/renderers/webgl-fallback/utils/WebGLState.js +163 -17
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +32 -5
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +11 -4
- package/src/renderers/webgpu/WebGPUBackend.js +513 -145
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +99 -20
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +2 -1
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +3 -12
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +24 -14
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +80 -14
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +62 -7
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +9 -3
- package/src/renderers/webgpu/utils/WebGPUUtils.js +16 -4
- package/src/renderers/webxr/WebXRManager.js +25 -2
- package/src/scenes/Scene.js +3 -3
- package/src/textures/CompressedArrayTexture.js +16 -0
- package/src/textures/Data3DTexture.js +16 -0
- package/src/textures/DataArrayTexture.js +16 -0
- package/src/textures/DepthTexture.js +3 -3
- package/src/textures/Texture.js +3 -3
- package/src/textures/{Source.js → TextureSource.js} +39 -8
- package/build/three.core.min.js +0 -6
- package/build/three.module.min.js +0 -6
- package/build/three.tsl.min.js +0 -6
- package/build/three.webgpu.min.js +0 -6
- package/build/three.webgpu.nodes.min.js +0 -6
- package/examples/jsm/libs/ecsy.module.js +0 -1792
- package/examples/jsm/loaders/LottieLoader.js +0 -130
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +0 -52
|
@@ -15,6 +15,8 @@ import { isTypedArray, warnOnce, warn, error } from '../../utils.js';
|
|
|
15
15
|
import { WebGLCoordinateSystem, TimestampQuery, Compatibility } from '../../constants.js';
|
|
16
16
|
import WebGLTimestampQueryPool from './utils/WebGLTimestampQueryPool.js';
|
|
17
17
|
|
|
18
|
+
const _invalidationArray = [];
|
|
19
|
+
|
|
18
20
|
/**
|
|
19
21
|
* A backend implementation targeting WebGL 2.
|
|
20
22
|
*
|
|
@@ -530,6 +532,12 @@ class WebGLBackend extends Backend {
|
|
|
530
532
|
renderContextData.occlusionQueryObjects = new Array( occlusionQueryCount );
|
|
531
533
|
renderContextData.occlusionQueryIndex = 0;
|
|
532
534
|
|
|
535
|
+
} else if ( renderContextData.lastOcclusionObject !== undefined ) {
|
|
536
|
+
|
|
537
|
+
// invalidate if there is a stale query
|
|
538
|
+
|
|
539
|
+
renderContextData.lastOcclusionObject = undefined;
|
|
540
|
+
|
|
533
541
|
}
|
|
534
542
|
|
|
535
543
|
}
|
|
@@ -552,7 +560,9 @@ class WebGLBackend extends Backend {
|
|
|
552
560
|
|
|
553
561
|
if ( occlusionQueryCount > 0 ) {
|
|
554
562
|
|
|
555
|
-
|
|
563
|
+
const lastOcclusionObject = renderContextData.lastOcclusionObject;
|
|
564
|
+
|
|
565
|
+
if ( lastOcclusionObject && lastOcclusionObject.occlusionTest === true ) {
|
|
556
566
|
|
|
557
567
|
gl.endQuery( gl.ANY_SAMPLES_PASSED );
|
|
558
568
|
|
|
@@ -641,14 +651,14 @@ class WebGLBackend extends Backend {
|
|
|
641
651
|
|
|
642
652
|
const check = () => {
|
|
643
653
|
|
|
644
|
-
let completed =
|
|
654
|
+
let completed = true;
|
|
645
655
|
|
|
646
656
|
// check all queries and requeue as appropriate
|
|
647
657
|
for ( let i = 0; i < currentOcclusionQueries.length; i ++ ) {
|
|
648
658
|
|
|
649
659
|
const query = currentOcclusionQueries[ i ];
|
|
650
660
|
|
|
651
|
-
if ( query
|
|
661
|
+
if ( ! query ) continue;
|
|
652
662
|
|
|
653
663
|
if ( gl.getQueryParameter( query, gl.QUERY_RESULT_AVAILABLE ) ) {
|
|
654
664
|
|
|
@@ -657,13 +667,15 @@ class WebGLBackend extends Backend {
|
|
|
657
667
|
currentOcclusionQueries[ i ] = null;
|
|
658
668
|
gl.deleteQuery( query );
|
|
659
669
|
|
|
660
|
-
|
|
670
|
+
} else {
|
|
671
|
+
|
|
672
|
+
completed = false;
|
|
661
673
|
|
|
662
674
|
}
|
|
663
675
|
|
|
664
676
|
}
|
|
665
677
|
|
|
666
|
-
if ( completed
|
|
678
|
+
if ( completed === false ) {
|
|
667
679
|
|
|
668
680
|
requestAnimationFrame( check );
|
|
669
681
|
|
|
@@ -738,6 +750,15 @@ class WebGLBackend extends Backend {
|
|
|
738
750
|
|
|
739
751
|
}
|
|
740
752
|
|
|
753
|
+
/**
|
|
754
|
+
* Restores the WebGL state to its default and invalidates the internal state cache.
|
|
755
|
+
*/
|
|
756
|
+
resetState() {
|
|
757
|
+
|
|
758
|
+
this.state.reset();
|
|
759
|
+
|
|
760
|
+
}
|
|
761
|
+
|
|
741
762
|
/**
|
|
742
763
|
* Returns the clear color and alpha into a single
|
|
743
764
|
* color object.
|
|
@@ -811,10 +832,14 @@ class WebGLBackend extends Backend {
|
|
|
811
832
|
const clearStencil = renderer.getClearStencil();
|
|
812
833
|
|
|
813
834
|
if ( depth ) this.state.setDepthMask( true );
|
|
835
|
+
if ( stencil ) this.state.setStencilMask( 0xffffffff );
|
|
814
836
|
|
|
815
837
|
if ( descriptor.textures === null ) {
|
|
816
838
|
|
|
817
|
-
gl.clearColor( clearColor.r, clearColor.g, clearColor.b, clearColor.a );
|
|
839
|
+
if ( color ) gl.clearColor( clearColor.r, clearColor.g, clearColor.b, clearColor.a );
|
|
840
|
+
if ( depth ) gl.clearDepth( clearDepth );
|
|
841
|
+
if ( stencil ) gl.clearStencil( clearStencil );
|
|
842
|
+
|
|
818
843
|
gl.clear( clear );
|
|
819
844
|
|
|
820
845
|
} else {
|
|
@@ -825,7 +850,13 @@ class WebGLBackend extends Backend {
|
|
|
825
850
|
|
|
826
851
|
for ( let i = 0; i < descriptor.textures.length; i ++ ) {
|
|
827
852
|
|
|
828
|
-
|
|
853
|
+
const mrtClearColor = descriptor.mrt ? descriptor.mrt.getClearColor( descriptor.textures[ i ].name ) : null;
|
|
854
|
+
|
|
855
|
+
if ( mrtClearColor !== null ) {
|
|
856
|
+
|
|
857
|
+
gl.clearBufferfv( gl.COLOR, i, [ mrtClearColor.r, mrtClearColor.g, mrtClearColor.b, mrtClearColor.a ] );
|
|
858
|
+
|
|
859
|
+
} else if ( i === 0 ) {
|
|
829
860
|
|
|
830
861
|
gl.clearBufferfv( gl.COLOR, i, [ clearColor.r, clearColor.g, clearColor.b, clearColor.a ] );
|
|
831
862
|
|
|
@@ -1247,9 +1278,9 @@ class WebGLBackend extends Backend {
|
|
|
1247
1278
|
|
|
1248
1279
|
}
|
|
1249
1280
|
|
|
1250
|
-
const pixelRatio = this.renderer.getPixelRatio();
|
|
1251
|
-
|
|
1252
1281
|
const renderTarget = this._currentContext.renderTarget;
|
|
1282
|
+
|
|
1283
|
+
const pixelRatio = ( renderTarget === null || renderTarget.isPostProcessingRenderTarget === true ) ? this.renderer.getPixelRatio() : 1;
|
|
1253
1284
|
const isRenderCameraDepthArray = this._isRenderCameraDepthArray( this._currentContext );
|
|
1254
1285
|
const prevActiveCubeFace = this._currentContext.activeCubeFace;
|
|
1255
1286
|
|
|
@@ -1428,7 +1459,7 @@ class WebGLBackend extends Backend {
|
|
|
1428
1459
|
* @param {number} y - The y coordinate of the copy origin.
|
|
1429
1460
|
* @param {number} width - The width of the copy.
|
|
1430
1461
|
* @param {number} height - The height of the copy.
|
|
1431
|
-
* @param {number} faceIndex - The face index.
|
|
1462
|
+
* @param {number} faceIndex - The cube face, depth slice or array layer index.
|
|
1432
1463
|
* @return {Promise<TypedArray>} A Promise that resolves with a typed array when the copy operation has finished.
|
|
1433
1464
|
*/
|
|
1434
1465
|
async copyTextureToBuffer( texture, x, y, width, height, faceIndex ) {
|
|
@@ -1712,10 +1743,11 @@ class WebGLBackend extends Backend {
|
|
|
1712
1743
|
*
|
|
1713
1744
|
* @param {ComputePipeline} computePipeline - The compute pipeline.
|
|
1714
1745
|
* @param {Array<BindGroup>} bindings - The bindings.
|
|
1746
|
+
* @param {?Array<Promise>} [promises=null] - Optional compilation promises.
|
|
1715
1747
|
*/
|
|
1716
|
-
createComputePipeline( computePipeline, bindings ) {
|
|
1748
|
+
createComputePipeline( computePipeline, bindings, promises = null ) {
|
|
1717
1749
|
|
|
1718
|
-
const {
|
|
1750
|
+
const { gl } = this;
|
|
1719
1751
|
|
|
1720
1752
|
// Program
|
|
1721
1753
|
|
|
@@ -1758,19 +1790,6 @@ class WebGLBackend extends Backend {
|
|
|
1758
1790
|
|
|
1759
1791
|
gl.linkProgram( programGPU );
|
|
1760
1792
|
|
|
1761
|
-
if ( gl.getProgramParameter( programGPU, gl.LINK_STATUS ) === false ) {
|
|
1762
|
-
|
|
1763
|
-
this._logProgramError( programGPU, fragmentShader, vertexShader );
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
}
|
|
1767
|
-
|
|
1768
|
-
state.useProgram( programGPU );
|
|
1769
|
-
|
|
1770
|
-
// Bindings
|
|
1771
|
-
|
|
1772
|
-
this._setupBindings( bindings, programGPU );
|
|
1773
|
-
|
|
1774
1793
|
const attributeNodes = computeProgram.attributes;
|
|
1775
1794
|
const attributes = [];
|
|
1776
1795
|
const transformBuffers = [];
|
|
@@ -1797,14 +1816,73 @@ class WebGLBackend extends Backend {
|
|
|
1797
1816
|
|
|
1798
1817
|
}
|
|
1799
1818
|
|
|
1800
|
-
//
|
|
1819
|
+
// Store pipeline data
|
|
1801
1820
|
|
|
1802
1821
|
this.set( computePipeline, {
|
|
1803
1822
|
programGPU,
|
|
1823
|
+
fragmentShader,
|
|
1824
|
+
vertexShader,
|
|
1804
1825
|
transformBuffers,
|
|
1805
1826
|
attributes
|
|
1806
1827
|
} );
|
|
1807
1828
|
|
|
1829
|
+
if ( promises !== null && this.parallel ) {
|
|
1830
|
+
|
|
1831
|
+
const parallel = this.parallel;
|
|
1832
|
+
|
|
1833
|
+
const p = new Promise( ( resolve ) => {
|
|
1834
|
+
|
|
1835
|
+
const checkStatus = () => {
|
|
1836
|
+
|
|
1837
|
+
if ( gl.getProgramParameter( programGPU, parallel.COMPLETION_STATUS_KHR ) ) {
|
|
1838
|
+
|
|
1839
|
+
this._completeComputeCompile( computePipeline, bindings );
|
|
1840
|
+
resolve();
|
|
1841
|
+
|
|
1842
|
+
} else {
|
|
1843
|
+
|
|
1844
|
+
requestAnimationFrame( checkStatus );
|
|
1845
|
+
|
|
1846
|
+
}
|
|
1847
|
+
|
|
1848
|
+
};
|
|
1849
|
+
|
|
1850
|
+
checkStatus();
|
|
1851
|
+
|
|
1852
|
+
} );
|
|
1853
|
+
|
|
1854
|
+
promises.push( p );
|
|
1855
|
+
return;
|
|
1856
|
+
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
// Sync fallback
|
|
1860
|
+
this._completeComputeCompile( computePipeline, bindings );
|
|
1861
|
+
|
|
1862
|
+
}
|
|
1863
|
+
|
|
1864
|
+
/**
|
|
1865
|
+
* Completes the compute pipeline setup for the given compute pipeline.
|
|
1866
|
+
*
|
|
1867
|
+
* @param {ComputePipeline} computePipeline - The compute pipeline.
|
|
1868
|
+
* @param {Array<BindGroup>} bindings - Array of bind groups.
|
|
1869
|
+
*/
|
|
1870
|
+
_completeComputeCompile( computePipeline, bindings ) {
|
|
1871
|
+
|
|
1872
|
+
const { state, gl } = this;
|
|
1873
|
+
const { programGPU, fragmentShader, vertexShader } = this.get( computePipeline );
|
|
1874
|
+
|
|
1875
|
+
if ( gl.getProgramParameter( programGPU, gl.LINK_STATUS ) === false ) {
|
|
1876
|
+
|
|
1877
|
+
this._logProgramError( programGPU, fragmentShader, vertexShader );
|
|
1878
|
+
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1881
|
+
state.useProgram( programGPU );
|
|
1882
|
+
|
|
1883
|
+
// Bindings (must be after link completion)
|
|
1884
|
+
this._setupBindings( bindings, programGPU );
|
|
1885
|
+
|
|
1808
1886
|
}
|
|
1809
1887
|
|
|
1810
1888
|
/**
|
|
@@ -1812,10 +1890,10 @@ class WebGLBackend extends Backend {
|
|
|
1812
1890
|
*
|
|
1813
1891
|
* @param {BindGroup} bindGroup - The bind group.
|
|
1814
1892
|
* @param {Array<BindGroup>} bindings - Array of bind groups.
|
|
1815
|
-
* @param {
|
|
1893
|
+
* @param {string} cacheKey - The cache key.
|
|
1816
1894
|
* @param {number} version - The version.
|
|
1817
1895
|
*/
|
|
1818
|
-
createBindings( bindGroup, bindings /*,
|
|
1896
|
+
createBindings( bindGroup, bindings /*, cacheKey, version*/ ) {
|
|
1819
1897
|
|
|
1820
1898
|
if ( this._knownBindings.has( bindings ) === false ) {
|
|
1821
1899
|
|
|
@@ -1851,10 +1929,10 @@ class WebGLBackend extends Backend {
|
|
|
1851
1929
|
*
|
|
1852
1930
|
* @param {BindGroup} bindGroup - The bind group.
|
|
1853
1931
|
* @param {Array<BindGroup>} bindings - Array of bind groups.
|
|
1854
|
-
* @param {
|
|
1932
|
+
* @param {string} cacheKey - The cache key.
|
|
1855
1933
|
* @param {number} version - The version.
|
|
1856
1934
|
*/
|
|
1857
|
-
updateBindings( bindGroup /*, bindings,
|
|
1935
|
+
updateBindings( bindGroup /*, bindings, cacheKey, version*/ ) {
|
|
1858
1936
|
|
|
1859
1937
|
const { gl } = this;
|
|
1860
1938
|
|
|
@@ -2182,7 +2260,7 @@ class WebGLBackend extends Backend {
|
|
|
2182
2260
|
|
|
2183
2261
|
const renderTarget = descriptor.renderTarget;
|
|
2184
2262
|
const renderTargetContextData = this.get( renderTarget );
|
|
2185
|
-
const {
|
|
2263
|
+
const { depthBuffer, stencilBuffer } = renderTarget;
|
|
2186
2264
|
|
|
2187
2265
|
const isCube = renderTarget.isCubeRenderTarget === true;
|
|
2188
2266
|
const isRenderTarget3D = renderTarget.isRenderTarget3D === true;
|
|
@@ -2195,6 +2273,20 @@ class WebGLBackend extends Backend {
|
|
|
2195
2273
|
const multisampledRTTExt = this.extensions.get( 'WEBGL_multisampled_render_to_texture' );
|
|
2196
2274
|
const multiviewExt = this.extensions.get( 'OVR_multiview2' );
|
|
2197
2275
|
const useMultisampledRTT = this._useMultisampledExtension( renderTarget );
|
|
2276
|
+
|
|
2277
|
+
let samples = renderTarget.samples;
|
|
2278
|
+
|
|
2279
|
+
if ( descriptor.depthTexture !== null && descriptor.depthTexture.renderTarget !== renderTarget && useMultisampledRTT === false ) {
|
|
2280
|
+
|
|
2281
|
+
if ( samples > 0 ) {
|
|
2282
|
+
|
|
2283
|
+
warnOnce( 'WebGLBackend: Shared depth texture is not supported with MSAA when "WEBGL_multisampled_render_to_texture" is unsupported. Falling back to single-sample rendering.' );
|
|
2284
|
+
samples = 0;
|
|
2285
|
+
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2288
|
+
}
|
|
2289
|
+
|
|
2198
2290
|
const cacheKey = getCacheKey( descriptor );
|
|
2199
2291
|
|
|
2200
2292
|
let fb;
|
|
@@ -2425,8 +2517,6 @@ class WebGLBackend extends Backend {
|
|
|
2425
2517
|
|
|
2426
2518
|
if ( msaaFb === undefined ) {
|
|
2427
2519
|
|
|
2428
|
-
const invalidationArray = [];
|
|
2429
|
-
|
|
2430
2520
|
msaaFb = gl.createFramebuffer();
|
|
2431
2521
|
|
|
2432
2522
|
state.bindFramebuffer( gl.FRAMEBUFFER, msaaFb );
|
|
@@ -2441,8 +2531,6 @@ class WebGLBackend extends Backend {
|
|
|
2441
2531
|
|
|
2442
2532
|
gl.bindRenderbuffer( gl.RENDERBUFFER, msaaRenderbuffers[ i ] );
|
|
2443
2533
|
|
|
2444
|
-
invalidationArray.push( gl.COLOR_ATTACHMENT0 + i );
|
|
2445
|
-
|
|
2446
2534
|
const texture = descriptor.textures[ i ];
|
|
2447
2535
|
const textureData = this.get( texture );
|
|
2448
2536
|
|
|
@@ -2464,13 +2552,8 @@ class WebGLBackend extends Backend {
|
|
|
2464
2552
|
|
|
2465
2553
|
renderTargetContextData.depthRenderbuffer = depthRenderbuffer;
|
|
2466
2554
|
|
|
2467
|
-
const depthStyle = stencilBuffer ? gl.DEPTH_STENCIL_ATTACHMENT : gl.DEPTH_ATTACHMENT;
|
|
2468
|
-
invalidationArray.push( depthStyle );
|
|
2469
|
-
|
|
2470
2555
|
}
|
|
2471
2556
|
|
|
2472
|
-
renderTargetContextData.invalidationArray = invalidationArray;
|
|
2473
|
-
|
|
2474
2557
|
}
|
|
2475
2558
|
|
|
2476
2559
|
currentFrameBuffer = renderTargetContextData.msaaFrameBuffer;
|
|
@@ -2716,11 +2799,11 @@ class WebGLBackend extends Backend {
|
|
|
2716
2799
|
|
|
2717
2800
|
const renderTargetContextData = this.get( renderTarget );
|
|
2718
2801
|
|
|
2719
|
-
if ( renderTarget.samples > 0 && this._useMultisampledExtension( renderTarget ) === false ) {
|
|
2802
|
+
if ( renderTarget.samples > 0 && renderTargetContextData.msaaFrameBuffer !== undefined && this._useMultisampledExtension( renderTarget ) === false ) {
|
|
2720
2803
|
|
|
2721
2804
|
const fb = renderTargetContextData.framebuffers[ renderContext.getCacheKey() ];
|
|
2722
2805
|
|
|
2723
|
-
let mask = gl.COLOR_BUFFER_BIT;
|
|
2806
|
+
let mask = renderTarget.resolveColorBuffer === false ? 0 : gl.COLOR_BUFFER_BIT;
|
|
2724
2807
|
|
|
2725
2808
|
if ( renderTarget.resolveDepthBuffer ) {
|
|
2726
2809
|
|
|
@@ -2798,11 +2881,34 @@ class WebGLBackend extends Backend {
|
|
|
2798
2881
|
|
|
2799
2882
|
if ( this._supportsInvalidateFramebuffer === true ) {
|
|
2800
2883
|
|
|
2801
|
-
|
|
2884
|
+
if ( renderTarget.storeMultisampledColorBuffer === false ) {
|
|
2885
|
+
|
|
2886
|
+
for ( let i = 0; i < textures.length; i ++ ) {
|
|
2887
|
+
|
|
2888
|
+
_invalidationArray.push( gl.COLOR_ATTACHMENT0 + i );
|
|
2889
|
+
|
|
2890
|
+
}
|
|
2891
|
+
|
|
2892
|
+
}
|
|
2893
|
+
|
|
2894
|
+
if ( renderTarget.depthBuffer && renderTarget.storeMultisampledDepthBuffer === false ) {
|
|
2895
|
+
|
|
2896
|
+
_invalidationArray.push( renderTarget.stencilBuffer ? gl.DEPTH_STENCIL_ATTACHMENT : gl.DEPTH_ATTACHMENT );
|
|
2897
|
+
|
|
2898
|
+
}
|
|
2899
|
+
|
|
2900
|
+
if ( _invalidationArray.length > 0 ) {
|
|
2901
|
+
|
|
2902
|
+
gl.invalidateFramebuffer( gl.READ_FRAMEBUFFER, _invalidationArray );
|
|
2903
|
+
|
|
2904
|
+
_invalidationArray.length = 0;
|
|
2905
|
+
|
|
2906
|
+
}
|
|
2802
2907
|
|
|
2803
2908
|
}
|
|
2804
2909
|
|
|
2805
|
-
} else if (
|
|
2910
|
+
} else if ( this._supportsInvalidateFramebuffer === true && renderTargetContextData.framebuffers &&
|
|
2911
|
+
( renderTarget._autoAllocateDepthBuffer === true || ( renderTarget.samples > 0 && renderTarget.storeMultisampledDepthBuffer === false ) ) ) {
|
|
2806
2912
|
|
|
2807
2913
|
const fb = renderTargetContextData.framebuffers[ renderContext.getCacheKey() ];
|
|
2808
2914
|
state.bindFramebuffer( gl.DRAW_FRAMEBUFFER, fb );
|
|
@@ -2837,7 +2943,9 @@ class WebGLBackend extends Backend {
|
|
|
2837
2943
|
/**
|
|
2838
2944
|
* Frees internal resources.
|
|
2839
2945
|
*/
|
|
2840
|
-
dispose() {
|
|
2946
|
+
async dispose() {
|
|
2947
|
+
|
|
2948
|
+
await super.dispose();
|
|
2841
2949
|
|
|
2842
2950
|
if ( this.textureUtils !== null ) this.textureUtils.dispose();
|
|
2843
2951
|
|
|
@@ -10,8 +10,6 @@ import { DataTexture } from '../../../textures/DataTexture.js';
|
|
|
10
10
|
import { error } from '../../../utils.js';
|
|
11
11
|
|
|
12
12
|
const glslPolyfills = {
|
|
13
|
-
bitcast_int_uint: new CodeNode( /* glsl */'uint tsl_bitcast_int_to_uint ( int x ) { return floatBitsToUint( intBitsToFloat ( x ) ); }' ),
|
|
14
|
-
bitcast_uint_int: new CodeNode( /* glsl */'uint tsl_bitcast_uint_to_int ( uint x ) { return floatBitsToInt( uintBitsToFloat ( x ) ); }' ),
|
|
15
13
|
textureGather: new CodeNode( /* glsl */`
|
|
16
14
|
vec4 tsl_textureGather( const int comp, sampler2D map, vec2 coord, ivec2 offset, bool flipY ) {
|
|
17
15
|
if ( flipY ) offset.y = - offset.y;
|
|
@@ -71,24 +69,29 @@ vec4 tsl_textureGatherCompare_array( sampler2DArrayShadow map, vec3 coord, ivec2
|
|
|
71
69
|
);
|
|
72
70
|
return flipY ? ret.wzyx : ret;
|
|
73
71
|
}
|
|
74
|
-
` )
|
|
72
|
+
` ),
|
|
73
|
+
floatpack_snorm_4x8: new CodeNode( /* glsl */'uint tsl_packSnorm4x8( vec4 v ) { uvec4 u = uvec4( ivec4( round( clamp( v, -1.0, 1.0 ) * 127.0 ) ) & 0xff ); return u.x | u.y << 8 | u.z << 16 | u.w << 24; }' ),
|
|
74
|
+
floatpack_unorm_4x8: new CodeNode( /* glsl */'uint tsl_packUnorm4x8( vec4 v ) { uvec4 u = uvec4( round( clamp( v, 0.0, 1.0 ) * 255.0 ) ); return u.x | u.y << 8 | u.z << 16 | u.w << 24; }' ),
|
|
75
|
+
floatunpack_snorm_4x8: new CodeNode( /* glsl */'vec4 tsl_unpackSnorm4x8( uint x ) { return max( vec4( ivec4( x << 24, x << 16, x << 8, x ) >> 24 ) / 127.0, -1.0 ); }' ),
|
|
76
|
+
floatunpack_unorm_4x8: new CodeNode( /* glsl */'vec4 tsl_unpackUnorm4x8( uint x ) { return vec4( uvec4( x, x >> 8, x >> 16, x >> 24 ) & 0xffu ) / 255.0; }' )
|
|
75
77
|
};
|
|
76
78
|
|
|
77
79
|
const glslMethods = {
|
|
78
|
-
textureDimensions: 'textureSize',
|
|
79
80
|
equals: 'equal',
|
|
80
81
|
bitcast_float_int: 'floatBitsToInt',
|
|
81
82
|
bitcast_int_float: 'intBitsToFloat',
|
|
82
83
|
bitcast_uint_float: 'uintBitsToFloat',
|
|
83
84
|
bitcast_float_uint: 'floatBitsToUint',
|
|
84
|
-
bitcast_uint_int: 'tsl_bitcast_uint_to_int',
|
|
85
|
-
bitcast_int_uint: 'tsl_bitcast_int_to_uint',
|
|
86
85
|
floatpack_snorm_2x16: 'packSnorm2x16',
|
|
87
86
|
floatpack_unorm_2x16: 'packUnorm2x16',
|
|
88
87
|
floatpack_float16_2x16: 'packHalf2x16',
|
|
88
|
+
floatpack_snorm_4x8: 'tsl_packSnorm4x8',
|
|
89
|
+
floatpack_unorm_4x8: 'tsl_packUnorm4x8',
|
|
89
90
|
floatunpack_snorm_2x16: 'unpackSnorm2x16',
|
|
90
91
|
floatunpack_unorm_2x16: 'unpackUnorm2x16',
|
|
91
|
-
floatunpack_float16_2x16: 'unpackHalf2x16'
|
|
92
|
+
floatunpack_float16_2x16: 'unpackHalf2x16',
|
|
93
|
+
floatunpack_snorm_4x8: 'tsl_unpackSnorm4x8',
|
|
94
|
+
floatunpack_unorm_4x8: 'tsl_unpackUnorm4x8'
|
|
92
95
|
};
|
|
93
96
|
|
|
94
97
|
const precisionLib = {
|
|
@@ -134,6 +137,30 @@ precision highp sampler2DArrayShadow;
|
|
|
134
137
|
precision highp samplerCubeShadow;
|
|
135
138
|
`;
|
|
136
139
|
|
|
140
|
+
const glslReservedKeywords = new Set( [
|
|
141
|
+
// keywords
|
|
142
|
+
'const', 'uniform', 'buffer', 'shared', 'attribute', 'varying', 'coherent', 'volatile', 'restrict',
|
|
143
|
+
'readonly', 'writeonly', 'atomic_uint', 'layout', 'centroid', 'flat', 'smooth', 'noperspective',
|
|
144
|
+
'patch', 'sample', 'invariant', 'precise', 'break', 'continue', 'do', 'for', 'while', 'switch',
|
|
145
|
+
'case', 'default', 'if', 'else', 'subroutine', 'in', 'out', 'inout', 'int', 'void', 'bool', 'true',
|
|
146
|
+
'false', 'float', 'double', 'discard', 'return', 'vec2', 'vec3', 'vec4', 'ivec2', 'ivec3', 'ivec4',
|
|
147
|
+
'bvec2', 'bvec3', 'bvec4', 'uint', 'uvec2', 'uvec3', 'uvec4', 'dvec2', 'dvec3', 'dvec4', 'mat2',
|
|
148
|
+
'mat3', 'mat4', 'mat2x2', 'mat2x3', 'mat2x4', 'mat3x2', 'mat3x3', 'mat3x4', 'mat4x2', 'mat4x3',
|
|
149
|
+
'mat4x4', 'dmat2', 'dmat3', 'dmat4', 'dmat2x2', 'dmat2x3', 'dmat2x4', 'dmat3x2', 'dmat3x3',
|
|
150
|
+
'dmat3x4', 'dmat4x2', 'dmat4x3', 'dmat4x4', 'lowp', 'mediump', 'highp', 'precision', 'sampler2D',
|
|
151
|
+
'sampler3D', 'samplerCube', 'sampler2DShadow', 'samplerCubeShadow', 'sampler2DArray',
|
|
152
|
+
'sampler2DArrayShadow', 'isampler2D', 'isampler3D', 'isamplerCube', 'isampler2DArray', 'usampler2D',
|
|
153
|
+
'usampler3D', 'usamplerCube', 'usampler2DArray', 'struct',
|
|
154
|
+
// reserved for future use
|
|
155
|
+
'common', 'partition', 'active', 'asm', 'class', 'union', 'enum', 'typedef', 'template', 'this',
|
|
156
|
+
'resource', 'goto', 'inline', 'noinline', 'public', 'static', 'extern', 'external', 'interface',
|
|
157
|
+
'long', 'short', 'half', 'fixed', 'unsigned', 'superp', 'input', 'output', 'hvec2', 'hvec3',
|
|
158
|
+
'hvec4', 'fvec2', 'fvec3', 'fvec4', 'sampler3DRect', 'filter', 'sizeof', 'cast', 'namespace',
|
|
159
|
+
'using',
|
|
160
|
+
// generated entry points
|
|
161
|
+
'main'
|
|
162
|
+
] );
|
|
163
|
+
|
|
137
164
|
/**
|
|
138
165
|
* A node builder targeting GLSL.
|
|
139
166
|
*
|
|
@@ -246,7 +273,19 @@ class GLSLNodeBuilder extends NodeBuilder {
|
|
|
246
273
|
*/
|
|
247
274
|
getBitcastMethod( type, inputType ) {
|
|
248
275
|
|
|
249
|
-
|
|
276
|
+
const inputComponentType = this.getComponentType( inputType );
|
|
277
|
+
const componentType = this.getComponentType( type );
|
|
278
|
+
|
|
279
|
+
// integer types support bitcast implicitly via the type constructor
|
|
280
|
+
|
|
281
|
+
if ( inputComponentType !== 'float' && componentType !== 'float' &&
|
|
282
|
+
this.getTypeLength( inputType ) === this.getTypeLength( type ) ) {
|
|
283
|
+
|
|
284
|
+
return this.getType( type );
|
|
285
|
+
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
return this.getMethod( `bitcast_${ inputComponentType }_${ componentType }` );
|
|
250
289
|
|
|
251
290
|
}
|
|
252
291
|
|
|
@@ -254,11 +293,12 @@ class GLSLNodeBuilder extends NodeBuilder {
|
|
|
254
293
|
* Returns the float packing method name for a given numeric encoding.
|
|
255
294
|
*
|
|
256
295
|
* @param {string} encoding - The numeric encoding that describes how the float values are mapped to the integer range.
|
|
296
|
+
* @param {string} [layout='2x16'] - The component layout of the packed integer.
|
|
257
297
|
* @returns {string} The resolved GLSL float packing method name.
|
|
258
298
|
*/
|
|
259
|
-
getFloatPackingMethod( encoding ) {
|
|
299
|
+
getFloatPackingMethod( encoding, layout = '2x16' ) {
|
|
260
300
|
|
|
261
|
-
return this.getMethod( `floatpack_${ encoding }
|
|
301
|
+
return this.getMethod( `floatpack_${ encoding }_${ layout }` );
|
|
262
302
|
|
|
263
303
|
}
|
|
264
304
|
|
|
@@ -266,11 +306,12 @@ class GLSLNodeBuilder extends NodeBuilder {
|
|
|
266
306
|
* Returns the float unpacking method name for a given numeric encoding.
|
|
267
307
|
*
|
|
268
308
|
* @param {string} encoding - The numeric encoding that describes how the integer values are mapped to the float range.
|
|
309
|
+
* @param {string} [layout='2x16'] - The component layout of the packed integer.
|
|
269
310
|
* @returns {string} The resolved GLSL float unpacking method name.
|
|
270
311
|
*/
|
|
271
|
-
getFloatUnpackingMethod( encoding ) {
|
|
312
|
+
getFloatUnpackingMethod( encoding, layout = '2x16' ) {
|
|
272
313
|
|
|
273
|
-
return this.getMethod( `floatunpack_${ encoding }
|
|
314
|
+
return this.getMethod( `floatunpack_${ encoding }_${ layout }` );
|
|
274
315
|
|
|
275
316
|
}
|
|
276
317
|
|
|
@@ -428,6 +469,18 @@ ${ flowData.code }
|
|
|
428
469
|
|
|
429
470
|
}
|
|
430
471
|
|
|
472
|
+
/**
|
|
473
|
+
* Returns whether the given name is a reserved keyword of GLSL.
|
|
474
|
+
*
|
|
475
|
+
* @param {string} name - The name to test.
|
|
476
|
+
* @return {boolean} Whether the name is a reserved keyword or not.
|
|
477
|
+
*/
|
|
478
|
+
isReservedKeyword( name ) {
|
|
479
|
+
|
|
480
|
+
return glslReservedKeywords.has( name );
|
|
481
|
+
|
|
482
|
+
}
|
|
483
|
+
|
|
431
484
|
/**
|
|
432
485
|
* Setups the Pixel Buffer Object (PBO) for the given storage
|
|
433
486
|
* buffer node.
|
|
@@ -598,6 +651,20 @@ ${ flowData.code }
|
|
|
598
651
|
|
|
599
652
|
}
|
|
600
653
|
|
|
654
|
+
/**
|
|
655
|
+
* Generates the GLSL snippet that resolves the dimensions of the given texture.
|
|
656
|
+
*
|
|
657
|
+
* @param {Texture} texture - The texture.
|
|
658
|
+
* @param {string} textureProperty - The name of the texture uniform in the shader.
|
|
659
|
+
* @param {string} levelSnippet - A GLSL snippet that represents the mip level.
|
|
660
|
+
* @return {string} The GLSL snippet.
|
|
661
|
+
*/
|
|
662
|
+
generateTextureSize( texture, textureProperty, levelSnippet ) {
|
|
663
|
+
|
|
664
|
+
return `textureSize( ${ textureProperty }, ${ levelSnippet } )`;
|
|
665
|
+
|
|
666
|
+
}
|
|
667
|
+
|
|
601
668
|
/**
|
|
602
669
|
* Generates the GLSL snippet when sampling textures with explicit mip level.
|
|
603
670
|
*
|
|
@@ -814,27 +881,14 @@ ${ flowData.code }
|
|
|
814
881
|
const textureNode = uniform.node;
|
|
815
882
|
const texture = textureNode.value;
|
|
816
883
|
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
if ( texture.isDataTexture === true || texture.isData3DTexture === true ) {
|
|
820
|
-
|
|
821
|
-
if ( texture.type === UnsignedIntType ) {
|
|
822
|
-
|
|
823
|
-
typePrefix = 'u';
|
|
824
|
-
|
|
825
|
-
} else if ( texture.type === IntType ) {
|
|
826
|
-
|
|
827
|
-
typePrefix = 'i';
|
|
828
|
-
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
}
|
|
884
|
+
const componentType = this.getComponentTypeFromTexture( texture );
|
|
885
|
+
const typePrefix = componentType === 'float' ? '' : componentType.charAt( 0 );
|
|
832
886
|
|
|
833
887
|
if ( uniform.type === 'texture3D' && texture.isArrayTexture === false ) {
|
|
834
888
|
|
|
835
889
|
snippet = `${typePrefix}sampler3D ${ uniform.name };`;
|
|
836
890
|
|
|
837
|
-
} else if ( texture.compareFunction && textureNode.
|
|
891
|
+
} else if ( texture.compareFunction && textureNode.isSampleCompare() ) {
|
|
838
892
|
|
|
839
893
|
if ( texture.isArrayTexture === true ) {
|
|
840
894
|
|
|
@@ -1198,7 +1252,7 @@ ${ flowData.code }
|
|
|
1198
1252
|
*/
|
|
1199
1253
|
getInvocationLocalIndex() {
|
|
1200
1254
|
|
|
1201
|
-
const workgroupSize = this.
|
|
1255
|
+
const workgroupSize = this.compute.workgroupSize;
|
|
1202
1256
|
|
|
1203
1257
|
const size = workgroupSize.reduce( ( acc, curr ) => acc * curr, 1 );
|
|
1204
1258
|
|