super-three 0.167.0 → 0.169.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/three.cjs +532 -173
- package/build/three.module.js +532 -174
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +18173 -14266
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +79941 -0
- package/build/three.webgpu.nodes.min.js +6 -0
- package/examples/jsm/Addons.js +0 -4
- package/examples/jsm/animation/AnimationClipCreator.js +1 -1
- package/examples/jsm/capabilities/WebGL.js +27 -21
- package/examples/jsm/controls/ArcballControls.js +174 -158
- package/examples/jsm/controls/DragControls.js +260 -132
- package/examples/jsm/controls/FirstPersonControls.js +175 -163
- package/examples/jsm/controls/FlyControls.js +194 -188
- package/examples/jsm/controls/OrbitControls.js +777 -786
- package/examples/jsm/controls/PointerLockControls.js +24 -15
- package/examples/jsm/controls/TrackballControls.js +469 -448
- package/examples/jsm/controls/TransformControls.js +97 -62
- package/examples/jsm/effects/AnaglyphEffect.js +6 -13
- package/examples/jsm/effects/ParallaxBarrierEffect.js +17 -11
- package/examples/jsm/effects/StereoEffect.js +6 -1
- package/examples/jsm/environments/RoomEnvironment.js +1 -1
- package/examples/jsm/exporters/DRACOExporter.js +4 -2
- package/examples/jsm/exporters/EXRExporter.js +19 -11
- package/examples/jsm/exporters/GLTFExporter.js +6 -1
- package/examples/jsm/exporters/KTX2Exporter.js +21 -13
- package/examples/jsm/exporters/OBJExporter.js +5 -1
- package/examples/jsm/exporters/PLYExporter.js +9 -7
- package/examples/jsm/exporters/USDZExporter.js +29 -8
- package/examples/jsm/geometries/DecalGeometry.js +4 -1
- package/examples/jsm/geometries/InstancedPointsGeometry.js +1 -1
- package/examples/jsm/helpers/LightProbeHelper.js +43 -44
- package/examples/jsm/helpers/LightProbeHelperGPU.js +65 -0
- package/examples/jsm/libs/basis/basis_transcoder.js +8 -10
- package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
- package/examples/jsm/libs/ktx-parse.module.js +1 -1
- package/examples/jsm/lights/LightProbeGenerator.js +24 -10
- package/examples/jsm/loaders/ColladaLoader.js +9 -6
- package/examples/jsm/loaders/DRACOLoader.js +3 -1
- package/examples/jsm/loaders/FBXLoader.js +30 -20
- package/examples/jsm/loaders/GLTFLoader.js +5 -10
- package/examples/jsm/loaders/KTX2Loader.js +27 -12
- package/examples/jsm/loaders/MTLLoader.js +4 -3
- package/examples/jsm/loaders/MaterialXLoader.js +40 -14
- package/examples/jsm/loaders/OBJLoader.js +5 -3
- package/examples/jsm/loaders/PCDLoader.js +14 -13
- package/examples/jsm/loaders/PDBLoader.js +3 -2
- package/examples/jsm/loaders/PLYLoader.js +8 -5
- package/examples/jsm/loaders/STLLoader.js +3 -2
- package/examples/jsm/loaders/VRMLLoader.js +10 -10
- package/examples/jsm/loaders/VTKLoader.js +4 -3
- package/examples/jsm/loaders/XYZLoader.js +3 -2
- package/examples/jsm/misc/Timer.js +1 -1
- package/examples/jsm/modifiers/CurveModifierGPU.js +233 -0
- package/examples/jsm/objects/LensflareMesh.js +322 -0
- package/examples/jsm/objects/SkyMesh.js +187 -0
- package/examples/jsm/objects/Water2Mesh.js +158 -0
- package/examples/jsm/objects/WaterMesh.js +101 -0
- package/examples/jsm/physics/JoltPhysics.js +1 -1
- package/examples/jsm/physics/RapierPhysics.js +21 -1
- package/examples/jsm/postprocessing/OutlinePass.js +31 -46
- package/examples/jsm/postprocessing/SSAARenderPass.js +3 -1
- package/examples/jsm/shaders/BleachBypassShader.js +1 -2
- package/examples/jsm/shaders/OutputShader.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -2
- package/examples/jsm/transpiler/TSLEncoder.js +8 -8
- package/examples/jsm/utils/GeometryCompressionUtils.js +37 -122
- package/examples/jsm/utils/ShadowMapViewer.js +3 -8
- package/examples/jsm/utils/ShadowMapViewerGPU.js +201 -0
- package/examples/jsm/utils/SkeletonUtils.js +84 -66
- package/examples/jsm/utils/TextureUtils.js +2 -1
- package/examples/jsm/utils/TextureUtilsGPU.js +63 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
- package/package.json +3 -2
- package/src/Three.WebGPU.Nodes.js +200 -0
- package/src/Three.WebGPU.js +7 -0
- package/src/Three.js +1 -0
- package/src/audio/Audio.js +2 -2
- package/src/constants.js +1 -1
- package/src/core/BufferAttribute.js +0 -9
- package/src/core/Clock.js +1 -1
- package/src/core/InterleavedBuffer.js +0 -9
- package/src/extras/Controls.js +32 -0
- package/src/geometries/CylinderGeometry.js +11 -4
- package/src/loaders/MaterialLoader.js +7 -1
- package/src/loaders/ObjectLoader.js +3 -3
- package/src/{nodes/loaders → loaders/nodes}/NodeLoader.js +25 -5
- package/src/{nodes/loaders → loaders/nodes}/NodeMaterialLoader.js +21 -18
- package/src/{nodes/loaders → loaders/nodes}/NodeObjectLoader.js +19 -0
- package/src/materials/Material.js +4 -7
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +156 -0
- package/src/{nodes/materials → materials/nodes}/Line2NodeMaterial.js +56 -59
- package/src/{nodes/materials → materials/nodes}/LineBasicNodeMaterial.js +8 -5
- package/src/{nodes/materials → materials/nodes}/LineDashedNodeMaterial.js +12 -10
- package/src/{nodes/materials → materials/nodes}/MeshBasicNodeMaterial.js +16 -12
- package/src/{nodes/materials → materials/nodes}/MeshLambertNodeMaterial.js +10 -6
- package/src/{nodes/materials → materials/nodes}/MeshMatcapNodeMaterial.js +13 -9
- package/src/{nodes/materials → materials/nodes}/MeshNormalNodeMaterial.js +13 -9
- package/src/{nodes/materials → materials/nodes}/MeshPhongNodeMaterial.js +14 -9
- package/src/{nodes/materials → materials/nodes}/MeshPhysicalNodeMaterial.js +22 -18
- package/src/{nodes/materials → materials/nodes}/MeshSSSNodeMaterial.js +10 -7
- package/src/{nodes/materials → materials/nodes}/MeshStandardNodeMaterial.js +22 -12
- package/src/{nodes/materials → materials/nodes}/MeshToonNodeMaterial.js +9 -5
- package/src/{nodes/materials → materials/nodes}/NodeMaterial.js +71 -115
- package/src/{nodes/materials/Materials.js → materials/nodes/NodeMaterials.js} +3 -1
- package/src/{nodes/materials → materials/nodes}/PointsNodeMaterial.js +8 -5
- package/src/{nodes/materials → materials/nodes}/ShadowNodeMaterial.js +9 -5
- package/src/{nodes/materials → materials/nodes}/SpriteNodeMaterial.js +47 -14
- package/src/{nodes/materials → materials/nodes}/VolumeNodeMaterial.js +24 -22
- package/src/materials/nodes/manager/NodeMaterialObserver.js +302 -0
- package/src/math/Triangle.js +24 -0
- package/src/nodes/Nodes.js +103 -159
- package/src/nodes/TSL.js +179 -0
- package/src/nodes/accessors/AccessorsUtils.js +8 -8
- package/src/nodes/accessors/BatchNode.js +53 -21
- package/src/nodes/accessors/{BitangentNode.js → Bitangent.js} +9 -9
- package/src/nodes/accessors/BufferAttributeNode.js +8 -5
- package/src/nodes/accessors/BufferNode.js +7 -4
- package/src/nodes/accessors/Camera.js +13 -0
- package/src/nodes/accessors/ClippingNode.js +19 -13
- package/src/nodes/accessors/CubeTextureNode.js +9 -8
- package/src/nodes/accessors/InstanceNode.js +19 -15
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +8 -5
- package/src/nodes/accessors/Lights.js +51 -0
- package/src/nodes/accessors/MaterialNode.js +56 -55
- package/src/nodes/accessors/MaterialProperties.js +3 -0
- package/src/nodes/accessors/MaterialReferenceNode.js +9 -4
- package/src/nodes/accessors/ModelNode.js +47 -12
- package/src/nodes/accessors/ModelViewProjectionNode.js +12 -9
- package/src/nodes/accessors/MorphNode.js +17 -13
- package/src/nodes/accessors/Normal.js +88 -0
- package/src/nodes/accessors/Object3DNode.js +17 -33
- package/src/nodes/accessors/PointUVNode.js +9 -5
- package/src/nodes/accessors/Position.js +10 -0
- package/src/nodes/accessors/ReferenceBaseNode.js +171 -0
- package/src/nodes/accessors/ReferenceNode.js +50 -7
- package/src/nodes/accessors/ReflectVector.js +10 -0
- package/src/nodes/accessors/RendererReferenceNode.js +12 -6
- package/src/nodes/accessors/SceneNode.js +9 -6
- package/src/nodes/accessors/SkinningNode.js +88 -21
- package/src/nodes/accessors/StorageBufferNode.js +22 -5
- package/src/nodes/accessors/StorageTextureNode.js +9 -6
- package/src/nodes/accessors/Tangent.js +22 -0
- package/src/nodes/accessors/Texture3DNode.js +16 -13
- package/src/nodes/accessors/{TextureBicubicNode.js → TextureBicubic.js} +3 -32
- package/src/nodes/accessors/TextureNode.js +29 -23
- package/src/nodes/accessors/TextureSizeNode.js +10 -9
- package/src/nodes/accessors/{UniformsNode.js → UniformArrayNode.js} +26 -14
- package/src/nodes/accessors/UserDataNode.js +10 -7
- package/src/nodes/accessors/VelocityNode.js +134 -0
- package/src/nodes/accessors/VertexColorNode.js +7 -4
- package/src/nodes/code/CodeNode.js +9 -5
- package/src/nodes/code/ExpressionNode.js +10 -6
- package/src/nodes/code/FunctionCallNode.js +8 -5
- package/src/nodes/code/FunctionNode.js +8 -23
- package/src/nodes/code/ScriptableNode.js +13 -10
- package/src/nodes/code/ScriptableValueNode.js +9 -7
- package/src/nodes/core/AssignNode.js +12 -9
- package/src/nodes/core/AttributeNode.js +12 -21
- package/src/nodes/core/BypassNode.js +11 -7
- package/src/nodes/core/CacheNode.js +10 -6
- package/src/nodes/core/ConstNode.js +6 -3
- package/src/nodes/core/ContextNode.js +21 -11
- package/src/nodes/core/IndexNode.js +35 -8
- package/src/nodes/core/InputNode.js +7 -3
- package/src/nodes/core/MRTNode.js +16 -7
- package/src/nodes/core/Node.js +19 -40
- package/src/nodes/core/NodeBuilder.js +117 -38
- package/src/nodes/core/NodeUtils.js +49 -6
- package/src/nodes/core/OutputStructNode.js +10 -6
- package/src/nodes/core/ParameterNode.js +7 -4
- package/src/nodes/core/PropertyNode.js +36 -32
- package/src/nodes/core/StackNode.js +31 -11
- package/src/nodes/core/StructTypeNode.js +7 -3
- package/src/nodes/core/TempNode.js +8 -4
- package/src/nodes/core/UniformGroupNode.js +14 -11
- package/src/nodes/core/UniformNode.js +7 -4
- package/src/nodes/core/VarNode.js +12 -8
- package/src/nodes/core/VaryingNode.js +10 -6
- package/src/nodes/display/AfterImageNode.js +15 -9
- package/src/nodes/display/AnaglyphPassNode.js +67 -0
- package/src/nodes/display/AnamorphicNode.js +17 -11
- package/src/nodes/display/BleachBypass.js +26 -0
- package/src/nodes/display/BlendMode.js +54 -0
- package/src/nodes/display/BloomNode.js +27 -19
- package/src/nodes/display/BumpMapNode.js +13 -12
- package/src/nodes/display/ColorAdjustment.js +46 -0
- package/src/nodes/display/ColorSpaceFunctions.js +38 -0
- package/src/nodes/display/ColorSpaceNode.js +67 -61
- package/src/nodes/display/DenoiseNode.js +23 -17
- package/src/nodes/display/DepthOfFieldNode.js +12 -7
- package/src/nodes/display/DotScreenNode.js +13 -22
- package/src/nodes/display/FXAANode.js +21 -16
- package/src/nodes/display/FilmNode.js +11 -7
- package/src/nodes/display/FrontFacingNode.js +10 -6
- package/src/nodes/display/GTAONode.js +22 -15
- package/src/nodes/display/GaussianBlurNode.js +14 -8
- package/src/nodes/display/Lut3DNode.js +10 -6
- package/src/nodes/display/MotionBlur.js +25 -0
- package/src/nodes/display/NormalMapNode.js +13 -13
- package/src/nodes/display/ParallaxBarrierPassNode.js +58 -0
- package/src/nodes/display/PassNode.js +95 -8
- package/src/nodes/display/PixelationPassNode.js +20 -8
- package/src/nodes/display/PosterizeNode.js +8 -7
- package/src/nodes/display/RGBShiftNode.js +11 -7
- package/src/nodes/display/RenderOutputNode.js +15 -11
- package/src/nodes/display/SSAAPassNode.js +287 -0
- package/src/nodes/display/ScreenNode.js +181 -0
- package/src/nodes/display/Sepia.js +17 -0
- package/src/nodes/display/SobelOperatorNode.js +13 -8
- package/src/nodes/display/StereoCompositePassNode.js +110 -0
- package/src/nodes/display/StereoPassNode.js +83 -0
- package/src/nodes/display/ToneMappingFunctions.js +190 -0
- package/src/nodes/display/ToneMappingNode.js +15 -175
- package/src/nodes/display/ToonOutlinePassNode.js +111 -0
- package/src/nodes/display/TransitionNode.js +12 -8
- package/src/nodes/display/ViewportDepthNode.js +34 -29
- package/src/nodes/display/ViewportDepthTextureNode.js +10 -9
- package/src/nodes/display/ViewportSharedTextureNode.js +10 -9
- package/src/nodes/display/ViewportTextureNode.js +11 -11
- package/src/nodes/fog/FogExp2Node.js +8 -7
- package/src/nodes/fog/FogNode.js +10 -8
- package/src/nodes/fog/FogRangeNode.js +8 -7
- package/src/nodes/functions/BSDF/BRDF_GGX.js +4 -4
- package/src/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +6 -6
- package/src/nodes/functions/BSDF/DFGApprox.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +3 -3
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/F_Schlick.js +2 -2
- package/src/nodes/functions/BSDF/LTC.js +6 -6
- package/src/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
- package/src/nodes/functions/BasicLightingModel.js +1 -1
- package/src/nodes/functions/PhongLightingModel.js +5 -5
- package/src/nodes/functions/PhysicalLightingModel.js +34 -33
- package/src/nodes/functions/ShadowMaskModel.js +1 -1
- package/src/nodes/functions/ToonLightingModel.js +3 -3
- package/src/nodes/functions/material/getGeometryRoughness.js +4 -4
- package/src/nodes/functions/material/getRoughness.js +2 -2
- package/src/nodes/functions/material/getShIrradianceAt.js +28 -0
- package/src/nodes/geometry/RangeNode.js +9 -5
- package/src/nodes/gpgpu/AtomicFunctionNode.js +99 -0
- package/src/nodes/gpgpu/BarrierNode.js +40 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +98 -0
- package/src/nodes/gpgpu/ComputeNode.js +10 -6
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +100 -0
- package/src/nodes/lighting/AONode.js +6 -3
- package/src/nodes/lighting/AmbientLightNode.js +6 -8
- package/src/nodes/lighting/AnalyticLightNode.js +225 -36
- package/src/nodes/lighting/BasicEnvironmentNode.js +8 -4
- package/src/nodes/lighting/BasicLightMapNode.js +7 -4
- package/src/nodes/lighting/DirectionalLightNode.js +7 -9
- package/src/nodes/lighting/EnvironmentNode.js +23 -19
- package/src/nodes/lighting/HemisphereLightNode.js +11 -11
- package/src/nodes/lighting/IESSpotLightNode.js +7 -9
- package/src/nodes/lighting/IrradianceNode.js +6 -3
- package/src/nodes/lighting/LightProbeNode.js +53 -0
- package/src/nodes/lighting/LightUtils.js +3 -3
- package/src/nodes/lighting/LightingContextNode.js +19 -18
- package/src/nodes/lighting/LightingNode.js +7 -3
- package/src/nodes/lighting/LightsNode.js +112 -75
- package/src/nodes/lighting/PointLightNode.js +12 -13
- package/src/nodes/lighting/RectAreaLightNode.js +11 -11
- package/src/nodes/lighting/SpotLightNode.js +14 -16
- package/src/nodes/materialx/MaterialXNodes.js +2 -2
- package/src/nodes/materialx/lib/mx_hsv.js +36 -31
- package/src/nodes/materialx/lib/mx_noise.js +96 -96
- package/src/nodes/materialx/lib/mx_transform_color.js +2 -2
- package/src/nodes/math/{CondNode.js → ConditionalNode.js} +38 -10
- package/src/nodes/math/Hash.js +13 -0
- package/src/nodes/math/MathNode.js +127 -124
- package/src/nodes/math/MathUtils.js +0 -7
- package/src/nodes/math/OperatorNode.js +97 -52
- package/src/nodes/math/TriNoise3D.js +19 -29
- package/src/nodes/pmrem/PMREMNode.js +61 -15
- package/src/nodes/pmrem/PMREMUtils.js +46 -46
- package/src/nodes/procedural/Checker.js +14 -0
- package/src/nodes/tsl/TSLBase.js +30 -0
- package/src/nodes/{shadernode/ShaderNode.js → tsl/TSLCore.js} +105 -97
- package/src/nodes/utils/ArrayElementNode.js +8 -4
- package/src/nodes/utils/ConvertNode.js +7 -3
- package/src/nodes/utils/CubeMapNode.js +160 -0
- package/src/nodes/utils/Discard.js +8 -0
- package/src/nodes/utils/EquirectUVNode.js +9 -6
- package/src/nodes/utils/FlipNode.js +68 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +9 -5
- package/src/nodes/utils/JoinNode.js +6 -3
- package/src/nodes/utils/LoopNode.js +16 -6
- package/src/nodes/utils/MatcapUVNode.js +10 -7
- package/src/nodes/utils/MaxMipLevelNode.js +8 -5
- package/src/nodes/utils/OscNode.js +12 -8
- package/src/nodes/utils/Packing.js +4 -0
- package/src/nodes/utils/RTTNode.js +11 -8
- package/src/nodes/utils/ReflectorNode.js +12 -4
- package/src/nodes/utils/RemapNode.js +12 -8
- package/src/nodes/utils/RotateNode.js +8 -13
- package/src/nodes/utils/SetNode.js +7 -4
- package/src/nodes/utils/SplitNode.js +7 -3
- package/src/nodes/utils/SpriteSheetUVNode.js +10 -6
- package/src/nodes/utils/SpriteUtils.js +47 -0
- package/src/nodes/utils/StorageArrayElementNode.js +11 -12
- package/src/nodes/utils/TimerNode.js +8 -5
- package/src/nodes/utils/TriplanarTexturesNode.js +11 -9
- package/src/nodes/utils/UVUtils.js +19 -0
- package/src/nodes/utils/ViewportUtils.js +14 -0
- package/src/objects/BatchedMesh.js +78 -13
- package/src/objects/LOD.js +21 -0
- package/src/objects/Line.js +1 -0
- package/src/objects/Mesh.js +7 -23
- package/src/objects/Points.js +2 -0
- package/src/renderers/WebGLRenderer.js +88 -41
- package/src/renderers/common/Backend.js +2 -2
- package/src/renderers/common/Background.js +3 -1
- package/src/renderers/common/BindGroup.js +3 -1
- package/src/renderers/common/Bindings.js +13 -15
- package/src/renderers/common/BundleGroup.js +26 -0
- package/src/renderers/common/ClippingContext.js +15 -5
- package/src/renderers/common/CubeRenderTarget.js +9 -3
- package/src/renderers/common/PostProcessing.js +4 -1
- package/src/renderers/common/QuadMesh.js +2 -0
- package/src/renderers/common/RenderContext.js +23 -0
- package/src/renderers/common/RenderList.js +1 -1
- package/src/renderers/common/RenderObject.js +117 -6
- package/src/renderers/common/RenderObjects.js +8 -1
- package/src/renderers/common/Renderer.js +128 -94
- package/src/renderers/common/SampledTexture.js +12 -3
- package/src/renderers/common/Textures.js +8 -12
- package/src/renderers/common/extras/PMREMGenerator.js +19 -22
- package/src/renderers/common/nodes/NodeBuilderState.js +4 -4
- package/src/renderers/common/nodes/NodeLibrary.js +118 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +2 -2
- package/src/renderers/common/nodes/Nodes.js +65 -19
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +2 -4
- package/src/renderers/webgl/WebGLAttributes.js +45 -14
- package/src/renderers/webgl/WebGLCapabilities.js +9 -0
- package/src/renderers/webgl/WebGLProgram.js +3 -1
- package/src/renderers/webgl/WebGLPrograms.js +21 -17
- package/src/renderers/webgl/WebGLProperties.js +7 -0
- package/src/renderers/webgl/WebGLState.js +21 -0
- package/src/renderers/webgl/WebGLTextures.js +83 -4
- package/src/renderers/webgl-fallback/WebGLBackend.js +135 -110
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +60 -12
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +6 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +20 -2
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +89 -37
- package/src/renderers/webgpu/WebGPUBackend.js +112 -86
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +42 -0
- package/src/renderers/webgpu/WebGPURenderer.js +9 -6
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +59 -0
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +105 -0
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +189 -73
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +6 -16
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -21
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -1
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +7 -16
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +43 -26
- package/src/renderers/webgpu/utils/WebGPUUtils.js +19 -2
- package/src/renderers/webxr/WebXRManager.js +32 -25
- package/src/utils.js +33 -1
- package/examples/jsm/geometries/SDFGeometryGenerator.js +0 -144
- package/examples/jsm/loaders/LogLuvLoader.js +0 -606
- package/examples/jsm/loaders/TiltLoader.js +0 -520
- package/examples/jsm/utils/GPUStatsPanel.js +0 -95
- package/examples/jsm/utils/PackedPhongMaterial.js +0 -178
- package/src/nodes/accessors/CameraNode.js +0 -19
- package/src/nodes/accessors/NormalNode.js +0 -14
- package/src/nodes/accessors/PositionNode.js +0 -10
- package/src/nodes/accessors/ReflectVectorNode.js +0 -10
- package/src/nodes/accessors/TangentNode.js +0 -23
- package/src/nodes/core/NodeKeywords.js +0 -80
- package/src/nodes/display/BlendModeNode.js +0 -128
- package/src/nodes/display/ColorAdjustmentNode.js +0 -104
- package/src/nodes/display/ViewportNode.js +0 -137
- package/src/nodes/lighting/LightNode.js +0 -57
- package/src/nodes/materials/InstancedPointsNodeMaterial.js +0 -162
- package/src/nodes/math/HashNode.js +0 -34
- package/src/nodes/procedural/CheckerNode.js +0 -42
- package/src/nodes/utils/DiscardNode.js +0 -28
- package/src/nodes/utils/PackingNode.js +0 -55
- package/src/nodes/utils/RotateUVNode.js +0 -35
- /package/src/nodes/accessors/{UVNode.js → UV.js} +0 -0
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import LightingNode from './LightingNode.js';
|
|
2
|
-
import { addNodeClass } from '../core/Node.js';
|
|
3
2
|
|
|
4
3
|
class AONode extends LightingNode {
|
|
5
4
|
|
|
5
|
+
static get type() {
|
|
6
|
+
|
|
7
|
+
return 'AONode';
|
|
8
|
+
|
|
9
|
+
}
|
|
10
|
+
|
|
6
11
|
constructor( aoNode = null ) {
|
|
7
12
|
|
|
8
13
|
super();
|
|
@@ -20,5 +25,3 @@ class AONode extends LightingNode {
|
|
|
20
25
|
}
|
|
21
26
|
|
|
22
27
|
export default AONode;
|
|
23
|
-
|
|
24
|
-
addNodeClass( 'AONode', AONode );
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import AnalyticLightNode from './AnalyticLightNode.js';
|
|
2
|
-
import { addLightNode } from './LightsNode.js';
|
|
3
|
-
import { addNodeClass } from '../core/Node.js';
|
|
4
|
-
|
|
5
|
-
import { AmbientLight } from '../../lights/AmbientLight.js';
|
|
6
2
|
|
|
7
3
|
class AmbientLightNode extends AnalyticLightNode {
|
|
8
4
|
|
|
5
|
+
static get type() {
|
|
6
|
+
|
|
7
|
+
return 'AmbientLightNode';
|
|
8
|
+
|
|
9
|
+
}
|
|
10
|
+
|
|
9
11
|
constructor( light = null ) {
|
|
10
12
|
|
|
11
13
|
super( light );
|
|
@@ -21,7 +23,3 @@ class AmbientLightNode extends AnalyticLightNode {
|
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
export default AmbientLightNode;
|
|
24
|
-
|
|
25
|
-
addNodeClass( 'AmbientLightNode', AmbientLightNode );
|
|
26
|
-
|
|
27
|
-
addLightNode( AmbientLight, AmbientLightNode );
|
|
@@ -1,31 +1,35 @@
|
|
|
1
1
|
import LightingNode from './LightingNode.js';
|
|
2
2
|
import { NodeUpdateType } from '../core/constants.js';
|
|
3
3
|
import { uniform } from '../core/UniformNode.js';
|
|
4
|
-
import {
|
|
5
|
-
import { float, vec2, vec3, vec4 } from '../shadernode/ShaderNode.js';
|
|
4
|
+
import { float, vec2, vec3, vec4, If, int, Fn } from '../tsl/TSLBase.js';
|
|
6
5
|
import { reference } from '../accessors/ReferenceNode.js';
|
|
7
6
|
import { texture } from '../accessors/TextureNode.js';
|
|
8
|
-
import { positionWorld } from '../accessors/
|
|
9
|
-
import { normalWorld } from '../accessors/
|
|
10
|
-
import { mix, fract } from '../math/MathNode.js';
|
|
11
|
-
import { add } from '../math/OperatorNode.js';
|
|
7
|
+
import { positionWorld } from '../accessors/Position.js';
|
|
8
|
+
import { normalWorld } from '../accessors/Normal.js';
|
|
9
|
+
import { mix, fract, step, max, clamp, sqrt } from '../math/MathNode.js';
|
|
10
|
+
import { add, sub } from '../math/OperatorNode.js';
|
|
12
11
|
import { Color } from '../../math/Color.js';
|
|
13
12
|
import { DepthTexture } from '../../textures/DepthTexture.js';
|
|
14
|
-
import
|
|
15
|
-
import
|
|
13
|
+
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
|
14
|
+
import QuadMesh from '../../renderers/common/QuadMesh.js';
|
|
15
|
+
import { Loop } from '../utils/LoopNode.js';
|
|
16
|
+
import { screenCoordinate } from '../display/ScreenNode.js';
|
|
17
|
+
import { HalfFloatType, LessCompare, RGFormat, VSMShadowMap, WebGPUCoordinateSystem } from '../../constants.js';
|
|
18
|
+
import { renderGroup } from '../core/UniformGroupNode.js';
|
|
19
|
+
import { hash } from '../core/NodeUtils.js';
|
|
16
20
|
|
|
17
|
-
const BasicShadowMap =
|
|
21
|
+
const BasicShadowMap = Fn( ( { depthTexture, shadowCoord } ) => {
|
|
18
22
|
|
|
19
23
|
return texture( depthTexture, shadowCoord.xy ).compare( shadowCoord.z );
|
|
20
24
|
|
|
21
25
|
} );
|
|
22
26
|
|
|
23
|
-
const PCFShadowMap =
|
|
27
|
+
const PCFShadowMap = Fn( ( { depthTexture, shadowCoord, shadow } ) => {
|
|
24
28
|
|
|
25
29
|
const depthCompare = ( uv, compare ) => texture( depthTexture, uv ).compare( compare );
|
|
26
30
|
|
|
27
|
-
const mapSize = reference( 'mapSize', 'vec2', shadow );
|
|
28
|
-
const radius = reference( 'radius', 'float', shadow );
|
|
31
|
+
const mapSize = reference( 'mapSize', 'vec2', shadow ).setGroup( renderGroup );
|
|
32
|
+
const radius = reference( 'radius', 'float', shadow ).setGroup( renderGroup );
|
|
29
33
|
|
|
30
34
|
const texelSize = vec2( 1 ).div( mapSize );
|
|
31
35
|
const dx0 = texelSize.x.negate().mul( radius );
|
|
@@ -59,11 +63,11 @@ const PCFShadowMap = tslFn( ( { depthTexture, shadowCoord, shadow } ) => {
|
|
|
59
63
|
|
|
60
64
|
} );
|
|
61
65
|
|
|
62
|
-
const PCFSoftShadowMap =
|
|
66
|
+
const PCFSoftShadowMap = Fn( ( { depthTexture, shadowCoord, shadow } ) => {
|
|
63
67
|
|
|
64
68
|
const depthCompare = ( uv, compare ) => texture( depthTexture, uv ).compare( compare );
|
|
65
69
|
|
|
66
|
-
const mapSize = reference( 'mapSize', 'vec2', shadow );
|
|
70
|
+
const mapSize = reference( 'mapSize', 'vec2', shadow ).setGroup( renderGroup );
|
|
67
71
|
|
|
68
72
|
const texelSize = vec2( 1 ).div( mapSize );
|
|
69
73
|
const dx = texelSize.x;
|
|
@@ -115,14 +119,97 @@ const PCFSoftShadowMap = tslFn( ( { depthTexture, shadowCoord, shadow } ) => {
|
|
|
115
119
|
|
|
116
120
|
} );
|
|
117
121
|
|
|
118
|
-
|
|
122
|
+
// VSM
|
|
123
|
+
|
|
124
|
+
const VSMShadowMapNode = Fn( ( { depthTexture, shadowCoord } ) => {
|
|
125
|
+
|
|
126
|
+
const occlusion = float( 1 ).toVar();
|
|
127
|
+
|
|
128
|
+
const distribution = texture( depthTexture ).uv( shadowCoord.xy ).rg;
|
|
129
|
+
|
|
130
|
+
const hardShadow = step( shadowCoord.z, distribution.x );
|
|
131
|
+
|
|
132
|
+
If( hardShadow.notEqual( float( 1.0 ) ), () => {
|
|
133
|
+
|
|
134
|
+
const distance = shadowCoord.z.sub( distribution.x );
|
|
135
|
+
const variance = max( 0, distribution.y.mul( distribution.y ) );
|
|
136
|
+
let softnessProbability = variance.div( variance.add( distance.mul( distance ) ) ); // Chebeyshevs inequality
|
|
137
|
+
softnessProbability = clamp( sub( softnessProbability, 0.3 ).div( 0.95 - 0.3 ) );
|
|
138
|
+
occlusion.assign( clamp( max( hardShadow, softnessProbability ) ) );
|
|
139
|
+
|
|
140
|
+
} );
|
|
141
|
+
|
|
142
|
+
return occlusion;
|
|
143
|
+
|
|
144
|
+
} );
|
|
145
|
+
|
|
146
|
+
const VSMPassVertical = Fn( ( { samples, radius, size, shadowPass } ) => {
|
|
147
|
+
|
|
148
|
+
const mean = float( 0 ).toVar();
|
|
149
|
+
const squaredMean = float( 0 ).toVar();
|
|
150
|
+
|
|
151
|
+
const uvStride = samples.lessThanEqual( float( 1 ) ).select( float( 0 ), float( 2 ).div( samples.sub( 1 ) ) );
|
|
152
|
+
const uvStart = samples.lessThanEqual( float( 1 ) ).select( float( 0 ), float( - 1 ) );
|
|
153
|
+
|
|
154
|
+
Loop( { start: int( 0 ), end: int( samples ), type: 'int', condition: '<' }, ( { i } ) => {
|
|
155
|
+
|
|
156
|
+
const uvOffset = uvStart.add( float( i ).mul( uvStride ) );
|
|
157
|
+
|
|
158
|
+
const depth = shadowPass.uv( add( screenCoordinate.xy, vec2( 0, uvOffset ).mul( radius ) ).div( size ) ).x;
|
|
159
|
+
mean.addAssign( depth );
|
|
160
|
+
squaredMean.addAssign( depth.mul( depth ) );
|
|
161
|
+
|
|
162
|
+
} );
|
|
163
|
+
|
|
164
|
+
mean.divAssign( samples );
|
|
165
|
+
squaredMean.divAssign( samples );
|
|
166
|
+
|
|
167
|
+
const std_dev = sqrt( squaredMean.sub( mean.mul( mean ) ) );
|
|
168
|
+
return vec2( mean, std_dev );
|
|
169
|
+
|
|
170
|
+
} );
|
|
171
|
+
|
|
172
|
+
const VSMPassHorizontal = Fn( ( { samples, radius, size, shadowPass } ) => {
|
|
173
|
+
|
|
174
|
+
const mean = float( 0 ).toVar();
|
|
175
|
+
const squaredMean = float( 0 ).toVar();
|
|
176
|
+
|
|
177
|
+
const uvStride = samples.lessThanEqual( float( 1 ) ).select( float( 0 ), float( 2 ).div( samples.sub( 1 ) ) );
|
|
178
|
+
const uvStart = samples.lessThanEqual( float( 1 ) ).select( float( 0 ), float( - 1 ) );
|
|
179
|
+
|
|
180
|
+
Loop( { start: int( 0 ), end: int( samples ), type: 'int', condition: '<' }, ( { i } ) => {
|
|
181
|
+
|
|
182
|
+
const uvOffset = uvStart.add( float( i ).mul( uvStride ) );
|
|
183
|
+
|
|
184
|
+
const distribution = shadowPass.uv( add( screenCoordinate.xy, vec2( uvOffset, 0 ).mul( radius ) ).div( size ) );
|
|
185
|
+
mean.addAssign( distribution.x );
|
|
186
|
+
squaredMean.addAssign( add( distribution.y.mul( distribution.y ), distribution.x.mul( distribution.x ) ) );
|
|
187
|
+
|
|
188
|
+
} );
|
|
189
|
+
|
|
190
|
+
mean.divAssign( samples );
|
|
191
|
+
squaredMean.divAssign( samples );
|
|
192
|
+
|
|
193
|
+
const std_dev = sqrt( squaredMean.sub( mean.mul( mean ) ) );
|
|
194
|
+
return vec2( mean, std_dev );
|
|
195
|
+
|
|
196
|
+
} );
|
|
197
|
+
|
|
198
|
+
const _shadowFilterLib = [ BasicShadowMap, PCFShadowMap, PCFSoftShadowMap, VSMShadowMapNode ];
|
|
119
199
|
|
|
120
200
|
//
|
|
121
201
|
|
|
122
|
-
let
|
|
202
|
+
let _overrideMaterial = null;
|
|
203
|
+
const _quadMesh = /*@__PURE__*/ new QuadMesh();
|
|
123
204
|
|
|
124
205
|
class AnalyticLightNode extends LightingNode {
|
|
125
206
|
|
|
207
|
+
static get type() {
|
|
208
|
+
|
|
209
|
+
return 'AnalyticLightNode';
|
|
210
|
+
|
|
211
|
+
}
|
|
212
|
+
|
|
126
213
|
constructor( light = null ) {
|
|
127
214
|
|
|
128
215
|
super();
|
|
@@ -132,7 +219,7 @@ class AnalyticLightNode extends LightingNode {
|
|
|
132
219
|
this.light = light;
|
|
133
220
|
|
|
134
221
|
this.color = new Color();
|
|
135
|
-
this.colorNode = uniform( this.color );
|
|
222
|
+
this.colorNode = uniform( this.color ).setGroup( renderGroup );
|
|
136
223
|
|
|
137
224
|
this.baseColorNode = null;
|
|
138
225
|
|
|
@@ -140,13 +227,19 @@ class AnalyticLightNode extends LightingNode {
|
|
|
140
227
|
this.shadowNode = null;
|
|
141
228
|
this.shadowColorNode = null;
|
|
142
229
|
|
|
230
|
+
this.vsmShadowMapVertical = null;
|
|
231
|
+
this.vsmShadowMapHorizontal = null;
|
|
232
|
+
|
|
233
|
+
this.vsmMaterialVertical = null;
|
|
234
|
+
this.vsmMaterialHorizontal = null;
|
|
235
|
+
|
|
143
236
|
this.isAnalyticLightNode = true;
|
|
144
237
|
|
|
145
238
|
}
|
|
146
239
|
|
|
147
240
|
getCacheKey() {
|
|
148
241
|
|
|
149
|
-
return super.getCacheKey()
|
|
242
|
+
return hash( super.getCacheKey(), this.light.id, this.light.castShadow ? 1 : 0 );
|
|
150
243
|
|
|
151
244
|
}
|
|
152
245
|
|
|
@@ -160,36 +253,67 @@ class AnalyticLightNode extends LightingNode {
|
|
|
160
253
|
|
|
161
254
|
const { object, renderer } = builder;
|
|
162
255
|
|
|
256
|
+
if ( renderer.shadowMap.enabled === false ) return;
|
|
257
|
+
|
|
163
258
|
let shadowColorNode = this.shadowColorNode;
|
|
164
259
|
|
|
165
260
|
if ( shadowColorNode === null ) {
|
|
166
261
|
|
|
167
|
-
if (
|
|
262
|
+
if ( _overrideMaterial === null ) {
|
|
168
263
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
264
|
+
_overrideMaterial = new NodeMaterial();
|
|
265
|
+
_overrideMaterial.fragmentNode = vec4( 0, 0, 0, 1 );
|
|
266
|
+
_overrideMaterial.isShadowNodeMaterial = true; // Use to avoid other overrideMaterial override material.fragmentNode unintentionally when using material.shadowNode
|
|
267
|
+
_overrideMaterial.name = 'ShadowMaterial';
|
|
172
268
|
|
|
173
269
|
}
|
|
174
270
|
|
|
271
|
+
const shadowMapType = renderer.shadowMap.type;
|
|
272
|
+
const shadow = this.light.shadow;
|
|
273
|
+
|
|
175
274
|
const depthTexture = new DepthTexture();
|
|
176
275
|
depthTexture.compareFunction = LessCompare;
|
|
177
276
|
|
|
178
|
-
const shadow = this.light.shadow;
|
|
179
277
|
const shadowMap = builder.createRenderTarget( shadow.mapSize.width, shadow.mapSize.height );
|
|
180
278
|
shadowMap.depthTexture = depthTexture;
|
|
181
279
|
|
|
182
280
|
shadow.camera.updateProjectionMatrix();
|
|
183
281
|
|
|
282
|
+
// VSM
|
|
283
|
+
|
|
284
|
+
if ( shadowMapType === VSMShadowMap ) {
|
|
285
|
+
|
|
286
|
+
depthTexture.compareFunction = null; // VSM does not use textureSampleCompare()/texture2DCompare()
|
|
287
|
+
|
|
288
|
+
this.vsmShadowMapVertical = builder.createRenderTarget( shadow.mapSize.width, shadow.mapSize.height, { format: RGFormat, type: HalfFloatType } );
|
|
289
|
+
this.vsmShadowMapHorizontal = builder.createRenderTarget( shadow.mapSize.width, shadow.mapSize.height, { format: RGFormat, type: HalfFloatType } );
|
|
290
|
+
|
|
291
|
+
const shadowPassVertical = texture( depthTexture );
|
|
292
|
+
const shadowPassHorizontal = texture( this.vsmShadowMapVertical.texture );
|
|
293
|
+
|
|
294
|
+
const samples = reference( 'blurSamples', 'float', shadow ).setGroup( renderGroup );
|
|
295
|
+
const radius = reference( 'radius', 'float', shadow ).setGroup( renderGroup );
|
|
296
|
+
const size = reference( 'mapSize', 'vec2', shadow ).setGroup( renderGroup );
|
|
297
|
+
|
|
298
|
+
let material = this.vsmMaterialVertical || ( this.vsmMaterialVertical = new NodeMaterial() );
|
|
299
|
+
material.fragmentNode = VSMPassVertical( { samples, radius, size, shadowPass: shadowPassVertical } ).context( builder.getSharedContext() );
|
|
300
|
+
material.name = 'VSMVertical';
|
|
301
|
+
|
|
302
|
+
material = this.vsmMaterialHorizontal || ( this.vsmMaterialHorizontal = new NodeMaterial() );
|
|
303
|
+
material.fragmentNode = VSMPassHorizontal( { samples, radius, size, shadowPass: shadowPassHorizontal } ).context( builder.getSharedContext() );
|
|
304
|
+
material.name = 'VSMHorizontal';
|
|
305
|
+
|
|
306
|
+
}
|
|
307
|
+
|
|
184
308
|
//
|
|
185
309
|
|
|
186
|
-
const shadowIntensity = reference( 'intensity', 'float', shadow );
|
|
187
|
-
const bias = reference( 'bias', 'float', shadow );
|
|
188
|
-
const normalBias = reference( 'normalBias', 'float', shadow );
|
|
310
|
+
const shadowIntensity = reference( 'intensity', 'float', shadow ).setGroup( renderGroup );
|
|
311
|
+
const bias = reference( 'bias', 'float', shadow ).setGroup( renderGroup );
|
|
312
|
+
const normalBias = reference( 'normalBias', 'float', shadow ).setGroup( renderGroup );
|
|
189
313
|
|
|
190
314
|
const position = object.material.shadowPositionNode || positionWorld;
|
|
191
315
|
|
|
192
|
-
let shadowCoord = uniform( shadow.matrix ).mul( position.add( normalWorld.mul( normalBias ) ) );
|
|
316
|
+
let shadowCoord = uniform( shadow.matrix ).setGroup( renderGroup ).mul( position.add( normalWorld.mul( normalBias ) ) );
|
|
193
317
|
shadowCoord = shadowCoord.xyz.div( shadowCoord.w );
|
|
194
318
|
|
|
195
319
|
let coordZ = shadowCoord.z.add( bias );
|
|
@@ -214,7 +338,7 @@ class AnalyticLightNode extends LightingNode {
|
|
|
214
338
|
|
|
215
339
|
//
|
|
216
340
|
|
|
217
|
-
const filterFn = shadow.filterNode ||
|
|
341
|
+
const filterFn = shadow.filterNode || _shadowFilterLib[ renderer.shadowMap.type ] || null;
|
|
218
342
|
|
|
219
343
|
if ( filterFn === null ) {
|
|
220
344
|
|
|
@@ -222,12 +346,14 @@ class AnalyticLightNode extends LightingNode {
|
|
|
222
346
|
|
|
223
347
|
}
|
|
224
348
|
|
|
225
|
-
const
|
|
349
|
+
const shadowColor = texture( shadowMap.texture, shadowCoord );
|
|
350
|
+
const shadowNode = frustumTest.select( filterFn( { depthTexture: ( shadowMapType === VSMShadowMap ) ? this.vsmShadowMapHorizontal.texture : depthTexture, shadowCoord, shadow } ), float( 1 ) );
|
|
226
351
|
|
|
227
352
|
this.shadowMap = shadowMap;
|
|
353
|
+
this.light.shadow.map = shadowMap;
|
|
228
354
|
|
|
229
355
|
this.shadowNode = shadowNode;
|
|
230
|
-
this.shadowColorNode = shadowColorNode = this.colorNode.mul( mix( 1, shadowNode, shadowIntensity ) );
|
|
356
|
+
this.shadowColorNode = shadowColorNode = this.colorNode.mul( mix( 1, shadowNode.rgb.mix( shadowColor, 1 ), shadowIntensity.mul( shadowColor.a ) ) );
|
|
231
357
|
|
|
232
358
|
this.baseColorNode = this.colorNode;
|
|
233
359
|
|
|
@@ -266,9 +392,14 @@ class AnalyticLightNode extends LightingNode {
|
|
|
266
392
|
const { shadowMap, light } = this;
|
|
267
393
|
const { renderer, scene, camera } = frame;
|
|
268
394
|
|
|
395
|
+
const shadowType = renderer.shadowMap.type;
|
|
396
|
+
|
|
397
|
+
const depthVersion = shadowMap.depthTexture.version;
|
|
398
|
+
this._depthVersionCached = depthVersion;
|
|
399
|
+
|
|
269
400
|
const currentOverrideMaterial = scene.overrideMaterial;
|
|
270
401
|
|
|
271
|
-
scene.overrideMaterial =
|
|
402
|
+
scene.overrideMaterial = _overrideMaterial;
|
|
272
403
|
|
|
273
404
|
shadowMap.setSize( light.shadow.mapSize.width, light.shadow.mapSize.height );
|
|
274
405
|
|
|
@@ -280,7 +411,7 @@ class AnalyticLightNode extends LightingNode {
|
|
|
280
411
|
|
|
281
412
|
renderer.setRenderObjectFunction( ( object, ...params ) => {
|
|
282
413
|
|
|
283
|
-
if ( object.castShadow === true ) {
|
|
414
|
+
if ( object.castShadow === true || ( object.receiveShadow && shadowType === VSMShadowMap ) ) {
|
|
284
415
|
|
|
285
416
|
renderer.renderObject( object, ...params );
|
|
286
417
|
|
|
@@ -291,18 +422,64 @@ class AnalyticLightNode extends LightingNode {
|
|
|
291
422
|
renderer.setRenderTarget( shadowMap );
|
|
292
423
|
renderer.render( scene, light.shadow.camera );
|
|
293
424
|
|
|
294
|
-
renderer.setRenderTarget( currentRenderTarget );
|
|
295
425
|
renderer.setRenderObjectFunction( currentRenderObjectFunction );
|
|
296
426
|
|
|
427
|
+
// vsm blur pass
|
|
428
|
+
|
|
429
|
+
if ( light.isPointLight !== true && shadowType === VSMShadowMap ) {
|
|
430
|
+
|
|
431
|
+
this.vsmPass( frame, light );
|
|
432
|
+
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
renderer.setRenderTarget( currentRenderTarget );
|
|
436
|
+
|
|
297
437
|
scene.overrideMaterial = currentOverrideMaterial;
|
|
298
438
|
|
|
299
439
|
}
|
|
300
440
|
|
|
441
|
+
vsmPass( frame, light ) {
|
|
442
|
+
|
|
443
|
+
const { renderer } = frame;
|
|
444
|
+
|
|
445
|
+
this.vsmShadowMapVertical.setSize( light.shadow.mapSize.width, light.shadow.mapSize.height );
|
|
446
|
+
this.vsmShadowMapHorizontal.setSize( light.shadow.mapSize.width, light.shadow.mapSize.height );
|
|
447
|
+
|
|
448
|
+
renderer.setRenderTarget( this.vsmShadowMapVertical );
|
|
449
|
+
_quadMesh.material = this.vsmMaterialVertical;
|
|
450
|
+
_quadMesh.render( renderer );
|
|
451
|
+
|
|
452
|
+
renderer.setRenderTarget( this.vsmShadowMapHorizontal );
|
|
453
|
+
_quadMesh.material = this.vsmMaterialHorizontal;
|
|
454
|
+
_quadMesh.render( renderer );
|
|
455
|
+
|
|
456
|
+
}
|
|
457
|
+
|
|
301
458
|
disposeShadow() {
|
|
302
459
|
|
|
303
460
|
this.shadowMap.dispose();
|
|
304
461
|
this.shadowMap = null;
|
|
305
462
|
|
|
463
|
+
if ( this.vsmShadowMapVertical !== null ) {
|
|
464
|
+
|
|
465
|
+
this.vsmShadowMapVertical.dispose();
|
|
466
|
+
this.vsmShadowMapVertical = null;
|
|
467
|
+
|
|
468
|
+
this.vsmMaterialVertical.dispose();
|
|
469
|
+
this.vsmMaterialVertical = null;
|
|
470
|
+
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
if ( this.vsmShadowMapHorizontal !== null ) {
|
|
474
|
+
|
|
475
|
+
this.vsmShadowMapHorizontal.dispose();
|
|
476
|
+
this.vsmShadowMapHorizontal = null;
|
|
477
|
+
|
|
478
|
+
this.vsmMaterialHorizontal.dispose();
|
|
479
|
+
this.vsmMaterialHorizontal = null;
|
|
480
|
+
|
|
481
|
+
}
|
|
482
|
+
|
|
306
483
|
this.shadowNode = null;
|
|
307
484
|
this.shadowColorNode = null;
|
|
308
485
|
|
|
@@ -314,7 +491,21 @@ class AnalyticLightNode extends LightingNode {
|
|
|
314
491
|
|
|
315
492
|
updateBefore( frame ) {
|
|
316
493
|
|
|
317
|
-
this.
|
|
494
|
+
const shadow = this.light.shadow;
|
|
495
|
+
|
|
496
|
+
const needsUpdate = shadow.needsUpdate || shadow.autoUpdate;
|
|
497
|
+
|
|
498
|
+
if ( needsUpdate ) {
|
|
499
|
+
|
|
500
|
+
this.updateShadow( frame );
|
|
501
|
+
|
|
502
|
+
if ( this.shadowMap.depthTexture.version === this._depthVersionCached ) {
|
|
503
|
+
|
|
504
|
+
shadow.needsUpdate = false;
|
|
505
|
+
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
}
|
|
318
509
|
|
|
319
510
|
}
|
|
320
511
|
|
|
@@ -329,5 +520,3 @@ class AnalyticLightNode extends LightingNode {
|
|
|
329
520
|
}
|
|
330
521
|
|
|
331
522
|
export default AnalyticLightNode;
|
|
332
|
-
|
|
333
|
-
addNodeClass( 'AnalyticLightNode', AnalyticLightNode );
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import LightingNode from './LightingNode.js';
|
|
2
|
-
import {
|
|
2
|
+
import { cubeMapNode } from '../utils/CubeMapNode.js';
|
|
3
3
|
|
|
4
4
|
class BasicEnvironmentNode extends LightingNode {
|
|
5
5
|
|
|
6
|
+
static get type() {
|
|
7
|
+
|
|
8
|
+
return 'BasicEnvironmentNode';
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
6
12
|
constructor( envNode = null ) {
|
|
7
13
|
|
|
8
14
|
super();
|
|
@@ -15,12 +21,10 @@ class BasicEnvironmentNode extends LightingNode {
|
|
|
15
21
|
|
|
16
22
|
// environment property is used in the finish() method of BasicLightingModel
|
|
17
23
|
|
|
18
|
-
builder.context.environment = this.envNode;
|
|
24
|
+
builder.context.environment = cubeMapNode( this.envNode );
|
|
19
25
|
|
|
20
26
|
}
|
|
21
27
|
|
|
22
28
|
}
|
|
23
29
|
|
|
24
30
|
export default BasicEnvironmentNode;
|
|
25
|
-
|
|
26
|
-
addNodeClass( 'BasicEnvironmentNode', BasicEnvironmentNode );
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import LightingNode from './LightingNode.js';
|
|
2
|
-
import {
|
|
3
|
-
import { float } from '../shadernode/ShaderNode.js';
|
|
2
|
+
import { float } from '../tsl/TSLBase.js';
|
|
4
3
|
|
|
5
4
|
class BasicLightMapNode extends LightingNode {
|
|
6
5
|
|
|
6
|
+
static get type() {
|
|
7
|
+
|
|
8
|
+
return 'BasicLightMapNode';
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
7
12
|
constructor( lightMapNode = null ) {
|
|
8
13
|
|
|
9
14
|
super();
|
|
@@ -25,5 +30,3 @@ class BasicLightMapNode extends LightingNode {
|
|
|
25
30
|
}
|
|
26
31
|
|
|
27
32
|
export default BasicLightMapNode;
|
|
28
|
-
|
|
29
|
-
addNodeClass( 'BasicLightMapNode', BasicLightMapNode );
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import AnalyticLightNode from './AnalyticLightNode.js';
|
|
2
|
-
import { lightTargetDirection } from '
|
|
3
|
-
import { addLightNode } from './LightsNode.js';
|
|
4
|
-
import { addNodeClass } from '../core/Node.js';
|
|
5
|
-
|
|
6
|
-
import { DirectionalLight } from '../../lights/DirectionalLight.js';
|
|
2
|
+
import { lightTargetDirection } from '../accessors/Lights.js';
|
|
7
3
|
|
|
8
4
|
class DirectionalLightNode extends AnalyticLightNode {
|
|
9
5
|
|
|
6
|
+
static get type() {
|
|
7
|
+
|
|
8
|
+
return 'DirectionalLightNode';
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
10
12
|
constructor( light = null ) {
|
|
11
13
|
|
|
12
14
|
super( light );
|
|
@@ -34,7 +36,3 @@ class DirectionalLightNode extends AnalyticLightNode {
|
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
export default DirectionalLightNode;
|
|
37
|
-
|
|
38
|
-
addNodeClass( 'DirectionalLightNode', DirectionalLightNode );
|
|
39
|
-
|
|
40
|
-
addLightNode( DirectionalLight, DirectionalLightNode );
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import LightingNode from './LightingNode.js';
|
|
2
2
|
import { cache } from '../core/CacheNode.js';
|
|
3
|
-
import { context } from '../core/ContextNode.js';
|
|
4
3
|
import { roughness, clearcoatRoughness } from '../core/PropertyNode.js';
|
|
5
|
-
import { cameraViewMatrix } from '../accessors/
|
|
6
|
-
import { transformedClearcoatNormalView, transformedNormalView, transformedNormalWorld } from '../accessors/
|
|
7
|
-
import { positionViewDirection } from '../accessors/
|
|
8
|
-
import {
|
|
9
|
-
import { float } from '../shadernode/ShaderNode.js';
|
|
4
|
+
import { cameraViewMatrix } from '../accessors/Camera.js';
|
|
5
|
+
import { transformedClearcoatNormalView, transformedNormalView, transformedNormalWorld } from '../accessors/Normal.js';
|
|
6
|
+
import { positionViewDirection } from '../accessors/Position.js';
|
|
7
|
+
import { float } from '../tsl/TSLBase.js';
|
|
10
8
|
import { reference } from '../accessors/ReferenceNode.js';
|
|
11
9
|
import { transformedBentNormalView } from '../accessors/AccessorsUtils.js';
|
|
12
10
|
import { pmremTexture } from '../pmrem/PMREMNode.js';
|
|
@@ -15,6 +13,12 @@ const _envNodeCache = new WeakMap();
|
|
|
15
13
|
|
|
16
14
|
class EnvironmentNode extends LightingNode {
|
|
17
15
|
|
|
16
|
+
static get type() {
|
|
17
|
+
|
|
18
|
+
return 'EnvironmentNode';
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
18
22
|
constructor( envNode = null ) {
|
|
19
23
|
|
|
20
24
|
super();
|
|
@@ -25,17 +29,21 @@ class EnvironmentNode extends LightingNode {
|
|
|
25
29
|
|
|
26
30
|
setup( builder ) {
|
|
27
31
|
|
|
32
|
+
const { material } = builder;
|
|
33
|
+
|
|
28
34
|
let envNode = this.envNode;
|
|
29
35
|
|
|
30
|
-
if ( envNode.isTextureNode ) {
|
|
36
|
+
if ( envNode.isTextureNode || envNode.isMaterialReferenceNode ) {
|
|
37
|
+
|
|
38
|
+
const value = ( envNode.isTextureNode ) ? envNode.value : material[ envNode.property ];
|
|
31
39
|
|
|
32
|
-
let cacheEnvNode = _envNodeCache.get(
|
|
40
|
+
let cacheEnvNode = _envNodeCache.get( value );
|
|
33
41
|
|
|
34
42
|
if ( cacheEnvNode === undefined ) {
|
|
35
43
|
|
|
36
|
-
cacheEnvNode = pmremTexture(
|
|
44
|
+
cacheEnvNode = pmremTexture( value );
|
|
37
45
|
|
|
38
|
-
_envNodeCache.set(
|
|
46
|
+
_envNodeCache.set( value, cacheEnvNode );
|
|
39
47
|
|
|
40
48
|
}
|
|
41
49
|
|
|
@@ -45,16 +53,14 @@ class EnvironmentNode extends LightingNode {
|
|
|
45
53
|
|
|
46
54
|
//
|
|
47
55
|
|
|
48
|
-
const { material } = builder;
|
|
49
|
-
|
|
50
56
|
const envMap = material.envMap;
|
|
51
57
|
const intensity = envMap ? reference( 'envMapIntensity', 'float', builder.material ) : reference( 'environmentIntensity', 'float', builder.scene ); // @TODO: Add materialEnvIntensity in MaterialNode
|
|
52
58
|
|
|
53
59
|
const useAnisotropy = material.useAnisotropy === true || material.anisotropy > 0;
|
|
54
60
|
const radianceNormalView = useAnisotropy ? transformedBentNormalView : transformedNormalView;
|
|
55
61
|
|
|
56
|
-
const radiance = context(
|
|
57
|
-
const irradiance = context(
|
|
62
|
+
const radiance = envNode.context( createRadianceContext( roughness, radianceNormalView ) ).mul( intensity );
|
|
63
|
+
const irradiance = envNode.context( createIrradianceContext( transformedNormalWorld ) ).mul( Math.PI ).mul( intensity );
|
|
58
64
|
|
|
59
65
|
const isolateRadiance = cache( radiance );
|
|
60
66
|
const isolateIrradiance = cache( irradiance );
|
|
@@ -71,7 +77,7 @@ class EnvironmentNode extends LightingNode {
|
|
|
71
77
|
|
|
72
78
|
if ( clearcoatRadiance ) {
|
|
73
79
|
|
|
74
|
-
const clearcoatRadianceContext = context(
|
|
80
|
+
const clearcoatRadianceContext = envNode.context( createRadianceContext( clearcoatRoughness, transformedClearcoatNormalView ) ).mul( intensity );
|
|
75
81
|
const isolateClearcoatRadiance = cache( clearcoatRadianceContext );
|
|
76
82
|
|
|
77
83
|
clearcoatRadiance.addAssign( isolateClearcoatRadiance );
|
|
@@ -82,6 +88,8 @@ class EnvironmentNode extends LightingNode {
|
|
|
82
88
|
|
|
83
89
|
}
|
|
84
90
|
|
|
91
|
+
export default EnvironmentNode;
|
|
92
|
+
|
|
85
93
|
const createRadianceContext = ( roughnessNode, normalViewNode ) => {
|
|
86
94
|
|
|
87
95
|
let reflectVec = null;
|
|
@@ -128,7 +136,3 @@ const createIrradianceContext = ( normalWorldNode ) => {
|
|
|
128
136
|
};
|
|
129
137
|
|
|
130
138
|
};
|
|
131
|
-
|
|
132
|
-
export default EnvironmentNode;
|
|
133
|
-
|
|
134
|
-
addNodeClass( 'EnvironmentNode', EnvironmentNode );
|
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
import AnalyticLightNode from './AnalyticLightNode.js';
|
|
2
|
-
import { addLightNode } from './LightsNode.js';
|
|
3
2
|
import { uniform } from '../core/UniformNode.js';
|
|
4
3
|
import { mix } from '../math/MathNode.js';
|
|
5
|
-
import { normalView } from '../accessors/
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { normalView } from '../accessors/Normal.js';
|
|
5
|
+
import { lightPosition } from '../accessors/Lights.js';
|
|
6
|
+
import { renderGroup } from '../core/UniformGroupNode.js';
|
|
8
7
|
|
|
9
8
|
import { Color } from '../../math/Color.js';
|
|
10
|
-
import { HemisphereLight } from '../../lights/HemisphereLight.js';
|
|
11
9
|
|
|
12
10
|
class HemisphereLightNode extends AnalyticLightNode {
|
|
13
11
|
|
|
12
|
+
static get type() {
|
|
13
|
+
|
|
14
|
+
return 'HemisphereLightNode';
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
|
|
14
18
|
constructor( light = null ) {
|
|
15
19
|
|
|
16
20
|
super( light );
|
|
17
21
|
|
|
18
|
-
this.lightPositionNode =
|
|
22
|
+
this.lightPositionNode = lightPosition( light );
|
|
19
23
|
this.lightDirectionNode = this.lightPositionNode.normalize();
|
|
20
24
|
|
|
21
|
-
this.groundColorNode = uniform( new Color() );
|
|
25
|
+
this.groundColorNode = uniform( new Color() ).setGroup( renderGroup );
|
|
22
26
|
|
|
23
27
|
}
|
|
24
28
|
|
|
@@ -50,7 +54,3 @@ class HemisphereLightNode extends AnalyticLightNode {
|
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
export default HemisphereLightNode;
|
|
53
|
-
|
|
54
|
-
addNodeClass( 'HemisphereLightNode', HemisphereLightNode );
|
|
55
|
-
|
|
56
|
-
addLightNode( HemisphereLight, HemisphereLightNode );
|