@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
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
import { NotEqualDepth, GreaterDepth, GreaterEqualDepth, EqualDepth, LessEqualDepth, LessDepth, AlwaysDepth, NeverDepth, CullFaceFront, CullFaceBack, CullFaceNone, DoubleSide, BackSide, CustomBlending, MultiplyBlending, SubtractiveBlending, AdditiveBlending, NoBlending, NormalBlending, AddEquation, SubtractEquation, ReverseSubtractEquation, MinEquation, MaxEquation, ZeroFactor, OneFactor, SrcColorFactor, SrcAlphaFactor, SrcAlphaSaturateFactor, DstColorFactor, DstAlphaFactor, OneMinusSrcColorFactor, OneMinusSrcAlphaFactor, OneMinusDstColorFactor, OneMinusDstAlphaFactor, ConstantColorFactor, OneMinusConstantColorFactor, ConstantAlphaFactor, OneMinusConstantAlphaFactor } from '../../constants.js';
|
|
2
2
|
import { Color } from '../../math/Color.js';
|
|
3
3
|
import { Vector4 } from '../../math/Vector4.js';
|
|
4
|
-
import { error } from '../../utils.js';
|
|
5
|
-
|
|
6
|
-
const reversedFuncs = {
|
|
7
|
-
[ NeverDepth ]: AlwaysDepth,
|
|
8
|
-
[ LessDepth ]: GreaterDepth,
|
|
9
|
-
[ EqualDepth ]: NotEqualDepth,
|
|
10
|
-
[ LessEqualDepth ]: GreaterEqualDepth,
|
|
11
|
-
|
|
12
|
-
[ AlwaysDepth ]: NeverDepth,
|
|
13
|
-
[ GreaterDepth ]: LessDepth,
|
|
14
|
-
[ NotEqualDepth ]: EqualDepth,
|
|
15
|
-
[ GreaterEqualDepth ]: LessEqualDepth,
|
|
16
|
-
};
|
|
4
|
+
import { error, ReversedDepthFuncs } from '../../utils.js';
|
|
17
5
|
|
|
18
6
|
function WebGLState( gl, extensions ) {
|
|
19
7
|
|
|
@@ -146,7 +134,7 @@ function WebGLState( gl, extensions ) {
|
|
|
146
134
|
|
|
147
135
|
setFunc: function ( depthFunc ) {
|
|
148
136
|
|
|
149
|
-
if ( currentReversed ) depthFunc =
|
|
137
|
+
if ( currentReversed ) depthFunc = ReversedDepthFuncs[ depthFunc ];
|
|
150
138
|
|
|
151
139
|
if ( currentDepthFunc !== depthFunc ) {
|
|
152
140
|
|
|
@@ -214,6 +202,8 @@ function WebGLState( gl, extensions ) {
|
|
|
214
202
|
|
|
215
203
|
if ( currentDepthClear !== depth ) {
|
|
216
204
|
|
|
205
|
+
currentDepthClear = depth;
|
|
206
|
+
|
|
217
207
|
if ( currentReversed ) {
|
|
218
208
|
|
|
219
209
|
depth = 1 - depth;
|
|
@@ -221,7 +211,6 @@ function WebGLState( gl, extensions ) {
|
|
|
221
211
|
}
|
|
222
212
|
|
|
223
213
|
gl.clearDepth( depth );
|
|
224
|
-
currentDepthClear = depth;
|
|
225
214
|
|
|
226
215
|
}
|
|
227
216
|
|
|
@@ -875,11 +864,17 @@ function WebGLState( gl, extensions ) {
|
|
|
875
864
|
|
|
876
865
|
if ( currentPolygonOffsetFactor !== factor || currentPolygonOffsetUnits !== units ) {
|
|
877
866
|
|
|
878
|
-
gl.polygonOffset( factor, units );
|
|
879
|
-
|
|
880
867
|
currentPolygonOffsetFactor = factor;
|
|
881
868
|
currentPolygonOffsetUnits = units;
|
|
882
869
|
|
|
870
|
+
if ( depthBuffer.getReversed() ) {
|
|
871
|
+
|
|
872
|
+
factor = - factor;
|
|
873
|
+
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
gl.polygonOffset( factor, units );
|
|
877
|
+
|
|
883
878
|
}
|
|
884
879
|
|
|
885
880
|
} else {
|
|
@@ -983,9 +978,9 @@ function WebGLState( gl, extensions ) {
|
|
|
983
978
|
|
|
984
979
|
gl.compressedTexImage2D( ...arguments );
|
|
985
980
|
|
|
986
|
-
} catch (
|
|
981
|
+
} catch ( e ) {
|
|
987
982
|
|
|
988
|
-
error( 'WebGLState:',
|
|
983
|
+
error( 'WebGLState:', e );
|
|
989
984
|
|
|
990
985
|
}
|
|
991
986
|
|
|
@@ -997,9 +992,9 @@ function WebGLState( gl, extensions ) {
|
|
|
997
992
|
|
|
998
993
|
gl.compressedTexImage3D( ...arguments );
|
|
999
994
|
|
|
1000
|
-
} catch (
|
|
995
|
+
} catch ( e ) {
|
|
1001
996
|
|
|
1002
|
-
error( 'WebGLState:',
|
|
997
|
+
error( 'WebGLState:', e );
|
|
1003
998
|
|
|
1004
999
|
}
|
|
1005
1000
|
|
|
@@ -1011,9 +1006,9 @@ function WebGLState( gl, extensions ) {
|
|
|
1011
1006
|
|
|
1012
1007
|
gl.texSubImage2D( ...arguments );
|
|
1013
1008
|
|
|
1014
|
-
} catch (
|
|
1009
|
+
} catch ( e ) {
|
|
1015
1010
|
|
|
1016
|
-
error( 'WebGLState:',
|
|
1011
|
+
error( 'WebGLState:', e );
|
|
1017
1012
|
|
|
1018
1013
|
}
|
|
1019
1014
|
|
|
@@ -1025,9 +1020,9 @@ function WebGLState( gl, extensions ) {
|
|
|
1025
1020
|
|
|
1026
1021
|
gl.texSubImage3D( ...arguments );
|
|
1027
1022
|
|
|
1028
|
-
} catch (
|
|
1023
|
+
} catch ( e ) {
|
|
1029
1024
|
|
|
1030
|
-
error( 'WebGLState:',
|
|
1025
|
+
error( 'WebGLState:', e );
|
|
1031
1026
|
|
|
1032
1027
|
}
|
|
1033
1028
|
|
|
@@ -1039,9 +1034,9 @@ function WebGLState( gl, extensions ) {
|
|
|
1039
1034
|
|
|
1040
1035
|
gl.compressedTexSubImage2D( ...arguments );
|
|
1041
1036
|
|
|
1042
|
-
} catch (
|
|
1037
|
+
} catch ( e ) {
|
|
1043
1038
|
|
|
1044
|
-
error( 'WebGLState:',
|
|
1039
|
+
error( 'WebGLState:', e );
|
|
1045
1040
|
|
|
1046
1041
|
}
|
|
1047
1042
|
|
|
@@ -1053,9 +1048,9 @@ function WebGLState( gl, extensions ) {
|
|
|
1053
1048
|
|
|
1054
1049
|
gl.compressedTexSubImage3D( ...arguments );
|
|
1055
1050
|
|
|
1056
|
-
} catch (
|
|
1051
|
+
} catch ( e ) {
|
|
1057
1052
|
|
|
1058
|
-
error( 'WebGLState:',
|
|
1053
|
+
error( 'WebGLState:', e );
|
|
1059
1054
|
|
|
1060
1055
|
}
|
|
1061
1056
|
|
|
@@ -1067,9 +1062,9 @@ function WebGLState( gl, extensions ) {
|
|
|
1067
1062
|
|
|
1068
1063
|
gl.texStorage2D( ...arguments );
|
|
1069
1064
|
|
|
1070
|
-
} catch (
|
|
1065
|
+
} catch ( e ) {
|
|
1071
1066
|
|
|
1072
|
-
error( 'WebGLState:',
|
|
1067
|
+
error( 'WebGLState:', e );
|
|
1073
1068
|
|
|
1074
1069
|
}
|
|
1075
1070
|
|
|
@@ -1081,9 +1076,9 @@ function WebGLState( gl, extensions ) {
|
|
|
1081
1076
|
|
|
1082
1077
|
gl.texStorage3D( ...arguments );
|
|
1083
1078
|
|
|
1084
|
-
} catch (
|
|
1079
|
+
} catch ( e ) {
|
|
1085
1080
|
|
|
1086
|
-
error( 'WebGLState:',
|
|
1081
|
+
error( 'WebGLState:', e );
|
|
1087
1082
|
|
|
1088
1083
|
}
|
|
1089
1084
|
|
|
@@ -1095,9 +1090,9 @@ function WebGLState( gl, extensions ) {
|
|
|
1095
1090
|
|
|
1096
1091
|
gl.texImage2D( ...arguments );
|
|
1097
1092
|
|
|
1098
|
-
} catch (
|
|
1093
|
+
} catch ( e ) {
|
|
1099
1094
|
|
|
1100
|
-
error( 'WebGLState:',
|
|
1095
|
+
error( 'WebGLState:', e );
|
|
1101
1096
|
|
|
1102
1097
|
}
|
|
1103
1098
|
|
|
@@ -1109,9 +1104,9 @@ function WebGLState( gl, extensions ) {
|
|
|
1109
1104
|
|
|
1110
1105
|
gl.texImage3D( ...arguments );
|
|
1111
1106
|
|
|
1112
|
-
} catch (
|
|
1107
|
+
} catch ( e ) {
|
|
1113
1108
|
|
|
1114
|
-
error( 'WebGLState:',
|
|
1109
|
+
error( 'WebGLState:', e );
|
|
1115
1110
|
|
|
1116
1111
|
}
|
|
1117
1112
|
|
|
@@ -24,9 +24,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
24
24
|
try {
|
|
25
25
|
|
|
26
26
|
useOffscreenCanvas = typeof OffscreenCanvas !== 'undefined'
|
|
27
|
-
// eslint-disable-next-line compat/compat
|
|
28
27
|
&& ( new OffscreenCanvas( 1, 1 ).getContext( '2d' ) ) !== null;
|
|
29
28
|
|
|
29
|
+
|
|
30
30
|
} catch ( err ) {
|
|
31
31
|
|
|
32
32
|
// Ignore any errors
|
|
@@ -38,7 +38,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
38
38
|
// Use OffscreenCanvas when available. Specially needed in web workers
|
|
39
39
|
|
|
40
40
|
return useOffscreenCanvas ?
|
|
41
|
-
// eslint-disable-next-line compat/compat
|
|
42
41
|
new OffscreenCanvas( width, height ) : createElementNS( 'canvas' );
|
|
43
42
|
|
|
44
43
|
}
|
|
@@ -583,7 +582,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
583
582
|
|
|
584
583
|
const textureProperties = properties.get( texture );
|
|
585
584
|
|
|
586
|
-
if ( texture.version > 0 && textureProperties.__version !== texture.version ) {
|
|
585
|
+
if ( texture.isCubeDepthTexture !== true && texture.version > 0 && textureProperties.__version !== texture.version ) {
|
|
587
586
|
|
|
588
587
|
uploadCubeTexture( textureProperties, texture, slot );
|
|
589
588
|
return;
|
|
@@ -1575,7 +1574,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1575
1574
|
}
|
|
1576
1575
|
|
|
1577
1576
|
// Setup storage for internal depth/stencil buffers and bind to correct framebuffer
|
|
1578
|
-
function setupRenderBufferStorage( renderbuffer, renderTarget,
|
|
1577
|
+
function setupRenderBufferStorage( renderbuffer, renderTarget, useMultisample ) {
|
|
1579
1578
|
|
|
1580
1579
|
_gl.bindRenderbuffer( _gl.RENDERBUFFER, renderbuffer );
|
|
1581
1580
|
|
|
@@ -1588,15 +1587,13 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1588
1587
|
const glAttachmentType = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
|
|
1589
1588
|
|
|
1590
1589
|
// set up the attachment
|
|
1591
|
-
|
|
1592
|
-
const isUseMultisampledRTT = useMultisampledRTT( renderTarget );
|
|
1593
|
-
if ( isUseMultisampledRTT ) {
|
|
1590
|
+
if ( useMultisampledRTT( renderTarget ) ) {
|
|
1594
1591
|
|
|
1595
|
-
multisampledRTTExt.renderbufferStorageMultisampleEXT( _gl.RENDERBUFFER,
|
|
1592
|
+
multisampledRTTExt.renderbufferStorageMultisampleEXT( _gl.RENDERBUFFER, getRenderTargetSamples( renderTarget ), glInternalFormat, renderTarget.width, renderTarget.height );
|
|
1596
1593
|
|
|
1597
|
-
} else if (
|
|
1594
|
+
} else if ( useMultisample ) {
|
|
1598
1595
|
|
|
1599
|
-
_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER,
|
|
1596
|
+
_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, getRenderTargetSamples( renderTarget ), glInternalFormat, renderTarget.width, renderTarget.height );
|
|
1600
1597
|
|
|
1601
1598
|
} else {
|
|
1602
1599
|
|
|
@@ -1617,15 +1614,14 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1617
1614
|
const glFormat = utils.convert( texture.format, texture.colorSpace );
|
|
1618
1615
|
const glType = utils.convert( texture.type );
|
|
1619
1616
|
const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace );
|
|
1620
|
-
const samples = getRenderTargetSamples( renderTarget );
|
|
1621
1617
|
|
|
1622
|
-
if (
|
|
1618
|
+
if ( useMultisampledRTT( renderTarget ) ) {
|
|
1623
1619
|
|
|
1624
|
-
|
|
1620
|
+
multisampledRTTExt.renderbufferStorageMultisampleEXT( _gl.RENDERBUFFER, getRenderTargetSamples( renderTarget ), glInternalFormat, renderTarget.width, renderTarget.height );
|
|
1625
1621
|
|
|
1626
|
-
} else if (
|
|
1622
|
+
} else if ( useMultisample ) {
|
|
1627
1623
|
|
|
1628
|
-
|
|
1624
|
+
_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, getRenderTargetSamples( renderTarget ), glInternalFormat, renderTarget.width, renderTarget.height );
|
|
1629
1625
|
|
|
1630
1626
|
} else {
|
|
1631
1627
|
|
|
@@ -1642,10 +1638,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1642
1638
|
}
|
|
1643
1639
|
|
|
1644
1640
|
// Setup resources for a Depth Texture for a FBO (needs an extension)
|
|
1645
|
-
function setupDepthTexture( framebuffer, renderTarget ) {
|
|
1641
|
+
function setupDepthTexture( framebuffer, renderTarget, cubeFace ) {
|
|
1646
1642
|
|
|
1647
|
-
const isCube = ( renderTarget
|
|
1648
|
-
if ( isCube ) throw new Error( 'Depth Texture with cube render targets is not supported' );
|
|
1643
|
+
const isCube = ( renderTarget.isWebGLCubeRenderTarget === true );
|
|
1649
1644
|
|
|
1650
1645
|
state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
|
|
1651
1646
|
|
|
@@ -1669,20 +1664,69 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1669
1664
|
|
|
1670
1665
|
}
|
|
1671
1666
|
|
|
1672
|
-
|
|
1667
|
+
if ( isCube ) {
|
|
1668
|
+
|
|
1669
|
+
// For cube depth textures, initialize and bind without uploading image data
|
|
1670
|
+
if ( textureProperties.__webglInit === undefined ) {
|
|
1671
|
+
|
|
1672
|
+
textureProperties.__webglInit = true;
|
|
1673
|
+
renderTarget.depthTexture.addEventListener( 'dispose', onTextureDispose );
|
|
1674
|
+
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1677
|
+
// Only create and allocate storage once
|
|
1678
|
+
if ( textureProperties.__webglTexture === undefined ) {
|
|
1679
|
+
|
|
1680
|
+
textureProperties.__webglTexture = _gl.createTexture();
|
|
1681
|
+
|
|
1682
|
+
state.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture );
|
|
1683
|
+
setTextureParameters( _gl.TEXTURE_CUBE_MAP, renderTarget.depthTexture );
|
|
1684
|
+
|
|
1685
|
+
// Allocate storage for all 6 faces with correct depth texture format
|
|
1686
|
+
const glFormat = utils.convert( renderTarget.depthTexture.format );
|
|
1687
|
+
const glType = utils.convert( renderTarget.depthTexture.type );
|
|
1688
|
+
|
|
1689
|
+
// Use proper internal format for depth textures
|
|
1690
|
+
let glInternalFormat;
|
|
1691
|
+
if ( renderTarget.depthTexture.format === DepthFormat ) {
|
|
1692
|
+
|
|
1693
|
+
glInternalFormat = _gl.DEPTH_COMPONENT24;
|
|
1694
|
+
|
|
1695
|
+
} else if ( renderTarget.depthTexture.format === DepthStencilFormat ) {
|
|
1696
|
+
|
|
1697
|
+
glInternalFormat = _gl.DEPTH24_STENCIL8;
|
|
1698
|
+
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1701
|
+
for ( let i = 0; i < 6; i ++ ) {
|
|
1702
|
+
|
|
1703
|
+
_gl.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, renderTarget.width, renderTarget.height, 0, glFormat, glType, null );
|
|
1704
|
+
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1709
|
+
} else {
|
|
1710
|
+
|
|
1711
|
+
setTexture2D( renderTarget.depthTexture, 0 );
|
|
1712
|
+
|
|
1713
|
+
}
|
|
1673
1714
|
|
|
1674
1715
|
const webglDepthTexture = textureProperties.__webglTexture;
|
|
1675
1716
|
const samples = getRenderTargetSamples( renderTarget );
|
|
1676
1717
|
|
|
1718
|
+
const glTextureType = isCube ? _gl.TEXTURE_CUBE_MAP_POSITIVE_X + cubeFace : _gl.TEXTURE_2D;
|
|
1719
|
+
const glAttachmentType = renderTarget.depthTexture.format === DepthStencilFormat ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
|
|
1720
|
+
|
|
1677
1721
|
if ( renderTarget.depthTexture.format === DepthFormat ) {
|
|
1678
1722
|
|
|
1679
1723
|
if ( useMultisampledRTT( renderTarget ) ) {
|
|
1680
1724
|
|
|
1681
|
-
multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER,
|
|
1725
|
+
multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, glAttachmentType, glTextureType, webglDepthTexture, 0, samples );
|
|
1682
1726
|
|
|
1683
1727
|
} else {
|
|
1684
1728
|
|
|
1685
|
-
_gl.framebufferTexture2D( _gl.FRAMEBUFFER,
|
|
1729
|
+
_gl.framebufferTexture2D( _gl.FRAMEBUFFER, glAttachmentType, glTextureType, webglDepthTexture, 0 );
|
|
1686
1730
|
|
|
1687
1731
|
}
|
|
1688
1732
|
|
|
@@ -1690,11 +1734,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1690
1734
|
|
|
1691
1735
|
if ( useMultisampledRTT( renderTarget ) ) {
|
|
1692
1736
|
|
|
1693
|
-
multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER,
|
|
1737
|
+
multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, glAttachmentType, glTextureType, webglDepthTexture, 0, samples );
|
|
1694
1738
|
|
|
1695
1739
|
} else {
|
|
1696
1740
|
|
|
1697
|
-
_gl.framebufferTexture2D( _gl.FRAMEBUFFER,
|
|
1741
|
+
_gl.framebufferTexture2D( _gl.FRAMEBUFFER, glAttachmentType, glTextureType, webglDepthTexture, 0 );
|
|
1698
1742
|
|
|
1699
1743
|
}
|
|
1700
1744
|
|
|
@@ -1745,17 +1789,28 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
1745
1789
|
|
|
1746
1790
|
if ( renderTarget.depthTexture && ! renderTargetProperties.__autoAllocateDepthBuffer ) {
|
|
1747
1791
|
|
|
1748
|
-
if ( isCube )
|
|
1792
|
+
if ( isCube ) {
|
|
1749
1793
|
|
|
1750
|
-
|
|
1794
|
+
// For cube render targets with depth texture, setup each face
|
|
1795
|
+
for ( let i = 0; i < 6; i ++ ) {
|
|
1751
1796
|
|
|
1752
|
-
|
|
1797
|
+
setupDepthTexture( renderTargetProperties.__webglFramebuffer[ i ], renderTarget, i );
|
|
1753
1798
|
|
|
1754
|
-
|
|
1799
|
+
}
|
|
1755
1800
|
|
|
1756
1801
|
} else {
|
|
1757
1802
|
|
|
1758
|
-
|
|
1803
|
+
const mipmaps = renderTarget.texture.mipmaps;
|
|
1804
|
+
|
|
1805
|
+
if ( mipmaps && mipmaps.length > 0 ) {
|
|
1806
|
+
|
|
1807
|
+
setupDepthTexture( renderTargetProperties.__webglFramebuffer[ 0 ], renderTarget, 0 );
|
|
1808
|
+
|
|
1809
|
+
} else {
|
|
1810
|
+
|
|
1811
|
+
setupDepthTexture( renderTargetProperties.__webglFramebuffer, renderTarget, 0 );
|
|
1812
|
+
|
|
1813
|
+
}
|
|
1759
1814
|
|
|
1760
1815
|
}
|
|
1761
1816
|
|
|
@@ -2337,6 +2392,12 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
2337
2392
|
this.setupFrameBufferTexture = setupFrameBufferTexture;
|
|
2338
2393
|
this.useMultisampledRTT = useMultisampledRTT;
|
|
2339
2394
|
|
|
2395
|
+
this.isReversedDepthBuffer = function () {
|
|
2396
|
+
|
|
2397
|
+
return state.buffers.depth.getReversed();
|
|
2398
|
+
|
|
2399
|
+
};
|
|
2400
|
+
|
|
2340
2401
|
}
|
|
2341
2402
|
|
|
2342
2403
|
export { WebGLTextures };
|
|
@@ -46,7 +46,7 @@ import { Texture } from '../../textures/Texture.js';
|
|
|
46
46
|
import { DataArrayTexture } from '../../textures/DataArrayTexture.js';
|
|
47
47
|
import { Data3DTexture } from '../../textures/Data3DTexture.js';
|
|
48
48
|
import { DepthTexture } from '../../textures/DepthTexture.js';
|
|
49
|
-
import { LessEqualCompare } from '../../constants.js';
|
|
49
|
+
import { LessEqualCompare, GreaterEqualCompare } from '../../constants.js';
|
|
50
50
|
|
|
51
51
|
const emptyTexture = /*@__PURE__*/ new Texture();
|
|
52
52
|
|
|
@@ -572,7 +572,7 @@ function setValueT1( gl, v, textures ) {
|
|
|
572
572
|
|
|
573
573
|
if ( this.type === gl.SAMPLER_2D_SHADOW ) {
|
|
574
574
|
|
|
575
|
-
emptyShadowTexture.compareFunction = LessEqualCompare;
|
|
575
|
+
emptyShadowTexture.compareFunction = textures.isReversedDepthBuffer() ? GreaterEqualCompare : LessEqualCompare;
|
|
576
576
|
emptyTexture2D = emptyShadowTexture;
|
|
577
577
|
|
|
578
578
|
} else {
|
|
@@ -822,9 +822,21 @@ function setValueT1Array( gl, v, textures ) {
|
|
|
822
822
|
|
|
823
823
|
}
|
|
824
824
|
|
|
825
|
+
let emptyTexture2D;
|
|
826
|
+
|
|
827
|
+
if ( this.type === gl.SAMPLER_2D_SHADOW ) {
|
|
828
|
+
|
|
829
|
+
emptyTexture2D = emptyShadowTexture;
|
|
830
|
+
|
|
831
|
+
} else {
|
|
832
|
+
|
|
833
|
+
emptyTexture2D = emptyTexture;
|
|
834
|
+
|
|
835
|
+
}
|
|
836
|
+
|
|
825
837
|
for ( let i = 0; i !== n; ++ i ) {
|
|
826
838
|
|
|
827
|
-
textures.setTexture2D( v[ i ] ||
|
|
839
|
+
textures.setTexture2D( v[ i ] || emptyTexture2D, units[ i ] );
|
|
828
840
|
|
|
829
841
|
}
|
|
830
842
|
|
|
@@ -1110,6 +1122,31 @@ class WebGLUniforms {
|
|
|
1110
1122
|
|
|
1111
1123
|
}
|
|
1112
1124
|
|
|
1125
|
+
// Sort uniforms to prioritize shadow samplers first (for optimal texture unit allocation)
|
|
1126
|
+
|
|
1127
|
+
const shadowSamplers = [];
|
|
1128
|
+
const otherUniforms = [];
|
|
1129
|
+
|
|
1130
|
+
for ( const u of this.seq ) {
|
|
1131
|
+
|
|
1132
|
+
if ( u.type === gl.SAMPLER_2D_SHADOW || u.type === gl.SAMPLER_CUBE_SHADOW || u.type === gl.SAMPLER_2D_ARRAY_SHADOW ) {
|
|
1133
|
+
|
|
1134
|
+
shadowSamplers.push( u );
|
|
1135
|
+
|
|
1136
|
+
} else {
|
|
1137
|
+
|
|
1138
|
+
otherUniforms.push( u );
|
|
1139
|
+
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
if ( shadowSamplers.length > 0 ) {
|
|
1145
|
+
|
|
1146
|
+
this.seq = shadowSamplers.concat( otherUniforms );
|
|
1147
|
+
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1113
1150
|
}
|
|
1114
1151
|
|
|
1115
1152
|
setValue( gl, name, value, textures ) {
|
|
@@ -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, RGBAFormat, AlphaFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBAIntegerFormat, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType, RGBA_BPTC_Format, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format, NoColorSpace, SRGBTransfer, UnsignedInt5999Type, RGBFormat, 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, RGBAFormat, AlphaFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBAIntegerFormat, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType, RGBA_BPTC_Format, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format, NoColorSpace, SRGBTransfer, UnsignedInt5999Type, RGBFormat, UnsignedInt101111Type } from '../../constants.js';
|
|
2
2
|
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
3
3
|
|
|
4
4
|
function WebGLUtils( gl, extensions ) {
|
|
@@ -102,7 +102,7 @@ function WebGLUtils( gl, extensions ) {
|
|
|
102
102
|
|
|
103
103
|
// ETC
|
|
104
104
|
|
|
105
|
-
if ( p === RGB_ETC1_Format || p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format ) {
|
|
105
|
+
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 ) {
|
|
106
106
|
|
|
107
107
|
extension = extensions.get( 'WEBGL_compressed_texture_etc' );
|
|
108
108
|
|
|
@@ -110,6 +110,10 @@ function WebGLUtils( gl, extensions ) {
|
|
|
110
110
|
|
|
111
111
|
if ( p === RGB_ETC1_Format || p === RGB_ETC2_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ETC2 : extension.COMPRESSED_RGB8_ETC2;
|
|
112
112
|
if ( p === RGBA_ETC2_EAC_Format ) return ( transfer === SRGBTransfer ) ? extension.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : extension.COMPRESSED_RGBA8_ETC2_EAC;
|
|
113
|
+
if ( p === R11_EAC_Format ) return extension.COMPRESSED_R11_EAC;
|
|
114
|
+
if ( p === SIGNED_R11_EAC_Format ) return extension.COMPRESSED_SIGNED_R11_EAC;
|
|
115
|
+
if ( p === RG11_EAC_Format ) return extension.COMPRESSED_RG11_EAC;
|
|
116
|
+
if ( p === SIGNED_RG11_EAC_Format ) return extension.COMPRESSED_SIGNED_RG11_EAC;
|
|
113
117
|
|
|
114
118
|
} else {
|
|
115
119
|
|