@plastic-software/three 0.179.0 → 0.181.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/three.cjs +1108 -591
- package/build/three.core.js +616 -345
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +488 -250
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +37 -6
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +6576 -2152
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +6575 -2151
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/fonts/MPLUSRounded1c/MPLUSRounded1c-Regular.typeface.json.zip +0 -0
- package/examples/fonts/MPLUSRounded1c/OFL.txt +91 -0
- package/examples/jsm/Addons.js +1 -1
- package/examples/jsm/animation/CCDIKSolver.js +1 -1
- package/examples/jsm/controls/ArcballControls.js +8 -8
- package/examples/jsm/controls/DragControls.js +7 -57
- package/examples/jsm/controls/FirstPersonControls.js +3 -3
- package/examples/jsm/controls/FlyControls.js +1 -1
- package/examples/jsm/controls/OrbitControls.js +2 -2
- package/examples/jsm/controls/PointerLockControls.js +2 -10
- package/examples/jsm/controls/TrackballControls.js +1 -1
- package/examples/jsm/controls/TransformControls.js +1 -1
- package/examples/jsm/effects/AsciiEffect.js +8 -8
- package/examples/jsm/exporters/DRACOExporter.js +2 -2
- package/examples/jsm/exporters/EXRExporter.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +33 -25
- package/examples/jsm/exporters/KTX2Exporter.js +4 -2
- package/examples/jsm/exporters/PLYExporter.js +1 -1
- package/examples/jsm/exporters/USDZExporter.js +9 -2
- package/examples/jsm/geometries/DecalGeometry.js +2 -2
- package/examples/jsm/geometries/ParametricGeometry.js +1 -1
- package/examples/jsm/geometries/TeapotGeometry.js +2 -2
- package/examples/jsm/geometries/TextGeometry.js +3 -2
- package/examples/jsm/gpgpu/BitonicSort.js +715 -0
- package/examples/jsm/helpers/ViewHelper.js +43 -5
- package/examples/jsm/inspector/Inspector.js +427 -0
- package/examples/jsm/inspector/RendererInspector.js +415 -0
- package/examples/jsm/inspector/tabs/Console.js +204 -0
- package/examples/jsm/inspector/tabs/Parameters.js +332 -0
- package/examples/jsm/inspector/tabs/Performance.js +268 -0
- package/examples/jsm/inspector/tabs/Viewer.js +166 -0
- package/examples/jsm/inspector/ui/Graph.js +95 -0
- package/examples/jsm/inspector/ui/Item.js +170 -0
- package/examples/jsm/inspector/ui/List.js +75 -0
- package/examples/jsm/inspector/ui/Profiler.js +170 -0
- package/examples/jsm/inspector/ui/Style.js +654 -0
- package/examples/jsm/inspector/ui/Tab.js +46 -0
- package/examples/jsm/inspector/ui/Values.js +423 -0
- package/examples/jsm/inspector/ui/utils.js +56 -0
- package/examples/jsm/interactive/HTMLMesh.js +6 -10
- package/examples/jsm/interactive/InteractiveGroup.js +1 -1
- package/examples/jsm/interactive/SelectionBox.js +30 -0
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +1 -1
- package/examples/jsm/lines/Line2.js +3 -3
- package/examples/jsm/lines/LineGeometry.js +1 -1
- package/examples/jsm/lines/LineSegments2.js +2 -2
- package/examples/jsm/lines/Wireframe.js +2 -2
- package/examples/jsm/lines/WireframeGeometry2.js +1 -1
- package/examples/jsm/lines/webgpu/LineSegments2.js +1 -1
- package/examples/jsm/lines/webgpu/Wireframe.js +1 -1
- package/examples/jsm/loaders/3MFLoader.js +1 -1
- package/examples/jsm/loaders/ColladaLoader.js +3 -3
- package/examples/jsm/loaders/DDSLoader.js +1 -1
- package/examples/jsm/loaders/DRACOLoader.js +73 -22
- package/examples/jsm/loaders/EXRLoader.js +5 -5
- package/examples/jsm/loaders/FBXLoader.js +2 -2
- package/examples/jsm/loaders/FontLoader.js +23 -5
- package/examples/jsm/loaders/GLTFLoader.js +14 -8
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +5 -5
- package/examples/jsm/loaders/HDRLoader.js +486 -0
- package/examples/jsm/loaders/KTX2Loader.js +136 -49
- package/examples/jsm/loaders/KTXLoader.js +2 -2
- package/examples/jsm/loaders/LDrawLoader.js +1 -1
- package/examples/jsm/loaders/LUT3dlLoader.js +2 -2
- package/examples/jsm/loaders/LUTCubeLoader.js +1 -1
- package/examples/jsm/loaders/LWOLoader.js +2 -2
- package/examples/jsm/loaders/MaterialXLoader.js +22 -5
- package/examples/jsm/loaders/OBJLoader.js +1 -1
- package/examples/jsm/loaders/PDBLoader.js +1 -1
- package/examples/jsm/loaders/RGBELoader.js +7 -473
- package/examples/jsm/loaders/SVGLoader.js +2 -2
- package/examples/jsm/loaders/TTFLoader.js +4 -4
- package/examples/jsm/loaders/UltraHDRLoader.js +2 -2
- package/examples/jsm/loaders/lwo/IFFParser.js +1 -1
- package/examples/jsm/materials/WoodNodeMaterial.js +533 -0
- package/examples/jsm/math/ColorSpaces.js +19 -1
- package/examples/jsm/math/ConvexHull.js +3 -3
- package/examples/jsm/math/ImprovedNoise.js +1 -1
- package/examples/jsm/math/Lut.js +2 -2
- package/examples/jsm/math/SimplexNoise.js +1 -1
- package/examples/jsm/misc/MD2CharacterComplex.js +1 -1
- package/examples/jsm/misc/ProgressiveLightMap.js +9 -3
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +7 -1
- package/examples/jsm/misc/TubePainter.js +383 -40
- package/examples/jsm/misc/Volume.js +1 -1
- package/examples/jsm/modifiers/SimplifyModifier.js +1 -1
- package/examples/jsm/objects/ReflectorForSSRPass.js +1 -0
- package/examples/jsm/objects/Sky.js +1 -1
- package/examples/jsm/objects/SkyMesh.js +1 -1
- package/examples/jsm/objects/Water.js +3 -3
- package/examples/jsm/objects/WaterMesh.js +6 -6
- package/examples/jsm/postprocessing/GlitchPass.js +2 -2
- package/examples/jsm/postprocessing/OutlinePass.js +1 -1
- package/examples/jsm/postprocessing/SSRPass.js +37 -8
- package/examples/jsm/postprocessing/UnrealBloomPass.js +8 -6
- package/examples/jsm/renderers/CSS2DRenderer.js +16 -5
- package/examples/jsm/renderers/CSS3DRenderer.js +7 -6
- package/examples/jsm/renderers/SVGRenderer.js +1 -1
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +1 -1
- package/examples/jsm/shaders/AfterimageShader.js +1 -1
- package/examples/jsm/shaders/BleachBypassShader.js +1 -1
- package/examples/jsm/shaders/BokehShader.js +1 -1
- package/examples/jsm/shaders/BokehShader2.js +1 -1
- package/examples/jsm/shaders/DotScreenShader.js +1 -1
- package/examples/jsm/shaders/FocusShader.js +1 -1
- package/examples/jsm/shaders/GTAOShader.js +2 -2
- package/examples/jsm/shaders/GodRaysShader.js +1 -1
- package/examples/jsm/shaders/KaleidoShader.js +1 -1
- package/examples/jsm/shaders/PoissonDenoiseShader.js +2 -2
- package/examples/jsm/shaders/SSRShader.js +1 -1
- package/examples/jsm/shaders/SepiaShader.js +1 -1
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +1 -1
- package/examples/jsm/shaders/TriangleBlurShader.js +1 -1
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +1 -1
- package/examples/jsm/shaders/VignetteShader.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +22 -19
- package/examples/jsm/transpiler/TSLEncoder.js +9 -10
- package/examples/jsm/transpiler/WGSLEncoder.js +24 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +26 -24
- package/examples/jsm/tsl/display/AnamorphicNode.js +28 -4
- package/examples/jsm/tsl/display/BloomNode.js +7 -3
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +2 -1
- package/examples/jsm/tsl/display/DenoiseNode.js +2 -0
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +446 -90
- package/examples/jsm/tsl/display/GTAONode.js +53 -5
- package/examples/jsm/tsl/display/GaussianBlurNode.js +49 -35
- package/examples/jsm/tsl/display/OutlineNode.js +13 -2
- package/examples/jsm/tsl/display/SSGINode.js +654 -0
- package/examples/jsm/tsl/display/SSRNode.js +182 -65
- package/examples/jsm/tsl/display/SSSNode.js +488 -0
- package/examples/jsm/tsl/display/TRAANode.js +124 -7
- package/examples/jsm/tsl/display/boxBlur.js +65 -0
- package/examples/jsm/tsl/display/hashBlur.js +16 -18
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +21 -1
- package/examples/jsm/utils/BufferGeometryUtils.js +1 -1
- package/examples/jsm/utils/ShadowMapViewerGPU.js +12 -5
- package/examples/jsm/webxr/OculusHandModel.js +1 -1
- package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
- package/examples/jsm/webxr/XRHandModelFactory.js +2 -6
- package/package.json +5 -10
- package/src/Three.Core.js +4 -2
- package/src/Three.TSL.js +36 -5
- package/src/Three.WebGPU.Nodes.js +2 -0
- package/src/Three.WebGPU.js +2 -0
- package/src/animation/AnimationClip.js +20 -4
- package/src/animation/AnimationMixer.js +3 -3
- package/src/animation/AnimationObjectGroup.js +2 -1
- package/src/animation/KeyframeTrack.js +7 -6
- package/src/animation/PropertyBinding.js +12 -11
- package/src/audio/Audio.js +10 -9
- package/src/audio/PositionalAudio.js +1 -1
- package/src/cameras/OrthographicCamera.js +1 -1
- package/src/cameras/PerspectiveCamera.js +1 -1
- package/src/cameras/StereoCamera.js +2 -2
- package/src/constants.js +11 -3
- package/src/core/BufferGeometry.js +10 -10
- package/src/core/EventDispatcher.js +1 -1
- package/src/core/InterleavedBuffer.js +1 -1
- package/src/core/InterleavedBufferAttribute.js +3 -2
- package/src/core/Object3D.js +3 -2
- package/src/core/Raycaster.js +2 -1
- package/src/core/RenderTarget.js +10 -1
- package/src/extras/Controls.js +5 -4
- package/src/extras/DataUtils.js +2 -1
- package/src/extras/Earcut.js +6 -0
- package/src/extras/ImageUtils.js +2 -2
- package/src/extras/PMREMGenerator.js +268 -55
- package/src/extras/TextureUtils.js +2 -1
- package/src/extras/core/Curve.js +2 -1
- package/src/extras/core/Interpolations.js +7 -1
- package/src/extras/core/ShapePath.js +4 -4
- package/src/extras/lib/earcut.js +8 -8
- package/src/geometries/BoxGeometry.js +1 -0
- package/src/geometries/CapsuleGeometry.js +1 -0
- package/src/geometries/CircleGeometry.js +1 -0
- package/src/geometries/ConeGeometry.js +1 -0
- package/src/geometries/CylinderGeometry.js +1 -0
- package/src/geometries/DodecahedronGeometry.js +1 -0
- package/src/geometries/ExtrudeGeometry.js +8 -6
- package/src/geometries/IcosahedronGeometry.js +1 -0
- package/src/geometries/LatheGeometry.js +1 -0
- package/src/geometries/OctahedronGeometry.js +1 -0
- package/src/geometries/PlaneGeometry.js +1 -0
- package/src/geometries/RingGeometry.js +1 -0
- package/src/geometries/ShapeGeometry.js +1 -0
- package/src/geometries/SphereGeometry.js +1 -0
- package/src/geometries/TetrahedronGeometry.js +1 -0
- package/src/geometries/TorusGeometry.js +1 -0
- package/src/geometries/TorusKnotGeometry.js +1 -0
- package/src/geometries/TubeGeometry.js +1 -0
- package/src/helpers/CameraHelper.js +1 -1
- package/src/lights/webgpu/ProjectorLight.js +1 -1
- package/src/loaders/AnimationLoader.js +2 -1
- package/src/loaders/AudioLoader.js +2 -1
- package/src/loaders/BufferGeometryLoader.js +2 -2
- package/src/loaders/Cache.js +2 -2
- package/src/loaders/DataTextureLoader.js +1 -1
- package/src/loaders/FileLoader.js +3 -2
- package/src/loaders/ImageBitmapLoader.js +5 -4
- package/src/loaders/ImageLoader.js +1 -1
- package/src/loaders/Loader.js +3 -3
- package/src/loaders/LoadingManager.js +25 -3
- package/src/loaders/MaterialLoader.js +3 -2
- package/src/loaders/ObjectLoader.js +13 -13
- package/src/loaders/TextureLoader.js +1 -1
- package/src/loaders/nodes/NodeLoader.js +3 -2
- package/src/materials/Material.js +16 -3
- package/src/materials/MeshBasicMaterial.js +1 -0
- package/src/materials/MeshDepthMaterial.js +1 -0
- package/src/materials/MeshDistanceMaterial.js +1 -1
- package/src/materials/MeshLambertMaterial.js +2 -1
- package/src/materials/MeshMatcapMaterial.js +22 -0
- package/src/materials/MeshNormalMaterial.js +1 -0
- package/src/materials/MeshPhongMaterial.js +2 -1
- package/src/materials/MeshPhysicalMaterial.js +2 -1
- package/src/materials/MeshStandardMaterial.js +8 -7
- package/src/materials/MeshToonMaterial.js +1 -0
- package/src/materials/PointsMaterial.js +1 -1
- package/src/materials/ShaderMaterial.js +2 -2
- package/src/materials/nodes/Line2NodeMaterial.js +2 -2
- package/src/materials/nodes/MeshSSSNodeMaterial.js +1 -1
- package/src/materials/nodes/NodeMaterial.js +62 -22
- package/src/materials/nodes/PointsNodeMaterial.js +81 -28
- package/src/materials/nodes/SpriteNodeMaterial.js +3 -15
- package/src/materials/nodes/manager/NodeMaterialObserver.js +3 -2
- package/src/math/Color.js +6 -5
- package/src/math/ColorManagement.js +9 -3
- package/src/math/Cylindrical.js +1 -1
- package/src/math/Euler.js +2 -1
- package/src/math/MathUtils.js +13 -11
- package/src/math/Matrix2.js +1 -1
- package/src/math/Matrix3.js +2 -2
- package/src/math/Matrix4.js +7 -7
- package/src/math/Plane.js +1 -1
- package/src/math/Quaternion.js +68 -66
- package/src/math/Spherical.js +1 -1
- package/src/nodes/Nodes.js +4 -1
- package/src/nodes/TSL.js +4 -1
- package/src/nodes/accessors/BufferNode.js +1 -1
- package/src/nodes/accessors/Camera.js +133 -7
- package/src/nodes/accessors/ClippingNode.js +6 -5
- package/src/nodes/accessors/CubeTextureNode.js +5 -4
- package/src/nodes/accessors/InstanceNode.js +25 -5
- package/src/nodes/accessors/Lights.js +10 -0
- package/src/nodes/accessors/Normal.js +5 -4
- package/src/nodes/accessors/Object3DNode.js +1 -1
- package/src/nodes/accessors/Position.js +18 -2
- package/src/nodes/accessors/ReferenceBaseNode.js +1 -1
- package/src/nodes/accessors/ReferenceNode.js +3 -2
- package/src/nodes/accessors/SceneNode.js +2 -1
- package/src/nodes/accessors/StorageBufferNode.js +2 -1
- package/src/nodes/accessors/StorageTextureNode.js +22 -0
- package/src/nodes/accessors/Texture3DNode.js +14 -1
- package/src/nodes/accessors/TextureNode.js +130 -44
- package/src/nodes/code/FunctionCallNode.js +24 -4
- package/src/nodes/code/FunctionNode.js +23 -0
- package/src/nodes/core/ArrayNode.js +1 -0
- package/src/nodes/core/AssignNode.js +4 -3
- package/src/nodes/core/AttributeNode.js +2 -1
- package/src/nodes/core/ContextNode.js +29 -10
- package/src/nodes/core/IndexNode.js +2 -2
- package/src/nodes/core/InputNode.js +2 -1
- package/src/nodes/core/InspectorNode.js +128 -0
- package/src/nodes/core/{CacheNode.js → IsolateNode.js} +40 -7
- package/src/nodes/core/Node.js +152 -31
- package/src/nodes/core/NodeBuilder.js +183 -35
- package/src/nodes/core/NodeFrame.js +21 -21
- package/src/nodes/core/NodeFunction.js +2 -1
- package/src/nodes/core/NodeParser.js +2 -1
- package/src/nodes/core/NodeUniform.js +1 -1
- package/src/nodes/core/NodeUtils.js +17 -91
- package/src/nodes/core/ParameterNode.js +31 -0
- package/src/nodes/core/PropertyNode.js +7 -0
- package/src/nodes/core/StackNode.js +43 -16
- package/src/nodes/core/StructNode.js +5 -5
- package/src/nodes/core/StructTypeNode.js +1 -0
- package/src/nodes/core/SubBuildNode.js +2 -2
- package/src/nodes/core/UniformNode.js +18 -10
- package/src/nodes/core/VarNode.js +70 -33
- package/src/nodes/core/VaryingNode.js +3 -2
- package/src/nodes/display/BlendModes.js +5 -4
- package/src/nodes/display/BumpMapNode.js +1 -1
- package/src/nodes/display/ColorAdjustment.js +1 -1
- package/src/nodes/display/FrontFacingNode.js +4 -8
- package/src/nodes/display/NormalMapNode.js +2 -1
- package/src/nodes/display/PassNode.js +52 -11
- package/src/nodes/display/RenderOutputNode.js +28 -2
- package/src/nodes/display/ScreenNode.js +44 -14
- package/src/nodes/display/ToneMappingNode.js +31 -4
- package/src/nodes/display/ToonOutlinePassNode.js +8 -0
- package/src/nodes/display/ViewportDepthTextureNode.js +16 -4
- package/src/nodes/display/ViewportSharedTextureNode.js +12 -0
- package/src/nodes/display/ViewportTextureNode.js +42 -12
- package/src/nodes/fog/Fog.js +3 -2
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +52 -0
- package/src/nodes/functions/BSDF/DFGApprox.js +60 -19
- package/src/nodes/functions/BasicLightingModel.js +2 -1
- package/src/nodes/functions/PhysicalLightingModel.js +3 -2
- package/src/nodes/functions/VolumetricLightingModel.js +5 -5
- package/src/nodes/geometry/RangeNode.js +40 -4
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +2 -1
- package/src/nodes/gpgpu/ComputeNode.js +17 -5
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +455 -0
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +2 -1
- package/src/nodes/lighting/EnvironmentNode.js +6 -6
- package/src/nodes/lighting/LightsNode.js +3 -4
- package/src/nodes/lighting/PointShadowNode.js +6 -0
- package/src/nodes/lighting/ShadowFilterNode.js +2 -0
- package/src/nodes/lighting/ShadowNode.js +75 -8
- package/src/nodes/math/BitcastNode.js +156 -0
- package/src/nodes/math/ConditionalNode.js +24 -7
- package/src/nodes/math/MathNode.js +25 -19
- package/src/nodes/math/OperatorNode.js +7 -5
- package/src/nodes/pmrem/PMREMUtils.js +117 -2
- package/src/nodes/shapes/Shapes.js +1 -1
- package/src/nodes/tsl/TSLBase.js +5 -2
- package/src/nodes/tsl/TSLCore.js +460 -159
- package/src/nodes/utils/DebugNode.js +2 -1
- package/src/nodes/utils/EventNode.js +36 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +37 -19
- package/src/nodes/utils/JoinNode.js +6 -3
- package/src/nodes/utils/LoopNode.js +20 -24
- package/src/nodes/utils/MemberNode.js +59 -7
- package/src/nodes/utils/PostProcessingUtils.js +28 -1
- package/src/nodes/utils/RTTNode.js +13 -3
- package/src/nodes/utils/ReflectorNode.js +58 -7
- package/src/nodes/utils/SampleNode.js +12 -2
- package/src/nodes/utils/SplitNode.js +11 -0
- package/src/nodes/utils/Timer.js +0 -47
- package/src/objects/BatchedMesh.js +2 -2
- package/src/objects/LOD.js +1 -1
- package/src/objects/Line.js +2 -1
- package/src/objects/LineSegments.js +2 -1
- package/src/objects/Skeleton.js +3 -2
- package/src/objects/SkinnedMesh.js +3 -1
- package/src/objects/Sprite.js +4 -3
- package/src/renderers/WebGLRenderer.js +48 -41
- package/src/renderers/common/Animation.js +13 -1
- package/src/renderers/common/Attributes.js +1 -1
- package/src/renderers/common/Backend.js +108 -27
- package/src/renderers/common/Background.js +2 -1
- package/src/renderers/common/Bindings.js +58 -2
- package/src/renderers/common/CanvasTarget.js +341 -0
- package/src/renderers/common/ChainMap.js +1 -1
- package/src/renderers/common/DataMap.js +1 -1
- package/src/renderers/common/Geometries.js +26 -0
- package/src/renderers/common/Info.js +4 -2
- package/src/renderers/common/InspectorBase.js +146 -0
- package/src/renderers/common/Pipelines.js +1 -1
- package/src/renderers/common/PostProcessing.js +6 -25
- package/src/renderers/common/QuadMesh.js +7 -1
- package/src/renderers/common/RenderContext.js +2 -2
- package/src/renderers/common/RenderList.js +7 -3
- package/src/renderers/common/RenderObject.js +16 -2
- package/src/renderers/common/RenderObjects.js +1 -1
- package/src/renderers/common/Renderer.js +473 -245
- package/src/renderers/common/RendererUtils.js +9 -0
- package/src/renderers/common/SampledTexture.js +9 -1
- package/src/renderers/common/Sampler.js +50 -12
- package/src/renderers/common/StorageTexture.js +9 -1
- package/src/renderers/common/Textures.js +121 -45
- package/src/renderers/common/TimestampQueryPool.js +65 -3
- package/src/renderers/common/UniformsGroup.js +2 -1
- package/src/renderers/common/XRManager.js +42 -22
- package/src/renderers/common/extras/PMREMGenerator.js +160 -65
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/NodeLibrary.js +9 -7
- package/src/renderers/common/nodes/NodeSampler.js +13 -1
- package/src/renderers/common/nodes/Nodes.js +38 -16
- package/src/renderers/shaders/DFGLUTData.js +64 -0
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -12
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +52 -18
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +7 -15
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +1 -1
- package/src/renderers/shaders/UniformsLib.js +1 -0
- package/src/renderers/shaders/UniformsUtils.js +25 -4
- package/src/renderers/webgl/WebGLCapabilities.js +2 -1
- package/src/renderers/webgl/WebGLExtensions.js +2 -25
- package/src/renderers/webgl/WebGLInfo.js +3 -1
- package/src/renderers/webgl/WebGLProgram.js +15 -14
- package/src/renderers/webgl/WebGLPrograms.js +2 -1
- package/src/renderers/webgl/WebGLShadowMap.js +3 -2
- package/src/renderers/webgl/WebGLState.js +15 -14
- package/src/renderers/webgl/WebGLTextures.js +19 -14
- package/src/renderers/webgl/WebGLUniformsGroups.js +5 -3
- package/src/renderers/webgl/WebGLUtils.js +3 -2
- package/src/renderers/webgl-fallback/WebGLBackend.js +199 -167
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +181 -25
- package/src/renderers/webgl-fallback/utils/WebGLConstants.js +2 -3
- package/src/renderers/webgl-fallback/utils/WebGLState.js +7 -6
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +169 -19
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +51 -22
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +3 -2
- package/src/renderers/webgpu/WebGPUBackend.js +153 -123
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +2 -1
- package/src/renderers/webgpu/WebGPURenderer.js +3 -2
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +142 -50
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +2 -1
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +5 -3
- package/src/renderers/webgpu/utils/WebGPUConstants.js +7 -2
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +53 -34
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +6 -8
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +260 -99
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +32 -9
- package/src/renderers/webgpu/utils/WebGPUUtils.js +22 -2
- package/src/renderers/webxr/WebXRManager.js +42 -26
- package/src/textures/ExternalTexture.js +15 -4
- package/src/textures/Source.js +3 -2
- package/src/textures/Texture.js +3 -2
- package/src/textures/VideoTexture.js +2 -3
- package/src/utils.js +67 -3
- package/examples/jsm/loaders/RGBMLoader.js +0 -1148
|
@@ -16,6 +16,7 @@ import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
|
|
16
16
|
import { PlaneGeometry } from '../../geometries/PlaneGeometry.js';
|
|
17
17
|
import { MeshBasicMaterial } from '../../materials/MeshBasicMaterial.js';
|
|
18
18
|
import { Mesh } from '../../objects/Mesh.js';
|
|
19
|
+
import { warn } from '../../utils.js';
|
|
19
20
|
|
|
20
21
|
const _cameraLPos = /*@__PURE__*/ new Vector3();
|
|
21
22
|
const _cameraRPos = /*@__PURE__*/ new Vector3();
|
|
@@ -164,12 +165,12 @@ class XRManager extends EventDispatcher {
|
|
|
164
165
|
this._layers = [];
|
|
165
166
|
|
|
166
167
|
/**
|
|
167
|
-
* Whether the
|
|
168
|
+
* Whether the XR session uses layers.
|
|
168
169
|
*
|
|
169
170
|
* @type {boolean}
|
|
170
171
|
* @default false
|
|
171
172
|
*/
|
|
172
|
-
this.
|
|
173
|
+
this._sessionUsesLayers = false;
|
|
173
174
|
|
|
174
175
|
/**
|
|
175
176
|
* Whether the device supports binding gl objects.
|
|
@@ -360,13 +361,16 @@ class XRManager extends EventDispatcher {
|
|
|
360
361
|
this._xrFrame = null;
|
|
361
362
|
|
|
362
363
|
/**
|
|
363
|
-
* Whether
|
|
364
|
+
* Whether the browser supports the APIs necessary to use XRProjectionLayers.
|
|
365
|
+
*
|
|
366
|
+
* Note: this does not represent XRSession explicitly requesting
|
|
367
|
+
* `'layers'` as a feature - see `_sessionUsesLayers` and #30112
|
|
364
368
|
*
|
|
365
369
|
* @private
|
|
366
370
|
* @type {boolean}
|
|
367
371
|
* @readonly
|
|
368
372
|
*/
|
|
369
|
-
this.
|
|
373
|
+
this._supportsLayers = ( this._supportsGlBinding && 'createProjectionLayer' in XRWebGLBinding.prototype ); // eslint-disable-line compat/compat
|
|
370
374
|
|
|
371
375
|
/**
|
|
372
376
|
* Whether the usage of multiview has been requested by the application or not.
|
|
@@ -503,7 +507,7 @@ class XRManager extends EventDispatcher {
|
|
|
503
507
|
|
|
504
508
|
if ( this.isPresenting === true ) {
|
|
505
509
|
|
|
506
|
-
|
|
510
|
+
warn( 'XRManager: Cannot change framebuffer scale while presenting.' );
|
|
507
511
|
|
|
508
512
|
}
|
|
509
513
|
|
|
@@ -533,7 +537,7 @@ class XRManager extends EventDispatcher {
|
|
|
533
537
|
|
|
534
538
|
if ( this.isPresenting === true ) {
|
|
535
539
|
|
|
536
|
-
|
|
540
|
+
warn( 'XRManager: Cannot change reference space type while presenting.' );
|
|
537
541
|
|
|
538
542
|
}
|
|
539
543
|
|
|
@@ -587,6 +591,27 @@ class XRManager extends EventDispatcher {
|
|
|
587
591
|
|
|
588
592
|
}
|
|
589
593
|
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Returns the current XR binding.
|
|
597
|
+
*
|
|
598
|
+
* Creates a new binding if needed and the browser is
|
|
599
|
+
* capable of doing so.
|
|
600
|
+
*
|
|
601
|
+
* @return {?XRWebGLBinding} The XR binding. Returns `null` if one cannot be created.
|
|
602
|
+
*/
|
|
603
|
+
getBinding() {
|
|
604
|
+
|
|
605
|
+
if ( this._glBinding === null && this._supportsGlBinding ) {
|
|
606
|
+
|
|
607
|
+
this._glBinding = new XRWebGLBinding( this._session, this._gl );
|
|
608
|
+
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
return this._glBinding;
|
|
612
|
+
|
|
613
|
+
}
|
|
614
|
+
|
|
590
615
|
/**
|
|
591
616
|
* Returns the current XR frame.
|
|
592
617
|
*
|
|
@@ -817,7 +842,7 @@ class XRManager extends EventDispatcher {
|
|
|
817
842
|
layer.renderTarget.isXRRenderTarget = this._session !== null;
|
|
818
843
|
layer.renderTarget._hasExternalTextures = layer.renderTarget.isXRRenderTarget;
|
|
819
844
|
|
|
820
|
-
if ( layer.renderTarget.isXRRenderTarget && this.
|
|
845
|
+
if ( layer.renderTarget.isXRRenderTarget && this._sessionUsesLayers ) {
|
|
821
846
|
|
|
822
847
|
layer.xrlayer.transform = new XRRigidTransform( layer.plane.getWorldPosition( translationObject ), layer.plane.getWorldQuaternion( quaternionObject ) );
|
|
823
848
|
|
|
@@ -924,16 +949,7 @@ class XRManager extends EventDispatcher {
|
|
|
924
949
|
|
|
925
950
|
//
|
|
926
951
|
|
|
927
|
-
if ( this.
|
|
928
|
-
|
|
929
|
-
const glBinding = new XRWebGLBinding( session, gl );
|
|
930
|
-
this._glBinding = glBinding;
|
|
931
|
-
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
//
|
|
935
|
-
|
|
936
|
-
if ( this._useLayers === true ) {
|
|
952
|
+
if ( this._supportsLayers === true ) {
|
|
937
953
|
|
|
938
954
|
// default path using XRProjectionLayer
|
|
939
955
|
|
|
@@ -963,6 +979,7 @@ class XRManager extends EventDispatcher {
|
|
|
963
979
|
|
|
964
980
|
}
|
|
965
981
|
|
|
982
|
+
this._glBinding = this.getBinding();
|
|
966
983
|
const glProjLayer = this._glBinding.createProjectionLayer( projectionlayerInit );
|
|
967
984
|
const layersArray = [ glProjLayer ];
|
|
968
985
|
|
|
@@ -993,11 +1010,11 @@ class XRManager extends EventDispatcher {
|
|
|
993
1010
|
this._xrRenderTarget._hasExternalTextures = true;
|
|
994
1011
|
this._xrRenderTarget.depth = this._useMultiview ? 2 : 1;
|
|
995
1012
|
|
|
996
|
-
this.
|
|
1013
|
+
this._sessionUsesLayers = session.enabledFeatures.includes( 'layers' );
|
|
997
1014
|
|
|
998
1015
|
this._referenceSpace = await session.requestReferenceSpace( this.getReferenceSpaceType() );
|
|
999
1016
|
|
|
1000
|
-
if ( this.
|
|
1017
|
+
if ( this._sessionUsesLayers ) {
|
|
1001
1018
|
|
|
1002
1019
|
// switch layers to native
|
|
1003
1020
|
for ( const layer of this._layers ) {
|
|
@@ -1024,7 +1041,7 @@ class XRManager extends EventDispatcher {
|
|
|
1024
1041
|
// fallback to XRWebGLLayer
|
|
1025
1042
|
|
|
1026
1043
|
const layerInit = {
|
|
1027
|
-
antialias: renderer.
|
|
1044
|
+
antialias: renderer.currentSamples > 0,
|
|
1028
1045
|
alpha: true,
|
|
1029
1046
|
depth: renderer.depth,
|
|
1030
1047
|
stencil: renderer.stencil,
|
|
@@ -1364,9 +1381,12 @@ function onSessionEnd() {
|
|
|
1364
1381
|
|
|
1365
1382
|
this._session = null;
|
|
1366
1383
|
this._xrRenderTarget = null;
|
|
1384
|
+
this._glBinding = null;
|
|
1385
|
+
this._glBaseLayer = null;
|
|
1386
|
+
this._glProjLayer = null;
|
|
1367
1387
|
|
|
1368
1388
|
// switch layers back to emulated
|
|
1369
|
-
if ( this.
|
|
1389
|
+
if ( this._sessionUsesLayers === true ) {
|
|
1370
1390
|
|
|
1371
1391
|
for ( const layer of this._layers ) {
|
|
1372
1392
|
|
|
@@ -1568,7 +1588,7 @@ function onAnimationFrame( time, frame ) {
|
|
|
1568
1588
|
|
|
1569
1589
|
let viewport;
|
|
1570
1590
|
|
|
1571
|
-
if ( this.
|
|
1591
|
+
if ( this._supportsLayers === true ) {
|
|
1572
1592
|
|
|
1573
1593
|
const glSubImage = this._glBinding.getViewSubImage( this._glProjLayer, view );
|
|
1574
1594
|
viewport = glSubImage.viewport;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import NodeMaterial from '../../../materials/nodes/NodeMaterial.js';
|
|
2
|
-
import { getDirection, blur } from '../../../nodes/pmrem/PMREMUtils.js';
|
|
2
|
+
import { getDirection, blur, ggxConvolution } from '../../../nodes/pmrem/PMREMUtils.js';
|
|
3
3
|
import { equirectUV } from '../../../nodes/utils/EquirectUV.js';
|
|
4
4
|
import { uniform } from '../../../nodes/core/UniformNode.js';
|
|
5
5
|
import { uniformArray } from '../../../nodes/accessors/UniformArrayNode.js';
|
|
6
6
|
import { texture } from '../../../nodes/accessors/TextureNode.js';
|
|
7
7
|
import { cubeTexture } from '../../../nodes/accessors/CubeTextureNode.js';
|
|
8
|
-
import { float, vec3 } from '../../../nodes/tsl/TSLBase.js';
|
|
8
|
+
import { float, uint, vec3 } from '../../../nodes/tsl/TSLBase.js';
|
|
9
9
|
import { uv } from '../../../nodes/accessors/UV.js';
|
|
10
10
|
import { attribute } from '../../../nodes/core/AttributeNode.js';
|
|
11
11
|
|
|
@@ -30,19 +30,22 @@ import {
|
|
|
30
30
|
BackSide,
|
|
31
31
|
LinearSRGBColorSpace
|
|
32
32
|
} from '../../../constants.js';
|
|
33
|
+
import { warn, error, warnOnce } from '../../../utils.js';
|
|
33
34
|
|
|
34
35
|
const LOD_MIN = 4;
|
|
35
36
|
|
|
36
|
-
// The standard deviations (radians) associated with the extra mips.
|
|
37
|
-
//
|
|
38
|
-
// geometric shadowing function. These sigma values squared must match the
|
|
39
|
-
// variance #defines in cube_uv_reflection_fragment.glsl.js.
|
|
37
|
+
// The standard deviations (radians) associated with the extra mips.
|
|
38
|
+
// Used for scene blur in fromScene() method.
|
|
40
39
|
const EXTRA_LOD_SIGMA = [ 0.125, 0.215, 0.35, 0.446, 0.526, 0.582 ];
|
|
41
40
|
|
|
42
41
|
// The maximum length of the blur for loop. Smaller sigmas will use fewer
|
|
43
42
|
// samples and exit early, but not recompile the shader.
|
|
43
|
+
// Used for scene blur in fromScene() method.
|
|
44
44
|
const MAX_SAMPLES = 20;
|
|
45
45
|
|
|
46
|
+
// GGX VNDF importance sampling configuration
|
|
47
|
+
const GGX_SAMPLES = 512;
|
|
48
|
+
|
|
46
49
|
const _flatCamera = /*@__PURE__*/ new OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
|
|
47
50
|
const _cubeCamera = /*@__PURE__*/ new PerspectiveCamera( 90, 1 );
|
|
48
51
|
const _clearColor = /*@__PURE__*/ new Color();
|
|
@@ -50,25 +53,6 @@ let _oldTarget = null;
|
|
|
50
53
|
let _oldActiveCubeFace = 0;
|
|
51
54
|
let _oldActiveMipmapLevel = 0;
|
|
52
55
|
|
|
53
|
-
// Golden Ratio
|
|
54
|
-
const PHI = ( 1 + Math.sqrt( 5 ) ) / 2;
|
|
55
|
-
const INV_PHI = 1 / PHI;
|
|
56
|
-
|
|
57
|
-
// Vertices of a dodecahedron (except the opposites, which represent the
|
|
58
|
-
// same axis), used as axis directions evenly spread on a sphere.
|
|
59
|
-
const _axisDirections = [
|
|
60
|
-
/*@__PURE__*/ new Vector3( - PHI, INV_PHI, 0 ),
|
|
61
|
-
/*@__PURE__*/ new Vector3( PHI, INV_PHI, 0 ),
|
|
62
|
-
/*@__PURE__*/ new Vector3( - INV_PHI, 0, PHI ),
|
|
63
|
-
/*@__PURE__*/ new Vector3( INV_PHI, 0, PHI ),
|
|
64
|
-
/*@__PURE__*/ new Vector3( 0, PHI, - INV_PHI ),
|
|
65
|
-
/*@__PURE__*/ new Vector3( 0, PHI, INV_PHI ),
|
|
66
|
-
/*@__PURE__*/ new Vector3( - 1, 1, - 1 ),
|
|
67
|
-
/*@__PURE__*/ new Vector3( 1, 1, - 1 ),
|
|
68
|
-
/*@__PURE__*/ new Vector3( - 1, 1, 1 ),
|
|
69
|
-
/*@__PURE__*/ new Vector3( 1, 1, 1 )
|
|
70
|
-
];
|
|
71
|
-
|
|
72
56
|
const _origin = /*@__PURE__*/ new Vector3();
|
|
73
57
|
|
|
74
58
|
// maps blur materials to their uniforms dictionary
|
|
@@ -95,9 +79,11 @@ const _outputDirection = /*@__PURE__*/ vec3( _direction.x, _direction.y, _direct
|
|
|
95
79
|
* higher roughness levels. In this way we maintain resolution to smoothly
|
|
96
80
|
* interpolate diffuse lighting while limiting sampling computation.
|
|
97
81
|
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
|
|
82
|
+
* The prefiltering uses GGX VNDF (Visible Normal Distribution Function)
|
|
83
|
+
* importance sampling based on "Sampling the GGX Distribution of Visible Normals"
|
|
84
|
+
* (Heitz, 2018) to generate environment maps that accurately match the GGX BRDF
|
|
85
|
+
* used in material rendering for physically-based image-based lighting.
|
|
86
|
+
*/
|
|
101
87
|
class PMREMGenerator {
|
|
102
88
|
|
|
103
89
|
/**
|
|
@@ -112,12 +98,13 @@ class PMREMGenerator {
|
|
|
112
98
|
|
|
113
99
|
this._lodMax = 0;
|
|
114
100
|
this._cubeSize = 0;
|
|
115
|
-
this._lodPlanes = [];
|
|
116
101
|
this._sizeLods = [];
|
|
117
102
|
this._sigmas = [];
|
|
118
103
|
this._lodMeshes = [];
|
|
119
104
|
|
|
120
105
|
this._blurMaterial = null;
|
|
106
|
+
this._ggxMaterial = null;
|
|
107
|
+
|
|
121
108
|
this._cubemapMaterial = null;
|
|
122
109
|
this._equirectMaterial = null;
|
|
123
110
|
this._backgroundBox = null;
|
|
@@ -145,7 +132,7 @@ class PMREMGenerator {
|
|
|
145
132
|
* @param {Vector3} [options.renderTarget=origin] - The position of the internal cube camera that renders the scene.
|
|
146
133
|
* @param {?RenderTarget} [options.renderTarget=null] - The render target to use.
|
|
147
134
|
* @return {RenderTarget} The resulting PMREM.
|
|
148
|
-
* @see {@link PMREMGenerator#
|
|
135
|
+
* @see {@link PMREMGenerator#fromScene}
|
|
149
136
|
*/
|
|
150
137
|
fromScene( scene, sigma = 0, near = 0.1, far = 100, options = {} ) {
|
|
151
138
|
|
|
@@ -159,7 +146,7 @@ class PMREMGenerator {
|
|
|
159
146
|
|
|
160
147
|
if ( this._hasInitialized === false ) {
|
|
161
148
|
|
|
162
|
-
|
|
149
|
+
warn( 'PMREMGenerator: ".fromScene()" called before the backend is initialized. Try using "await renderer.init()" instead.' );
|
|
163
150
|
|
|
164
151
|
const cubeUVRenderTarget = renderTarget || this._allocateTarget();
|
|
165
152
|
|
|
@@ -203,6 +190,7 @@ class PMREMGenerator {
|
|
|
203
190
|
* and far planes ensure the scene is rendered in its entirety (the cubeCamera
|
|
204
191
|
* is placed at the origin).
|
|
205
192
|
*
|
|
193
|
+
* @deprecated
|
|
206
194
|
* @param {Scene} scene - The scene to be captured.
|
|
207
195
|
* @param {number} [sigma=0] - The blur radius in radians.
|
|
208
196
|
* @param {number} [near=0.1] - The near plane distance.
|
|
@@ -216,7 +204,9 @@ class PMREMGenerator {
|
|
|
216
204
|
*/
|
|
217
205
|
async fromSceneAsync( scene, sigma = 0, near = 0.1, far = 100, options = {} ) {
|
|
218
206
|
|
|
219
|
-
|
|
207
|
+
warnOnce( 'PMREMGenerator: ".fromSceneAsync()" is deprecated. Use "await renderer.init()" instead.' ); // @deprecated r181
|
|
208
|
+
|
|
209
|
+
await this._renderer.init();
|
|
220
210
|
|
|
221
211
|
return this.fromScene( scene, sigma, near, far, options );
|
|
222
212
|
|
|
@@ -236,7 +226,7 @@ class PMREMGenerator {
|
|
|
236
226
|
|
|
237
227
|
if ( this._hasInitialized === false ) {
|
|
238
228
|
|
|
239
|
-
|
|
229
|
+
warn( 'PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using "await renderer.init()" instead.' );
|
|
240
230
|
|
|
241
231
|
this._setSizeFromTexture( equirectangular );
|
|
242
232
|
|
|
@@ -257,6 +247,7 @@ class PMREMGenerator {
|
|
|
257
247
|
* or HDR. The ideal input image size is 1k (1024 x 512),
|
|
258
248
|
* as this matches best with the 256 x 256 cubemap output.
|
|
259
249
|
*
|
|
250
|
+
* @deprecated
|
|
260
251
|
* @param {Texture} equirectangular - The equirectangular texture to be converted.
|
|
261
252
|
* @param {?RenderTarget} [renderTarget=null] - The render target to use.
|
|
262
253
|
* @return {Promise<RenderTarget>} The resulting PMREM.
|
|
@@ -264,7 +255,9 @@ class PMREMGenerator {
|
|
|
264
255
|
*/
|
|
265
256
|
async fromEquirectangularAsync( equirectangular, renderTarget = null ) {
|
|
266
257
|
|
|
267
|
-
|
|
258
|
+
warnOnce( 'PMREMGenerator: ".fromEquirectangularAsync()" is deprecated. Use "await renderer.init()" instead.' ); // @deprecated r181
|
|
259
|
+
|
|
260
|
+
await this._renderer.init();
|
|
268
261
|
|
|
269
262
|
return this._fromTexture( equirectangular, renderTarget );
|
|
270
263
|
|
|
@@ -284,7 +277,7 @@ class PMREMGenerator {
|
|
|
284
277
|
|
|
285
278
|
if ( this._hasInitialized === false ) {
|
|
286
279
|
|
|
287
|
-
|
|
280
|
+
warn( 'PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead.' );
|
|
288
281
|
|
|
289
282
|
this._setSizeFromTexture( cubemap );
|
|
290
283
|
|
|
@@ -305,6 +298,7 @@ class PMREMGenerator {
|
|
|
305
298
|
* or HDR. The ideal input cube size is 256 x 256,
|
|
306
299
|
* with the 256 x 256 cubemap output.
|
|
307
300
|
*
|
|
301
|
+
* @deprecated
|
|
308
302
|
* @param {Texture} cubemap - The cubemap texture to be converted.
|
|
309
303
|
* @param {?RenderTarget} [renderTarget=null] - The render target to use.
|
|
310
304
|
* @return {Promise<RenderTarget>} The resulting PMREM.
|
|
@@ -312,7 +306,9 @@ class PMREMGenerator {
|
|
|
312
306
|
*/
|
|
313
307
|
async fromCubemapAsync( cubemap, renderTarget = null ) {
|
|
314
308
|
|
|
315
|
-
|
|
309
|
+
warnOnce( 'PMREMGenerator: ".fromCubemapAsync()" is deprecated. Use "await renderer.init()" instead.' ); // @deprecated r181
|
|
310
|
+
|
|
311
|
+
await this._renderer.init();
|
|
316
312
|
|
|
317
313
|
return this._fromTexture( cubemap, renderTarget );
|
|
318
314
|
|
|
@@ -398,12 +394,13 @@ class PMREMGenerator {
|
|
|
398
394
|
_dispose() {
|
|
399
395
|
|
|
400
396
|
if ( this._blurMaterial !== null ) this._blurMaterial.dispose();
|
|
397
|
+
if ( this._ggxMaterial !== null ) this._ggxMaterial.dispose();
|
|
401
398
|
|
|
402
399
|
if ( this._pingPongRenderTarget !== null ) this._pingPongRenderTarget.dispose();
|
|
403
400
|
|
|
404
|
-
for ( let i = 0; i < this.
|
|
401
|
+
for ( let i = 0; i < this._lodMeshes.length; i ++ ) {
|
|
405
402
|
|
|
406
|
-
this.
|
|
403
|
+
this._lodMeshes[ i ].geometry.dispose();
|
|
407
404
|
|
|
408
405
|
}
|
|
409
406
|
|
|
@@ -459,7 +456,7 @@ class PMREMGenerator {
|
|
|
459
456
|
this._pingPongRenderTarget = _createRenderTarget( renderTarget.width, renderTarget.height );
|
|
460
457
|
|
|
461
458
|
const { _lodMax } = this;
|
|
462
|
-
( {
|
|
459
|
+
( { lodMeshes: this._lodMeshes, sizeLods: this._sizeLods, sigmas: this._sigmas } = _createPlanes( _lodMax ) );
|
|
463
460
|
|
|
464
461
|
this._blurMaterial = _getBlurShader( _lodMax, renderTarget.width, renderTarget.height );
|
|
465
462
|
|
|
@@ -469,8 +466,8 @@ class PMREMGenerator {
|
|
|
469
466
|
|
|
470
467
|
async _compileMaterial( material ) {
|
|
471
468
|
|
|
472
|
-
const
|
|
473
|
-
await this._renderer.compile(
|
|
469
|
+
const mesh = new Mesh( new BufferGeometry(), material );
|
|
470
|
+
await this._renderer.compile( mesh, _flatCamera );
|
|
474
471
|
|
|
475
472
|
}
|
|
476
473
|
|
|
@@ -492,29 +489,32 @@ class PMREMGenerator {
|
|
|
492
489
|
|
|
493
490
|
renderer.autoClear = false;
|
|
494
491
|
|
|
495
|
-
|
|
492
|
+
if ( this._backgroundBox === null ) {
|
|
496
493
|
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
backgroundBox = new Mesh( new BoxGeometry(), backgroundMaterial );
|
|
494
|
+
this._backgroundBox = new Mesh(
|
|
495
|
+
new BoxGeometry(),
|
|
496
|
+
new MeshBasicMaterial( {
|
|
497
|
+
name: 'PMREM.Background',
|
|
498
|
+
side: BackSide,
|
|
499
|
+
depthWrite: false,
|
|
500
|
+
depthTest: false,
|
|
501
|
+
} )
|
|
502
|
+
);
|
|
507
503
|
|
|
508
504
|
}
|
|
509
505
|
|
|
506
|
+
const backgroundBox = this._backgroundBox;
|
|
507
|
+
const backgroundMaterial = backgroundBox.material;
|
|
508
|
+
|
|
510
509
|
let useSolidColor = false;
|
|
510
|
+
|
|
511
511
|
const background = scene.background;
|
|
512
512
|
|
|
513
513
|
if ( background ) {
|
|
514
514
|
|
|
515
515
|
if ( background.isColor ) {
|
|
516
516
|
|
|
517
|
-
|
|
517
|
+
backgroundMaterial.color.copy( background );
|
|
518
518
|
scene.background = null;
|
|
519
519
|
useSolidColor = true;
|
|
520
520
|
|
|
@@ -522,7 +522,7 @@ class PMREMGenerator {
|
|
|
522
522
|
|
|
523
523
|
} else {
|
|
524
524
|
|
|
525
|
-
|
|
525
|
+
backgroundMaterial.color.copy( _clearColor );
|
|
526
526
|
useSolidColor = true;
|
|
527
527
|
|
|
528
528
|
}
|
|
@@ -620,19 +620,83 @@ class PMREMGenerator {
|
|
|
620
620
|
const renderer = this._renderer;
|
|
621
621
|
const autoClear = renderer.autoClear;
|
|
622
622
|
renderer.autoClear = false;
|
|
623
|
-
const n = this._lodPlanes.length;
|
|
624
623
|
|
|
624
|
+
const n = this._lodMeshes.length;
|
|
625
|
+
|
|
626
|
+
// Use GGX VNDF importance sampling
|
|
625
627
|
for ( let i = 1; i < n; i ++ ) {
|
|
626
628
|
|
|
627
|
-
|
|
629
|
+
this._applyGGXFilter( cubeUVRenderTarget, i - 1, i );
|
|
628
630
|
|
|
629
|
-
|
|
631
|
+
}
|
|
630
632
|
|
|
631
|
-
|
|
633
|
+
renderer.autoClear = autoClear;
|
|
634
|
+
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* Applies GGX VNDF importance sampling filter to generate a prefiltered environment map.
|
|
639
|
+
* Uses Monte Carlo integration with VNDF importance sampling to accurately represent the
|
|
640
|
+
* GGX BRDF for physically-based rendering. Reads from the previous LOD level and
|
|
641
|
+
* applies incremental roughness filtering to avoid over-blurring.
|
|
642
|
+
*
|
|
643
|
+
* @private
|
|
644
|
+
* @param {RenderTarget} cubeUVRenderTarget
|
|
645
|
+
* @param {number} lodIn - Source LOD level to read from
|
|
646
|
+
* @param {number} lodOut - Target LOD level to write to
|
|
647
|
+
*/
|
|
648
|
+
_applyGGXFilter( cubeUVRenderTarget, lodIn, lodOut ) {
|
|
649
|
+
|
|
650
|
+
const renderer = this._renderer;
|
|
651
|
+
const pingPongRenderTarget = this._pingPongRenderTarget;
|
|
652
|
+
|
|
653
|
+
// Lazy create GGX material only when first used
|
|
654
|
+
if ( this._ggxMaterial === null ) {
|
|
655
|
+
|
|
656
|
+
this._ggxMaterial = _getGGXShader( this._lodMax, this._pingPongRenderTarget.width, this._pingPongRenderTarget.height );
|
|
632
657
|
|
|
633
658
|
}
|
|
634
659
|
|
|
635
|
-
|
|
660
|
+
const ggxMaterial = this._ggxMaterial;
|
|
661
|
+
const ggxMesh = this._lodMeshes[ lodOut ];
|
|
662
|
+
ggxMesh.material = ggxMaterial;
|
|
663
|
+
|
|
664
|
+
const ggxUniforms = _uniformsMap.get( ggxMaterial );
|
|
665
|
+
|
|
666
|
+
// Calculate incremental roughness between LOD levels
|
|
667
|
+
const targetRoughness = lodOut / ( this._lodMeshes.length - 1 );
|
|
668
|
+
const sourceRoughness = lodIn / ( this._lodMeshes.length - 1 );
|
|
669
|
+
const incrementalRoughness = Math.sqrt( targetRoughness * targetRoughness - sourceRoughness * sourceRoughness );
|
|
670
|
+
|
|
671
|
+
// Apply blur strength mapping for better quality across the roughness range
|
|
672
|
+
const blurStrength = 0.05 + targetRoughness * 0.95;
|
|
673
|
+
const adjustedRoughness = incrementalRoughness * blurStrength;
|
|
674
|
+
|
|
675
|
+
// Calculate viewport position based on output LOD level
|
|
676
|
+
const { _lodMax } = this;
|
|
677
|
+
const outputSize = this._sizeLods[ lodOut ];
|
|
678
|
+
const x = 3 * outputSize * ( lodOut > _lodMax - LOD_MIN ? lodOut - _lodMax + LOD_MIN : 0 );
|
|
679
|
+
const y = 4 * ( this._cubeSize - outputSize );
|
|
680
|
+
|
|
681
|
+
// Read from previous LOD with incremental roughness
|
|
682
|
+
cubeUVRenderTarget.texture.frame = ( cubeUVRenderTarget.texture.frame || 0 ) + 1;
|
|
683
|
+
ggxUniforms.envMap.value = cubeUVRenderTarget.texture;
|
|
684
|
+
ggxUniforms.roughness.value = adjustedRoughness;
|
|
685
|
+
ggxUniforms.mipInt.value = _lodMax - lodIn; // Sample from input LOD
|
|
686
|
+
|
|
687
|
+
_setViewport( pingPongRenderTarget, x, y, 3 * outputSize, 2 * outputSize );
|
|
688
|
+
renderer.setRenderTarget( pingPongRenderTarget );
|
|
689
|
+
renderer.render( ggxMesh, _flatCamera );
|
|
690
|
+
|
|
691
|
+
// Copy from pingPong back to cubeUV (simple direct copy)
|
|
692
|
+
pingPongRenderTarget.texture.frame = ( pingPongRenderTarget.texture.frame || 0 ) + 1;
|
|
693
|
+
ggxUniforms.envMap.value = pingPongRenderTarget.texture;
|
|
694
|
+
ggxUniforms.roughness.value = 0.0; // Direct copy
|
|
695
|
+
ggxUniforms.mipInt.value = _lodMax - lodOut; // Read from the level we just wrote
|
|
696
|
+
|
|
697
|
+
_setViewport( cubeUVRenderTarget, x, y, 3 * outputSize, 2 * outputSize );
|
|
698
|
+
renderer.setRenderTarget( cubeUVRenderTarget );
|
|
699
|
+
renderer.render( ggxMesh, _flatCamera );
|
|
636
700
|
|
|
637
701
|
}
|
|
638
702
|
|
|
@@ -643,6 +707,8 @@ class PMREMGenerator {
|
|
|
643
707
|
* the poles) to approximate the orthogonally-separable blur. It is least
|
|
644
708
|
* accurate at the poles, but still does a decent job.
|
|
645
709
|
*
|
|
710
|
+
* Used for initial scene blur in fromScene() method when sigma > 0.
|
|
711
|
+
*
|
|
646
712
|
* @private
|
|
647
713
|
* @param {RenderTarget} cubeUVRenderTarget - The cubemap render target.
|
|
648
714
|
* @param {number} lodIn - The input level-of-detail.
|
|
@@ -681,7 +747,7 @@ class PMREMGenerator {
|
|
|
681
747
|
|
|
682
748
|
if ( direction !== 'latitudinal' && direction !== 'longitudinal' ) {
|
|
683
749
|
|
|
684
|
-
|
|
750
|
+
error( 'blur direction must be either latitudinal or longitudinal!' );
|
|
685
751
|
|
|
686
752
|
}
|
|
687
753
|
|
|
@@ -700,7 +766,7 @@ class PMREMGenerator {
|
|
|
700
766
|
|
|
701
767
|
if ( samples > MAX_SAMPLES ) {
|
|
702
768
|
|
|
703
|
-
|
|
769
|
+
warn( `sigmaRadians, ${
|
|
704
770
|
sigmaRadians}, is too large and will clip, as it requested ${
|
|
705
771
|
samples} samples when the maximum is set to ${MAX_SAMPLES}` );
|
|
706
772
|
|
|
@@ -764,7 +830,6 @@ class PMREMGenerator {
|
|
|
764
830
|
|
|
765
831
|
function _createPlanes( lodMax ) {
|
|
766
832
|
|
|
767
|
-
const lodPlanes = [];
|
|
768
833
|
const sizeLods = [];
|
|
769
834
|
const sigmas = [];
|
|
770
835
|
const lodMeshes = [];
|
|
@@ -831,7 +896,6 @@ function _createPlanes( lodMax ) {
|
|
|
831
896
|
planes.setAttribute( 'position', new BufferAttribute( position, positionSize ) );
|
|
832
897
|
planes.setAttribute( 'uv', new BufferAttribute( uv, uvSize ) );
|
|
833
898
|
planes.setAttribute( 'faceIndex', new BufferAttribute( faceIndex, faceIndexSize ) );
|
|
834
|
-
lodPlanes.push( planes );
|
|
835
899
|
lodMeshes.push( new Mesh( planes, null ) );
|
|
836
900
|
|
|
837
901
|
if ( lod > LOD_MIN ) {
|
|
@@ -842,7 +906,7 @@ function _createPlanes( lodMax ) {
|
|
|
842
906
|
|
|
843
907
|
}
|
|
844
908
|
|
|
845
|
-
return {
|
|
909
|
+
return { lodMeshes, sizeLods, sigmas };
|
|
846
910
|
|
|
847
911
|
}
|
|
848
912
|
|
|
@@ -894,7 +958,7 @@ function _getBlurShader( lodMax, width, height ) {
|
|
|
894
958
|
const n = float( MAX_SAMPLES );
|
|
895
959
|
const latitudinal = uniform( 0 ); // false, bool
|
|
896
960
|
const samples = uniform( 1 ); // int
|
|
897
|
-
const envMap = texture(
|
|
961
|
+
const envMap = texture();
|
|
898
962
|
const mipInt = uniform( 0 ); // int
|
|
899
963
|
const CUBEUV_TEXEL_WIDTH = float( 1 / width );
|
|
900
964
|
const CUBEUV_TEXEL_HEIGHT = float( 1 / height );
|
|
@@ -924,6 +988,37 @@ function _getBlurShader( lodMax, width, height ) {
|
|
|
924
988
|
|
|
925
989
|
}
|
|
926
990
|
|
|
991
|
+
function _getGGXShader( lodMax, width, height ) {
|
|
992
|
+
|
|
993
|
+
const envMap = texture();
|
|
994
|
+
const roughness = uniform( 0 );
|
|
995
|
+
const mipInt = uniform( 0 );
|
|
996
|
+
const CUBEUV_TEXEL_WIDTH = float( 1 / width );
|
|
997
|
+
const CUBEUV_TEXEL_HEIGHT = float( 1 / height );
|
|
998
|
+
const CUBEUV_MAX_MIP = float( lodMax );
|
|
999
|
+
|
|
1000
|
+
const materialUniforms = {
|
|
1001
|
+
envMap,
|
|
1002
|
+
roughness,
|
|
1003
|
+
mipInt,
|
|
1004
|
+
CUBEUV_TEXEL_WIDTH,
|
|
1005
|
+
CUBEUV_TEXEL_HEIGHT,
|
|
1006
|
+
CUBEUV_MAX_MIP
|
|
1007
|
+
};
|
|
1008
|
+
|
|
1009
|
+
const material = _getMaterial( 'ggx' );
|
|
1010
|
+
material.fragmentNode = ggxConvolution( {
|
|
1011
|
+
...materialUniforms,
|
|
1012
|
+
N_immutable: _outputDirection,
|
|
1013
|
+
GGX_SAMPLES: uint( GGX_SAMPLES )
|
|
1014
|
+
} );
|
|
1015
|
+
|
|
1016
|
+
_uniformsMap.set( material, materialUniforms );
|
|
1017
|
+
|
|
1018
|
+
return material;
|
|
1019
|
+
|
|
1020
|
+
}
|
|
1021
|
+
|
|
927
1022
|
function _getCubemapMaterial( envTexture ) {
|
|
928
1023
|
|
|
929
1024
|
const material = _getMaterial( 'cubemap' );
|
|
@@ -126,7 +126,7 @@ class NodeBuilderState {
|
|
|
126
126
|
|
|
127
127
|
if ( shared !== true ) {
|
|
128
128
|
|
|
129
|
-
const bindingsGroup = new BindGroup( instanceGroup.name, [], instanceGroup.index, instanceGroup );
|
|
129
|
+
const bindingsGroup = new BindGroup( instanceGroup.name, [], instanceGroup.index, instanceGroup.bindingsReference );
|
|
130
130
|
bindings.push( bindingsGroup );
|
|
131
131
|
|
|
132
132
|
for ( const instanceBinding of instanceGroup.bindings ) {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { warn } from '../../../utils.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* The purpose of a node library is to assign node implementations
|
|
3
5
|
* to existing library features. In `WebGPURenderer` lights, materials
|
|
@@ -146,15 +148,15 @@ class NodeLibrary {
|
|
|
146
148
|
/**
|
|
147
149
|
* Adds a node class definition for the given type to the provided type library.
|
|
148
150
|
*
|
|
149
|
-
* @param {
|
|
151
|
+
* @param {Node.constructor} nodeClass - The node class definition.
|
|
150
152
|
* @param {number|string} type - The object type.
|
|
151
|
-
* @param {Map} library - The type library.
|
|
153
|
+
* @param {Map<number|string,Node.constructor>} library - The type library.
|
|
152
154
|
*/
|
|
153
155
|
addType( nodeClass, type, library ) {
|
|
154
156
|
|
|
155
157
|
if ( library.has( type ) ) {
|
|
156
158
|
|
|
157
|
-
|
|
159
|
+
warn( `Redefinition of node ${ type }` );
|
|
158
160
|
return;
|
|
159
161
|
|
|
160
162
|
}
|
|
@@ -169,15 +171,15 @@ class NodeLibrary {
|
|
|
169
171
|
/**
|
|
170
172
|
* Adds a node class definition for the given class definition to the provided type library.
|
|
171
173
|
*
|
|
172
|
-
* @param {
|
|
173
|
-
* @param {
|
|
174
|
-
* @param {WeakMap} library - The type library.
|
|
174
|
+
* @param {Node.constructor} nodeClass - The node class definition.
|
|
175
|
+
* @param {Node.constructor} baseClass - The class definition.
|
|
176
|
+
* @param {WeakMap<Node.constructor, Node.constructor>} library - The type library.
|
|
175
177
|
*/
|
|
176
178
|
addClass( nodeClass, baseClass, library ) {
|
|
177
179
|
|
|
178
180
|
if ( library.has( baseClass ) ) {
|
|
179
181
|
|
|
180
|
-
|
|
182
|
+
warn( `Redefinition of node ${ baseClass.name }` );
|
|
181
183
|
return;
|
|
182
184
|
|
|
183
185
|
}
|