super-three 0.170.1 → 0.172.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/build/three.cjs +157 -49
- package/build/three.core.js +104 -42
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +53 -8
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +10 -5
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +21191 -1008
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +21189 -1008
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +0 -5
- package/examples/jsm/animation/CCDIKSolver.js +3 -2
- package/examples/jsm/controls/ArcballControls.js +28 -19
- package/examples/jsm/controls/OrbitControls.js +5 -4
- package/examples/jsm/csm/CSMShadowNode.js +16 -11
- package/examples/jsm/curves/NURBSCurve.js +1 -1
- package/examples/jsm/curves/NURBSUtils.js +3 -0
- package/examples/jsm/effects/OutlineEffect.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +11 -7
- package/examples/jsm/exporters/KTX2Exporter.js +1 -1
- package/examples/jsm/exporters/PLYExporter.js +2 -2
- package/examples/jsm/helpers/TextureHelperGPU.js +15 -5
- package/examples/jsm/helpers/VertexNormalsHelper.js +2 -0
- package/examples/jsm/lights/LightProbeGenerator.js +3 -3
- package/examples/jsm/lines/webgpu/LineSegments2.js +15 -6
- package/examples/jsm/loaders/3MFLoader.js +6 -3
- package/examples/jsm/loaders/BVHLoader.js +1 -1
- package/examples/jsm/loaders/ColladaLoader.js +5 -5
- package/examples/jsm/loaders/DDSLoader.js +42 -0
- package/examples/jsm/loaders/GCodeLoader.js +1 -1
- package/examples/jsm/loaders/GLTFLoader.js +22 -2
- package/examples/jsm/loaders/KTX2Loader.js +6 -1
- package/examples/jsm/loaders/KTXLoader.js +4 -4
- package/examples/jsm/loaders/LDrawLoader.js +1 -1
- package/examples/jsm/loaders/LottieLoader.js +1 -1
- package/examples/jsm/loaders/MTLLoader.js +1 -0
- package/examples/jsm/loaders/NRRDLoader.js +1 -1
- package/examples/jsm/loaders/PLYLoader.js +7 -7
- package/examples/jsm/loaders/PVRLoader.js +1 -1
- package/examples/jsm/loaders/SVGLoader.js +2 -2
- package/examples/jsm/loaders/TDSLoader.js +1 -1
- package/examples/jsm/loaders/VRMLLoader.js +7 -7
- package/examples/jsm/loaders/lwo/IFFParser.js +4 -4
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +1 -1
- package/examples/jsm/math/ConvexHull.js +1 -1
- package/examples/jsm/math/OBB.js +17 -0
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +10 -10
- package/examples/jsm/misc/Volume.js +20 -12
- package/examples/jsm/misc/VolumeSlice.js +2 -2
- package/examples/jsm/modifiers/CurveModifier.js +10 -8
- package/examples/jsm/modifiers/CurveModifierGPU.js +9 -7
- package/examples/jsm/modifiers/SimplifyModifier.js +2 -2
- package/examples/jsm/objects/GroundedSkybox.js +4 -4
- package/examples/jsm/objects/Sky.js +2 -2
- package/examples/jsm/objects/SkyMesh.js +3 -3
- package/examples/jsm/objects/Water2.js +1 -1
- package/examples/jsm/objects/Water2Mesh.js +2 -2
- package/examples/jsm/objects/WaterMesh.js +4 -4
- package/examples/jsm/postprocessing/BloomPass.js +2 -2
- package/examples/jsm/postprocessing/EffectComposer.js +1 -2
- package/examples/jsm/postprocessing/OutlinePass.js +4 -4
- package/examples/jsm/postprocessing/SAOPass.js +1 -2
- package/examples/jsm/postprocessing/SMAAPass.js +1 -3
- package/examples/jsm/postprocessing/SSAOPass.js +2 -4
- package/examples/jsm/postprocessing/SSRPass.js +2 -4
- package/examples/jsm/postprocessing/UnrealBloomPass.js +2 -2
- package/examples/jsm/renderers/SVGRenderer.js +6 -4
- package/examples/jsm/shaders/BokehShader2.js +1 -1
- package/examples/jsm/shaders/GodRaysShader.js +3 -3
- package/examples/jsm/shaders/SobelOperatorShader.js +1 -1
- package/examples/jsm/tsl/display/AfterImageNode.js +93 -4
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +46 -2
- package/examples/jsm/tsl/display/AnamorphicNode.js +118 -5
- package/examples/jsm/tsl/display/BleachBypass.js +10 -0
- package/examples/jsm/tsl/display/BloomNode.js +233 -26
- package/examples/jsm/tsl/display/DenoiseNode.js +141 -25
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +80 -1
- package/examples/jsm/tsl/display/DotScreenNode.js +50 -5
- package/examples/jsm/tsl/display/FXAANode.js +52 -3
- package/examples/jsm/tsl/display/FilmNode.js +47 -1
- package/examples/jsm/tsl/display/GTAONode.js +210 -14
- package/examples/jsm/tsl/display/GaussianBlurNode.js +152 -8
- package/examples/jsm/tsl/display/LensflareNode.js +131 -13
- package/examples/jsm/tsl/display/Lut3DNode.js +55 -1
- package/examples/jsm/tsl/display/MotionBlur.js +12 -2
- package/examples/jsm/tsl/display/OutlineNode.js +343 -26
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +36 -2
- package/examples/jsm/tsl/display/PixelationPassNode.js +142 -9
- package/examples/jsm/tsl/display/RGBShiftNode.js +49 -2
- package/examples/jsm/tsl/display/SMAANode.js +187 -46
- package/examples/jsm/tsl/display/SSAAPassNode.js +110 -25
- package/examples/jsm/tsl/display/SSRNode.js +194 -21
- package/examples/jsm/tsl/display/Sepia.js +9 -0
- package/examples/jsm/tsl/display/SobelOperatorNode.js +54 -4
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +79 -3
- package/examples/jsm/tsl/display/StereoPassNode.js +41 -3
- package/examples/jsm/tsl/display/TRAAPassNode.js +116 -21
- package/examples/jsm/tsl/display/TransitionNode.js +71 -6
- package/examples/jsm/tsl/display/hashBlur.js +14 -3
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +40 -34
- package/examples/jsm/utils/BufferGeometryUtils.js +1 -1
- package/examples/jsm/utils/CameraUtils.js +4 -1
- package/examples/jsm/utils/GeometryUtils.js +22 -19
- package/examples/jsm/utils/SceneUtils.js +2 -2
- package/examples/jsm/webxr/XRControllerModelFactory.js +6 -1
- package/examples/jsm/webxr/XREstimatedLight.js +1 -1
- package/package.json +8 -3
- package/src/Three.Core.js +2 -0
- package/src/Three.Legacy.js +0 -21
- package/src/Three.TSL.js +9 -4
- package/src/Three.WebGPU.Nodes.js +2 -2
- package/src/Three.WebGPU.js +2 -2
- package/src/animation/PropertyBinding.js +2 -2
- package/src/cameras/PerspectiveCamera.js +18 -2
- package/src/constants.js +1 -1
- package/src/core/RenderTarget.js +18 -0
- package/src/core/RenderTarget3D.js +22 -0
- package/src/core/RenderTargetArray.js +22 -0
- package/src/extras/Earcut.js +1 -1
- package/src/extras/PMREMGenerator.js +20 -0
- package/src/extras/TextureUtils.js +6 -0
- package/src/helpers/CameraHelper.js +16 -13
- package/src/loaders/nodes/NodeLoader.js +59 -0
- package/src/loaders/nodes/NodeMaterialLoader.js +45 -0
- package/src/loaders/nodes/NodeObjectLoader.js +61 -0
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +72 -19
- package/src/materials/nodes/Line2NodeMaterial.js +128 -34
- package/src/materials/nodes/LineBasicNodeMaterial.js +17 -2
- package/src/materials/nodes/LineDashedNodeMaterial.js +78 -5
- package/src/materials/nodes/MeshBasicNodeMaterial.js +56 -0
- package/src/materials/nodes/MeshLambertNodeMaterial.js +35 -0
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +22 -2
- package/src/materials/nodes/MeshNormalNodeMaterial.js +21 -2
- package/src/materials/nodes/MeshPhongNodeMaterial.js +64 -1
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +269 -0
- package/src/materials/nodes/MeshSSSNodeMaterial.js +97 -6
- package/src/materials/nodes/MeshStandardNodeMaterial.js +78 -0
- package/src/materials/nodes/MeshToonNodeMaterial.js +28 -0
- package/src/materials/nodes/NodeMaterial.js +474 -21
- package/src/materials/nodes/PointsNodeMaterial.js +22 -13
- package/src/materials/nodes/ShadowNodeMaterial.js +29 -0
- package/src/materials/nodes/SpriteNodeMaterial.js +77 -19
- package/src/materials/nodes/VolumeNodeMaterial.js +80 -4
- package/src/materials/nodes/manager/NodeMaterialObserver.js +87 -0
- package/src/nodes/Nodes.js +1 -6
- package/src/nodes/TSL.js +2 -3
- package/src/nodes/accessors/AccessorsUtils.js +27 -0
- package/src/nodes/accessors/Arrays.js +24 -5
- package/src/nodes/accessors/BatchNode.js +39 -3
- package/src/nodes/accessors/Bitangent.js +37 -0
- package/src/nodes/accessors/BufferAttributeNode.js +178 -5
- package/src/nodes/accessors/BufferNode.js +63 -0
- package/src/nodes/accessors/BuiltinNode.js +38 -0
- package/src/nodes/accessors/Camera.js +49 -0
- package/src/nodes/accessors/ClippingNode.js +71 -2
- package/src/nodes/accessors/CubeTextureNode.js +64 -0
- package/src/nodes/accessors/InstanceNode.js +85 -2
- package/src/nodes/accessors/InstancedMeshNode.js +28 -3
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +13 -0
- package/src/nodes/accessors/Lights.js +50 -1
- package/src/nodes/accessors/MaterialNode.js +302 -8
- package/src/nodes/accessors/MaterialProperties.js +7 -0
- package/src/nodes/accessors/MaterialReferenceNode.js +53 -13
- package/src/nodes/accessors/ModelNode.js +100 -5
- package/src/nodes/accessors/ModelViewProjectionNode.js +10 -38
- package/src/nodes/accessors/MorphNode.js +48 -4
- package/src/nodes/accessors/Normal.js +59 -3
- package/src/nodes/accessors/Object3DNode.js +102 -1
- package/src/nodes/accessors/PointUVNode.js +26 -0
- package/src/nodes/accessors/Position.js +53 -4
- package/src/nodes/accessors/ReferenceBaseNode.js +188 -0
- package/src/nodes/accessors/ReferenceNode.js +202 -2
- package/src/nodes/accessors/ReflectVector.js +24 -0
- package/src/nodes/accessors/RendererReferenceNode.js +46 -1
- package/src/nodes/accessors/SceneNode.js +54 -0
- package/src/nodes/accessors/SkinningNode.js +127 -1
- package/src/nodes/accessors/StorageBufferNode.js +168 -4
- package/src/nodes/accessors/StorageTextureNode.js +118 -0
- package/src/nodes/accessors/Tangent.js +36 -0
- package/src/nodes/accessors/Texture3DNode.js +89 -5
- package/src/nodes/accessors/TextureBicubic.js +12 -2
- package/src/nodes/accessors/TextureNode.js +309 -10
- package/src/nodes/accessors/TextureSizeNode.js +42 -0
- package/src/nodes/accessors/UV.js +10 -1
- package/src/nodes/accessors/UniformArrayNode.js +223 -23
- package/src/nodes/accessors/UserDataNode.js +46 -0
- package/src/nodes/accessors/VelocityNode.js +82 -0
- package/src/nodes/accessors/VertexColorNode.js +39 -2
- package/src/nodes/code/CodeNode.js +95 -1
- package/src/nodes/code/ExpressionNode.js +28 -0
- package/src/nodes/code/FunctionCallNode.js +37 -0
- package/src/nodes/code/FunctionNode.js +45 -0
- package/src/nodes/code/ScriptableNode.js +223 -1
- package/src/nodes/code/ScriptableValueNode.js +85 -1
- package/src/nodes/core/AssignNode.js +48 -2
- package/src/nodes/core/AttributeNode.js +43 -0
- package/src/nodes/core/BypassNode.js +47 -2
- package/src/nodes/core/CacheNode.js +53 -2
- package/src/nodes/core/ConstNode.js +24 -0
- package/src/nodes/core/ContextNode.js +65 -0
- package/src/nodes/core/IndexNode.js +68 -7
- package/src/nodes/core/InputNode.js +48 -0
- package/src/nodes/core/LightingModel.js +60 -0
- package/src/nodes/core/MRTNode.js +66 -0
- package/src/nodes/core/Node.js +337 -12
- package/src/nodes/core/NodeAttribute.js +38 -0
- package/src/nodes/core/NodeBuilder.js +945 -15
- package/src/nodes/core/NodeCache.js +41 -2
- package/src/nodes/core/NodeCode.js +31 -0
- package/src/nodes/core/NodeFrame.js +123 -2
- package/src/nodes/core/NodeFunction.js +46 -0
- package/src/nodes/core/NodeFunctionInput.js +44 -0
- package/src/nodes/core/NodeParser.js +11 -0
- package/src/nodes/core/NodeUniform.js +52 -0
- package/src/nodes/core/NodeUtils.js +141 -0
- package/src/nodes/core/NodeVar.js +30 -0
- package/src/nodes/core/NodeVarying.js +28 -0
- package/src/nodes/core/OutputStructNode.js +33 -2
- package/src/nodes/core/ParameterNode.js +28 -0
- package/src/nodes/core/PropertyNode.js +232 -0
- package/src/nodes/core/StackNode.js +78 -0
- package/src/nodes/core/StructTypeNode.js +39 -1
- package/src/nodes/core/TempNode.js +30 -4
- package/src/nodes/core/UniformGroupNode.js +82 -7
- package/src/nodes/core/UniformNode.js +66 -0
- package/src/nodes/core/VarNode.js +52 -0
- package/src/nodes/core/VaryingNode.js +83 -2
- package/src/nodes/core/constants.js +36 -0
- package/src/nodes/display/BumpMapNode.js +37 -0
- package/src/nodes/display/ColorAdjustment.js +53 -11
- package/src/nodes/display/ColorSpaceFunctions.js +16 -0
- package/src/nodes/display/ColorSpaceNode.js +82 -0
- package/src/nodes/display/FrontFacingNode.js +29 -0
- package/src/nodes/display/NormalMapNode.js +43 -0
- package/src/nodes/display/PassNode.js +298 -7
- package/src/nodes/display/PosterizeNode.js +33 -0
- package/src/nodes/display/RenderOutputNode.js +66 -1
- package/src/nodes/display/ScreenNode.js +87 -0
- package/src/nodes/display/ToneMappingFunctions.js +58 -10
- package/src/nodes/display/ToneMappingNode.js +55 -2
- package/src/nodes/display/ToonOutlinePassNode.js +73 -0
- package/src/nodes/display/ViewportDepthNode.js +122 -8
- package/src/nodes/display/ViewportDepthTextureNode.js +23 -0
- package/src/nodes/display/ViewportSharedTextureNode.js +23 -0
- package/src/nodes/display/ViewportTextureNode.js +57 -0
- package/src/nodes/fog/Fog.js +93 -0
- package/src/nodes/functions/BasicLightingModel.js +24 -0
- package/src/nodes/functions/PhongLightingModel.js +34 -2
- package/src/nodes/functions/PhysicalLightingModel.js +167 -8
- package/src/nodes/functions/ShadowMaskModel.js +23 -0
- package/src/nodes/functions/ToonLightingModel.js +20 -0
- package/src/nodes/functions/material/getAlphaHashThreshold.js +1 -3
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +16 -1
- package/src/nodes/geometry/RangeNode.js +54 -2
- package/src/nodes/gpgpu/AtomicFunctionNode.js +157 -1
- package/src/nodes/gpgpu/BarrierNode.js +47 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +126 -0
- package/src/nodes/gpgpu/ComputeNode.js +106 -2
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +115 -6
- package/src/nodes/lighting/AONode.js +18 -0
- package/src/nodes/lighting/AmbientLightNode.js +10 -0
- package/src/nodes/lighting/AnalyticLightNode.js +97 -2
- package/src/nodes/lighting/BasicEnvironmentNode.js +19 -0
- package/src/nodes/lighting/BasicLightMapNode.js +17 -0
- package/src/nodes/lighting/DirectionalLightNode.js +10 -0
- package/src/nodes/lighting/EnvironmentNode.js +18 -0
- package/src/nodes/lighting/HemisphereLightNode.js +31 -0
- package/src/nodes/lighting/IESSpotLightNode.js +11 -0
- package/src/nodes/lighting/IrradianceNode.js +17 -0
- package/src/nodes/lighting/LightProbeNode.js +20 -0
- package/src/nodes/lighting/LightUtils.js +12 -0
- package/src/nodes/lighting/LightingContextNode.js +48 -0
- package/src/nodes/lighting/LightingNode.js +15 -6
- package/src/nodes/lighting/LightsNode.js +132 -1
- package/src/nodes/lighting/PointLightNode.js +32 -1
- package/src/nodes/lighting/PointShadowNode.js +54 -1
- package/src/nodes/lighting/RectAreaLightNode.js +44 -6
- package/src/nodes/lighting/ShadowBaseNode.js +93 -0
- package/src/nodes/lighting/ShadowNode.js +240 -34
- package/src/nodes/lighting/SpotLightNode.js +43 -0
- package/src/nodes/math/ConditionalNode.js +70 -3
- package/src/nodes/math/Hash.js +9 -0
- package/src/nodes/math/MathNode.js +614 -11
- package/src/nodes/math/MathUtils.js +45 -1
- package/src/nodes/math/OperatorNode.js +233 -0
- package/src/nodes/math/TriNoise3D.js +18 -7
- package/src/nodes/parsers/GLSLNodeFunction.js +16 -0
- package/src/nodes/parsers/GLSLNodeParser.js +11 -0
- package/src/nodes/pmrem/PMREMNode.js +133 -0
- package/src/nodes/pmrem/PMREMUtils.js +1 -1
- package/src/nodes/procedural/Checker.js +9 -0
- package/src/nodes/tsl/TSLBase.js +2 -2
- package/src/nodes/utils/ArrayElementNode.js +38 -2
- package/src/nodes/utils/ConvertNode.js +31 -0
- package/src/nodes/utils/CubeMapNode.js +78 -0
- package/src/nodes/utils/Discard.js +16 -0
- package/src/nodes/utils/EquirectUVNode.js +31 -1
- package/src/nodes/utils/FlipNode.js +38 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +53 -1
- package/src/nodes/utils/JoinNode.js +25 -0
- package/src/nodes/utils/LoopNode.js +74 -1
- package/src/nodes/utils/MatcapUVNode.js +17 -0
- package/src/nodes/utils/MaxMipLevelNode.js +49 -0
- package/src/nodes/utils/Oscillators.js +33 -0
- package/src/nodes/utils/Packing.js +17 -0
- package/src/nodes/utils/PostProcessingUtils.js +28 -23
- package/src/nodes/utils/RTTNode.js +123 -2
- package/src/nodes/utils/ReflectorNode.js +174 -4
- package/src/nodes/utils/RemapNode.js +79 -0
- package/src/nodes/utils/RotateNode.js +41 -0
- package/src/nodes/utils/SetNode.js +44 -1
- package/src/nodes/utils/SplitNode.js +55 -3
- package/src/nodes/utils/SpriteSheetUVNode.js +46 -0
- package/src/nodes/utils/SpriteUtils.js +17 -0
- package/src/nodes/utils/StorageArrayElementNode.js +40 -0
- package/src/nodes/utils/Timer.js +19 -0
- package/src/nodes/utils/TriplanarTexturesNode.js +84 -0
- package/src/nodes/utils/UVUtils.js +20 -0
- package/src/nodes/utils/ViewportUtils.js +13 -0
- package/src/objects/BatchedMesh.js +1 -2
- package/src/objects/ClippingGroup.js +49 -0
- package/src/renderers/WebGLRenderer.js +23 -4
- package/src/renderers/common/Animation.js +63 -0
- package/src/renderers/common/Attributes.js +36 -0
- package/src/renderers/common/Backend.js +467 -52
- package/src/renderers/common/Background.js +34 -1
- package/src/renderers/common/BindGroup.js +43 -0
- package/src/renderers/common/Binding.js +35 -0
- package/src/renderers/common/Bindings.js +93 -1
- package/src/renderers/common/Buffer.js +49 -0
- package/src/renderers/common/BufferUtils.js +27 -0
- package/src/renderers/common/BundleGroup.js +57 -0
- package/src/renderers/common/ChainMap.js +38 -1
- package/src/renderers/common/ClippingContext.js +107 -14
- package/src/renderers/common/Color4.js +36 -0
- package/src/renderers/common/ComputePipeline.js +24 -0
- package/src/renderers/common/CubeRenderTarget.js +13 -0
- package/src/renderers/common/DataMap.js +37 -1
- package/src/renderers/common/Geometries.js +98 -0
- package/src/renderers/common/IndirectStorageBufferAttribute.js +25 -2
- package/src/renderers/common/Info.js +87 -0
- package/src/renderers/common/Lighting.js +26 -0
- package/src/renderers/common/Pipeline.js +22 -0
- package/src/renderers/common/Pipelines.js +148 -5
- package/src/renderers/common/PostProcessing.js +75 -3
- package/src/renderers/common/ProgrammableStage.js +60 -2
- package/src/renderers/common/QuadMesh.js +54 -5
- package/src/renderers/common/RenderBundle.js +14 -8
- package/src/renderers/common/RenderBundles.js +33 -10
- package/src/renderers/common/RenderContext.js +169 -4
- package/src/renderers/common/RenderContexts.js +42 -2
- package/src/renderers/common/RenderList.js +178 -0
- package/src/renderers/common/RenderLists.js +31 -0
- package/src/renderers/common/RenderObject.js +328 -4
- package/src/renderers/common/RenderObjects.js +101 -7
- package/src/renderers/common/RenderPipeline.js +24 -0
- package/src/renderers/common/Renderer.js +1096 -31
- package/src/renderers/common/RendererUtils.js +193 -0
- package/src/renderers/common/SampledTexture.js +121 -0
- package/src/renderers/common/Sampler.js +30 -0
- package/src/renderers/common/StorageBuffer.js +24 -0
- package/src/renderers/common/StorageBufferAttribute.js +31 -2
- package/src/renderers/common/StorageInstancedBufferAttribute.js +31 -2
- package/src/renderers/common/StorageTexture.js +38 -0
- package/src/renderers/common/Textures.js +83 -0
- package/src/renderers/common/Uniform.js +188 -2
- package/src/renderers/common/UniformBuffer.js +19 -0
- package/src/renderers/common/UniformsGroup.js +139 -2
- package/src/renderers/common/extras/PMREMGenerator.js +24 -3
- package/src/renderers/common/nodes/NodeBuilderState.js +95 -1
- package/src/renderers/common/nodes/NodeLibrary.js +89 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +91 -2
- package/src/renderers/common/nodes/NodeSampler.js +28 -0
- package/src/renderers/common/nodes/NodeStorageBuffer.js +35 -0
- package/src/renderers/common/nodes/NodeUniform.js +189 -0
- package/src/renderers/common/nodes/NodeUniformBuffer.js +29 -0
- package/src/renderers/common/nodes/NodeUniformsGroup.js +31 -18
- package/src/renderers/common/nodes/Nodes.js +327 -60
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +7 -7
- package/src/renderers/webgl-fallback/WebGLBackend.js +547 -29
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +0 -1
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +1 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +1 -1
- package/src/renderers/webgpu/WebGPUBackend.js +480 -49
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +34 -0
- package/src/renderers/webgpu/WebGPURenderer.js +35 -0
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +20 -8
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +21 -8
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +59 -11
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +17 -0
- package/src/renderers/webgpu/nodes/WGSLNodeParser.js +11 -0
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +10 -8
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +9 -1
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +5 -9
- package/src/renderers/webgpu/utils/WebGPUUtils.js +30 -0
- package/src/renderers/webxr/WebXRDepthSensing.js +1 -1
- package/src/renderers/webxr/WebXRManager.js +7 -1
- package/src/textures/Data3DTexture.js +2 -2
- package/src/textures/Texture.js +4 -0
- package/examples/jsm/animation/MMDAnimationHelper.js +0 -1209
- package/examples/jsm/animation/MMDPhysics.js +0 -1408
- package/examples/jsm/exporters/MMDExporter.js +0 -223
- package/examples/jsm/libs/mmdparser.module.js +0 -11530
- package/examples/jsm/loaders/MMDLoader.js +0 -2298
- package/examples/jsm/shaders/MMDToonShader.js +0 -134
- package/src/nodes/core/UniformGroup.js +0 -13
- package/src/nodes/fog/FogExp2Node.js +0 -35
- package/src/nodes/fog/FogNode.js +0 -50
- package/src/nodes/fog/FogRangeNode.js +0 -36
- package/src/renderers/common/PostProcessingUtils.js +0 -86
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
import { AdditiveBlending, Color, Vector2,
|
|
1
|
+
import { AdditiveBlending, Color, Vector2, RendererUtils, PassNode, QuadMesh, NodeMaterial } from 'three/webgpu';
|
|
2
2
|
import { nodeObject, uniform, mrt, texture, getTextureIndex } from 'three/tsl';
|
|
3
3
|
|
|
4
|
+
/** @module SSAAPassNode **/
|
|
5
|
+
|
|
4
6
|
const _size = /*@__PURE__*/ new Vector2();
|
|
5
7
|
|
|
6
8
|
let _rendererState;
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* This
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
* A special render pass node that renders the scene with SSAA (Supersampling Anti-Aliasing).
|
|
12
|
+
* This manual SSAA approach re-renders the scene ones for each sample with camera jitter and accumulates the results.
|
|
13
|
+
*
|
|
14
|
+
* This node produces a high-quality anti-aliased output but is also extremely expensive because of
|
|
15
|
+
* its brute-force approach of re-rendering the entire scene multiple times.
|
|
16
|
+
*
|
|
17
|
+
* Reference: {@link https://en.wikipedia.org/wiki/Supersampling}
|
|
18
|
+
*
|
|
19
|
+
* @augments PassNode
|
|
20
|
+
*/
|
|
18
21
|
class SSAAPassNode extends PassNode {
|
|
19
22
|
|
|
20
23
|
static get type() {
|
|
@@ -23,31 +26,95 @@ class SSAAPassNode extends PassNode {
|
|
|
23
26
|
|
|
24
27
|
}
|
|
25
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Constructs a new SSAA pass node.
|
|
31
|
+
*
|
|
32
|
+
* @param {Scene} scene - The scene to render.
|
|
33
|
+
* @param {Camera} camera - The camera to render the scene with.
|
|
34
|
+
*/
|
|
26
35
|
constructor( scene, camera ) {
|
|
27
36
|
|
|
28
37
|
super( PassNode.COLOR, scene, camera );
|
|
29
38
|
|
|
39
|
+
/**
|
|
40
|
+
* This flag can be used for type testing.
|
|
41
|
+
*
|
|
42
|
+
* @type {Boolean}
|
|
43
|
+
* @readonly
|
|
44
|
+
* @default true
|
|
45
|
+
*/
|
|
30
46
|
this.isSSAAPassNode = true;
|
|
31
47
|
|
|
32
|
-
|
|
48
|
+
/**
|
|
49
|
+
* The sample level specified as n, where the number of samples is 2^n,
|
|
50
|
+
* so sampleLevel = 4, is 2^4 samples, 16.
|
|
51
|
+
*
|
|
52
|
+
* @type {Number}
|
|
53
|
+
* @default 4
|
|
54
|
+
*/
|
|
55
|
+
this.sampleLevel = 4;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Whether rounding errors should be mitigated or not.
|
|
59
|
+
*
|
|
60
|
+
* @type {Boolean}
|
|
61
|
+
* @default true
|
|
62
|
+
*/
|
|
33
63
|
this.unbiased = true;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The clear color of the pass.
|
|
67
|
+
*
|
|
68
|
+
* @type {Color}
|
|
69
|
+
* @default 0x000000
|
|
70
|
+
*/
|
|
34
71
|
this.clearColor = new Color( 0x000000 );
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The clear alpha of the pass.
|
|
75
|
+
*
|
|
76
|
+
* @type {Number}
|
|
77
|
+
* @default 0
|
|
78
|
+
*/
|
|
35
79
|
this.clearAlpha = 0;
|
|
36
80
|
|
|
81
|
+
/**
|
|
82
|
+
* A uniform node representing the sample weight.
|
|
83
|
+
*
|
|
84
|
+
* @type {UniformNode<float>}
|
|
85
|
+
* @default 1
|
|
86
|
+
*/
|
|
37
87
|
this.sampleWeight = uniform( 1 );
|
|
38
88
|
|
|
39
|
-
|
|
40
|
-
|
|
89
|
+
/**
|
|
90
|
+
* Reference to the internal render target that holds the current sample.
|
|
91
|
+
*
|
|
92
|
+
* @private
|
|
93
|
+
* @type {RenderTarget?}
|
|
94
|
+
*/
|
|
95
|
+
this._sampleRenderTarget = null;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Reference to the internal quad mesh.
|
|
99
|
+
*
|
|
100
|
+
* @private
|
|
101
|
+
* @type {QuadMesh}
|
|
102
|
+
*/
|
|
41
103
|
this._quadMesh = new QuadMesh();
|
|
42
104
|
|
|
43
105
|
}
|
|
44
106
|
|
|
107
|
+
/**
|
|
108
|
+
* This method is used to render the SSAA effect once per frame.
|
|
109
|
+
*
|
|
110
|
+
* @param {NodeFrame} frame - The current node frame.
|
|
111
|
+
*/
|
|
45
112
|
updateBefore( frame ) {
|
|
46
113
|
|
|
47
114
|
const { renderer } = frame;
|
|
48
115
|
const { scene, camera } = this;
|
|
49
116
|
|
|
50
|
-
_rendererState =
|
|
117
|
+
_rendererState = RendererUtils.resetRendererAndSceneState( renderer, scene, _rendererState );
|
|
51
118
|
|
|
52
119
|
//
|
|
53
120
|
|
|
@@ -56,7 +123,7 @@ class SSAAPassNode extends PassNode {
|
|
|
56
123
|
const size = renderer.getSize( _size );
|
|
57
124
|
|
|
58
125
|
this.setSize( size.width, size.height );
|
|
59
|
-
this.
|
|
126
|
+
this._sampleRenderTarget.setSize( this.renderTarget.width, this.renderTarget.height );
|
|
60
127
|
|
|
61
128
|
//
|
|
62
129
|
|
|
@@ -120,7 +187,7 @@ class SSAAPassNode extends PassNode {
|
|
|
120
187
|
}
|
|
121
188
|
|
|
122
189
|
renderer.setClearColor( this.clearColor, this.clearAlpha );
|
|
123
|
-
renderer.setRenderTarget( this.
|
|
190
|
+
renderer.setRenderTarget( this._sampleRenderTarget );
|
|
124
191
|
renderer.clear();
|
|
125
192
|
renderer.render( scene, camera );
|
|
126
193
|
|
|
@@ -139,7 +206,7 @@ class SSAAPassNode extends PassNode {
|
|
|
139
206
|
|
|
140
207
|
}
|
|
141
208
|
|
|
142
|
-
renderer.copyTextureToTexture( this.
|
|
209
|
+
renderer.copyTextureToTexture( this._sampleRenderTarget.depthTexture, this.renderTarget.depthTexture );
|
|
143
210
|
|
|
144
211
|
// restore
|
|
145
212
|
|
|
@@ -163,15 +230,21 @@ class SSAAPassNode extends PassNode {
|
|
|
163
230
|
|
|
164
231
|
//
|
|
165
232
|
|
|
166
|
-
|
|
233
|
+
RendererUtils.restoreRendererAndSceneState( renderer, scene, _rendererState );
|
|
167
234
|
|
|
168
235
|
}
|
|
169
236
|
|
|
237
|
+
/**
|
|
238
|
+
* This method is used to setup the effect's MRT configuration and quad mesh.
|
|
239
|
+
*
|
|
240
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
241
|
+
* @return {PassTextureNode}
|
|
242
|
+
*/
|
|
170
243
|
setup( builder ) {
|
|
171
244
|
|
|
172
|
-
if ( this.
|
|
245
|
+
if ( this._sampleRenderTarget === null ) {
|
|
173
246
|
|
|
174
|
-
this.
|
|
247
|
+
this._sampleRenderTarget = this.renderTarget.clone();
|
|
175
248
|
|
|
176
249
|
}
|
|
177
250
|
|
|
@@ -185,11 +258,11 @@ class SSAAPassNode extends PassNode {
|
|
|
185
258
|
|
|
186
259
|
for ( const name in passMRT.outputNodes ) {
|
|
187
260
|
|
|
188
|
-
const index = getTextureIndex( this.
|
|
261
|
+
const index = getTextureIndex( this._sampleRenderTarget.textures, name );
|
|
189
262
|
|
|
190
263
|
if ( index >= 0 ) {
|
|
191
264
|
|
|
192
|
-
outputs[ name ] = texture( this.
|
|
265
|
+
outputs[ name ] = texture( this._sampleRenderTarget.textures[ index ] ).mul( this.sampleWeight );
|
|
193
266
|
|
|
194
267
|
}
|
|
195
268
|
|
|
@@ -199,7 +272,7 @@ class SSAAPassNode extends PassNode {
|
|
|
199
272
|
|
|
200
273
|
} else {
|
|
201
274
|
|
|
202
|
-
sampleTexture = texture( this.
|
|
275
|
+
sampleTexture = texture( this._sampleRenderTarget.texture ).mul( this.sampleWeight );
|
|
203
276
|
|
|
204
277
|
}
|
|
205
278
|
|
|
@@ -216,13 +289,17 @@ class SSAAPassNode extends PassNode {
|
|
|
216
289
|
|
|
217
290
|
}
|
|
218
291
|
|
|
292
|
+
/**
|
|
293
|
+
* Frees internal resources. This method should be called
|
|
294
|
+
* when the pass is no longer required.
|
|
295
|
+
*/
|
|
219
296
|
dispose() {
|
|
220
297
|
|
|
221
298
|
super.dispose();
|
|
222
299
|
|
|
223
|
-
if ( this.
|
|
300
|
+
if ( this._sampleRenderTarget !== null ) {
|
|
224
301
|
|
|
225
|
-
this.
|
|
302
|
+
this._sampleRenderTarget.dispose();
|
|
226
303
|
|
|
227
304
|
}
|
|
228
305
|
|
|
@@ -269,4 +346,12 @@ const _JitterVectors = [
|
|
|
269
346
|
]
|
|
270
347
|
];
|
|
271
348
|
|
|
349
|
+
/**
|
|
350
|
+
* TSL function for creating a SSAA pass node for Supersampling Anti-Aliasing.
|
|
351
|
+
*
|
|
352
|
+
* @function
|
|
353
|
+
* @param {Scene} scene - The scene to render.
|
|
354
|
+
* @param {Camera} camera - The camera to render the scene with.
|
|
355
|
+
* @returns {SSAAPassNode}
|
|
356
|
+
*/
|
|
272
357
|
export const ssaaPass = ( scene, camera ) => nodeObject( new SSAAPassNode( scene, camera ) );
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import { NearestFilter, RenderTarget, Vector2,
|
|
1
|
+
import { NearestFilter, RenderTarget, Vector2, RendererUtils, QuadMesh, TempNode, NodeMaterial, NodeUpdateType } from 'three/webgpu';
|
|
2
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';
|
|
3
3
|
|
|
4
|
+
/** @module SSRNode **/
|
|
5
|
+
|
|
4
6
|
const _quadMesh = /*@__PURE__*/ new QuadMesh();
|
|
5
7
|
const _size = /*@__PURE__*/ new Vector2();
|
|
6
8
|
let _rendererState;
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
+
* Post processing node for computing screen space reflections (SSR).
|
|
12
|
+
*
|
|
13
|
+
* Reference: {@link https://lettier.github.io/3d-game-shaders-for-beginners/screen-space-reflection.html}
|
|
14
|
+
*
|
|
15
|
+
* @augments TempNode
|
|
11
16
|
*/
|
|
12
17
|
class SSRNode extends TempNode {
|
|
13
18
|
|
|
@@ -17,56 +22,198 @@ class SSRNode extends TempNode {
|
|
|
17
22
|
|
|
18
23
|
}
|
|
19
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Constructs a new SSR node.
|
|
27
|
+
*
|
|
28
|
+
* @param {Node<vec4>} colorNode - The node that represents the beauty pass.
|
|
29
|
+
* @param {Node<float>} depthNode - A node that represents the beauty pass's depth.
|
|
30
|
+
* @param {Node<vec3>} normalNode - A node that represents the beauty pass's normals.
|
|
31
|
+
* @param {Node<float>} metalnessNode - A node that represents the beauty pass's metalness.
|
|
32
|
+
* @param {Camera} camera - The camera the scene is rendered with.
|
|
33
|
+
*/
|
|
20
34
|
constructor( colorNode, depthNode, normalNode, metalnessNode, camera ) {
|
|
21
35
|
|
|
22
36
|
super( 'vec4' );
|
|
23
37
|
|
|
38
|
+
/**
|
|
39
|
+
* The node that represents the beauty pass.
|
|
40
|
+
*
|
|
41
|
+
* @type {Node<vec4>}
|
|
42
|
+
*/
|
|
24
43
|
this.colorNode = colorNode;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* A node that represents the beauty pass's depth.
|
|
47
|
+
*
|
|
48
|
+
* @type {Node<float>}
|
|
49
|
+
*/
|
|
25
50
|
this.depthNode = depthNode;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* A node that represents the beauty pass's normals.
|
|
54
|
+
*
|
|
55
|
+
* @type {Node<vec3>}
|
|
56
|
+
*/
|
|
26
57
|
this.normalNode = normalNode;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* A node that represents the beauty pass's metalness.
|
|
61
|
+
*
|
|
62
|
+
* @type {Node<float>}
|
|
63
|
+
*/
|
|
27
64
|
this.metalnessNode = metalnessNode;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The camera the scene is rendered with.
|
|
68
|
+
*
|
|
69
|
+
* @type {Camera}
|
|
70
|
+
*/
|
|
28
71
|
this.camera = camera;
|
|
29
72
|
|
|
73
|
+
/**
|
|
74
|
+
* The resolution scale. By default SSR reflections
|
|
75
|
+
* are computed in half resolutions. Setting the value
|
|
76
|
+
* to `1` improves quality but also results in more
|
|
77
|
+
* computational overhead.
|
|
78
|
+
*
|
|
79
|
+
* @type {Number}
|
|
80
|
+
* @default 0.5
|
|
81
|
+
*/
|
|
30
82
|
this.resolutionScale = 0.5;
|
|
31
83
|
|
|
84
|
+
/**
|
|
85
|
+
* The `updateBeforeType` is set to `NodeUpdateType.FRAME` since the node renders
|
|
86
|
+
* its effect once per frame in `updateBefore()`.
|
|
87
|
+
*
|
|
88
|
+
* @type {String}
|
|
89
|
+
* @default 'frame'
|
|
90
|
+
*/
|
|
32
91
|
this.updateBeforeType = NodeUpdateType.FRAME;
|
|
33
92
|
|
|
34
|
-
|
|
35
|
-
|
|
93
|
+
/**
|
|
94
|
+
* The render target the SSR is rendered into.
|
|
95
|
+
*
|
|
96
|
+
* @private
|
|
97
|
+
* @type {RenderTarget}
|
|
98
|
+
*/
|
|
36
99
|
this._ssrRenderTarget = new RenderTarget( 1, 1, { depthBuffer: false, minFilter: NearestFilter, magFilter: NearestFilter } );
|
|
37
100
|
this._ssrRenderTarget.texture.name = 'SSRNode.SSR';
|
|
38
101
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
102
|
+
/**
|
|
103
|
+
* Controls how far a fragment can reflect
|
|
104
|
+
*
|
|
105
|
+
*
|
|
106
|
+
* @type {UniformNode<float>}
|
|
107
|
+
*/
|
|
108
|
+
this.maxDistance = uniform( 1 );
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Controls the cutoff between what counts as a possible reflection hit and what does not.
|
|
112
|
+
*
|
|
113
|
+
* @type {UniformNode<float>}
|
|
114
|
+
*/
|
|
115
|
+
this.thickness = uniform( 0.1 );
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Controls the transparency of the reflected colors.
|
|
119
|
+
*
|
|
120
|
+
* @type {UniformNode<float>}
|
|
121
|
+
*/
|
|
122
|
+
this.opacity = uniform( 1 );
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Represents the projection matrix of the scene's camera.
|
|
126
|
+
*
|
|
127
|
+
* @private
|
|
128
|
+
* @type {UniformNode<mat4>}
|
|
129
|
+
*/
|
|
45
130
|
this._cameraProjectionMatrix = uniform( camera.projectionMatrix );
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Represents the inverse projection matrix of the scene's camera.
|
|
134
|
+
*
|
|
135
|
+
* @private
|
|
136
|
+
* @type {UniformNode<mat4>}
|
|
137
|
+
*/
|
|
46
138
|
this._cameraProjectionMatrixInverse = uniform( camera.projectionMatrixInverse );
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Represents the near value of the scene's camera.
|
|
142
|
+
*
|
|
143
|
+
* @private
|
|
144
|
+
* @type {ReferenceNode<float>}
|
|
145
|
+
*/
|
|
47
146
|
this._cameraNear = reference( 'near', 'float', camera );
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Represents the far value of the scene's camera.
|
|
150
|
+
*
|
|
151
|
+
* @private
|
|
152
|
+
* @type {ReferenceNode<float>}
|
|
153
|
+
*/
|
|
48
154
|
this._cameraFar = reference( 'far', 'float', camera );
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Whether the scene's camera is perspective or orthographic.
|
|
158
|
+
*
|
|
159
|
+
* @private
|
|
160
|
+
* @type {UniformNode<bool>}
|
|
161
|
+
*/
|
|
49
162
|
this._isPerspectiveCamera = uniform( camera.isPerspectiveCamera ? 1 : 0 );
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* The resolution of the pass.
|
|
166
|
+
*
|
|
167
|
+
* @private
|
|
168
|
+
* @type {UniformNode<vec2>}
|
|
169
|
+
*/
|
|
50
170
|
this._resolution = uniform( new Vector2() );
|
|
51
|
-
this._maxStep = uniform( 0 );
|
|
52
171
|
|
|
53
|
-
|
|
172
|
+
/**
|
|
173
|
+
* This value is derived from the resolution and restricts
|
|
174
|
+
* the maximum raymarching steps in the fragment shader.
|
|
175
|
+
*
|
|
176
|
+
* @private
|
|
177
|
+
* @type {UniformNode<float>}
|
|
178
|
+
*/
|
|
179
|
+
this._maxStep = uniform( 0 );
|
|
54
180
|
|
|
181
|
+
/**
|
|
182
|
+
* The material that is used to render the effect.
|
|
183
|
+
*
|
|
184
|
+
* @private
|
|
185
|
+
* @type {NodeMaterial}
|
|
186
|
+
*/
|
|
55
187
|
this._material = new NodeMaterial();
|
|
56
188
|
this._material.name = 'SSRNode.SSR';
|
|
57
189
|
|
|
58
|
-
|
|
59
|
-
|
|
190
|
+
/**
|
|
191
|
+
* The result of the effect is represented as a separate texture node.
|
|
192
|
+
*
|
|
193
|
+
* @private
|
|
194
|
+
* @type {PassTextureNode}
|
|
195
|
+
*/
|
|
60
196
|
this._textureNode = passTexture( this, this._ssrRenderTarget.texture );
|
|
61
197
|
|
|
62
198
|
}
|
|
63
199
|
|
|
200
|
+
/**
|
|
201
|
+
* Returns the result of the effect as a texture node.
|
|
202
|
+
*
|
|
203
|
+
* @return {PassTextureNode} A texture node that represents the result of the effect.
|
|
204
|
+
*/
|
|
64
205
|
getTextureNode() {
|
|
65
206
|
|
|
66
207
|
return this._textureNode;
|
|
67
208
|
|
|
68
209
|
}
|
|
69
210
|
|
|
211
|
+
/**
|
|
212
|
+
* Sets the size of the effect.
|
|
213
|
+
*
|
|
214
|
+
* @param {Number} width - The width of the effect.
|
|
215
|
+
* @param {Number} height - The height of the effect.
|
|
216
|
+
*/
|
|
70
217
|
setSize( width, height ) {
|
|
71
218
|
|
|
72
219
|
width = Math.round( this.resolutionScale * width );
|
|
@@ -79,11 +226,16 @@ class SSRNode extends TempNode {
|
|
|
79
226
|
|
|
80
227
|
}
|
|
81
228
|
|
|
229
|
+
/**
|
|
230
|
+
* This method is used to render the effect once per frame.
|
|
231
|
+
*
|
|
232
|
+
* @param {NodeFrame} frame - The current node frame.
|
|
233
|
+
*/
|
|
82
234
|
updateBefore( frame ) {
|
|
83
235
|
|
|
84
236
|
const { renderer } = frame;
|
|
85
237
|
|
|
86
|
-
_rendererState =
|
|
238
|
+
_rendererState = RendererUtils.resetRendererState( renderer, _rendererState );
|
|
87
239
|
|
|
88
240
|
const size = renderer.getDrawingBufferSize( _size );
|
|
89
241
|
|
|
@@ -103,10 +255,16 @@ class SSRNode extends TempNode {
|
|
|
103
255
|
|
|
104
256
|
// restore
|
|
105
257
|
|
|
106
|
-
|
|
258
|
+
RendererUtils.restoreRendererState( renderer, _rendererState );
|
|
107
259
|
|
|
108
260
|
}
|
|
109
261
|
|
|
262
|
+
/**
|
|
263
|
+
* This method is used to setup the effect's TSL code.
|
|
264
|
+
*
|
|
265
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
266
|
+
* @return {PassTextureNode}
|
|
267
|
+
*/
|
|
110
268
|
setup( builder ) {
|
|
111
269
|
|
|
112
270
|
const uvNode = uv();
|
|
@@ -153,7 +311,7 @@ class SSRNode extends TempNode {
|
|
|
153
311
|
|
|
154
312
|
const sampleDepth = ( uv ) => {
|
|
155
313
|
|
|
156
|
-
const depth = this.depthNode.
|
|
314
|
+
const depth = this.depthNode.sample( uv ).r;
|
|
157
315
|
|
|
158
316
|
if ( builder.renderer.logarithmicDepthBuffer === true ) {
|
|
159
317
|
|
|
@@ -169,7 +327,7 @@ class SSRNode extends TempNode {
|
|
|
169
327
|
|
|
170
328
|
const ssr = Fn( () => {
|
|
171
329
|
|
|
172
|
-
const metalness = this.metalnessNode.
|
|
330
|
+
const metalness = this.metalnessNode.sample( uvNode ).r;
|
|
173
331
|
|
|
174
332
|
// fragments with no metalness do not reflect their environment
|
|
175
333
|
metalness.equal( 0.0 ).discard();
|
|
@@ -295,7 +453,7 @@ class SSRNode extends TempNode {
|
|
|
295
453
|
|
|
296
454
|
If( away.lessThanEqual( tk ), () => { // hit
|
|
297
455
|
|
|
298
|
-
const vN = this.normalNode.
|
|
456
|
+
const vN = this.normalNode.sample( uvNode ).rgb.normalize().toVar();
|
|
299
457
|
|
|
300
458
|
If( dot( viewReflectDir, vN ).greaterThanEqual( 0 ), () => {
|
|
301
459
|
|
|
@@ -328,7 +486,7 @@ class SSRNode extends TempNode {
|
|
|
328
486
|
op.mulAssign( fresnelCoe );
|
|
329
487
|
|
|
330
488
|
// output
|
|
331
|
-
const reflectColor = this.colorNode.
|
|
489
|
+
const reflectColor = this.colorNode.sample( uvNode );
|
|
332
490
|
output.assign( vec4( reflectColor.rgb, op ) );
|
|
333
491
|
Break();
|
|
334
492
|
|
|
@@ -351,6 +509,10 @@ class SSRNode extends TempNode {
|
|
|
351
509
|
|
|
352
510
|
}
|
|
353
511
|
|
|
512
|
+
/**
|
|
513
|
+
* Frees internal resources. This method should be called
|
|
514
|
+
* when the effect is no longer required.
|
|
515
|
+
*/
|
|
354
516
|
dispose() {
|
|
355
517
|
|
|
356
518
|
this._ssrRenderTarget.dispose();
|
|
@@ -363,4 +525,15 @@ class SSRNode extends TempNode {
|
|
|
363
525
|
|
|
364
526
|
export default SSRNode;
|
|
365
527
|
|
|
528
|
+
/**
|
|
529
|
+
* TSL function for creating screen space reflections (SSR).
|
|
530
|
+
*
|
|
531
|
+
* @function
|
|
532
|
+
* @param {Node<vec4>} colorNode - The node that represents the beauty pass.
|
|
533
|
+
* @param {Node<float>} depthNode - A node that represents the beauty pass's depth.
|
|
534
|
+
* @param {Node<vec3>} normalNode - A node that represents the beauty pass's normals.
|
|
535
|
+
* @param {Node<float>} metalnessNode - A node that represents the beauty pass's metalness.
|
|
536
|
+
* @param {Camera} camera - The camera the scene is rendered with.
|
|
537
|
+
* @returns {SSRNode}
|
|
538
|
+
*/
|
|
366
539
|
export const ssr = ( colorNode, depthNode, normalNode, metalnessNode, camera ) => nodeObject( new SSRNode( nodeObject( colorNode ), nodeObject( depthNode ), nodeObject( normalNode ), nodeObject( metalnessNode ), camera ) );
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { dot, Fn, vec3, vec4 } from 'three/tsl';
|
|
2
2
|
|
|
3
|
+
/** @module Sepia **/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Applies a sepia effect to the given color node.
|
|
7
|
+
*
|
|
8
|
+
* @function
|
|
9
|
+
* @param {Node<vec4>} color - The color node to apply the sepia for.
|
|
10
|
+
* @return {Node<vec4>} The updated color node.
|
|
11
|
+
*/
|
|
3
12
|
export const sepia = /*@__PURE__*/ Fn( ( [ color ] ) => {
|
|
4
13
|
|
|
5
14
|
const c = vec3( color );
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { Vector2, TempNode, NodeUpdateType } from 'three/webgpu';
|
|
2
2
|
import { nodeObject, Fn, uv, uniform, convertToTexture, vec2, vec3, vec4, mat3, luminance, add } from 'three/tsl';
|
|
3
3
|
|
|
4
|
+
/** @module SobelOperatorNode **/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Post processing node for detecting edges with a sobel filter.
|
|
8
|
+
* A sobel filter should be applied after tone mapping and output color
|
|
9
|
+
* space conversion.
|
|
10
|
+
*
|
|
11
|
+
* @augments TempNode
|
|
12
|
+
*/
|
|
4
13
|
class SobelOperatorNode extends TempNode {
|
|
5
14
|
|
|
6
15
|
static get type() {
|
|
@@ -9,19 +18,47 @@ class SobelOperatorNode extends TempNode {
|
|
|
9
18
|
|
|
10
19
|
}
|
|
11
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Constructs a new sobel operator node.
|
|
23
|
+
*
|
|
24
|
+
* @param {TextureNode} textureNode - The texture node that represents the input of the effect.
|
|
25
|
+
*/
|
|
12
26
|
constructor( textureNode ) {
|
|
13
27
|
|
|
14
28
|
super( 'vec4' );
|
|
15
29
|
|
|
30
|
+
/**
|
|
31
|
+
* The texture node that represents the input of the effect.
|
|
32
|
+
*
|
|
33
|
+
* @type {TextureNode}
|
|
34
|
+
*/
|
|
16
35
|
this.textureNode = textureNode;
|
|
17
36
|
|
|
37
|
+
/**
|
|
38
|
+
* The `updateBeforeType` is set to `NodeUpdateType.FRAME` since the node updates
|
|
39
|
+
* its internal uniforms once per frame in `updateBefore()`.
|
|
40
|
+
*
|
|
41
|
+
* @type {String}
|
|
42
|
+
* @default 'frame'
|
|
43
|
+
*/
|
|
18
44
|
this.updateBeforeType = NodeUpdateType.FRAME;
|
|
19
45
|
|
|
46
|
+
/**
|
|
47
|
+
* A uniform node holding the inverse resolution value.
|
|
48
|
+
*
|
|
49
|
+
* @private
|
|
50
|
+
* @type {UniformNode<vec2>}
|
|
51
|
+
*/
|
|
20
52
|
this._invSize = uniform( new Vector2() );
|
|
21
53
|
|
|
22
54
|
}
|
|
23
55
|
|
|
24
|
-
|
|
56
|
+
/**
|
|
57
|
+
* This method is used to update the effect's uniforms once per frame.
|
|
58
|
+
*
|
|
59
|
+
* @param {NodeFrame} frame - The current node frame.
|
|
60
|
+
*/
|
|
61
|
+
updateBefore( /* frame */ ) {
|
|
25
62
|
|
|
26
63
|
const map = this.textureNode.value;
|
|
27
64
|
|
|
@@ -29,13 +66,19 @@ class SobelOperatorNode extends TempNode {
|
|
|
29
66
|
|
|
30
67
|
}
|
|
31
68
|
|
|
32
|
-
|
|
69
|
+
/**
|
|
70
|
+
* This method is used to setup the effect's TSL code.
|
|
71
|
+
*
|
|
72
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
73
|
+
* @return {ShaderCallNodeInternal}
|
|
74
|
+
*/
|
|
75
|
+
setup( /* builder */ ) {
|
|
33
76
|
|
|
34
77
|
const { textureNode } = this;
|
|
35
78
|
|
|
36
79
|
const uvNode = textureNode.uvNode || uv();
|
|
37
80
|
|
|
38
|
-
const sampleTexture = ( uv ) => textureNode.
|
|
81
|
+
const sampleTexture = ( uv ) => textureNode.sample( uv );
|
|
39
82
|
|
|
40
83
|
const sobel = Fn( () => {
|
|
41
84
|
|
|
@@ -97,7 +140,7 @@ class SobelOperatorNode extends TempNode {
|
|
|
97
140
|
Gy[ 2 ][ 2 ].mul( tx2y2 )
|
|
98
141
|
);
|
|
99
142
|
|
|
100
|
-
//
|
|
143
|
+
// magnitude of the total gradient
|
|
101
144
|
|
|
102
145
|
const G = valueGx.mul( valueGx ).add( valueGy.mul( valueGy ) ).sqrt();
|
|
103
146
|
|
|
@@ -115,4 +158,11 @@ class SobelOperatorNode extends TempNode {
|
|
|
115
158
|
|
|
116
159
|
export default SobelOperatorNode;
|
|
117
160
|
|
|
161
|
+
/**
|
|
162
|
+
* TSL function for creating a sobel operator node which performs edge detection with a sobel filter.
|
|
163
|
+
*
|
|
164
|
+
* @function
|
|
165
|
+
* @param {Node<vec4>} node - The node that represents the input of the effect.
|
|
166
|
+
* @returns {SobelOperatorNode}
|
|
167
|
+
*/
|
|
118
168
|
export const sobel = ( node ) => nodeObject( new SobelOperatorNode( convertToTexture( node ) ) );
|