super-three 0.169.1 → 0.170.1
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 +24628 -24228
- package/build/three.core.js +37002 -0
- package/build/three.core.min.js +6 -0
- package/build/three.module.js +10519 -47108
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +533 -0
- package/build/three.tsl.min.js +6 -0
- package/build/three.webgpu.js +17071 -53583
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +17134 -53623
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +3 -3
- package/examples/jsm/animation/MMDAnimationHelper.js +2 -0
- package/examples/jsm/animation/MMDPhysics.js +2 -0
- package/examples/jsm/capabilities/WebGPU.js +1 -10
- package/examples/jsm/controls/ArcballControls.js +25 -21
- package/examples/jsm/controls/OrbitControls.js +41 -9
- package/examples/jsm/controls/PointerLockControls.js +2 -5
- package/examples/jsm/controls/TransformControls.js +22 -6
- package/examples/jsm/csm/CSM.js +2 -2
- package/examples/jsm/csm/CSMFrustum.js +7 -4
- package/examples/jsm/csm/CSMHelper.js +2 -0
- package/examples/jsm/csm/CSMShadowNode.js +437 -0
- package/examples/jsm/curves/NURBSCurve.js +34 -3
- package/examples/jsm/exporters/GLTFExporter.js +138 -71
- package/examples/jsm/exporters/KTX2Exporter.js +35 -12
- package/examples/jsm/exporters/MMDExporter.js +6 -0
- package/examples/jsm/exporters/USDZExporter.js +21 -3
- package/examples/jsm/geometries/DecalGeometry.js +70 -21
- package/examples/jsm/geometries/InstancedPointsGeometry.js +2 -0
- package/examples/jsm/helpers/TextureHelperGPU.js +175 -0
- package/examples/jsm/interactive/HTMLMesh.js +1 -0
- package/examples/jsm/lighting/TiledLighting.js +18 -0
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +1 -1
- package/examples/jsm/lines/LineGeometry.js +25 -0
- package/examples/jsm/lines/LineMaterial.js +0 -1
- package/examples/jsm/lines/LineSegmentsGeometry.js +2 -0
- package/examples/jsm/lines/webgpu/Line2.js +2 -1
- package/examples/jsm/lines/webgpu/LineSegments2.js +2 -16
- package/examples/jsm/lines/webgpu/Wireframe.js +57 -0
- package/examples/jsm/loaders/3DMLoader.js +1 -0
- package/examples/jsm/loaders/3MFLoader.js +91 -0
- package/examples/jsm/loaders/FBXLoader.js +12 -2
- package/examples/jsm/loaders/GLTFLoader.js +2 -0
- package/examples/jsm/loaders/KTX2Loader.js +143 -49
- package/examples/jsm/loaders/LDrawLoader.js +22 -136
- package/examples/jsm/loaders/LottieLoader.js +1 -0
- package/examples/jsm/loaders/MMDLoader.js +3 -0
- package/examples/jsm/loaders/MaterialXLoader.js +2 -2
- package/examples/jsm/materials/LDrawConditionalLineMaterial.js +143 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +114 -0
- package/examples/jsm/math/ColorSpaces.js +76 -0
- package/examples/jsm/misc/ProgressiveLightMap.js +52 -40
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +293 -0
- package/examples/jsm/misc/VolumeSlice.js +1 -0
- package/examples/jsm/objects/InstancedPoints.js +2 -4
- package/examples/jsm/objects/LensflareMesh.js +4 -2
- package/examples/jsm/objects/SkyMesh.js +5 -3
- package/examples/jsm/objects/Water2Mesh.js +7 -3
- package/examples/jsm/objects/WaterMesh.js +12 -10
- package/examples/jsm/postprocessing/AfterimagePass.js +14 -3
- package/examples/jsm/postprocessing/SSRPass.js +6 -0
- package/examples/jsm/renderers/CSS2DRenderer.js +6 -3
- package/examples/jsm/renderers/CSS3DRenderer.js +7 -4
- package/examples/jsm/shaders/FXAAShader.js +225 -224
- package/examples/jsm/transpiler/AST.js +2 -2
- package/examples/jsm/transpiler/GLSLDecoder.js +57 -25
- package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
- package/examples/jsm/transpiler/TSLEncoder.js +11 -6
- package/{src/nodes → examples/jsm/tsl}/display/AfterImageNode.js +18 -21
- package/{src/nodes → examples/jsm/tsl}/display/AnaglyphPassNode.js +2 -6
- package/{src/nodes → examples/jsm/tsl}/display/AnamorphicNode.js +12 -18
- package/{src/nodes → examples/jsm/tsl}/display/BleachBypass.js +1 -3
- package/{src/nodes → examples/jsm/tsl}/display/BloomNode.js +12 -41
- package/{src/nodes → examples/jsm/tsl}/display/DenoiseNode.js +60 -47
- package/{src/nodes → examples/jsm/tsl}/display/DepthOfFieldNode.js +4 -9
- package/{src/nodes → examples/jsm/tsl}/display/DotScreenNode.js +2 -9
- package/examples/jsm/tsl/display/FXAANode.js +316 -0
- package/{src/nodes → examples/jsm/tsl}/display/FilmNode.js +4 -7
- package/{src/nodes → examples/jsm/tsl}/display/GTAONode.js +73 -78
- package/{src/nodes → examples/jsm/tsl}/display/GaussianBlurNode.js +78 -42
- package/examples/jsm/tsl/display/LensflareNode.js +161 -0
- package/{src/nodes → examples/jsm/tsl}/display/Lut3DNode.js +3 -5
- package/{src/nodes → examples/jsm/tsl}/display/MotionBlur.js +2 -3
- package/examples/jsm/tsl/display/OutlineNode.js +434 -0
- package/{src/nodes → examples/jsm/tsl}/display/ParallaxBarrierPassNode.js +2 -5
- package/{src/nodes → examples/jsm/tsl}/display/PixelationPassNode.js +5 -17
- package/{src/nodes → examples/jsm/tsl}/display/RGBShiftNode.js +2 -6
- package/examples/jsm/tsl/display/SMAANode.js +620 -0
- package/{src/nodes → examples/jsm/tsl}/display/SSAAPassNode.js +10 -25
- package/examples/jsm/tsl/display/SSRNode.js +366 -0
- package/{src/nodes → examples/jsm/tsl}/display/Sepia.js +1 -2
- package/{src/nodes → examples/jsm/tsl}/display/SobelOperatorNode.js +4 -12
- package/{src/nodes → examples/jsm/tsl}/display/StereoCompositePassNode.js +9 -11
- package/{src/nodes → examples/jsm/tsl}/display/StereoPassNode.js +10 -11
- package/examples/jsm/tsl/display/TRAAPassNode.js +355 -0
- package/{src/nodes → examples/jsm/tsl}/display/TransitionNode.js +3 -7
- package/examples/jsm/tsl/display/hashBlur.js +24 -0
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +389 -0
- package/examples/jsm/utils/SceneOptimizer.js +410 -0
- package/examples/jsm/utils/UVsDebug.js +1 -1
- package/examples/jsm/utils/{TextureUtilsGPU.js → WebGPUTextureUtils.js} +2 -1
- package/examples/jsm/webxr/OculusHandPointerModel.js +21 -21
- package/examples/jsm/webxr/Text2D.js +6 -6
- package/package.json +4 -4
- package/src/Three.Core.js +178 -0
- package/src/Three.TSL.js +526 -0
- package/src/Three.WebGPU.Nodes.js +9 -186
- package/src/Three.WebGPU.js +8 -186
- package/src/Three.js +1 -177
- package/src/animation/AnimationClip.js +2 -2
- package/src/animation/AnimationObjectGroup.js +2 -2
- package/src/audio/Audio.js +38 -0
- package/src/cameras/PerspectiveCamera.js +6 -6
- package/src/cameras/StereoCamera.js +2 -2
- package/src/constants.js +1 -6
- package/src/core/BufferGeometry.js +48 -8
- package/src/core/InterleavedBuffer.js +4 -4
- package/src/core/Object3D.js +2 -2
- package/src/extras/core/Curve.js +3 -3
- package/src/extras/core/Shape.js +2 -2
- package/src/geometries/CylinderGeometry.js +2 -2
- package/src/geometries/EdgesGeometry.js +2 -2
- package/src/geometries/LatheGeometry.js +2 -2
- package/src/lights/SpotLightShadow.js +2 -2
- package/src/materials/LineDashedMaterial.js +0 -1
- package/src/materials/Material.js +2 -2
- package/src/materials/MeshPhongMaterial.js +1 -1
- package/src/materials/MeshPhysicalMaterial.js +2 -2
- package/src/materials/MeshStandardMaterial.js +2 -2
- package/src/materials/nodes/Line2NodeMaterial.js +32 -13
- package/src/materials/nodes/LineDashedNodeMaterial.js +4 -2
- package/src/materials/nodes/NodeMaterial.js +93 -23
- package/src/materials/nodes/SpriteNodeMaterial.js +11 -2
- package/src/materials/nodes/manager/NodeMaterialObserver.js +119 -7
- package/src/math/ColorManagement.js +143 -102
- package/src/math/Line3.js +2 -2
- package/src/math/Quaternion.js +2 -2
- package/src/math/Spherical.js +3 -3
- package/src/math/Vector2.js +7 -7
- package/src/math/Vector3.js +9 -9
- package/src/math/Vector4.js +22 -9
- package/src/nodes/Nodes.js +2 -21
- package/src/nodes/TSL.js +9 -25
- package/src/nodes/accessors/Arrays.js +27 -0
- package/src/nodes/accessors/BuiltinNode.js +26 -0
- package/src/nodes/accessors/Camera.js +0 -1
- package/src/nodes/accessors/ClippingNode.js +76 -42
- package/src/nodes/accessors/InstanceNode.js +17 -20
- package/src/nodes/accessors/InstancedMeshNode.js +26 -0
- package/src/nodes/accessors/Lights.js +32 -0
- package/src/nodes/accessors/SceneNode.js +35 -1
- package/src/nodes/accessors/StorageBufferNode.js +61 -19
- package/src/nodes/accessors/StorageTextureNode.js +10 -4
- package/src/nodes/accessors/TextureNode.js +1 -1
- package/src/nodes/accessors/VelocityNode.js +13 -3
- package/src/nodes/code/FunctionCallNode.js +16 -5
- package/src/nodes/code/ScriptableNode.js +4 -4
- package/src/nodes/core/Node.js +1 -0
- package/src/nodes/core/NodeBuilder.js +31 -14
- package/src/nodes/core/NodeUtils.js +28 -0
- package/src/nodes/core/VarNode.js +15 -3
- package/src/nodes/core/constants.js +6 -0
- package/src/nodes/display/BlendModes.js +99 -0
- package/src/nodes/display/ColorAdjustment.js +53 -4
- package/src/nodes/display/ColorSpaceFunctions.js +5 -5
- package/src/nodes/display/ColorSpaceNode.js +27 -39
- package/src/nodes/display/PassNode.js +6 -4
- package/src/nodes/display/ToneMappingNode.js +1 -1
- package/src/nodes/display/ToonOutlinePassNode.js +3 -3
- package/src/nodes/display/ViewportDepthNode.js +48 -1
- package/src/nodes/functions/PhysicalLightingModel.js +21 -15
- package/src/nodes/functions/material/getAlphaHashThreshold.js +70 -0
- package/src/nodes/functions/material/getGeometryRoughness.js +8 -2
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +22 -0
- package/src/nodes/gpgpu/ComputeNode.js +9 -1
- package/src/nodes/lighting/AnalyticLightNode.js +23 -419
- package/src/nodes/lighting/LightsNode.js +24 -12
- package/src/nodes/lighting/PointLightNode.js +41 -22
- package/src/nodes/lighting/PointShadowNode.js +254 -0
- package/src/nodes/lighting/RectAreaLightNode.js +3 -0
- package/src/nodes/lighting/ShadowNode.js +593 -0
- package/src/nodes/lighting/SpotLightNode.js +14 -2
- package/src/nodes/utils/LoopNode.js +2 -2
- package/src/nodes/utils/Oscillators.js +6 -0
- package/src/nodes/utils/PostProcessingUtils.js +89 -0
- package/src/nodes/utils/RTTNode.js +9 -1
- package/src/nodes/utils/ReflectorNode.js +101 -15
- package/src/nodes/utils/StorageArrayElementNode.js +2 -2
- package/src/nodes/utils/Timer.js +29 -0
- package/src/objects/BatchedMesh.js +472 -296
- package/src/objects/ClippingGroup.js +19 -0
- package/src/objects/Skeleton.js +2 -2
- package/src/renderers/WebGLRenderer.js +183 -109
- package/src/renderers/common/Animation.js +23 -11
- package/src/renderers/common/Attributes.js +4 -0
- package/src/renderers/common/Backend.js +2 -0
- package/src/renderers/common/Background.js +15 -5
- package/src/renderers/common/Bindings.js +23 -6
- package/src/renderers/common/ClippingContext.js +77 -85
- package/src/renderers/common/Constants.js +2 -1
- package/src/renderers/common/Geometries.js +20 -0
- package/src/renderers/common/IndirectStorageBufferAttribute.js +15 -0
- package/src/renderers/common/Lighting.js +45 -0
- package/src/renderers/common/PostProcessingUtils.js +86 -0
- package/src/renderers/common/RenderList.js +48 -17
- package/src/renderers/common/RenderLists.js +4 -2
- package/src/renderers/common/RenderObject.js +45 -28
- package/src/renderers/common/RenderObjects.js +12 -6
- package/src/renderers/common/Renderer.js +222 -77
- package/src/renderers/common/Textures.js +41 -17
- package/src/renderers/common/UniformsGroup.js +16 -4
- package/src/renderers/common/extras/PMREMGenerator.js +89 -13
- package/src/renderers/common/nodes/NodeLibrary.js +2 -15
- package/src/renderers/common/nodes/NodeStorageBuffer.js +2 -3
- package/src/renderers/common/nodes/NodeUniform.js +42 -0
- package/src/renderers/common/nodes/Nodes.js +2 -2
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +4 -24
- package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +2 -2
- package/src/renderers/webgl/WebGLBackground.js +20 -1
- package/src/renderers/webgl/WebGLBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLCapabilities.js +0 -7
- package/src/renderers/webgl/WebGLGeometries.js +0 -28
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLProgram.js +24 -28
- package/src/renderers/webgl/WebGLPrograms.js +5 -2
- package/src/renderers/webgl/WebGLState.js +37 -1
- package/src/renderers/webgl/WebGLTextures.js +29 -12
- package/src/renderers/webgl-fallback/WebGLBackend.js +111 -37
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +2 -7
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +43 -12
- package/src/renderers/webgl-fallback/utils/WebGLState.js +26 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +37 -9
- package/src/renderers/webgpu/WebGPUBackend.js +152 -56
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +1 -1
- package/src/renderers/webgpu/WebGPURenderer.js +1 -1
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +0 -8
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +13 -34
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +192 -92
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +12 -4
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +15 -2
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +72 -7
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +29 -9
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +29 -7
- package/src/renderers/webgpu/utils/WebGPUUtils.js +0 -1
- package/src/renderers/webxr/WebXRManager.js +4 -4
- package/src/textures/Source.js +2 -2
- package/src/textures/Texture.js +2 -2
- package/examples/jsm/cameras/CinematicCamera.js +0 -208
- package/src/nodes/display/BlendMode.js +0 -54
- package/src/nodes/display/FXAANode.js +0 -332
- package/src/nodes/utils/OscNode.js +0 -85
- package/src/nodes/utils/TimerNode.js +0 -97
- /package/examples/jsm/utils/{TextureUtils.js → WebGLTextureUtils.js} +0 -0
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import ShadowNode from './ShadowNode.js';
|
|
2
|
+
import { uniform } from '../core/UniformNode.js';
|
|
3
|
+
import { float, vec2, If, Fn, nodeObject } from '../tsl/TSLBase.js';
|
|
4
|
+
import { reference } from '../accessors/ReferenceNode.js';
|
|
5
|
+
import { texture } from '../accessors/TextureNode.js';
|
|
6
|
+
import { max, abs, sign } from '../math/MathNode.js';
|
|
7
|
+
import { sub, div } from '../math/OperatorNode.js';
|
|
8
|
+
import { renderGroup } from '../core/UniformGroupNode.js';
|
|
9
|
+
import { Vector2 } from '../../math/Vector2.js';
|
|
10
|
+
import { Vector4 } from '../../math/Vector4.js';
|
|
11
|
+
import { Color } from '../../math/Color.js';
|
|
12
|
+
import { BasicShadowMap } from '../../constants.js';
|
|
13
|
+
|
|
14
|
+
const _clearColor = /*@__PURE__*/ new Color();
|
|
15
|
+
|
|
16
|
+
// cubeToUV() maps a 3D direction vector suitable for cube texture mapping to a 2D
|
|
17
|
+
// vector suitable for 2D texture mapping. This code uses the following layout for the
|
|
18
|
+
// 2D texture:
|
|
19
|
+
//
|
|
20
|
+
// xzXZ
|
|
21
|
+
// y Y
|
|
22
|
+
//
|
|
23
|
+
// Y - Positive y direction
|
|
24
|
+
// y - Negative y direction
|
|
25
|
+
// X - Positive x direction
|
|
26
|
+
// x - Negative x direction
|
|
27
|
+
// Z - Positive z direction
|
|
28
|
+
// z - Negative z direction
|
|
29
|
+
//
|
|
30
|
+
// Source and test bed:
|
|
31
|
+
// https://gist.github.com/tschw/da10c43c467ce8afd0c4
|
|
32
|
+
|
|
33
|
+
export const cubeToUV = /*@__PURE__*/ Fn( ( [ pos, texelSizeY ] ) => {
|
|
34
|
+
|
|
35
|
+
const v = pos.toVar();
|
|
36
|
+
|
|
37
|
+
// Number of texels to avoid at the edge of each square
|
|
38
|
+
|
|
39
|
+
const absV = abs( v );
|
|
40
|
+
|
|
41
|
+
// Intersect unit cube
|
|
42
|
+
|
|
43
|
+
const scaleToCube = div( 1.0, max( absV.x, max( absV.y, absV.z ) ) );
|
|
44
|
+
absV.mulAssign( scaleToCube );
|
|
45
|
+
|
|
46
|
+
// Apply scale to avoid seams
|
|
47
|
+
|
|
48
|
+
// two texels less per square (one texel will do for NEAREST)
|
|
49
|
+
v.mulAssign( scaleToCube.mul( texelSizeY.mul( 2 ).oneMinus() ) );
|
|
50
|
+
|
|
51
|
+
// Unwrap
|
|
52
|
+
|
|
53
|
+
// space: -1 ... 1 range for each square
|
|
54
|
+
//
|
|
55
|
+
// #X## dim := ( 4 , 2 )
|
|
56
|
+
// # # center := ( 1 , 1 )
|
|
57
|
+
|
|
58
|
+
const planar = vec2( v.xy ).toVar();
|
|
59
|
+
|
|
60
|
+
const almostATexel = texelSizeY.mul( 1.5 );
|
|
61
|
+
const almostOne = almostATexel.oneMinus();
|
|
62
|
+
|
|
63
|
+
If( absV.z.greaterThanEqual( almostOne ), () => {
|
|
64
|
+
|
|
65
|
+
If( v.z.greaterThan( 0.0 ), () => {
|
|
66
|
+
|
|
67
|
+
planar.x.assign( sub( 4.0, v.x ) );
|
|
68
|
+
|
|
69
|
+
} );
|
|
70
|
+
|
|
71
|
+
} ).ElseIf( absV.x.greaterThanEqual( almostOne ), () => {
|
|
72
|
+
|
|
73
|
+
const signX = sign( v.x );
|
|
74
|
+
planar.x.assign( v.z.mul( signX ).add( signX.mul( 2.0 ) ) );
|
|
75
|
+
|
|
76
|
+
} ).ElseIf( absV.y.greaterThanEqual( almostOne ), () => {
|
|
77
|
+
|
|
78
|
+
const signY = sign( v.y );
|
|
79
|
+
planar.x.assign( v.x.add( signY.mul( 2.0 ) ).add( 2.0 ) );
|
|
80
|
+
planar.y.assign( v.z.mul( signY ).sub( 2.0 ) );
|
|
81
|
+
|
|
82
|
+
} );
|
|
83
|
+
|
|
84
|
+
// Transform to UV space
|
|
85
|
+
|
|
86
|
+
// scale := 0.5 / dim
|
|
87
|
+
// translate := ( center + 0.5 ) / dim
|
|
88
|
+
return vec2( 0.125, 0.25 ).mul( planar ).add( vec2( 0.375, 0.75 ) ).flipY();
|
|
89
|
+
|
|
90
|
+
} ).setLayout( {
|
|
91
|
+
name: 'cubeToUV',
|
|
92
|
+
type: 'vec2',
|
|
93
|
+
inputs: [
|
|
94
|
+
{ name: 'pos', type: 'vec3' },
|
|
95
|
+
{ name: 'texelSizeY', type: 'float' }
|
|
96
|
+
]
|
|
97
|
+
} );
|
|
98
|
+
|
|
99
|
+
export const BasicPointShadowFilter = /*@__PURE__*/ Fn( ( { depthTexture, bd3D, dp, texelSize } ) => {
|
|
100
|
+
|
|
101
|
+
return texture( depthTexture, cubeToUV( bd3D, texelSize.y ) ).compare( dp );
|
|
102
|
+
|
|
103
|
+
} );
|
|
104
|
+
|
|
105
|
+
export const PointShadowFilter = /*@__PURE__*/ Fn( ( { depthTexture, bd3D, dp, texelSize, shadow } ) => {
|
|
106
|
+
|
|
107
|
+
const radius = reference( 'radius', 'float', shadow ).setGroup( renderGroup );
|
|
108
|
+
const offset = vec2( - 1.0, 1.0 ).mul( radius ).mul( texelSize.y );
|
|
109
|
+
|
|
110
|
+
return texture( depthTexture, cubeToUV( bd3D.add( offset.xyy ), texelSize.y ) ).compare( dp )
|
|
111
|
+
.add( texture( depthTexture, cubeToUV( bd3D.add( offset.yyy ), texelSize.y ) ).compare( dp ) )
|
|
112
|
+
.add( texture( depthTexture, cubeToUV( bd3D.add( offset.xyx ), texelSize.y ) ).compare( dp ) )
|
|
113
|
+
.add( texture( depthTexture, cubeToUV( bd3D.add( offset.yyx ), texelSize.y ) ).compare( dp ) )
|
|
114
|
+
.add( texture( depthTexture, cubeToUV( bd3D, texelSize.y ) ).compare( dp ) )
|
|
115
|
+
.add( texture( depthTexture, cubeToUV( bd3D.add( offset.xxy ), texelSize.y ) ).compare( dp ) )
|
|
116
|
+
.add( texture( depthTexture, cubeToUV( bd3D.add( offset.yxy ), texelSize.y ) ).compare( dp ) )
|
|
117
|
+
.add( texture( depthTexture, cubeToUV( bd3D.add( offset.xxx ), texelSize.y ) ).compare( dp ) )
|
|
118
|
+
.add( texture( depthTexture, cubeToUV( bd3D.add( offset.yxx ), texelSize.y ) ).compare( dp ) )
|
|
119
|
+
.mul( 1.0 / 9.0 );
|
|
120
|
+
|
|
121
|
+
} );
|
|
122
|
+
|
|
123
|
+
const pointShadowFilter = /*@__PURE__*/ Fn( ( { filterFn, depthTexture, shadowCoord, shadow } ) => {
|
|
124
|
+
|
|
125
|
+
// for point lights, the uniform @vShadowCoord is re-purposed to hold
|
|
126
|
+
// the vector from the light to the world-space position of the fragment.
|
|
127
|
+
const lightToPosition = shadowCoord.xyz.toVar();
|
|
128
|
+
const lightToPositionLength = lightToPosition.length();
|
|
129
|
+
|
|
130
|
+
const cameraNearLocal = uniform( 'float' ).setGroup( renderGroup ).onRenderUpdate( () => shadow.camera.near );
|
|
131
|
+
const cameraFarLocal = uniform( 'float' ).setGroup( renderGroup ).onRenderUpdate( () => shadow.camera.far );
|
|
132
|
+
const bias = reference( 'bias', 'float', shadow ).setGroup( renderGroup );
|
|
133
|
+
const mapSize = uniform( shadow.mapSize ).setGroup( renderGroup );
|
|
134
|
+
|
|
135
|
+
const result = float( 1.0 ).toVar();
|
|
136
|
+
|
|
137
|
+
If( lightToPositionLength.sub( cameraFarLocal ).lessThanEqual( 0.0 ).and( lightToPositionLength.sub( cameraNearLocal ).greaterThanEqual( 0.0 ) ), () => {
|
|
138
|
+
|
|
139
|
+
// dp = normalized distance from light to fragment position
|
|
140
|
+
const dp = lightToPositionLength.sub( cameraNearLocal ).div( cameraFarLocal.sub( cameraNearLocal ) ).toVar(); // need to clamp?
|
|
141
|
+
dp.addAssign( bias );
|
|
142
|
+
|
|
143
|
+
// bd3D = base direction 3D
|
|
144
|
+
const bd3D = lightToPosition.normalize();
|
|
145
|
+
const texelSize = vec2( 1.0 ).div( mapSize.mul( vec2( 4.0, 2.0 ) ) );
|
|
146
|
+
|
|
147
|
+
// percentage-closer filtering
|
|
148
|
+
result.assign( filterFn( { depthTexture, bd3D, dp, texelSize, shadow } ) );
|
|
149
|
+
|
|
150
|
+
} );
|
|
151
|
+
|
|
152
|
+
return result;
|
|
153
|
+
|
|
154
|
+
} );
|
|
155
|
+
|
|
156
|
+
const _viewport = /*@__PURE__*/ new Vector4();
|
|
157
|
+
const _viewportSize = /*@__PURE__*/ new Vector2();
|
|
158
|
+
const _shadowMapSize = /*@__PURE__*/ new Vector2();
|
|
159
|
+
|
|
160
|
+
//
|
|
161
|
+
|
|
162
|
+
class PointShadowNode extends ShadowNode {
|
|
163
|
+
|
|
164
|
+
static get type() {
|
|
165
|
+
|
|
166
|
+
return 'PointShadowNode';
|
|
167
|
+
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
constructor( light, shadow = null ) {
|
|
171
|
+
|
|
172
|
+
super( light, shadow );
|
|
173
|
+
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
getShadowFilterFn( type ) {
|
|
177
|
+
|
|
178
|
+
return type === BasicShadowMap ? BasicPointShadowFilter : PointShadowFilter;
|
|
179
|
+
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
setupShadowCoord( builder, shadowPosition ) {
|
|
183
|
+
|
|
184
|
+
return shadowPosition;
|
|
185
|
+
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
setupShadowFilter( builder, { filterFn, shadowTexture, depthTexture, shadowCoord, shadow } ) {
|
|
189
|
+
|
|
190
|
+
return pointShadowFilter( { filterFn, shadowTexture, depthTexture, shadowCoord, shadow } );
|
|
191
|
+
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
renderShadow( frame ) {
|
|
195
|
+
|
|
196
|
+
const { shadow, shadowMap, light } = this;
|
|
197
|
+
const { renderer, scene } = frame;
|
|
198
|
+
|
|
199
|
+
const shadowFrameExtents = shadow.getFrameExtents();
|
|
200
|
+
|
|
201
|
+
_shadowMapSize.copy( shadow.mapSize );
|
|
202
|
+
_shadowMapSize.multiply( shadowFrameExtents );
|
|
203
|
+
|
|
204
|
+
shadowMap.setSize( _shadowMapSize.width, _shadowMapSize.height );
|
|
205
|
+
|
|
206
|
+
_viewportSize.copy( shadow.mapSize );
|
|
207
|
+
|
|
208
|
+
//
|
|
209
|
+
|
|
210
|
+
const previousAutoClear = renderer.autoClear;
|
|
211
|
+
|
|
212
|
+
const previousClearColor = renderer.getClearColor( _clearColor );
|
|
213
|
+
const previousClearAlpha = renderer.getClearAlpha();
|
|
214
|
+
|
|
215
|
+
renderer.autoClear = false;
|
|
216
|
+
renderer.setClearColor( shadow.clearColor, shadow.clearAlpha );
|
|
217
|
+
renderer.clear();
|
|
218
|
+
|
|
219
|
+
const viewportCount = shadow.getViewportCount();
|
|
220
|
+
|
|
221
|
+
for ( let vp = 0; vp < viewportCount; vp ++ ) {
|
|
222
|
+
|
|
223
|
+
const viewport = shadow.getViewport( vp );
|
|
224
|
+
|
|
225
|
+
const x = _viewportSize.x * viewport.x;
|
|
226
|
+
const y = _shadowMapSize.y - _viewportSize.y - ( _viewportSize.y * viewport.y );
|
|
227
|
+
|
|
228
|
+
_viewport.set(
|
|
229
|
+
x,
|
|
230
|
+
y,
|
|
231
|
+
_viewportSize.x * viewport.z,
|
|
232
|
+
_viewportSize.y * viewport.w
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
shadowMap.viewport.copy( _viewport );
|
|
236
|
+
|
|
237
|
+
shadow.updateMatrices( light, vp );
|
|
238
|
+
|
|
239
|
+
renderer.render( scene, shadow.camera );
|
|
240
|
+
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
//
|
|
244
|
+
|
|
245
|
+
renderer.autoClear = previousAutoClear;
|
|
246
|
+
renderer.setClearColor( previousClearColor, previousClearAlpha );
|
|
247
|
+
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export default PointShadowNode;
|
|
253
|
+
|
|
254
|
+
export const pointShadow = ( light, shadow ) => nodeObject( new PointShadowNode( light, shadow ) );
|
|
@@ -6,6 +6,7 @@ import { renderGroup } from '../core/UniformGroupNode.js';
|
|
|
6
6
|
|
|
7
7
|
import { Matrix4 } from '../../math/Matrix4.js';
|
|
8
8
|
import { Vector3 } from '../../math/Vector3.js';
|
|
9
|
+
import { NodeUpdateType } from '../core/constants.js';
|
|
9
10
|
|
|
10
11
|
const _matrix41 = /*@__PURE__*/ new Matrix4();
|
|
11
12
|
const _matrix42 = /*@__PURE__*/ new Matrix4();
|
|
@@ -27,6 +28,8 @@ class RectAreaLightNode extends AnalyticLightNode {
|
|
|
27
28
|
this.halfHeight = uniform( new Vector3() ).setGroup( renderGroup );
|
|
28
29
|
this.halfWidth = uniform( new Vector3() ).setGroup( renderGroup );
|
|
29
30
|
|
|
31
|
+
this.updateType = NodeUpdateType.RENDER;
|
|
32
|
+
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
update( frame ) {
|