@plastic-software/three 0.181.3 → 0.183.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/LICENSE +1 -1
- package/README.md +3 -4
- package/build/three.cjs +11330 -10017
- package/build/three.core.js +10011 -9493
- package/build/three.core.min.js +2 -2
- package/build/three.module.js +1414 -631
- package/build/three.module.min.js +2 -2
- package/build/three.tsl.js +21 -13
- package/build/three.tsl.min.js +2 -2
- package/build/three.webgpu.js +8007 -5427
- package/build/three.webgpu.min.js +2 -2
- package/build/three.webgpu.nodes.js +8005 -5426
- package/build/three.webgpu.nodes.min.js +2 -2
- package/examples/jsm/Addons.js +0 -3
- package/examples/jsm/animation/CCDIKSolver.js +2 -2
- package/examples/jsm/controls/ArcballControls.js +3 -3
- package/examples/jsm/controls/MapControls.js +55 -1
- package/examples/jsm/controls/OrbitControls.js +109 -6
- package/examples/jsm/controls/TrackballControls.js +6 -6
- package/examples/jsm/csm/CSM.js +2 -1
- package/examples/jsm/effects/AnaglyphEffect.js +102 -7
- package/examples/jsm/environments/ColorEnvironment.js +59 -0
- package/examples/jsm/environments/RoomEnvironment.js +3 -0
- package/examples/jsm/exporters/EXRExporter.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +131 -4
- package/examples/jsm/exporters/USDZExporter.js +22 -3
- package/examples/jsm/geometries/DecalGeometry.js +1 -1
- package/examples/jsm/helpers/AnimationPathHelper.js +302 -0
- package/examples/jsm/helpers/LightProbeHelperGPU.js +1 -1
- package/examples/jsm/helpers/TextureHelperGPU.js +1 -1
- package/examples/jsm/helpers/ViewHelper.js +67 -8
- package/examples/jsm/inspector/Inspector.js +74 -14
- package/examples/jsm/inspector/RendererInspector.js +12 -2
- package/examples/jsm/inspector/tabs/Console.js +41 -7
- package/examples/jsm/inspector/tabs/Parameters.js +18 -2
- package/examples/jsm/inspector/tabs/Performance.js +2 -2
- package/examples/jsm/inspector/tabs/Viewer.js +4 -4
- package/examples/jsm/inspector/ui/Profiler.js +1836 -31
- package/examples/jsm/inspector/ui/Style.js +973 -14
- package/examples/jsm/inspector/ui/Tab.js +188 -1
- package/examples/jsm/inspector/ui/Values.js +17 -1
- package/examples/jsm/libs/meshopt_decoder.module.js +6 -5
- package/examples/jsm/lines/LineMaterial.js +6 -0
- package/examples/jsm/loaders/3DMLoader.js +5 -4
- package/examples/jsm/loaders/3MFLoader.js +2 -2
- package/examples/jsm/loaders/AMFLoader.js +2 -2
- package/examples/jsm/loaders/ColladaLoader.js +24 -4026
- package/examples/jsm/loaders/DRACOLoader.js +5 -5
- package/examples/jsm/loaders/EXRLoader.js +5 -5
- package/examples/jsm/loaders/FBXLoader.js +2 -4
- package/examples/jsm/loaders/GCodeLoader.js +34 -8
- package/examples/jsm/loaders/GLTFLoader.js +122 -171
- package/examples/jsm/loaders/HDRLoader.js +0 -1
- package/examples/jsm/loaders/KMZLoader.js +5 -5
- package/examples/jsm/loaders/KTX2Loader.js +19 -3
- package/examples/jsm/loaders/LDrawLoader.js +2 -3
- package/examples/jsm/loaders/LWOLoader.js +7 -39
- package/examples/jsm/loaders/NRRDLoader.js +2 -2
- package/examples/jsm/loaders/PCDLoader.js +4 -2
- package/examples/jsm/loaders/SVGLoader.js +1 -1
- package/examples/jsm/loaders/TDSLoader.js +0 -2
- package/examples/jsm/loaders/TGALoader.js +0 -2
- package/examples/jsm/loaders/USDLoader.js +100 -40
- package/examples/jsm/loaders/UltraHDRLoader.js +285 -160
- package/examples/jsm/loaders/VOXLoader.js +660 -117
- package/examples/jsm/loaders/VRMLLoader.js +79 -2
- package/examples/jsm/loaders/VTKLoader.js +37 -24
- package/examples/jsm/loaders/collada/ColladaComposer.js +2950 -0
- package/examples/jsm/loaders/collada/ColladaParser.js +1962 -0
- package/examples/jsm/loaders/usd/USDAParser.js +447 -366
- package/examples/jsm/loaders/usd/USDCParser.js +1841 -6
- package/examples/jsm/loaders/usd/USDComposer.js +4041 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +2 -2
- package/examples/jsm/materials/WoodNodeMaterial.js +11 -11
- package/examples/jsm/math/Octree.js +131 -1
- package/examples/jsm/misc/Volume.js +0 -1
- package/examples/jsm/misc/VolumeSlice.js +0 -1
- package/examples/jsm/objects/LensflareMesh.js +1 -1
- package/examples/jsm/objects/Sky.js +76 -4
- package/examples/jsm/objects/SkyMesh.js +127 -10
- package/examples/jsm/objects/Water.js +4 -3
- package/examples/jsm/objects/Water2.js +5 -3
- package/examples/jsm/objects/WaterMesh.js +5 -7
- package/examples/jsm/physics/AmmoPhysics.js +12 -7
- package/examples/jsm/physics/JoltPhysics.js +10 -6
- package/examples/jsm/physics/RapierPhysics.js +9 -5
- package/examples/jsm/postprocessing/EffectComposer.js +7 -5
- package/examples/jsm/postprocessing/OutputPass.js +9 -0
- package/examples/jsm/postprocessing/RenderPass.js +10 -0
- package/examples/jsm/postprocessing/RenderTransitionPass.js +1 -1
- package/examples/jsm/postprocessing/UnrealBloomPass.js +48 -18
- package/examples/jsm/renderers/CSS3DRenderer.js +1 -1
- package/examples/jsm/renderers/Projector.js +268 -30
- package/examples/jsm/renderers/SVGRenderer.js +193 -60
- package/examples/jsm/shaders/GTAOShader.js +19 -6
- package/examples/jsm/shaders/HalftoneShader.js +12 -1
- package/examples/jsm/shaders/PoissonDenoiseShader.js +6 -2
- package/examples/jsm/shaders/SAOShader.js +17 -4
- package/examples/jsm/shaders/SSAOShader.js +11 -1
- package/examples/jsm/shaders/SSRShader.js +6 -5
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +2 -4
- package/examples/jsm/shaders/VignetteShader.js +1 -1
- package/examples/jsm/transpiler/AST.js +44 -0
- package/examples/jsm/transpiler/GLSLDecoder.js +61 -4
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -0
- package/examples/jsm/transpiler/TSLEncoder.js +46 -3
- package/examples/jsm/transpiler/TranspilerUtils.js +3 -3
- package/examples/jsm/transpiler/WGSLEncoder.js +27 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +1 -1
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +458 -16
- package/examples/jsm/tsl/display/AnamorphicNode.js +1 -1
- package/examples/jsm/tsl/display/BilateralBlurNode.js +364 -0
- package/examples/jsm/tsl/display/BloomNode.js +16 -6
- package/examples/jsm/tsl/display/CRT.js +150 -0
- package/examples/jsm/tsl/display/DenoiseNode.js +1 -1
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +1 -1
- package/examples/jsm/tsl/display/DotScreenNode.js +1 -1
- package/examples/jsm/tsl/display/FXAANode.js +2 -2
- package/examples/jsm/tsl/display/GTAONode.js +5 -4
- package/examples/jsm/tsl/display/GaussianBlurNode.js +11 -2
- package/examples/jsm/tsl/display/GodraysNode.js +624 -0
- package/examples/jsm/tsl/display/LensflareNode.js +1 -1
- package/examples/jsm/tsl/display/Lut3DNode.js +1 -1
- package/examples/jsm/tsl/display/OutlineNode.js +3 -3
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +2 -2
- package/examples/jsm/tsl/display/PixelationPassNode.js +7 -6
- package/examples/jsm/tsl/display/RGBShiftNode.js +2 -2
- package/examples/jsm/tsl/display/RetroPassNode.js +263 -0
- package/examples/jsm/tsl/display/SMAANode.js +2 -2
- package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
- package/examples/jsm/tsl/display/SSGINode.js +8 -20
- package/examples/jsm/tsl/display/SSRNode.js +8 -8
- package/examples/jsm/tsl/display/SSSNode.js +6 -4
- package/examples/jsm/tsl/display/Shape.js +29 -0
- package/examples/jsm/tsl/display/SobelOperatorNode.js +2 -2
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +8 -1
- package/examples/jsm/tsl/display/StereoPassNode.js +1 -2
- package/examples/jsm/tsl/display/TRAANode.js +273 -125
- package/examples/jsm/tsl/display/TransitionNode.js +1 -1
- package/examples/jsm/tsl/display/depthAwareBlend.js +80 -0
- package/examples/jsm/tsl/display/radialBlur.js +68 -0
- package/examples/jsm/tsl/math/Bayer.js +40 -1
- package/examples/jsm/utils/LDrawUtils.js +1 -1
- package/examples/jsm/utils/ShadowMapViewer.js +24 -10
- package/examples/jsm/utils/ShadowMapViewerGPU.js +1 -1
- package/examples/jsm/utils/WebGPUTextureUtils.js +1 -1
- package/package.json +20 -26
- package/src/Three.Core.js +2 -1
- package/src/Three.TSL.js +19 -11
- package/src/Three.WebGPU.Nodes.js +2 -0
- package/src/Three.WebGPU.js +3 -0
- package/src/Three.js +1 -0
- package/src/animation/AnimationAction.js +1 -1
- package/src/animation/AnimationClip.js +1 -1
- package/src/animation/AnimationMixer.js +6 -0
- package/src/animation/AnimationUtils.js +1 -12
- package/src/animation/KeyframeTrack.js +47 -8
- package/src/animation/PropertyMixer.js +4 -4
- package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
- package/src/animation/tracks/ColorKeyframeTrack.js +1 -1
- package/src/animation/tracks/NumberKeyframeTrack.js +1 -1
- package/src/animation/tracks/QuaternionKeyframeTrack.js +1 -1
- package/src/animation/tracks/StringKeyframeTrack.js +1 -1
- package/src/animation/tracks/VectorKeyframeTrack.js +1 -1
- package/src/audio/Audio.js +1 -1
- package/src/audio/AudioListener.js +5 -3
- package/src/cameras/Camera.js +32 -2
- package/src/cameras/CubeCamera.js +20 -0
- package/src/constants.js +90 -5
- package/src/core/BufferGeometry.js +14 -2
- package/src/core/Clock.js +7 -0
- package/src/core/Object3D.js +56 -4
- package/src/core/Raycaster.js +2 -2
- package/src/core/RenderTarget.js +3 -4
- package/src/extras/PMREMGenerator.js +7 -18
- package/src/extras/TextureUtils.js +5 -1
- package/src/geometries/ExtrudeGeometry.js +2 -2
- package/src/geometries/PolyhedronGeometry.js +1 -1
- package/src/geometries/TorusGeometry.js +8 -3
- package/src/helpers/CameraHelper.js +3 -0
- package/src/helpers/DirectionalLightHelper.js +4 -1
- package/src/helpers/HemisphereLightHelper.js +3 -0
- package/src/helpers/PointLightHelper.js +1 -25
- package/src/helpers/SpotLightHelper.js +3 -0
- package/src/lights/DirectionalLight.js +13 -0
- package/src/lights/HemisphereLight.js +10 -0
- package/src/lights/Light.js +1 -11
- package/src/lights/LightProbe.js +0 -15
- package/src/lights/LightShadow.js +15 -6
- package/src/lights/PointLight.js +15 -0
- package/src/lights/PointLightShadow.js +0 -86
- package/src/lights/SpotLight.js +22 -1
- package/src/lights/webgpu/IESSpotLight.js +2 -1
- package/src/loaders/Cache.js +28 -0
- package/src/loaders/FileLoader.js +1 -1
- package/src/loaders/ImageBitmapLoader.js +8 -3
- package/src/loaders/Loader.js +6 -0
- package/src/loaders/MaterialLoader.js +2 -1
- package/src/loaders/ObjectLoader.js +21 -2
- package/src/loaders/nodes/NodeLoader.js +2 -2
- package/src/materials/Material.js +2 -0
- package/src/materials/MeshLambertMaterial.js +9 -0
- package/src/materials/MeshPhongMaterial.js +9 -0
- package/src/materials/ShaderMaterial.js +20 -1
- package/src/materials/nodes/Line2NodeMaterial.js +7 -7
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +5 -2
- package/src/materials/nodes/MeshStandardNodeMaterial.js +5 -4
- package/src/materials/nodes/NodeMaterial.js +72 -25
- package/src/materials/nodes/manager/NodeMaterialObserver.js +10 -4
- package/src/math/Line3.js +3 -5
- package/src/math/MathUtils.js +10 -10
- package/src/math/Matrix4.js +74 -65
- package/src/math/Quaternion.js +3 -29
- package/src/math/Sphere.js +1 -1
- package/src/math/Vector3.js +3 -5
- package/src/math/interpolants/BezierInterpolant.js +108 -0
- package/src/nodes/Nodes.js +87 -68
- package/src/nodes/TSL.js +6 -6
- package/src/nodes/accessors/Arrays.js +1 -1
- package/src/nodes/accessors/BatchNode.js +10 -10
- package/src/nodes/accessors/Bitangent.js +5 -5
- package/src/nodes/accessors/BufferAttributeNode.js +98 -12
- package/src/nodes/accessors/BufferNode.js +29 -2
- package/src/nodes/accessors/Camera.js +149 -28
- package/src/nodes/accessors/ClippingNode.js +4 -4
- package/src/nodes/accessors/CubeTextureNode.js +20 -1
- package/src/nodes/accessors/InstanceNode.js +148 -43
- package/src/nodes/accessors/MaterialNode.js +9 -1
- package/src/nodes/accessors/MaterialReferenceNode.js +1 -2
- package/src/nodes/accessors/ModelNode.js +1 -1
- package/src/nodes/accessors/Normal.js +11 -11
- package/src/nodes/accessors/Position.js +34 -2
- package/src/nodes/accessors/ReferenceBaseNode.js +4 -4
- package/src/nodes/accessors/ReferenceNode.js +4 -4
- package/src/nodes/accessors/RendererReferenceNode.js +1 -2
- package/src/nodes/accessors/SceneProperties.js +53 -0
- package/src/nodes/accessors/SkinningNode.js +27 -26
- package/src/nodes/accessors/StorageBufferNode.js +4 -21
- package/src/nodes/accessors/StorageTextureNode.js +37 -1
- package/src/nodes/accessors/Tangent.js +4 -14
- package/src/nodes/accessors/Texture3DNode.js +32 -35
- package/src/nodes/accessors/TextureNode.js +58 -22
- package/src/nodes/accessors/UniformArrayNode.js +4 -2
- package/src/nodes/accessors/UserDataNode.js +1 -2
- package/src/nodes/accessors/VertexColorNode.js +1 -2
- package/src/nodes/code/FunctionNode.js +1 -2
- package/src/nodes/core/ArrayNode.js +20 -1
- package/src/nodes/core/AssignNode.js +2 -2
- package/src/nodes/core/AttributeNode.js +2 -2
- package/src/nodes/core/ContextNode.js +103 -4
- package/src/nodes/core/MRTNode.js +48 -2
- package/src/nodes/core/Node.js +29 -3
- package/src/nodes/core/NodeBuilder.js +170 -53
- package/src/nodes/core/NodeError.js +28 -0
- package/src/nodes/core/NodeFrame.js +12 -4
- package/src/nodes/core/NodeUtils.js +10 -8
- package/src/nodes/core/OutputStructNode.js +12 -10
- package/src/nodes/core/ParameterNode.js +3 -3
- package/src/nodes/core/PropertyNode.js +19 -3
- package/src/nodes/core/StackNode.js +65 -16
- package/src/nodes/core/StackTrace.js +139 -0
- package/src/nodes/core/StructNode.js +16 -2
- package/src/nodes/core/StructTypeNode.js +11 -17
- package/src/nodes/core/SubBuildNode.js +1 -1
- package/src/nodes/core/UniformNode.js +21 -5
- package/src/nodes/core/VarNode.js +47 -22
- package/src/nodes/core/VaryingNode.js +1 -18
- package/src/nodes/display/BlendModes.js +0 -64
- package/src/nodes/display/ColorAdjustment.js +17 -0
- package/src/nodes/display/ColorSpaceNode.js +3 -3
- package/src/nodes/display/NormalMapNode.js +39 -4
- package/src/nodes/display/PassNode.js +98 -9
- package/src/nodes/display/RenderOutputNode.js +3 -3
- package/src/nodes/display/ScreenNode.js +3 -1
- package/src/nodes/display/ToneMappingNode.js +1 -1
- package/src/nodes/display/ToonOutlinePassNode.js +2 -2
- package/src/nodes/display/ViewportDepthNode.js +52 -4
- package/src/nodes/display/ViewportTextureNode.js +21 -4
- package/src/nodes/fog/Fog.js +18 -35
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +3 -3
- package/src/nodes/functions/BSDF/DFGLUT.js +56 -0
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +1 -1
- package/src/nodes/functions/PhysicalLightingModel.js +126 -45
- package/src/nodes/geometry/RangeNode.js +4 -2
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -2
- package/src/nodes/gpgpu/ComputeNode.js +5 -4
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +1 -1
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +4 -4
- package/src/nodes/lighting/AnalyticLightNode.js +53 -0
- package/src/nodes/lighting/EnvironmentNode.js +28 -3
- package/src/nodes/lighting/LightsNode.js +2 -2
- package/src/nodes/lighting/PointShadowNode.js +162 -149
- package/src/nodes/lighting/ShadowFilterNode.js +53 -65
- package/src/nodes/lighting/ShadowNode.js +97 -41
- package/src/nodes/math/BitcountNode.js +433 -0
- package/src/nodes/math/ConditionalNode.js +2 -2
- package/src/nodes/math/MathNode.js +3 -40
- package/src/nodes/math/OperatorNode.js +2 -1
- package/src/nodes/math/PackFloatNode.js +98 -0
- package/src/nodes/math/UnpackFloatNode.js +96 -0
- package/src/nodes/pmrem/PMREMNode.js +1 -1
- package/src/nodes/pmrem/PMREMUtils.js +9 -15
- package/src/nodes/tsl/TSLCore.js +17 -14
- package/src/nodes/utils/ArrayElementNode.js +13 -0
- package/src/nodes/utils/DebugNode.js +11 -11
- package/src/nodes/utils/EventNode.js +1 -2
- package/src/nodes/utils/JoinNode.js +2 -2
- package/src/nodes/utils/LoopNode.js +1 -1
- package/src/nodes/utils/MemberNode.js +1 -1
- package/src/nodes/utils/Packing.js +13 -1
- package/src/nodes/utils/PostProcessingUtils.js +33 -1
- package/src/nodes/utils/RTTNode.js +1 -1
- package/src/nodes/utils/ReflectorNode.js +3 -4
- package/src/nodes/utils/SampleNode.js +1 -1
- package/src/nodes/utils/SpriteSheetUV.js +35 -0
- package/src/nodes/utils/UVUtils.js +28 -0
- package/src/objects/BatchedMesh.js +27 -14
- package/src/objects/InstancedMesh.js +11 -0
- package/src/objects/Line.js +1 -1
- package/src/objects/Mesh.js +1 -1
- package/src/objects/Points.js +1 -1
- package/src/objects/Skeleton.js +9 -0
- package/src/renderers/WebGLRenderer.js +178 -92
- package/src/renderers/common/Backend.js +29 -0
- package/src/renderers/common/Background.js +24 -11
- package/src/renderers/common/BindGroup.js +1 -9
- package/src/renderers/common/Binding.js +11 -0
- package/src/renderers/common/Bindings.js +27 -12
- package/src/renderers/common/BlendMode.js +143 -0
- package/src/renderers/common/Buffer.js +40 -0
- package/src/renderers/common/BundleGroup.js +1 -1
- package/src/renderers/common/ChainMap.js +30 -6
- package/src/renderers/common/CubeRenderTarget.js +50 -6
- package/src/renderers/common/Geometries.js +29 -3
- package/src/renderers/common/Lighting.js +5 -21
- package/src/renderers/common/Pipelines.js +4 -4
- package/src/renderers/common/PostProcessing.js +8 -206
- package/src/renderers/common/RenderBundles.js +2 -1
- package/src/renderers/common/RenderContext.js +16 -0
- package/src/renderers/common/RenderContexts.js +33 -49
- package/src/renderers/common/RenderLists.js +2 -1
- package/src/renderers/common/RenderObject.js +15 -3
- package/src/renderers/common/RenderObjectPipeline.js +40 -0
- package/src/renderers/common/RenderObjects.js +18 -2
- package/src/renderers/common/RenderPipeline.js +203 -17
- package/src/renderers/common/Renderer.js +257 -72
- package/src/renderers/common/Sampler.js +4 -4
- package/src/renderers/common/StorageBuffer.js +13 -1
- package/src/renderers/common/Textures.js +17 -1
- package/src/renderers/common/TimestampQueryPool.js +5 -3
- package/src/renderers/common/Uniform.js +8 -0
- package/src/renderers/common/UniformsGroup.js +61 -0
- package/src/renderers/common/XRManager.js +3 -2
- package/src/renderers/common/extras/PMREMGenerator.js +2 -8
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/{Nodes.js → NodeManager.js} +18 -6
- package/src/renderers/common/nodes/NodeStorageBuffer.js +13 -2
- package/src/renderers/common/nodes/NodeUniformBuffer.js +52 -0
- package/src/renderers/shaders/DFGLUTData.js +19 -34
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +8 -10
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +7 -11
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +5 -2
- package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +6 -2
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +8 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +112 -51
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +20 -4
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +225 -186
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk.js +3 -3
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +3 -0
- package/src/renderers/shaders/ShaderLib/{distanceRGBA.glsl.js → distance.glsl.js} +1 -2
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -9
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/vsm.glsl.js +4 -6
- package/src/renderers/shaders/ShaderLib.js +7 -5
- package/src/renderers/shaders/UniformsLib.js +0 -3
- package/src/renderers/webgl/WebGLBackground.js +2 -2
- package/src/renderers/webgl/WebGLBindingStates.js +99 -27
- package/src/renderers/webgl/WebGLCapabilities.js +3 -4
- package/src/renderers/webgl/WebGLEnvironments.js +228 -0
- package/src/renderers/webgl/WebGLGeometries.js +10 -7
- package/src/renderers/webgl/WebGLLights.js +18 -1
- package/src/renderers/webgl/WebGLMaterials.js +12 -0
- package/src/renderers/webgl/WebGLObjects.js +3 -1
- package/src/renderers/webgl/WebGLOutput.js +267 -0
- package/src/renderers/webgl/WebGLProgram.js +45 -109
- package/src/renderers/webgl/WebGLPrograms.js +45 -49
- package/src/renderers/webgl/WebGLRenderLists.js +15 -0
- package/src/renderers/webgl/WebGLShadowMap.js +188 -24
- package/src/renderers/webgl/WebGLState.js +32 -37
- package/src/renderers/webgl/WebGLTextures.js +89 -28
- package/src/renderers/webgl/WebGLUniforms.js +40 -3
- package/src/renderers/webgl/WebGLUtils.js +6 -2
- package/src/renderers/webgl-fallback/WebGLBackend.js +148 -18
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +156 -35
- package/src/renderers/webgl-fallback/utils/WebGLState.js +181 -5
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +5 -3
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +9 -9
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +6 -2
- package/src/renderers/webgpu/WebGPUBackend.js +119 -13
- package/src/renderers/webgpu/WebGPURenderer.js +2 -1
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +322 -68
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +4 -17
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +357 -200
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -0
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +61 -23
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +152 -200
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +65 -42
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +7 -7
- package/src/renderers/webgpu/utils/WebGPUUtils.js +17 -11
- package/src/renderers/webxr/WebXRManager.js +2 -2
- package/src/textures/CubeDepthTexture.js +76 -0
- package/src/textures/Source.js +1 -1
- package/src/textures/Texture.js +3 -3
- package/src/utils.js +258 -3
- package/examples/jsm/materials/MeshGouraudMaterial.js +0 -434
- package/examples/jsm/materials/MeshPostProcessingMaterial.js +0 -167
- package/examples/jsm/shaders/GodRaysShader.js +0 -333
- package/src/nodes/accessors/SceneNode.js +0 -145
- package/src/nodes/code/ScriptableNode.js +0 -726
- package/src/nodes/code/ScriptableValueNode.js +0 -253
- package/src/nodes/display/PosterizeNode.js +0 -65
- package/src/nodes/functions/BSDF/DFGApprox.js +0 -71
- package/src/nodes/utils/SpriteSheetUVNode.js +0 -90
- package/src/renderers/webgl/WebGLCubeMaps.js +0 -99
- package/src/renderers/webgl/WebGLCubeUVMaps.js +0 -134
|
@@ -4,10 +4,11 @@ import {
|
|
|
4
4
|
AdditiveBlending, SubtractiveBlending, MultiplyBlending, SubtractEquation, ReverseSubtractEquation,
|
|
5
5
|
ZeroFactor, OneFactor, SrcColorFactor, SrcAlphaFactor, SrcAlphaSaturateFactor, DstColorFactor, DstAlphaFactor,
|
|
6
6
|
OneMinusSrcColorFactor, OneMinusSrcAlphaFactor, OneMinusDstColorFactor, OneMinusDstAlphaFactor,
|
|
7
|
-
NeverDepth, AlwaysDepth, LessDepth, LessEqualDepth, EqualDepth, GreaterEqualDepth, GreaterDepth, NotEqualDepth
|
|
7
|
+
NeverDepth, AlwaysDepth, LessDepth, LessEqualDepth, EqualDepth, GreaterEqualDepth, GreaterDepth, NotEqualDepth,
|
|
8
|
+
MaterialBlending
|
|
8
9
|
} from '../../../constants.js';
|
|
9
10
|
import { Vector4 } from '../../../math/Vector4.js';
|
|
10
|
-
import { error } from '../../../utils.js';
|
|
11
|
+
import { error, ReversedDepthFuncs, warnOnce } from '../../../utils.js';
|
|
11
12
|
|
|
12
13
|
let equationToGL, factorToGL;
|
|
13
14
|
|
|
@@ -62,6 +63,7 @@ class WebGLState {
|
|
|
62
63
|
this.currentPolygonOffsetFactor = null;
|
|
63
64
|
this.currentPolygonOffsetUnits = null;
|
|
64
65
|
this.currentColorMask = null;
|
|
66
|
+
this.currentDepthReversed = false;
|
|
65
67
|
this.currentDepthFunc = null;
|
|
66
68
|
this.currentDepthMask = null;
|
|
67
69
|
this.currentStencilFunc = null;
|
|
@@ -85,7 +87,6 @@ class WebGLState {
|
|
|
85
87
|
this.currentBoundTextures = {};
|
|
86
88
|
this.currentBoundBufferBases = {};
|
|
87
89
|
|
|
88
|
-
|
|
89
90
|
this._init();
|
|
90
91
|
|
|
91
92
|
}
|
|
@@ -271,6 +272,151 @@ class WebGLState {
|
|
|
271
272
|
|
|
272
273
|
}
|
|
273
274
|
|
|
275
|
+
setMRTBlending( textures, mrt, material ) {
|
|
276
|
+
|
|
277
|
+
const gl = this.gl;
|
|
278
|
+
const drawBuffersIndexedExt = this.backend.drawBuffersIndexedExt;
|
|
279
|
+
|
|
280
|
+
if ( ! drawBuffersIndexedExt ) {
|
|
281
|
+
|
|
282
|
+
warnOnce( 'WebGPURenderer: Multiple Render Targets (MRT) blending configuration is not fully supported in compatibility mode. The material blending will be used for all render targets.' );
|
|
283
|
+
|
|
284
|
+
return;
|
|
285
|
+
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
for ( let i = 0; i < textures.length; i ++ ) {
|
|
289
|
+
|
|
290
|
+
const texture = textures[ i ];
|
|
291
|
+
|
|
292
|
+
let blending = null;
|
|
293
|
+
|
|
294
|
+
if ( mrt !== null ) {
|
|
295
|
+
|
|
296
|
+
const blendMode = mrt.getBlendMode( texture.name );
|
|
297
|
+
|
|
298
|
+
if ( blendMode.blending === MaterialBlending ) {
|
|
299
|
+
|
|
300
|
+
// use material blending
|
|
301
|
+
blending = material;
|
|
302
|
+
|
|
303
|
+
} else if ( blendMode.blending !== NoBlending ) {
|
|
304
|
+
|
|
305
|
+
blending = blendMode;
|
|
306
|
+
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
} else {
|
|
310
|
+
|
|
311
|
+
// use material blending
|
|
312
|
+
blending = material;
|
|
313
|
+
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
if ( blending !== null ) {
|
|
317
|
+
|
|
318
|
+
this._setMRTBlendingIndex( i, blending );
|
|
319
|
+
|
|
320
|
+
} else {
|
|
321
|
+
|
|
322
|
+
// use opaque blending (no blending)
|
|
323
|
+
drawBuffersIndexedExt.blendFuncSeparateiOES( i, gl.ONE, gl.ZERO, gl.ONE, gl.ZERO );
|
|
324
|
+
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Applies blending configuration for a specific draw buffer index.
|
|
333
|
+
*
|
|
334
|
+
* @private
|
|
335
|
+
* @param {number} index - The draw buffer index.
|
|
336
|
+
* @param {Object} blending - The blending configuration (material or BlendMode).
|
|
337
|
+
*/
|
|
338
|
+
_setMRTBlendingIndex( index, blending ) {
|
|
339
|
+
|
|
340
|
+
const { gl } = this;
|
|
341
|
+
const drawBuffersIndexedExt = this.backend.drawBuffersIndexedExt;
|
|
342
|
+
|
|
343
|
+
const blendingType = blending.blending;
|
|
344
|
+
const blendSrc = blending.blendSrc;
|
|
345
|
+
const blendDst = blending.blendDst;
|
|
346
|
+
const blendEquation = blending.blendEquation;
|
|
347
|
+
const premultipliedAlpha = blending.premultipliedAlpha;
|
|
348
|
+
|
|
349
|
+
if ( blendingType === CustomBlending ) {
|
|
350
|
+
|
|
351
|
+
const blendSrcAlpha = blending.blendSrcAlpha !== null ? blending.blendSrcAlpha : blendSrc;
|
|
352
|
+
const blendDstAlpha = blending.blendDstAlpha !== null ? blending.blendDstAlpha : blendDst;
|
|
353
|
+
const blendEquationAlpha = blending.blendEquationAlpha !== null ? blending.blendEquationAlpha : blendEquation;
|
|
354
|
+
|
|
355
|
+
drawBuffersIndexedExt.blendEquationSeparateiOES( index, equationToGL[ blendEquation ], equationToGL[ blendEquationAlpha ] );
|
|
356
|
+
drawBuffersIndexedExt.blendFuncSeparateiOES( index, factorToGL[ blendSrc ], factorToGL[ blendDst ], factorToGL[ blendSrcAlpha ], factorToGL[ blendDstAlpha ] );
|
|
357
|
+
|
|
358
|
+
} else {
|
|
359
|
+
|
|
360
|
+
drawBuffersIndexedExt.blendEquationSeparateiOES( index, gl.FUNC_ADD, gl.FUNC_ADD );
|
|
361
|
+
|
|
362
|
+
if ( premultipliedAlpha ) {
|
|
363
|
+
|
|
364
|
+
switch ( blendingType ) {
|
|
365
|
+
|
|
366
|
+
case NormalBlending:
|
|
367
|
+
drawBuffersIndexedExt.blendFuncSeparateiOES( index, gl.ONE, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA );
|
|
368
|
+
break;
|
|
369
|
+
|
|
370
|
+
case AdditiveBlending:
|
|
371
|
+
drawBuffersIndexedExt.blendFuncSeparateiOES( index, gl.ONE, gl.ONE, gl.ONE, gl.ONE );
|
|
372
|
+
break;
|
|
373
|
+
|
|
374
|
+
case SubtractiveBlending:
|
|
375
|
+
drawBuffersIndexedExt.blendFuncSeparateiOES( index, gl.ZERO, gl.ONE_MINUS_SRC_COLOR, gl.ZERO, gl.ONE );
|
|
376
|
+
break;
|
|
377
|
+
|
|
378
|
+
case MultiplyBlending:
|
|
379
|
+
drawBuffersIndexedExt.blendFuncSeparateiOES( index, gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA, gl.ZERO, gl.ONE );
|
|
380
|
+
break;
|
|
381
|
+
|
|
382
|
+
default:
|
|
383
|
+
drawBuffersIndexedExt.blendFuncSeparateiOES( index, gl.ONE, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA );
|
|
384
|
+
break;
|
|
385
|
+
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
} else {
|
|
389
|
+
|
|
390
|
+
switch ( blendingType ) {
|
|
391
|
+
|
|
392
|
+
case NormalBlending:
|
|
393
|
+
drawBuffersIndexedExt.blendFuncSeparateiOES( index, gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA );
|
|
394
|
+
break;
|
|
395
|
+
|
|
396
|
+
case AdditiveBlending:
|
|
397
|
+
drawBuffersIndexedExt.blendFuncSeparateiOES( index, gl.SRC_ALPHA, gl.ONE, gl.ONE, gl.ONE );
|
|
398
|
+
break;
|
|
399
|
+
|
|
400
|
+
case SubtractiveBlending:
|
|
401
|
+
drawBuffersIndexedExt.blendFuncSeparateiOES( index, gl.ZERO, gl.ONE_MINUS_SRC_COLOR, gl.ZERO, gl.ONE );
|
|
402
|
+
break;
|
|
403
|
+
|
|
404
|
+
case MultiplyBlending:
|
|
405
|
+
drawBuffersIndexedExt.blendFuncSeparateiOES( index, gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA, gl.ZERO, gl.ONE );
|
|
406
|
+
break;
|
|
407
|
+
|
|
408
|
+
default:
|
|
409
|
+
drawBuffersIndexedExt.blendFuncSeparateiOES( index, gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA );
|
|
410
|
+
break;
|
|
411
|
+
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
}
|
|
419
|
+
|
|
274
420
|
/**
|
|
275
421
|
* Defines the blending.
|
|
276
422
|
*
|
|
@@ -463,6 +609,34 @@ class WebGLState {
|
|
|
463
609
|
|
|
464
610
|
}
|
|
465
611
|
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* Configures the WebGL state to use a reversed depth buffer.
|
|
615
|
+
*
|
|
616
|
+
* @param {boolean} reversed - Whether the depth buffer is reversed or not.
|
|
617
|
+
*/
|
|
618
|
+
setReversedDepth( reversed ) {
|
|
619
|
+
|
|
620
|
+
if ( this.currentDepthReversed !== reversed ) {
|
|
621
|
+
|
|
622
|
+
const ext = this.backend.extensions.get( 'EXT_clip_control' );
|
|
623
|
+
|
|
624
|
+
if ( reversed ) {
|
|
625
|
+
|
|
626
|
+
ext.clipControlEXT( ext.LOWER_LEFT_EXT, ext.ZERO_TO_ONE_EXT );
|
|
627
|
+
|
|
628
|
+
} else {
|
|
629
|
+
|
|
630
|
+
ext.clipControlEXT( ext.LOWER_LEFT_EXT, ext.NEGATIVE_ONE_TO_ONE_EXT );
|
|
631
|
+
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
this.currentDepthReversed = reversed;
|
|
635
|
+
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
}
|
|
639
|
+
|
|
466
640
|
/**
|
|
467
641
|
* Specifies whether depth values can be written when rendering
|
|
468
642
|
* into a framebuffer or not.
|
|
@@ -493,6 +667,8 @@ class WebGLState {
|
|
|
493
667
|
*/
|
|
494
668
|
setDepthFunc( depthFunc ) {
|
|
495
669
|
|
|
670
|
+
if ( this.currentDepthReversed ) depthFunc = ReversedDepthFuncs[ depthFunc ];
|
|
671
|
+
|
|
496
672
|
if ( this.currentDepthFunc !== depthFunc ) {
|
|
497
673
|
|
|
498
674
|
const { gl } = this;
|
|
@@ -610,11 +786,11 @@ class WebGLState {
|
|
|
610
786
|
|
|
611
787
|
if ( boolean ) {
|
|
612
788
|
|
|
613
|
-
|
|
789
|
+
this.enable( gl.SCISSOR_TEST );
|
|
614
790
|
|
|
615
791
|
} else {
|
|
616
792
|
|
|
617
|
-
|
|
793
|
+
this.disable( gl.SCISSOR_TEST );
|
|
618
794
|
|
|
619
795
|
}
|
|
620
796
|
|
|
@@ -488,7 +488,7 @@ class WebGLTextureUtils {
|
|
|
488
488
|
backend.state.unbindTexture();
|
|
489
489
|
// debug
|
|
490
490
|
// const framebuffer = gl.createFramebuffer();
|
|
491
|
-
//
|
|
491
|
+
// backend.state.bindFramebuffer( gl.FRAMEBUFFER, framebuffer );
|
|
492
492
|
// gl.framebufferTexture2D( gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, glTextureType, textureGPU, 0 );
|
|
493
493
|
|
|
494
494
|
// const readout = new Float32Array( width * height * 4 );
|
|
@@ -497,7 +497,7 @@ class WebGLTextureUtils {
|
|
|
497
497
|
// const altType = gl.getParameter( gl.IMPLEMENTATION_COLOR_READ_TYPE );
|
|
498
498
|
|
|
499
499
|
// gl.readPixels( 0, 0, width, height, altFormat, altType, readout );
|
|
500
|
-
//
|
|
500
|
+
// backend.state.bindFramebuffer( gl.FRAMEBUFFER, null );
|
|
501
501
|
// log( readout );
|
|
502
502
|
|
|
503
503
|
}
|
|
@@ -1183,7 +1183,7 @@ class WebGLTextureUtils {
|
|
|
1183
1183
|
|
|
1184
1184
|
const fb = gl.createFramebuffer();
|
|
1185
1185
|
|
|
1186
|
-
|
|
1186
|
+
backend.state.bindFramebuffer( gl.READ_FRAMEBUFFER, fb );
|
|
1187
1187
|
|
|
1188
1188
|
const target = texture.isCubeTexture ? gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex : gl.TEXTURE_2D;
|
|
1189
1189
|
|
|
@@ -1210,6 +1210,8 @@ class WebGLTextureUtils {
|
|
|
1210
1210
|
gl.getBufferSubData( gl.PIXEL_PACK_BUFFER, 0, dstBuffer );
|
|
1211
1211
|
gl.bindBuffer( gl.PIXEL_PACK_BUFFER, null );
|
|
1212
1212
|
|
|
1213
|
+
backend.state.bindFramebuffer( gl.READ_FRAMEBUFFER, null );
|
|
1214
|
+
|
|
1213
1215
|
gl.deleteFramebuffer( fb );
|
|
1214
1216
|
|
|
1215
1217
|
return dstBuffer;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { warnOnce, warn } from '../../../utils.js';
|
|
1
|
+
import { error, warnOnce, warn } from '../../../utils.js';
|
|
2
2
|
import TimestampQueryPool from '../../common/TimestampQueryPool.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -122,9 +122,9 @@ class WebGLTimestampQueryPool extends TimestampQueryPool {
|
|
|
122
122
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
} catch (
|
|
125
|
+
} catch ( e ) {
|
|
126
126
|
|
|
127
|
-
error( 'Error in beginQuery:',
|
|
127
|
+
error( 'Error in beginQuery:', e );
|
|
128
128
|
this.activeQuery = null;
|
|
129
129
|
this.queryStates.set( baseOffset, 'inactive' );
|
|
130
130
|
|
|
@@ -165,9 +165,9 @@ class WebGLTimestampQueryPool extends TimestampQueryPool {
|
|
|
165
165
|
this.queryStates.set( baseOffset, 'ended' );
|
|
166
166
|
this.activeQuery = null;
|
|
167
167
|
|
|
168
|
-
} catch (
|
|
168
|
+
} catch ( e ) {
|
|
169
169
|
|
|
170
|
-
error( 'Error in endQuery:',
|
|
170
|
+
error( 'Error in endQuery:', e );
|
|
171
171
|
// Reset state on error
|
|
172
172
|
this.queryStates.set( baseOffset, 'inactive' );
|
|
173
173
|
this.activeQuery = null;
|
|
@@ -258,9 +258,9 @@ class WebGLTimestampQueryPool extends TimestampQueryPool {
|
|
|
258
258
|
|
|
259
259
|
return totalDuration;
|
|
260
260
|
|
|
261
|
-
} catch (
|
|
261
|
+
} catch ( e ) {
|
|
262
262
|
|
|
263
|
-
error( 'Error resolving queries:',
|
|
263
|
+
error( 'Error resolving queries:', e );
|
|
264
264
|
return this.lastValue;
|
|
265
265
|
|
|
266
266
|
} finally {
|
|
@@ -346,9 +346,9 @@ class WebGLTimestampQueryPool extends TimestampQueryPool {
|
|
|
346
346
|
const elapsed = this.gl.getQueryParameter( query, this.gl.QUERY_RESULT );
|
|
347
347
|
resolve( Number( elapsed ) / 1e6 ); // Convert nanoseconds to milliseconds
|
|
348
348
|
|
|
349
|
-
} catch (
|
|
349
|
+
} catch ( e ) {
|
|
350
350
|
|
|
351
|
-
error( 'Error checking query:',
|
|
351
|
+
error( 'Error checking query:', e );
|
|
352
352
|
resolve( this.lastValue );
|
|
353
353
|
|
|
354
354
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { 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, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT5_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT1_Format, RGB_S3TC_DXT1_Format, DepthFormat, DepthStencilFormat, RedFormat, RGBFormat, RGBAFormat, AlphaFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBAIntegerFormat, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedInt5999Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType, RGBA_BPTC_Format, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format, SRGBTransfer, NoColorSpace, UnsignedInt101111Type } from '../../../constants.js';
|
|
1
|
+
import { 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, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, R11_EAC_Format, SIGNED_R11_EAC_Format, RG11_EAC_Format, SIGNED_RG11_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT5_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT1_Format, RGB_S3TC_DXT1_Format, DepthFormat, DepthStencilFormat, RedFormat, RGBFormat, RGBAFormat, AlphaFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBAIntegerFormat, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedInt5999Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType, RGBA_BPTC_Format, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format, SRGBTransfer, NoColorSpace, UnsignedInt101111Type } from '../../../constants.js';
|
|
2
2
|
import { ColorManagement } from '../../../math/ColorManagement.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -154,7 +154,7 @@ class WebGLUtils {
|
|
|
154
154
|
|
|
155
155
|
// ETC
|
|
156
156
|
|
|
157
|
-
if ( p === RGB_ETC1_Format || p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format ) {
|
|
157
|
+
if ( p === RGB_ETC1_Format || p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format || p === R11_EAC_Format || p === SIGNED_R11_EAC_Format || p === RG11_EAC_Format || p === SIGNED_RG11_EAC_Format ) {
|
|
158
158
|
|
|
159
159
|
extension = extensions.get( 'WEBGL_compressed_texture_etc' );
|
|
160
160
|
|
|
@@ -162,6 +162,10 @@ class WebGLUtils {
|
|
|
162
162
|
|
|
163
163
|
if ( p === RGB_ETC1_Format || p === RGB_ETC2_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2;
|
|
164
164
|
if ( p === RGBA_ETC2_EAC_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : extension.COMPRESSED_RGBA8_ETC2_EAC;
|
|
165
|
+
if ( p === R11_EAC_Format ) return extension.COMPRESSED_R11_EAC;
|
|
166
|
+
if ( p === SIGNED_R11_EAC_Format ) return extension.COMPRESSED_SIGNED_R11_EAC;
|
|
167
|
+
if ( p === RG11_EAC_Format ) return extension.COMPRESSED_RG11_EAC;
|
|
168
|
+
if ( p === SIGNED_RG11_EAC_Format ) return extension.COMPRESSED_SIGNED_RG11_EAC;
|
|
165
169
|
|
|
166
170
|
} else {
|
|
167
171
|
|
|
@@ -13,7 +13,7 @@ import WebGPUBindingUtils from './utils/WebGPUBindingUtils.js';
|
|
|
13
13
|
import WebGPUPipelineUtils from './utils/WebGPUPipelineUtils.js';
|
|
14
14
|
import WebGPUTextureUtils from './utils/WebGPUTextureUtils.js';
|
|
15
15
|
|
|
16
|
-
import { WebGPUCoordinateSystem, TimestampQuery, REVISION, HalfFloatType } from '../../constants.js';
|
|
16
|
+
import { WebGPUCoordinateSystem, TimestampQuery, REVISION, HalfFloatType, Compatibility } from '../../constants.js';
|
|
17
17
|
import WebGPUTimestampQueryPool from './utils/WebGPUTimestampQueryPool.js';
|
|
18
18
|
import { warnOnce, error } from '../../utils.js';
|
|
19
19
|
|
|
@@ -30,8 +30,8 @@ class WebGPUBackend extends Backend {
|
|
|
30
30
|
*
|
|
31
31
|
* @typedef {Object} WebGPUBackend~Options
|
|
32
32
|
* @property {boolean} [logarithmicDepthBuffer=false] - Whether logarithmic depth buffer is enabled or not.
|
|
33
|
+
* @property {boolean} [reversedDepthBuffer=false] - Whether reversed depth buffer is enabled or not.
|
|
33
34
|
* @property {boolean} [alpha=true] - Whether the default framebuffer (which represents the final contents of the canvas) should be transparent or opaque.
|
|
34
|
-
* @property {boolean} [compatibilityMode=false] - Whether the backend should be in compatibility mode or not.
|
|
35
35
|
* @property {boolean} [depth=true] - Whether the default framebuffer should have a depth buffer or not.
|
|
36
36
|
* @property {boolean} [stencil=false] - Whether the default framebuffer should have a stencil buffer or not.
|
|
37
37
|
* @property {boolean} [antialias=false] - Whether MSAA as the default anti-aliasing should be enabled or not.
|
|
@@ -64,16 +64,18 @@ class WebGPUBackend extends Backend {
|
|
|
64
64
|
|
|
65
65
|
// some parameters require default values other than "undefined"
|
|
66
66
|
this.parameters.alpha = ( parameters.alpha === undefined ) ? true : parameters.alpha;
|
|
67
|
-
this.parameters.compatibilityMode = ( parameters.compatibilityMode === undefined ) ? false : parameters.compatibilityMode;
|
|
68
67
|
|
|
69
68
|
this.parameters.requiredLimits = ( parameters.requiredLimits === undefined ) ? {} : parameters.requiredLimits;
|
|
70
69
|
|
|
71
70
|
/**
|
|
72
|
-
* Indicates whether the backend is in compatibility mode or not.
|
|
73
|
-
*
|
|
74
|
-
*
|
|
71
|
+
* Indicates whether the backend is in WebGPU compatibility mode or not.
|
|
72
|
+
* The backend must be initialized before the property can be evaluated.
|
|
73
|
+
*
|
|
74
|
+
* @type {?boolean}
|
|
75
|
+
* @readonly
|
|
76
|
+
* @default null
|
|
75
77
|
*/
|
|
76
|
-
this.compatibilityMode =
|
|
78
|
+
this.compatibilityMode = null;
|
|
77
79
|
|
|
78
80
|
/**
|
|
79
81
|
* A reference to the device.
|
|
@@ -137,6 +139,19 @@ class WebGPUBackend extends Backend {
|
|
|
137
139
|
*/
|
|
138
140
|
this.occludedResolveCache = new Map();
|
|
139
141
|
|
|
142
|
+
// compatibility checks
|
|
143
|
+
|
|
144
|
+
const compatibilityTextureCompare = typeof navigator === 'undefined' ? true : /Android/.test( navigator.userAgent ) === false;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* A map of compatibility checks.
|
|
148
|
+
*
|
|
149
|
+
* @type {Object}
|
|
150
|
+
*/
|
|
151
|
+
this._compatibility = {
|
|
152
|
+
[ Compatibility.TEXTURE_COMPARE ]: compatibilityTextureCompare
|
|
153
|
+
};
|
|
154
|
+
|
|
140
155
|
}
|
|
141
156
|
|
|
142
157
|
/**
|
|
@@ -162,7 +177,7 @@ class WebGPUBackend extends Backend {
|
|
|
162
177
|
|
|
163
178
|
const adapterOptions = {
|
|
164
179
|
powerPreference: parameters.powerPreference,
|
|
165
|
-
featureLevel:
|
|
180
|
+
featureLevel: 'compatibility'
|
|
166
181
|
};
|
|
167
182
|
|
|
168
183
|
const adapter = ( typeof navigator !== 'undefined' ) ? await navigator.gpu.requestAdapter( adapterOptions ) : null;
|
|
@@ -202,8 +217,18 @@ class WebGPUBackend extends Backend {
|
|
|
202
217
|
|
|
203
218
|
}
|
|
204
219
|
|
|
220
|
+
this.compatibilityMode = ! device.features.has( 'core-features-and-limits' );
|
|
221
|
+
|
|
222
|
+
if ( this.compatibilityMode ) {
|
|
223
|
+
|
|
224
|
+
renderer._samples = 0;
|
|
225
|
+
|
|
226
|
+
}
|
|
227
|
+
|
|
205
228
|
device.lost.then( ( info ) => {
|
|
206
229
|
|
|
230
|
+
if ( info.reason === 'destroyed' ) return;
|
|
231
|
+
|
|
207
232
|
const deviceLossInfo = {
|
|
208
233
|
api: 'WebGPU',
|
|
209
234
|
message: info.message || 'Unknown reason',
|
|
@@ -519,7 +544,7 @@ class WebGPUBackend extends Backend {
|
|
|
519
544
|
|
|
520
545
|
const depthTextureData = this.get( renderContext.depthTexture );
|
|
521
546
|
const options = {};
|
|
522
|
-
if ( renderContext.depthTexture.isArrayTexture ) {
|
|
547
|
+
if ( renderContext.depthTexture.isArrayTexture || renderContext.depthTexture.isCubeTexture ) {
|
|
523
548
|
|
|
524
549
|
options.dimension = GPUTextureViewDimension.TwoD;
|
|
525
550
|
options.arrayLayerCount = 1;
|
|
@@ -1572,6 +1597,14 @@ class WebGPUBackend extends Backend {
|
|
|
1572
1597
|
|
|
1573
1598
|
}
|
|
1574
1599
|
|
|
1600
|
+
let bytesPerElement = ( hasIndex === true ) ? index.array.BYTES_PER_ELEMENT : 1;
|
|
1601
|
+
|
|
1602
|
+
if ( material.wireframe ) {
|
|
1603
|
+
|
|
1604
|
+
bytesPerElement = object.geometry.attributes.position.count > 65535 ? 4 : 2;
|
|
1605
|
+
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1575
1608
|
for ( let i = 0; i < drawCount; i ++ ) {
|
|
1576
1609
|
|
|
1577
1610
|
const count = drawInstances ? drawInstances[ i ] : 1;
|
|
@@ -1579,7 +1612,7 @@ class WebGPUBackend extends Backend {
|
|
|
1579
1612
|
|
|
1580
1613
|
if ( hasIndex === true ) {
|
|
1581
1614
|
|
|
1582
|
-
passEncoderGPU.drawIndexed( counts[ i ], count, starts[ i ] /
|
|
1615
|
+
passEncoderGPU.drawIndexed( counts[ i ], count, starts[ i ] / bytesPerElement, 0, firstInstance );
|
|
1583
1616
|
|
|
1584
1617
|
} else {
|
|
1585
1618
|
|
|
@@ -1600,8 +1633,14 @@ class WebGPUBackend extends Backend {
|
|
|
1600
1633
|
if ( indirect !== null ) {
|
|
1601
1634
|
|
|
1602
1635
|
const buffer = this.get( indirect ).buffer;
|
|
1636
|
+
const indirectOffset = renderObject.getIndirectOffset();
|
|
1637
|
+
const indirectOffsets = Array.isArray( indirectOffset ) ? indirectOffset : [ indirectOffset ];
|
|
1603
1638
|
|
|
1604
|
-
|
|
1639
|
+
for ( let i = 0; i < indirectOffsets.length; i ++ ) {
|
|
1640
|
+
|
|
1641
|
+
passEncoderGPU.drawIndexedIndirect( buffer, indirectOffsets[ i ] );
|
|
1642
|
+
|
|
1643
|
+
}
|
|
1605
1644
|
|
|
1606
1645
|
} else {
|
|
1607
1646
|
|
|
@@ -1620,8 +1659,15 @@ class WebGPUBackend extends Backend {
|
|
|
1620
1659
|
if ( indirect !== null ) {
|
|
1621
1660
|
|
|
1622
1661
|
const buffer = this.get( indirect ).buffer;
|
|
1662
|
+
const indirectOffset = renderObject.getIndirectOffset();
|
|
1663
|
+
const indirectOffsets = Array.isArray( indirectOffset ) ? indirectOffset : [ indirectOffset ];
|
|
1664
|
+
|
|
1665
|
+
for ( let i = 0; i < indirectOffsets.length; i ++ ) {
|
|
1666
|
+
|
|
1667
|
+
passEncoderGPU.drawIndirect( buffer, indirectOffsets[ i ] );
|
|
1668
|
+
|
|
1669
|
+
}
|
|
1623
1670
|
|
|
1624
|
-
passEncoderGPU.drawIndirect( buffer, 0 );
|
|
1625
1671
|
|
|
1626
1672
|
} else {
|
|
1627
1673
|
|
|
@@ -1652,7 +1698,9 @@ class WebGPUBackend extends Backend {
|
|
|
1652
1698
|
|
|
1653
1699
|
data[ 0 ] = i;
|
|
1654
1700
|
|
|
1655
|
-
const
|
|
1701
|
+
const { layoutGPU } = bindingsData.layout;
|
|
1702
|
+
|
|
1703
|
+
const bindGroupIndex = this.bindingUtils.createBindGroupIndex( data, layoutGPU );
|
|
1656
1704
|
|
|
1657
1705
|
indexesGPU.push( bindGroupIndex );
|
|
1658
1706
|
|
|
@@ -2144,6 +2192,17 @@ class WebGPUBackend extends Backend {
|
|
|
2144
2192
|
|
|
2145
2193
|
}
|
|
2146
2194
|
|
|
2195
|
+
/**
|
|
2196
|
+
* Delete data associated with the current bind group.
|
|
2197
|
+
*
|
|
2198
|
+
* @param {BindGroup} bindGroup - The bind group.
|
|
2199
|
+
*/
|
|
2200
|
+
deleteBindGroupData( bindGroup ) {
|
|
2201
|
+
|
|
2202
|
+
this.bindingUtils.deleteBindGroupData( bindGroup );
|
|
2203
|
+
|
|
2204
|
+
}
|
|
2205
|
+
|
|
2147
2206
|
// attributes
|
|
2148
2207
|
|
|
2149
2208
|
/**
|
|
@@ -2471,10 +2530,57 @@ class WebGPUBackend extends Backend {
|
|
|
2471
2530
|
|
|
2472
2531
|
}
|
|
2473
2532
|
|
|
2533
|
+
/**
|
|
2534
|
+
* Checks if the given compatibility is supported by the backend.
|
|
2535
|
+
*
|
|
2536
|
+
* @param {string} name - The compatibility name.
|
|
2537
|
+
* @return {boolean} Whether the compatibility is supported or not.
|
|
2538
|
+
*/
|
|
2539
|
+
hasCompatibility( name ) {
|
|
2540
|
+
|
|
2541
|
+
if ( this._compatibility[ Compatibility.TEXTURE_COMPARE ] !== undefined ) {
|
|
2542
|
+
|
|
2543
|
+
return this._compatibility[ Compatibility.TEXTURE_COMPARE ];
|
|
2544
|
+
|
|
2545
|
+
}
|
|
2546
|
+
|
|
2547
|
+
return super.hasCompatibility( name );
|
|
2548
|
+
|
|
2549
|
+
}
|
|
2550
|
+
|
|
2474
2551
|
dispose() {
|
|
2475
2552
|
|
|
2553
|
+
this.bindingUtils.dispose();
|
|
2476
2554
|
this.textureUtils.dispose();
|
|
2477
2555
|
|
|
2556
|
+
if ( this.occludedResolveCache ) {
|
|
2557
|
+
|
|
2558
|
+
for ( const buffer of this.occludedResolveCache.values() ) {
|
|
2559
|
+
|
|
2560
|
+
buffer.destroy();
|
|
2561
|
+
|
|
2562
|
+
}
|
|
2563
|
+
|
|
2564
|
+
this.occludedResolveCache.clear();
|
|
2565
|
+
|
|
2566
|
+
}
|
|
2567
|
+
|
|
2568
|
+
if ( this.timestampQueryPool ) {
|
|
2569
|
+
|
|
2570
|
+
for ( const queryPool of Object.values( this.timestampQueryPool ) ) {
|
|
2571
|
+
|
|
2572
|
+
if ( queryPool !== null ) queryPool.dispose();
|
|
2573
|
+
|
|
2574
|
+
}
|
|
2575
|
+
|
|
2576
|
+
}
|
|
2577
|
+
|
|
2578
|
+
if ( this.parameters.device === undefined && this.device !== null ) {
|
|
2579
|
+
|
|
2580
|
+
this.device.destroy();
|
|
2581
|
+
|
|
2582
|
+
}
|
|
2583
|
+
|
|
2478
2584
|
}
|
|
2479
2585
|
|
|
2480
2586
|
}
|
|
@@ -32,6 +32,7 @@ class WebGPURenderer extends Renderer {
|
|
|
32
32
|
*
|
|
33
33
|
* @typedef {Object} WebGPURenderer~Options
|
|
34
34
|
* @property {boolean} [logarithmicDepthBuffer=false] - Whether logarithmic depth buffer is enabled or not.
|
|
35
|
+
* @property {boolean} [reversedDepthBuffer=false] - Whether reversed depth buffer is enabled or not.
|
|
35
36
|
* @property {boolean} [alpha=true] - Whether the default framebuffer (which represents the final contents of the canvas) should be transparent or opaque.
|
|
36
37
|
* @property {boolean} [depth=true] - Whether the default framebuffer should have a depth buffer or not.
|
|
37
38
|
* @property {boolean} [stencil=false] - Whether the default framebuffer should have a stencil buffer or not.
|
|
@@ -40,7 +41,7 @@ class WebGPURenderer extends Renderer {
|
|
|
40
41
|
* @property {boolean} [forceWebGL=false] - If set to `true`, the renderer uses a WebGL 2 backend no matter if WebGPU is supported or not.
|
|
41
42
|
* @property {boolean} [multiview=false] - If set to `true`, the renderer will use multiview during WebXR rendering if supported.
|
|
42
43
|
* @property {number} [outputType=undefined] - Texture type for output to canvas. By default, device's preferred format is used; other formats may incur overhead.
|
|
43
|
-
* @property {number} [
|
|
44
|
+
* @property {number} [outputBufferType=HalfFloatType] - Defines the type of output buffers. The default `HalfFloatType` is recommend for best
|
|
44
45
|
* quality. To save memory and bandwidth, `UnsignedByteType` might be used. This will reduce rendering quality though.
|
|
45
46
|
*/
|
|
46
47
|
|