super-three 0.171.0 → 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,4 +1,4 @@
|
|
|
1
|
-
import { RenderTarget, StereoCamera, HalfFloatType, LinearFilter, NearestFilter, Vector2, PassNode, QuadMesh,
|
|
1
|
+
import { RenderTarget, StereoCamera, HalfFloatType, LinearFilter, NearestFilter, Vector2, PassNode, QuadMesh, RendererUtils } from 'three/webgpu';
|
|
2
2
|
import { texture } from 'three/tsl';
|
|
3
3
|
|
|
4
4
|
const _size = /*@__PURE__*/ new Vector2();
|
|
@@ -6,6 +6,16 @@ const _quadMesh = /*@__PURE__*/ new QuadMesh();
|
|
|
6
6
|
|
|
7
7
|
let _rendererState;
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* A special (abstract) render pass node that renders the scene
|
|
11
|
+
* as a stereoscopic image. Unlike {@link StereoPassNode}, this
|
|
12
|
+
* node merges the image for the left and right eye
|
|
13
|
+
* into a single one. That is required for effects like
|
|
14
|
+
* anaglyph or parallax barrier.
|
|
15
|
+
*
|
|
16
|
+
* @abstract
|
|
17
|
+
* @augments PassNode
|
|
18
|
+
*/
|
|
9
19
|
class StereoCompositePassNode extends PassNode {
|
|
10
20
|
|
|
11
21
|
static get type() {
|
|
@@ -14,25 +24,76 @@ class StereoCompositePassNode extends PassNode {
|
|
|
14
24
|
|
|
15
25
|
}
|
|
16
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Constructs a new stereo composite pass node.
|
|
29
|
+
*
|
|
30
|
+
* @param {Scene} scene - The scene to render.
|
|
31
|
+
* @param {Camera} camera - The camera to render the scene with.
|
|
32
|
+
*/
|
|
17
33
|
constructor( scene, camera ) {
|
|
18
34
|
|
|
19
35
|
super( PassNode.COLOR, scene, camera );
|
|
20
36
|
|
|
37
|
+
/**
|
|
38
|
+
* This flag can be used for type testing.
|
|
39
|
+
*
|
|
40
|
+
* @type {Boolean}
|
|
41
|
+
* @readonly
|
|
42
|
+
* @default true
|
|
43
|
+
*/
|
|
21
44
|
this.isStereoCompositePassNode = true;
|
|
22
45
|
|
|
46
|
+
/**
|
|
47
|
+
* The internal stereo camera that is used to render the scene.
|
|
48
|
+
*
|
|
49
|
+
* @type {StereoCamera}
|
|
50
|
+
*/
|
|
23
51
|
this.stereo = new StereoCamera();
|
|
24
52
|
const _params = { minFilter: LinearFilter, magFilter: NearestFilter, type: HalfFloatType };
|
|
25
53
|
|
|
54
|
+
/**
|
|
55
|
+
* The render target for rendering the left eye's view.
|
|
56
|
+
*
|
|
57
|
+
* @type {RenderTarget}
|
|
58
|
+
*/
|
|
26
59
|
this._renderTargetL = new RenderTarget( 1, 1, _params );
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The render target for rendering the right eye's view.
|
|
63
|
+
*
|
|
64
|
+
* @type {RenderTarget}
|
|
65
|
+
*/
|
|
27
66
|
this._renderTargetR = new RenderTarget( 1, 1, _params );
|
|
28
67
|
|
|
68
|
+
/**
|
|
69
|
+
* A texture node representing the left's eye view.
|
|
70
|
+
*
|
|
71
|
+
* @type {TextureNode}
|
|
72
|
+
*/
|
|
29
73
|
this._mapLeft = texture( this._renderTargetL.texture );
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* A texture node representing the right's eye view.
|
|
77
|
+
*
|
|
78
|
+
* @type {TextureNode}
|
|
79
|
+
*/
|
|
30
80
|
this._mapRight = texture( this._renderTargetR.texture );
|
|
31
81
|
|
|
82
|
+
/**
|
|
83
|
+
* The node material that implements the composite. All
|
|
84
|
+
* derived effect passes must provide an instance for rendering.
|
|
85
|
+
*
|
|
86
|
+
* @type {NodeMaterial}
|
|
87
|
+
*/
|
|
32
88
|
this._material = null;
|
|
33
89
|
|
|
34
90
|
}
|
|
35
91
|
|
|
92
|
+
/**
|
|
93
|
+
* Updates the internal stereo camera.
|
|
94
|
+
*
|
|
95
|
+
* @param {Number} coordinateSystem - The current coordinate system.
|
|
96
|
+
*/
|
|
36
97
|
updateStereoCamera( coordinateSystem ) {
|
|
37
98
|
|
|
38
99
|
this.stereo.cameraL.coordinateSystem = coordinateSystem;
|
|
@@ -41,6 +102,12 @@ class StereoCompositePassNode extends PassNode {
|
|
|
41
102
|
|
|
42
103
|
}
|
|
43
104
|
|
|
105
|
+
/**
|
|
106
|
+
* Sets the size of the pass.
|
|
107
|
+
*
|
|
108
|
+
* @param {Number} width - The width of the pass.
|
|
109
|
+
* @param {Number} height - The height of the pass.
|
|
110
|
+
*/
|
|
44
111
|
setSize( width, height ) {
|
|
45
112
|
|
|
46
113
|
super.setSize( width, height );
|
|
@@ -50,12 +117,17 @@ class StereoCompositePassNode extends PassNode {
|
|
|
50
117
|
|
|
51
118
|
}
|
|
52
119
|
|
|
120
|
+
/**
|
|
121
|
+
* This method is used to render the effect once per frame.
|
|
122
|
+
*
|
|
123
|
+
* @param {NodeFrame} frame - The current node frame.
|
|
124
|
+
*/
|
|
53
125
|
updateBefore( frame ) {
|
|
54
126
|
|
|
55
127
|
const { renderer } = frame;
|
|
56
128
|
const { scene, stereo, renderTarget } = this;
|
|
57
129
|
|
|
58
|
-
_rendererState =
|
|
130
|
+
_rendererState = RendererUtils.resetRendererState( renderer, _rendererState );
|
|
59
131
|
|
|
60
132
|
//
|
|
61
133
|
|
|
@@ -84,10 +156,14 @@ class StereoCompositePassNode extends PassNode {
|
|
|
84
156
|
|
|
85
157
|
// restore
|
|
86
158
|
|
|
87
|
-
|
|
159
|
+
RendererUtils.restoreRendererState( renderer, _rendererState );
|
|
88
160
|
|
|
89
161
|
}
|
|
90
162
|
|
|
163
|
+
/**
|
|
164
|
+
* Frees internal resources. This method should be called
|
|
165
|
+
* when the pass is no longer required.
|
|
166
|
+
*/
|
|
91
167
|
dispose() {
|
|
92
168
|
|
|
93
169
|
super.dispose();
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import { StereoCamera, Vector2, PassNode,
|
|
1
|
+
import { StereoCamera, Vector2, PassNode, RendererUtils } from 'three/webgpu';
|
|
2
2
|
import { nodeObject } from 'three/tsl';
|
|
3
3
|
|
|
4
|
+
/** @module StereoPassNode **/
|
|
5
|
+
|
|
4
6
|
const _size = /*@__PURE__*/ new Vector2();
|
|
5
7
|
|
|
6
8
|
let _rendererState;
|
|
7
9
|
|
|
10
|
+
/**
|
|
11
|
+
* A special render pass node that renders the scene as a stereoscopic image.
|
|
12
|
+
*
|
|
13
|
+
* @augments PassNode
|
|
14
|
+
*/
|
|
8
15
|
class StereoPassNode extends PassNode {
|
|
9
16
|
|
|
10
17
|
static get type() {
|
|
@@ -13,23 +20,46 @@ class StereoPassNode extends PassNode {
|
|
|
13
20
|
|
|
14
21
|
}
|
|
15
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Constructs a new stereo pass node.
|
|
25
|
+
*
|
|
26
|
+
* @param {Scene} scene - The scene to render.
|
|
27
|
+
* @param {Camera} camera - The camera to render the scene with.
|
|
28
|
+
*/
|
|
16
29
|
constructor( scene, camera ) {
|
|
17
30
|
|
|
18
31
|
super( PassNode.COLOR, scene, camera );
|
|
19
32
|
|
|
33
|
+
/**
|
|
34
|
+
* This flag can be used for type testing.
|
|
35
|
+
*
|
|
36
|
+
* @type {Boolean}
|
|
37
|
+
* @readonly
|
|
38
|
+
* @default true
|
|
39
|
+
*/
|
|
20
40
|
this.isStereoPassNode = true;
|
|
21
41
|
|
|
42
|
+
/**
|
|
43
|
+
* The internal stereo camera that is used to render the scene.
|
|
44
|
+
*
|
|
45
|
+
* @type {StereoCamera}
|
|
46
|
+
*/
|
|
22
47
|
this.stereo = new StereoCamera();
|
|
23
48
|
this.stereo.aspect = 0.5;
|
|
24
49
|
|
|
25
50
|
}
|
|
26
51
|
|
|
52
|
+
/**
|
|
53
|
+
* This method is used to render the stereo effect once per frame.
|
|
54
|
+
*
|
|
55
|
+
* @param {NodeFrame} frame - The current node frame.
|
|
56
|
+
*/
|
|
27
57
|
updateBefore( frame ) {
|
|
28
58
|
|
|
29
59
|
const { renderer } = frame;
|
|
30
60
|
const { scene, camera, stereo, renderTarget } = this;
|
|
31
61
|
|
|
32
|
-
_rendererState =
|
|
62
|
+
_rendererState = RendererUtils.resetRendererState( renderer, _rendererState );
|
|
33
63
|
|
|
34
64
|
//
|
|
35
65
|
|
|
@@ -71,7 +101,7 @@ class StereoPassNode extends PassNode {
|
|
|
71
101
|
|
|
72
102
|
// restore
|
|
73
103
|
|
|
74
|
-
|
|
104
|
+
RendererUtils.restoreRendererState( renderer, _rendererState );
|
|
75
105
|
|
|
76
106
|
}
|
|
77
107
|
|
|
@@ -79,4 +109,12 @@ class StereoPassNode extends PassNode {
|
|
|
79
109
|
|
|
80
110
|
export default StereoPassNode;
|
|
81
111
|
|
|
112
|
+
/**
|
|
113
|
+
* TSL function for creating a stereo pass node for stereoscopic rendering.
|
|
114
|
+
*
|
|
115
|
+
* @function
|
|
116
|
+
* @param {Scene} scene - The scene to render.
|
|
117
|
+
* @param {Camera} camera - The camera to render the scene with.
|
|
118
|
+
* @returns {StereoPassNode}
|
|
119
|
+
*/
|
|
82
120
|
export const stereoPass = ( scene, camera ) => nodeObject( new StereoPassNode( scene, camera ) );
|
|
@@ -1,19 +1,25 @@
|
|
|
1
|
-
import { Color, Vector2, NearestFilter, Matrix4,
|
|
1
|
+
import { Color, Vector2, NearestFilter, Matrix4, RendererUtils, PassNode, QuadMesh, NodeMaterial } from 'three/webgpu';
|
|
2
2
|
import { add, float, If, Loop, int, Fn, min, max, clamp, nodeObject, texture, uniform, uv, vec2, vec4, luminance } from 'three/tsl';
|
|
3
3
|
|
|
4
|
+
/** @module TRAAPassNode **/
|
|
5
|
+
|
|
4
6
|
const _quadMesh = /*@__PURE__*/ new QuadMesh();
|
|
5
7
|
const _size = /*@__PURE__*/ new Vector2();
|
|
6
8
|
|
|
7
9
|
let _rendererState;
|
|
8
10
|
|
|
11
|
+
|
|
9
12
|
/**
|
|
10
|
-
* Temporal Reprojection Anti-Aliasing
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
|
|
13
|
+
* A special render pass node that renders the scene with TRAA (Temporal Reprojection Anti-Aliasing).
|
|
14
|
+
*
|
|
15
|
+
* Note: The current implementation does not yet support MRT setups.
|
|
16
|
+
*
|
|
17
|
+
* References:
|
|
18
|
+
* - {@link https://alextardif.com/TAA.html}
|
|
19
|
+
* - {@link https://www.elopezr.com/temporal-aa-and-the-quest-for-the-holy-trail/}
|
|
20
|
+
*
|
|
21
|
+
* @augments PassNode
|
|
22
|
+
*/
|
|
17
23
|
class TRAAPassNode extends PassNode {
|
|
18
24
|
|
|
19
25
|
static get type() {
|
|
@@ -22,34 +28,100 @@ class TRAAPassNode extends PassNode {
|
|
|
22
28
|
|
|
23
29
|
}
|
|
24
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Constructs a new TRAA pass node.
|
|
33
|
+
*
|
|
34
|
+
* @param {Scene} scene - The scene to render.
|
|
35
|
+
* @param {Camera} camera - The camera to render the scene with.
|
|
36
|
+
*/
|
|
25
37
|
constructor( scene, camera ) {
|
|
26
38
|
|
|
27
39
|
super( PassNode.COLOR, scene, camera );
|
|
28
40
|
|
|
41
|
+
/**
|
|
42
|
+
* This flag can be used for type testing.
|
|
43
|
+
*
|
|
44
|
+
* @type {Boolean}
|
|
45
|
+
* @readonly
|
|
46
|
+
* @default true
|
|
47
|
+
*/
|
|
29
48
|
this.isTRAAPassNode = true;
|
|
30
49
|
|
|
50
|
+
/**
|
|
51
|
+
* The clear color of the pass.
|
|
52
|
+
*
|
|
53
|
+
* @type {Color}
|
|
54
|
+
* @default 0x000000
|
|
55
|
+
*/
|
|
31
56
|
this.clearColor = new Color( 0x000000 );
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The clear alpha of the pass.
|
|
60
|
+
*
|
|
61
|
+
* @type {Number}
|
|
62
|
+
* @default 0
|
|
63
|
+
*/
|
|
32
64
|
this.clearAlpha = 0;
|
|
33
65
|
|
|
66
|
+
/**
|
|
67
|
+
* The jitter index selects the current camera offset value.
|
|
68
|
+
*
|
|
69
|
+
* @private
|
|
70
|
+
* @type {Number}
|
|
71
|
+
* @default 0
|
|
72
|
+
*/
|
|
34
73
|
this._jitterIndex = 0;
|
|
35
|
-
this._originalProjectionMatrix = new Matrix4();
|
|
36
74
|
|
|
37
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Used to save the original/unjittered projection matrix.
|
|
77
|
+
*
|
|
78
|
+
* @private
|
|
79
|
+
* @type {Matrix4}
|
|
80
|
+
*/
|
|
81
|
+
this._originalProjectionMatrix = new Matrix4();
|
|
38
82
|
|
|
83
|
+
/**
|
|
84
|
+
* A uniform node holding the inverse resolution value.
|
|
85
|
+
*
|
|
86
|
+
* @private
|
|
87
|
+
* @type {UniformNode<vec2>}
|
|
88
|
+
*/
|
|
39
89
|
this._invSize = uniform( new Vector2() );
|
|
40
90
|
|
|
41
|
-
|
|
42
|
-
|
|
91
|
+
/**
|
|
92
|
+
* The render target that holds the current sample.
|
|
93
|
+
*
|
|
94
|
+
* @private
|
|
95
|
+
* @type {RenderTarget?}
|
|
96
|
+
*/
|
|
43
97
|
this._sampleRenderTarget = null;
|
|
44
|
-
this._historyRenderTarget = null;
|
|
45
98
|
|
|
46
|
-
|
|
99
|
+
/**
|
|
100
|
+
* The render target that represents the history of frame data.
|
|
101
|
+
*
|
|
102
|
+
* @private
|
|
103
|
+
* @type {RenderTarget?}
|
|
104
|
+
*/
|
|
105
|
+
this._historyRenderTarget = null;
|
|
47
106
|
|
|
107
|
+
/**
|
|
108
|
+
* Material used for the resolve step.
|
|
109
|
+
*
|
|
110
|
+
* @private
|
|
111
|
+
* @type {NodeMaterial}
|
|
112
|
+
*/
|
|
48
113
|
this._resolveMaterial = new NodeMaterial();
|
|
49
114
|
this._resolveMaterial.name = 'TRAA.Resolve';
|
|
50
115
|
|
|
51
116
|
}
|
|
52
117
|
|
|
118
|
+
/**
|
|
119
|
+
* Sets the size of the effect.
|
|
120
|
+
*
|
|
121
|
+
* @param {Number} width - The width of the effect.
|
|
122
|
+
* @param {Number} height - The height of the effect.
|
|
123
|
+
* @return {Boolean} Whether the TRAA needs a restart or not. That is required after a resize since buffer data with different sizes can't be resolved.
|
|
124
|
+
*/
|
|
53
125
|
setSize( width, height ) {
|
|
54
126
|
|
|
55
127
|
super.setSize( width, height );
|
|
@@ -71,12 +143,17 @@ class TRAAPassNode extends PassNode {
|
|
|
71
143
|
|
|
72
144
|
}
|
|
73
145
|
|
|
146
|
+
/**
|
|
147
|
+
* This method is used to render the effect once per frame.
|
|
148
|
+
*
|
|
149
|
+
* @param {NodeFrame} frame - The current node frame.
|
|
150
|
+
*/
|
|
74
151
|
updateBefore( frame ) {
|
|
75
152
|
|
|
76
153
|
const { renderer } = frame;
|
|
77
154
|
const { scene, camera } = this;
|
|
78
155
|
|
|
79
|
-
_rendererState =
|
|
156
|
+
_rendererState = RendererUtils.resetRendererAndSceneState( renderer, scene, _rendererState );
|
|
80
157
|
|
|
81
158
|
//
|
|
82
159
|
|
|
@@ -214,10 +291,16 @@ class TRAAPassNode extends PassNode {
|
|
|
214
291
|
|
|
215
292
|
velocityOutput.setProjectionMatrix( null );
|
|
216
293
|
|
|
217
|
-
|
|
294
|
+
RendererUtils.restoreRendererAndSceneState( renderer, scene, _rendererState );
|
|
218
295
|
|
|
219
296
|
}
|
|
220
297
|
|
|
298
|
+
/**
|
|
299
|
+
* This method is used to setup the effect's render targets and TSL code.
|
|
300
|
+
*
|
|
301
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
302
|
+
* @return {PassTextureNode}
|
|
303
|
+
*/
|
|
221
304
|
setup( builder ) {
|
|
222
305
|
|
|
223
306
|
if ( this._sampleRenderTarget === null ) {
|
|
@@ -260,12 +343,12 @@ class TRAAPassNode extends PassNode {
|
|
|
260
343
|
Loop( { start: int( - 1 ), end: int( 1 ), type: 'int', condition: '<=', name: 'y' }, ( { y } ) => {
|
|
261
344
|
|
|
262
345
|
const uvNeighbor = uvNode.add( vec2( float( x ), float( y ) ).mul( this._invSize ) ).toVar();
|
|
263
|
-
const colorNeighbor = max( vec4( 0 ), sampleTexture.
|
|
346
|
+
const colorNeighbor = max( vec4( 0 ), sampleTexture.sample( uvNeighbor ) ).toVar(); // use max() to avoid propagate garbage values
|
|
264
347
|
|
|
265
348
|
minColor.assign( min( minColor, colorNeighbor ) );
|
|
266
349
|
maxColor.assign( max( maxColor, colorNeighbor ) );
|
|
267
350
|
|
|
268
|
-
const currentDepth = depthTexture.
|
|
351
|
+
const currentDepth = depthTexture.sample( uvNeighbor ).r.toVar();
|
|
269
352
|
|
|
270
353
|
// find the sample position of the closest depth in the neighborhood (used for velocity)
|
|
271
354
|
|
|
@@ -282,10 +365,10 @@ class TRAAPassNode extends PassNode {
|
|
|
282
365
|
|
|
283
366
|
// sampling/reprojection
|
|
284
367
|
|
|
285
|
-
const offset = velocityTexture.
|
|
368
|
+
const offset = velocityTexture.sample( closestDepthPixelPosition ).xy.mul( vec2( 0.5, - 0.5 ) ); // NDC to uv offset
|
|
286
369
|
|
|
287
|
-
const currentColor = sampleTexture.
|
|
288
|
-
const historyColor = historyTexture.
|
|
370
|
+
const currentColor = sampleTexture.sample( uvNode );
|
|
371
|
+
const historyColor = historyTexture.sample( uvNode.sub( offset ) );
|
|
289
372
|
|
|
290
373
|
// clamping
|
|
291
374
|
|
|
@@ -317,6 +400,10 @@ class TRAAPassNode extends PassNode {
|
|
|
317
400
|
|
|
318
401
|
}
|
|
319
402
|
|
|
403
|
+
/**
|
|
404
|
+
* Frees internal resources. This method should be called
|
|
405
|
+
* when the effect is no longer required.
|
|
406
|
+
*/
|
|
320
407
|
dispose() {
|
|
321
408
|
|
|
322
409
|
super.dispose();
|
|
@@ -352,4 +439,12 @@ const _JitterVectors = [
|
|
|
352
439
|
[ 2, 5 ], [ 7, 5 ], [ 5, 6 ], [ 3, 7 ]
|
|
353
440
|
];
|
|
354
441
|
|
|
442
|
+
/**
|
|
443
|
+
* TSL function for creating a TRAA pass node for Temporal Reprojection Anti-Aliasing.
|
|
444
|
+
*
|
|
445
|
+
* @function
|
|
446
|
+
* @param {Scene} scene - The scene to render.
|
|
447
|
+
* @param {Camera} camera - The camera to render the scene with.
|
|
448
|
+
* @returns {TRAAPassNode}
|
|
449
|
+
*/
|
|
355
450
|
export const traaPass = ( scene, camera ) => nodeObject( new TRAAPassNode( scene, camera ) );
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { TempNode } from 'three/webgpu';
|
|
2
2
|
import { nodeObject, Fn, float, uv, convertToTexture, vec4, If, int, clamp, sub, mix } from 'three/tsl';
|
|
3
3
|
|
|
4
|
+
/** @module TransitionNode **/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Post processing node for creating a transition effect between scenes.
|
|
8
|
+
*
|
|
9
|
+
* @augments TempNode
|
|
10
|
+
*/
|
|
4
11
|
class TransitionNode extends TempNode {
|
|
5
12
|
|
|
6
13
|
static get type() {
|
|
@@ -9,24 +16,70 @@ class TransitionNode extends TempNode {
|
|
|
9
16
|
|
|
10
17
|
}
|
|
11
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Constructs a new transition node.
|
|
21
|
+
*
|
|
22
|
+
* @param {TextureNode} textureNodeA - A texture node that represents the beauty pass of the first scene.
|
|
23
|
+
* @param {TextureNode} textureNodeB - A texture node that represents the beauty pass of the second scene.
|
|
24
|
+
* @param {TextureNode} mixTextureNode - A texture node that defines how the transition effect should look like.
|
|
25
|
+
* @param {Node<float>} mixRatioNode - The interpolation factor that controls the mix.
|
|
26
|
+
* @param {Node<float>} thresholdNode - Can be used to tweak the linear interpolation.
|
|
27
|
+
* @param {Node<float>} useTextureNode - Whether `mixTextureNode` should influence the transition or not.
|
|
28
|
+
*/
|
|
12
29
|
constructor( textureNodeA, textureNodeB, mixTextureNode, mixRatioNode, thresholdNode, useTextureNode ) {
|
|
13
30
|
|
|
14
31
|
super( 'vec4' );
|
|
15
32
|
|
|
16
|
-
|
|
17
|
-
|
|
33
|
+
/**
|
|
34
|
+
* A texture node that represents the beauty pass of the first scene.
|
|
35
|
+
*
|
|
36
|
+
* @type {TextureNode}
|
|
37
|
+
*/
|
|
18
38
|
this.textureNodeA = textureNodeA;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* A texture node that represents the beauty pass of the second scene.
|
|
42
|
+
*
|
|
43
|
+
* @type {TextureNode}
|
|
44
|
+
*/
|
|
19
45
|
this.textureNodeB = textureNodeB;
|
|
20
|
-
this.mixTextureNode = mixTextureNode;
|
|
21
46
|
|
|
22
|
-
|
|
47
|
+
/**
|
|
48
|
+
* A texture that defines how the transition effect should look like.
|
|
49
|
+
*
|
|
50
|
+
* @type {TextureNode}
|
|
51
|
+
*/
|
|
52
|
+
this.mixTextureNode = mixTextureNode;
|
|
23
53
|
|
|
54
|
+
/**
|
|
55
|
+
* The interpolation factor that controls the mix.
|
|
56
|
+
*
|
|
57
|
+
* @type {Node<float>}
|
|
58
|
+
*/
|
|
24
59
|
this.mixRatioNode = mixRatioNode;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Can be used to tweak the linear interpolation.
|
|
63
|
+
*
|
|
64
|
+
* @type {Node<float>}
|
|
65
|
+
*/
|
|
25
66
|
this.thresholdNode = thresholdNode;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Whether `mixTextureNode` should influence the transition or not.
|
|
70
|
+
*
|
|
71
|
+
* @type {Node<float>}
|
|
72
|
+
*/
|
|
26
73
|
this.useTextureNode = useTextureNode;
|
|
27
74
|
|
|
28
75
|
}
|
|
29
76
|
|
|
77
|
+
/**
|
|
78
|
+
* This method is used to setup the effect's TSL code.
|
|
79
|
+
*
|
|
80
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
81
|
+
* @return {ShaderCallNodeInternal}
|
|
82
|
+
*/
|
|
30
83
|
setup() {
|
|
31
84
|
|
|
32
85
|
const { textureNodeA, textureNodeB, mixTextureNode, mixRatioNode, thresholdNode, useTextureNode } = this;
|
|
@@ -34,7 +87,7 @@ class TransitionNode extends TempNode {
|
|
|
34
87
|
const sampleTexture = ( textureNode ) => {
|
|
35
88
|
|
|
36
89
|
const uvNodeTexture = textureNode.uvNode || uv();
|
|
37
|
-
return textureNode.
|
|
90
|
+
return textureNode.sample( uvNodeTexture );
|
|
38
91
|
|
|
39
92
|
};
|
|
40
93
|
|
|
@@ -73,4 +126,16 @@ class TransitionNode extends TempNode {
|
|
|
73
126
|
|
|
74
127
|
export default TransitionNode;
|
|
75
128
|
|
|
76
|
-
|
|
129
|
+
/**
|
|
130
|
+
* TSL function for creating a transition node for post processing.
|
|
131
|
+
*
|
|
132
|
+
* @function
|
|
133
|
+
* @param {Node<vec4>} nodeA - A texture node that represents the beauty pass of the first scene.
|
|
134
|
+
* @param {Node<vec4>} nodeB - A texture node that represents the beauty pass of the second scene.
|
|
135
|
+
* @param {Node<vec4>} mixTextureNode - A texture that defines how the transition effect should look like.
|
|
136
|
+
* @param {Node<float> | Number} mixRatio - The interpolation factor that controls the mix.
|
|
137
|
+
* @param {Node<float> | Number} threshold - Can be used to tweak the linear interpolation.
|
|
138
|
+
* @param {Node<float> | Number} useTexture - Whether `mixTextureNode` should influence the transition or not.
|
|
139
|
+
* @returns {TransitionNode}
|
|
140
|
+
*/
|
|
141
|
+
export const transition = ( nodeA, nodeB, mixTextureNode, mixRatio, threshold, useTexture ) => nodeObject( new TransitionNode( convertToTexture( nodeA ), convertToTexture( nodeB ), convertToTexture( mixTextureNode ), nodeObject( mixRatio ), nodeObject( threshold ), nodeObject( useTexture ) ) );
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
import { float, Fn, vec2, uv, sin, rand, degrees, cos, Loop, vec4 } from 'three/tsl';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/** @module HashBlur **/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Applies a hash blur effect to the given texture node.
|
|
7
|
+
*
|
|
8
|
+
* Reference: {@link https://www.shadertoy.com/view/4lXXWn}.
|
|
9
|
+
*
|
|
10
|
+
* @function
|
|
11
|
+
* @param {Node<vec4>} textureNode - The texture node that should be blurred.
|
|
12
|
+
* @param {Node<float>} [bluramount=float(0.1)] - This node determines the amount of blur.
|
|
13
|
+
* @param {Node<float>} [repeats=float(45)] - This node determines the quality of the blur. A higher value produces a less grainy result but is also more expensive.
|
|
14
|
+
* @return {Node<vec4>} The blurred texture node.
|
|
15
|
+
*/
|
|
5
16
|
export const hashBlur = /*#__PURE__*/ Fn( ( [ textureNode, bluramount = float( 0.1 ), repeats = float( 45 ) ] ) => {
|
|
6
17
|
|
|
7
|
-
const draw = ( uv ) => textureNode.
|
|
18
|
+
const draw = ( uv ) => textureNode.sample( uv );
|
|
8
19
|
|
|
9
20
|
const targetUV = textureNode.uvNode || uv();
|
|
10
21
|
const blurred_image = vec4( 0. ).toVar();
|