@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
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { reference, viewZToPerspectiveDepth, logarithmicDepthToViewZ, getScreenPosition, getViewPosition, sqrt, mul, div, cross, float, Continue, Break, Loop, int, max, abs, sub, If, dot, reflect, normalize, screenCoordinate, nodeObject, Fn, passTexture, uv, uniform, perspectiveDepthToViewZ, orthographicDepthToViewZ, vec2, vec3, vec4 } from 'three/tsl';
|
|
1
|
+
import { HalfFloatType, RenderTarget, Vector2, RendererUtils, QuadMesh, TempNode, NodeMaterial, NodeUpdateType, LinearFilter, LinearMipmapLinearFilter } from 'three/webgpu';
|
|
2
|
+
import { texture, reference, viewZToPerspectiveDepth, logarithmicDepthToViewZ, getScreenPosition, getViewPosition, sqrt, mul, div, cross, float, Continue, Break, Loop, int, max, abs, sub, If, dot, reflect, normalize, screenCoordinate, nodeObject, Fn, passTexture, uv, uniform, perspectiveDepthToViewZ, orthographicDepthToViewZ, vec2, vec3, vec4 } from 'three/tsl';
|
|
3
|
+
import { boxBlur } from './boxBlur.js';
|
|
3
4
|
|
|
4
5
|
const _quadMesh = /*@__PURE__*/ new QuadMesh();
|
|
5
6
|
const _size = /*@__PURE__*/ new Vector2();
|
|
@@ -28,9 +29,10 @@ class SSRNode extends TempNode {
|
|
|
28
29
|
* @param {Node<float>} depthNode - A node that represents the beauty pass's depth.
|
|
29
30
|
* @param {Node<vec3>} normalNode - A node that represents the beauty pass's normals.
|
|
30
31
|
* @param {Node<float>} metalnessNode - A node that represents the beauty pass's metalness.
|
|
31
|
-
* @param {
|
|
32
|
+
* @param {?Node<float>} [roughnessNode=null] - A node that represents the beauty pass's roughness.
|
|
33
|
+
* @param {?Camera} [camera=null] - The camera the scene is rendered with.
|
|
32
34
|
*/
|
|
33
|
-
constructor( colorNode, depthNode, normalNode, metalnessNode, camera ) {
|
|
35
|
+
constructor( colorNode, depthNode, normalNode, metalnessNode, roughnessNode = null, camera = null ) {
|
|
34
36
|
|
|
35
37
|
super( 'vec4' );
|
|
36
38
|
|
|
@@ -63,22 +65,26 @@ class SSRNode extends TempNode {
|
|
|
63
65
|
this.metalnessNode = metalnessNode;
|
|
64
66
|
|
|
65
67
|
/**
|
|
66
|
-
*
|
|
68
|
+
* Whether the SSR reflections should be blurred or not. Blurring is a costly
|
|
69
|
+
* operation so turn it off if you encounter performance issues on certain
|
|
70
|
+
* devices.
|
|
67
71
|
*
|
|
68
|
-
* @
|
|
72
|
+
* @private
|
|
73
|
+
* @type {Node<float>}
|
|
74
|
+
* @default false
|
|
69
75
|
*/
|
|
70
|
-
this.
|
|
76
|
+
this.roughnessNode = roughnessNode;
|
|
71
77
|
|
|
72
78
|
/**
|
|
73
|
-
* The resolution scale.
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
79
|
+
* The resolution scale. Valid values are in the range
|
|
80
|
+
* `[0,1]`. `1` means best quality but also results in
|
|
81
|
+
* more computational overhead. Setting to `0.5` means
|
|
82
|
+
* the effect is computed in half-resolution.
|
|
77
83
|
*
|
|
78
84
|
* @type {number}
|
|
79
|
-
* @default
|
|
85
|
+
* @default 1
|
|
80
86
|
*/
|
|
81
|
-
this.resolutionScale =
|
|
87
|
+
this.resolutionScale = 1;
|
|
82
88
|
|
|
83
89
|
/**
|
|
84
90
|
* The `updateBeforeType` is set to `NodeUpdateType.FRAME` since the node renders
|
|
@@ -90,17 +96,8 @@ class SSRNode extends TempNode {
|
|
|
90
96
|
this.updateBeforeType = NodeUpdateType.FRAME;
|
|
91
97
|
|
|
92
98
|
/**
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
* @private
|
|
96
|
-
* @type {RenderTarget}
|
|
97
|
-
*/
|
|
98
|
-
this._ssrRenderTarget = new RenderTarget( 1, 1, { depthBuffer: false, minFilter: NearestFilter, magFilter: NearestFilter } );
|
|
99
|
-
this._ssrRenderTarget.texture.name = 'SSRNode.SSR';
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Controls how far a fragment can reflect.
|
|
103
|
-
*
|
|
99
|
+
* Controls how far a fragment can reflect. Increasing this value result in more
|
|
100
|
+
* computational overhead but also increases the reflection distance.
|
|
104
101
|
*
|
|
105
102
|
* @type {UniformNode<float>}
|
|
106
103
|
*/
|
|
@@ -114,12 +111,63 @@ class SSRNode extends TempNode {
|
|
|
114
111
|
this.thickness = uniform( 0.1 );
|
|
115
112
|
|
|
116
113
|
/**
|
|
117
|
-
* Controls the
|
|
114
|
+
* Controls how the SSR reflections are blended with the beauty pass.
|
|
118
115
|
*
|
|
119
116
|
* @type {UniformNode<float>}
|
|
120
117
|
*/
|
|
121
118
|
this.opacity = uniform( 1 );
|
|
122
119
|
|
|
120
|
+
/**
|
|
121
|
+
* This parameter controls how detailed the raymarching process works.
|
|
122
|
+
* The value ranges is `[0,1]` where `1` means best quality (the maximum number
|
|
123
|
+
* of raymarching iterations/samples) and `0` means no samples at all.
|
|
124
|
+
*
|
|
125
|
+
* A quality of `0.5` is usually sufficient for most use cases. Try to keep
|
|
126
|
+
* this parameter as low as possible. Larger values result in noticeable more
|
|
127
|
+
* overhead.
|
|
128
|
+
*
|
|
129
|
+
* @type {UniformNode<float>}
|
|
130
|
+
*/
|
|
131
|
+
this.quality = uniform( 0.5 );
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* The quality of the blur. Must be an integer in the range `[1,3]`.
|
|
135
|
+
*
|
|
136
|
+
* @type {UniformNode<int>}
|
|
137
|
+
*/
|
|
138
|
+
this.blurQuality = uniform( 2 );
|
|
139
|
+
|
|
140
|
+
//
|
|
141
|
+
|
|
142
|
+
if ( camera === null ) {
|
|
143
|
+
|
|
144
|
+
if ( this.colorNode.passNode && this.colorNode.passNode.isPassNode === true ) {
|
|
145
|
+
|
|
146
|
+
camera = this.colorNode.passNode.camera;
|
|
147
|
+
|
|
148
|
+
} else {
|
|
149
|
+
|
|
150
|
+
throw new Error( 'THREE.TSL: No camera found. ssr() requires a camera.' );
|
|
151
|
+
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* The camera the scene is rendered with.
|
|
158
|
+
*
|
|
159
|
+
* @type {Camera}
|
|
160
|
+
*/
|
|
161
|
+
this.camera = camera;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* The spread of the blur. Automatically set when generating mips.
|
|
165
|
+
*
|
|
166
|
+
* @private
|
|
167
|
+
* @type {UniformNode<int>}
|
|
168
|
+
*/
|
|
169
|
+
this._blurSpread = uniform( 1 );
|
|
170
|
+
|
|
123
171
|
/**
|
|
124
172
|
* Represents the projection matrix of the scene's camera.
|
|
125
173
|
*
|
|
@@ -158,7 +206,7 @@ class SSRNode extends TempNode {
|
|
|
158
206
|
* @private
|
|
159
207
|
* @type {UniformNode<bool>}
|
|
160
208
|
*/
|
|
161
|
-
this._isPerspectiveCamera = uniform( camera.isPerspectiveCamera
|
|
209
|
+
this._isPerspectiveCamera = uniform( camera.isPerspectiveCamera );
|
|
162
210
|
|
|
163
211
|
/**
|
|
164
212
|
* The resolution of the pass.
|
|
@@ -169,13 +217,23 @@ class SSRNode extends TempNode {
|
|
|
169
217
|
this._resolution = uniform( new Vector2() );
|
|
170
218
|
|
|
171
219
|
/**
|
|
172
|
-
*
|
|
173
|
-
* the maximum raymarching steps in the fragment shader.
|
|
220
|
+
* The render target the SSR is rendered into.
|
|
174
221
|
*
|
|
175
222
|
* @private
|
|
176
|
-
* @type {
|
|
223
|
+
* @type {RenderTarget}
|
|
224
|
+
*/
|
|
225
|
+
this._ssrRenderTarget = new RenderTarget( 1, 1, { depthBuffer: false, type: HalfFloatType } );
|
|
226
|
+
this._ssrRenderTarget.texture.name = 'SSRNode.SSR';
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* The render target for the blurred SSR reflections.
|
|
230
|
+
*
|
|
231
|
+
* @private
|
|
232
|
+
* @type {RenderTarget}
|
|
177
233
|
*/
|
|
178
|
-
this.
|
|
234
|
+
this._blurRenderTarget = new RenderTarget( 1, 1, { depthBuffer: false, type: HalfFloatType, minFilter: LinearMipmapLinearFilter, magFilter: LinearFilter } );
|
|
235
|
+
this._blurRenderTarget.texture.name = 'SSRNode.Blur';
|
|
236
|
+
this._blurRenderTarget.texture.mipmaps.push( {}, {}, {}, {}, {} );
|
|
179
237
|
|
|
180
238
|
/**
|
|
181
239
|
* The material that is used to render the effect.
|
|
@@ -183,8 +241,26 @@ class SSRNode extends TempNode {
|
|
|
183
241
|
* @private
|
|
184
242
|
* @type {NodeMaterial}
|
|
185
243
|
*/
|
|
186
|
-
this.
|
|
187
|
-
this.
|
|
244
|
+
this._ssrMaterial = new NodeMaterial();
|
|
245
|
+
this._ssrMaterial.name = 'SSRNode.SSR';
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* The blur material.
|
|
249
|
+
*
|
|
250
|
+
* @private
|
|
251
|
+
* @type {NodeMaterial}
|
|
252
|
+
*/
|
|
253
|
+
this._blurMaterial = new NodeMaterial();
|
|
254
|
+
this._blurMaterial.name = 'SSRNode.Blur';
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* The copy material.
|
|
258
|
+
*
|
|
259
|
+
* @private
|
|
260
|
+
* @type {NodeMaterial}
|
|
261
|
+
*/
|
|
262
|
+
this._copyMaterial = new NodeMaterial();
|
|
263
|
+
this._copyMaterial.name = 'SSRNode.Copy';
|
|
188
264
|
|
|
189
265
|
/**
|
|
190
266
|
* The result of the effect is represented as a separate texture node.
|
|
@@ -194,6 +270,25 @@ class SSRNode extends TempNode {
|
|
|
194
270
|
*/
|
|
195
271
|
this._textureNode = passTexture( this, this._ssrRenderTarget.texture );
|
|
196
272
|
|
|
273
|
+
let blurredTextureNode = null;
|
|
274
|
+
|
|
275
|
+
if ( this.roughnessNode !== null ) {
|
|
276
|
+
|
|
277
|
+
const mips = this._blurRenderTarget.texture.mipmaps.length - 1;
|
|
278
|
+
const lod = float( this.roughnessNode ).mul( mips ).clamp( 0, mips );
|
|
279
|
+
|
|
280
|
+
blurredTextureNode = passTexture( this, this._blurRenderTarget.texture ).level( lod );
|
|
281
|
+
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Holds the blurred SSR reflections.
|
|
286
|
+
*
|
|
287
|
+
* @private
|
|
288
|
+
* @type {?PassTextureNode}
|
|
289
|
+
*/
|
|
290
|
+
this._blurredTextureNode = blurredTextureNode;
|
|
291
|
+
|
|
197
292
|
}
|
|
198
293
|
|
|
199
294
|
/**
|
|
@@ -203,7 +298,7 @@ class SSRNode extends TempNode {
|
|
|
203
298
|
*/
|
|
204
299
|
getTextureNode() {
|
|
205
300
|
|
|
206
|
-
return this._textureNode;
|
|
301
|
+
return this.roughnessNode !== null ? this._blurredTextureNode : this._textureNode;
|
|
207
302
|
|
|
208
303
|
}
|
|
209
304
|
|
|
@@ -219,9 +314,8 @@ class SSRNode extends TempNode {
|
|
|
219
314
|
height = Math.round( this.resolutionScale * height );
|
|
220
315
|
|
|
221
316
|
this._resolution.value.set( width, height );
|
|
222
|
-
this._maxStep.value = Math.round( Math.sqrt( width * width + height * height ) );
|
|
223
|
-
|
|
224
317
|
this._ssrRenderTarget.setSize( width, height );
|
|
318
|
+
this._blurRenderTarget.setSize( width, height );
|
|
225
319
|
|
|
226
320
|
}
|
|
227
321
|
|
|
@@ -236,9 +330,12 @@ class SSRNode extends TempNode {
|
|
|
236
330
|
|
|
237
331
|
_rendererState = RendererUtils.resetRendererState( renderer, _rendererState );
|
|
238
332
|
|
|
333
|
+
const ssrRenderTarget = this._ssrRenderTarget;
|
|
334
|
+
const blurRenderTarget = this._blurRenderTarget;
|
|
335
|
+
|
|
239
336
|
const size = renderer.getDrawingBufferSize( _size );
|
|
240
337
|
|
|
241
|
-
_quadMesh.material = this.
|
|
338
|
+
_quadMesh.material = this._ssrMaterial;
|
|
242
339
|
|
|
243
340
|
this.setSize( size.width, size.height );
|
|
244
341
|
|
|
@@ -249,9 +346,29 @@ class SSRNode extends TempNode {
|
|
|
249
346
|
|
|
250
347
|
// ssr
|
|
251
348
|
|
|
252
|
-
renderer.setRenderTarget(
|
|
349
|
+
renderer.setRenderTarget( ssrRenderTarget );
|
|
350
|
+
_quadMesh.name = 'SSR [ Reflections ]';
|
|
253
351
|
_quadMesh.render( renderer );
|
|
254
352
|
|
|
353
|
+
// blur (optional)
|
|
354
|
+
|
|
355
|
+
if ( this.roughnessNode !== null ) {
|
|
356
|
+
|
|
357
|
+
// blur mips but leave the base mip unblurred
|
|
358
|
+
|
|
359
|
+
for ( let i = 0; i < blurRenderTarget.texture.mipmaps.length; i ++ ) {
|
|
360
|
+
|
|
361
|
+
_quadMesh.material = ( i === 0 ) ? this._copyMaterial : this._blurMaterial;
|
|
362
|
+
|
|
363
|
+
this._blurSpread.value = i;
|
|
364
|
+
renderer.setRenderTarget( blurRenderTarget, 0, i );
|
|
365
|
+
_quadMesh.name = 'SSR [ Blur Level ' + i + ' ]';
|
|
366
|
+
_quadMesh.render( renderer );
|
|
367
|
+
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
}
|
|
371
|
+
|
|
255
372
|
// restore
|
|
256
373
|
|
|
257
374
|
RendererUtils.restoreRendererState( renderer, _rendererState );
|
|
@@ -326,7 +443,7 @@ class SSRNode extends TempNode {
|
|
|
326
443
|
|
|
327
444
|
const ssr = Fn( () => {
|
|
328
445
|
|
|
329
|
-
const metalness = this.metalnessNode
|
|
446
|
+
const metalness = float( this.metalnessNode );
|
|
330
447
|
|
|
331
448
|
// fragments with no metalness do not reflect their environment
|
|
332
449
|
metalness.equal( 0.0 ).discard();
|
|
@@ -349,7 +466,7 @@ class SSRNode extends TempNode {
|
|
|
349
466
|
const d1viewPosition = viewPosition.add( viewReflectDir.mul( maxReflectRayLen ) ).toVar();
|
|
350
467
|
|
|
351
468
|
// check if d1viewPosition lies behind the camera near plane
|
|
352
|
-
If( this._isPerspectiveCamera.
|
|
469
|
+
If( this._isPerspectiveCamera.and( d1viewPosition.z.greaterThan( this._cameraNear.negate() ) ), () => {
|
|
353
470
|
|
|
354
471
|
// if so, ensure d1viewPosition is clamped on the near plane.
|
|
355
472
|
// this prevents artifacts during the ray marching process
|
|
@@ -374,7 +491,7 @@ class SSRNode extends TempNode {
|
|
|
374
491
|
// determine the larger delta
|
|
375
492
|
// The larger difference will help to determine how much to travel in the X and Y direction each iteration and
|
|
376
493
|
// how many iterations are needed to travel the entire ray
|
|
377
|
-
const totalStep = max( abs( xLen ), abs( yLen ) ).
|
|
494
|
+
const totalStep = int( max( abs( xLen ), abs( yLen ) ).mul( this.quality.clamp() ) ).toConst();
|
|
378
495
|
|
|
379
496
|
// step sizes in the x and y directions
|
|
380
497
|
const xSpan = xLen.div( totalStep ).toVar();
|
|
@@ -385,23 +502,9 @@ class SSRNode extends TempNode {
|
|
|
385
502
|
// the actual ray marching loop
|
|
386
503
|
// starting from d0, the code gradually travels along the ray and looks for an intersection with the geometry.
|
|
387
504
|
// it does not exceed d1 (the maximum ray extend)
|
|
388
|
-
Loop(
|
|
389
|
-
|
|
390
|
-
// TODO: Remove this when Chrome is fixed, see https://issues.chromium.org/issues/372714384#comment14
|
|
391
|
-
If( metalness.equal( 0 ), () => {
|
|
505
|
+
Loop( totalStep, ( { i } ) => {
|
|
392
506
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
} );
|
|
396
|
-
|
|
397
|
-
// stop if the maximum number of steps is reached for this specific ray
|
|
398
|
-
If( float( i ).greaterThanEqual( totalStep ), () => {
|
|
399
|
-
|
|
400
|
-
Break();
|
|
401
|
-
|
|
402
|
-
} );
|
|
403
|
-
|
|
404
|
-
// advance on the ray by computing a new position in screen space
|
|
507
|
+
// advance on the ray by computing a new position in screen coordinates
|
|
405
508
|
const xy = vec2( d0.x.add( xSpan.mul( float( i ) ) ), d0.y.add( ySpan.mul( float( i ) ) ) ).toVar();
|
|
406
509
|
|
|
407
510
|
// stop processing if the new position lies outside of the screen
|
|
@@ -411,11 +514,10 @@ class SSRNode extends TempNode {
|
|
|
411
514
|
|
|
412
515
|
} );
|
|
413
516
|
|
|
414
|
-
// compute new uv, depth
|
|
517
|
+
// compute new uv, depth and viewZ for the next fragment
|
|
415
518
|
const uvNode = xy.div( this._resolution );
|
|
416
519
|
const d = sampleDepth( uvNode ).toVar();
|
|
417
520
|
const vZ = getViewZ( d ).toVar();
|
|
418
|
-
const vP = getViewPosition( uvNode, d, this._cameraProjectionMatrixInverse ).toVar();
|
|
419
521
|
|
|
420
522
|
const viewReflectRayZ = float( 0 ).toVar();
|
|
421
523
|
|
|
@@ -423,7 +525,7 @@ class SSRNode extends TempNode {
|
|
|
423
525
|
const s = xy.sub( d0 ).length().div( totalLen );
|
|
424
526
|
|
|
425
527
|
// depending on the camera type, we now compute the z-coordinate of the reflected ray at the current step in view space
|
|
426
|
-
If( this._isPerspectiveCamera
|
|
528
|
+
If( this._isPerspectiveCamera, () => {
|
|
427
529
|
|
|
428
530
|
const recipVPZ = float( 1 ).div( viewPosition.z ).toVar();
|
|
429
531
|
viewReflectRayZ.assign( float( 1 ).div( recipVPZ.add( s.mul( float( 1 ).div( d1viewPosition.z ).sub( recipVPZ ) ) ) ) );
|
|
@@ -439,6 +541,7 @@ class SSRNode extends TempNode {
|
|
|
439
541
|
|
|
440
542
|
// compute the distance of the new location to the ray in view space
|
|
441
543
|
// to clarify vP is the fragment's view position which is not an exact point on the ray
|
|
544
|
+
const vP = getViewPosition( uvNode, d, this._cameraProjectionMatrixInverse ).toVar();
|
|
442
545
|
const away = pointToLineDistance( vP, viewPosition, d1viewPosition ).toVar();
|
|
443
546
|
|
|
444
547
|
// compute the minimum thickness between the current fragment and its neighbor in the x-direction.
|
|
@@ -499,12 +602,22 @@ class SSRNode extends TempNode {
|
|
|
499
602
|
|
|
500
603
|
} );
|
|
501
604
|
|
|
502
|
-
this.
|
|
503
|
-
this.
|
|
605
|
+
this._ssrMaterial.fragmentNode = ssr().context( builder.getSharedContext() );
|
|
606
|
+
this._ssrMaterial.needsUpdate = true;
|
|
607
|
+
|
|
608
|
+
// below materials are used for blurring
|
|
609
|
+
|
|
610
|
+
const reflectionBuffer = texture( this._ssrRenderTarget.texture );
|
|
611
|
+
|
|
612
|
+
this._blurMaterial.fragmentNode = boxBlur( reflectionBuffer, { size: this.blurQuality, separation: this._blurSpread } );
|
|
613
|
+
this._blurMaterial.needsUpdate = true;
|
|
614
|
+
|
|
615
|
+
this._copyMaterial.fragmentNode = reflectionBuffer;
|
|
616
|
+
this._copyMaterial.needsUpdate = true;
|
|
504
617
|
|
|
505
618
|
//
|
|
506
619
|
|
|
507
|
-
return this.
|
|
620
|
+
return this.getTextureNode();
|
|
508
621
|
|
|
509
622
|
}
|
|
510
623
|
|
|
@@ -515,8 +628,11 @@ class SSRNode extends TempNode {
|
|
|
515
628
|
dispose() {
|
|
516
629
|
|
|
517
630
|
this._ssrRenderTarget.dispose();
|
|
631
|
+
this._blurRenderTarget.dispose();
|
|
518
632
|
|
|
519
|
-
this.
|
|
633
|
+
this._ssrMaterial.dispose();
|
|
634
|
+
this._blurMaterial.dispose();
|
|
635
|
+
this._copyMaterial.dispose();
|
|
520
636
|
|
|
521
637
|
}
|
|
522
638
|
|
|
@@ -533,7 +649,8 @@ export default SSRNode;
|
|
|
533
649
|
* @param {Node<float>} depthNode - A node that represents the beauty pass's depth.
|
|
534
650
|
* @param {Node<vec3>} normalNode - A node that represents the beauty pass's normals.
|
|
535
651
|
* @param {Node<float>} metalnessNode - A node that represents the beauty pass's metalness.
|
|
536
|
-
* @param {
|
|
652
|
+
* @param {?Node<float>} [roughnessNode=null] - A node that represents the beauty pass's roughness.
|
|
653
|
+
* @param {?Camera} [camera=null] - The camera the scene is rendered with.
|
|
537
654
|
* @returns {SSRNode}
|
|
538
655
|
*/
|
|
539
|
-
export const ssr = ( colorNode, depthNode, normalNode, metalnessNode, camera ) => nodeObject( new SSRNode( nodeObject( colorNode ), nodeObject( depthNode ), nodeObject( normalNode ), nodeObject( metalnessNode ), camera ) );
|
|
656
|
+
export const ssr = ( colorNode, depthNode, normalNode, metalnessNode, roughnessNode = null, camera = null ) => nodeObject( new SSRNode( nodeObject( colorNode ), nodeObject( depthNode ), nodeObject( normalNode ), nodeObject( metalnessNode ), nodeObject( roughnessNode ), camera ) );
|