super-three 0.167.0 → 0.168.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 +165 -44
- package/build/three.module.js +165 -45
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +23600 -21931
- package/build/three.webgpu.min.js +1 -1
- package/examples/jsm/Addons.js +3 -1
- 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 +453 -452
- 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/GLTFExporter.js +6 -1
- package/examples/jsm/exporters/USDZExporter.js +29 -8
- package/examples/jsm/helpers/LightProbeHelper.js +42 -43
- package/examples/jsm/loaders/KTX2Loader.js +19 -7
- package/examples/jsm/loaders/MaterialXLoader.js +11 -4
- package/examples/jsm/loaders/PCDLoader.js +9 -9
- package/examples/jsm/objects/SkyMesh.js +188 -0
- package/examples/jsm/objects/Water2Mesh.js +159 -0
- package/examples/jsm/objects/WaterMesh.js +102 -0
- package/examples/jsm/physics/RapierPhysics.js +20 -0
- 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/TSLEncoder.js +8 -8
- package/examples/jsm/utils/TextureUtils.js +1 -1
- package/package.json +2 -1
- package/src/Three.WebGPU.js +6 -0
- package/src/Three.js +1 -0
- package/src/constants.js +1 -1
- package/src/extras/Controls.js +32 -0
- package/src/loaders/ObjectLoader.js +3 -3
- package/src/{nodes/loaders → loaders/nodes}/NodeLoader.js +4 -4
- package/src/{nodes/loaders → loaders/nodes}/NodeMaterialLoader.js +1 -2
- package/src/materials/Material.js +4 -7
- package/src/{nodes/materials → materials/nodes}/InstancedPointsNodeMaterial.js +33 -24
- package/src/{nodes/materials → materials/nodes}/Line2NodeMaterial.js +34 -37
- package/src/{nodes/materials → materials/nodes}/LineBasicNodeMaterial.js +3 -4
- package/src/{nodes/materials → materials/nodes}/LineDashedNodeMaterial.js +7 -9
- package/src/{nodes/materials → materials/nodes}/MeshBasicNodeMaterial.js +11 -11
- package/src/{nodes/materials → materials/nodes}/MeshLambertNodeMaterial.js +5 -5
- package/src/{nodes/materials → materials/nodes}/MeshMatcapNodeMaterial.js +8 -8
- package/src/materials/nodes/MeshNormalNodeMaterial.js +40 -0
- package/src/{nodes/materials → materials/nodes}/MeshPhongNodeMaterial.js +9 -8
- package/src/{nodes/materials → materials/nodes}/MeshPhysicalNodeMaterial.js +18 -17
- package/src/{nodes/materials → materials/nodes}/MeshSSSNodeMaterial.js +6 -6
- package/src/{nodes/materials → materials/nodes}/MeshStandardNodeMaterial.js +17 -11
- package/src/{nodes/materials → materials/nodes}/MeshToonNodeMaterial.js +4 -4
- package/src/{nodes/materials → materials/nodes}/NodeMaterial.js +67 -86
- package/src/{nodes/materials/Materials.js → materials/nodes/NodeMaterials.js} +1 -1
- package/src/{nodes/materials → materials/nodes}/PointsNodeMaterial.js +3 -4
- package/src/{nodes/materials → materials/nodes}/ShadowNodeMaterial.js +4 -4
- package/src/{nodes/materials → materials/nodes}/SpriteNodeMaterial.js +11 -11
- package/src/{nodes/materials → materials/nodes}/VolumeNodeMaterial.js +14 -16
- package/src/nodes/Nodes.js +103 -159
- package/src/nodes/TSL.js +176 -0
- package/src/nodes/accessors/AccessorsUtils.js +8 -8
- package/src/nodes/accessors/BatchNode.js +48 -20
- package/src/nodes/accessors/{BitangentNode.js → Bitangent.js} +9 -9
- package/src/nodes/accessors/BufferAttributeNode.js +5 -5
- package/src/nodes/accessors/BufferNode.js +4 -4
- package/src/nodes/accessors/{CameraNode.js → Camera.js} +10 -10
- package/src/nodes/accessors/ClippingNode.js +16 -14
- package/src/nodes/accessors/CubeTextureNode.js +5 -7
- package/src/nodes/accessors/InstanceNode.js +17 -13
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +4 -4
- package/src/nodes/accessors/MaterialNode.js +52 -55
- package/src/nodes/accessors/MaterialProperties.js +3 -0
- package/src/nodes/accessors/MaterialReferenceNode.js +6 -4
- package/src/nodes/accessors/ModelNode.js +11 -11
- package/src/nodes/accessors/ModelViewProjectionNode.js +6 -7
- package/src/nodes/accessors/MorphNode.js +12 -12
- package/src/nodes/accessors/Normal.js +62 -0
- package/src/nodes/accessors/Object3DNode.js +10 -10
- package/src/nodes/accessors/PointUVNode.js +4 -4
- package/src/nodes/accessors/Position.js +10 -0
- package/src/nodes/accessors/ReferenceBaseNode.js +143 -0
- package/src/nodes/accessors/ReferenceNode.js +13 -7
- package/src/nodes/accessors/ReflectVector.js +10 -0
- package/src/nodes/accessors/RendererReferenceNode.js +6 -6
- package/src/nodes/accessors/SceneNode.js +5 -6
- package/src/nodes/accessors/SkinningNode.js +84 -21
- package/src/nodes/accessors/StorageBufferNode.js +4 -5
- package/src/nodes/accessors/StorageTextureNode.js +5 -5
- package/src/nodes/accessors/Tangent.js +22 -0
- package/src/nodes/accessors/Texture3DNode.js +11 -11
- package/src/nodes/accessors/{TextureBicubicNode.js → TextureBicubic.js} +3 -32
- package/src/nodes/accessors/TextureNode.js +16 -21
- package/src/nodes/accessors/TextureSizeNode.js +4 -6
- package/src/nodes/accessors/{UniformsNode.js → UniformArrayNode.js} +17 -8
- package/src/nodes/accessors/UserDataNode.js +4 -4
- package/src/nodes/accessors/VelocityNode.js +83 -0
- package/src/nodes/accessors/VertexColorNode.js +4 -4
- package/src/nodes/code/CodeNode.js +5 -5
- package/src/nodes/code/ExpressionNode.js +4 -4
- package/src/nodes/code/FunctionCallNode.js +5 -5
- package/src/nodes/code/FunctionNode.js +5 -23
- package/src/nodes/code/ScriptableNode.js +4 -6
- package/src/nodes/code/ScriptableValueNode.js +4 -6
- package/src/nodes/core/AssignNode.js +5 -5
- package/src/nodes/core/AttributeNode.js +7 -20
- package/src/nodes/core/BypassNode.js +5 -5
- package/src/nodes/core/CacheNode.js +5 -5
- package/src/nodes/core/ConstNode.js +2 -2
- package/src/nodes/core/ContextNode.js +17 -11
- package/src/nodes/core/IndexNode.js +12 -7
- package/src/nodes/core/InputNode.js +2 -2
- package/src/nodes/core/MRTNode.js +12 -6
- package/src/nodes/core/Node.js +39 -19
- package/src/nodes/core/NodeBuilder.js +46 -33
- package/src/nodes/core/NodeUtils.js +1 -0
- package/src/nodes/core/OutputStructNode.js +4 -4
- package/src/nodes/core/ParameterNode.js +4 -4
- package/src/nodes/core/PropertyNode.js +32 -32
- package/src/nodes/core/StackNode.js +26 -10
- package/src/nodes/core/StructTypeNode.js +2 -2
- package/src/nodes/core/TempNode.js +2 -2
- package/src/nodes/core/UniformGroupNode.js +8 -9
- package/src/nodes/core/UniformNode.js +4 -4
- package/src/nodes/core/VarNode.js +6 -6
- package/src/nodes/core/VaryingNode.js +5 -5
- package/src/nodes/display/AfterImageNode.js +9 -9
- package/src/nodes/display/AnaglyphPassNode.js +61 -0
- package/src/nodes/display/AnamorphicNode.js +11 -11
- package/src/nodes/display/BleachBypass.js +26 -0
- package/src/nodes/display/BlendMode.js +54 -0
- package/src/nodes/display/BloomNode.js +21 -19
- package/src/nodes/display/BumpMapNode.js +7 -12
- package/src/nodes/display/ColorAdjustment.js +46 -0
- package/src/nodes/display/ColorSpaceFunctions.js +38 -0
- package/src/nodes/display/ColorSpaceNode.js +40 -63
- package/src/nodes/display/DenoiseNode.js +20 -17
- package/src/nodes/display/DepthOfFieldNode.js +8 -6
- package/src/nodes/display/DotScreenNode.js +10 -22
- package/src/nodes/display/FXAANode.js +17 -15
- package/src/nodes/display/FilmNode.js +7 -6
- package/src/nodes/display/FrontFacingNode.js +5 -5
- package/src/nodes/display/GTAONode.js +19 -15
- package/src/nodes/display/GaussianBlurNode.js +11 -8
- package/src/nodes/display/Lut3DNode.js +6 -5
- package/src/nodes/display/MotionBlur.js +25 -0
- package/src/nodes/display/NormalMapNode.js +8 -10
- package/src/nodes/display/ParallaxBarrierPassNode.js +55 -0
- package/src/nodes/display/PassNode.js +84 -8
- package/src/nodes/display/PixelationPassNode.js +12 -7
- package/src/nodes/display/PosterizeNode.js +4 -6
- package/src/nodes/display/RGBShiftNode.js +8 -7
- package/src/nodes/display/RenderOutputNode.js +9 -9
- package/src/nodes/display/SSAAPassNode.js +284 -0
- package/src/nodes/display/Sepia.js +17 -0
- package/src/nodes/display/SobelOperatorNode.js +9 -7
- package/src/nodes/display/StereoCompositePassNode.js +107 -0
- package/src/nodes/display/StereoPassNode.js +80 -0
- package/src/nodes/display/ToneMappingFunctions.js +190 -0
- package/src/nodes/display/ToneMappingNode.js +12 -173
- package/src/nodes/display/TransitionNode.js +9 -8
- package/src/nodes/display/ViewportDepthNode.js +30 -29
- package/src/nodes/display/ViewportDepthTextureNode.js +6 -8
- package/src/nodes/display/ViewportNode.js +26 -25
- package/src/nodes/display/ViewportSharedTextureNode.js +6 -8
- package/src/nodes/display/ViewportTextureNode.js +7 -10
- package/src/nodes/fog/FogExp2Node.js +4 -6
- package/src/nodes/fog/FogNode.js +5 -7
- package/src/nodes/fog/FogRangeNode.js +4 -6
- 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 +32 -31
- 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/geometry/RangeNode.js +4 -4
- package/src/nodes/gpgpu/ComputeNode.js +5 -5
- package/src/nodes/lighting/AONode.js +2 -2
- package/src/nodes/lighting/AmbientLightNode.js +2 -7
- package/src/nodes/lighting/AnalyticLightNode.js +34 -13
- package/src/nodes/lighting/BasicEnvironmentNode.js +4 -3
- package/src/nodes/lighting/BasicLightMapNode.js +3 -3
- package/src/nodes/lighting/DirectionalLightNode.js +2 -7
- package/src/nodes/lighting/EnvironmentNode.js +20 -19
- package/src/nodes/lighting/HemisphereLightNode.js +3 -7
- package/src/nodes/lighting/IESSpotLightNode.js +3 -8
- package/src/nodes/lighting/IrradianceNode.js +2 -2
- package/src/nodes/lighting/LightNode.js +5 -5
- package/src/nodes/lighting/LightProbeNode.js +76 -0
- package/src/nodes/lighting/LightUtils.js +3 -3
- package/src/nodes/lighting/LightingContextNode.js +15 -17
- package/src/nodes/lighting/LightingNode.js +2 -2
- package/src/nodes/lighting/LightsNode.js +94 -76
- package/src/nodes/lighting/PointLightNode.js +3 -8
- package/src/nodes/lighting/RectAreaLightNode.js +2 -6
- package/src/nodes/lighting/SpotLightNode.js +3 -8
- 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} +18 -7
- package/src/nodes/math/Hash.js +13 -0
- package/src/nodes/math/MathNode.js +124 -124
- package/src/nodes/math/MathUtils.js +0 -7
- package/src/nodes/math/OperatorNode.js +94 -52
- package/src/nodes/math/TriNoise3D.js +19 -29
- package/src/nodes/pmrem/PMREMNode.js +58 -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 +2 -2
- package/src/nodes/utils/ConvertNode.js +2 -2
- package/src/nodes/utils/CubeMapNode.js +157 -0
- package/src/nodes/utils/Discard.js +8 -0
- package/src/nodes/utils/EquirectUVNode.js +5 -5
- package/src/nodes/utils/FlipNode.js +65 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +5 -5
- package/src/nodes/utils/JoinNode.js +2 -2
- package/src/nodes/utils/LoopNode.js +12 -6
- package/src/nodes/utils/MatcapUVNode.js +6 -6
- package/src/nodes/utils/MaxMipLevelNode.js +4 -4
- package/src/nodes/utils/OscNode.js +7 -7
- package/src/nodes/utils/Packing.js +4 -0
- package/src/nodes/utils/RTTNode.js +8 -8
- package/src/nodes/utils/ReflectorNode.js +8 -3
- package/src/nodes/utils/RemapNode.js +7 -7
- package/src/nodes/utils/RotateNode.js +4 -12
- package/src/nodes/utils/SetNode.js +2 -2
- package/src/nodes/utils/SplitNode.js +2 -2
- package/src/nodes/utils/SpriteSheetUVNode.js +5 -5
- package/src/nodes/utils/SpriteUtils.js +47 -0
- package/src/nodes/utils/StorageArrayElementNode.js +4 -6
- package/src/nodes/utils/TimerNode.js +5 -5
- package/src/nodes/utils/TriplanarTexturesNode.js +7 -9
- package/src/nodes/utils/UVUtils.js +19 -0
- package/src/nodes/utils/ViewportUtils.js +14 -0
- package/src/objects/BatchedMesh.js +2 -3
- package/src/renderers/WebGLRenderer.js +24 -0
- 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/ClippingContext.js +14 -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 +24 -0
- package/src/renderers/common/RenderList.js +1 -1
- package/src/renderers/common/RenderObject.js +2 -2
- package/src/renderers/common/Renderer.js +75 -49
- package/src/renderers/common/SampledTexture.js +12 -3
- package/src/renderers/common/StandardRenderer.js +18 -0
- package/src/renderers/common/Textures.js +8 -12
- package/src/renderers/common/extras/PMREMGenerator.js +12 -13
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- 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 +36 -9
- package/src/renderers/common/nodes/StandardNodeLibrary.js +105 -0
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +2 -2
- package/src/renderers/webgl/WebGLProgram.js +1 -1
- package/src/renderers/webgl/WebGLProperties.js +7 -0
- package/src/renderers/webgl/WebGLTextures.js +61 -4
- package/src/renderers/webgl-fallback/WebGLBackend.js +88 -68
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +57 -9
- package/src/renderers/webgl-fallback/utils/WebGLState.js +21 -0
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +28 -21
- package/src/renderers/webgpu/WebGPUBackend.js +86 -68
- package/src/renderers/webgpu/WebGPURenderer.js +8 -8
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +99 -63
- 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 +6 -15
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +36 -21
- package/src/renderers/webgpu/utils/WebGPUUtils.js +18 -1
- package/src/renderers/webxr/WebXRManager.js +32 -25
- package/examples/jsm/loaders/LogLuvLoader.js +0 -606
- 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/materials/MeshNormalNodeMaterial.js +0 -40
- 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/loaders → loaders/nodes}/NodeObjectLoader.js +0 -0
- /package/src/nodes/accessors/{UVNode.js → UV.js} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import Node, {
|
|
1
|
+
import Node, { registerNode } from '../core/Node.js';
|
|
2
2
|
import { getValueType } from '../core/NodeUtils.js';
|
|
3
3
|
import { buffer } from '../accessors/BufferNode.js';
|
|
4
4
|
import { instancedBufferAttribute } from '../accessors/BufferAttributeNode.js';
|
|
5
5
|
import { instanceIndex } from '../core/IndexNode.js';
|
|
6
|
-
import { nodeProxy, float } from '../
|
|
6
|
+
import { nodeProxy, float } from '../tsl/TSLBase.js';
|
|
7
7
|
|
|
8
8
|
import { Vector4 } from '../../math/Vector4.js';
|
|
9
9
|
import { MathUtils } from '../../math/MathUtils.js';
|
|
@@ -112,6 +112,6 @@ class RangeNode extends Node {
|
|
|
112
112
|
|
|
113
113
|
export default RangeNode;
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
RangeNode.type = /*@__PURE__*/ registerNode( 'Range', RangeNode );
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
export const range = /*@__PURE__*/ nodeProxy( RangeNode );
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import Node, {
|
|
1
|
+
import Node, { registerNode } from '../core/Node.js';
|
|
2
2
|
import { NodeUpdateType } from '../core/constants.js';
|
|
3
|
-
import {
|
|
3
|
+
import { addMethodChaining, nodeObject } from '../tsl/TSLCore.js';
|
|
4
4
|
|
|
5
5
|
class ComputeNode extends Node {
|
|
6
6
|
|
|
@@ -78,8 +78,8 @@ class ComputeNode extends Node {
|
|
|
78
78
|
|
|
79
79
|
export default ComputeNode;
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
ComputeNode.type = /*@__PURE__*/ registerNode( 'Compute', ComputeNode );
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
export const compute = ( node, count, workgroupSize ) => nodeObject( new ComputeNode( nodeObject( node ), count, workgroupSize ) );
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
addMethodChaining( 'compute', compute );
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { registerNode } from '../core/Node.js';
|
|
1
2
|
import LightingNode from './LightingNode.js';
|
|
2
|
-
import { addNodeClass } from '../core/Node.js';
|
|
3
3
|
|
|
4
4
|
class AONode extends LightingNode {
|
|
5
5
|
|
|
@@ -21,4 +21,4 @@ class AONode extends LightingNode {
|
|
|
21
21
|
|
|
22
22
|
export default AONode;
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
AONode.type = /*@__PURE__*/ registerNode( 'AO', AONode );
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
+
import { registerNode } from '../core/Node.js';
|
|
1
2
|
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
3
|
|
|
7
4
|
class AmbientLightNode extends AnalyticLightNode {
|
|
8
5
|
|
|
@@ -22,6 +19,4 @@ class AmbientLightNode extends AnalyticLightNode {
|
|
|
22
19
|
|
|
23
20
|
export default AmbientLightNode;
|
|
24
21
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
addLightNode( AmbientLight, AmbientLightNode );
|
|
22
|
+
AmbientLightNode.type = /*@__PURE__*/ registerNode( 'AmbientLight', AmbientLightNode );
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
+
import { registerNode } from '../core/Node.js';
|
|
1
2
|
import LightingNode from './LightingNode.js';
|
|
2
3
|
import { NodeUpdateType } from '../core/constants.js';
|
|
3
4
|
import { uniform } from '../core/UniformNode.js';
|
|
4
|
-
import {
|
|
5
|
-
import { float, vec2, vec3, vec4 } from '../shadernode/ShaderNode.js';
|
|
5
|
+
import { float, vec2, vec3, vec4 } from '../tsl/TSLBase.js';
|
|
6
6
|
import { reference } from '../accessors/ReferenceNode.js';
|
|
7
7
|
import { texture } from '../accessors/TextureNode.js';
|
|
8
|
-
import { positionWorld } from '../accessors/
|
|
9
|
-
import { normalWorld } from '../accessors/
|
|
8
|
+
import { positionWorld } from '../accessors/Position.js';
|
|
9
|
+
import { normalWorld } from '../accessors/Normal.js';
|
|
10
10
|
import { mix, fract } from '../math/MathNode.js';
|
|
11
11
|
import { add } from '../math/OperatorNode.js';
|
|
12
12
|
import { Color } from '../../math/Color.js';
|
|
13
13
|
import { DepthTexture } from '../../textures/DepthTexture.js';
|
|
14
|
-
import {
|
|
14
|
+
import { Fn } from '../tsl/TSLBase.js';
|
|
15
15
|
import { LessCompare, WebGPUCoordinateSystem } from '../../constants.js';
|
|
16
|
+
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
|
16
17
|
|
|
17
|
-
const BasicShadowMap =
|
|
18
|
+
const BasicShadowMap = Fn( ( { depthTexture, shadowCoord } ) => {
|
|
18
19
|
|
|
19
20
|
return texture( depthTexture, shadowCoord.xy ).compare( shadowCoord.z );
|
|
20
21
|
|
|
21
22
|
} );
|
|
22
23
|
|
|
23
|
-
const PCFShadowMap =
|
|
24
|
+
const PCFShadowMap = Fn( ( { depthTexture, shadowCoord, shadow } ) => {
|
|
24
25
|
|
|
25
26
|
const depthCompare = ( uv, compare ) => texture( depthTexture, uv ).compare( compare );
|
|
26
27
|
|
|
@@ -59,7 +60,7 @@ const PCFShadowMap = tslFn( ( { depthTexture, shadowCoord, shadow } ) => {
|
|
|
59
60
|
|
|
60
61
|
} );
|
|
61
62
|
|
|
62
|
-
const PCFSoftShadowMap =
|
|
63
|
+
const PCFSoftShadowMap = Fn( ( { depthTexture, shadowCoord, shadow } ) => {
|
|
63
64
|
|
|
64
65
|
const depthCompare = ( uv, compare ) => texture( depthTexture, uv ).compare( compare );
|
|
65
66
|
|
|
@@ -166,9 +167,10 @@ class AnalyticLightNode extends LightingNode {
|
|
|
166
167
|
|
|
167
168
|
if ( overrideMaterial === null ) {
|
|
168
169
|
|
|
169
|
-
overrideMaterial =
|
|
170
|
+
overrideMaterial = new NodeMaterial();
|
|
170
171
|
overrideMaterial.fragmentNode = vec4( 0, 0, 0, 1 );
|
|
171
172
|
overrideMaterial.isShadowNodeMaterial = true; // Use to avoid other overrideMaterial override material.fragmentNode unintentionally when using material.shadowNode
|
|
173
|
+
overrideMaterial.name = 'ShadowMaterial';
|
|
172
174
|
|
|
173
175
|
}
|
|
174
176
|
|
|
@@ -222,12 +224,13 @@ class AnalyticLightNode extends LightingNode {
|
|
|
222
224
|
|
|
223
225
|
}
|
|
224
226
|
|
|
225
|
-
const
|
|
227
|
+
const shadowColor = texture( shadowMap.texture, shadowCoord );
|
|
228
|
+
const shadowNode = frustumTest.select( filterFn( { depthTexture, shadowCoord, shadow } ), float( 1 ) );
|
|
226
229
|
|
|
227
230
|
this.shadowMap = shadowMap;
|
|
228
231
|
|
|
229
232
|
this.shadowNode = shadowNode;
|
|
230
|
-
this.shadowColorNode = shadowColorNode = this.colorNode.mul( mix( 1, shadowNode, shadowIntensity ) );
|
|
233
|
+
this.shadowColorNode = shadowColorNode = this.colorNode.mul( mix( 1, shadowNode.rgb.mix( shadowColor, 1 ), shadowIntensity.mul( shadowColor.a ) ) );
|
|
231
234
|
|
|
232
235
|
this.baseColorNode = this.colorNode;
|
|
233
236
|
|
|
@@ -266,6 +269,10 @@ class AnalyticLightNode extends LightingNode {
|
|
|
266
269
|
const { shadowMap, light } = this;
|
|
267
270
|
const { renderer, scene, camera } = frame;
|
|
268
271
|
|
|
272
|
+
|
|
273
|
+
const depthVersion = shadowMap.depthTexture.version;
|
|
274
|
+
this._depthVersionCached = depthVersion;
|
|
275
|
+
|
|
269
276
|
const currentOverrideMaterial = scene.overrideMaterial;
|
|
270
277
|
|
|
271
278
|
scene.overrideMaterial = overrideMaterial;
|
|
@@ -314,7 +321,21 @@ class AnalyticLightNode extends LightingNode {
|
|
|
314
321
|
|
|
315
322
|
updateBefore( frame ) {
|
|
316
323
|
|
|
317
|
-
this.
|
|
324
|
+
const shadow = this.light.shadow;
|
|
325
|
+
|
|
326
|
+
const needsUpdate = shadow.needsUpdate || shadow.autoUpdate;
|
|
327
|
+
|
|
328
|
+
if ( needsUpdate ) {
|
|
329
|
+
|
|
330
|
+
this.updateShadow( frame );
|
|
331
|
+
|
|
332
|
+
if ( this.shadowMap.depthTexture.version === this._depthVersionCached ) {
|
|
333
|
+
|
|
334
|
+
shadow.needsUpdate = false;
|
|
335
|
+
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
}
|
|
318
339
|
|
|
319
340
|
}
|
|
320
341
|
|
|
@@ -330,4 +351,4 @@ class AnalyticLightNode extends LightingNode {
|
|
|
330
351
|
|
|
331
352
|
export default AnalyticLightNode;
|
|
332
353
|
|
|
333
|
-
|
|
354
|
+
AnalyticLightNode.type = /*@__PURE__*/ registerNode( 'AnalyticLight', AnalyticLightNode );
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { registerNode } from '../core/Node.js';
|
|
1
2
|
import LightingNode from './LightingNode.js';
|
|
2
|
-
import {
|
|
3
|
+
import { cubeMapNode } from '../utils/CubeMapNode.js';
|
|
3
4
|
|
|
4
5
|
class BasicEnvironmentNode extends LightingNode {
|
|
5
6
|
|
|
@@ -15,7 +16,7 @@ class BasicEnvironmentNode extends LightingNode {
|
|
|
15
16
|
|
|
16
17
|
// environment property is used in the finish() method of BasicLightingModel
|
|
17
18
|
|
|
18
|
-
builder.context.environment = this.envNode;
|
|
19
|
+
builder.context.environment = cubeMapNode( this.envNode );
|
|
19
20
|
|
|
20
21
|
}
|
|
21
22
|
|
|
@@ -23,4 +24,4 @@ class BasicEnvironmentNode extends LightingNode {
|
|
|
23
24
|
|
|
24
25
|
export default BasicEnvironmentNode;
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
BasicEnvironmentNode.type = /*@__PURE__*/ registerNode( 'BasicEnvironment', BasicEnvironmentNode );
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { registerNode } from '../core/Node.js';
|
|
1
2
|
import LightingNode from './LightingNode.js';
|
|
2
|
-
import {
|
|
3
|
-
import { float } from '../shadernode/ShaderNode.js';
|
|
3
|
+
import { float } from '../tsl/TSLBase.js';
|
|
4
4
|
|
|
5
5
|
class BasicLightMapNode extends LightingNode {
|
|
6
6
|
|
|
@@ -26,4 +26,4 @@ class BasicLightMapNode extends LightingNode {
|
|
|
26
26
|
|
|
27
27
|
export default BasicLightMapNode;
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
BasicLightMapNode.type = /*@__PURE__*/ registerNode( 'BasicLightMap', BasicLightMapNode );
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
+
import { registerNode } from '../core/Node.js';
|
|
1
2
|
import AnalyticLightNode from './AnalyticLightNode.js';
|
|
2
3
|
import { lightTargetDirection } from './LightNode.js';
|
|
3
|
-
import { addLightNode } from './LightsNode.js';
|
|
4
|
-
import { addNodeClass } from '../core/Node.js';
|
|
5
|
-
|
|
6
|
-
import { DirectionalLight } from '../../lights/DirectionalLight.js';
|
|
7
4
|
|
|
8
5
|
class DirectionalLightNode extends AnalyticLightNode {
|
|
9
6
|
|
|
@@ -35,6 +32,4 @@ class DirectionalLightNode extends AnalyticLightNode {
|
|
|
35
32
|
|
|
36
33
|
export default DirectionalLightNode;
|
|
37
34
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
addLightNode( DirectionalLight, DirectionalLightNode );
|
|
35
|
+
DirectionalLightNode.type = /*@__PURE__*/ registerNode( 'DirectionalLight', DirectionalLightNode );
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
+
import { registerNode } from '../core/Node.js';
|
|
1
2
|
import LightingNode from './LightingNode.js';
|
|
2
3
|
import { cache } from '../core/CacheNode.js';
|
|
3
|
-
import { context } from '../core/ContextNode.js';
|
|
4
4
|
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';
|
|
5
|
+
import { cameraViewMatrix } from '../accessors/Camera.js';
|
|
6
|
+
import { transformedClearcoatNormalView, transformedNormalView, transformedNormalWorld } from '../accessors/Normal.js';
|
|
7
|
+
import { positionViewDirection } from '../accessors/Position.js';
|
|
8
|
+
import { float } from '../tsl/TSLBase.js';
|
|
10
9
|
import { reference } from '../accessors/ReferenceNode.js';
|
|
11
10
|
import { transformedBentNormalView } from '../accessors/AccessorsUtils.js';
|
|
12
11
|
import { pmremTexture } from '../pmrem/PMREMNode.js';
|
|
@@ -25,17 +24,21 @@ class EnvironmentNode extends LightingNode {
|
|
|
25
24
|
|
|
26
25
|
setup( builder ) {
|
|
27
26
|
|
|
27
|
+
const { material } = builder;
|
|
28
|
+
|
|
28
29
|
let envNode = this.envNode;
|
|
29
30
|
|
|
30
|
-
if ( envNode.isTextureNode ) {
|
|
31
|
+
if ( envNode.isTextureNode || envNode.isMaterialReferenceNode ) {
|
|
32
|
+
|
|
33
|
+
const value = ( envNode.isTextureNode ) ? envNode.value : material[ envNode.property ];
|
|
31
34
|
|
|
32
|
-
let cacheEnvNode = _envNodeCache.get(
|
|
35
|
+
let cacheEnvNode = _envNodeCache.get( value );
|
|
33
36
|
|
|
34
37
|
if ( cacheEnvNode === undefined ) {
|
|
35
38
|
|
|
36
|
-
cacheEnvNode = pmremTexture(
|
|
39
|
+
cacheEnvNode = pmremTexture( value );
|
|
37
40
|
|
|
38
|
-
_envNodeCache.set(
|
|
41
|
+
_envNodeCache.set( value, cacheEnvNode );
|
|
39
42
|
|
|
40
43
|
}
|
|
41
44
|
|
|
@@ -45,16 +48,14 @@ class EnvironmentNode extends LightingNode {
|
|
|
45
48
|
|
|
46
49
|
//
|
|
47
50
|
|
|
48
|
-
const { material } = builder;
|
|
49
|
-
|
|
50
51
|
const envMap = material.envMap;
|
|
51
52
|
const intensity = envMap ? reference( 'envMapIntensity', 'float', builder.material ) : reference( 'environmentIntensity', 'float', builder.scene ); // @TODO: Add materialEnvIntensity in MaterialNode
|
|
52
53
|
|
|
53
54
|
const useAnisotropy = material.useAnisotropy === true || material.anisotropy > 0;
|
|
54
55
|
const radianceNormalView = useAnisotropy ? transformedBentNormalView : transformedNormalView;
|
|
55
56
|
|
|
56
|
-
const radiance = context(
|
|
57
|
-
const irradiance = context(
|
|
57
|
+
const radiance = envNode.context( createRadianceContext( roughness, radianceNormalView ) ).mul( intensity );
|
|
58
|
+
const irradiance = envNode.context( createIrradianceContext( transformedNormalWorld ) ).mul( Math.PI ).mul( intensity );
|
|
58
59
|
|
|
59
60
|
const isolateRadiance = cache( radiance );
|
|
60
61
|
const isolateIrradiance = cache( irradiance );
|
|
@@ -71,7 +72,7 @@ class EnvironmentNode extends LightingNode {
|
|
|
71
72
|
|
|
72
73
|
if ( clearcoatRadiance ) {
|
|
73
74
|
|
|
74
|
-
const clearcoatRadianceContext = context(
|
|
75
|
+
const clearcoatRadianceContext = envNode.context( createRadianceContext( clearcoatRoughness, transformedClearcoatNormalView ) ).mul( intensity );
|
|
75
76
|
const isolateClearcoatRadiance = cache( clearcoatRadianceContext );
|
|
76
77
|
|
|
77
78
|
clearcoatRadiance.addAssign( isolateClearcoatRadiance );
|
|
@@ -82,6 +83,10 @@ class EnvironmentNode extends LightingNode {
|
|
|
82
83
|
|
|
83
84
|
}
|
|
84
85
|
|
|
86
|
+
export default EnvironmentNode;
|
|
87
|
+
|
|
88
|
+
EnvironmentNode.type = /*@__PURE__*/ registerNode( 'Environment', EnvironmentNode );
|
|
89
|
+
|
|
85
90
|
const createRadianceContext = ( roughnessNode, normalViewNode ) => {
|
|
86
91
|
|
|
87
92
|
let reflectVec = null;
|
|
@@ -128,7 +133,3 @@ const createIrradianceContext = ( normalWorldNode ) => {
|
|
|
128
133
|
};
|
|
129
134
|
|
|
130
135
|
};
|
|
131
|
-
|
|
132
|
-
export default EnvironmentNode;
|
|
133
|
-
|
|
134
|
-
addNodeClass( 'EnvironmentNode', EnvironmentNode );
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
+
import { registerNode } from '../core/Node.js';
|
|
1
2
|
import AnalyticLightNode from './AnalyticLightNode.js';
|
|
2
|
-
import { addLightNode } from './LightsNode.js';
|
|
3
3
|
import { uniform } from '../core/UniformNode.js';
|
|
4
4
|
import { mix } from '../math/MathNode.js';
|
|
5
|
-
import { normalView } from '../accessors/
|
|
5
|
+
import { normalView } from '../accessors/Normal.js';
|
|
6
6
|
import { objectPosition } from '../accessors/Object3DNode.js';
|
|
7
|
-
import { addNodeClass } from '../core/Node.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
|
|
|
@@ -51,6 +49,4 @@ class HemisphereLightNode extends AnalyticLightNode {
|
|
|
51
49
|
|
|
52
50
|
export default HemisphereLightNode;
|
|
53
51
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
addLightNode( HemisphereLight, HemisphereLightNode );
|
|
52
|
+
HemisphereLightNode.type = /*@__PURE__*/ registerNode( 'HemisphereLight', HemisphereLightNode );
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
+
import { registerNode } from '../core/Node.js';
|
|
1
2
|
import SpotLightNode from './SpotLightNode.js';
|
|
2
|
-
import { addLightNode } from './LightsNode.js';
|
|
3
3
|
import { texture } from '../accessors/TextureNode.js';
|
|
4
|
-
import { vec2 } from '../
|
|
5
|
-
import { addNodeClass } from '../core/Node.js';
|
|
6
|
-
|
|
7
|
-
import IESSpotLight from '../../lights/webgpu/IESSpotLight.js';
|
|
4
|
+
import { vec2 } from '../tsl/TSLBase.js';
|
|
8
5
|
|
|
9
6
|
class IESSpotLightNode extends SpotLightNode {
|
|
10
7
|
|
|
@@ -34,6 +31,4 @@ class IESSpotLightNode extends SpotLightNode {
|
|
|
34
31
|
|
|
35
32
|
export default IESSpotLightNode;
|
|
36
33
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
addLightNode( IESSpotLight, IESSpotLightNode );
|
|
34
|
+
IESSpotLightNode.type = /*@__PURE__*/ registerNode( 'IESSpotLight', IESSpotLightNode );
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { registerNode } from '../core/Node.js';
|
|
1
2
|
import LightingNode from './LightingNode.js';
|
|
2
|
-
import { addNodeClass } from '../core/Node.js';
|
|
3
3
|
|
|
4
4
|
class IrradianceNode extends LightingNode {
|
|
5
5
|
|
|
@@ -21,4 +21,4 @@ class IrradianceNode extends LightingNode {
|
|
|
21
21
|
|
|
22
22
|
export default IrradianceNode;
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
IrradianceNode.type = /*@__PURE__*/ registerNode( 'Irradiance', IrradianceNode );
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import Node, {
|
|
2
|
-
import { nodeProxy } from '../
|
|
1
|
+
import Node, { registerNode } from '../core/Node.js';
|
|
2
|
+
import { nodeProxy } from '../tsl/TSLBase.js';
|
|
3
3
|
import { objectPosition } from '../accessors/Object3DNode.js';
|
|
4
|
-
import { cameraViewMatrix } from '../accessors/
|
|
4
|
+
import { cameraViewMatrix } from '../accessors/Camera.js';
|
|
5
5
|
|
|
6
6
|
class LightNode extends Node {
|
|
7
7
|
|
|
@@ -52,6 +52,6 @@ LightNode.TARGET_DIRECTION = 'targetDirection';
|
|
|
52
52
|
|
|
53
53
|
export default LightNode;
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
LightNode.type = /*@__PURE__*/ registerNode( 'Light', LightNode );
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
export const lightTargetDirection = /*@__PURE__*/ nodeProxy( LightNode, LightNode.TARGET_DIRECTION );
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { registerNode } from '../core/Node.js';
|
|
2
|
+
import AnalyticLightNode from './AnalyticLightNode.js';
|
|
3
|
+
import { normalWorld } from '../accessors/Normal.js';
|
|
4
|
+
import { uniformArray } from '../accessors/UniformArrayNode.js';
|
|
5
|
+
import { Fn } from '../tsl/TSLBase.js';
|
|
6
|
+
import { mul } from '../math/OperatorNode.js';
|
|
7
|
+
import { Vector3 } from '../../math/Vector3.js';
|
|
8
|
+
|
|
9
|
+
class LightProbeNode extends AnalyticLightNode {
|
|
10
|
+
|
|
11
|
+
constructor( light = null ) {
|
|
12
|
+
|
|
13
|
+
super( light );
|
|
14
|
+
|
|
15
|
+
const array = [];
|
|
16
|
+
|
|
17
|
+
for ( let i = 0; i < 9; i ++ ) array.push( new Vector3() );
|
|
18
|
+
|
|
19
|
+
this.lightProbe = uniformArray( array );
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
update( frame ) {
|
|
24
|
+
|
|
25
|
+
const { light } = this;
|
|
26
|
+
|
|
27
|
+
super.update( frame );
|
|
28
|
+
|
|
29
|
+
//
|
|
30
|
+
|
|
31
|
+
for ( let i = 0; i < 9; i ++ ) {
|
|
32
|
+
|
|
33
|
+
this.lightProbe.array[ i ].copy( light.sh.coefficients[ i ] ).multiplyScalar( light.intensity );
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
setup( builder ) {
|
|
40
|
+
|
|
41
|
+
const irradiance = shGetIrradianceAt( normalWorld, this.lightProbe );
|
|
42
|
+
|
|
43
|
+
builder.context.irradiance.addAssign( irradiance );
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default LightProbeNode;
|
|
50
|
+
|
|
51
|
+
LightProbeNode.type = /*@__PURE__*/ registerNode( 'LightProbe', LightProbeNode );
|
|
52
|
+
|
|
53
|
+
const shGetIrradianceAt = /*@__PURE__*/ Fn( ( [ normal, shCoefficients ] ) => {
|
|
54
|
+
|
|
55
|
+
// normal is assumed to have unit length
|
|
56
|
+
|
|
57
|
+
const x = normal.x, y = normal.y, z = normal.z;
|
|
58
|
+
|
|
59
|
+
// band 0
|
|
60
|
+
const result = shCoefficients.element( 0 ).mul( 0.886227 );
|
|
61
|
+
|
|
62
|
+
// band 1
|
|
63
|
+
result.addAssign( shCoefficients.element( 1 ).mul( 2.0 * 0.511664 ).mul( y ) );
|
|
64
|
+
result.addAssign( shCoefficients.element( 2 ).mul( 2.0 * 0.511664 ).mul( z ) );
|
|
65
|
+
result.addAssign( shCoefficients.element( 3 ).mul( 2.0 * 0.511664 ).mul( x ) );
|
|
66
|
+
|
|
67
|
+
// band 2
|
|
68
|
+
result.addAssign( shCoefficients.element( 4 ).mul( 2.0 * 0.429043 ).mul( x ).mul( y ) );
|
|
69
|
+
result.addAssign( shCoefficients.element( 5 ).mul( 2.0 * 0.429043 ).mul( y ).mul( z ) );
|
|
70
|
+
result.addAssign( shCoefficients.element( 6 ).mul( z.mul( z ).mul( 0.743125 ).sub( 0.247708 ) ) );
|
|
71
|
+
result.addAssign( shCoefficients.element( 7 ).mul( 2.0 * 0.429043 ).mul( x ).mul( z ) );
|
|
72
|
+
result.addAssign( shCoefficients.element( 8 ).mul( 0.429043 ).mul( mul( x, x ).sub( mul( y, y ) ) ) );
|
|
73
|
+
|
|
74
|
+
return result;
|
|
75
|
+
|
|
76
|
+
} );
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Fn } from '../tsl/TSLBase.js';
|
|
2
2
|
|
|
3
|
-
export const getDistanceAttenuation =
|
|
3
|
+
export const getDistanceAttenuation = /*@__PURE__*/ Fn( ( inputs ) => {
|
|
4
4
|
|
|
5
5
|
const { lightDistance, cutoffDistance, decayExponent } = inputs;
|
|
6
6
|
|
|
@@ -9,7 +9,7 @@ export const getDistanceAttenuation = tslFn( ( inputs ) => {
|
|
|
9
9
|
// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf
|
|
10
10
|
const distanceFalloff = lightDistance.pow( decayExponent ).max( 0.01 ).reciprocal();
|
|
11
11
|
|
|
12
|
-
return cutoffDistance.greaterThan( 0 ).
|
|
12
|
+
return cutoffDistance.greaterThan( 0 ).select(
|
|
13
13
|
distanceFalloff.mul( lightDistance.div( cutoffDistance ).pow4().oneMinus().clamp().pow2() ),
|
|
14
14
|
distanceFalloff
|
|
15
15
|
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { registerNode } from '../core/Node.js';
|
|
1
2
|
import ContextNode from '../core/ContextNode.js';
|
|
2
|
-
import {
|
|
3
|
-
import { addNodeElement, nodeProxy, float, vec3 } from '../shadernode/ShaderNode.js';
|
|
3
|
+
import { nodeProxy, float, vec3 } from '../tsl/TSLBase.js';
|
|
4
4
|
|
|
5
5
|
class LightingContextNode extends ContextNode {
|
|
6
6
|
|
|
@@ -12,7 +12,7 @@ class LightingContextNode extends ContextNode {
|
|
|
12
12
|
this.backdropNode = backdropNode;
|
|
13
13
|
this.backdropAlphaNode = backdropAlphaNode;
|
|
14
14
|
|
|
15
|
-
this.
|
|
15
|
+
this._value = null;
|
|
16
16
|
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -20,10 +20,10 @@ class LightingContextNode extends ContextNode {
|
|
|
20
20
|
|
|
21
21
|
const { backdropNode, backdropAlphaNode } = this;
|
|
22
22
|
|
|
23
|
-
const directDiffuse = vec3().
|
|
24
|
-
directSpecular = vec3().
|
|
25
|
-
indirectDiffuse = vec3().
|
|
26
|
-
indirectSpecular = vec3().
|
|
23
|
+
const directDiffuse = vec3().toVar( 'directDiffuse' ),
|
|
24
|
+
directSpecular = vec3().toVar( 'directSpecular' ),
|
|
25
|
+
indirectDiffuse = vec3().toVar( 'indirectDiffuse' ),
|
|
26
|
+
indirectSpecular = vec3().toVar( 'indirectSpecular' );
|
|
27
27
|
|
|
28
28
|
const reflectedLight = {
|
|
29
29
|
directDiffuse,
|
|
@@ -33,10 +33,10 @@ class LightingContextNode extends ContextNode {
|
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
const context = {
|
|
36
|
-
radiance: vec3().
|
|
37
|
-
irradiance: vec3().
|
|
38
|
-
iblIrradiance: vec3().
|
|
39
|
-
ambientOcclusion: float( 1 ).
|
|
36
|
+
radiance: vec3().toVar( 'radiance' ),
|
|
37
|
+
irradiance: vec3().toVar( 'irradiance' ),
|
|
38
|
+
iblIrradiance: vec3().toVar( 'iblIrradiance' ),
|
|
39
|
+
ambientOcclusion: float( 1 ).toVar( 'ambientOcclusion' ),
|
|
40
40
|
reflectedLight,
|
|
41
41
|
backdrop: backdropNode,
|
|
42
42
|
backdropAlpha: backdropAlphaNode
|
|
@@ -48,8 +48,8 @@ class LightingContextNode extends ContextNode {
|
|
|
48
48
|
|
|
49
49
|
setup( builder ) {
|
|
50
50
|
|
|
51
|
-
this.
|
|
52
|
-
this.
|
|
51
|
+
this.value = this._value || ( this._value = this.getContext() );
|
|
52
|
+
this.value.lightingModel = this.lightingModel || builder.context.lightingModel;
|
|
53
53
|
|
|
54
54
|
return super.setup( builder );
|
|
55
55
|
|
|
@@ -59,8 +59,6 @@ class LightingContextNode extends ContextNode {
|
|
|
59
59
|
|
|
60
60
|
export default LightingContextNode;
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
LightingContextNode.type = /*@__PURE__*/ registerNode( 'LightingContext', LightingContextNode );
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
addNodeClass( 'LightingContextNode', LightingContextNode );
|
|
64
|
+
export const lightingContext = /*@__PURE__*/ nodeProxy( LightingContextNode );
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Node, {
|
|
1
|
+
import Node, { registerNode } from '../core/Node.js';
|
|
2
2
|
|
|
3
3
|
class LightingNode extends Node {
|
|
4
4
|
|
|
@@ -20,4 +20,4 @@ class LightingNode extends Node {
|
|
|
20
20
|
|
|
21
21
|
export default LightingNode;
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
LightingNode.type = /*@__PURE__*/ registerNode( 'Lighting', LightingNode );
|