super-three 0.167.0 → 0.169.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/build/three.cjs +532 -173
- package/build/three.module.js +532 -174
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +18173 -14266
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +79941 -0
- package/build/three.webgpu.nodes.min.js +6 -0
- package/examples/jsm/Addons.js +0 -4
- package/examples/jsm/animation/AnimationClipCreator.js +1 -1
- package/examples/jsm/capabilities/WebGL.js +27 -21
- package/examples/jsm/controls/ArcballControls.js +174 -158
- package/examples/jsm/controls/DragControls.js +260 -132
- package/examples/jsm/controls/FirstPersonControls.js +175 -163
- package/examples/jsm/controls/FlyControls.js +194 -188
- package/examples/jsm/controls/OrbitControls.js +777 -786
- package/examples/jsm/controls/PointerLockControls.js +24 -15
- package/examples/jsm/controls/TrackballControls.js +469 -448
- package/examples/jsm/controls/TransformControls.js +97 -62
- package/examples/jsm/effects/AnaglyphEffect.js +6 -13
- package/examples/jsm/effects/ParallaxBarrierEffect.js +17 -11
- package/examples/jsm/effects/StereoEffect.js +6 -1
- package/examples/jsm/environments/RoomEnvironment.js +1 -1
- package/examples/jsm/exporters/DRACOExporter.js +4 -2
- package/examples/jsm/exporters/EXRExporter.js +19 -11
- package/examples/jsm/exporters/GLTFExporter.js +6 -1
- package/examples/jsm/exporters/KTX2Exporter.js +21 -13
- package/examples/jsm/exporters/OBJExporter.js +5 -1
- package/examples/jsm/exporters/PLYExporter.js +9 -7
- package/examples/jsm/exporters/USDZExporter.js +29 -8
- package/examples/jsm/geometries/DecalGeometry.js +4 -1
- package/examples/jsm/geometries/InstancedPointsGeometry.js +1 -1
- package/examples/jsm/helpers/LightProbeHelper.js +43 -44
- package/examples/jsm/helpers/LightProbeHelperGPU.js +65 -0
- package/examples/jsm/libs/basis/basis_transcoder.js +8 -10
- package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/lights/LightProbeGenerator.js +24 -10
- package/examples/jsm/loaders/ColladaLoader.js +9 -6
- package/examples/jsm/loaders/DRACOLoader.js +3 -1
- package/examples/jsm/loaders/FBXLoader.js +30 -20
- package/examples/jsm/loaders/GLTFLoader.js +5 -10
- package/examples/jsm/loaders/KTX2Loader.js +27 -12
- package/examples/jsm/loaders/MTLLoader.js +4 -3
- package/examples/jsm/loaders/MaterialXLoader.js +40 -14
- package/examples/jsm/loaders/OBJLoader.js +5 -3
- package/examples/jsm/loaders/PCDLoader.js +14 -13
- package/examples/jsm/loaders/PDBLoader.js +3 -2
- package/examples/jsm/loaders/PLYLoader.js +8 -5
- package/examples/jsm/loaders/STLLoader.js +3 -2
- package/examples/jsm/loaders/VRMLLoader.js +10 -10
- package/examples/jsm/loaders/VTKLoader.js +4 -3
- package/examples/jsm/loaders/XYZLoader.js +3 -2
- package/examples/jsm/misc/Timer.js +1 -1
- package/examples/jsm/modifiers/CurveModifierGPU.js +233 -0
- package/examples/jsm/objects/LensflareMesh.js +322 -0
- package/examples/jsm/objects/SkyMesh.js +187 -0
- package/examples/jsm/objects/Water2Mesh.js +158 -0
- package/examples/jsm/objects/WaterMesh.js +101 -0
- package/examples/jsm/physics/JoltPhysics.js +1 -1
- package/examples/jsm/physics/RapierPhysics.js +21 -1
- package/examples/jsm/postprocessing/OutlinePass.js +31 -46
- package/examples/jsm/postprocessing/SSAARenderPass.js +3 -1
- package/examples/jsm/shaders/BleachBypassShader.js +1 -2
- package/examples/jsm/shaders/OutputShader.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -2
- package/examples/jsm/transpiler/TSLEncoder.js +8 -8
- package/examples/jsm/utils/GeometryCompressionUtils.js +37 -122
- package/examples/jsm/utils/ShadowMapViewer.js +3 -8
- package/examples/jsm/utils/ShadowMapViewerGPU.js +201 -0
- package/examples/jsm/utils/SkeletonUtils.js +84 -66
- package/examples/jsm/utils/TextureUtils.js +2 -1
- package/examples/jsm/utils/TextureUtilsGPU.js +63 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
- package/package.json +3 -2
- package/src/Three.WebGPU.Nodes.js +200 -0
- package/src/Three.WebGPU.js +7 -0
- package/src/Three.js +1 -0
- package/src/audio/Audio.js +2 -2
- package/src/constants.js +1 -1
- package/src/core/BufferAttribute.js +0 -9
- package/src/core/Clock.js +1 -1
- package/src/core/InterleavedBuffer.js +0 -9
- package/src/extras/Controls.js +32 -0
- package/src/geometries/CylinderGeometry.js +11 -4
- package/src/loaders/MaterialLoader.js +7 -1
- package/src/loaders/ObjectLoader.js +3 -3
- package/src/{nodes/loaders → loaders/nodes}/NodeLoader.js +25 -5
- package/src/{nodes/loaders → loaders/nodes}/NodeMaterialLoader.js +21 -18
- package/src/{nodes/loaders → loaders/nodes}/NodeObjectLoader.js +19 -0
- package/src/materials/Material.js +4 -7
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +156 -0
- package/src/{nodes/materials → materials/nodes}/Line2NodeMaterial.js +56 -59
- package/src/{nodes/materials → materials/nodes}/LineBasicNodeMaterial.js +8 -5
- package/src/{nodes/materials → materials/nodes}/LineDashedNodeMaterial.js +12 -10
- package/src/{nodes/materials → materials/nodes}/MeshBasicNodeMaterial.js +16 -12
- package/src/{nodes/materials → materials/nodes}/MeshLambertNodeMaterial.js +10 -6
- package/src/{nodes/materials → materials/nodes}/MeshMatcapNodeMaterial.js +13 -9
- package/src/{nodes/materials → materials/nodes}/MeshNormalNodeMaterial.js +13 -9
- package/src/{nodes/materials → materials/nodes}/MeshPhongNodeMaterial.js +14 -9
- package/src/{nodes/materials → materials/nodes}/MeshPhysicalNodeMaterial.js +22 -18
- package/src/{nodes/materials → materials/nodes}/MeshSSSNodeMaterial.js +10 -7
- package/src/{nodes/materials → materials/nodes}/MeshStandardNodeMaterial.js +22 -12
- package/src/{nodes/materials → materials/nodes}/MeshToonNodeMaterial.js +9 -5
- package/src/{nodes/materials → materials/nodes}/NodeMaterial.js +71 -115
- package/src/{nodes/materials/Materials.js → materials/nodes/NodeMaterials.js} +3 -1
- package/src/{nodes/materials → materials/nodes}/PointsNodeMaterial.js +8 -5
- package/src/{nodes/materials → materials/nodes}/ShadowNodeMaterial.js +9 -5
- package/src/{nodes/materials → materials/nodes}/SpriteNodeMaterial.js +47 -14
- package/src/{nodes/materials → materials/nodes}/VolumeNodeMaterial.js +24 -22
- package/src/materials/nodes/manager/NodeMaterialObserver.js +302 -0
- package/src/math/Triangle.js +24 -0
- package/src/nodes/Nodes.js +103 -159
- package/src/nodes/TSL.js +179 -0
- package/src/nodes/accessors/AccessorsUtils.js +8 -8
- package/src/nodes/accessors/BatchNode.js +53 -21
- package/src/nodes/accessors/{BitangentNode.js → Bitangent.js} +9 -9
- package/src/nodes/accessors/BufferAttributeNode.js +8 -5
- package/src/nodes/accessors/BufferNode.js +7 -4
- package/src/nodes/accessors/Camera.js +13 -0
- package/src/nodes/accessors/ClippingNode.js +19 -13
- package/src/nodes/accessors/CubeTextureNode.js +9 -8
- package/src/nodes/accessors/InstanceNode.js +19 -15
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +8 -5
- package/src/nodes/accessors/Lights.js +51 -0
- package/src/nodes/accessors/MaterialNode.js +56 -55
- package/src/nodes/accessors/MaterialProperties.js +3 -0
- package/src/nodes/accessors/MaterialReferenceNode.js +9 -4
- package/src/nodes/accessors/ModelNode.js +47 -12
- package/src/nodes/accessors/ModelViewProjectionNode.js +12 -9
- package/src/nodes/accessors/MorphNode.js +17 -13
- package/src/nodes/accessors/Normal.js +88 -0
- package/src/nodes/accessors/Object3DNode.js +17 -33
- package/src/nodes/accessors/PointUVNode.js +9 -5
- package/src/nodes/accessors/Position.js +10 -0
- package/src/nodes/accessors/ReferenceBaseNode.js +171 -0
- package/src/nodes/accessors/ReferenceNode.js +50 -7
- package/src/nodes/accessors/ReflectVector.js +10 -0
- package/src/nodes/accessors/RendererReferenceNode.js +12 -6
- package/src/nodes/accessors/SceneNode.js +9 -6
- package/src/nodes/accessors/SkinningNode.js +88 -21
- package/src/nodes/accessors/StorageBufferNode.js +22 -5
- package/src/nodes/accessors/StorageTextureNode.js +9 -6
- package/src/nodes/accessors/Tangent.js +22 -0
- package/src/nodes/accessors/Texture3DNode.js +16 -13
- package/src/nodes/accessors/{TextureBicubicNode.js → TextureBicubic.js} +3 -32
- package/src/nodes/accessors/TextureNode.js +29 -23
- package/src/nodes/accessors/TextureSizeNode.js +10 -9
- package/src/nodes/accessors/{UniformsNode.js → UniformArrayNode.js} +26 -14
- package/src/nodes/accessors/UserDataNode.js +10 -7
- package/src/nodes/accessors/VelocityNode.js +134 -0
- package/src/nodes/accessors/VertexColorNode.js +7 -4
- package/src/nodes/code/CodeNode.js +9 -5
- package/src/nodes/code/ExpressionNode.js +10 -6
- package/src/nodes/code/FunctionCallNode.js +8 -5
- package/src/nodes/code/FunctionNode.js +8 -23
- package/src/nodes/code/ScriptableNode.js +13 -10
- package/src/nodes/code/ScriptableValueNode.js +9 -7
- package/src/nodes/core/AssignNode.js +12 -9
- package/src/nodes/core/AttributeNode.js +12 -21
- package/src/nodes/core/BypassNode.js +11 -7
- package/src/nodes/core/CacheNode.js +10 -6
- package/src/nodes/core/ConstNode.js +6 -3
- package/src/nodes/core/ContextNode.js +21 -11
- package/src/nodes/core/IndexNode.js +35 -8
- package/src/nodes/core/InputNode.js +7 -3
- package/src/nodes/core/MRTNode.js +16 -7
- package/src/nodes/core/Node.js +19 -40
- package/src/nodes/core/NodeBuilder.js +117 -38
- package/src/nodes/core/NodeUtils.js +49 -6
- package/src/nodes/core/OutputStructNode.js +10 -6
- package/src/nodes/core/ParameterNode.js +7 -4
- package/src/nodes/core/PropertyNode.js +36 -32
- package/src/nodes/core/StackNode.js +31 -11
- package/src/nodes/core/StructTypeNode.js +7 -3
- package/src/nodes/core/TempNode.js +8 -4
- package/src/nodes/core/UniformGroupNode.js +14 -11
- package/src/nodes/core/UniformNode.js +7 -4
- package/src/nodes/core/VarNode.js +12 -8
- package/src/nodes/core/VaryingNode.js +10 -6
- package/src/nodes/display/AfterImageNode.js +15 -9
- package/src/nodes/display/AnaglyphPassNode.js +67 -0
- package/src/nodes/display/AnamorphicNode.js +17 -11
- package/src/nodes/display/BleachBypass.js +26 -0
- package/src/nodes/display/BlendMode.js +54 -0
- package/src/nodes/display/BloomNode.js +27 -19
- package/src/nodes/display/BumpMapNode.js +13 -12
- package/src/nodes/display/ColorAdjustment.js +46 -0
- package/src/nodes/display/ColorSpaceFunctions.js +38 -0
- package/src/nodes/display/ColorSpaceNode.js +67 -61
- package/src/nodes/display/DenoiseNode.js +23 -17
- package/src/nodes/display/DepthOfFieldNode.js +12 -7
- package/src/nodes/display/DotScreenNode.js +13 -22
- package/src/nodes/display/FXAANode.js +21 -16
- package/src/nodes/display/FilmNode.js +11 -7
- package/src/nodes/display/FrontFacingNode.js +10 -6
- package/src/nodes/display/GTAONode.js +22 -15
- package/src/nodes/display/GaussianBlurNode.js +14 -8
- package/src/nodes/display/Lut3DNode.js +10 -6
- package/src/nodes/display/MotionBlur.js +25 -0
- package/src/nodes/display/NormalMapNode.js +13 -13
- package/src/nodes/display/ParallaxBarrierPassNode.js +58 -0
- package/src/nodes/display/PassNode.js +95 -8
- package/src/nodes/display/PixelationPassNode.js +20 -8
- package/src/nodes/display/PosterizeNode.js +8 -7
- package/src/nodes/display/RGBShiftNode.js +11 -7
- package/src/nodes/display/RenderOutputNode.js +15 -11
- package/src/nodes/display/SSAAPassNode.js +287 -0
- package/src/nodes/display/ScreenNode.js +181 -0
- package/src/nodes/display/Sepia.js +17 -0
- package/src/nodes/display/SobelOperatorNode.js +13 -8
- package/src/nodes/display/StereoCompositePassNode.js +110 -0
- package/src/nodes/display/StereoPassNode.js +83 -0
- package/src/nodes/display/ToneMappingFunctions.js +190 -0
- package/src/nodes/display/ToneMappingNode.js +15 -175
- package/src/nodes/display/ToonOutlinePassNode.js +111 -0
- package/src/nodes/display/TransitionNode.js +12 -8
- package/src/nodes/display/ViewportDepthNode.js +34 -29
- package/src/nodes/display/ViewportDepthTextureNode.js +10 -9
- package/src/nodes/display/ViewportSharedTextureNode.js +10 -9
- package/src/nodes/display/ViewportTextureNode.js +11 -11
- package/src/nodes/fog/FogExp2Node.js +8 -7
- package/src/nodes/fog/FogNode.js +10 -8
- package/src/nodes/fog/FogRangeNode.js +8 -7
- package/src/nodes/functions/BSDF/BRDF_GGX.js +4 -4
- package/src/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +6 -6
- package/src/nodes/functions/BSDF/DFGApprox.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +3 -3
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/F_Schlick.js +2 -2
- package/src/nodes/functions/BSDF/LTC.js +6 -6
- package/src/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
- package/src/nodes/functions/BasicLightingModel.js +1 -1
- package/src/nodes/functions/PhongLightingModel.js +5 -5
- package/src/nodes/functions/PhysicalLightingModel.js +34 -33
- package/src/nodes/functions/ShadowMaskModel.js +1 -1
- package/src/nodes/functions/ToonLightingModel.js +3 -3
- package/src/nodes/functions/material/getGeometryRoughness.js +4 -4
- package/src/nodes/functions/material/getRoughness.js +2 -2
- package/src/nodes/functions/material/getShIrradianceAt.js +28 -0
- package/src/nodes/geometry/RangeNode.js +9 -5
- package/src/nodes/gpgpu/AtomicFunctionNode.js +99 -0
- package/src/nodes/gpgpu/BarrierNode.js +40 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +98 -0
- package/src/nodes/gpgpu/ComputeNode.js +10 -6
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +100 -0
- package/src/nodes/lighting/AONode.js +6 -3
- package/src/nodes/lighting/AmbientLightNode.js +6 -8
- package/src/nodes/lighting/AnalyticLightNode.js +225 -36
- package/src/nodes/lighting/BasicEnvironmentNode.js +8 -4
- package/src/nodes/lighting/BasicLightMapNode.js +7 -4
- package/src/nodes/lighting/DirectionalLightNode.js +7 -9
- package/src/nodes/lighting/EnvironmentNode.js +23 -19
- package/src/nodes/lighting/HemisphereLightNode.js +11 -11
- package/src/nodes/lighting/IESSpotLightNode.js +7 -9
- package/src/nodes/lighting/IrradianceNode.js +6 -3
- package/src/nodes/lighting/LightProbeNode.js +53 -0
- package/src/nodes/lighting/LightUtils.js +3 -3
- package/src/nodes/lighting/LightingContextNode.js +19 -18
- package/src/nodes/lighting/LightingNode.js +7 -3
- package/src/nodes/lighting/LightsNode.js +112 -75
- package/src/nodes/lighting/PointLightNode.js +12 -13
- package/src/nodes/lighting/RectAreaLightNode.js +11 -11
- package/src/nodes/lighting/SpotLightNode.js +14 -16
- package/src/nodes/materialx/MaterialXNodes.js +2 -2
- package/src/nodes/materialx/lib/mx_hsv.js +36 -31
- package/src/nodes/materialx/lib/mx_noise.js +96 -96
- package/src/nodes/materialx/lib/mx_transform_color.js +2 -2
- package/src/nodes/math/{CondNode.js → ConditionalNode.js} +38 -10
- package/src/nodes/math/Hash.js +13 -0
- package/src/nodes/math/MathNode.js +127 -124
- package/src/nodes/math/MathUtils.js +0 -7
- package/src/nodes/math/OperatorNode.js +97 -52
- package/src/nodes/math/TriNoise3D.js +19 -29
- package/src/nodes/pmrem/PMREMNode.js +61 -15
- package/src/nodes/pmrem/PMREMUtils.js +46 -46
- package/src/nodes/procedural/Checker.js +14 -0
- package/src/nodes/tsl/TSLBase.js +30 -0
- package/src/nodes/{shadernode/ShaderNode.js → tsl/TSLCore.js} +105 -97
- package/src/nodes/utils/ArrayElementNode.js +8 -4
- package/src/nodes/utils/ConvertNode.js +7 -3
- package/src/nodes/utils/CubeMapNode.js +160 -0
- package/src/nodes/utils/Discard.js +8 -0
- package/src/nodes/utils/EquirectUVNode.js +9 -6
- package/src/nodes/utils/FlipNode.js +68 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +9 -5
- package/src/nodes/utils/JoinNode.js +6 -3
- package/src/nodes/utils/LoopNode.js +16 -6
- package/src/nodes/utils/MatcapUVNode.js +10 -7
- package/src/nodes/utils/MaxMipLevelNode.js +8 -5
- package/src/nodes/utils/OscNode.js +12 -8
- package/src/nodes/utils/Packing.js +4 -0
- package/src/nodes/utils/RTTNode.js +11 -8
- package/src/nodes/utils/ReflectorNode.js +12 -4
- package/src/nodes/utils/RemapNode.js +12 -8
- package/src/nodes/utils/RotateNode.js +8 -13
- package/src/nodes/utils/SetNode.js +7 -4
- package/src/nodes/utils/SplitNode.js +7 -3
- package/src/nodes/utils/SpriteSheetUVNode.js +10 -6
- package/src/nodes/utils/SpriteUtils.js +47 -0
- package/src/nodes/utils/StorageArrayElementNode.js +11 -12
- package/src/nodes/utils/TimerNode.js +8 -5
- package/src/nodes/utils/TriplanarTexturesNode.js +11 -9
- package/src/nodes/utils/UVUtils.js +19 -0
- package/src/nodes/utils/ViewportUtils.js +14 -0
- package/src/objects/BatchedMesh.js +78 -13
- package/src/objects/LOD.js +21 -0
- package/src/objects/Line.js +1 -0
- package/src/objects/Mesh.js +7 -23
- package/src/objects/Points.js +2 -0
- package/src/renderers/WebGLRenderer.js +88 -41
- package/src/renderers/common/Backend.js +2 -2
- package/src/renderers/common/Background.js +3 -1
- package/src/renderers/common/BindGroup.js +3 -1
- package/src/renderers/common/Bindings.js +13 -15
- package/src/renderers/common/BundleGroup.js +26 -0
- package/src/renderers/common/ClippingContext.js +15 -5
- package/src/renderers/common/CubeRenderTarget.js +9 -3
- package/src/renderers/common/PostProcessing.js +4 -1
- package/src/renderers/common/QuadMesh.js +2 -0
- package/src/renderers/common/RenderContext.js +23 -0
- package/src/renderers/common/RenderList.js +1 -1
- package/src/renderers/common/RenderObject.js +117 -6
- package/src/renderers/common/RenderObjects.js +8 -1
- package/src/renderers/common/Renderer.js +128 -94
- package/src/renderers/common/SampledTexture.js +12 -3
- package/src/renderers/common/Textures.js +8 -12
- package/src/renderers/common/extras/PMREMGenerator.js +19 -22
- package/src/renderers/common/nodes/NodeBuilderState.js +4 -4
- package/src/renderers/common/nodes/NodeLibrary.js +118 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +2 -2
- package/src/renderers/common/nodes/Nodes.js +65 -19
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +2 -4
- package/src/renderers/webgl/WebGLAttributes.js +45 -14
- package/src/renderers/webgl/WebGLCapabilities.js +9 -0
- package/src/renderers/webgl/WebGLProgram.js +3 -1
- package/src/renderers/webgl/WebGLPrograms.js +21 -17
- package/src/renderers/webgl/WebGLProperties.js +7 -0
- package/src/renderers/webgl/WebGLState.js +21 -0
- package/src/renderers/webgl/WebGLTextures.js +83 -4
- package/src/renderers/webgl-fallback/WebGLBackend.js +135 -110
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +60 -12
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +6 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +20 -2
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +89 -37
- package/src/renderers/webgpu/WebGPUBackend.js +112 -86
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +42 -0
- package/src/renderers/webgpu/WebGPURenderer.js +9 -6
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +59 -0
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +105 -0
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +189 -73
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +6 -16
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -21
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -1
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +7 -16
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +43 -26
- package/src/renderers/webgpu/utils/WebGPUUtils.js +19 -2
- package/src/renderers/webxr/WebXRManager.js +32 -25
- package/src/utils.js +33 -1
- package/examples/jsm/geometries/SDFGeometryGenerator.js +0 -144
- package/examples/jsm/loaders/LogLuvLoader.js +0 -606
- package/examples/jsm/loaders/TiltLoader.js +0 -520
- package/examples/jsm/utils/GPUStatsPanel.js +0 -95
- package/examples/jsm/utils/PackedPhongMaterial.js +0 -178
- package/src/nodes/accessors/CameraNode.js +0 -19
- package/src/nodes/accessors/NormalNode.js +0 -14
- package/src/nodes/accessors/PositionNode.js +0 -10
- package/src/nodes/accessors/ReflectVectorNode.js +0 -10
- package/src/nodes/accessors/TangentNode.js +0 -23
- package/src/nodes/core/NodeKeywords.js +0 -80
- package/src/nodes/display/BlendModeNode.js +0 -128
- package/src/nodes/display/ColorAdjustmentNode.js +0 -104
- package/src/nodes/display/ViewportNode.js +0 -137
- package/src/nodes/lighting/LightNode.js +0 -57
- package/src/nodes/materials/InstancedPointsNodeMaterial.js +0 -162
- package/src/nodes/math/HashNode.js +0 -34
- package/src/nodes/procedural/CheckerNode.js +0 -42
- package/src/nodes/utils/DiscardNode.js +0 -28
- package/src/nodes/utils/PackingNode.js +0 -55
- package/src/nodes/utils/RotateUVNode.js +0 -35
- /package/src/nodes/accessors/{UVNode.js → UV.js} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import TempNode from '../core/TempNode.js';
|
|
2
2
|
import { texture } from '../accessors/TextureNode.js';
|
|
3
3
|
import { textureSize } from '../accessors/TextureSizeNode.js';
|
|
4
|
-
import { uv } from '../accessors/
|
|
5
|
-
import {
|
|
4
|
+
import { uv } from '../accessors/UV.js';
|
|
5
|
+
import { nodeObject, Fn, mat3, vec2, vec3, vec4, float, int, If } from '../tsl/TSLBase.js';
|
|
6
6
|
import { NodeUpdateType } from '../core/constants.js';
|
|
7
7
|
import { uniform } from '../core/UniformNode.js';
|
|
8
8
|
import { DataTexture } from '../../textures/DataTexture.js';
|
|
@@ -10,10 +10,12 @@ import { Vector2 } from '../../math/Vector2.js';
|
|
|
10
10
|
import { Vector3 } from '../../math/Vector3.js';
|
|
11
11
|
import { PI, cos, sin, pow, clamp, abs, max, mix, sqrt, acos, dot, normalize, cross } from '../math/MathNode.js';
|
|
12
12
|
import { div, mul, add, sub } from '../math/OperatorNode.js';
|
|
13
|
-
import {
|
|
13
|
+
import { Loop } from '../utils/LoopNode.js';
|
|
14
14
|
import { passTexture } from './PassNode.js';
|
|
15
15
|
import { RepeatWrapping } from '../../constants.js';
|
|
16
16
|
import QuadMesh from '../../renderers/common/QuadMesh.js';
|
|
17
|
+
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
|
18
|
+
|
|
17
19
|
import { RenderTarget } from '../../core/RenderTarget.js';
|
|
18
20
|
import { Color } from '../../math/Color.js';
|
|
19
21
|
|
|
@@ -23,6 +25,12 @@ const _size = /*@__PURE__*/ new Vector2();
|
|
|
23
25
|
|
|
24
26
|
class GTAONode extends TempNode {
|
|
25
27
|
|
|
28
|
+
static get type() {
|
|
29
|
+
|
|
30
|
+
return 'GTAONode';
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
26
34
|
constructor( depthNode, normalNode, camera ) {
|
|
27
35
|
|
|
28
36
|
super();
|
|
@@ -106,7 +114,7 @@ class GTAONode extends TempNode {
|
|
|
106
114
|
const sampleDepth = ( uv ) => this.depthNode.uv( uv ).x;
|
|
107
115
|
const sampleNoise = ( uv ) => this.noiseNode.uv( uv );
|
|
108
116
|
|
|
109
|
-
const getSceneUvAndDepth =
|
|
117
|
+
const getSceneUvAndDepth = Fn( ( [ sampleViewPos ] )=> {
|
|
110
118
|
|
|
111
119
|
const sampleClipPos = this.cameraProjectionMatrix.mul( vec4( sampleViewPos, 1.0 ) );
|
|
112
120
|
let sampleUv = sampleClipPos.xy.div( sampleClipPos.w ).mul( 0.5 ).add( 0.5 ).toVar();
|
|
@@ -116,7 +124,7 @@ class GTAONode extends TempNode {
|
|
|
116
124
|
|
|
117
125
|
} );
|
|
118
126
|
|
|
119
|
-
const getViewPosition =
|
|
127
|
+
const getViewPosition = Fn( ( [ screenPosition, depth ] ) => {
|
|
120
128
|
|
|
121
129
|
screenPosition = vec2( screenPosition.x, screenPosition.y.oneMinus() ).mul( 2.0 ).sub( 1.0 );
|
|
122
130
|
|
|
@@ -127,7 +135,7 @@ class GTAONode extends TempNode {
|
|
|
127
135
|
|
|
128
136
|
} );
|
|
129
137
|
|
|
130
|
-
const ao =
|
|
138
|
+
const ao = Fn( () => {
|
|
131
139
|
|
|
132
140
|
const depth = sampleDepth( uvNode );
|
|
133
141
|
|
|
@@ -147,12 +155,12 @@ class GTAONode extends TempNode {
|
|
|
147
155
|
const bitangent = vec3( tangent.y.mul( - 1.0 ), tangent.x, 0.0 );
|
|
148
156
|
const kernelMatrix = mat3( tangent, bitangent, vec3( 0.0, 0.0, 1.0 ) );
|
|
149
157
|
|
|
150
|
-
const DIRECTIONS = this.SAMPLES.lessThan( 30 ).
|
|
158
|
+
const DIRECTIONS = this.SAMPLES.lessThan( 30 ).select( 3, 5 );
|
|
151
159
|
const STEPS = add( this.SAMPLES, DIRECTIONS.sub( 1 ) ).div( DIRECTIONS );
|
|
152
160
|
|
|
153
161
|
const ao = float( 0 ).toVar();
|
|
154
162
|
|
|
155
|
-
|
|
163
|
+
Loop( { start: int( 0 ), end: DIRECTIONS, type: 'int', condition: '<' }, ( { i } ) => {
|
|
156
164
|
|
|
157
165
|
const angle = float( i ).div( float( DIRECTIONS ) ).mul( PI );
|
|
158
166
|
const sampleDir = vec4( cos( angle ), sin( angle ), 0., add( 0.5, mul( 0.5, noiseTexel.w ) ) );
|
|
@@ -166,7 +174,7 @@ class GTAONode extends TempNode {
|
|
|
166
174
|
const tangentToNormalInSlice = cross( normalInSlice, sliceBitangent );
|
|
167
175
|
const cosHorizons = vec2( dot( viewDir, tangentToNormalInSlice ), dot( viewDir, tangentToNormalInSlice.negate() ) ).toVar();
|
|
168
176
|
|
|
169
|
-
|
|
177
|
+
Loop( { end: STEPS, type: 'int', name: 'j', condition: '<' }, ( { j } ) => {
|
|
170
178
|
|
|
171
179
|
const sampleViewOffset = sampleDir.xyz.mul( radiusToUse ).mul( sampleDir.w ).mul( pow( div( float( j ).add( 1.0 ), float( STEPS ) ), this.distanceExponent ) );
|
|
172
180
|
|
|
@@ -206,7 +214,7 @@ class GTAONode extends TempNode {
|
|
|
206
214
|
const occlusion = nx.mul( nxb ).add( ny.mul( nyb ) );
|
|
207
215
|
ao.addAssign( occlusion );
|
|
208
216
|
|
|
209
|
-
}
|
|
217
|
+
} );
|
|
210
218
|
|
|
211
219
|
ao.assign( clamp( ao.div( DIRECTIONS ), 0, 1 ) );
|
|
212
220
|
ao.assign( pow( ao, this.scale ) );
|
|
@@ -215,8 +223,9 @@ class GTAONode extends TempNode {
|
|
|
215
223
|
|
|
216
224
|
} );
|
|
217
225
|
|
|
218
|
-
const material = this._material || ( this._material =
|
|
226
|
+
const material = this._material || ( this._material = new NodeMaterial() );
|
|
219
227
|
material.fragmentNode = ao().context( builder.getSharedContext() );
|
|
228
|
+
material.name = 'GTAO';
|
|
220
229
|
material.needsUpdate = true;
|
|
221
230
|
|
|
222
231
|
//
|
|
@@ -233,6 +242,8 @@ class GTAONode extends TempNode {
|
|
|
233
242
|
|
|
234
243
|
}
|
|
235
244
|
|
|
245
|
+
export default GTAONode;
|
|
246
|
+
|
|
236
247
|
function generateMagicSquareNoise( size = 5 ) {
|
|
237
248
|
|
|
238
249
|
const noiseSize = Math.floor( size ) % 2 === 0 ? Math.floor( size ) + 1 : Math.floor( size );
|
|
@@ -318,7 +329,3 @@ function generateMagicSquare( size ) {
|
|
|
318
329
|
}
|
|
319
330
|
|
|
320
331
|
export const ao = ( depthNode, normalNode, camera ) => nodeObject( new GTAONode( nodeObject( depthNode ), nodeObject( normalNode ), camera ) );
|
|
321
|
-
|
|
322
|
-
addNodeElement( 'ao', ao );
|
|
323
|
-
|
|
324
|
-
export default GTAONode;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import TempNode from '../core/TempNode.js';
|
|
2
|
-
import { nodeObject,
|
|
2
|
+
import { nodeObject, Fn, float, vec2, vec4 } from '../tsl/TSLBase.js';
|
|
3
3
|
import { NodeUpdateType } from '../core/constants.js';
|
|
4
4
|
import { mul } from '../math/OperatorNode.js';
|
|
5
|
-
import { uv } from '../accessors/
|
|
5
|
+
import { uv } from '../accessors/UV.js';
|
|
6
6
|
import { passTexture } from './PassNode.js';
|
|
7
7
|
import { uniform } from '../core/UniformNode.js';
|
|
8
|
+
import { convertToTexture } from '../utils/RTTNode.js';
|
|
8
9
|
import QuadMesh from '../../renderers/common/QuadMesh.js';
|
|
9
10
|
|
|
10
11
|
import { Vector2 } from '../../math/Vector2.js';
|
|
11
12
|
import { RenderTarget } from '../../core/RenderTarget.js';
|
|
13
|
+
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
|
12
14
|
|
|
13
15
|
// WebGPU: The use of a single QuadMesh for both gaussian blur passes results in a single RenderObject with a SampledTexture binding that
|
|
14
16
|
// alternates between source textures and triggers creation of new BindGroups and BindGroupLayouts every frame.
|
|
@@ -18,6 +20,12 @@ const _quadMesh2 = /*@__PURE__*/ new QuadMesh();
|
|
|
18
20
|
|
|
19
21
|
class GaussianBlurNode extends TempNode {
|
|
20
22
|
|
|
23
|
+
static get type() {
|
|
24
|
+
|
|
25
|
+
return 'GaussianBlurNode';
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
21
29
|
constructor( textureNode, directionNode = null, sigma = 2 ) {
|
|
22
30
|
|
|
23
31
|
super( 'vec4' );
|
|
@@ -129,7 +137,7 @@ class GaussianBlurNode extends TempNode {
|
|
|
129
137
|
|
|
130
138
|
const sampleTexture = ( uv ) => textureNode.uv( uv );
|
|
131
139
|
|
|
132
|
-
const blur =
|
|
140
|
+
const blur = Fn( () => {
|
|
133
141
|
|
|
134
142
|
const kernelSize = 3 + ( 2 * this.sigma );
|
|
135
143
|
const gaussianCoefficients = this._getCoefficients( kernelSize );
|
|
@@ -161,8 +169,9 @@ class GaussianBlurNode extends TempNode {
|
|
|
161
169
|
|
|
162
170
|
//
|
|
163
171
|
|
|
164
|
-
const material = this._material || ( this._material =
|
|
172
|
+
const material = this._material || ( this._material = new NodeMaterial() );
|
|
165
173
|
material.fragmentNode = blur().context( builder.getSharedContext() );
|
|
174
|
+
material.name = 'Gaussian_blur';
|
|
166
175
|
material.needsUpdate = true;
|
|
167
176
|
|
|
168
177
|
//
|
|
@@ -199,9 +208,6 @@ class GaussianBlurNode extends TempNode {
|
|
|
199
208
|
|
|
200
209
|
}
|
|
201
210
|
|
|
202
|
-
export const gaussianBlur = ( node, directionNode, sigma ) => nodeObject( new GaussianBlurNode( nodeObject( node ).toTexture(), directionNode, sigma ) );
|
|
203
|
-
|
|
204
|
-
addNodeElement( 'gaussianBlur', gaussianBlur );
|
|
205
|
-
|
|
206
211
|
export default GaussianBlurNode;
|
|
207
212
|
|
|
213
|
+
export const gaussianBlur = ( node, directionNode, sigma ) => nodeObject( new GaussianBlurNode( convertToTexture( node ), directionNode, sigma ) );
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import TempNode from '../core/TempNode.js';
|
|
2
|
-
import {
|
|
2
|
+
import { Fn, nodeObject, vec3, vec4, float } from '../tsl/TSLBase.js';
|
|
3
3
|
import { uniform } from '../core/UniformNode.js';
|
|
4
4
|
import { mix } from '../math/MathNode.js';
|
|
5
5
|
|
|
6
6
|
class Lut3DNode extends TempNode {
|
|
7
7
|
|
|
8
|
+
static get type() {
|
|
9
|
+
|
|
10
|
+
return 'Lut3DNode';
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
|
|
8
14
|
constructor( inputNode, lutNode, size, intensityNode ) {
|
|
9
15
|
|
|
10
16
|
super();
|
|
@@ -22,7 +28,7 @@ class Lut3DNode extends TempNode {
|
|
|
22
28
|
|
|
23
29
|
const sampleLut = ( uv ) => lutNode.uv( uv );
|
|
24
30
|
|
|
25
|
-
const lut3D =
|
|
31
|
+
const lut3D = Fn( () => {
|
|
26
32
|
|
|
27
33
|
const base = inputNode;
|
|
28
34
|
|
|
@@ -46,8 +52,6 @@ class Lut3DNode extends TempNode {
|
|
|
46
52
|
|
|
47
53
|
}
|
|
48
54
|
|
|
49
|
-
export const lut3D = ( node, lut, size, intensity ) => nodeObject( new Lut3DNode( nodeObject( node ), nodeObject( lut ), size, nodeObject( intensity ) ) );
|
|
50
|
-
|
|
51
|
-
addNodeElement( 'lut3D', lut3D );
|
|
52
|
-
|
|
53
55
|
export default Lut3DNode;
|
|
56
|
+
|
|
57
|
+
export const lut3D = ( node, lut, size, intensity ) => nodeObject( new Lut3DNode( nodeObject( node ), nodeObject( lut ), size, nodeObject( intensity ) ) );
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { float, int, Fn } from '../tsl/TSLBase.js';
|
|
2
|
+
import { Loop } from '../utils/LoopNode.js';
|
|
3
|
+
import { uv } from '../accessors/UV.js';
|
|
4
|
+
|
|
5
|
+
export const motionBlur = /*@__PURE__*/ Fn( ( [ inputNode, velocity, numSamples = int( 16 ) ] ) => {
|
|
6
|
+
|
|
7
|
+
const sampleColor = ( uv ) => inputNode.uv( uv );
|
|
8
|
+
|
|
9
|
+
const uvs = uv();
|
|
10
|
+
|
|
11
|
+
const colorResult = sampleColor( uvs ).toVar();
|
|
12
|
+
const fSamples = float( numSamples );
|
|
13
|
+
|
|
14
|
+
Loop( { start: int( 1 ), end: numSamples, type: 'int', condition: '<=' }, ( { i } ) => {
|
|
15
|
+
|
|
16
|
+
const offset = velocity.mul( float( i ).div( fSamples.sub( 1 ) ).sub( 0.5 ) );
|
|
17
|
+
colorResult.addAssign( sampleColor( uvs.add( offset ) ) );
|
|
18
|
+
|
|
19
|
+
} );
|
|
20
|
+
|
|
21
|
+
colorResult.divAssign( fSamples );
|
|
22
|
+
|
|
23
|
+
return colorResult;
|
|
24
|
+
|
|
25
|
+
} );
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import TempNode from '../core/TempNode.js';
|
|
2
2
|
import { add } from '../math/OperatorNode.js';
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { positionView } from '../accessors/PositionNode.js';
|
|
4
|
+
import { normalView, transformNormalToView } from '../accessors/Normal.js';
|
|
5
|
+
import { positionView } from '../accessors/Position.js';
|
|
7
6
|
import { TBNViewMatrix } from '../accessors/AccessorsUtils.js';
|
|
8
|
-
import { uv } from '../accessors/
|
|
7
|
+
import { uv } from '../accessors/UV.js';
|
|
9
8
|
import { faceDirection } from './FrontFacingNode.js';
|
|
10
|
-
import {
|
|
11
|
-
import { addNodeElement, tslFn, nodeProxy, vec3 } from '../shadernode/ShaderNode.js';
|
|
9
|
+
import { Fn, nodeProxy, vec3 } from '../tsl/TSLBase.js';
|
|
12
10
|
|
|
13
11
|
import { TangentSpaceNormalMap, ObjectSpaceNormalMap } from '../../constants.js';
|
|
14
12
|
|
|
15
13
|
// Normal Mapping Without Precomputed Tangents
|
|
16
14
|
// http://www.thetenthplanet.de/archives/1180
|
|
17
15
|
|
|
18
|
-
const perturbNormal2Arb =
|
|
16
|
+
const perturbNormal2Arb = /*@__PURE__*/ Fn( ( inputs ) => {
|
|
19
17
|
|
|
20
18
|
const { eye_pos, surf_norm, mapN, uv } = inputs;
|
|
21
19
|
|
|
@@ -41,6 +39,12 @@ const perturbNormal2Arb = tslFn( ( inputs ) => {
|
|
|
41
39
|
|
|
42
40
|
class NormalMapNode extends TempNode {
|
|
43
41
|
|
|
42
|
+
static get type() {
|
|
43
|
+
|
|
44
|
+
return 'NormalMapNode';
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
|
|
44
48
|
constructor( node, scaleNode = null ) {
|
|
45
49
|
|
|
46
50
|
super( 'vec3' );
|
|
@@ -68,7 +72,7 @@ class NormalMapNode extends TempNode {
|
|
|
68
72
|
|
|
69
73
|
if ( normalMapType === ObjectSpaceNormalMap ) {
|
|
70
74
|
|
|
71
|
-
outputNode =
|
|
75
|
+
outputNode = transformNormalToView( normalMap );
|
|
72
76
|
|
|
73
77
|
} else if ( normalMapType === TangentSpaceNormalMap ) {
|
|
74
78
|
|
|
@@ -99,8 +103,4 @@ class NormalMapNode extends TempNode {
|
|
|
99
103
|
|
|
100
104
|
export default NormalMapNode;
|
|
101
105
|
|
|
102
|
-
export const normalMap = nodeProxy( NormalMapNode );
|
|
103
|
-
|
|
104
|
-
addNodeElement( 'normalMap', normalMap );
|
|
105
|
-
|
|
106
|
-
addNodeClass( 'NormalMapNode', NormalMapNode );
|
|
106
|
+
export const normalMap = /*@__PURE__*/ nodeProxy( NormalMapNode );
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Fn, If, nodeObject, vec4 } from '../tsl/TSLBase.js';
|
|
2
|
+
import { uv } from '../accessors/UV.js';
|
|
3
|
+
import { mod } from '../math/MathNode.js';
|
|
4
|
+
import { screenCoordinate } from './ScreenNode.js';
|
|
5
|
+
import StereoCompositePassNode from './StereoCompositePassNode.js';
|
|
6
|
+
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
|
7
|
+
|
|
8
|
+
class ParallaxBarrierPassNode extends StereoCompositePassNode {
|
|
9
|
+
|
|
10
|
+
static get type() {
|
|
11
|
+
|
|
12
|
+
return 'ParallaxBarrierPassNode';
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
constructor( scene, camera ) {
|
|
17
|
+
|
|
18
|
+
super( scene, camera );
|
|
19
|
+
|
|
20
|
+
this.isParallaxBarrierPassNode = true;
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
setup( builder ) {
|
|
25
|
+
|
|
26
|
+
const uvNode = uv();
|
|
27
|
+
|
|
28
|
+
const parallaxBarrier = Fn( () => {
|
|
29
|
+
|
|
30
|
+
const color = vec4().toVar();
|
|
31
|
+
|
|
32
|
+
If( mod( screenCoordinate.y, 2 ).greaterThan( 1 ), () => {
|
|
33
|
+
|
|
34
|
+
color.assign( this._mapLeft.uv( uvNode ) );
|
|
35
|
+
|
|
36
|
+
} ).Else( () => {
|
|
37
|
+
|
|
38
|
+
color.assign( this._mapRight.uv( uvNode ) );
|
|
39
|
+
|
|
40
|
+
} );
|
|
41
|
+
|
|
42
|
+
return color;
|
|
43
|
+
|
|
44
|
+
} );
|
|
45
|
+
|
|
46
|
+
const material = this._material || ( this._material = new NodeMaterial() );
|
|
47
|
+
material.fragmentNode = parallaxBarrier().context( builder.getSharedContext() );
|
|
48
|
+
material.needsUpdate = true;
|
|
49
|
+
|
|
50
|
+
return super.setup( builder );
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export default ParallaxBarrierPassNode;
|
|
57
|
+
|
|
58
|
+
export const parallaxBarrierPass = ( scene, camera ) => nodeObject( new ParallaxBarrierPassNode( scene, camera ) );
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { addNodeClass } from '../core/Node.js';
|
|
2
1
|
import TempNode from '../core/TempNode.js';
|
|
3
2
|
import { default as TextureNode/*, texture*/ } from '../accessors/TextureNode.js';
|
|
4
3
|
import { NodeUpdateType } from '../core/constants.js';
|
|
5
|
-
import { nodeObject } from '../
|
|
4
|
+
import { nodeObject } from '../tsl/TSLBase.js';
|
|
6
5
|
import { uniform } from '../core/UniformNode.js';
|
|
7
6
|
import { viewZToOrthographicDepth, perspectiveDepthToViewZ } from './ViewportDepthNode.js';
|
|
8
7
|
|
|
@@ -15,6 +14,12 @@ const _size = /*@__PURE__*/ new Vector2();
|
|
|
15
14
|
|
|
16
15
|
class PassTextureNode extends TextureNode {
|
|
17
16
|
|
|
17
|
+
static get type() {
|
|
18
|
+
|
|
19
|
+
return 'PassTextureNode';
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
18
23
|
constructor( passNode, texture ) {
|
|
19
24
|
|
|
20
25
|
super( texture );
|
|
@@ -27,7 +32,7 @@ class PassTextureNode extends TextureNode {
|
|
|
27
32
|
|
|
28
33
|
setup( builder ) {
|
|
29
34
|
|
|
30
|
-
this.passNode.build( builder );
|
|
35
|
+
if ( builder.object.isQuadMesh ) this.passNode.build( builder );
|
|
31
36
|
|
|
32
37
|
return super.setup( builder );
|
|
33
38
|
|
|
@@ -43,17 +48,30 @@ class PassTextureNode extends TextureNode {
|
|
|
43
48
|
|
|
44
49
|
class PassMultipleTextureNode extends PassTextureNode {
|
|
45
50
|
|
|
46
|
-
|
|
51
|
+
static get type() {
|
|
52
|
+
|
|
53
|
+
return 'PassMultipleTextureNode';
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
constructor( passNode, textureName, previousTexture = false ) {
|
|
47
58
|
|
|
48
59
|
super( passNode, null );
|
|
49
60
|
|
|
50
61
|
this.textureName = textureName;
|
|
62
|
+
this.previousTexture = previousTexture;
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
updateTexture() {
|
|
67
|
+
|
|
68
|
+
this.value = this.previousTexture ? this.passNode.getPreviousTexture( this.textureName ) : this.passNode.getTexture( this.textureName );
|
|
51
69
|
|
|
52
70
|
}
|
|
53
71
|
|
|
54
72
|
setup( builder ) {
|
|
55
73
|
|
|
56
|
-
this.
|
|
74
|
+
this.updateTexture();
|
|
57
75
|
|
|
58
76
|
return super.setup( builder );
|
|
59
77
|
|
|
@@ -61,7 +79,7 @@ class PassMultipleTextureNode extends PassTextureNode {
|
|
|
61
79
|
|
|
62
80
|
clone() {
|
|
63
81
|
|
|
64
|
-
return new this.constructor( this.passNode, this.textureName );
|
|
82
|
+
return new this.constructor( this.passNode, this.textureName, this.previousTexture );
|
|
65
83
|
|
|
66
84
|
}
|
|
67
85
|
|
|
@@ -69,6 +87,12 @@ class PassMultipleTextureNode extends PassTextureNode {
|
|
|
69
87
|
|
|
70
88
|
class PassNode extends TempNode {
|
|
71
89
|
|
|
90
|
+
static get type() {
|
|
91
|
+
|
|
92
|
+
return 'PassNode';
|
|
93
|
+
|
|
94
|
+
}
|
|
95
|
+
|
|
72
96
|
constructor( scope, scene, camera, options = {} ) {
|
|
73
97
|
|
|
74
98
|
super( 'vec4' );
|
|
@@ -104,6 +128,9 @@ class PassNode extends TempNode {
|
|
|
104
128
|
this._linearDepthNodes = {};
|
|
105
129
|
this._viewZNodes = {};
|
|
106
130
|
|
|
131
|
+
this._previousTextures = {};
|
|
132
|
+
this._previousTextureNodes = {};
|
|
133
|
+
|
|
107
134
|
this._cameraNear = uniform( 0 );
|
|
108
135
|
this._cameraFar = uniform( 0 );
|
|
109
136
|
|
|
@@ -155,6 +182,44 @@ class PassNode extends TempNode {
|
|
|
155
182
|
|
|
156
183
|
}
|
|
157
184
|
|
|
185
|
+
getPreviousTexture( name ) {
|
|
186
|
+
|
|
187
|
+
let texture = this._previousTextures[ name ];
|
|
188
|
+
|
|
189
|
+
if ( texture === undefined ) {
|
|
190
|
+
|
|
191
|
+
texture = this.getTexture( name ).clone();
|
|
192
|
+
texture.isRenderTargetTexture = true;
|
|
193
|
+
|
|
194
|
+
this._previousTextures[ name ] = texture;
|
|
195
|
+
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return texture;
|
|
199
|
+
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
toggleTexture( name ) {
|
|
203
|
+
|
|
204
|
+
const prevTexture = this._previousTextures[ name ];
|
|
205
|
+
|
|
206
|
+
if ( prevTexture !== undefined ) {
|
|
207
|
+
|
|
208
|
+
const texture = this._textures[ name ];
|
|
209
|
+
|
|
210
|
+
const index = this.renderTarget.textures.indexOf( texture );
|
|
211
|
+
this.renderTarget.textures[ index ] = prevTexture;
|
|
212
|
+
|
|
213
|
+
this._textures[ name ] = prevTexture;
|
|
214
|
+
this._previousTextures[ name ] = texture;
|
|
215
|
+
|
|
216
|
+
this._textureNodes[ name ].updateTexture();
|
|
217
|
+
this._previousTextureNodes[ name ].updateTexture();
|
|
218
|
+
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
}
|
|
222
|
+
|
|
158
223
|
getTextureNode( name = 'output' ) {
|
|
159
224
|
|
|
160
225
|
let textureNode = this._textureNodes[ name ];
|
|
@@ -162,6 +227,24 @@ class PassNode extends TempNode {
|
|
|
162
227
|
if ( textureNode === undefined ) {
|
|
163
228
|
|
|
164
229
|
this._textureNodes[ name ] = textureNode = nodeObject( new PassMultipleTextureNode( this, name ) );
|
|
230
|
+
this._textureNodes[ name ].updateTexture();
|
|
231
|
+
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return textureNode;
|
|
235
|
+
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
getPreviousTextureNode( name = 'output' ) {
|
|
239
|
+
|
|
240
|
+
let textureNode = this._previousTextureNodes[ name ];
|
|
241
|
+
|
|
242
|
+
if ( textureNode === undefined ) {
|
|
243
|
+
|
|
244
|
+
if ( this._textureNodes[ name ] === undefined ) this.getTextureNode( name );
|
|
245
|
+
|
|
246
|
+
this._previousTextureNodes[ name ] = textureNode = nodeObject( new PassMultipleTextureNode( this, name, true ) );
|
|
247
|
+
this._previousTextureNodes[ name ].updateTexture();
|
|
165
248
|
|
|
166
249
|
}
|
|
167
250
|
|
|
@@ -240,6 +323,12 @@ class PassNode extends TempNode {
|
|
|
240
323
|
this._cameraNear.value = camera.near;
|
|
241
324
|
this._cameraFar.value = camera.far;
|
|
242
325
|
|
|
326
|
+
for ( const name in this._previousTextures ) {
|
|
327
|
+
|
|
328
|
+
this.toggleTexture( name );
|
|
329
|
+
|
|
330
|
+
}
|
|
331
|
+
|
|
243
332
|
renderer.setRenderTarget( this.renderTarget );
|
|
244
333
|
renderer.setMRT( this._mrt );
|
|
245
334
|
|
|
@@ -287,5 +376,3 @@ export default PassNode;
|
|
|
287
376
|
export const pass = ( scene, camera, options ) => nodeObject( new PassNode( PassNode.COLOR, scene, camera, options ) );
|
|
288
377
|
export const passTexture = ( pass, texture ) => nodeObject( new PassTextureNode( pass, texture ) );
|
|
289
378
|
export const depthPass = ( scene, camera ) => nodeObject( new PassNode( PassNode.DEPTH, scene, camera ) );
|
|
290
|
-
|
|
291
|
-
addNodeClass( 'PassNode', PassNode );
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import TempNode from '../core/TempNode.js';
|
|
2
|
-
import { uv } from '../accessors/
|
|
3
|
-
import {
|
|
2
|
+
import { uv } from '../accessors/UV.js';
|
|
3
|
+
import { Fn, nodeObject, vec2, vec3, float, If } from '../tsl/TSLBase.js';
|
|
4
4
|
import { NodeUpdateType } from '../core/constants.js';
|
|
5
5
|
import { uniform } from '../core/UniformNode.js';
|
|
6
6
|
import { dot, clamp, smoothstep, sign, step, floor } from '../math/MathNode.js';
|
|
@@ -8,11 +8,19 @@ import { Vector4 } from '../../math/Vector4.js';
|
|
|
8
8
|
import { output, property } from '../core/PropertyNode.js';
|
|
9
9
|
import PassNode from './PassNode.js';
|
|
10
10
|
import { mrt } from '../core/MRTNode.js';
|
|
11
|
-
import { normalView } from '../accessors/
|
|
11
|
+
import { normalView } from '../accessors/Normal.js';
|
|
12
|
+
import { convertToTexture } from '../utils/RTTNode.js';
|
|
13
|
+
|
|
12
14
|
import { NearestFilter } from '../../constants.js';
|
|
13
15
|
|
|
14
16
|
class PixelationNode extends TempNode {
|
|
15
17
|
|
|
18
|
+
static get type() {
|
|
19
|
+
|
|
20
|
+
return 'PixelationNode';
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
16
24
|
constructor( textureNode, depthNode, normalNode, pixelSize, normalEdgeStrength, depthEdgeStrength ) {
|
|
17
25
|
|
|
18
26
|
super();
|
|
@@ -106,7 +114,7 @@ class PixelationNode extends TempNode {
|
|
|
106
114
|
|
|
107
115
|
};
|
|
108
116
|
|
|
109
|
-
const pixelation =
|
|
117
|
+
const pixelation = Fn( () => {
|
|
110
118
|
|
|
111
119
|
const texel = sampleTexture();
|
|
112
120
|
|
|
@@ -136,7 +144,7 @@ class PixelationNode extends TempNode {
|
|
|
136
144
|
|
|
137
145
|
} );
|
|
138
146
|
|
|
139
|
-
const strength = dei.greaterThan( 0 ).
|
|
147
|
+
const strength = dei.greaterThan( 0 ).select( float( 1.0 ).sub( dei.mul( this.depthEdgeStrength ) ), nei.mul( this.normalEdgeStrength ).add( 1 ) );
|
|
140
148
|
|
|
141
149
|
return texel.mul( strength );
|
|
142
150
|
|
|
@@ -150,12 +158,16 @@ class PixelationNode extends TempNode {
|
|
|
150
158
|
|
|
151
159
|
}
|
|
152
160
|
|
|
153
|
-
const pixelation = ( node, depthNode, normalNode, pixelSize = 6, normalEdgeStrength = 0.3, depthEdgeStrength = 0.4 ) => nodeObject( new PixelationNode(
|
|
154
|
-
|
|
155
|
-
addNodeElement( 'pixelation', pixelation );
|
|
161
|
+
const pixelation = ( node, depthNode, normalNode, pixelSize = 6, normalEdgeStrength = 0.3, depthEdgeStrength = 0.4 ) => nodeObject( new PixelationNode( convertToTexture( node ), convertToTexture( depthNode ), convertToTexture( normalNode ), nodeObject( pixelSize ), nodeObject( normalEdgeStrength ), nodeObject( depthEdgeStrength ) ) );
|
|
156
162
|
|
|
157
163
|
class PixelationPassNode extends PassNode {
|
|
158
164
|
|
|
165
|
+
static get type() {
|
|
166
|
+
|
|
167
|
+
return 'PixelationPassNode';
|
|
168
|
+
|
|
169
|
+
}
|
|
170
|
+
|
|
159
171
|
constructor( scene, camera, pixelSize = 6, normalEdgeStrength = 0.3, depthEdgeStrength = 0.4 ) {
|
|
160
172
|
|
|
161
173
|
super( 'color', scene, camera, { minFilter: NearestFilter, magFilter: NearestFilter } );
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import TempNode from '../core/TempNode.js';
|
|
2
|
-
import {
|
|
3
|
-
import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js';
|
|
2
|
+
import { nodeProxy } from '../tsl/TSLBase.js';
|
|
4
3
|
|
|
5
4
|
class PosterizeNode extends TempNode {
|
|
6
5
|
|
|
6
|
+
static get type() {
|
|
7
|
+
|
|
8
|
+
return 'PosterizeNode';
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
7
12
|
constructor( sourceNode, stepsNode ) {
|
|
8
13
|
|
|
9
14
|
super();
|
|
@@ -25,8 +30,4 @@ class PosterizeNode extends TempNode {
|
|
|
25
30
|
|
|
26
31
|
export default PosterizeNode;
|
|
27
32
|
|
|
28
|
-
export const posterize = nodeProxy( PosterizeNode );
|
|
29
|
-
|
|
30
|
-
addNodeElement( 'posterize', posterize );
|
|
31
|
-
|
|
32
|
-
addNodeClass( 'PosterizeNode', PosterizeNode );
|
|
33
|
+
export const posterize = /*@__PURE__*/ nodeProxy( PosterizeNode );
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import TempNode from '../core/TempNode.js';
|
|
2
|
-
import { nodeObject,
|
|
2
|
+
import { nodeObject, Fn, vec2, vec4 } from '../tsl/TSLBase.js';
|
|
3
3
|
import { uniform } from '../core/UniformNode.js';
|
|
4
|
-
import { uv } from '../accessors/
|
|
4
|
+
import { uv } from '../accessors/UV.js';
|
|
5
5
|
import { sin, cos } from '../math/MathNode.js';
|
|
6
|
+
import { convertToTexture } from '../utils/RTTNode.js';
|
|
6
7
|
|
|
7
8
|
class RGBShiftNode extends TempNode {
|
|
8
9
|
|
|
10
|
+
static get type() {
|
|
11
|
+
|
|
12
|
+
return 'RGBShiftNode';
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
9
16
|
constructor( textureNode, amount = 0.005, angle = 0 ) {
|
|
10
17
|
|
|
11
18
|
super( 'vec4' );
|
|
@@ -24,7 +31,7 @@ class RGBShiftNode extends TempNode {
|
|
|
24
31
|
|
|
25
32
|
const sampleTexture = ( uv ) => textureNode.uv( uv );
|
|
26
33
|
|
|
27
|
-
const rgbShift =
|
|
34
|
+
const rgbShift = Fn( () => {
|
|
28
35
|
|
|
29
36
|
const offset = vec2( cos( this.angle ), sin( this.angle ) ).mul( this.amount );
|
|
30
37
|
const cr = sampleTexture( uvNode.add( offset ) );
|
|
@@ -41,9 +48,6 @@ class RGBShiftNode extends TempNode {
|
|
|
41
48
|
|
|
42
49
|
}
|
|
43
50
|
|
|
44
|
-
export const rgbShift = ( node, amount, angle ) => nodeObject( new RGBShiftNode( nodeObject( node ).toTexture(), amount, angle ) );
|
|
45
|
-
|
|
46
|
-
addNodeElement( 'rgbShift', rgbShift );
|
|
47
|
-
|
|
48
51
|
export default RGBShiftNode;
|
|
49
52
|
|
|
53
|
+
export const rgbShift = ( node, amount, angle ) => nodeObject( new RGBShiftNode( convertToTexture( node ), amount, angle ) );
|