@plastic-software/three 0.179.0 → 0.181.1
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 +1108 -591
- package/build/three.core.js +616 -345
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +488 -250
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +37 -6
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +6576 -2152
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +6575 -2151
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/fonts/MPLUSRounded1c/MPLUSRounded1c-Regular.typeface.json.zip +0 -0
- package/examples/fonts/MPLUSRounded1c/OFL.txt +91 -0
- package/examples/jsm/Addons.js +1 -1
- package/examples/jsm/animation/CCDIKSolver.js +1 -1
- package/examples/jsm/controls/ArcballControls.js +8 -8
- package/examples/jsm/controls/DragControls.js +7 -57
- package/examples/jsm/controls/FirstPersonControls.js +3 -3
- package/examples/jsm/controls/FlyControls.js +1 -1
- package/examples/jsm/controls/OrbitControls.js +2 -2
- package/examples/jsm/controls/PointerLockControls.js +2 -10
- package/examples/jsm/controls/TrackballControls.js +1 -1
- package/examples/jsm/controls/TransformControls.js +1 -1
- package/examples/jsm/effects/AsciiEffect.js +8 -8
- package/examples/jsm/exporters/DRACOExporter.js +2 -2
- package/examples/jsm/exporters/EXRExporter.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +33 -25
- package/examples/jsm/exporters/KTX2Exporter.js +4 -2
- package/examples/jsm/exporters/PLYExporter.js +1 -1
- package/examples/jsm/exporters/USDZExporter.js +9 -2
- package/examples/jsm/geometries/DecalGeometry.js +2 -2
- package/examples/jsm/geometries/ParametricGeometry.js +1 -1
- package/examples/jsm/geometries/TeapotGeometry.js +2 -2
- package/examples/jsm/geometries/TextGeometry.js +3 -2
- package/examples/jsm/gpgpu/BitonicSort.js +715 -0
- package/examples/jsm/helpers/ViewHelper.js +43 -5
- package/examples/jsm/inspector/Inspector.js +427 -0
- package/examples/jsm/inspector/RendererInspector.js +415 -0
- package/examples/jsm/inspector/tabs/Console.js +204 -0
- package/examples/jsm/inspector/tabs/Parameters.js +332 -0
- package/examples/jsm/inspector/tabs/Performance.js +268 -0
- package/examples/jsm/inspector/tabs/Viewer.js +166 -0
- package/examples/jsm/inspector/ui/Graph.js +95 -0
- package/examples/jsm/inspector/ui/Item.js +170 -0
- package/examples/jsm/inspector/ui/List.js +75 -0
- package/examples/jsm/inspector/ui/Profiler.js +170 -0
- package/examples/jsm/inspector/ui/Style.js +654 -0
- package/examples/jsm/inspector/ui/Tab.js +46 -0
- package/examples/jsm/inspector/ui/Values.js +423 -0
- package/examples/jsm/inspector/ui/utils.js +56 -0
- package/examples/jsm/interactive/HTMLMesh.js +6 -10
- package/examples/jsm/interactive/InteractiveGroup.js +1 -1
- package/examples/jsm/interactive/SelectionBox.js +30 -0
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +1 -1
- package/examples/jsm/lines/Line2.js +3 -3
- package/examples/jsm/lines/LineGeometry.js +1 -1
- package/examples/jsm/lines/LineSegments2.js +2 -2
- package/examples/jsm/lines/Wireframe.js +2 -2
- package/examples/jsm/lines/WireframeGeometry2.js +1 -1
- package/examples/jsm/lines/webgpu/LineSegments2.js +1 -1
- package/examples/jsm/lines/webgpu/Wireframe.js +1 -1
- package/examples/jsm/loaders/3MFLoader.js +1 -1
- package/examples/jsm/loaders/ColladaLoader.js +3 -3
- package/examples/jsm/loaders/DDSLoader.js +1 -1
- package/examples/jsm/loaders/DRACOLoader.js +73 -22
- package/examples/jsm/loaders/EXRLoader.js +5 -5
- package/examples/jsm/loaders/FBXLoader.js +2 -2
- package/examples/jsm/loaders/FontLoader.js +23 -5
- package/examples/jsm/loaders/GLTFLoader.js +14 -8
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +5 -5
- package/examples/jsm/loaders/HDRLoader.js +486 -0
- package/examples/jsm/loaders/KTX2Loader.js +136 -49
- package/examples/jsm/loaders/KTXLoader.js +2 -2
- package/examples/jsm/loaders/LDrawLoader.js +1 -1
- package/examples/jsm/loaders/LUT3dlLoader.js +2 -2
- package/examples/jsm/loaders/LUTCubeLoader.js +1 -1
- package/examples/jsm/loaders/LWOLoader.js +2 -2
- package/examples/jsm/loaders/MaterialXLoader.js +22 -5
- package/examples/jsm/loaders/OBJLoader.js +1 -1
- package/examples/jsm/loaders/PDBLoader.js +1 -1
- package/examples/jsm/loaders/RGBELoader.js +7 -473
- package/examples/jsm/loaders/SVGLoader.js +2 -2
- package/examples/jsm/loaders/TTFLoader.js +4 -4
- package/examples/jsm/loaders/UltraHDRLoader.js +2 -2
- package/examples/jsm/loaders/lwo/IFFParser.js +1 -1
- package/examples/jsm/materials/WoodNodeMaterial.js +533 -0
- package/examples/jsm/math/ColorSpaces.js +19 -1
- package/examples/jsm/math/ConvexHull.js +3 -3
- package/examples/jsm/math/ImprovedNoise.js +1 -1
- package/examples/jsm/math/Lut.js +2 -2
- package/examples/jsm/math/SimplexNoise.js +1 -1
- package/examples/jsm/misc/MD2CharacterComplex.js +1 -1
- package/examples/jsm/misc/ProgressiveLightMap.js +9 -3
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +7 -1
- package/examples/jsm/misc/TubePainter.js +383 -40
- package/examples/jsm/misc/Volume.js +1 -1
- package/examples/jsm/modifiers/SimplifyModifier.js +1 -1
- package/examples/jsm/objects/ReflectorForSSRPass.js +1 -0
- package/examples/jsm/objects/Sky.js +1 -1
- package/examples/jsm/objects/SkyMesh.js +1 -1
- package/examples/jsm/objects/Water.js +3 -3
- package/examples/jsm/objects/WaterMesh.js +6 -6
- package/examples/jsm/postprocessing/GlitchPass.js +2 -2
- package/examples/jsm/postprocessing/OutlinePass.js +1 -1
- package/examples/jsm/postprocessing/SSRPass.js +37 -8
- package/examples/jsm/postprocessing/UnrealBloomPass.js +8 -6
- package/examples/jsm/renderers/CSS2DRenderer.js +16 -5
- package/examples/jsm/renderers/CSS3DRenderer.js +7 -6
- package/examples/jsm/renderers/SVGRenderer.js +1 -1
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +1 -1
- package/examples/jsm/shaders/AfterimageShader.js +1 -1
- package/examples/jsm/shaders/BleachBypassShader.js +1 -1
- package/examples/jsm/shaders/BokehShader.js +1 -1
- package/examples/jsm/shaders/BokehShader2.js +1 -1
- package/examples/jsm/shaders/DotScreenShader.js +1 -1
- package/examples/jsm/shaders/FocusShader.js +1 -1
- package/examples/jsm/shaders/GTAOShader.js +2 -2
- package/examples/jsm/shaders/GodRaysShader.js +1 -1
- package/examples/jsm/shaders/KaleidoShader.js +1 -1
- package/examples/jsm/shaders/PoissonDenoiseShader.js +2 -2
- package/examples/jsm/shaders/SSRShader.js +1 -1
- package/examples/jsm/shaders/SepiaShader.js +1 -1
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +1 -1
- package/examples/jsm/shaders/TriangleBlurShader.js +1 -1
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +1 -1
- package/examples/jsm/shaders/VignetteShader.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +22 -19
- package/examples/jsm/transpiler/TSLEncoder.js +9 -10
- package/examples/jsm/transpiler/WGSLEncoder.js +24 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +26 -24
- package/examples/jsm/tsl/display/AnamorphicNode.js +28 -4
- package/examples/jsm/tsl/display/BloomNode.js +7 -3
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +2 -1
- package/examples/jsm/tsl/display/DenoiseNode.js +2 -0
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +446 -90
- package/examples/jsm/tsl/display/GTAONode.js +53 -5
- package/examples/jsm/tsl/display/GaussianBlurNode.js +49 -35
- package/examples/jsm/tsl/display/OutlineNode.js +13 -2
- package/examples/jsm/tsl/display/SSGINode.js +654 -0
- package/examples/jsm/tsl/display/SSRNode.js +182 -65
- package/examples/jsm/tsl/display/SSSNode.js +488 -0
- package/examples/jsm/tsl/display/TRAANode.js +124 -7
- package/examples/jsm/tsl/display/boxBlur.js +65 -0
- package/examples/jsm/tsl/display/hashBlur.js +16 -18
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +21 -1
- package/examples/jsm/utils/BufferGeometryUtils.js +1 -1
- package/examples/jsm/utils/ShadowMapViewerGPU.js +12 -5
- package/examples/jsm/webxr/OculusHandModel.js +1 -1
- package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
- package/examples/jsm/webxr/XRHandModelFactory.js +2 -6
- package/package.json +5 -10
- package/src/Three.Core.js +4 -2
- package/src/Three.TSL.js +36 -5
- package/src/Three.WebGPU.Nodes.js +2 -0
- package/src/Three.WebGPU.js +2 -0
- package/src/animation/AnimationClip.js +20 -4
- package/src/animation/AnimationMixer.js +3 -3
- package/src/animation/AnimationObjectGroup.js +2 -1
- package/src/animation/KeyframeTrack.js +7 -6
- package/src/animation/PropertyBinding.js +12 -11
- package/src/audio/Audio.js +10 -9
- package/src/audio/PositionalAudio.js +1 -1
- package/src/cameras/OrthographicCamera.js +1 -1
- package/src/cameras/PerspectiveCamera.js +1 -1
- package/src/cameras/StereoCamera.js +2 -2
- package/src/constants.js +11 -3
- package/src/core/BufferGeometry.js +10 -10
- package/src/core/EventDispatcher.js +1 -1
- package/src/core/InterleavedBuffer.js +1 -1
- package/src/core/InterleavedBufferAttribute.js +3 -2
- package/src/core/Object3D.js +3 -2
- package/src/core/Raycaster.js +2 -1
- package/src/core/RenderTarget.js +10 -1
- package/src/extras/Controls.js +5 -4
- package/src/extras/DataUtils.js +2 -1
- package/src/extras/Earcut.js +6 -0
- package/src/extras/ImageUtils.js +2 -2
- package/src/extras/PMREMGenerator.js +268 -55
- package/src/extras/TextureUtils.js +2 -1
- package/src/extras/core/Curve.js +2 -1
- package/src/extras/core/Interpolations.js +7 -1
- package/src/extras/core/ShapePath.js +4 -4
- package/src/extras/lib/earcut.js +8 -8
- package/src/geometries/BoxGeometry.js +1 -0
- package/src/geometries/CapsuleGeometry.js +1 -0
- package/src/geometries/CircleGeometry.js +1 -0
- package/src/geometries/ConeGeometry.js +1 -0
- package/src/geometries/CylinderGeometry.js +1 -0
- package/src/geometries/DodecahedronGeometry.js +1 -0
- package/src/geometries/ExtrudeGeometry.js +8 -6
- package/src/geometries/IcosahedronGeometry.js +1 -0
- package/src/geometries/LatheGeometry.js +1 -0
- package/src/geometries/OctahedronGeometry.js +1 -0
- package/src/geometries/PlaneGeometry.js +1 -0
- package/src/geometries/RingGeometry.js +1 -0
- package/src/geometries/ShapeGeometry.js +1 -0
- package/src/geometries/SphereGeometry.js +1 -0
- package/src/geometries/TetrahedronGeometry.js +1 -0
- package/src/geometries/TorusGeometry.js +1 -0
- package/src/geometries/TorusKnotGeometry.js +1 -0
- package/src/geometries/TubeGeometry.js +1 -0
- package/src/helpers/CameraHelper.js +1 -1
- package/src/lights/webgpu/ProjectorLight.js +1 -1
- package/src/loaders/AnimationLoader.js +2 -1
- package/src/loaders/AudioLoader.js +2 -1
- package/src/loaders/BufferGeometryLoader.js +2 -2
- package/src/loaders/Cache.js +2 -2
- package/src/loaders/DataTextureLoader.js +1 -1
- package/src/loaders/FileLoader.js +3 -2
- package/src/loaders/ImageBitmapLoader.js +5 -4
- package/src/loaders/ImageLoader.js +1 -1
- package/src/loaders/Loader.js +3 -3
- package/src/loaders/LoadingManager.js +25 -3
- package/src/loaders/MaterialLoader.js +3 -2
- package/src/loaders/ObjectLoader.js +13 -13
- package/src/loaders/TextureLoader.js +1 -1
- package/src/loaders/nodes/NodeLoader.js +3 -2
- package/src/materials/Material.js +16 -3
- package/src/materials/MeshBasicMaterial.js +1 -0
- package/src/materials/MeshDepthMaterial.js +1 -0
- package/src/materials/MeshDistanceMaterial.js +1 -1
- package/src/materials/MeshLambertMaterial.js +2 -1
- package/src/materials/MeshMatcapMaterial.js +22 -0
- package/src/materials/MeshNormalMaterial.js +1 -0
- package/src/materials/MeshPhongMaterial.js +2 -1
- package/src/materials/MeshPhysicalMaterial.js +2 -1
- package/src/materials/MeshStandardMaterial.js +8 -7
- package/src/materials/MeshToonMaterial.js +1 -0
- package/src/materials/PointsMaterial.js +1 -1
- package/src/materials/ShaderMaterial.js +2 -2
- package/src/materials/nodes/Line2NodeMaterial.js +2 -2
- package/src/materials/nodes/MeshSSSNodeMaterial.js +1 -1
- package/src/materials/nodes/NodeMaterial.js +62 -22
- package/src/materials/nodes/PointsNodeMaterial.js +81 -28
- package/src/materials/nodes/SpriteNodeMaterial.js +3 -15
- package/src/materials/nodes/manager/NodeMaterialObserver.js +3 -2
- package/src/math/Color.js +6 -5
- package/src/math/ColorManagement.js +9 -3
- package/src/math/Cylindrical.js +1 -1
- package/src/math/Euler.js +2 -1
- package/src/math/MathUtils.js +13 -11
- package/src/math/Matrix2.js +1 -1
- package/src/math/Matrix3.js +2 -2
- package/src/math/Matrix4.js +7 -7
- package/src/math/Plane.js +1 -1
- package/src/math/Quaternion.js +68 -66
- package/src/math/Spherical.js +1 -1
- package/src/nodes/Nodes.js +4 -1
- package/src/nodes/TSL.js +4 -1
- package/src/nodes/accessors/BufferNode.js +1 -1
- package/src/nodes/accessors/Camera.js +133 -7
- package/src/nodes/accessors/ClippingNode.js +6 -5
- package/src/nodes/accessors/CubeTextureNode.js +5 -4
- package/src/nodes/accessors/InstanceNode.js +25 -5
- package/src/nodes/accessors/Lights.js +10 -0
- package/src/nodes/accessors/Normal.js +5 -4
- package/src/nodes/accessors/Object3DNode.js +1 -1
- package/src/nodes/accessors/Position.js +18 -2
- package/src/nodes/accessors/ReferenceBaseNode.js +1 -1
- package/src/nodes/accessors/ReferenceNode.js +3 -2
- package/src/nodes/accessors/SceneNode.js +2 -1
- package/src/nodes/accessors/StorageBufferNode.js +2 -1
- package/src/nodes/accessors/StorageTextureNode.js +22 -0
- package/src/nodes/accessors/Texture3DNode.js +14 -1
- package/src/nodes/accessors/TextureNode.js +130 -44
- package/src/nodes/code/FunctionCallNode.js +24 -4
- package/src/nodes/code/FunctionNode.js +23 -0
- package/src/nodes/core/ArrayNode.js +1 -0
- package/src/nodes/core/AssignNode.js +4 -3
- package/src/nodes/core/AttributeNode.js +2 -1
- package/src/nodes/core/ContextNode.js +29 -10
- package/src/nodes/core/IndexNode.js +2 -2
- package/src/nodes/core/InputNode.js +2 -1
- package/src/nodes/core/InspectorNode.js +128 -0
- package/src/nodes/core/{CacheNode.js → IsolateNode.js} +40 -7
- package/src/nodes/core/Node.js +152 -31
- package/src/nodes/core/NodeBuilder.js +183 -35
- package/src/nodes/core/NodeFrame.js +21 -21
- package/src/nodes/core/NodeFunction.js +2 -1
- package/src/nodes/core/NodeParser.js +2 -1
- package/src/nodes/core/NodeUniform.js +1 -1
- package/src/nodes/core/NodeUtils.js +17 -91
- package/src/nodes/core/ParameterNode.js +31 -0
- package/src/nodes/core/PropertyNode.js +7 -0
- package/src/nodes/core/StackNode.js +43 -16
- package/src/nodes/core/StructNode.js +5 -5
- package/src/nodes/core/StructTypeNode.js +1 -0
- package/src/nodes/core/SubBuildNode.js +2 -2
- package/src/nodes/core/UniformNode.js +18 -10
- package/src/nodes/core/VarNode.js +70 -33
- package/src/nodes/core/VaryingNode.js +3 -2
- package/src/nodes/display/BlendModes.js +5 -4
- package/src/nodes/display/BumpMapNode.js +1 -1
- package/src/nodes/display/ColorAdjustment.js +1 -1
- package/src/nodes/display/FrontFacingNode.js +4 -8
- package/src/nodes/display/NormalMapNode.js +2 -1
- package/src/nodes/display/PassNode.js +52 -11
- package/src/nodes/display/RenderOutputNode.js +28 -2
- package/src/nodes/display/ScreenNode.js +44 -14
- package/src/nodes/display/ToneMappingNode.js +31 -4
- package/src/nodes/display/ToonOutlinePassNode.js +8 -0
- package/src/nodes/display/ViewportDepthTextureNode.js +16 -4
- package/src/nodes/display/ViewportSharedTextureNode.js +12 -0
- package/src/nodes/display/ViewportTextureNode.js +42 -12
- package/src/nodes/fog/Fog.js +3 -2
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +52 -0
- package/src/nodes/functions/BSDF/DFGApprox.js +60 -19
- package/src/nodes/functions/BasicLightingModel.js +2 -1
- package/src/nodes/functions/PhysicalLightingModel.js +3 -2
- package/src/nodes/functions/VolumetricLightingModel.js +5 -5
- package/src/nodes/geometry/RangeNode.js +40 -4
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +2 -1
- package/src/nodes/gpgpu/ComputeNode.js +17 -5
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +455 -0
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +2 -1
- package/src/nodes/lighting/EnvironmentNode.js +6 -6
- package/src/nodes/lighting/LightsNode.js +3 -4
- package/src/nodes/lighting/PointShadowNode.js +6 -0
- package/src/nodes/lighting/ShadowFilterNode.js +2 -0
- package/src/nodes/lighting/ShadowNode.js +75 -8
- package/src/nodes/math/BitcastNode.js +156 -0
- package/src/nodes/math/ConditionalNode.js +24 -7
- package/src/nodes/math/MathNode.js +25 -19
- package/src/nodes/math/OperatorNode.js +7 -5
- package/src/nodes/pmrem/PMREMUtils.js +117 -2
- package/src/nodes/shapes/Shapes.js +1 -1
- package/src/nodes/tsl/TSLBase.js +5 -2
- package/src/nodes/tsl/TSLCore.js +460 -159
- package/src/nodes/utils/DebugNode.js +2 -1
- package/src/nodes/utils/EventNode.js +36 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +37 -19
- package/src/nodes/utils/JoinNode.js +6 -3
- package/src/nodes/utils/LoopNode.js +20 -24
- package/src/nodes/utils/MemberNode.js +59 -7
- package/src/nodes/utils/PostProcessingUtils.js +28 -1
- package/src/nodes/utils/RTTNode.js +13 -3
- package/src/nodes/utils/ReflectorNode.js +58 -7
- package/src/nodes/utils/SampleNode.js +12 -2
- package/src/nodes/utils/SplitNode.js +11 -0
- package/src/nodes/utils/Timer.js +0 -47
- package/src/objects/BatchedMesh.js +2 -2
- package/src/objects/LOD.js +1 -1
- package/src/objects/Line.js +2 -1
- package/src/objects/LineSegments.js +2 -1
- package/src/objects/Skeleton.js +3 -2
- package/src/objects/SkinnedMesh.js +3 -1
- package/src/objects/Sprite.js +4 -3
- package/src/renderers/WebGLRenderer.js +48 -41
- package/src/renderers/common/Animation.js +13 -1
- package/src/renderers/common/Attributes.js +1 -1
- package/src/renderers/common/Backend.js +108 -27
- package/src/renderers/common/Background.js +2 -1
- package/src/renderers/common/Bindings.js +58 -2
- package/src/renderers/common/CanvasTarget.js +341 -0
- package/src/renderers/common/ChainMap.js +1 -1
- package/src/renderers/common/DataMap.js +1 -1
- package/src/renderers/common/Geometries.js +26 -0
- package/src/renderers/common/Info.js +4 -2
- package/src/renderers/common/InspectorBase.js +146 -0
- package/src/renderers/common/Pipelines.js +1 -1
- package/src/renderers/common/PostProcessing.js +6 -25
- package/src/renderers/common/QuadMesh.js +7 -1
- package/src/renderers/common/RenderContext.js +2 -2
- package/src/renderers/common/RenderList.js +7 -3
- package/src/renderers/common/RenderObject.js +16 -2
- package/src/renderers/common/RenderObjects.js +1 -1
- package/src/renderers/common/Renderer.js +473 -245
- package/src/renderers/common/RendererUtils.js +9 -0
- package/src/renderers/common/SampledTexture.js +9 -1
- package/src/renderers/common/Sampler.js +50 -12
- package/src/renderers/common/StorageTexture.js +9 -1
- package/src/renderers/common/Textures.js +121 -45
- package/src/renderers/common/TimestampQueryPool.js +65 -3
- package/src/renderers/common/UniformsGroup.js +2 -1
- package/src/renderers/common/XRManager.js +42 -22
- package/src/renderers/common/extras/PMREMGenerator.js +160 -65
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/NodeLibrary.js +9 -7
- package/src/renderers/common/nodes/NodeSampler.js +13 -1
- package/src/renderers/common/nodes/Nodes.js +38 -16
- package/src/renderers/shaders/DFGLUTData.js +64 -0
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -12
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +52 -18
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +7 -15
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +1 -1
- package/src/renderers/shaders/UniformsLib.js +1 -0
- package/src/renderers/shaders/UniformsUtils.js +25 -4
- package/src/renderers/webgl/WebGLCapabilities.js +2 -1
- package/src/renderers/webgl/WebGLExtensions.js +2 -25
- package/src/renderers/webgl/WebGLInfo.js +3 -1
- package/src/renderers/webgl/WebGLProgram.js +15 -14
- package/src/renderers/webgl/WebGLPrograms.js +2 -1
- package/src/renderers/webgl/WebGLShadowMap.js +3 -2
- package/src/renderers/webgl/WebGLState.js +15 -14
- package/src/renderers/webgl/WebGLTextures.js +19 -14
- package/src/renderers/webgl/WebGLUniformsGroups.js +5 -3
- package/src/renderers/webgl/WebGLUtils.js +3 -2
- package/src/renderers/webgl-fallback/WebGLBackend.js +199 -167
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +181 -25
- package/src/renderers/webgl-fallback/utils/WebGLConstants.js +2 -3
- package/src/renderers/webgl-fallback/utils/WebGLState.js +7 -6
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +169 -19
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +51 -22
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +3 -2
- package/src/renderers/webgpu/WebGPUBackend.js +153 -123
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +2 -1
- package/src/renderers/webgpu/WebGPURenderer.js +3 -2
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +142 -50
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +2 -1
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +5 -3
- package/src/renderers/webgpu/utils/WebGPUConstants.js +7 -2
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +53 -34
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +6 -8
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +260 -99
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +32 -9
- package/src/renderers/webgpu/utils/WebGPUUtils.js +22 -2
- package/src/renderers/webxr/WebXRManager.js +42 -26
- package/src/textures/ExternalTexture.js +15 -4
- package/src/textures/Source.js +3 -2
- package/src/textures/Texture.js +3 -2
- package/src/textures/VideoTexture.js +2 -3
- package/src/utils.js +67 -3
- package/examples/jsm/loaders/RGBMLoader.js +0 -1148
|
@@ -13,11 +13,12 @@ import {
|
|
|
13
13
|
RGBAFormat, RGBFormat, RedFormat, RGFormat, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, UnsignedByteType, FloatType, HalfFloatType, SRGBTransfer, DepthFormat, DepthStencilFormat,
|
|
14
14
|
RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format,
|
|
15
15
|
RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, UnsignedIntType, UnsignedShortType, UnsignedInt248Type, UnsignedInt5999Type,
|
|
16
|
-
NeverCompare, AlwaysCompare, LessCompare, LessEqualCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare, IntType, RedIntegerFormat, RGIntegerFormat, RGBAIntegerFormat
|
|
16
|
+
NeverCompare, AlwaysCompare, LessCompare, LessEqualCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare, IntType, RedIntegerFormat, RGIntegerFormat, RGBAIntegerFormat,
|
|
17
|
+
UnsignedInt101111Type, RGBA_BPTC_Format, RGB_ETC1_Format, RGB_S3TC_DXT1_Format, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format
|
|
17
18
|
} from '../../../constants.js';
|
|
18
19
|
import { CubeTexture } from '../../../textures/CubeTexture.js';
|
|
19
|
-
import { DepthTexture } from '../../../textures/DepthTexture.js';
|
|
20
20
|
import { Texture } from '../../../textures/Texture.js';
|
|
21
|
+
import { warn, error } from '../../../utils.js';
|
|
21
22
|
|
|
22
23
|
const _compareToWebGPU = {
|
|
23
24
|
[ NeverCompare ]: 'never',
|
|
@@ -86,20 +87,11 @@ class WebGPUTextureUtils {
|
|
|
86
87
|
this.defaultVideoFrame = null;
|
|
87
88
|
|
|
88
89
|
/**
|
|
89
|
-
*
|
|
90
|
+
* A cache of shared texture samplers.
|
|
90
91
|
*
|
|
91
|
-
* @type {
|
|
92
|
-
* @default null
|
|
93
|
-
*/
|
|
94
|
-
this.colorBuffer = null;
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Represents the depth attachment of the default framebuffer.
|
|
98
|
-
*
|
|
99
|
-
* @type {DepthTexture}
|
|
92
|
+
* @type {Map<string, Object>}
|
|
100
93
|
*/
|
|
101
|
-
this.
|
|
102
|
-
this.depthTexture.name = 'depthBuffer';
|
|
94
|
+
this._samplerCache = new Map();
|
|
103
95
|
|
|
104
96
|
}
|
|
105
97
|
|
|
@@ -107,39 +99,81 @@ class WebGPUTextureUtils {
|
|
|
107
99
|
* Creates a GPU sampler for the given texture.
|
|
108
100
|
*
|
|
109
101
|
* @param {Texture} texture - The texture to create the sampler for.
|
|
102
|
+
* @return {string} The current sampler key.
|
|
110
103
|
*/
|
|
111
|
-
|
|
104
|
+
updateSampler( texture ) {
|
|
112
105
|
|
|
113
106
|
const backend = this.backend;
|
|
114
|
-
const device = backend.device;
|
|
115
|
-
|
|
116
|
-
const textureGPU = backend.get( texture );
|
|
117
|
-
|
|
118
|
-
const samplerDescriptorGPU = {
|
|
119
|
-
addressModeU: this._convertAddressMode( texture.wrapS ),
|
|
120
|
-
addressModeV: this._convertAddressMode( texture.wrapT ),
|
|
121
|
-
addressModeW: this._convertAddressMode( texture.wrapR ),
|
|
122
|
-
magFilter: this._convertFilterMode( texture.magFilter ),
|
|
123
|
-
minFilter: this._convertFilterMode( texture.minFilter ),
|
|
124
|
-
mipmapFilter: this._convertFilterMode( texture.minFilter ),
|
|
125
|
-
maxAnisotropy: 1
|
|
126
|
-
};
|
|
127
107
|
|
|
128
|
-
|
|
108
|
+
const samplerKey = texture.minFilter + '-' + texture.magFilter + '-' +
|
|
109
|
+
texture.wrapS + '-' + texture.wrapT + '-' + ( texture.wrapR || '0' ) + '-' +
|
|
110
|
+
texture.anisotropy + '-' + ( texture.compareFunction || 0 );
|
|
111
|
+
|
|
112
|
+
let samplerData = this._samplerCache.get( samplerKey );
|
|
113
|
+
|
|
114
|
+
if ( samplerData === undefined ) {
|
|
115
|
+
|
|
116
|
+
const samplerDescriptorGPU = {
|
|
117
|
+
addressModeU: this._convertAddressMode( texture.wrapS ),
|
|
118
|
+
addressModeV: this._convertAddressMode( texture.wrapT ),
|
|
119
|
+
addressModeW: this._convertAddressMode( texture.wrapR ),
|
|
120
|
+
magFilter: this._convertFilterMode( texture.magFilter ),
|
|
121
|
+
minFilter: this._convertFilterMode( texture.minFilter ),
|
|
122
|
+
mipmapFilter: this._convertFilterMode( texture.minFilter ),
|
|
123
|
+
maxAnisotropy: 1
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
// anisotropy can only be used when all filter modes are set to linear.
|
|
127
|
+
|
|
128
|
+
if ( samplerDescriptorGPU.magFilter === GPUFilterMode.Linear && samplerDescriptorGPU.minFilter === GPUFilterMode.Linear && samplerDescriptorGPU.mipmapFilter === GPUFilterMode.Linear ) {
|
|
129
|
+
|
|
130
|
+
samplerDescriptorGPU.maxAnisotropy = texture.anisotropy;
|
|
131
|
+
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if ( texture.isDepthTexture && texture.compareFunction !== null ) {
|
|
135
|
+
|
|
136
|
+
samplerDescriptorGPU.compare = _compareToWebGPU[ texture.compareFunction ];
|
|
129
137
|
|
|
130
|
-
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const sampler = backend.device.createSampler( samplerDescriptorGPU );
|
|
131
141
|
|
|
132
|
-
|
|
142
|
+
samplerData = { sampler, usedTimes: 0 };
|
|
143
|
+
|
|
144
|
+
this._samplerCache.set( samplerKey, samplerData );
|
|
133
145
|
|
|
134
146
|
}
|
|
135
147
|
|
|
136
|
-
|
|
148
|
+
const textureData = backend.get( texture );
|
|
149
|
+
|
|
150
|
+
if ( textureData.sampler !== samplerData.sampler ) {
|
|
151
|
+
|
|
152
|
+
// check if previous sampler is unused so it can be deleted
|
|
153
|
+
|
|
154
|
+
if ( textureData.sampler !== undefined ) {
|
|
155
|
+
|
|
156
|
+
const oldSamplerData = this._samplerCache.get( textureData.samplerKey );
|
|
157
|
+
oldSamplerData.usedTimes --;
|
|
158
|
+
|
|
159
|
+
if ( oldSamplerData.usedTimes === 0 ) {
|
|
160
|
+
|
|
161
|
+
this._samplerCache.delete( textureData.samplerKey );
|
|
162
|
+
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// update to new sampler data
|
|
168
|
+
|
|
169
|
+
textureData.samplerKey = samplerKey;
|
|
170
|
+
textureData.sampler = samplerData.sampler;
|
|
137
171
|
|
|
138
|
-
|
|
172
|
+
samplerData.usedTimes ++;
|
|
139
173
|
|
|
140
174
|
}
|
|
141
175
|
|
|
142
|
-
|
|
176
|
+
return samplerKey;
|
|
143
177
|
|
|
144
178
|
}
|
|
145
179
|
|
|
@@ -186,6 +220,15 @@ class WebGPUTextureUtils {
|
|
|
186
220
|
|
|
187
221
|
}
|
|
188
222
|
|
|
223
|
+
if ( texture.isExternalTexture ) {
|
|
224
|
+
|
|
225
|
+
textureData.texture = texture.sourceTexture;
|
|
226
|
+
textureData.initialized = true;
|
|
227
|
+
|
|
228
|
+
return;
|
|
229
|
+
|
|
230
|
+
}
|
|
231
|
+
|
|
189
232
|
if ( options.needsMipmaps === undefined ) options.needsMipmaps = false;
|
|
190
233
|
if ( options.levels === undefined ) options.levels = 1;
|
|
191
234
|
if ( options.depth === undefined ) options.depth = 1;
|
|
@@ -221,7 +264,7 @@ class WebGPUTextureUtils {
|
|
|
221
264
|
|
|
222
265
|
}
|
|
223
266
|
|
|
224
|
-
if ( texture.isCompressedTexture !== true && texture.isCompressedArrayTexture !== true ) {
|
|
267
|
+
if ( texture.isCompressedTexture !== true && texture.isCompressedArrayTexture !== true && format !== GPUTextureFormat.RGB9E5UFloat ) {
|
|
225
268
|
|
|
226
269
|
usage |= GPUTextureUsage.RENDER_ATTACHMENT;
|
|
227
270
|
|
|
@@ -245,7 +288,7 @@ class WebGPUTextureUtils {
|
|
|
245
288
|
|
|
246
289
|
if ( format === undefined ) {
|
|
247
290
|
|
|
248
|
-
|
|
291
|
+
warn( 'WebGPURenderer: Texture format not supported.' );
|
|
249
292
|
|
|
250
293
|
this.createDefaultTexture( texture );
|
|
251
294
|
return;
|
|
@@ -266,6 +309,7 @@ class WebGPUTextureUtils {
|
|
|
266
309
|
|
|
267
310
|
msaaTextureDescriptorGPU.label = msaaTextureDescriptorGPU.label + '-msaa';
|
|
268
311
|
msaaTextureDescriptorGPU.sampleCount = samples;
|
|
312
|
+
msaaTextureDescriptorGPU.mipLevelCount = 1; // See https://www.w3.org/TR/webgpu/#texture-creation
|
|
269
313
|
|
|
270
314
|
textureData.msaaTexture = backend.device.createTexture( msaaTextureDescriptorGPU );
|
|
271
315
|
|
|
@@ -281,13 +325,14 @@ class WebGPUTextureUtils {
|
|
|
281
325
|
* Destroys the GPU data for the given texture object.
|
|
282
326
|
*
|
|
283
327
|
* @param {Texture} texture - The texture.
|
|
328
|
+
* @param {boolean} [isDefaultTexture=false] - Whether the texture uses a default GPU texture or not.
|
|
284
329
|
*/
|
|
285
|
-
destroyTexture( texture ) {
|
|
330
|
+
destroyTexture( texture, isDefaultTexture = false ) {
|
|
286
331
|
|
|
287
332
|
const backend = this.backend;
|
|
288
333
|
const textureData = backend.get( texture );
|
|
289
334
|
|
|
290
|
-
if ( textureData.texture !== undefined ) textureData.texture.destroy();
|
|
335
|
+
if ( textureData.texture !== undefined && isDefaultTexture === false ) textureData.texture.destroy();
|
|
291
336
|
|
|
292
337
|
if ( textureData.msaaTexture !== undefined ) textureData.msaaTexture.destroy();
|
|
293
338
|
|
|
@@ -295,26 +340,13 @@ class WebGPUTextureUtils {
|
|
|
295
340
|
|
|
296
341
|
}
|
|
297
342
|
|
|
298
|
-
/**
|
|
299
|
-
* Destroys the GPU sampler for the given texture.
|
|
300
|
-
*
|
|
301
|
-
* @param {Texture} texture - The texture to destroy the sampler for.
|
|
302
|
-
*/
|
|
303
|
-
destroySampler( texture ) {
|
|
304
|
-
|
|
305
|
-
const backend = this.backend;
|
|
306
|
-
const textureData = backend.get( texture );
|
|
307
|
-
|
|
308
|
-
delete textureData.sampler;
|
|
309
|
-
|
|
310
|
-
}
|
|
311
|
-
|
|
312
343
|
/**
|
|
313
344
|
* Generates mipmaps for the given texture.
|
|
314
345
|
*
|
|
315
346
|
* @param {Texture} texture - The texture.
|
|
347
|
+
* @param {?GPUCommandEncoder} [encoder=null] - An optional command encoder used to generate mipmaps.
|
|
316
348
|
*/
|
|
317
|
-
generateMipmaps( texture ) {
|
|
349
|
+
generateMipmaps( texture, encoder = null ) {
|
|
318
350
|
|
|
319
351
|
const textureData = this.backend.get( texture );
|
|
320
352
|
|
|
@@ -322,7 +354,7 @@ class WebGPUTextureUtils {
|
|
|
322
354
|
|
|
323
355
|
for ( let i = 0; i < 6; i ++ ) {
|
|
324
356
|
|
|
325
|
-
this._generateMipmaps( textureData.texture, textureData.textureDescriptorGPU, i );
|
|
357
|
+
this._generateMipmaps( textureData.texture, textureData.textureDescriptorGPU, i, encoder );
|
|
326
358
|
|
|
327
359
|
}
|
|
328
360
|
|
|
@@ -332,7 +364,7 @@ class WebGPUTextureUtils {
|
|
|
332
364
|
|
|
333
365
|
for ( let i = 0; i < depth; i ++ ) {
|
|
334
366
|
|
|
335
|
-
this._generateMipmaps( textureData.texture, textureData.textureDescriptorGPU, i );
|
|
367
|
+
this._generateMipmaps( textureData.texture, textureData.textureDescriptorGPU, i, encoder );
|
|
336
368
|
|
|
337
369
|
}
|
|
338
370
|
|
|
@@ -348,24 +380,47 @@ class WebGPUTextureUtils {
|
|
|
348
380
|
*/
|
|
349
381
|
getColorBuffer() {
|
|
350
382
|
|
|
351
|
-
if ( this.colorBuffer ) this.colorBuffer.destroy();
|
|
352
|
-
|
|
353
383
|
const backend = this.backend;
|
|
384
|
+
const canvasTarget = backend.renderer.getCanvasTarget();
|
|
354
385
|
const { width, height } = backend.getDrawingBufferSize();
|
|
386
|
+
const samples = backend.renderer.currentSamples;
|
|
387
|
+
|
|
388
|
+
const colorTexture = canvasTarget.colorTexture;
|
|
389
|
+
const colorTextureData = backend.get( colorTexture );
|
|
390
|
+
|
|
391
|
+
if ( colorTexture.width === width && colorTexture.height === height && colorTexture.samples === samples ) {
|
|
392
|
+
|
|
393
|
+
return colorTextureData.texture;
|
|
394
|
+
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// recreate
|
|
398
|
+
|
|
399
|
+
let colorBuffer = colorTextureData.texture;
|
|
355
400
|
|
|
356
|
-
|
|
401
|
+
if ( colorBuffer ) colorBuffer.destroy();
|
|
402
|
+
|
|
403
|
+
colorBuffer = backend.device.createTexture( {
|
|
357
404
|
label: 'colorBuffer',
|
|
358
405
|
size: {
|
|
359
406
|
width: width,
|
|
360
407
|
height: height,
|
|
361
408
|
depthOrArrayLayers: 1
|
|
362
409
|
},
|
|
363
|
-
sampleCount: backend.utils.getSampleCount( backend.renderer.
|
|
410
|
+
sampleCount: backend.utils.getSampleCount( backend.renderer.currentSamples ),
|
|
364
411
|
format: backend.utils.getPreferredCanvasFormat(),
|
|
365
412
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC
|
|
366
413
|
} );
|
|
367
414
|
|
|
368
|
-
|
|
415
|
+
//
|
|
416
|
+
|
|
417
|
+
colorTexture.source.width = width;
|
|
418
|
+
colorTexture.source.height = height;
|
|
419
|
+
colorTexture.samples = samples;
|
|
420
|
+
|
|
421
|
+
colorTextureData.texture = colorBuffer;
|
|
422
|
+
|
|
423
|
+
return colorBuffer;
|
|
369
424
|
|
|
370
425
|
}
|
|
371
426
|
|
|
@@ -380,9 +435,24 @@ class WebGPUTextureUtils {
|
|
|
380
435
|
getDepthBuffer( depth = true, stencil = false ) {
|
|
381
436
|
|
|
382
437
|
const backend = this.backend;
|
|
438
|
+
const canvasTarget = backend.renderer.getCanvasTarget();
|
|
383
439
|
const { width, height } = backend.getDrawingBufferSize();
|
|
440
|
+
const samples = backend.renderer.currentSamples;
|
|
441
|
+
|
|
442
|
+
const depthTexture = canvasTarget.depthTexture;
|
|
443
|
+
|
|
444
|
+
if ( depthTexture.width === width &&
|
|
445
|
+
depthTexture.height === height &&
|
|
446
|
+
depthTexture.samples === samples &&
|
|
447
|
+
depthTexture.depth === depth &&
|
|
448
|
+
depthTexture.stencil === stencil ) {
|
|
449
|
+
|
|
450
|
+
return backend.get( depthTexture ).texture;
|
|
451
|
+
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
//
|
|
384
455
|
|
|
385
|
-
const depthTexture = this.depthTexture;
|
|
386
456
|
const depthTextureGPU = backend.get( depthTexture ).texture;
|
|
387
457
|
|
|
388
458
|
let format, type;
|
|
@@ -401,7 +471,7 @@ class WebGPUTextureUtils {
|
|
|
401
471
|
|
|
402
472
|
if ( depthTextureGPU !== undefined ) {
|
|
403
473
|
|
|
404
|
-
if ( depthTexture.image.width === width && depthTexture.image.height === height && depthTexture.format === format && depthTexture.type === type ) {
|
|
474
|
+
if ( depthTexture.image.width === width && depthTexture.image.height === height && depthTexture.format === format && depthTexture.type === type && depthTexture.samples === samples ) {
|
|
405
475
|
|
|
406
476
|
return depthTextureGPU;
|
|
407
477
|
|
|
@@ -411,11 +481,14 @@ class WebGPUTextureUtils {
|
|
|
411
481
|
|
|
412
482
|
}
|
|
413
483
|
|
|
484
|
+
// recreate
|
|
485
|
+
|
|
414
486
|
depthTexture.name = 'depthBuffer';
|
|
415
487
|
depthTexture.format = format;
|
|
416
488
|
depthTexture.type = type;
|
|
417
489
|
depthTexture.image.width = width;
|
|
418
490
|
depthTexture.image.height = height;
|
|
491
|
+
depthTexture.samples = samples;
|
|
419
492
|
|
|
420
493
|
this.createTexture( depthTexture, { width, height } );
|
|
421
494
|
|
|
@@ -432,6 +505,7 @@ class WebGPUTextureUtils {
|
|
|
432
505
|
updateTexture( texture, options ) {
|
|
433
506
|
|
|
434
507
|
const textureData = this.backend.get( texture );
|
|
508
|
+
const mipmaps = texture.mipmaps;
|
|
435
509
|
|
|
436
510
|
const { textureDescriptorGPU } = textureData;
|
|
437
511
|
|
|
@@ -442,7 +516,22 @@ class WebGPUTextureUtils {
|
|
|
442
516
|
|
|
443
517
|
if ( texture.isDataTexture ) {
|
|
444
518
|
|
|
445
|
-
|
|
519
|
+
if ( mipmaps.length > 0 ) {
|
|
520
|
+
|
|
521
|
+
for ( let i = 0, il = mipmaps.length; i < il; i ++ ) {
|
|
522
|
+
|
|
523
|
+
const mipmap = mipmaps[ i ];
|
|
524
|
+
|
|
525
|
+
this._copyBufferToTexture( mipmap, textureData.texture, textureDescriptorGPU, 0, texture.flipY, 0, i );
|
|
526
|
+
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
} else {
|
|
531
|
+
|
|
532
|
+
this._copyBufferToTexture( options.image, textureData.texture, textureDescriptorGPU, 0, texture.flipY );
|
|
533
|
+
|
|
534
|
+
}
|
|
446
535
|
|
|
447
536
|
} else if ( texture.isArrayTexture || texture.isDataArrayTexture || texture.isData3DTexture ) {
|
|
448
537
|
|
|
@@ -458,11 +547,26 @@ class WebGPUTextureUtils {
|
|
|
458
547
|
|
|
459
548
|
} else if ( texture.isCubeTexture ) {
|
|
460
549
|
|
|
461
|
-
this._copyCubeMapToTexture(
|
|
550
|
+
this._copyCubeMapToTexture( texture, textureData.texture, textureDescriptorGPU );
|
|
462
551
|
|
|
463
552
|
} else {
|
|
464
553
|
|
|
465
|
-
|
|
554
|
+
if ( mipmaps.length > 0 ) {
|
|
555
|
+
|
|
556
|
+
for ( let i = 0, il = mipmaps.length; i < il; i ++ ) {
|
|
557
|
+
|
|
558
|
+
const mipmap = mipmaps[ i ];
|
|
559
|
+
|
|
560
|
+
this._copyImageToTexture( mipmap, textureData.texture, textureDescriptorGPU, 0, texture.flipY, texture.premultiplyAlpha, i );
|
|
561
|
+
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
} else {
|
|
566
|
+
|
|
567
|
+
this._copyImageToTexture( options.image, textureData.texture, textureDescriptorGPU, 0, texture.flipY, texture.premultiplyAlpha );
|
|
568
|
+
|
|
569
|
+
}
|
|
466
570
|
|
|
467
571
|
}
|
|
468
572
|
|
|
@@ -470,8 +574,6 @@ class WebGPUTextureUtils {
|
|
|
470
574
|
|
|
471
575
|
textureData.version = texture.version;
|
|
472
576
|
|
|
473
|
-
if ( texture.onUpdate ) texture.onUpdate( texture );
|
|
474
|
-
|
|
475
577
|
}
|
|
476
578
|
|
|
477
579
|
/**
|
|
@@ -500,7 +602,7 @@ class WebGPUTextureUtils {
|
|
|
500
602
|
|
|
501
603
|
const readBuffer = device.createBuffer(
|
|
502
604
|
{
|
|
503
|
-
size:
|
|
605
|
+
size: ( ( height - 1 ) * bytesPerRow ) + ( width * bytesPerTexel ), // see https://github.com/mrdoob/three.js/issues/31658#issuecomment-3229442010
|
|
504
606
|
usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ
|
|
505
607
|
}
|
|
506
608
|
);
|
|
@@ -535,6 +637,15 @@ class WebGPUTextureUtils {
|
|
|
535
637
|
|
|
536
638
|
}
|
|
537
639
|
|
|
640
|
+
/**
|
|
641
|
+
* Frees all internal resources.
|
|
642
|
+
*/
|
|
643
|
+
dispose() {
|
|
644
|
+
|
|
645
|
+
this._samplerCache.clear();
|
|
646
|
+
|
|
647
|
+
}
|
|
648
|
+
|
|
538
649
|
/**
|
|
539
650
|
* Returns the default GPU texture for the given format.
|
|
540
651
|
*
|
|
@@ -593,27 +704,46 @@ class WebGPUTextureUtils {
|
|
|
593
704
|
* Uploads cube texture image data to the GPU memory.
|
|
594
705
|
*
|
|
595
706
|
* @private
|
|
596
|
-
* @param {
|
|
707
|
+
* @param {CubeTexture} texture - The cube texture.
|
|
597
708
|
* @param {GPUTexture} textureGPU - The GPU texture.
|
|
598
709
|
* @param {Object} textureDescriptorGPU - The GPU texture descriptor.
|
|
599
|
-
* @param {boolean} flipY - Whether to flip texture data along their vertical axis or not.
|
|
600
|
-
* @param {boolean} premultiplyAlpha - Whether the texture should have its RGB channels premultiplied by the alpha channel or not.
|
|
601
710
|
*/
|
|
602
|
-
_copyCubeMapToTexture(
|
|
711
|
+
_copyCubeMapToTexture( texture, textureGPU, textureDescriptorGPU ) {
|
|
712
|
+
|
|
713
|
+
const images = texture.images;
|
|
714
|
+
const mipmaps = texture.mipmaps;
|
|
603
715
|
|
|
604
716
|
for ( let i = 0; i < 6; i ++ ) {
|
|
605
717
|
|
|
606
718
|
const image = images[ i ];
|
|
607
719
|
|
|
608
|
-
const flipIndex = flipY === true ? _flipMap[ i ] : i;
|
|
720
|
+
const flipIndex = texture.flipY === true ? _flipMap[ i ] : i;
|
|
609
721
|
|
|
610
722
|
if ( image.isDataTexture ) {
|
|
611
723
|
|
|
612
|
-
this._copyBufferToTexture( image.image, textureGPU, textureDescriptorGPU, flipIndex, flipY );
|
|
724
|
+
this._copyBufferToTexture( image.image, textureGPU, textureDescriptorGPU, flipIndex, texture.flipY );
|
|
613
725
|
|
|
614
726
|
} else {
|
|
615
727
|
|
|
616
|
-
this._copyImageToTexture( image, textureGPU, textureDescriptorGPU, flipIndex, flipY, premultiplyAlpha );
|
|
728
|
+
this._copyImageToTexture( image, textureGPU, textureDescriptorGPU, flipIndex, texture.flipY, texture.premultiplyAlpha );
|
|
729
|
+
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
for ( let j = 0; j < mipmaps.length; j ++ ) {
|
|
733
|
+
|
|
734
|
+
const mipmap = mipmaps[ j ];
|
|
735
|
+
const image = mipmap.images[ i ];
|
|
736
|
+
|
|
737
|
+
if ( image.isDataTexture ) {
|
|
738
|
+
|
|
739
|
+
this._copyBufferToTexture( image.image, textureGPU, textureDescriptorGPU, flipIndex, texture.flipY, 0, j + 1 );
|
|
740
|
+
|
|
741
|
+
} else {
|
|
742
|
+
|
|
743
|
+
this._copyImageToTexture( image, textureGPU, textureDescriptorGPU, flipIndex, texture.flipY, texture.premultiplyAlpha, j + 1 );
|
|
744
|
+
|
|
745
|
+
}
|
|
746
|
+
|
|
617
747
|
|
|
618
748
|
}
|
|
619
749
|
|
|
@@ -631,23 +761,27 @@ class WebGPUTextureUtils {
|
|
|
631
761
|
* @param {number} originDepth - The origin depth.
|
|
632
762
|
* @param {boolean} flipY - Whether to flip texture data along their vertical axis or not.
|
|
633
763
|
* @param {boolean} premultiplyAlpha - Whether the texture should have its RGB channels premultiplied by the alpha channel or not.
|
|
764
|
+
* @param {number} [mipLevel=0] - The mip level where the data should be copied to.
|
|
634
765
|
*/
|
|
635
|
-
_copyImageToTexture( image, textureGPU, textureDescriptorGPU, originDepth, flipY, premultiplyAlpha ) {
|
|
766
|
+
_copyImageToTexture( image, textureGPU, textureDescriptorGPU, originDepth, flipY, premultiplyAlpha, mipLevel = 0 ) {
|
|
636
767
|
|
|
637
768
|
const device = this.backend.device;
|
|
638
769
|
|
|
770
|
+
const width = ( mipLevel > 0 ) ? image.width : textureDescriptorGPU.size.width;
|
|
771
|
+
const height = ( mipLevel > 0 ) ? image.height : textureDescriptorGPU.size.height;
|
|
772
|
+
|
|
639
773
|
device.queue.copyExternalImageToTexture(
|
|
640
774
|
{
|
|
641
775
|
source: image,
|
|
642
776
|
flipY: flipY
|
|
643
777
|
}, {
|
|
644
778
|
texture: textureGPU,
|
|
645
|
-
mipLevel:
|
|
779
|
+
mipLevel: mipLevel,
|
|
646
780
|
origin: { x: 0, y: 0, z: originDepth },
|
|
647
781
|
premultipliedAlpha: premultiplyAlpha
|
|
648
782
|
}, {
|
|
649
|
-
width:
|
|
650
|
-
height:
|
|
783
|
+
width: width,
|
|
784
|
+
height: height,
|
|
651
785
|
depthOrArrayLayers: 1
|
|
652
786
|
}
|
|
653
787
|
);
|
|
@@ -681,10 +815,11 @@ class WebGPUTextureUtils {
|
|
|
681
815
|
* @param {GPUTexture} textureGPU - The GPU texture object.
|
|
682
816
|
* @param {Object} textureDescriptorGPU - The texture descriptor.
|
|
683
817
|
* @param {number} [baseArrayLayer=0] - The index of the first array layer accessible to the texture view.
|
|
818
|
+
* @param {?GPUCommandEncoder} [encoder=null] - An optional command encoder used to generate mipmaps.
|
|
684
819
|
*/
|
|
685
|
-
_generateMipmaps( textureGPU, textureDescriptorGPU, baseArrayLayer = 0 ) {
|
|
820
|
+
_generateMipmaps( textureGPU, textureDescriptorGPU, baseArrayLayer = 0, encoder = null ) {
|
|
686
821
|
|
|
687
|
-
this._getPassUtils().generateMipmaps( textureGPU, textureDescriptorGPU, baseArrayLayer );
|
|
822
|
+
this._getPassUtils().generateMipmaps( textureGPU, textureDescriptorGPU, baseArrayLayer, encoder );
|
|
688
823
|
|
|
689
824
|
}
|
|
690
825
|
|
|
@@ -711,9 +846,10 @@ class WebGPUTextureUtils {
|
|
|
711
846
|
* @param {Object} textureDescriptorGPU - The GPU texture descriptor.
|
|
712
847
|
* @param {number} originDepth - The origin depth.
|
|
713
848
|
* @param {boolean} flipY - Whether to flip texture data along their vertical axis or not.
|
|
714
|
-
* @param {number} [depth=0] -
|
|
849
|
+
* @param {number} [depth=0] - The depth offset when copying array or 3D texture data.
|
|
850
|
+
* @param {number} [mipLevel=0] - The mip level where the data should be copied to.
|
|
715
851
|
*/
|
|
716
|
-
_copyBufferToTexture( image, textureGPU, textureDescriptorGPU, originDepth, flipY, depth = 0 ) {
|
|
852
|
+
_copyBufferToTexture( image, textureGPU, textureDescriptorGPU, originDepth, flipY, depth = 0, mipLevel = 0 ) {
|
|
717
853
|
|
|
718
854
|
// @TODO: Consider to use GPUCommandEncoder.copyBufferToTexture()
|
|
719
855
|
// @TODO: Consider to support valid buffer layouts with other formats like RGB
|
|
@@ -728,7 +864,7 @@ class WebGPUTextureUtils {
|
|
|
728
864
|
device.queue.writeTexture(
|
|
729
865
|
{
|
|
730
866
|
texture: textureGPU,
|
|
731
|
-
mipLevel:
|
|
867
|
+
mipLevel: mipLevel,
|
|
732
868
|
origin: { x: 0, y: 0, z: originDepth }
|
|
733
869
|
},
|
|
734
870
|
data,
|
|
@@ -976,7 +1112,7 @@ class WebGPUTextureUtils {
|
|
|
976
1112
|
if ( format === GPUTextureFormat.RG8Snorm ) return Int8Array;
|
|
977
1113
|
if ( format === GPUTextureFormat.RGBA8Uint ) return Uint8Array;
|
|
978
1114
|
if ( format === GPUTextureFormat.RGBA8Sint ) return Int8Array;
|
|
979
|
-
if ( format === GPUTextureFormat.RGBA8Unorm ) return Uint8Array;
|
|
1115
|
+
if ( format === GPUTextureFormat.RGBA8Unorm || format === GPUTextureFormat.RGBA8UnormSRGB ) return Uint8Array;
|
|
980
1116
|
if ( format === GPUTextureFormat.RGBA8Snorm ) return Int8Array;
|
|
981
1117
|
|
|
982
1118
|
|
|
@@ -1001,8 +1137,7 @@ class WebGPUTextureUtils {
|
|
|
1001
1137
|
if ( format === GPUTextureFormat.RGBA32Sint ) return Int32Array;
|
|
1002
1138
|
if ( format === GPUTextureFormat.RGBA32Float ) return Float32Array;
|
|
1003
1139
|
|
|
1004
|
-
if ( format === GPUTextureFormat.BGRA8Unorm ) return Uint8Array;
|
|
1005
|
-
if ( format === GPUTextureFormat.BGRA8UnormSRGB ) return Uint8Array;
|
|
1140
|
+
if ( format === GPUTextureFormat.BGRA8Unorm || format === GPUTextureFormat.BGRA8UnormSRGB ) return Uint8Array;
|
|
1006
1141
|
if ( format === GPUTextureFormat.RGB10A2Unorm ) return Uint32Array;
|
|
1007
1142
|
if ( format === GPUTextureFormat.RGB9E5UFloat ) return Uint32Array;
|
|
1008
1143
|
if ( format === GPUTextureFormat.RG11B10UFloat ) return Uint32Array;
|
|
@@ -1062,6 +1197,7 @@ export function getFormat( texture, device = null ) {
|
|
|
1062
1197
|
|
|
1063
1198
|
switch ( format ) {
|
|
1064
1199
|
|
|
1200
|
+
case RGB_S3TC_DXT1_Format:
|
|
1065
1201
|
case RGBA_S3TC_DXT1_Format:
|
|
1066
1202
|
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.BC1RGBAUnormSRGB : GPUTextureFormat.BC1RGBAUnorm;
|
|
1067
1203
|
break;
|
|
@@ -1074,7 +1210,28 @@ export function getFormat( texture, device = null ) {
|
|
|
1074
1210
|
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.BC3RGBAUnormSRGB : GPUTextureFormat.BC3RGBAUnorm;
|
|
1075
1211
|
break;
|
|
1076
1212
|
|
|
1213
|
+
case RED_RGTC1_Format:
|
|
1214
|
+
formatGPU = GPUTextureFormat.BC4RUnorm;
|
|
1215
|
+
break;
|
|
1216
|
+
|
|
1217
|
+
case SIGNED_RED_RGTC1_Format:
|
|
1218
|
+
formatGPU = GPUTextureFormat.BC4RSnorm;
|
|
1219
|
+
break;
|
|
1220
|
+
|
|
1221
|
+
case RED_GREEN_RGTC2_Format:
|
|
1222
|
+
formatGPU = GPUTextureFormat.BC5RGUnorm;
|
|
1223
|
+
break;
|
|
1224
|
+
|
|
1225
|
+
case SIGNED_RED_GREEN_RGTC2_Format:
|
|
1226
|
+
formatGPU = GPUTextureFormat.BC5RGSnorm;
|
|
1227
|
+
break;
|
|
1228
|
+
|
|
1229
|
+
case RGBA_BPTC_Format:
|
|
1230
|
+
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.BC7RGBAUnormSRGB : GPUTextureFormat.BC7RGBAUnorm;
|
|
1231
|
+
break;
|
|
1232
|
+
|
|
1077
1233
|
case RGB_ETC2_Format:
|
|
1234
|
+
case RGB_ETC1_Format:
|
|
1078
1235
|
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ETC2RGB8UnormSRGB : GPUTextureFormat.ETC2RGB8Unorm;
|
|
1079
1236
|
break;
|
|
1080
1237
|
|
|
@@ -1143,7 +1300,7 @@ export function getFormat( texture, device = null ) {
|
|
|
1143
1300
|
break;
|
|
1144
1301
|
|
|
1145
1302
|
default:
|
|
1146
|
-
|
|
1303
|
+
error( 'WebGPURenderer: Unsupported texture format.', format );
|
|
1147
1304
|
|
|
1148
1305
|
}
|
|
1149
1306
|
|
|
@@ -1187,7 +1344,7 @@ export function getFormat( texture, device = null ) {
|
|
|
1187
1344
|
break;
|
|
1188
1345
|
|
|
1189
1346
|
default:
|
|
1190
|
-
|
|
1347
|
+
error( 'WebGPURenderer: Unsupported texture type with RGBAFormat.', type );
|
|
1191
1348
|
|
|
1192
1349
|
}
|
|
1193
1350
|
|
|
@@ -1201,8 +1358,12 @@ export function getFormat( texture, device = null ) {
|
|
|
1201
1358
|
formatGPU = GPUTextureFormat.RGB9E5UFloat;
|
|
1202
1359
|
break;
|
|
1203
1360
|
|
|
1361
|
+
case UnsignedInt101111Type:
|
|
1362
|
+
formatGPU = GPUTextureFormat.RG11B10UFloat;
|
|
1363
|
+
break;
|
|
1364
|
+
|
|
1204
1365
|
default:
|
|
1205
|
-
|
|
1366
|
+
error( 'WebGPURenderer: Unsupported texture type with RGBFormat.', type );
|
|
1206
1367
|
|
|
1207
1368
|
}
|
|
1208
1369
|
|
|
@@ -1245,7 +1406,7 @@ export function getFormat( texture, device = null ) {
|
|
|
1245
1406
|
break;
|
|
1246
1407
|
|
|
1247
1408
|
default:
|
|
1248
|
-
|
|
1409
|
+
error( 'WebGPURenderer: Unsupported texture type with RedFormat.', type );
|
|
1249
1410
|
|
|
1250
1411
|
}
|
|
1251
1412
|
|
|
@@ -1288,7 +1449,7 @@ export function getFormat( texture, device = null ) {
|
|
|
1288
1449
|
break;
|
|
1289
1450
|
|
|
1290
1451
|
default:
|
|
1291
|
-
|
|
1452
|
+
error( 'WebGPURenderer: Unsupported texture type with RGFormat.', type );
|
|
1292
1453
|
|
|
1293
1454
|
}
|
|
1294
1455
|
|
|
@@ -1311,7 +1472,7 @@ export function getFormat( texture, device = null ) {
|
|
|
1311
1472
|
break;
|
|
1312
1473
|
|
|
1313
1474
|
default:
|
|
1314
|
-
|
|
1475
|
+
error( 'WebGPURenderer: Unsupported texture type with DepthFormat.', type );
|
|
1315
1476
|
|
|
1316
1477
|
}
|
|
1317
1478
|
|
|
@@ -1329,7 +1490,7 @@ export function getFormat( texture, device = null ) {
|
|
|
1329
1490
|
|
|
1330
1491
|
if ( device && device.features.has( GPUFeatureName.Depth32FloatStencil8 ) === false ) {
|
|
1331
1492
|
|
|
1332
|
-
|
|
1493
|
+
error( 'WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.' );
|
|
1333
1494
|
|
|
1334
1495
|
}
|
|
1335
1496
|
|
|
@@ -1338,7 +1499,7 @@ export function getFormat( texture, device = null ) {
|
|
|
1338
1499
|
break;
|
|
1339
1500
|
|
|
1340
1501
|
default:
|
|
1341
|
-
|
|
1502
|
+
error( 'WebGPURenderer: Unsupported texture type with DepthStencilFormat.', type );
|
|
1342
1503
|
|
|
1343
1504
|
}
|
|
1344
1505
|
|
|
@@ -1357,7 +1518,7 @@ export function getFormat( texture, device = null ) {
|
|
|
1357
1518
|
break;
|
|
1358
1519
|
|
|
1359
1520
|
default:
|
|
1360
|
-
|
|
1521
|
+
error( 'WebGPURenderer: Unsupported texture type with RedIntegerFormat.', type );
|
|
1361
1522
|
|
|
1362
1523
|
}
|
|
1363
1524
|
|
|
@@ -1376,7 +1537,7 @@ export function getFormat( texture, device = null ) {
|
|
|
1376
1537
|
break;
|
|
1377
1538
|
|
|
1378
1539
|
default:
|
|
1379
|
-
|
|
1540
|
+
error( 'WebGPURenderer: Unsupported texture type with RGIntegerFormat.', type );
|
|
1380
1541
|
|
|
1381
1542
|
}
|
|
1382
1543
|
|
|
@@ -1395,14 +1556,14 @@ export function getFormat( texture, device = null ) {
|
|
|
1395
1556
|
break;
|
|
1396
1557
|
|
|
1397
1558
|
default:
|
|
1398
|
-
|
|
1559
|
+
error( 'WebGPURenderer: Unsupported texture type with RGBAIntegerFormat.', type );
|
|
1399
1560
|
|
|
1400
1561
|
}
|
|
1401
1562
|
|
|
1402
1563
|
break;
|
|
1403
1564
|
|
|
1404
1565
|
default:
|
|
1405
|
-
|
|
1566
|
+
error( 'WebGPURenderer: Unsupported texture format.', format );
|
|
1406
1567
|
|
|
1407
1568
|
}
|
|
1408
1569
|
|