super-three 0.168.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 +369 -131
- package/build/three.module.js +369 -131
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +24644 -22406
- 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 -6
- package/examples/jsm/controls/TrackballControls.js +32 -12
- package/examples/jsm/controls/TransformControls.js +97 -62
- package/examples/jsm/exporters/DRACOExporter.js +4 -2
- package/examples/jsm/exporters/EXRExporter.js +19 -11
- 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/geometries/DecalGeometry.js +4 -1
- package/examples/jsm/geometries/InstancedPointsGeometry.js +1 -1
- package/examples/jsm/helpers/LightProbeHelper.js +1 -1
- 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 +10 -7
- package/examples/jsm/loaders/MTLLoader.js +4 -3
- package/examples/jsm/loaders/MaterialXLoader.js +29 -10
- package/examples/jsm/loaders/OBJLoader.js +5 -3
- package/examples/jsm/loaders/PCDLoader.js +5 -4
- 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 +1 -2
- package/examples/jsm/objects/Water2Mesh.js +2 -3
- package/examples/jsm/objects/WaterMesh.js +1 -2
- package/examples/jsm/physics/JoltPhysics.js +1 -1
- package/examples/jsm/physics/RapierPhysics.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -2
- 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 +1 -0
- package/examples/jsm/utils/TextureUtilsGPU.js +63 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
- package/package.json +2 -2
- package/src/Three.WebGPU.Nodes.js +200 -0
- package/src/Three.WebGPU.js +2 -1
- 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 +1 -1
- package/src/geometries/CylinderGeometry.js +11 -4
- package/src/loaders/MaterialLoader.js +7 -1
- package/src/loaders/nodes/NodeLoader.js +24 -4
- package/src/loaders/nodes/NodeMaterialLoader.js +21 -17
- package/src/loaders/nodes/NodeObjectLoader.js +19 -0
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +19 -34
- package/src/materials/nodes/Line2NodeMaterial.js +26 -26
- package/src/materials/nodes/LineBasicNodeMaterial.js +7 -3
- package/src/materials/nodes/LineDashedNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshBasicNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshLambertNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshNormalNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshPhongNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +6 -3
- package/src/materials/nodes/MeshSSSNodeMaterial.js +6 -3
- package/src/materials/nodes/MeshStandardNodeMaterial.js +7 -3
- package/src/materials/nodes/MeshToonNodeMaterial.js +7 -3
- package/src/materials/nodes/NodeMaterial.js +20 -45
- package/src/materials/nodes/NodeMaterials.js +2 -0
- package/src/materials/nodes/PointsNodeMaterial.js +7 -3
- package/src/materials/nodes/ShadowNodeMaterial.js +7 -3
- package/src/materials/nodes/SpriteNodeMaterial.js +39 -6
- package/src/materials/nodes/VolumeNodeMaterial.js +13 -9
- package/src/materials/nodes/manager/NodeMaterialObserver.js +302 -0
- package/src/math/Triangle.js +24 -0
- package/src/nodes/Nodes.js +3 -3
- package/src/nodes/TSL.js +96 -93
- package/src/nodes/accessors/BatchNode.js +7 -3
- package/src/nodes/accessors/BufferAttributeNode.js +6 -3
- package/src/nodes/accessors/BufferNode.js +6 -3
- package/src/nodes/accessors/Camera.js +10 -16
- package/src/nodes/accessors/ClippingNode.js +7 -3
- package/src/nodes/accessors/CubeTextureNode.js +6 -3
- package/src/nodes/accessors/InstanceNode.js +11 -11
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +6 -3
- package/src/nodes/accessors/Lights.js +51 -0
- package/src/nodes/accessors/MaterialNode.js +8 -4
- package/src/nodes/accessors/MaterialReferenceNode.js +6 -3
- package/src/nodes/accessors/ModelNode.js +42 -7
- package/src/nodes/accessors/ModelViewProjectionNode.js +9 -5
- package/src/nodes/accessors/MorphNode.js +7 -3
- package/src/nodes/accessors/Normal.js +32 -6
- package/src/nodes/accessors/Object3DNode.js +11 -27
- package/src/nodes/accessors/PointUVNode.js +7 -3
- package/src/nodes/accessors/ReferenceBaseNode.js +32 -4
- package/src/nodes/accessors/ReferenceNode.js +40 -3
- package/src/nodes/accessors/RendererReferenceNode.js +9 -3
- package/src/nodes/accessors/SceneNode.js +7 -3
- package/src/nodes/accessors/SkinningNode.js +7 -3
- package/src/nodes/accessors/StorageBufferNode.js +21 -3
- package/src/nodes/accessors/StorageTextureNode.js +7 -4
- package/src/nodes/accessors/Texture3DNode.js +7 -4
- package/src/nodes/accessors/TextureNode.js +19 -8
- package/src/nodes/accessors/TextureSizeNode.js +8 -5
- package/src/nodes/accessors/UniformArrayNode.js +12 -9
- package/src/nodes/accessors/UserDataNode.js +9 -6
- package/src/nodes/accessors/VelocityNode.js +74 -23
- package/src/nodes/accessors/VertexColorNode.js +6 -3
- package/src/nodes/code/CodeNode.js +7 -3
- package/src/nodes/code/ExpressionNode.js +8 -4
- package/src/nodes/code/FunctionCallNode.js +6 -3
- package/src/nodes/code/FunctionNode.js +6 -3
- package/src/nodes/code/ScriptableNode.js +11 -6
- package/src/nodes/code/ScriptableValueNode.js +7 -3
- package/src/nodes/core/AssignNode.js +9 -6
- package/src/nodes/core/AttributeNode.js +7 -3
- package/src/nodes/core/BypassNode.js +8 -4
- package/src/nodes/core/CacheNode.js +8 -4
- package/src/nodes/core/ConstNode.js +6 -3
- package/src/nodes/core/ContextNode.js +7 -3
- package/src/nodes/core/IndexNode.js +25 -3
- package/src/nodes/core/InputNode.js +7 -3
- package/src/nodes/core/MRTNode.js +6 -3
- package/src/nodes/core/Node.js +10 -51
- package/src/nodes/core/NodeBuilder.js +71 -5
- package/src/nodes/core/NodeUtils.js +48 -6
- package/src/nodes/core/OutputStructNode.js +8 -4
- package/src/nodes/core/ParameterNode.js +6 -3
- package/src/nodes/core/PropertyNode.js +7 -3
- package/src/nodes/core/StackNode.js +7 -3
- package/src/nodes/core/StructTypeNode.js +7 -3
- package/src/nodes/core/TempNode.js +8 -4
- package/src/nodes/core/UniformGroupNode.js +10 -6
- package/src/nodes/core/UniformNode.js +6 -3
- package/src/nodes/core/VarNode.js +8 -4
- package/src/nodes/core/VaryingNode.js +7 -3
- package/src/nodes/display/AfterImageNode.js +6 -0
- package/src/nodes/display/AnaglyphPassNode.js +6 -0
- package/src/nodes/display/AnamorphicNode.js +6 -0
- package/src/nodes/display/BloomNode.js +6 -0
- package/src/nodes/display/BumpMapNode.js +6 -0
- package/src/nodes/display/ColorSpaceFunctions.js +4 -4
- package/src/nodes/display/ColorSpaceNode.js +43 -14
- package/src/nodes/display/DenoiseNode.js +6 -3
- package/src/nodes/display/DepthOfFieldNode.js +6 -3
- package/src/nodes/display/DotScreenNode.js +8 -5
- package/src/nodes/display/FXAANode.js +6 -3
- package/src/nodes/display/FilmNode.js +6 -3
- package/src/nodes/display/FrontFacingNode.js +7 -3
- package/src/nodes/display/GTAONode.js +6 -3
- package/src/nodes/display/GaussianBlurNode.js +6 -3
- package/src/nodes/display/Lut3DNode.js +6 -3
- package/src/nodes/display/NormalMapNode.js +8 -6
- package/src/nodes/display/ParallaxBarrierPassNode.js +8 -5
- package/src/nodes/display/PassNode.js +18 -7
- package/src/nodes/display/PixelationPassNode.js +12 -5
- package/src/nodes/display/PosterizeNode.js +6 -3
- package/src/nodes/display/RGBShiftNode.js +6 -3
- package/src/nodes/display/RenderOutputNode.js +12 -8
- package/src/nodes/display/SSAAPassNode.js +6 -3
- package/src/nodes/display/ScreenNode.js +181 -0
- package/src/nodes/display/SobelOperatorNode.js +6 -3
- package/src/nodes/display/StereoCompositePassNode.js +6 -3
- package/src/nodes/display/StereoPassNode.js +6 -3
- package/src/nodes/display/ToneMappingFunctions.js +12 -12
- package/src/nodes/display/ToneMappingNode.js +8 -7
- package/src/nodes/display/ToonOutlinePassNode.js +111 -0
- package/src/nodes/display/TransitionNode.js +6 -3
- package/src/nodes/display/ViewportDepthNode.js +7 -3
- package/src/nodes/display/ViewportDepthTextureNode.js +8 -5
- package/src/nodes/display/ViewportSharedTextureNode.js +8 -5
- package/src/nodes/display/ViewportTextureNode.js +8 -5
- package/src/nodes/fog/FogExp2Node.js +6 -3
- package/src/nodes/fog/FogNode.js +7 -3
- package/src/nodes/fog/FogRangeNode.js +6 -3
- package/src/nodes/functions/PhysicalLightingModel.js +2 -2
- package/src/nodes/functions/material/getShIrradianceAt.js +28 -0
- package/src/nodes/geometry/RangeNode.js +7 -3
- 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 +8 -4
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +100 -0
- package/src/nodes/lighting/AONode.js +6 -3
- package/src/nodes/lighting/AmbientLightNode.js +6 -3
- package/src/nodes/lighting/AnalyticLightNode.js +198 -30
- package/src/nodes/lighting/BasicEnvironmentNode.js +6 -3
- package/src/nodes/lighting/BasicLightMapNode.js +6 -3
- package/src/nodes/lighting/DirectionalLightNode.js +7 -4
- package/src/nodes/lighting/EnvironmentNode.js +6 -3
- package/src/nodes/lighting/HemisphereLightNode.js +10 -6
- package/src/nodes/lighting/IESSpotLightNode.js +6 -3
- package/src/nodes/lighting/IrradianceNode.js +6 -3
- package/src/nodes/lighting/LightProbeNode.js +8 -31
- package/src/nodes/lighting/LightingContextNode.js +6 -3
- package/src/nodes/lighting/LightingNode.js +7 -3
- package/src/nodes/lighting/LightsNode.js +24 -5
- package/src/nodes/lighting/PointLightNode.js +11 -7
- package/src/nodes/lighting/RectAreaLightNode.js +11 -7
- package/src/nodes/lighting/SpotLightNode.js +13 -10
- package/src/nodes/math/ConditionalNode.js +23 -6
- package/src/nodes/math/MathNode.js +6 -3
- package/src/nodes/math/OperatorNode.js +6 -3
- package/src/nodes/pmrem/PMREMNode.js +6 -3
- package/src/nodes/utils/ArrayElementNode.js +8 -4
- package/src/nodes/utils/ConvertNode.js +7 -3
- package/src/nodes/utils/CubeMapNode.js +6 -3
- package/src/nodes/utils/EquirectUVNode.js +6 -3
- package/src/nodes/utils/FlipNode.js +7 -4
- package/src/nodes/utils/FunctionOverloadingNode.js +7 -3
- package/src/nodes/utils/JoinNode.js +6 -3
- package/src/nodes/utils/LoopNode.js +7 -3
- package/src/nodes/utils/MatcapUVNode.js +6 -3
- package/src/nodes/utils/MaxMipLevelNode.js +6 -3
- package/src/nodes/utils/OscNode.js +7 -3
- package/src/nodes/utils/RTTNode.js +6 -3
- package/src/nodes/utils/ReflectorNode.js +8 -5
- package/src/nodes/utils/RemapNode.js +7 -3
- package/src/nodes/utils/RotateNode.js +6 -3
- package/src/nodes/utils/SetNode.js +7 -4
- package/src/nodes/utils/SplitNode.js +7 -3
- package/src/nodes/utils/SpriteSheetUVNode.js +7 -3
- package/src/nodes/utils/StorageArrayElementNode.js +9 -8
- package/src/nodes/utils/TimerNode.js +6 -3
- package/src/nodes/utils/TriplanarTexturesNode.js +7 -3
- package/src/nodes/utils/ViewportUtils.js +2 -2
- package/src/objects/BatchedMesh.js +76 -10
- 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 +64 -41
- package/src/renderers/common/BundleGroup.js +26 -0
- package/src/renderers/common/ClippingContext.js +4 -3
- package/src/renderers/common/RenderContext.js +4 -5
- package/src/renderers/common/RenderObject.js +116 -5
- package/src/renderers/common/RenderObjects.js +8 -1
- package/src/renderers/common/Renderer.js +57 -49
- package/src/renderers/common/extras/PMREMGenerator.js +7 -9
- package/src/renderers/common/nodes/NodeBuilderState.js +3 -3
- package/src/renderers/common/nodes/Nodes.js +33 -14
- 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 +2 -0
- package/src/renderers/webgl/WebGLPrograms.js +21 -17
- package/src/renderers/webgl/WebGLState.js +21 -0
- package/src/renderers/webgl/WebGLTextures.js +22 -0
- package/src/renderers/webgl-fallback/WebGLBackend.js +50 -45
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +4 -4
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +6 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +1 -4
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +61 -16
- package/src/renderers/webgpu/WebGPUBackend.js +33 -25
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +42 -0
- package/src/renderers/webgpu/WebGPURenderer.js +5 -2
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +59 -0
- package/src/renderers/{common → webgpu}/nodes/StandardNodeLibrary.js +11 -11
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +91 -11
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +6 -16
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +7 -5
- package/src/renderers/webgpu/utils/WebGPUUtils.js +1 -1
- package/src/utils.js +33 -1
- package/examples/jsm/geometries/SDFGeometryGenerator.js +0 -144
- 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/display/ViewportNode.js +0 -138
- package/src/nodes/lighting/LightNode.js +0 -57
- package/src/renderers/common/StandardRenderer.js +0 -18
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import { registerNode } from '../core/Node.js';
|
|
2
1
|
import LightingNode from './LightingNode.js';
|
|
3
2
|
import { NodeUpdateType } from '../core/constants.js';
|
|
4
3
|
import { uniform } from '../core/UniformNode.js';
|
|
5
|
-
import { float, vec2, vec3, vec4 } from '../tsl/TSLBase.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
7
|
import { positionWorld } from '../accessors/Position.js';
|
|
9
8
|
import { normalWorld } from '../accessors/Normal.js';
|
|
10
|
-
import { mix, fract } from '../math/MathNode.js';
|
|
11
|
-
import { add } from '../math/OperatorNode.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 { Fn } from '../tsl/TSLBase.js';
|
|
15
|
-
import { LessCompare, WebGPUCoordinateSystem } from '../../constants.js';
|
|
16
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';
|
|
17
20
|
|
|
18
21
|
const BasicShadowMap = Fn( ( { depthTexture, shadowCoord } ) => {
|
|
19
22
|
|
|
@@ -25,8 +28,8 @@ const PCFShadowMap = Fn( ( { depthTexture, shadowCoord, shadow } ) => {
|
|
|
25
28
|
|
|
26
29
|
const depthCompare = ( uv, compare ) => texture( depthTexture, uv ).compare( compare );
|
|
27
30
|
|
|
28
|
-
const mapSize = reference( 'mapSize', 'vec2', shadow );
|
|
29
|
-
const radius = reference( 'radius', 'float', shadow );
|
|
31
|
+
const mapSize = reference( 'mapSize', 'vec2', shadow ).setGroup( renderGroup );
|
|
32
|
+
const radius = reference( 'radius', 'float', shadow ).setGroup( renderGroup );
|
|
30
33
|
|
|
31
34
|
const texelSize = vec2( 1 ).div( mapSize );
|
|
32
35
|
const dx0 = texelSize.x.negate().mul( radius );
|
|
@@ -64,7 +67,7 @@ const PCFSoftShadowMap = Fn( ( { depthTexture, shadowCoord, shadow } ) => {
|
|
|
64
67
|
|
|
65
68
|
const depthCompare = ( uv, compare ) => texture( depthTexture, uv ).compare( compare );
|
|
66
69
|
|
|
67
|
-
const mapSize = reference( 'mapSize', 'vec2', shadow );
|
|
70
|
+
const mapSize = reference( 'mapSize', 'vec2', shadow ).setGroup( renderGroup );
|
|
68
71
|
|
|
69
72
|
const texelSize = vec2( 1 ).div( mapSize );
|
|
70
73
|
const dx = texelSize.x;
|
|
@@ -116,14 +119,97 @@ const PCFSoftShadowMap = Fn( ( { depthTexture, shadowCoord, shadow } ) => {
|
|
|
116
119
|
|
|
117
120
|
} );
|
|
118
121
|
|
|
119
|
-
|
|
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 ];
|
|
120
199
|
|
|
121
200
|
//
|
|
122
201
|
|
|
123
|
-
let
|
|
202
|
+
let _overrideMaterial = null;
|
|
203
|
+
const _quadMesh = /*@__PURE__*/ new QuadMesh();
|
|
124
204
|
|
|
125
205
|
class AnalyticLightNode extends LightingNode {
|
|
126
206
|
|
|
207
|
+
static get type() {
|
|
208
|
+
|
|
209
|
+
return 'AnalyticLightNode';
|
|
210
|
+
|
|
211
|
+
}
|
|
212
|
+
|
|
127
213
|
constructor( light = null ) {
|
|
128
214
|
|
|
129
215
|
super();
|
|
@@ -133,7 +219,7 @@ class AnalyticLightNode extends LightingNode {
|
|
|
133
219
|
this.light = light;
|
|
134
220
|
|
|
135
221
|
this.color = new Color();
|
|
136
|
-
this.colorNode = uniform( this.color );
|
|
222
|
+
this.colorNode = uniform( this.color ).setGroup( renderGroup );
|
|
137
223
|
|
|
138
224
|
this.baseColorNode = null;
|
|
139
225
|
|
|
@@ -141,13 +227,19 @@ class AnalyticLightNode extends LightingNode {
|
|
|
141
227
|
this.shadowNode = null;
|
|
142
228
|
this.shadowColorNode = null;
|
|
143
229
|
|
|
230
|
+
this.vsmShadowMapVertical = null;
|
|
231
|
+
this.vsmShadowMapHorizontal = null;
|
|
232
|
+
|
|
233
|
+
this.vsmMaterialVertical = null;
|
|
234
|
+
this.vsmMaterialHorizontal = null;
|
|
235
|
+
|
|
144
236
|
this.isAnalyticLightNode = true;
|
|
145
237
|
|
|
146
238
|
}
|
|
147
239
|
|
|
148
240
|
getCacheKey() {
|
|
149
241
|
|
|
150
|
-
return super.getCacheKey()
|
|
242
|
+
return hash( super.getCacheKey(), this.light.id, this.light.castShadow ? 1 : 0 );
|
|
151
243
|
|
|
152
244
|
}
|
|
153
245
|
|
|
@@ -161,37 +253,67 @@ class AnalyticLightNode extends LightingNode {
|
|
|
161
253
|
|
|
162
254
|
const { object, renderer } = builder;
|
|
163
255
|
|
|
256
|
+
if ( renderer.shadowMap.enabled === false ) return;
|
|
257
|
+
|
|
164
258
|
let shadowColorNode = this.shadowColorNode;
|
|
165
259
|
|
|
166
260
|
if ( shadowColorNode === null ) {
|
|
167
261
|
|
|
168
|
-
if (
|
|
262
|
+
if ( _overrideMaterial === null ) {
|
|
169
263
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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';
|
|
174
268
|
|
|
175
269
|
}
|
|
176
270
|
|
|
271
|
+
const shadowMapType = renderer.shadowMap.type;
|
|
272
|
+
const shadow = this.light.shadow;
|
|
273
|
+
|
|
177
274
|
const depthTexture = new DepthTexture();
|
|
178
275
|
depthTexture.compareFunction = LessCompare;
|
|
179
276
|
|
|
180
|
-
const shadow = this.light.shadow;
|
|
181
277
|
const shadowMap = builder.createRenderTarget( shadow.mapSize.width, shadow.mapSize.height );
|
|
182
278
|
shadowMap.depthTexture = depthTexture;
|
|
183
279
|
|
|
184
280
|
shadow.camera.updateProjectionMatrix();
|
|
185
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
|
+
|
|
186
308
|
//
|
|
187
309
|
|
|
188
|
-
const shadowIntensity = reference( 'intensity', 'float', shadow );
|
|
189
|
-
const bias = reference( 'bias', 'float', shadow );
|
|
190
|
-
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 );
|
|
191
313
|
|
|
192
314
|
const position = object.material.shadowPositionNode || positionWorld;
|
|
193
315
|
|
|
194
|
-
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 ) ) );
|
|
195
317
|
shadowCoord = shadowCoord.xyz.div( shadowCoord.w );
|
|
196
318
|
|
|
197
319
|
let coordZ = shadowCoord.z.add( bias );
|
|
@@ -216,7 +338,7 @@ class AnalyticLightNode extends LightingNode {
|
|
|
216
338
|
|
|
217
339
|
//
|
|
218
340
|
|
|
219
|
-
const filterFn = shadow.filterNode ||
|
|
341
|
+
const filterFn = shadow.filterNode || _shadowFilterLib[ renderer.shadowMap.type ] || null;
|
|
220
342
|
|
|
221
343
|
if ( filterFn === null ) {
|
|
222
344
|
|
|
@@ -225,9 +347,10 @@ class AnalyticLightNode extends LightingNode {
|
|
|
225
347
|
}
|
|
226
348
|
|
|
227
349
|
const shadowColor = texture( shadowMap.texture, shadowCoord );
|
|
228
|
-
const shadowNode = frustumTest.select( filterFn( { depthTexture, shadowCoord, shadow } ), float( 1 ) );
|
|
350
|
+
const shadowNode = frustumTest.select( filterFn( { depthTexture: ( shadowMapType === VSMShadowMap ) ? this.vsmShadowMapHorizontal.texture : depthTexture, shadowCoord, shadow } ), float( 1 ) );
|
|
229
351
|
|
|
230
352
|
this.shadowMap = shadowMap;
|
|
353
|
+
this.light.shadow.map = shadowMap;
|
|
231
354
|
|
|
232
355
|
this.shadowNode = shadowNode;
|
|
233
356
|
this.shadowColorNode = shadowColorNode = this.colorNode.mul( mix( 1, shadowNode.rgb.mix( shadowColor, 1 ), shadowIntensity.mul( shadowColor.a ) ) );
|
|
@@ -269,13 +392,14 @@ class AnalyticLightNode extends LightingNode {
|
|
|
269
392
|
const { shadowMap, light } = this;
|
|
270
393
|
const { renderer, scene, camera } = frame;
|
|
271
394
|
|
|
395
|
+
const shadowType = renderer.shadowMap.type;
|
|
272
396
|
|
|
273
397
|
const depthVersion = shadowMap.depthTexture.version;
|
|
274
398
|
this._depthVersionCached = depthVersion;
|
|
275
399
|
|
|
276
400
|
const currentOverrideMaterial = scene.overrideMaterial;
|
|
277
401
|
|
|
278
|
-
scene.overrideMaterial =
|
|
402
|
+
scene.overrideMaterial = _overrideMaterial;
|
|
279
403
|
|
|
280
404
|
shadowMap.setSize( light.shadow.mapSize.width, light.shadow.mapSize.height );
|
|
281
405
|
|
|
@@ -287,7 +411,7 @@ class AnalyticLightNode extends LightingNode {
|
|
|
287
411
|
|
|
288
412
|
renderer.setRenderObjectFunction( ( object, ...params ) => {
|
|
289
413
|
|
|
290
|
-
if ( object.castShadow === true ) {
|
|
414
|
+
if ( object.castShadow === true || ( object.receiveShadow && shadowType === VSMShadowMap ) ) {
|
|
291
415
|
|
|
292
416
|
renderer.renderObject( object, ...params );
|
|
293
417
|
|
|
@@ -298,18 +422,64 @@ class AnalyticLightNode extends LightingNode {
|
|
|
298
422
|
renderer.setRenderTarget( shadowMap );
|
|
299
423
|
renderer.render( scene, light.shadow.camera );
|
|
300
424
|
|
|
301
|
-
renderer.setRenderTarget( currentRenderTarget );
|
|
302
425
|
renderer.setRenderObjectFunction( currentRenderObjectFunction );
|
|
303
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
|
+
|
|
304
437
|
scene.overrideMaterial = currentOverrideMaterial;
|
|
305
438
|
|
|
306
439
|
}
|
|
307
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
|
+
|
|
308
458
|
disposeShadow() {
|
|
309
459
|
|
|
310
460
|
this.shadowMap.dispose();
|
|
311
461
|
this.shadowMap = null;
|
|
312
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
|
+
|
|
313
483
|
this.shadowNode = null;
|
|
314
484
|
this.shadowColorNode = null;
|
|
315
485
|
|
|
@@ -350,5 +520,3 @@ class AnalyticLightNode extends LightingNode {
|
|
|
350
520
|
}
|
|
351
521
|
|
|
352
522
|
export default AnalyticLightNode;
|
|
353
|
-
|
|
354
|
-
AnalyticLightNode.type = /*@__PURE__*/ registerNode( 'AnalyticLight', AnalyticLightNode );
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { registerNode } from '../core/Node.js';
|
|
2
1
|
import LightingNode from './LightingNode.js';
|
|
3
2
|
import { cubeMapNode } from '../utils/CubeMapNode.js';
|
|
4
3
|
|
|
5
4
|
class BasicEnvironmentNode extends LightingNode {
|
|
6
5
|
|
|
6
|
+
static get type() {
|
|
7
|
+
|
|
8
|
+
return 'BasicEnvironmentNode';
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
7
12
|
constructor( envNode = null ) {
|
|
8
13
|
|
|
9
14
|
super();
|
|
@@ -23,5 +28,3 @@ class BasicEnvironmentNode extends LightingNode {
|
|
|
23
28
|
}
|
|
24
29
|
|
|
25
30
|
export default BasicEnvironmentNode;
|
|
26
|
-
|
|
27
|
-
BasicEnvironmentNode.type = /*@__PURE__*/ registerNode( 'BasicEnvironment', BasicEnvironmentNode );
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { registerNode } from '../core/Node.js';
|
|
2
1
|
import LightingNode from './LightingNode.js';
|
|
3
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
|
-
BasicLightMapNode.type = /*@__PURE__*/ registerNode( 'BasicLightMap', BasicLightMapNode );
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { registerNode } from '../core/Node.js';
|
|
2
1
|
import AnalyticLightNode from './AnalyticLightNode.js';
|
|
3
|
-
import { lightTargetDirection } from '
|
|
2
|
+
import { lightTargetDirection } from '../accessors/Lights.js';
|
|
4
3
|
|
|
5
4
|
class DirectionalLightNode extends AnalyticLightNode {
|
|
6
5
|
|
|
6
|
+
static get type() {
|
|
7
|
+
|
|
8
|
+
return 'DirectionalLightNode';
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
7
12
|
constructor( light = null ) {
|
|
8
13
|
|
|
9
14
|
super( light );
|
|
@@ -31,5 +36,3 @@ class DirectionalLightNode extends AnalyticLightNode {
|
|
|
31
36
|
}
|
|
32
37
|
|
|
33
38
|
export default DirectionalLightNode;
|
|
34
|
-
|
|
35
|
-
DirectionalLightNode.type = /*@__PURE__*/ registerNode( 'DirectionalLight', DirectionalLightNode );
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { registerNode } from '../core/Node.js';
|
|
2
1
|
import LightingNode from './LightingNode.js';
|
|
3
2
|
import { cache } from '../core/CacheNode.js';
|
|
4
3
|
import { roughness, clearcoatRoughness } from '../core/PropertyNode.js';
|
|
@@ -14,6 +13,12 @@ const _envNodeCache = new WeakMap();
|
|
|
14
13
|
|
|
15
14
|
class EnvironmentNode extends LightingNode {
|
|
16
15
|
|
|
16
|
+
static get type() {
|
|
17
|
+
|
|
18
|
+
return 'EnvironmentNode';
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
17
22
|
constructor( envNode = null ) {
|
|
18
23
|
|
|
19
24
|
super();
|
|
@@ -85,8 +90,6 @@ class EnvironmentNode extends LightingNode {
|
|
|
85
90
|
|
|
86
91
|
export default EnvironmentNode;
|
|
87
92
|
|
|
88
|
-
EnvironmentNode.type = /*@__PURE__*/ registerNode( 'Environment', EnvironmentNode );
|
|
89
|
-
|
|
90
93
|
const createRadianceContext = ( roughnessNode, normalViewNode ) => {
|
|
91
94
|
|
|
92
95
|
let reflectVec = null;
|
|
@@ -1,22 +1,28 @@
|
|
|
1
|
-
import { registerNode } from '../core/Node.js';
|
|
2
1
|
import AnalyticLightNode from './AnalyticLightNode.js';
|
|
3
2
|
import { uniform } from '../core/UniformNode.js';
|
|
4
3
|
import { mix } from '../math/MathNode.js';
|
|
5
4
|
import { normalView } from '../accessors/Normal.js';
|
|
6
|
-
import {
|
|
5
|
+
import { lightPosition } from '../accessors/Lights.js';
|
|
6
|
+
import { renderGroup } from '../core/UniformGroupNode.js';
|
|
7
7
|
|
|
8
8
|
import { Color } from '../../math/Color.js';
|
|
9
9
|
|
|
10
10
|
class HemisphereLightNode extends AnalyticLightNode {
|
|
11
11
|
|
|
12
|
+
static get type() {
|
|
13
|
+
|
|
14
|
+
return 'HemisphereLightNode';
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
|
|
12
18
|
constructor( light = null ) {
|
|
13
19
|
|
|
14
20
|
super( light );
|
|
15
21
|
|
|
16
|
-
this.lightPositionNode =
|
|
22
|
+
this.lightPositionNode = lightPosition( light );
|
|
17
23
|
this.lightDirectionNode = this.lightPositionNode.normalize();
|
|
18
24
|
|
|
19
|
-
this.groundColorNode = uniform( new Color() );
|
|
25
|
+
this.groundColorNode = uniform( new Color() ).setGroup( renderGroup );
|
|
20
26
|
|
|
21
27
|
}
|
|
22
28
|
|
|
@@ -48,5 +54,3 @@ class HemisphereLightNode extends AnalyticLightNode {
|
|
|
48
54
|
}
|
|
49
55
|
|
|
50
56
|
export default HemisphereLightNode;
|
|
51
|
-
|
|
52
|
-
HemisphereLightNode.type = /*@__PURE__*/ registerNode( 'HemisphereLight', HemisphereLightNode );
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { registerNode } from '../core/Node.js';
|
|
2
1
|
import SpotLightNode from './SpotLightNode.js';
|
|
3
2
|
import { texture } from '../accessors/TextureNode.js';
|
|
4
3
|
import { vec2 } from '../tsl/TSLBase.js';
|
|
5
4
|
|
|
6
5
|
class IESSpotLightNode extends SpotLightNode {
|
|
7
6
|
|
|
7
|
+
static get type() {
|
|
8
|
+
|
|
9
|
+
return 'IESSpotLightNode';
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
|
|
8
13
|
getSpotAttenuation( angleCosine ) {
|
|
9
14
|
|
|
10
15
|
const iesMap = this.light.iesMap;
|
|
@@ -30,5 +35,3 @@ class IESSpotLightNode extends SpotLightNode {
|
|
|
30
35
|
}
|
|
31
36
|
|
|
32
37
|
export default IESSpotLightNode;
|
|
33
|
-
|
|
34
|
-
IESSpotLightNode.type = /*@__PURE__*/ registerNode( 'IESSpotLight', IESSpotLightNode );
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { registerNode } from '../core/Node.js';
|
|
2
1
|
import LightingNode from './LightingNode.js';
|
|
3
2
|
|
|
4
3
|
class IrradianceNode extends LightingNode {
|
|
5
4
|
|
|
5
|
+
static get type() {
|
|
6
|
+
|
|
7
|
+
return 'IrradianceNode';
|
|
8
|
+
|
|
9
|
+
}
|
|
10
|
+
|
|
6
11
|
constructor( node ) {
|
|
7
12
|
|
|
8
13
|
super();
|
|
@@ -20,5 +25,3 @@ class IrradianceNode extends LightingNode {
|
|
|
20
25
|
}
|
|
21
26
|
|
|
22
27
|
export default IrradianceNode;
|
|
23
|
-
|
|
24
|
-
IrradianceNode.type = /*@__PURE__*/ registerNode( 'Irradiance', IrradianceNode );
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import { registerNode } from '../core/Node.js';
|
|
2
1
|
import AnalyticLightNode from './AnalyticLightNode.js';
|
|
3
2
|
import { normalWorld } from '../accessors/Normal.js';
|
|
4
3
|
import { uniformArray } from '../accessors/UniformArrayNode.js';
|
|
5
|
-
import { Fn } from '../tsl/TSLBase.js';
|
|
6
|
-
import { mul } from '../math/OperatorNode.js';
|
|
7
4
|
import { Vector3 } from '../../math/Vector3.js';
|
|
5
|
+
import getShIrradianceAt from '../functions/material/getShIrradianceAt.js';
|
|
8
6
|
|
|
9
7
|
class LightProbeNode extends AnalyticLightNode {
|
|
10
8
|
|
|
9
|
+
static get type() {
|
|
10
|
+
|
|
11
|
+
return 'LightProbeNode';
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
11
15
|
constructor( light = null ) {
|
|
12
16
|
|
|
13
17
|
super( light );
|
|
@@ -38,7 +42,7 @@ class LightProbeNode extends AnalyticLightNode {
|
|
|
38
42
|
|
|
39
43
|
setup( builder ) {
|
|
40
44
|
|
|
41
|
-
const irradiance =
|
|
45
|
+
const irradiance = getShIrradianceAt( normalWorld, this.lightProbe );
|
|
42
46
|
|
|
43
47
|
builder.context.irradiance.addAssign( irradiance );
|
|
44
48
|
|
|
@@ -47,30 +51,3 @@ class LightProbeNode extends AnalyticLightNode {
|
|
|
47
51
|
}
|
|
48
52
|
|
|
49
53
|
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,9 +1,14 @@
|
|
|
1
|
-
import { registerNode } from '../core/Node.js';
|
|
2
1
|
import ContextNode from '../core/ContextNode.js';
|
|
3
2
|
import { nodeProxy, float, vec3 } from '../tsl/TSLBase.js';
|
|
4
3
|
|
|
5
4
|
class LightingContextNode extends ContextNode {
|
|
6
5
|
|
|
6
|
+
static get type() {
|
|
7
|
+
|
|
8
|
+
return 'LightingContextNode';
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
7
12
|
constructor( node, lightingModel = null, backdropNode = null, backdropAlphaNode = null ) {
|
|
8
13
|
|
|
9
14
|
super( node );
|
|
@@ -59,6 +64,4 @@ class LightingContextNode extends ContextNode {
|
|
|
59
64
|
|
|
60
65
|
export default LightingContextNode;
|
|
61
66
|
|
|
62
|
-
LightingContextNode.type = /*@__PURE__*/ registerNode( 'LightingContext', LightingContextNode );
|
|
63
|
-
|
|
64
67
|
export const lightingContext = /*@__PURE__*/ nodeProxy( LightingContextNode );
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import Node
|
|
1
|
+
import Node from '../core/Node.js';
|
|
2
2
|
|
|
3
3
|
class LightingNode extends Node {
|
|
4
4
|
|
|
5
|
+
static get type() {
|
|
6
|
+
|
|
7
|
+
return 'LightingNode';
|
|
8
|
+
|
|
9
|
+
}
|
|
10
|
+
|
|
5
11
|
constructor() {
|
|
6
12
|
|
|
7
13
|
super( 'vec3' );
|
|
@@ -19,5 +25,3 @@ class LightingNode extends Node {
|
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
export default LightingNode;
|
|
22
|
-
|
|
23
|
-
LightingNode.type = /*@__PURE__*/ registerNode( 'Lighting', LightingNode );
|