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,10 +1,15 @@
|
|
|
1
1
|
import InputNode from './InputNode.js';
|
|
2
2
|
import { objectGroup } from './UniformGroupNode.js';
|
|
3
|
-
import {
|
|
4
|
-
import { nodeObject, getConstNodeType } from '../shadernode/ShaderNode.js';
|
|
3
|
+
import { nodeObject, getConstNodeType } from '../tsl/TSLCore.js';
|
|
5
4
|
|
|
6
5
|
class UniformNode extends InputNode {
|
|
7
6
|
|
|
7
|
+
static get type() {
|
|
8
|
+
|
|
9
|
+
return 'UniformNode';
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
|
|
8
13
|
constructor( value, nodeType = null ) {
|
|
9
14
|
|
|
10
15
|
super( value, nodeType );
|
|
@@ -105,5 +110,3 @@ export const uniform = ( arg1, arg2 ) => {
|
|
|
105
110
|
return nodeObject( new UniformNode( value, nodeType ) );
|
|
106
111
|
|
|
107
112
|
};
|
|
108
|
-
|
|
109
|
-
addNodeClass( 'UniformNode', UniformNode );
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import Node
|
|
2
|
-
import {
|
|
1
|
+
import Node from './Node.js';
|
|
2
|
+
import { addMethodChaining, nodeProxy } from '../tsl/TSLCore.js';
|
|
3
3
|
|
|
4
4
|
class VarNode extends Node {
|
|
5
5
|
|
|
6
|
+
static get type() {
|
|
7
|
+
|
|
8
|
+
return 'VarNode';
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
6
12
|
constructor( node, name = null ) {
|
|
7
13
|
|
|
8
14
|
super();
|
|
@@ -38,7 +44,7 @@ class VarNode extends Node {
|
|
|
38
44
|
|
|
39
45
|
const snippet = node.build( builder, nodeVar.type );
|
|
40
46
|
|
|
41
|
-
builder.addLineFlowCode( `${propertyName} = ${snippet}
|
|
47
|
+
builder.addLineFlowCode( `${propertyName} = ${snippet}`, this );
|
|
42
48
|
|
|
43
49
|
return propertyName;
|
|
44
50
|
|
|
@@ -48,9 +54,7 @@ class VarNode extends Node {
|
|
|
48
54
|
|
|
49
55
|
export default VarNode;
|
|
50
56
|
|
|
51
|
-
export const temp = nodeProxy( VarNode );
|
|
52
|
-
|
|
53
|
-
addNodeElement( 'temp', temp ); // @TODO: Will be removed in the future
|
|
54
|
-
addNodeElement( 'toVar', ( ...params ) => temp( ...params ).append() );
|
|
57
|
+
export const temp = /*@__PURE__*/ nodeProxy( VarNode );
|
|
55
58
|
|
|
56
|
-
|
|
59
|
+
addMethodChaining( 'temp', temp ); // @TODO: Will be removed in the future
|
|
60
|
+
addMethodChaining( 'toVar', ( ...params ) => temp( ...params ).append() );
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import Node
|
|
1
|
+
import Node from './Node.js';
|
|
2
2
|
import { NodeShaderStage } from './constants.js';
|
|
3
|
-
import {
|
|
3
|
+
import { addMethodChaining, nodeProxy } from '../tsl/TSLCore.js';
|
|
4
4
|
|
|
5
5
|
class VaryingNode extends Node {
|
|
6
6
|
|
|
7
|
+
static get type() {
|
|
8
|
+
|
|
9
|
+
return 'VaryingNode';
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
|
|
7
13
|
constructor( node, name = null ) {
|
|
8
14
|
|
|
9
15
|
super();
|
|
@@ -97,8 +103,6 @@ class VaryingNode extends Node {
|
|
|
97
103
|
|
|
98
104
|
export default VaryingNode;
|
|
99
105
|
|
|
100
|
-
export const varying = nodeProxy( VaryingNode );
|
|
101
|
-
|
|
102
|
-
addNodeElement( 'varying', varying );
|
|
106
|
+
export const varying = /*@__PURE__*/ nodeProxy( VaryingNode );
|
|
103
107
|
|
|
104
|
-
|
|
108
|
+
addMethodChaining( 'varying', varying );
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import TempNode from '../core/TempNode.js';
|
|
2
|
-
import { nodeObject,
|
|
2
|
+
import { nodeObject, Fn, float, vec4 } from '../tsl/TSLBase.js';
|
|
3
3
|
import { NodeUpdateType } from '../core/constants.js';
|
|
4
|
-
import { uv } from '../accessors/
|
|
4
|
+
import { uv } from '../accessors/UV.js';
|
|
5
5
|
import { texture } from '../accessors/TextureNode.js';
|
|
6
6
|
import { passTexture } from './PassNode.js';
|
|
7
7
|
import { uniform } from '../core/UniformNode.js';
|
|
8
8
|
import { sign, max } from '../math/MathNode.js';
|
|
9
|
+
import { convertToTexture } from '../utils/RTTNode.js';
|
|
9
10
|
import QuadMesh from '../../renderers/common/QuadMesh.js';
|
|
11
|
+
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
|
10
12
|
|
|
11
13
|
import { Vector2 } from '../../math/Vector2.js';
|
|
12
14
|
import { RenderTarget } from '../../core/RenderTarget.js';
|
|
@@ -17,6 +19,12 @@ const _quadMeshComp = /*@__PURE__*/ new QuadMesh();
|
|
|
17
19
|
|
|
18
20
|
class AfterImageNode extends TempNode {
|
|
19
21
|
|
|
22
|
+
static get type() {
|
|
23
|
+
|
|
24
|
+
return 'AfterImageNode';
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
20
28
|
constructor( textureNode, damp = 0.96 ) {
|
|
21
29
|
|
|
22
30
|
super( textureNode );
|
|
@@ -98,7 +106,7 @@ class AfterImageNode extends TempNode {
|
|
|
98
106
|
|
|
99
107
|
const sampleTexture = ( uv ) => textureNode.uv( uv );
|
|
100
108
|
|
|
101
|
-
const when_gt =
|
|
109
|
+
const when_gt = Fn( ( [ x_immutable, y_immutable ] ) => {
|
|
102
110
|
|
|
103
111
|
const y = float( y_immutable ).toVar();
|
|
104
112
|
const x = vec4( x_immutable ).toVar();
|
|
@@ -107,7 +115,7 @@ class AfterImageNode extends TempNode {
|
|
|
107
115
|
|
|
108
116
|
} );
|
|
109
117
|
|
|
110
|
-
const afterImg =
|
|
118
|
+
const afterImg = Fn( () => {
|
|
111
119
|
|
|
112
120
|
const texelOld = vec4( textureNodeOld );
|
|
113
121
|
const texelNew = vec4( sampleTexture( uvNode ) );
|
|
@@ -119,7 +127,8 @@ class AfterImageNode extends TempNode {
|
|
|
119
127
|
|
|
120
128
|
//
|
|
121
129
|
|
|
122
|
-
const materialComposed = this._materialComposed || ( this._materialComposed =
|
|
130
|
+
const materialComposed = this._materialComposed || ( this._materialComposed = new NodeMaterial() );
|
|
131
|
+
materialComposed.name = 'AfterImage';
|
|
123
132
|
materialComposed.fragmentNode = afterImg();
|
|
124
133
|
|
|
125
134
|
_quadMeshComp.material = materialComposed;
|
|
@@ -144,9 +153,6 @@ class AfterImageNode extends TempNode {
|
|
|
144
153
|
|
|
145
154
|
}
|
|
146
155
|
|
|
147
|
-
export const afterImage = ( node, damp ) => nodeObject( new AfterImageNode(
|
|
148
|
-
|
|
149
|
-
addNodeElement( 'afterImage', afterImage );
|
|
156
|
+
export const afterImage = ( node, damp ) => nodeObject( new AfterImageNode( convertToTexture( node ), damp ) );
|
|
150
157
|
|
|
151
158
|
export default AfterImageNode;
|
|
152
|
-
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Fn, nodeObject, vec4 } from '../tsl/TSLBase.js';
|
|
2
|
+
import { Matrix3 } from '../../math/Matrix3.js';
|
|
3
|
+
import { uniform } from '../core/UniformNode.js';
|
|
4
|
+
import { uv } from '../accessors/UV.js';
|
|
5
|
+
import { clamp, max } from '../math/MathNode.js';
|
|
6
|
+
import StereoCompositePassNode from './StereoCompositePassNode.js';
|
|
7
|
+
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
|
8
|
+
|
|
9
|
+
class AnaglyphPassNode extends StereoCompositePassNode {
|
|
10
|
+
|
|
11
|
+
static get type() {
|
|
12
|
+
|
|
13
|
+
return 'AnaglyphPassNode';
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
constructor( scene, camera ) {
|
|
18
|
+
|
|
19
|
+
super( scene, camera );
|
|
20
|
+
|
|
21
|
+
this.isAnaglyphPassNode = true;
|
|
22
|
+
|
|
23
|
+
// Dubois matrices from https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.7.6968&rep=rep1&type=pdf#page=4
|
|
24
|
+
|
|
25
|
+
this._colorMatrixLeft = uniform( new Matrix3().fromArray( [
|
|
26
|
+
0.456100, - 0.0400822, - 0.0152161,
|
|
27
|
+
0.500484, - 0.0378246, - 0.0205971,
|
|
28
|
+
0.176381, - 0.0157589, - 0.00546856
|
|
29
|
+
] ) );
|
|
30
|
+
|
|
31
|
+
this._colorMatrixRight = uniform( new Matrix3().fromArray( [
|
|
32
|
+
- 0.0434706, 0.378476, - 0.0721527,
|
|
33
|
+
- 0.0879388, 0.73364, - 0.112961,
|
|
34
|
+
- 0.00155529, - 0.0184503, 1.2264
|
|
35
|
+
] ) );
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
setup( builder ) {
|
|
40
|
+
|
|
41
|
+
const uvNode = uv();
|
|
42
|
+
|
|
43
|
+
const anaglyph = Fn( () => {
|
|
44
|
+
|
|
45
|
+
const colorL = this._mapLeft.uv( uvNode );
|
|
46
|
+
const colorR = this._mapRight.uv( uvNode );
|
|
47
|
+
|
|
48
|
+
const color = clamp( this._colorMatrixLeft.mul( colorL.rgb ).add( this._colorMatrixRight.mul( colorR.rgb ) ) );
|
|
49
|
+
|
|
50
|
+
return vec4( color.rgb, max( colorL.a, colorR.a ) );
|
|
51
|
+
|
|
52
|
+
} );
|
|
53
|
+
|
|
54
|
+
const material = this._material || ( this._material = new NodeMaterial() );
|
|
55
|
+
material.fragmentNode = anaglyph().context( builder.getSharedContext() );
|
|
56
|
+
material.name = 'Anaglyph';
|
|
57
|
+
material.needsUpdate = true;
|
|
58
|
+
|
|
59
|
+
return super.setup( builder );
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export default AnaglyphPassNode;
|
|
66
|
+
|
|
67
|
+
export const anaglyphPass = ( scene, camera ) => nodeObject( new AnaglyphPassNode( scene, camera ) );
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import TempNode from '../core/TempNode.js';
|
|
2
|
-
import { nodeObject,
|
|
3
|
-
import {
|
|
2
|
+
import { nodeObject, Fn, float, vec2, vec3 } from '../tsl/TSLBase.js';
|
|
3
|
+
import { Loop } from '../utils/LoopNode.js';
|
|
4
4
|
import { uniform } from '../core/UniformNode.js';
|
|
5
5
|
import { NodeUpdateType } from '../core/constants.js';
|
|
6
|
-
import { threshold } from './
|
|
7
|
-
import { uv } from '../accessors/
|
|
6
|
+
import { threshold } from './ColorAdjustment.js';
|
|
7
|
+
import { uv } from '../accessors/UV.js';
|
|
8
8
|
import { passTexture } from './PassNode.js';
|
|
9
|
+
import { convertToTexture } from '../utils/RTTNode.js';
|
|
9
10
|
import QuadMesh from '../../renderers/common/QuadMesh.js';
|
|
11
|
+
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
|
10
12
|
|
|
11
13
|
import { Vector2 } from '../../math/Vector2.js';
|
|
12
14
|
import { RenderTarget } from '../../core/RenderTarget.js';
|
|
@@ -15,6 +17,12 @@ const _quadMesh = /*@__PURE__*/ new QuadMesh();
|
|
|
15
17
|
|
|
16
18
|
class AnamorphicNode extends TempNode {
|
|
17
19
|
|
|
20
|
+
static get type() {
|
|
21
|
+
|
|
22
|
+
return 'AnamorphicNode';
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
18
26
|
constructor( textureNode, tresholdNode, scaleNode, samples ) {
|
|
19
27
|
|
|
20
28
|
super( 'vec4' );
|
|
@@ -90,14 +98,14 @@ class AnamorphicNode extends TempNode {
|
|
|
90
98
|
|
|
91
99
|
const sampleTexture = ( uv ) => textureNode.uv( uv );
|
|
92
100
|
|
|
93
|
-
const anamorph =
|
|
101
|
+
const anamorph = Fn( () => {
|
|
94
102
|
|
|
95
103
|
const samples = this.samples;
|
|
96
104
|
const halfSamples = Math.floor( samples / 2 );
|
|
97
105
|
|
|
98
106
|
const total = vec3( 0 ).toVar();
|
|
99
107
|
|
|
100
|
-
|
|
108
|
+
Loop( { start: - halfSamples, end: halfSamples }, ( { i } ) => {
|
|
101
109
|
|
|
102
110
|
const softness = float( i ).abs().div( halfSamples ).oneMinus();
|
|
103
111
|
|
|
@@ -115,7 +123,8 @@ class AnamorphicNode extends TempNode {
|
|
|
115
123
|
|
|
116
124
|
//
|
|
117
125
|
|
|
118
|
-
const material = this._material || ( this._material =
|
|
126
|
+
const material = this._material || ( this._material = new NodeMaterial() );
|
|
127
|
+
material.name = 'Anamorphic';
|
|
119
128
|
material.fragmentNode = anamorph();
|
|
120
129
|
|
|
121
130
|
//
|
|
@@ -137,9 +146,6 @@ class AnamorphicNode extends TempNode {
|
|
|
137
146
|
|
|
138
147
|
}
|
|
139
148
|
|
|
140
|
-
export const anamorphic = ( node, threshold = .9, scale = 3, samples = 32 ) => nodeObject( new AnamorphicNode(
|
|
141
|
-
|
|
142
|
-
addNodeElement( 'anamorphic', anamorphic );
|
|
149
|
+
export const anamorphic = ( node, threshold = .9, scale = 3, samples = 32 ) => nodeObject( new AnamorphicNode( convertToTexture( node ), nodeObject( threshold ), nodeObject( scale ), samples ) );
|
|
143
150
|
|
|
144
151
|
export default AnamorphicNode;
|
|
145
|
-
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { float, Fn, vec3, vec4 } from '../tsl/TSLBase.js';
|
|
2
|
+
import { min, max, mix } from '../math/MathNode.js';
|
|
3
|
+
import { luminance } from './ColorAdjustment.js';
|
|
4
|
+
|
|
5
|
+
export const bleach = /*@__PURE__*/ Fn( ( [ color, opacity = 1 ] ) => {
|
|
6
|
+
|
|
7
|
+
const base = color;
|
|
8
|
+
const lum = luminance( base.rgb );
|
|
9
|
+
const blend = vec3( lum );
|
|
10
|
+
|
|
11
|
+
const L = min( 1.0, max( 0.0, float( 10.0 ).mul( lum.sub( 0.45 ) ) ) );
|
|
12
|
+
|
|
13
|
+
const result1 = blend.mul( base.rgb ).mul( 2.0 );
|
|
14
|
+
const result2 = float( 2.0 ).mul( blend.oneMinus() ).mul( base.rgb.oneMinus() ).oneMinus();
|
|
15
|
+
|
|
16
|
+
const newColor = mix( result1, result2, L );
|
|
17
|
+
|
|
18
|
+
const A2 = base.a.mul( opacity );
|
|
19
|
+
|
|
20
|
+
const mixRGB = A2.mul( newColor.rgb );
|
|
21
|
+
|
|
22
|
+
mixRGB.addAssign( base.rgb.mul( A2.oneMinus() ) );
|
|
23
|
+
|
|
24
|
+
return vec4( mixRGB, base.a );
|
|
25
|
+
|
|
26
|
+
} );
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Fn } from '../tsl/TSLBase.js';
|
|
2
|
+
import { mix, min, step } from '../math/MathNode.js';
|
|
3
|
+
|
|
4
|
+
export const burn = /*@__PURE__*/ Fn( ( [ base, blend ] ) => {
|
|
5
|
+
|
|
6
|
+
return min( 1.0, base.oneMinus().div( blend ) ).oneMinus();
|
|
7
|
+
|
|
8
|
+
} ).setLayout( {
|
|
9
|
+
name: 'burnBlend',
|
|
10
|
+
type: 'vec3',
|
|
11
|
+
inputs: [
|
|
12
|
+
{ name: 'base', type: 'vec3' },
|
|
13
|
+
{ name: 'blend', type: 'vec3' }
|
|
14
|
+
]
|
|
15
|
+
} );
|
|
16
|
+
|
|
17
|
+
export const dodge = /*@__PURE__*/ Fn( ( [ base, blend ] ) => {
|
|
18
|
+
|
|
19
|
+
return min( base.div( blend.oneMinus() ), 1.0 );
|
|
20
|
+
|
|
21
|
+
} ).setLayout( {
|
|
22
|
+
name: 'dodgeBlend',
|
|
23
|
+
type: 'vec3',
|
|
24
|
+
inputs: [
|
|
25
|
+
{ name: 'base', type: 'vec3' },
|
|
26
|
+
{ name: 'blend', type: 'vec3' }
|
|
27
|
+
]
|
|
28
|
+
} );
|
|
29
|
+
|
|
30
|
+
export const screen = /*@__PURE__*/ Fn( ( [ base, blend ] ) => {
|
|
31
|
+
|
|
32
|
+
return base.oneMinus().mul( blend.oneMinus() ).oneMinus();
|
|
33
|
+
|
|
34
|
+
} ).setLayout( {
|
|
35
|
+
name: 'screenBlend',
|
|
36
|
+
type: 'vec3',
|
|
37
|
+
inputs: [
|
|
38
|
+
{ name: 'base', type: 'vec3' },
|
|
39
|
+
{ name: 'blend', type: 'vec3' }
|
|
40
|
+
]
|
|
41
|
+
} );
|
|
42
|
+
|
|
43
|
+
export const overlay = /*@__PURE__*/ Fn( ( [ base, blend ] ) => {
|
|
44
|
+
|
|
45
|
+
return mix( base.mul( 2.0 ).mul( blend ), base.oneMinus().mul( 2.0 ).mul( blend.oneMinus() ).oneMinus(), step( 0.5, base ) );
|
|
46
|
+
|
|
47
|
+
} ).setLayout( {
|
|
48
|
+
name: 'overlayBlend',
|
|
49
|
+
type: 'vec3',
|
|
50
|
+
inputs: [
|
|
51
|
+
{ name: 'base', type: 'vec3' },
|
|
52
|
+
{ name: 'blend', type: 'vec3' }
|
|
53
|
+
]
|
|
54
|
+
} );
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import TempNode from '../core/TempNode.js';
|
|
2
|
-
import {
|
|
2
|
+
import { Fn, nodeObject, float, vec4, int } from '../tsl/TSLBase.js';
|
|
3
3
|
import { mix, smoothstep } from '../math/MathNode.js';
|
|
4
|
-
import { luminance } from './
|
|
4
|
+
import { luminance } from './ColorAdjustment.js';
|
|
5
5
|
import { uniform } from '../core/UniformNode.js';
|
|
6
|
-
import {
|
|
7
|
-
import { uv } from '../accessors/
|
|
6
|
+
import { uniformArray } from '../accessors/UniformArrayNode.js';
|
|
7
|
+
import { uv } from '../accessors/UV.js';
|
|
8
8
|
import { Color } from '../../math/Color.js';
|
|
9
9
|
import { passTexture } from './PassNode.js';
|
|
10
10
|
import { RenderTarget } from '../../core/RenderTarget.js';
|
|
11
11
|
import { HalfFloatType } from '../../constants.js';
|
|
12
12
|
import { NodeUpdateType } from '../core/constants.js';
|
|
13
13
|
import { Vector2 } from '../../math/Vector2.js';
|
|
14
|
-
import {
|
|
14
|
+
import { Loop } from '../utils/LoopNode.js';
|
|
15
15
|
import { add } from '../math/OperatorNode.js';
|
|
16
16
|
import QuadMesh from '../../renderers/common/QuadMesh.js';
|
|
17
17
|
import { texture } from '../accessors/TextureNode.js';
|
|
18
18
|
import { Vector3 } from '../../math/Vector3.js';
|
|
19
|
+
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
|
19
20
|
|
|
20
21
|
const _quadMesh = /*@__PURE__*/ new QuadMesh();
|
|
21
22
|
|
|
@@ -28,6 +29,12 @@ const _BlurDirectionY = /*@__PURE__*/ new Vector2( 0.0, 1.0 );
|
|
|
28
29
|
|
|
29
30
|
class BloomNode extends TempNode {
|
|
30
31
|
|
|
32
|
+
static get type() {
|
|
33
|
+
|
|
34
|
+
return 'BloomNode';
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
31
38
|
constructor( inputNode, strength = 1, radius = 0, threshold = 0 ) {
|
|
32
39
|
|
|
33
40
|
super();
|
|
@@ -183,7 +190,7 @@ class BloomNode extends TempNode {
|
|
|
183
190
|
|
|
184
191
|
// luminosity high pass material
|
|
185
192
|
|
|
186
|
-
const luminosityHighPass =
|
|
193
|
+
const luminosityHighPass = Fn( () => {
|
|
187
194
|
|
|
188
195
|
const texel = this.inputNode;
|
|
189
196
|
const v = luminance( texel.rgb );
|
|
@@ -194,8 +201,9 @@ class BloomNode extends TempNode {
|
|
|
194
201
|
|
|
195
202
|
} );
|
|
196
203
|
|
|
197
|
-
this._highPassFilterMaterial = this._highPassFilterMaterial ||
|
|
204
|
+
this._highPassFilterMaterial = this._highPassFilterMaterial || new NodeMaterial();
|
|
198
205
|
this._highPassFilterMaterial.fragmentNode = luminosityHighPass().context( builder.getSharedContext() );
|
|
206
|
+
this._highPassFilterMaterial.name = 'Bloom_highPass';
|
|
199
207
|
this._highPassFilterMaterial.needsUpdate = true;
|
|
200
208
|
|
|
201
209
|
// gaussian blur materials
|
|
@@ -210,10 +218,10 @@ class BloomNode extends TempNode {
|
|
|
210
218
|
|
|
211
219
|
// composite material
|
|
212
220
|
|
|
213
|
-
const bloomFactors =
|
|
214
|
-
const bloomTintColors =
|
|
221
|
+
const bloomFactors = uniformArray( [ 1.0, 0.8, 0.6, 0.4, 0.2 ] );
|
|
222
|
+
const bloomTintColors = uniformArray( [ new Vector3( 1, 1, 1 ), new Vector3( 1, 1, 1 ), new Vector3( 1, 1, 1 ), new Vector3( 1, 1, 1 ), new Vector3( 1, 1, 1 ) ] );
|
|
215
223
|
|
|
216
|
-
const lerpBloomFactor =
|
|
224
|
+
const lerpBloomFactor = Fn( ( [ factor, radius ] ) => {
|
|
217
225
|
|
|
218
226
|
const mirrorFactor = float( 1.2 ).sub( factor );
|
|
219
227
|
return mix( factor, mirrorFactor, radius );
|
|
@@ -228,7 +236,7 @@ class BloomNode extends TempNode {
|
|
|
228
236
|
} );
|
|
229
237
|
|
|
230
238
|
|
|
231
|
-
const compositePass =
|
|
239
|
+
const compositePass = Fn( () => {
|
|
232
240
|
|
|
233
241
|
const color0 = lerpBloomFactor( bloomFactors.element( 0 ), this.radius ).mul( vec4( bloomTintColors.element( 0 ), 1.0 ) ).mul( this._textureNodeBlur0 );
|
|
234
242
|
const color1 = lerpBloomFactor( bloomFactors.element( 1 ), this.radius ).mul( vec4( bloomTintColors.element( 1 ), 1.0 ) ).mul( this._textureNodeBlur1 );
|
|
@@ -242,8 +250,9 @@ class BloomNode extends TempNode {
|
|
|
242
250
|
|
|
243
251
|
} );
|
|
244
252
|
|
|
245
|
-
this._compositeMaterial = this._compositeMaterial ||
|
|
253
|
+
this._compositeMaterial = this._compositeMaterial || new NodeMaterial();
|
|
246
254
|
this._compositeMaterial.fragmentNode = compositePass().context( builder.getSharedContext() );
|
|
255
|
+
this._compositeMaterial.name = 'Bloom_comp';
|
|
247
256
|
this._compositeMaterial.needsUpdate = true;
|
|
248
257
|
|
|
249
258
|
//
|
|
@@ -283,19 +292,19 @@ class BloomNode extends TempNode {
|
|
|
283
292
|
//
|
|
284
293
|
|
|
285
294
|
const colorTexture = texture();
|
|
286
|
-
const gaussianCoefficients =
|
|
295
|
+
const gaussianCoefficients = uniformArray( coefficients );
|
|
287
296
|
const invSize = uniform( new Vector2() );
|
|
288
297
|
const direction = uniform( new Vector2( 0.5, 0.5 ) );
|
|
289
298
|
|
|
290
299
|
const uvNode = uv();
|
|
291
300
|
const sampleTexel = ( uv ) => colorTexture.uv( uv );
|
|
292
301
|
|
|
293
|
-
const seperableBlurPass =
|
|
302
|
+
const seperableBlurPass = Fn( () => {
|
|
294
303
|
|
|
295
304
|
const weightSum = gaussianCoefficients.element( 0 ).toVar();
|
|
296
305
|
const diffuseSum = sampleTexel( uvNode ).rgb.mul( weightSum ).toVar();
|
|
297
306
|
|
|
298
|
-
|
|
307
|
+
Loop( { start: int( 1 ), end: int( kernelRadius ), type: 'int', condition: '<' }, ( { i } ) => {
|
|
299
308
|
|
|
300
309
|
const x = float( i );
|
|
301
310
|
const w = gaussianCoefficients.element( i );
|
|
@@ -305,14 +314,15 @@ class BloomNode extends TempNode {
|
|
|
305
314
|
diffuseSum.addAssign( add( sample1, sample2 ).mul( w ) );
|
|
306
315
|
weightSum.addAssign( float( 2.0 ).mul( w ) );
|
|
307
316
|
|
|
308
|
-
}
|
|
317
|
+
} );
|
|
309
318
|
|
|
310
319
|
return vec4( diffuseSum.div( weightSum ), 1.0 );
|
|
311
320
|
|
|
312
321
|
} );
|
|
313
322
|
|
|
314
|
-
const seperableBlurMaterial =
|
|
323
|
+
const seperableBlurMaterial = new NodeMaterial();
|
|
315
324
|
seperableBlurMaterial.fragmentNode = seperableBlurPass().context( builder.getSharedContext() );
|
|
325
|
+
seperableBlurMaterial.name = 'Bloom_seperable';
|
|
316
326
|
seperableBlurMaterial.needsUpdate = true;
|
|
317
327
|
|
|
318
328
|
// uniforms
|
|
@@ -328,6 +338,4 @@ class BloomNode extends TempNode {
|
|
|
328
338
|
|
|
329
339
|
export const bloom = ( node, strength, radius, threshold ) => nodeObject( new BloomNode( nodeObject( node ), strength, radius, threshold ) );
|
|
330
340
|
|
|
331
|
-
addNodeElement( 'bloom', bloom );
|
|
332
|
-
|
|
333
341
|
export default BloomNode;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import TempNode from '../core/TempNode.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { positionView } from '../accessors/PositionNode.js';
|
|
2
|
+
import { uv } from '../accessors/UV.js';
|
|
3
|
+
import { normalView } from '../accessors/Normal.js';
|
|
4
|
+
import { positionView } from '../accessors/Position.js';
|
|
6
5
|
import { faceDirection } from './FrontFacingNode.js';
|
|
7
|
-
import {
|
|
6
|
+
import { Fn, nodeProxy, float, vec2 } from '../tsl/TSLBase.js';
|
|
8
7
|
|
|
9
8
|
// Bump Mapping Unparametrized Surfaces on the GPU by Morten S. Mikkelsen
|
|
10
9
|
// https://mmikk.github.io/papers3d/mm_sfgrad_bump.pdf
|
|
11
10
|
|
|
12
|
-
const dHdxy_fwd =
|
|
11
|
+
const dHdxy_fwd = Fn( ( { textureNode, bumpScale } ) => {
|
|
13
12
|
|
|
14
13
|
// It's used to preserve the same TextureNode instance
|
|
15
14
|
const sampleTexture = ( callback ) => textureNode.cache().context( { getUV: ( texNode ) => callback( texNode.uvNode || uv() ), forceUVContext: true } );
|
|
@@ -25,7 +24,7 @@ const dHdxy_fwd = tslFn( ( { textureNode, bumpScale } ) => {
|
|
|
25
24
|
|
|
26
25
|
// Evaluate the derivative of the height w.r.t. screen-space using forward differencing (listing 2)
|
|
27
26
|
|
|
28
|
-
const perturbNormalArb =
|
|
27
|
+
const perturbNormalArb = Fn( ( inputs ) => {
|
|
29
28
|
|
|
30
29
|
const { surf_pos, surf_norm, dHdxy } = inputs;
|
|
31
30
|
|
|
@@ -47,6 +46,12 @@ const perturbNormalArb = tslFn( ( inputs ) => {
|
|
|
47
46
|
|
|
48
47
|
class BumpMapNode extends TempNode {
|
|
49
48
|
|
|
49
|
+
static get type() {
|
|
50
|
+
|
|
51
|
+
return 'BumpMapNode';
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
|
|
50
55
|
constructor( textureNode, scaleNode = null ) {
|
|
51
56
|
|
|
52
57
|
super( 'vec3' );
|
|
@@ -73,8 +78,4 @@ class BumpMapNode extends TempNode {
|
|
|
73
78
|
|
|
74
79
|
export default BumpMapNode;
|
|
75
80
|
|
|
76
|
-
export const bumpMap = nodeProxy( BumpMapNode );
|
|
77
|
-
|
|
78
|
-
addNodeElement( 'bumpMap', bumpMap );
|
|
79
|
-
|
|
80
|
-
addNodeClass( 'BumpMapNode', BumpMapNode );
|
|
81
|
+
export const bumpMap = /*@__PURE__*/ nodeProxy( BumpMapNode );
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { dot, mix } from '../math/MathNode.js';
|
|
2
|
+
import { add } from '../math/OperatorNode.js';
|
|
3
|
+
import { Fn, float, vec3 } from '../tsl/TSLBase.js';
|
|
4
|
+
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
5
|
+
import { Vector3 } from '../../math/Vector3.js';
|
|
6
|
+
|
|
7
|
+
export const grayscale = /*@__PURE__*/ Fn( ( [ color ] ) => {
|
|
8
|
+
|
|
9
|
+
return luminance( color.rgb );
|
|
10
|
+
|
|
11
|
+
} );
|
|
12
|
+
|
|
13
|
+
export const saturation = /*@__PURE__*/ Fn( ( [ color, adjustment = float( 1 ) ] ) => {
|
|
14
|
+
|
|
15
|
+
return adjustment.mix( luminance( color.rgb ), color.rgb );
|
|
16
|
+
|
|
17
|
+
} );
|
|
18
|
+
|
|
19
|
+
export const vibrance = /*@__PURE__*/ Fn( ( [ color, adjustment = float( 1 ) ] ) => {
|
|
20
|
+
|
|
21
|
+
const average = add( color.r, color.g, color.b ).div( 3.0 );
|
|
22
|
+
|
|
23
|
+
const mx = color.r.max( color.g.max( color.b ) );
|
|
24
|
+
const amt = mx.sub( average ).mul( adjustment ).mul( - 3.0 );
|
|
25
|
+
|
|
26
|
+
return mix( color.rgb, mx, amt );
|
|
27
|
+
|
|
28
|
+
} );
|
|
29
|
+
|
|
30
|
+
export const hue = /*@__PURE__*/ Fn( ( [ color, adjustment = float( 1 ) ] ) => {
|
|
31
|
+
|
|
32
|
+
const k = vec3( 0.57735, 0.57735, 0.57735 );
|
|
33
|
+
|
|
34
|
+
const cosAngle = adjustment.cos();
|
|
35
|
+
|
|
36
|
+
return vec3( color.rgb.mul( cosAngle ).add( k.cross( color.rgb ).mul( adjustment.sin() ).add( k.mul( dot( k, color.rgb ).mul( cosAngle.oneMinus() ) ) ) ) );
|
|
37
|
+
|
|
38
|
+
} );
|
|
39
|
+
|
|
40
|
+
const _luminanceCoefficients = /*@__PURE__*/ new Vector3();
|
|
41
|
+
export const luminance = (
|
|
42
|
+
color,
|
|
43
|
+
luminanceCoefficients = vec3( ... ColorManagement.getLuminanceCoefficients( _luminanceCoefficients ) )
|
|
44
|
+
) => dot( color, luminanceCoefficients );
|
|
45
|
+
|
|
46
|
+
export const threshold = ( color, threshold ) => mix( vec3( 0.0 ), color, luminance( color ).sub( threshold ).max( 0 ) );
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { mix } from '../math/MathNode.js';
|
|
2
|
+
import { Fn } from '../tsl/TSLBase.js';
|
|
3
|
+
|
|
4
|
+
export const sRGBToLinearSRGB = /*@__PURE__*/ Fn( ( [ color ] ) => {
|
|
5
|
+
|
|
6
|
+
const a = color.mul( 0.9478672986 ).add( 0.0521327014 ).pow( 2.4 );
|
|
7
|
+
const b = color.mul( 0.0773993808 );
|
|
8
|
+
const factor = color.lessThanEqual( 0.04045 );
|
|
9
|
+
|
|
10
|
+
const rgbResult = mix( a, b, factor );
|
|
11
|
+
|
|
12
|
+
return rgbResult;
|
|
13
|
+
|
|
14
|
+
} ).setLayout( {
|
|
15
|
+
name: 'sRGBToLinearSRGB',
|
|
16
|
+
type: 'vec3',
|
|
17
|
+
inputs: [
|
|
18
|
+
{ name: 'color', type: 'vec3' }
|
|
19
|
+
]
|
|
20
|
+
} );
|
|
21
|
+
|
|
22
|
+
export const linearSRGBTosRGB = /*@__PURE__*/ Fn( ( [ color ] ) => {
|
|
23
|
+
|
|
24
|
+
const a = color.pow( 0.41666 ).mul( 1.055 ).sub( 0.055 );
|
|
25
|
+
const b = color.mul( 12.92 );
|
|
26
|
+
const factor = color.lessThanEqual( 0.0031308 );
|
|
27
|
+
|
|
28
|
+
const rgbResult = mix( a, b, factor );
|
|
29
|
+
|
|
30
|
+
return rgbResult;
|
|
31
|
+
|
|
32
|
+
} ).setLayout( {
|
|
33
|
+
name: 'linearSRGBTosRGB',
|
|
34
|
+
type: 'vec3',
|
|
35
|
+
inputs: [
|
|
36
|
+
{ name: 'color', type: 'vec3' }
|
|
37
|
+
]
|
|
38
|
+
} );
|