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
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { nodeObject } from '../tsl/TSLBase.js';
|
|
2
|
+
import PassNode from './PassNode.js';
|
|
3
|
+
import { Vector2 } from '../../math/Vector2.js';
|
|
4
|
+
import { StereoCamera } from '../../cameras/StereoCamera.js';
|
|
5
|
+
|
|
6
|
+
const _size = /*@__PURE__*/ new Vector2();
|
|
7
|
+
|
|
8
|
+
class StereoPassNode extends PassNode {
|
|
9
|
+
|
|
10
|
+
static get type() {
|
|
11
|
+
|
|
12
|
+
return 'StereoPassNode';
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
constructor( scene, camera ) {
|
|
17
|
+
|
|
18
|
+
super( PassNode.COLOR, scene, camera );
|
|
19
|
+
|
|
20
|
+
this.isStereoPassNode = true;
|
|
21
|
+
|
|
22
|
+
this.stereo = new StereoCamera();
|
|
23
|
+
this.stereo.aspect = 0.5;
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
updateBefore( frame ) {
|
|
28
|
+
|
|
29
|
+
const { renderer } = frame;
|
|
30
|
+
const { scene, camera, stereo, renderTarget } = this;
|
|
31
|
+
|
|
32
|
+
this._pixelRatio = renderer.getPixelRatio();
|
|
33
|
+
|
|
34
|
+
stereo.cameraL.coordinateSystem = renderer.coordinateSystem;
|
|
35
|
+
stereo.cameraR.coordinateSystem = renderer.coordinateSystem;
|
|
36
|
+
stereo.update( camera );
|
|
37
|
+
|
|
38
|
+
const size = renderer.getSize( _size );
|
|
39
|
+
this.setSize( size.width, size.height );
|
|
40
|
+
|
|
41
|
+
const currentAutoClear = renderer.autoClear;
|
|
42
|
+
renderer.autoClear = false;
|
|
43
|
+
|
|
44
|
+
const currentRenderTarget = renderer.getRenderTarget();
|
|
45
|
+
const currentMRT = renderer.getMRT();
|
|
46
|
+
|
|
47
|
+
this._cameraNear.value = camera.near;
|
|
48
|
+
this._cameraFar.value = camera.far;
|
|
49
|
+
|
|
50
|
+
for ( const name in this._previousTextures ) {
|
|
51
|
+
|
|
52
|
+
this.toggleTexture( name );
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
renderer.setRenderTarget( renderTarget );
|
|
57
|
+
renderer.setMRT( this._mrt );
|
|
58
|
+
renderer.clear();
|
|
59
|
+
|
|
60
|
+
renderTarget.scissorTest = true;
|
|
61
|
+
|
|
62
|
+
renderTarget.scissor.set( 0, 0, renderTarget.width / 2, renderTarget.height );
|
|
63
|
+
renderTarget.viewport.set( 0, 0, renderTarget.width / 2, renderTarget.height );
|
|
64
|
+
renderer.render( scene, stereo.cameraL );
|
|
65
|
+
|
|
66
|
+
renderTarget.scissor.set( renderTarget.width / 2, 0, renderTarget.width / 2, renderTarget.height );
|
|
67
|
+
renderTarget.viewport.set( renderTarget.width / 2, 0, renderTarget.width / 2, renderTarget.height );
|
|
68
|
+
renderer.render( scene, stereo.cameraR );
|
|
69
|
+
|
|
70
|
+
renderTarget.scissorTest = false;
|
|
71
|
+
|
|
72
|
+
renderer.setRenderTarget( currentRenderTarget );
|
|
73
|
+
renderer.setMRT( currentMRT );
|
|
74
|
+
|
|
75
|
+
renderer.autoClear = currentAutoClear;
|
|
76
|
+
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export default StereoPassNode;
|
|
82
|
+
|
|
83
|
+
export const stereoPass = ( scene, camera ) => nodeObject( new StereoPassNode( scene, camera ) );
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { Fn, float, mat3, vec3, If } from '../tsl/TSLBase.js';
|
|
2
|
+
import { select } from '../math/ConditionalNode.js';
|
|
3
|
+
import { clamp, log2, max, min, pow, mix } from '../math/MathNode.js';
|
|
4
|
+
import { mul, sub, div } from '../math/OperatorNode.js';
|
|
5
|
+
|
|
6
|
+
// exposure only
|
|
7
|
+
|
|
8
|
+
export const linearToneMapping = /*@__PURE__*/ Fn( ( [ color, exposure ] ) => {
|
|
9
|
+
|
|
10
|
+
return color.mul( exposure ).clamp();
|
|
11
|
+
|
|
12
|
+
} ).setLayout( {
|
|
13
|
+
name: 'linearToneMapping',
|
|
14
|
+
type: 'vec3',
|
|
15
|
+
inputs: [
|
|
16
|
+
{ name: 'color', type: 'vec3' },
|
|
17
|
+
{ name: 'exposure', type: 'float' }
|
|
18
|
+
]
|
|
19
|
+
} );
|
|
20
|
+
|
|
21
|
+
// source: https://www.cs.utah.edu/docs/techreports/2002/pdf/UUCS-02-001.pdf
|
|
22
|
+
|
|
23
|
+
export const reinhardToneMapping = /*@__PURE__*/ Fn( ( [ color, exposure ] ) => {
|
|
24
|
+
|
|
25
|
+
color = color.mul( exposure );
|
|
26
|
+
|
|
27
|
+
return color.div( color.add( 1.0 ) ).clamp();
|
|
28
|
+
|
|
29
|
+
} ).setLayout( {
|
|
30
|
+
name: 'reinhardToneMapping',
|
|
31
|
+
type: 'vec3',
|
|
32
|
+
inputs: [
|
|
33
|
+
{ name: 'color', type: 'vec3' },
|
|
34
|
+
{ name: 'exposure', type: 'float' }
|
|
35
|
+
]
|
|
36
|
+
} );
|
|
37
|
+
|
|
38
|
+
// source: http://filmicworlds.com/blog/filmic-tonemapping-operators/
|
|
39
|
+
|
|
40
|
+
export const cineonToneMapping = /*@__PURE__*/ Fn( ( [ color, exposure ] ) => {
|
|
41
|
+
|
|
42
|
+
// filmic operator by Jim Hejl and Richard Burgess-Dawson
|
|
43
|
+
color = color.mul( exposure );
|
|
44
|
+
color = color.sub( 0.004 ).max( 0.0 );
|
|
45
|
+
|
|
46
|
+
const a = color.mul( color.mul( 6.2 ).add( 0.5 ) );
|
|
47
|
+
const b = color.mul( color.mul( 6.2 ).add( 1.7 ) ).add( 0.06 );
|
|
48
|
+
|
|
49
|
+
return a.div( b ).pow( 2.2 );
|
|
50
|
+
|
|
51
|
+
} ).setLayout( {
|
|
52
|
+
name: 'cineonToneMapping',
|
|
53
|
+
type: 'vec3',
|
|
54
|
+
inputs: [
|
|
55
|
+
{ name: 'color', type: 'vec3' },
|
|
56
|
+
{ name: 'exposure', type: 'float' }
|
|
57
|
+
]
|
|
58
|
+
} );
|
|
59
|
+
|
|
60
|
+
// source: https://github.com/selfshadow/ltc_code/blob/master/webgl/shaders/ltc/ltc_blit.fs
|
|
61
|
+
|
|
62
|
+
const RRTAndODTFit = /*@__PURE__*/ Fn( ( [ color ] ) => {
|
|
63
|
+
|
|
64
|
+
const a = color.mul( color.add( 0.0245786 ) ).sub( 0.000090537 );
|
|
65
|
+
const b = color.mul( color.add( 0.4329510 ).mul( 0.983729 ) ).add( 0.238081 );
|
|
66
|
+
|
|
67
|
+
return a.div( b );
|
|
68
|
+
|
|
69
|
+
} );
|
|
70
|
+
|
|
71
|
+
// source: https://github.com/selfshadow/ltc_code/blob/master/webgl/shaders/ltc/ltc_blit.fs
|
|
72
|
+
|
|
73
|
+
export const acesFilmicToneMapping = /*@__PURE__*/ Fn( ( [ color, exposure ] ) => {
|
|
74
|
+
|
|
75
|
+
// sRGB => XYZ => D65_2_D60 => AP1 => RRT_SAT
|
|
76
|
+
const ACESInputMat = mat3(
|
|
77
|
+
0.59719, 0.35458, 0.04823,
|
|
78
|
+
0.07600, 0.90834, 0.01566,
|
|
79
|
+
0.02840, 0.13383, 0.83777
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
// ODT_SAT => XYZ => D60_2_D65 => sRGB
|
|
83
|
+
const ACESOutputMat = mat3(
|
|
84
|
+
1.60475, - 0.53108, - 0.07367,
|
|
85
|
+
- 0.10208, 1.10813, - 0.00605,
|
|
86
|
+
- 0.00327, - 0.07276, 1.07602
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
color = color.mul( exposure ).div( 0.6 );
|
|
90
|
+
|
|
91
|
+
color = ACESInputMat.mul( color );
|
|
92
|
+
|
|
93
|
+
// Apply RRT and ODT
|
|
94
|
+
color = RRTAndODTFit( color );
|
|
95
|
+
|
|
96
|
+
color = ACESOutputMat.mul( color );
|
|
97
|
+
|
|
98
|
+
// Clamp to [0, 1]
|
|
99
|
+
return color.clamp();
|
|
100
|
+
|
|
101
|
+
} ).setLayout( {
|
|
102
|
+
name: 'acesFilmicToneMapping',
|
|
103
|
+
type: 'vec3',
|
|
104
|
+
inputs: [
|
|
105
|
+
{ name: 'color', type: 'vec3' },
|
|
106
|
+
{ name: 'exposure', type: 'float' }
|
|
107
|
+
]
|
|
108
|
+
} );
|
|
109
|
+
|
|
110
|
+
const LINEAR_REC2020_TO_LINEAR_SRGB = /*@__PURE__*/ mat3( vec3( 1.6605, - 0.1246, - 0.0182 ), vec3( - 0.5876, 1.1329, - 0.1006 ), vec3( - 0.0728, - 0.0083, 1.1187 ) );
|
|
111
|
+
const LINEAR_SRGB_TO_LINEAR_REC2020 = /*@__PURE__*/ mat3( vec3( 0.6274, 0.0691, 0.0164 ), vec3( 0.3293, 0.9195, 0.0880 ), vec3( 0.0433, 0.0113, 0.8956 ) );
|
|
112
|
+
|
|
113
|
+
const agxDefaultContrastApprox = /*@__PURE__*/ Fn( ( [ x_immutable ] ) => {
|
|
114
|
+
|
|
115
|
+
const x = vec3( x_immutable ).toVar();
|
|
116
|
+
const x2 = vec3( x.mul( x ) ).toVar();
|
|
117
|
+
const x4 = vec3( x2.mul( x2 ) ).toVar();
|
|
118
|
+
|
|
119
|
+
return float( 15.5 ).mul( x4.mul( x2 ) ).sub( mul( 40.14, x4.mul( x ) ) ).add( mul( 31.96, x4 ).sub( mul( 6.868, x2.mul( x ) ) ).add( mul( 0.4298, x2 ).add( mul( 0.1191, x ).sub( 0.00232 ) ) ) );
|
|
120
|
+
|
|
121
|
+
} );
|
|
122
|
+
|
|
123
|
+
export const agxToneMapping = /*@__PURE__*/ Fn( ( [ color, exposure ] ) => {
|
|
124
|
+
|
|
125
|
+
const colortone = vec3( color ).toVar();
|
|
126
|
+
const AgXInsetMatrix = mat3( vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) );
|
|
127
|
+
const AgXOutsetMatrix = mat3( vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) );
|
|
128
|
+
const AgxMinEv = float( - 12.47393 );
|
|
129
|
+
const AgxMaxEv = float( 4.026069 );
|
|
130
|
+
colortone.mulAssign( exposure );
|
|
131
|
+
colortone.assign( LINEAR_SRGB_TO_LINEAR_REC2020.mul( colortone ) );
|
|
132
|
+
colortone.assign( AgXInsetMatrix.mul( colortone ) );
|
|
133
|
+
colortone.assign( max( colortone, 1e-10 ) );
|
|
134
|
+
colortone.assign( log2( colortone ) );
|
|
135
|
+
colortone.assign( colortone.sub( AgxMinEv ).div( AgxMaxEv.sub( AgxMinEv ) ) );
|
|
136
|
+
colortone.assign( clamp( colortone, 0.0, 1.0 ) );
|
|
137
|
+
colortone.assign( agxDefaultContrastApprox( colortone ) );
|
|
138
|
+
colortone.assign( AgXOutsetMatrix.mul( colortone ) );
|
|
139
|
+
colortone.assign( pow( max( vec3( 0.0 ), colortone ), vec3( 2.2 ) ) );
|
|
140
|
+
colortone.assign( LINEAR_REC2020_TO_LINEAR_SRGB.mul( colortone ) );
|
|
141
|
+
colortone.assign( clamp( colortone, 0.0, 1.0 ) );
|
|
142
|
+
|
|
143
|
+
return colortone;
|
|
144
|
+
|
|
145
|
+
} ).setLayout( {
|
|
146
|
+
name: 'agxToneMapping',
|
|
147
|
+
type: 'vec3',
|
|
148
|
+
inputs: [
|
|
149
|
+
{ name: 'color', type: 'vec3' },
|
|
150
|
+
{ name: 'exposure', type: 'float' }
|
|
151
|
+
]
|
|
152
|
+
} );
|
|
153
|
+
|
|
154
|
+
// https://modelviewer.dev/examples/tone-mapping
|
|
155
|
+
|
|
156
|
+
export const neutralToneMapping = /*@__PURE__*/ Fn( ( [ color, exposure ] ) => {
|
|
157
|
+
|
|
158
|
+
const StartCompression = float( 0.8 - 0.04 );
|
|
159
|
+
const Desaturation = float( 0.15 );
|
|
160
|
+
|
|
161
|
+
color = color.mul( exposure );
|
|
162
|
+
|
|
163
|
+
const x = min( color.r, min( color.g, color.b ) );
|
|
164
|
+
const offset = select( x.lessThan( 0.08 ), x.sub( mul( 6.25, x.mul( x ) ) ), 0.04 );
|
|
165
|
+
|
|
166
|
+
color.subAssign( offset );
|
|
167
|
+
|
|
168
|
+
const peak = max( color.r, max( color.g, color.b ) );
|
|
169
|
+
|
|
170
|
+
If( peak.lessThan( StartCompression ), () => {
|
|
171
|
+
|
|
172
|
+
return color;
|
|
173
|
+
|
|
174
|
+
} );
|
|
175
|
+
|
|
176
|
+
const d = sub( 1, StartCompression );
|
|
177
|
+
const newPeak = sub( 1, d.mul( d ).div( peak.add( d.sub( StartCompression ) ) ) );
|
|
178
|
+
color.mulAssign( newPeak.div( peak ) );
|
|
179
|
+
const g = sub( 1, div( 1, Desaturation.mul( peak.sub( newPeak ) ).add( 1 ) ) );
|
|
180
|
+
|
|
181
|
+
return mix( color, vec3( newPeak ), g );
|
|
182
|
+
|
|
183
|
+
} ).setLayout( {
|
|
184
|
+
name: 'neutralToneMapping',
|
|
185
|
+
type: 'vec3',
|
|
186
|
+
inputs: [
|
|
187
|
+
{ name: 'color', type: 'vec3' },
|
|
188
|
+
{ name: 'exposure', type: 'float' }
|
|
189
|
+
]
|
|
190
|
+
} );
|
|
@@ -1,173 +1,19 @@
|
|
|
1
1
|
import TempNode from '../core/TempNode.js';
|
|
2
|
-
import {
|
|
3
|
-
import { addNodeElement, tslFn, nodeObject, float, mat3, vec3, If } from '../shadernode/ShaderNode.js';
|
|
2
|
+
import { addMethodChaining, nodeObject, vec4 } from '../tsl/TSLCore.js';
|
|
4
3
|
import { rendererReference } from '../accessors/RendererReferenceNode.js';
|
|
5
|
-
import { cond } from '../math/CondNode.js';
|
|
6
|
-
import { clamp, log2, max, min, pow, mix } from '../math/MathNode.js';
|
|
7
|
-
import { mul, sub, div } from '../math/OperatorNode.js';
|
|
8
4
|
|
|
9
|
-
import { NoToneMapping
|
|
5
|
+
import { NoToneMapping } from '../../constants.js';
|
|
6
|
+
import { hash } from '../core/NodeUtils.js';
|
|
10
7
|
|
|
11
|
-
|
|
12
|
-
const LinearToneMappingNode = tslFn( ( { color, exposure } ) => {
|
|
13
|
-
|
|
14
|
-
return color.mul( exposure ).clamp();
|
|
15
|
-
|
|
16
|
-
} );
|
|
17
|
-
|
|
18
|
-
// source: https://www.cs.utah.edu/docs/techreports/2002/pdf/UUCS-02-001.pdf
|
|
19
|
-
const ReinhardToneMappingNode = tslFn( ( { color, exposure } ) => {
|
|
20
|
-
|
|
21
|
-
color = color.mul( exposure );
|
|
22
|
-
|
|
23
|
-
return color.div( color.add( 1.0 ) ).clamp();
|
|
24
|
-
|
|
25
|
-
} );
|
|
26
|
-
|
|
27
|
-
// source: http://filmicworlds.com/blog/filmic-tonemapping-operators/
|
|
28
|
-
const OptimizedCineonToneMappingNode = tslFn( ( { color, exposure } ) => {
|
|
29
|
-
|
|
30
|
-
// optimized filmic operator by Jim Hejl and Richard Burgess-Dawson
|
|
31
|
-
color = color.mul( exposure );
|
|
32
|
-
color = color.sub( 0.004 ).max( 0.0 );
|
|
33
|
-
|
|
34
|
-
const a = color.mul( color.mul( 6.2 ).add( 0.5 ) );
|
|
35
|
-
const b = color.mul( color.mul( 6.2 ).add( 1.7 ) ).add( 0.06 );
|
|
36
|
-
|
|
37
|
-
return a.div( b ).pow( 2.2 );
|
|
38
|
-
|
|
39
|
-
} );
|
|
40
|
-
|
|
41
|
-
// source: https://github.com/selfshadow/ltc_code/blob/master/webgl/shaders/ltc/ltc_blit.fs
|
|
42
|
-
const RRTAndODTFit = tslFn( ( { color } ) => {
|
|
43
|
-
|
|
44
|
-
const a = color.mul( color.add( 0.0245786 ) ).sub( 0.000090537 );
|
|
45
|
-
const b = color.mul( color.add( 0.4329510 ).mul( 0.983729 ) ).add( 0.238081 );
|
|
46
|
-
|
|
47
|
-
return a.div( b );
|
|
48
|
-
|
|
49
|
-
} );
|
|
50
|
-
|
|
51
|
-
// source: https://github.com/selfshadow/ltc_code/blob/master/webgl/shaders/ltc/ltc_blit.fs
|
|
52
|
-
const ACESFilmicToneMappingNode = tslFn( ( { color, exposure } ) => {
|
|
53
|
-
|
|
54
|
-
// sRGB => XYZ => D65_2_D60 => AP1 => RRT_SAT
|
|
55
|
-
const ACESInputMat = mat3(
|
|
56
|
-
0.59719, 0.35458, 0.04823,
|
|
57
|
-
0.07600, 0.90834, 0.01566,
|
|
58
|
-
0.02840, 0.13383, 0.83777
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
// ODT_SAT => XYZ => D60_2_D65 => sRGB
|
|
62
|
-
const ACESOutputMat = mat3(
|
|
63
|
-
1.60475, - 0.53108, - 0.07367,
|
|
64
|
-
- 0.10208, 1.10813, - 0.00605,
|
|
65
|
-
- 0.00327, - 0.07276, 1.07602
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
color = color.mul( exposure ).div( 0.6 );
|
|
69
|
-
|
|
70
|
-
color = ACESInputMat.mul( color );
|
|
71
|
-
|
|
72
|
-
// Apply RRT and ODT
|
|
73
|
-
color = RRTAndODTFit( { color } );
|
|
74
|
-
|
|
75
|
-
color = ACESOutputMat.mul( color );
|
|
76
|
-
|
|
77
|
-
// Clamp to [0, 1]
|
|
78
|
-
return color.clamp();
|
|
79
|
-
|
|
80
|
-
} );
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const LINEAR_REC2020_TO_LINEAR_SRGB = mat3( vec3( 1.6605, - 0.1246, - 0.0182 ), vec3( - 0.5876, 1.1329, - 0.1006 ), vec3( - 0.0728, - 0.0083, 1.1187 ) );
|
|
85
|
-
const LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( vec3( 0.6274, 0.0691, 0.0164 ), vec3( 0.3293, 0.9195, 0.0880 ), vec3( 0.0433, 0.0113, 0.8956 ) );
|
|
86
|
-
|
|
87
|
-
const agxDefaultContrastApprox = tslFn( ( [ x_immutable ] ) => {
|
|
88
|
-
|
|
89
|
-
const x = vec3( x_immutable ).toVar();
|
|
90
|
-
const x2 = vec3( x.mul( x ) ).toVar();
|
|
91
|
-
const x4 = vec3( x2.mul( x2 ) ).toVar();
|
|
92
|
-
|
|
93
|
-
return float( 15.5 ).mul( x4.mul( x2 ) ).sub( mul( 40.14, x4.mul( x ) ) ).add( mul( 31.96, x4 ).sub( mul( 6.868, x2.mul( x ) ) ).add( mul( 0.4298, x2 ).add( mul( 0.1191, x ).sub( 0.00232 ) ) ) );
|
|
94
|
-
|
|
95
|
-
} );
|
|
96
|
-
|
|
97
|
-
const AGXToneMappingNode = tslFn( ( { color, exposure } ) => {
|
|
98
|
-
|
|
99
|
-
const colortone = vec3( color ).toVar();
|
|
100
|
-
const AgXInsetMatrix = mat3( vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) );
|
|
101
|
-
const AgXOutsetMatrix = mat3( vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) );
|
|
102
|
-
const AgxMinEv = float( - 12.47393 );
|
|
103
|
-
const AgxMaxEv = float( 4.026069 );
|
|
104
|
-
colortone.mulAssign( exposure );
|
|
105
|
-
colortone.assign( LINEAR_SRGB_TO_LINEAR_REC2020.mul( colortone ) );
|
|
106
|
-
colortone.assign( AgXInsetMatrix.mul( colortone ) );
|
|
107
|
-
colortone.assign( max( colortone, 1e-10 ) );
|
|
108
|
-
colortone.assign( log2( colortone ) );
|
|
109
|
-
colortone.assign( colortone.sub( AgxMinEv ).div( AgxMaxEv.sub( AgxMinEv ) ) );
|
|
110
|
-
colortone.assign( clamp( colortone, 0.0, 1.0 ) );
|
|
111
|
-
colortone.assign( agxDefaultContrastApprox( colortone ) );
|
|
112
|
-
colortone.assign( AgXOutsetMatrix.mul( colortone ) );
|
|
113
|
-
colortone.assign( pow( max( vec3( 0.0 ), colortone ), vec3( 2.2 ) ) );
|
|
114
|
-
colortone.assign( LINEAR_REC2020_TO_LINEAR_SRGB.mul( colortone ) );
|
|
115
|
-
colortone.assign( clamp( colortone, 0.0, 1.0 ) );
|
|
116
|
-
|
|
117
|
-
return colortone;
|
|
118
|
-
|
|
119
|
-
} );
|
|
120
|
-
|
|
121
|
-
// https://modelviewer.dev/examples/tone-mapping
|
|
122
|
-
|
|
123
|
-
const NeutralToneMappingNode = tslFn( ( { color, exposure } ) => {
|
|
124
|
-
|
|
125
|
-
const StartCompression = float( 0.8 - 0.04 );
|
|
126
|
-
const Desaturation = float( 0.15 );
|
|
127
|
-
|
|
128
|
-
color = color.mul( exposure );
|
|
129
|
-
|
|
130
|
-
const x = min( color.r, min( color.g, color.b ) );
|
|
131
|
-
const offset = cond( x.lessThan( 0.08 ), x.sub( mul( 6.25, x.mul( x ) ) ), 0.04 );
|
|
132
|
-
|
|
133
|
-
color.subAssign( offset );
|
|
134
|
-
|
|
135
|
-
const peak = max( color.r, max( color.g, color.b ) );
|
|
136
|
-
|
|
137
|
-
If( peak.lessThan( StartCompression ), () => {
|
|
138
|
-
|
|
139
|
-
return color;
|
|
140
|
-
|
|
141
|
-
} );
|
|
142
|
-
|
|
143
|
-
const d = sub( 1, StartCompression );
|
|
144
|
-
const newPeak = sub( 1, d.mul( d ).div( peak.add( d.sub( StartCompression ) ) ) );
|
|
145
|
-
color.mulAssign( newPeak.div( peak ) );
|
|
146
|
-
const g = sub( 1, div( 1, Desaturation.mul( peak.sub( newPeak ) ).add( 1 ) ) );
|
|
147
|
-
|
|
148
|
-
return mix( color, vec3( newPeak ), g );
|
|
8
|
+
class ToneMappingNode extends TempNode {
|
|
149
9
|
|
|
150
|
-
|
|
151
|
-
name: 'NeutralToneMapping',
|
|
152
|
-
type: 'vec3',
|
|
153
|
-
inputs: [
|
|
154
|
-
{ name: 'color', type: 'vec3' },
|
|
155
|
-
{ name: 'exposure', type: 'float' }
|
|
156
|
-
]
|
|
157
|
-
} );
|
|
10
|
+
static get type() {
|
|
158
11
|
|
|
159
|
-
|
|
160
|
-
[ LinearToneMapping ]: LinearToneMappingNode,
|
|
161
|
-
[ ReinhardToneMapping ]: ReinhardToneMappingNode,
|
|
162
|
-
[ CineonToneMapping ]: OptimizedCineonToneMappingNode,
|
|
163
|
-
[ ACESFilmicToneMapping ]: ACESFilmicToneMappingNode,
|
|
164
|
-
[ AgXToneMapping ]: AGXToneMappingNode,
|
|
165
|
-
[ NeutralToneMapping ]: NeutralToneMappingNode
|
|
166
|
-
};
|
|
12
|
+
return 'ToneMappingNode';
|
|
167
13
|
|
|
168
|
-
|
|
14
|
+
}
|
|
169
15
|
|
|
170
|
-
constructor( toneMapping
|
|
16
|
+
constructor( toneMapping, exposureNode = toneMappingExposure, colorNode = null ) {
|
|
171
17
|
|
|
172
18
|
super( 'vec3' );
|
|
173
19
|
|
|
@@ -180,10 +26,7 @@ class ToneMappingNode extends TempNode {
|
|
|
180
26
|
|
|
181
27
|
getCacheKey() {
|
|
182
28
|
|
|
183
|
-
|
|
184
|
-
cacheKey = '{toneMapping:' + this.toneMapping + ',nodes:' + cacheKey + '}';
|
|
185
|
-
|
|
186
|
-
return cacheKey;
|
|
29
|
+
return hash( super.getCacheKey(), this.toneMapping );
|
|
187
30
|
|
|
188
31
|
}
|
|
189
32
|
|
|
@@ -194,14 +37,13 @@ class ToneMappingNode extends TempNode {
|
|
|
194
37
|
|
|
195
38
|
if ( toneMapping === NoToneMapping ) return colorNode;
|
|
196
39
|
|
|
197
|
-
const toneMappingParams = { exposure: this.exposureNode, color: colorNode };
|
|
198
|
-
const toneMappingNode = toneMappingLib[ toneMapping ];
|
|
199
|
-
|
|
200
40
|
let outputNode = null;
|
|
201
41
|
|
|
202
|
-
|
|
42
|
+
const toneMappingFn = builder.renderer.nodes.library.getToneMappingFunction( toneMapping );
|
|
43
|
+
|
|
44
|
+
if ( toneMappingFn !== null ) {
|
|
203
45
|
|
|
204
|
-
outputNode =
|
|
46
|
+
outputNode = vec4( toneMappingFn( colorNode.rgb, this.exposureNode ), colorNode.a );
|
|
205
47
|
|
|
206
48
|
} else {
|
|
207
49
|
|
|
@@ -220,8 +62,6 @@ class ToneMappingNode extends TempNode {
|
|
|
220
62
|
export default ToneMappingNode;
|
|
221
63
|
|
|
222
64
|
export const toneMapping = ( mapping, exposure, color ) => nodeObject( new ToneMappingNode( mapping, nodeObject( exposure ), nodeObject( color ) ) );
|
|
223
|
-
export const toneMappingExposure = rendererReference( 'toneMappingExposure', 'float' );
|
|
224
|
-
|
|
225
|
-
addNodeElement( 'toneMapping', ( color, mapping, exposure ) => toneMapping( mapping, exposure, color ) );
|
|
65
|
+
export const toneMappingExposure = /*@__PURE__*/ rendererReference( 'toneMappingExposure', 'float' );
|
|
226
66
|
|
|
227
|
-
|
|
67
|
+
addMethodChaining( 'toneMapping', ( color, mapping, exposure ) => toneMapping( mapping, exposure, color ) );
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { float, nodeObject, normalize, vec4 } from '../tsl/TSLBase.js';
|
|
2
|
+
import { Color } from '../../math/Color.js';
|
|
3
|
+
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
|
4
|
+
import { cameraProjectionMatrix } from '../../nodes/accessors/Camera.js';
|
|
5
|
+
import { modelViewMatrix } from '../../nodes/accessors/ModelNode.js';
|
|
6
|
+
import { positionLocal } from '../../nodes/accessors/Position.js';
|
|
7
|
+
import { normalLocal } from '../../nodes/accessors/Normal.js';
|
|
8
|
+
import { BackSide } from '../../constants.js';
|
|
9
|
+
import PassNode from './PassNode.js';
|
|
10
|
+
|
|
11
|
+
class ToonOutlinePassNode extends PassNode {
|
|
12
|
+
|
|
13
|
+
static get type() {
|
|
14
|
+
|
|
15
|
+
return 'ToonOutlinePassNode';
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
constructor( scene, camera, colorNode, thicknessNode, alphaNode ) {
|
|
20
|
+
|
|
21
|
+
super( PassNode.COLOR, scene, camera );
|
|
22
|
+
|
|
23
|
+
this.colorNode = colorNode;
|
|
24
|
+
this.thicknessNode = thicknessNode;
|
|
25
|
+
this.alphaNode = alphaNode;
|
|
26
|
+
|
|
27
|
+
this._materialCache = new WeakMap();
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
updateBefore( frame ) {
|
|
32
|
+
|
|
33
|
+
const { renderer } = frame;
|
|
34
|
+
|
|
35
|
+
const currentRenderObjectFunction = renderer.getRenderObjectFunction();
|
|
36
|
+
|
|
37
|
+
renderer.setRenderObjectFunction( ( object, scene, camera, geometry, material, group, lightsNode ) => {
|
|
38
|
+
|
|
39
|
+
// only render outline for supported materials
|
|
40
|
+
|
|
41
|
+
if ( material.isMeshToonMaterial || material.isMeshToonNodeMaterial ) {
|
|
42
|
+
|
|
43
|
+
if ( material.wireframe === false ) {
|
|
44
|
+
|
|
45
|
+
const outlineMaterial = this._getOutlineMaterial( material );
|
|
46
|
+
renderer.renderObject( object, scene, camera, geometry, outlineMaterial, group, lightsNode );
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// default
|
|
53
|
+
|
|
54
|
+
renderer.renderObject( object, scene, camera, geometry, material, group, lightsNode );
|
|
55
|
+
|
|
56
|
+
} );
|
|
57
|
+
|
|
58
|
+
super.updateBefore( frame );
|
|
59
|
+
|
|
60
|
+
renderer.setRenderObjectFunction( currentRenderObjectFunction );
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
_createMaterial() {
|
|
65
|
+
|
|
66
|
+
const material = new NodeMaterial();
|
|
67
|
+
material.isMeshToonOutlineMaterial = true;
|
|
68
|
+
material.name = 'Toon_Outline';
|
|
69
|
+
material.side = BackSide;
|
|
70
|
+
|
|
71
|
+
// vertex node
|
|
72
|
+
|
|
73
|
+
const outlineNormal = normalLocal.negate();
|
|
74
|
+
const mvp = cameraProjectionMatrix.mul( modelViewMatrix );
|
|
75
|
+
|
|
76
|
+
const ratio = float( 1.0 ); // TODO: support outline thickness ratio for each vertex
|
|
77
|
+
const pos = mvp.mul( vec4( positionLocal, 1.0 ) );
|
|
78
|
+
const pos2 = mvp.mul( vec4( positionLocal.add( outlineNormal ), 1.0 ) );
|
|
79
|
+
const norm = normalize( pos.sub( pos2 ) ); // NOTE: subtract pos2 from pos because BackSide objectNormal is negative
|
|
80
|
+
|
|
81
|
+
material.vertexNode = pos.add( norm.mul( this.thicknessNode ).mul( pos.w ).mul( ratio ) );
|
|
82
|
+
|
|
83
|
+
// color node
|
|
84
|
+
|
|
85
|
+
material.colorNode = vec4( this.colorNode, this.alphaNode );
|
|
86
|
+
|
|
87
|
+
return material;
|
|
88
|
+
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
_getOutlineMaterial( originalMaterial ) {
|
|
92
|
+
|
|
93
|
+
let outlineMaterial = this._materialCache.get( originalMaterial );
|
|
94
|
+
|
|
95
|
+
if ( outlineMaterial === undefined ) {
|
|
96
|
+
|
|
97
|
+
outlineMaterial = this._createMaterial();
|
|
98
|
+
|
|
99
|
+
this._materialCache.set( originalMaterial, outlineMaterial );
|
|
100
|
+
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return outlineMaterial;
|
|
104
|
+
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export default ToonOutlinePassNode;
|
|
110
|
+
|
|
111
|
+
export const toonOutlinePass = ( scene, camera, color = new Color( 0, 0, 0 ), thickness = 0.003, alpha = 1 ) => nodeObject( new ToonOutlinePassNode( scene, camera, nodeObject( color ), nodeObject( thickness ), nodeObject( alpha ) ) );
|
|
@@ -1,11 +1,18 @@
|
|
|
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, float, int, vec4, If } from '../tsl/TSLBase.js';
|
|
4
4
|
import { clamp, mix } from '../math/MathNode.js';
|
|
5
5
|
import { sub } from '../math/OperatorNode.js';
|
|
6
|
+
import { convertToTexture } from '../utils/RTTNode.js';
|
|
6
7
|
|
|
7
8
|
class TransitionNode extends TempNode {
|
|
8
9
|
|
|
10
|
+
static get type() {
|
|
11
|
+
|
|
12
|
+
return 'TransitionNode';
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
9
16
|
constructor( textureNodeA, textureNodeB, mixTextureNode, mixRatioNode, thresholdNode, useTextureNode ) {
|
|
10
17
|
|
|
11
18
|
super();
|
|
@@ -35,7 +42,7 @@ class TransitionNode extends TempNode {
|
|
|
35
42
|
|
|
36
43
|
};
|
|
37
44
|
|
|
38
|
-
const transition =
|
|
45
|
+
const transition = Fn( () => {
|
|
39
46
|
|
|
40
47
|
const texelOne = sampleTexture( textureNodeA );
|
|
41
48
|
const texelTwo = sampleTexture( textureNodeB );
|
|
@@ -50,7 +57,7 @@ class TransitionNode extends TempNode {
|
|
|
50
57
|
|
|
51
58
|
color.assign( mix( texelOne, texelTwo, mixf ) );
|
|
52
59
|
|
|
53
|
-
} ).
|
|
60
|
+
} ).Else( () => {
|
|
54
61
|
|
|
55
62
|
color.assign( mix( texelTwo, texelOne, mixRatioNode ) );
|
|
56
63
|
|
|
@@ -68,9 +75,6 @@ class TransitionNode extends TempNode {
|
|
|
68
75
|
|
|
69
76
|
}
|
|
70
77
|
|
|
71
|
-
export const transition = ( nodeA, nodeB, mixTexture, mixRatio = 0.0, threshold = 0.1, useTexture = 0 ) => nodeObject( new TransitionNode( nodeObject( nodeA ).toTexture(), nodeObject( nodeB ).toTexture(), nodeObject( mixTexture ).toTexture(), nodeObject( mixRatio ), nodeObject( threshold ), nodeObject( useTexture ) ) );
|
|
72
|
-
|
|
73
|
-
addNodeElement( 'transition', transition );
|
|
74
|
-
|
|
75
78
|
export default TransitionNode;
|
|
76
79
|
|
|
80
|
+
export const transition = ( nodeA, nodeB, mixTexture, mixRatio = 0.0, threshold = 0.1, useTexture = 0 ) => nodeObject( new TransitionNode( convertToTexture( nodeA ), convertToTexture( nodeB ), convertToTexture( mixTexture ), nodeObject( mixRatio ), nodeObject( threshold ), nodeObject( useTexture ) ) );
|