super-three 0.164.0 → 0.167.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/README.md +3 -3
- package/build/three.cjs +1273 -503
- package/build/three.module.js +1269 -504
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +76086 -0
- package/build/three.webgpu.min.js +6 -0
- package/examples/jsm/Addons.js +2 -1
- package/examples/jsm/controls/TransformControls.js +1 -1
- package/examples/jsm/csm/CSMShader.js +4 -4
- package/examples/jsm/environments/RoomEnvironment.js +1 -5
- package/examples/jsm/exporters/GLTFExporter.js +8 -4
- package/examples/jsm/exporters/USDZExporter.js +6 -4
- package/examples/jsm/geometries/TeapotGeometry.js +1 -1
- package/examples/jsm/helpers/ViewHelper.js +75 -61
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +91 -0
- package/examples/jsm/lights/RectAreaLightUniformsLib.js +8 -63
- package/examples/jsm/lines/LineMaterial.js +1 -15
- package/examples/jsm/lines/LineSegments2.js +15 -0
- package/examples/jsm/lines/Wireframe.js +16 -1
- package/examples/jsm/lines/webgpu/Line2.js +20 -0
- package/examples/jsm/lines/webgpu/LineSegments2.js +376 -0
- package/examples/jsm/loaders/DRACOLoader.js +1 -1
- package/examples/jsm/loaders/FBXLoader.js +47 -58
- package/examples/jsm/loaders/GLTFLoader.js +12 -4
- package/examples/jsm/loaders/LDrawLoader.js +3 -2
- package/examples/jsm/loaders/MMDLoader.js +31 -12
- package/examples/jsm/loaders/MaterialXLoader.js +2 -9
- package/examples/jsm/loaders/USDZLoader.js +124 -76
- package/examples/jsm/loaders/UltraHDRLoader.js +583 -0
- package/examples/jsm/loaders/VTKLoader.js +76 -3
- package/examples/jsm/misc/GPUComputationRenderer.js +9 -19
- package/examples/jsm/modifiers/CurveModifier.js +11 -9
- package/examples/jsm/modifiers/SimplifyModifier.js +2 -1
- package/examples/jsm/objects/InstancedPoints.js +2 -2
- package/examples/jsm/objects/Lensflare.js +2 -2
- package/examples/jsm/postprocessing/RenderPass.js +1 -1
- package/examples/jsm/postprocessing/RenderTransitionPass.js +13 -38
- package/examples/jsm/postprocessing/SSAOPass.js +6 -9
- package/examples/jsm/postprocessing/UnrealBloomPass.js +4 -4
- package/examples/jsm/renderers/CSS2DRenderer.js +25 -5
- package/examples/jsm/renderers/CSS3DRenderer.js +24 -3
- package/examples/jsm/shaders/ColorifyShader.js +1 -2
- package/examples/jsm/shaders/FXAAShader.js +0 -2
- package/examples/jsm/shaders/GTAOShader.js +1 -1
- package/examples/jsm/shaders/LuminosityHighPassShader.js +1 -3
- package/examples/jsm/transpiler/GLSLDecoder.js +46 -4
- package/examples/jsm/transpiler/TSLEncoder.js +17 -15
- package/examples/jsm/utils/BufferGeometryUtils.js +18 -16
- package/examples/jsm/utils/GPUStatsPanel.js +2 -0
- package/examples/jsm/utils/SortUtils.js +8 -5
- package/package.json +9 -7
- package/src/Three.WebGPU.js +194 -0
- package/src/Three.js +2 -0
- package/src/animation/tracks/BooleanKeyframeTrack.js +10 -1
- package/src/animation/tracks/QuaternionKeyframeTrack.js +1 -2
- package/src/animation/tracks/StringKeyframeTrack.js +10 -1
- package/src/constants.js +4 -1
- package/src/core/Object3D.js +24 -22
- package/src/core/Raycaster.js +6 -2
- package/src/extras/TextureUtils.js +210 -0
- package/src/lights/Light.js +1 -0
- package/src/lights/LightShadow.js +5 -0
- package/{examples/jsm/lights → src/lights/webgpu}/IESSpotLight.js +1 -1
- package/src/loaders/FileLoader.js +4 -0
- package/src/loaders/LoaderUtils.js +3 -1
- package/src/loaders/ObjectLoader.js +34 -2
- package/src/materials/Material.js +13 -4
- package/src/math/Box2.js +4 -4
- package/src/math/Box3.js +6 -6
- package/src/math/ColorManagement.js +10 -0
- package/src/math/Matrix2.js +54 -0
- package/src/math/Vector4.js +13 -0
- package/{examples/jsm → src}/nodes/Nodes.js +39 -20
- package/{examples/jsm → src}/nodes/accessors/BatchNode.js +28 -10
- package/src/nodes/accessors/BitangentNode.js +13 -0
- package/{examples/jsm → src}/nodes/accessors/BufferAttributeNode.js +36 -1
- package/{examples/jsm → src}/nodes/accessors/BufferNode.js +6 -0
- package/src/nodes/accessors/CameraNode.js +19 -0
- package/{examples/jsm → src}/nodes/accessors/CubeTextureNode.js +22 -5
- package/src/nodes/accessors/InstanceNode.js +140 -0
- package/{examples/jsm → src}/nodes/accessors/MaterialNode.js +24 -2
- package/{examples/jsm → src}/nodes/accessors/ModelNode.js +4 -0
- package/{examples/jsm → src}/nodes/accessors/MorphNode.js +24 -20
- package/src/nodes/accessors/NormalNode.js +14 -0
- package/{examples/jsm → src}/nodes/accessors/Object3DNode.js +1 -1
- package/src/nodes/accessors/PositionNode.js +10 -0
- package/{examples/jsm → src}/nodes/accessors/ReferenceNode.js +7 -1
- package/src/nodes/accessors/ReflectVectorNode.js +10 -0
- package/{examples/jsm → src}/nodes/accessors/StorageBufferNode.js +50 -1
- package/{examples/jsm/nodes/accessors/TextureStoreNode.js → src/nodes/accessors/StorageTextureNode.js} +28 -6
- package/src/nodes/accessors/TangentNode.js +23 -0
- package/src/nodes/accessors/Texture3DNode.js +100 -0
- package/{examples/jsm → src}/nodes/accessors/TextureNode.js +55 -18
- package/src/nodes/accessors/UVNode.js +3 -0
- package/{examples/jsm → src}/nodes/accessors/UniformsNode.js +7 -1
- package/{examples/jsm → src}/nodes/accessors/VertexColorNode.js +2 -1
- package/{examples/jsm → src}/nodes/code/ScriptableNode.js +14 -0
- package/{examples/jsm → src}/nodes/code/ScriptableValueNode.js +2 -1
- package/{examples/jsm → src}/nodes/core/AttributeNode.js +34 -8
- package/{examples/jsm → src}/nodes/core/CacheNode.js +7 -10
- package/{examples/jsm → src}/nodes/core/ContextNode.js +6 -0
- package/{examples/jsm → src}/nodes/core/IndexNode.js +6 -0
- package/{examples/jsm → src}/nodes/core/LightingModel.js +2 -2
- package/src/nodes/core/MRTNode.js +76 -0
- package/{examples/jsm → src}/nodes/core/Node.js +33 -14
- package/{examples/jsm → src}/nodes/core/NodeBuilder.js +194 -45
- package/src/nodes/core/NodeCache.js +36 -0
- package/{examples/jsm → src}/nodes/core/NodeFrame.js +42 -0
- package/{examples/jsm → src}/nodes/core/NodeFunction.js +2 -2
- package/{examples/jsm → src}/nodes/core/NodeKeywords.js +1 -1
- package/{examples/jsm → src}/nodes/core/NodeUniform.js +1 -2
- package/{examples/jsm → src}/nodes/core/NodeUtils.js +6 -1
- package/{examples/jsm → src}/nodes/core/OutputStructNode.js +1 -5
- package/{examples/jsm → src}/nodes/core/PropertyNode.js +2 -0
- package/{examples/jsm → src}/nodes/core/TempNode.js +2 -2
- package/{examples/jsm → src}/nodes/core/UniformGroupNode.js +20 -0
- package/{examples/jsm → src}/nodes/core/UniformNode.js +10 -1
- package/{examples/jsm → src}/nodes/core/VarNode.js +2 -6
- package/src/nodes/core/VaryingNode.js +104 -0
- package/{examples/jsm → src}/nodes/display/AfterImageNode.js +24 -20
- package/{examples/jsm → src}/nodes/display/AnamorphicNode.js +18 -21
- package/src/nodes/display/BloomNode.js +333 -0
- package/{examples/jsm → src}/nodes/display/ColorAdjustmentNode.js +7 -2
- package/{examples/jsm → src}/nodes/display/ColorSpaceNode.js +1 -1
- package/src/nodes/display/DenoiseNode.js +198 -0
- package/src/nodes/display/DepthOfFieldNode.js +119 -0
- package/src/nodes/display/DotScreenNode.js +75 -0
- package/src/nodes/display/FXAANode.js +327 -0
- package/src/nodes/display/FilmNode.js +52 -0
- package/{examples/jsm → src}/nodes/display/FrontFacingNode.js +2 -1
- package/src/nodes/display/GTAONode.js +324 -0
- package/{examples/jsm → src}/nodes/display/GaussianBlurNode.js +34 -17
- package/src/nodes/display/Lut3DNode.js +53 -0
- package/{examples/jsm → src}/nodes/display/NormalMapNode.js +1 -1
- package/src/nodes/display/PassNode.js +291 -0
- package/src/nodes/display/PixelationPassNode.js +201 -0
- package/src/nodes/display/RGBShiftNode.js +49 -0
- package/src/nodes/display/RenderOutputNode.js +56 -0
- package/src/nodes/display/SobelOperatorNode.js +121 -0
- package/{examples/jsm → src}/nodes/display/ToneMappingNode.js +44 -5
- package/src/nodes/display/TransitionNode.js +76 -0
- package/{examples/jsm → src}/nodes/display/ViewportDepthNode.js +39 -16
- package/{examples/jsm → src}/nodes/display/ViewportDepthTextureNode.js +2 -1
- package/{examples/jsm → src}/nodes/display/ViewportNode.js +3 -2
- package/{examples/jsm → src}/nodes/display/ViewportSharedTextureNode.js +2 -1
- package/{examples/jsm → src}/nodes/display/ViewportTextureNode.js +5 -2
- package/src/nodes/functions/BSDF/LTC.js +131 -0
- package/src/nodes/functions/BasicLightingModel.js +78 -0
- package/{examples/jsm → src}/nodes/functions/PhongLightingModel.js +5 -3
- package/{examples/jsm → src}/nodes/functions/PhysicalLightingModel.js +103 -18
- package/src/nodes/functions/ToonLightingModel.js +51 -0
- package/{examples/jsm → src}/nodes/geometry/RangeNode.js +19 -6
- package/{examples/jsm → src}/nodes/lighting/AONode.js +1 -4
- package/{examples/jsm → src}/nodes/lighting/AmbientLightNode.js +1 -1
- package/src/nodes/lighting/AnalyticLightNode.js +333 -0
- package/src/nodes/lighting/BasicEnvironmentNode.js +26 -0
- package/src/nodes/lighting/BasicLightMapNode.js +29 -0
- package/{examples/jsm → src}/nodes/lighting/DirectionalLightNode.js +2 -3
- package/{examples/jsm → src}/nodes/lighting/EnvironmentNode.js +5 -4
- package/{examples/jsm → src}/nodes/lighting/HemisphereLightNode.js +2 -1
- package/{examples/jsm → src}/nodes/lighting/IESSpotLightNode.js +1 -1
- package/{examples/jsm → src}/nodes/lighting/LightingNode.js +2 -0
- package/{examples/jsm → src}/nodes/lighting/LightsNode.js +18 -3
- package/{examples/jsm → src}/nodes/lighting/PointLightNode.js +2 -3
- package/src/nodes/lighting/RectAreaLightNode.js +97 -0
- package/{examples/jsm → src}/nodes/lighting/SpotLightNode.js +2 -3
- package/{examples/jsm → src}/nodes/loaders/NodeLoader.js +3 -1
- package/{examples/jsm → src}/nodes/loaders/NodeMaterialLoader.js +2 -1
- package/{examples/jsm → src}/nodes/loaders/NodeObjectLoader.js +2 -1
- package/{examples/jsm → src}/nodes/materials/InstancedPointsNodeMaterial.js +3 -3
- package/{examples/jsm → src}/nodes/materials/Line2NodeMaterial.js +4 -4
- package/{examples/jsm → src}/nodes/materials/LineBasicNodeMaterial.js +3 -3
- package/{examples/jsm → src}/nodes/materials/LineDashedNodeMaterial.js +4 -3
- package/{examples/jsm → src}/nodes/materials/Materials.js +3 -0
- package/src/nodes/materials/MeshBasicNodeMaterial.js +73 -0
- package/{examples/jsm → src}/nodes/materials/MeshLambertNodeMaterial.js +12 -3
- package/src/nodes/materials/MeshMatcapNodeMaterial.js +53 -0
- package/{examples/jsm → src}/nodes/materials/MeshNormalNodeMaterial.js +5 -3
- package/{examples/jsm → src}/nodes/materials/MeshPhongNodeMaterial.js +11 -3
- package/{examples/jsm → src}/nodes/materials/MeshPhysicalNodeMaterial.js +26 -8
- package/{examples/jsm → src}/nodes/materials/MeshStandardNodeMaterial.js +14 -3
- package/src/nodes/materials/MeshToonNodeMaterial.js +34 -0
- package/{examples/jsm → src}/nodes/materials/NodeMaterial.js +97 -24
- package/{examples/jsm → src}/nodes/materials/PointsNodeMaterial.js +3 -3
- package/{examples/jsm → src}/nodes/materials/ShadowNodeMaterial.js +3 -3
- package/{examples/jsm → src}/nodes/materials/SpriteNodeMaterial.js +3 -3
- package/src/nodes/materials/VolumeNodeMaterial.js +106 -0
- package/{examples/jsm → src}/nodes/materialx/lib/mx_hsv.js +9 -17
- package/{examples/jsm → src}/nodes/materialx/lib/mx_noise.js +474 -577
- package/{examples/jsm → src}/nodes/materialx/lib/mx_transform_color.js +2 -8
- package/{examples/jsm → src}/nodes/math/CondNode.js +13 -6
- package/{examples/jsm → src}/nodes/math/HashNode.js +2 -2
- package/{examples/jsm → src}/nodes/math/MathNode.js +14 -1
- package/{examples/jsm → src}/nodes/math/OperatorNode.js +6 -6
- package/{examples/jsm → src}/nodes/parsers/GLSLNodeFunction.js +7 -7
- package/{examples/jsm → src}/nodes/pmrem/PMREMNode.js +2 -1
- package/{examples/jsm → src}/nodes/shadernode/ShaderNode.js +57 -33
- package/{examples/jsm → src}/nodes/utils/ArrayElementNode.js +1 -1
- package/{examples/jsm → src}/nodes/utils/DiscardNode.js +1 -0
- package/{examples/jsm → src}/nodes/utils/FunctionOverloadingNode.js +2 -0
- package/{examples/jsm → src}/nodes/utils/LoopNode.js +7 -6
- package/{examples/jsm → src}/nodes/utils/MatcapUVNode.js +1 -1
- package/{examples/jsm → src}/nodes/utils/MaxMipLevelNode.js +8 -2
- package/src/nodes/utils/RTTNode.js +130 -0
- package/{examples/jsm → src}/nodes/utils/ReflectorNode.js +9 -1
- package/{examples/jsm → src}/nodes/utils/TimerNode.js +1 -1
- package/src/objects/BatchedMesh.js +232 -162
- package/src/objects/InstancedMesh.js +1 -1
- package/src/renderers/WebGLRenderer.js +312 -68
- package/{examples/jsm → src}/renderers/common/Attributes.js +4 -1
- package/{examples/jsm → src}/renderers/common/Backend.js +30 -27
- package/{examples/jsm → src}/renderers/common/Background.js +9 -3
- package/src/renderers/common/BindGroup.js +16 -0
- package/{examples/jsm → src}/renderers/common/Bindings.js +54 -22
- package/src/renderers/common/ChainMap.js +59 -0
- package/{examples/jsm → src}/renderers/common/ClippingContext.js +8 -6
- package/{examples/jsm → src}/renderers/common/Color4.js +1 -1
- package/{examples/jsm → src}/renderers/common/CubeRenderTarget.js +7 -1
- package/{examples/jsm → src}/renderers/common/Geometries.js +37 -5
- package/{examples/jsm → src}/renderers/common/Info.js +34 -6
- package/{examples/jsm → src}/renderers/common/Pipelines.js +2 -2
- package/src/renderers/common/PostProcessing.js +87 -0
- package/{examples/jsm/objects → src/renderers/common}/QuadMesh.js +6 -3
- package/src/renderers/common/RenderBundle.js +18 -0
- package/src/renderers/common/RenderBundles.js +38 -0
- package/{examples/jsm → src}/renderers/common/RenderContext.js +1 -1
- package/{examples/jsm → src}/renderers/common/RenderContexts.js +1 -1
- package/{examples/jsm → src}/renderers/common/RenderList.js +9 -0
- package/{examples/jsm → src}/renderers/common/RenderObject.js +50 -11
- package/{examples/jsm → src}/renderers/common/Renderer.js +220 -40
- package/{examples/jsm → src}/renderers/common/SampledTexture.js +2 -2
- package/{examples/jsm → src}/renderers/common/StorageBufferAttribute.js +1 -1
- package/{examples/jsm → src}/renderers/common/StorageInstancedBufferAttribute.js +1 -1
- package/{examples/jsm → src}/renderers/common/StorageTexture.js +2 -1
- package/{examples/jsm → src}/renderers/common/Textures.js +6 -2
- package/{examples/jsm → src}/renderers/common/Uniform.js +10 -5
- package/{examples/jsm → src}/renderers/common/UniformsGroup.js +69 -31
- package/{examples/jsm → src}/renderers/common/extras/PMREMGenerator.js +13 -12
- package/src/renderers/common/nodes/NodeBuilderState.js +58 -0
- package/{examples/jsm → src}/renderers/common/nodes/NodeSampledTexture.js +19 -4
- package/{examples/jsm → src}/renderers/common/nodes/NodeSampler.js +8 -1
- package/{examples/jsm → src}/renderers/common/nodes/NodeStorageBuffer.js +5 -1
- package/{examples/jsm → src}/renderers/common/nodes/NodeUniform.js +3 -3
- package/{examples/jsm → src}/renderers/common/nodes/NodeUniformBuffer.js +2 -1
- package/{examples/jsm → src}/renderers/common/nodes/NodeUniformsGroup.js +2 -8
- package/{examples/jsm → src}/renderers/common/nodes/Nodes.js +37 -16
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +31 -1
- package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +9 -1
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +0 -9
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -10
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +3 -3
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +8 -22
- package/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +3 -14
- package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +10 -31
- package/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js +3 -23
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +45 -13
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +7 -4
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +3 -0
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +3 -3
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +8 -0
- package/src/renderers/shaders/UniformsLib.js +3 -0
- package/src/renderers/webgl/WebGLAttributes.js +2 -2
- package/src/renderers/webgl/WebGLBackground.js +6 -0
- package/src/renderers/webgl/WebGLBufferRenderer.js +6 -19
- package/src/renderers/webgl/WebGLExtensions.js +3 -1
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +6 -18
- package/src/renderers/webgl/WebGLLights.js +15 -12
- package/src/renderers/webgl/WebGLMaterials.js +1 -5
- package/src/renderers/webgl/WebGLMorphtargets.js +1 -2
- package/src/renderers/webgl/WebGLProgram.js +28 -31
- package/src/renderers/webgl/WebGLPrograms.js +15 -15
- package/src/renderers/webgl/WebGLRenderStates.js +2 -2
- package/src/renderers/webgl/WebGLTextures.js +100 -70
- package/src/renderers/webgl/WebGLUniforms.js +12 -2
- package/src/renderers/webgl/WebGLUniformsGroups.js +7 -7
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/WebGLBackend.js +156 -54
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/nodes/GLSLNodeBuilder.js +188 -41
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLAttributeUtils.js +2 -2
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLConstants.js +1 -0
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLExtensions.js +2 -0
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLState.js +1 -1
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLTextureUtils.js +126 -7
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLUtils.js +1 -1
- package/{examples/jsm → src}/renderers/webgpu/WebGPUBackend.js +212 -78
- package/{examples/jsm → src}/renderers/webgpu/WebGPURenderer.js +2 -2
- package/{examples/jsm → src}/renderers/webgpu/nodes/WGSLNodeBuilder.js +245 -49
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +159 -0
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUAttributeUtils.js +2 -1
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUBindingUtils.js +30 -14
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUConstants.js +9 -1
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUPipelineUtils.js +74 -24
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUTextureUtils.js +101 -25
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUUtils.js +24 -3
- package/src/renderers/webxr/WebXRDepthSensing.js +9 -3
- package/src/renderers/webxr/WebXRManager.js +12 -2
- package/src/textures/CompressedArrayTexture.js +14 -0
- package/src/textures/DataArrayTexture.js +14 -0
- package/src/textures/DepthTexture.js +1 -3
- package/src/utils.js +30 -1
- package/examples/jsm/nodes/accessors/BitangentNode.js +0 -89
- package/examples/jsm/nodes/accessors/CameraNode.js +0 -119
- package/examples/jsm/nodes/accessors/InstanceNode.js +0 -94
- package/examples/jsm/nodes/accessors/NormalNode.js +0 -106
- package/examples/jsm/nodes/accessors/PositionNode.js +0 -104
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +0 -35
- package/examples/jsm/nodes/accessors/TangentNode.js +0 -109
- package/examples/jsm/nodes/accessors/UVNode.js +0 -47
- package/examples/jsm/nodes/core/NodeCache.js +0 -26
- package/examples/jsm/nodes/core/VaryingNode.js +0 -65
- package/examples/jsm/nodes/display/PassNode.js +0 -199
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +0 -255
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +0 -28
- package/examples/jsm/renderers/common/ChainMap.js +0 -89
- package/examples/jsm/renderers/common/PostProcessing.js +0 -33
- package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +0 -44
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +0 -104
- /package/{examples/jsm → src}/nodes/accessors/AccessorsUtils.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/ClippingNode.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/InstancedPointsMaterialNode.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/MaterialReferenceNode.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/ModelViewProjectionNode.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/PointUVNode.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/RendererReferenceNode.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/SceneNode.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/SkinningNode.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/TextureBicubicNode.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/TextureSizeNode.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/UserDataNode.js +0 -0
- /package/{examples/jsm → src}/nodes/code/CodeNode.js +0 -0
- /package/{examples/jsm → src}/nodes/code/ExpressionNode.js +0 -0
- /package/{examples/jsm → src}/nodes/code/FunctionCallNode.js +0 -0
- /package/{examples/jsm → src}/nodes/code/FunctionNode.js +0 -0
- /package/{examples/jsm → src}/nodes/core/AssignNode.js +0 -0
- /package/{examples/jsm → src}/nodes/core/BypassNode.js +0 -0
- /package/{examples/jsm → src}/nodes/core/ConstNode.js +0 -0
- /package/{examples/jsm → src}/nodes/core/InputNode.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeAttribute.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeCode.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeFunctionInput.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeParser.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeVar.js +0 -0
- /package/{examples/jsm → src}/nodes/core/NodeVarying.js +0 -0
- /package/{examples/jsm → src}/nodes/core/ParameterNode.js +0 -0
- /package/{examples/jsm → src}/nodes/core/StackNode.js +0 -0
- /package/{examples/jsm → src}/nodes/core/StructTypeNode.js +0 -0
- /package/{examples/jsm → src}/nodes/core/UniformGroup.js +0 -0
- /package/{examples/jsm → src}/nodes/core/constants.js +0 -0
- /package/{examples/jsm → src}/nodes/display/BlendModeNode.js +0 -0
- /package/{examples/jsm → src}/nodes/display/BumpMapNode.js +0 -0
- /package/{examples/jsm → src}/nodes/display/PosterizeNode.js +0 -0
- /package/{examples/jsm → src}/nodes/fog/FogExp2Node.js +0 -0
- /package/{examples/jsm → src}/nodes/fog/FogNode.js +0 -0
- /package/{examples/jsm → src}/nodes/fog/FogRangeNode.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_GGX.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_Lambert.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/BSDF/BRDF_Sheen.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/BSDF/DFGApprox.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/BSDF/D_GGX.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/BSDF/D_GGX_Anisotropic.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/BSDF/EnvironmentBRDF.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/BSDF/F_Schlick.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/BSDF/Schlick_to_F0.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/ShadowMaskModel.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/material/getGeometryRoughness.js +0 -0
- /package/{examples/jsm → src}/nodes/functions/material/getRoughness.js +0 -0
- /package/{examples/jsm → src}/nodes/gpgpu/ComputeNode.js +0 -0
- /package/{examples/jsm → src}/nodes/lighting/IrradianceNode.js +0 -0
- /package/{examples/jsm → src}/nodes/lighting/LightNode.js +0 -0
- /package/{examples/jsm → src}/nodes/lighting/LightUtils.js +0 -0
- /package/{examples/jsm → src}/nodes/lighting/LightingContextNode.js +0 -0
- /package/{examples/jsm → src}/nodes/materials/MeshSSSNodeMaterial.js +0 -0
- /package/{examples/jsm → src}/nodes/materialx/DISCLAIMER.md +0 -0
- /package/{examples/jsm → src}/nodes/materialx/MaterialXNodes.js +0 -0
- /package/{examples/jsm → src}/nodes/math/MathUtils.js +0 -0
- /package/{examples/jsm → src}/nodes/math/TriNoise3D.js +0 -0
- /package/{examples/jsm → src}/nodes/parsers/GLSLNodeParser.js +0 -0
- /package/{examples/jsm → src}/nodes/pmrem/PMREMUtils.js +0 -0
- /package/{examples/jsm → src}/nodes/procedural/CheckerNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/ConvertNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/EquirectUVNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/JoinNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/OscNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/PackingNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/RemapNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/RotateNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/RotateUVNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/SetNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/SplitNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/SpriteSheetUVNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/StorageArrayElementNode.js +0 -0
- /package/{examples/jsm → src}/nodes/utils/TriplanarTexturesNode.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Animation.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Binding.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Buffer.js +0 -0
- /package/{examples/jsm → src}/renderers/common/BufferUtils.js +0 -0
- /package/{examples/jsm → src}/renderers/common/ComputePipeline.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Constants.js +0 -0
- /package/{examples/jsm → src}/renderers/common/DataMap.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Pipeline.js +0 -0
- /package/{examples/jsm → src}/renderers/common/ProgrammableStage.js +0 -0
- /package/{examples/jsm → src}/renderers/common/RenderLists.js +0 -0
- /package/{examples/jsm → src}/renderers/common/RenderObjects.js +0 -0
- /package/{examples/jsm → src}/renderers/common/RenderPipeline.js +0 -0
- /package/{examples/jsm → src}/renderers/common/Sampler.js +0 -0
- /package/{examples/jsm → src}/renderers/common/StorageBuffer.js +0 -0
- /package/{examples/jsm → src}/renderers/common/UniformBuffer.js +0 -0
- /package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/WebGLBufferRenderer.js +0 -0
- /package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLCapabilities.js +0 -0
- /package/{examples/jsm → src}/renderers/webgpu/nodes/WGSLNodeParser.js +0 -0
- /package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUTexturePassUtils.js +0 -0
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import LightingNode from './LightingNode.js';
|
|
2
|
+
import { NodeUpdateType } from '../core/constants.js';
|
|
3
|
+
import { uniform } from '../core/UniformNode.js';
|
|
4
|
+
import { addNodeClass } from '../core/Node.js';
|
|
5
|
+
import { float, vec2, vec3, vec4 } from '../shadernode/ShaderNode.js';
|
|
6
|
+
import { reference } from '../accessors/ReferenceNode.js';
|
|
7
|
+
import { texture } from '../accessors/TextureNode.js';
|
|
8
|
+
import { positionWorld } from '../accessors/PositionNode.js';
|
|
9
|
+
import { normalWorld } from '../accessors/NormalNode.js';
|
|
10
|
+
import { mix, fract } from '../math/MathNode.js';
|
|
11
|
+
import { add } from '../math/OperatorNode.js';
|
|
12
|
+
import { Color } from '../../math/Color.js';
|
|
13
|
+
import { DepthTexture } from '../../textures/DepthTexture.js';
|
|
14
|
+
import { tslFn } from '../shadernode/ShaderNode.js';
|
|
15
|
+
import { LessCompare, WebGPUCoordinateSystem } from '../../constants.js';
|
|
16
|
+
|
|
17
|
+
const BasicShadowMap = tslFn( ( { depthTexture, shadowCoord } ) => {
|
|
18
|
+
|
|
19
|
+
return texture( depthTexture, shadowCoord.xy ).compare( shadowCoord.z );
|
|
20
|
+
|
|
21
|
+
} );
|
|
22
|
+
|
|
23
|
+
const PCFShadowMap = tslFn( ( { depthTexture, shadowCoord, shadow } ) => {
|
|
24
|
+
|
|
25
|
+
const depthCompare = ( uv, compare ) => texture( depthTexture, uv ).compare( compare );
|
|
26
|
+
|
|
27
|
+
const mapSize = reference( 'mapSize', 'vec2', shadow );
|
|
28
|
+
const radius = reference( 'radius', 'float', shadow );
|
|
29
|
+
|
|
30
|
+
const texelSize = vec2( 1 ).div( mapSize );
|
|
31
|
+
const dx0 = texelSize.x.negate().mul( radius );
|
|
32
|
+
const dy0 = texelSize.y.negate().mul( radius );
|
|
33
|
+
const dx1 = texelSize.x.mul( radius );
|
|
34
|
+
const dy1 = texelSize.y.mul( radius );
|
|
35
|
+
const dx2 = dx0.div( 2 );
|
|
36
|
+
const dy2 = dy0.div( 2 );
|
|
37
|
+
const dx3 = dx1.div( 2 );
|
|
38
|
+
const dy3 = dy1.div( 2 );
|
|
39
|
+
|
|
40
|
+
return add(
|
|
41
|
+
depthCompare( shadowCoord.xy.add( vec2( dx0, dy0 ) ), shadowCoord.z ),
|
|
42
|
+
depthCompare( shadowCoord.xy.add( vec2( 0, dy0 ) ), shadowCoord.z ),
|
|
43
|
+
depthCompare( shadowCoord.xy.add( vec2( dx1, dy0 ) ), shadowCoord.z ),
|
|
44
|
+
depthCompare( shadowCoord.xy.add( vec2( dx2, dy2 ) ), shadowCoord.z ),
|
|
45
|
+
depthCompare( shadowCoord.xy.add( vec2( 0, dy2 ) ), shadowCoord.z ),
|
|
46
|
+
depthCompare( shadowCoord.xy.add( vec2( dx3, dy2 ) ), shadowCoord.z ),
|
|
47
|
+
depthCompare( shadowCoord.xy.add( vec2( dx0, 0 ) ), shadowCoord.z ),
|
|
48
|
+
depthCompare( shadowCoord.xy.add( vec2( dx2, 0 ) ), shadowCoord.z ),
|
|
49
|
+
depthCompare( shadowCoord.xy, shadowCoord.z ),
|
|
50
|
+
depthCompare( shadowCoord.xy.add( vec2( dx3, 0 ) ), shadowCoord.z ),
|
|
51
|
+
depthCompare( shadowCoord.xy.add( vec2( dx1, 0 ) ), shadowCoord.z ),
|
|
52
|
+
depthCompare( shadowCoord.xy.add( vec2( dx2, dy3 ) ), shadowCoord.z ),
|
|
53
|
+
depthCompare( shadowCoord.xy.add( vec2( 0, dy3 ) ), shadowCoord.z ),
|
|
54
|
+
depthCompare( shadowCoord.xy.add( vec2( dx3, dy3 ) ), shadowCoord.z ),
|
|
55
|
+
depthCompare( shadowCoord.xy.add( vec2( dx0, dy1 ) ), shadowCoord.z ),
|
|
56
|
+
depthCompare( shadowCoord.xy.add( vec2( 0, dy1 ) ), shadowCoord.z ),
|
|
57
|
+
depthCompare( shadowCoord.xy.add( vec2( dx1, dy1 ) ), shadowCoord.z )
|
|
58
|
+
).mul( 1 / 17 );
|
|
59
|
+
|
|
60
|
+
} );
|
|
61
|
+
|
|
62
|
+
const PCFSoftShadowMap = tslFn( ( { depthTexture, shadowCoord, shadow } ) => {
|
|
63
|
+
|
|
64
|
+
const depthCompare = ( uv, compare ) => texture( depthTexture, uv ).compare( compare );
|
|
65
|
+
|
|
66
|
+
const mapSize = reference( 'mapSize', 'vec2', shadow );
|
|
67
|
+
|
|
68
|
+
const texelSize = vec2( 1 ).div( mapSize );
|
|
69
|
+
const dx = texelSize.x;
|
|
70
|
+
const dy = texelSize.y;
|
|
71
|
+
|
|
72
|
+
const uv = shadowCoord.xy;
|
|
73
|
+
const f = fract( uv.mul( mapSize ).add( 0.5 ) );
|
|
74
|
+
uv.subAssign( f.mul( texelSize ) );
|
|
75
|
+
|
|
76
|
+
return add(
|
|
77
|
+
depthCompare( uv, shadowCoord.z ),
|
|
78
|
+
depthCompare( uv.add( vec2( dx, 0 ) ), shadowCoord.z ),
|
|
79
|
+
depthCompare( uv.add( vec2( 0, dy ) ), shadowCoord.z ),
|
|
80
|
+
depthCompare( uv.add( texelSize ), shadowCoord.z ),
|
|
81
|
+
mix(
|
|
82
|
+
depthCompare( uv.add( vec2( dx.negate(), 0 ) ), shadowCoord.z ),
|
|
83
|
+
depthCompare( uv.add( vec2( dx.mul( 2 ), 0 ) ), shadowCoord.z ),
|
|
84
|
+
f.x
|
|
85
|
+
),
|
|
86
|
+
mix(
|
|
87
|
+
depthCompare( uv.add( vec2( dx.negate(), dy ) ), shadowCoord.z ),
|
|
88
|
+
depthCompare( uv.add( vec2( dx.mul( 2 ), dy ) ), shadowCoord.z ),
|
|
89
|
+
f.x
|
|
90
|
+
),
|
|
91
|
+
mix(
|
|
92
|
+
depthCompare( uv.add( vec2( 0, dy.negate() ) ), shadowCoord.z ),
|
|
93
|
+
depthCompare( uv.add( vec2( 0, dy.mul( 2 ) ) ), shadowCoord.z ),
|
|
94
|
+
f.y
|
|
95
|
+
),
|
|
96
|
+
mix(
|
|
97
|
+
depthCompare( uv.add( vec2( dx, dy.negate() ) ), shadowCoord.z ),
|
|
98
|
+
depthCompare( uv.add( vec2( dx, dy.mul( 2 ) ) ), shadowCoord.z ),
|
|
99
|
+
f.y
|
|
100
|
+
),
|
|
101
|
+
mix(
|
|
102
|
+
mix(
|
|
103
|
+
depthCompare( uv.add( vec2( dx.negate(), dy.negate() ) ), shadowCoord.z ),
|
|
104
|
+
depthCompare( uv.add( vec2( dx.mul( 2 ), dy.negate() ) ), shadowCoord.z ),
|
|
105
|
+
f.x
|
|
106
|
+
),
|
|
107
|
+
mix(
|
|
108
|
+
depthCompare( uv.add( vec2( dx.negate(), dy.mul( 2 ) ) ), shadowCoord.z ),
|
|
109
|
+
depthCompare( uv.add( vec2( dx.mul( 2 ), dy.mul( 2 ) ) ), shadowCoord.z ),
|
|
110
|
+
f.x
|
|
111
|
+
),
|
|
112
|
+
f.y
|
|
113
|
+
)
|
|
114
|
+
).mul( 1 / 9 );
|
|
115
|
+
|
|
116
|
+
} );
|
|
117
|
+
|
|
118
|
+
const shadowFilterLib = [ BasicShadowMap, PCFShadowMap, PCFSoftShadowMap ];
|
|
119
|
+
|
|
120
|
+
//
|
|
121
|
+
|
|
122
|
+
let overrideMaterial = null;
|
|
123
|
+
|
|
124
|
+
class AnalyticLightNode extends LightingNode {
|
|
125
|
+
|
|
126
|
+
constructor( light = null ) {
|
|
127
|
+
|
|
128
|
+
super();
|
|
129
|
+
|
|
130
|
+
this.updateType = NodeUpdateType.FRAME;
|
|
131
|
+
|
|
132
|
+
this.light = light;
|
|
133
|
+
|
|
134
|
+
this.color = new Color();
|
|
135
|
+
this.colorNode = uniform( this.color );
|
|
136
|
+
|
|
137
|
+
this.baseColorNode = null;
|
|
138
|
+
|
|
139
|
+
this.shadowMap = null;
|
|
140
|
+
this.shadowNode = null;
|
|
141
|
+
this.shadowColorNode = null;
|
|
142
|
+
|
|
143
|
+
this.isAnalyticLightNode = true;
|
|
144
|
+
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
getCacheKey() {
|
|
148
|
+
|
|
149
|
+
return super.getCacheKey() + '-' + ( this.light.id + '-' + ( this.light.castShadow ? '1' : '0' ) );
|
|
150
|
+
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
getHash() {
|
|
154
|
+
|
|
155
|
+
return this.light.uuid;
|
|
156
|
+
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
setupShadow( builder ) {
|
|
160
|
+
|
|
161
|
+
const { object, renderer } = builder;
|
|
162
|
+
|
|
163
|
+
let shadowColorNode = this.shadowColorNode;
|
|
164
|
+
|
|
165
|
+
if ( shadowColorNode === null ) {
|
|
166
|
+
|
|
167
|
+
if ( overrideMaterial === null ) {
|
|
168
|
+
|
|
169
|
+
overrideMaterial = builder.createNodeMaterial();
|
|
170
|
+
overrideMaterial.fragmentNode = vec4( 0, 0, 0, 1 );
|
|
171
|
+
overrideMaterial.isShadowNodeMaterial = true; // Use to avoid other overrideMaterial override material.fragmentNode unintentionally when using material.shadowNode
|
|
172
|
+
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const depthTexture = new DepthTexture();
|
|
176
|
+
depthTexture.compareFunction = LessCompare;
|
|
177
|
+
|
|
178
|
+
const shadow = this.light.shadow;
|
|
179
|
+
const shadowMap = builder.createRenderTarget( shadow.mapSize.width, shadow.mapSize.height );
|
|
180
|
+
shadowMap.depthTexture = depthTexture;
|
|
181
|
+
|
|
182
|
+
shadow.camera.updateProjectionMatrix();
|
|
183
|
+
|
|
184
|
+
//
|
|
185
|
+
|
|
186
|
+
const shadowIntensity = reference( 'intensity', 'float', shadow );
|
|
187
|
+
const bias = reference( 'bias', 'float', shadow );
|
|
188
|
+
const normalBias = reference( 'normalBias', 'float', shadow );
|
|
189
|
+
|
|
190
|
+
const position = object.material.shadowPositionNode || positionWorld;
|
|
191
|
+
|
|
192
|
+
let shadowCoord = uniform( shadow.matrix ).mul( position.add( normalWorld.mul( normalBias ) ) );
|
|
193
|
+
shadowCoord = shadowCoord.xyz.div( shadowCoord.w );
|
|
194
|
+
|
|
195
|
+
let coordZ = shadowCoord.z.add( bias );
|
|
196
|
+
|
|
197
|
+
if ( renderer.coordinateSystem === WebGPUCoordinateSystem ) {
|
|
198
|
+
|
|
199
|
+
coordZ = coordZ.mul( 2 ).sub( 1 ); // WebGPU: Convertion [ 0, 1 ] to [ - 1, 1 ]
|
|
200
|
+
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
shadowCoord = vec3(
|
|
204
|
+
shadowCoord.x,
|
|
205
|
+
shadowCoord.y.oneMinus(), // follow webgpu standards
|
|
206
|
+
coordZ
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
const frustumTest = shadowCoord.x.greaterThanEqual( 0 )
|
|
210
|
+
.and( shadowCoord.x.lessThanEqual( 1 ) )
|
|
211
|
+
.and( shadowCoord.y.greaterThanEqual( 0 ) )
|
|
212
|
+
.and( shadowCoord.y.lessThanEqual( 1 ) )
|
|
213
|
+
.and( shadowCoord.z.lessThanEqual( 1 ) );
|
|
214
|
+
|
|
215
|
+
//
|
|
216
|
+
|
|
217
|
+
const filterFn = shadow.filterNode || shadowFilterLib[ renderer.shadowMap.type ] || null;
|
|
218
|
+
|
|
219
|
+
if ( filterFn === null ) {
|
|
220
|
+
|
|
221
|
+
throw new Error( 'THREE.WebGPURenderer: Shadow map type not supported yet.' );
|
|
222
|
+
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const shadowNode = frustumTest.cond( filterFn( { depthTexture, shadowCoord, shadow } ), float( 1 ) );
|
|
226
|
+
|
|
227
|
+
this.shadowMap = shadowMap;
|
|
228
|
+
|
|
229
|
+
this.shadowNode = shadowNode;
|
|
230
|
+
this.shadowColorNode = shadowColorNode = this.colorNode.mul( mix( 1, shadowNode, shadowIntensity ) );
|
|
231
|
+
|
|
232
|
+
this.baseColorNode = this.colorNode;
|
|
233
|
+
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
//
|
|
237
|
+
|
|
238
|
+
this.colorNode = shadowColorNode;
|
|
239
|
+
|
|
240
|
+
this.updateBeforeType = NodeUpdateType.RENDER;
|
|
241
|
+
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
setup( builder ) {
|
|
245
|
+
|
|
246
|
+
this.colorNode = this.baseColorNode || this.colorNode;
|
|
247
|
+
|
|
248
|
+
if ( this.light.castShadow ) {
|
|
249
|
+
|
|
250
|
+
if ( builder.object.receiveShadow ) {
|
|
251
|
+
|
|
252
|
+
this.setupShadow( builder );
|
|
253
|
+
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
} else if ( this.shadowNode !== null ) {
|
|
257
|
+
|
|
258
|
+
this.disposeShadow();
|
|
259
|
+
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
updateShadow( frame ) {
|
|
265
|
+
|
|
266
|
+
const { shadowMap, light } = this;
|
|
267
|
+
const { renderer, scene, camera } = frame;
|
|
268
|
+
|
|
269
|
+
const currentOverrideMaterial = scene.overrideMaterial;
|
|
270
|
+
|
|
271
|
+
scene.overrideMaterial = overrideMaterial;
|
|
272
|
+
|
|
273
|
+
shadowMap.setSize( light.shadow.mapSize.width, light.shadow.mapSize.height );
|
|
274
|
+
|
|
275
|
+
light.shadow.updateMatrices( light );
|
|
276
|
+
light.shadow.camera.layers.mask = camera.layers.mask;
|
|
277
|
+
|
|
278
|
+
const currentRenderTarget = renderer.getRenderTarget();
|
|
279
|
+
const currentRenderObjectFunction = renderer.getRenderObjectFunction();
|
|
280
|
+
|
|
281
|
+
renderer.setRenderObjectFunction( ( object, ...params ) => {
|
|
282
|
+
|
|
283
|
+
if ( object.castShadow === true ) {
|
|
284
|
+
|
|
285
|
+
renderer.renderObject( object, ...params );
|
|
286
|
+
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
} );
|
|
290
|
+
|
|
291
|
+
renderer.setRenderTarget( shadowMap );
|
|
292
|
+
renderer.render( scene, light.shadow.camera );
|
|
293
|
+
|
|
294
|
+
renderer.setRenderTarget( currentRenderTarget );
|
|
295
|
+
renderer.setRenderObjectFunction( currentRenderObjectFunction );
|
|
296
|
+
|
|
297
|
+
scene.overrideMaterial = currentOverrideMaterial;
|
|
298
|
+
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
disposeShadow() {
|
|
302
|
+
|
|
303
|
+
this.shadowMap.dispose();
|
|
304
|
+
this.shadowMap = null;
|
|
305
|
+
|
|
306
|
+
this.shadowNode = null;
|
|
307
|
+
this.shadowColorNode = null;
|
|
308
|
+
|
|
309
|
+
this.baseColorNode = null;
|
|
310
|
+
|
|
311
|
+
this.updateBeforeType = NodeUpdateType.NONE;
|
|
312
|
+
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
updateBefore( frame ) {
|
|
316
|
+
|
|
317
|
+
this.updateShadow( frame );
|
|
318
|
+
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
update( /*frame*/ ) {
|
|
322
|
+
|
|
323
|
+
const { light } = this;
|
|
324
|
+
|
|
325
|
+
this.color.copy( light.color ).multiplyScalar( light.intensity );
|
|
326
|
+
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export default AnalyticLightNode;
|
|
332
|
+
|
|
333
|
+
addNodeClass( 'AnalyticLightNode', AnalyticLightNode );
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import LightingNode from './LightingNode.js';
|
|
2
|
+
import { addNodeClass } from '../core/Node.js';
|
|
3
|
+
|
|
4
|
+
class BasicEnvironmentNode extends LightingNode {
|
|
5
|
+
|
|
6
|
+
constructor( envNode = null ) {
|
|
7
|
+
|
|
8
|
+
super();
|
|
9
|
+
|
|
10
|
+
this.envNode = envNode;
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
setup( builder ) {
|
|
15
|
+
|
|
16
|
+
// environment property is used in the finish() method of BasicLightingModel
|
|
17
|
+
|
|
18
|
+
builder.context.environment = this.envNode;
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default BasicEnvironmentNode;
|
|
25
|
+
|
|
26
|
+
addNodeClass( 'BasicEnvironmentNode', BasicEnvironmentNode );
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import LightingNode from './LightingNode.js';
|
|
2
|
+
import { addNodeClass } from '../core/Node.js';
|
|
3
|
+
import { float } from '../shadernode/ShaderNode.js';
|
|
4
|
+
|
|
5
|
+
class BasicLightMapNode extends LightingNode {
|
|
6
|
+
|
|
7
|
+
constructor( lightMapNode = null ) {
|
|
8
|
+
|
|
9
|
+
super();
|
|
10
|
+
|
|
11
|
+
this.lightMapNode = lightMapNode;
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
setup( builder ) {
|
|
16
|
+
|
|
17
|
+
// irradianceLightMap property is used in the indirectDiffuse() method of BasicLightingModel
|
|
18
|
+
|
|
19
|
+
const RECIPROCAL_PI = float( 1 / Math.PI );
|
|
20
|
+
|
|
21
|
+
builder.context.irradianceLightMap = this.lightMapNode.mul( RECIPROCAL_PI );
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default BasicLightMapNode;
|
|
28
|
+
|
|
29
|
+
addNodeClass( 'BasicLightMapNode', BasicLightMapNode );
|
|
@@ -3,7 +3,7 @@ import { lightTargetDirection } from './LightNode.js';
|
|
|
3
3
|
import { addLightNode } from './LightsNode.js';
|
|
4
4
|
import { addNodeClass } from '../core/Node.js';
|
|
5
5
|
|
|
6
|
-
import { DirectionalLight } from '
|
|
6
|
+
import { DirectionalLight } from '../../lights/DirectionalLight.js';
|
|
7
7
|
|
|
8
8
|
class DirectionalLightNode extends AnalyticLightNode {
|
|
9
9
|
|
|
@@ -26,8 +26,7 @@ class DirectionalLightNode extends AnalyticLightNode {
|
|
|
26
26
|
lightingModel.direct( {
|
|
27
27
|
lightDirection,
|
|
28
28
|
lightColor,
|
|
29
|
-
reflectedLight
|
|
30
|
-
shadowMask: this.shadowMaskNode
|
|
29
|
+
reflectedLight
|
|
31
30
|
}, builder.stack, builder );
|
|
32
31
|
|
|
33
32
|
}
|
|
@@ -11,7 +11,7 @@ import { reference } from '../accessors/ReferenceNode.js';
|
|
|
11
11
|
import { transformedBentNormalView } from '../accessors/AccessorsUtils.js';
|
|
12
12
|
import { pmremTexture } from '../pmrem/PMREMNode.js';
|
|
13
13
|
|
|
14
|
-
const
|
|
14
|
+
const _envNodeCache = new WeakMap();
|
|
15
15
|
|
|
16
16
|
class EnvironmentNode extends LightingNode {
|
|
17
17
|
|
|
@@ -29,13 +29,13 @@ class EnvironmentNode extends LightingNode {
|
|
|
29
29
|
|
|
30
30
|
if ( envNode.isTextureNode ) {
|
|
31
31
|
|
|
32
|
-
let cacheEnvNode =
|
|
32
|
+
let cacheEnvNode = _envNodeCache.get( envNode.value );
|
|
33
33
|
|
|
34
34
|
if ( cacheEnvNode === undefined ) {
|
|
35
35
|
|
|
36
36
|
cacheEnvNode = pmremTexture( envNode.value );
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
_envNodeCache.set( envNode.value, cacheEnvNode );
|
|
39
39
|
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -57,12 +57,13 @@ class EnvironmentNode extends LightingNode {
|
|
|
57
57
|
const irradiance = context( envNode, createIrradianceContext( transformedNormalWorld ) ).mul( Math.PI ).mul( intensity );
|
|
58
58
|
|
|
59
59
|
const isolateRadiance = cache( radiance );
|
|
60
|
+
const isolateIrradiance = cache( irradiance );
|
|
60
61
|
|
|
61
62
|
//
|
|
62
63
|
|
|
63
64
|
builder.context.radiance.addAssign( isolateRadiance );
|
|
64
65
|
|
|
65
|
-
builder.context.iblIrradiance.addAssign(
|
|
66
|
+
builder.context.iblIrradiance.addAssign( isolateIrradiance );
|
|
66
67
|
|
|
67
68
|
//
|
|
68
69
|
|
|
@@ -6,7 +6,8 @@ import { normalView } from '../accessors/NormalNode.js';
|
|
|
6
6
|
import { objectPosition } from '../accessors/Object3DNode.js';
|
|
7
7
|
import { addNodeClass } from '../core/Node.js';
|
|
8
8
|
|
|
9
|
-
import { Color
|
|
9
|
+
import { Color } from '../../math/Color.js';
|
|
10
|
+
import { HemisphereLight } from '../../lights/HemisphereLight.js';
|
|
10
11
|
|
|
11
12
|
class HemisphereLightNode extends AnalyticLightNode {
|
|
12
13
|
|
|
@@ -4,7 +4,7 @@ import { texture } from '../accessors/TextureNode.js';
|
|
|
4
4
|
import { vec2 } from '../shadernode/ShaderNode.js';
|
|
5
5
|
import { addNodeClass } from '../core/Node.js';
|
|
6
6
|
|
|
7
|
-
import IESSpotLight from '../../lights/IESSpotLight.js';
|
|
7
|
+
import IESSpotLight from '../../lights/webgpu/IESSpotLight.js';
|
|
8
8
|
|
|
9
9
|
class IESSpotLightNode extends SpotLightNode {
|
|
10
10
|
|
|
@@ -53,6 +53,18 @@ class LightsNode extends Node {
|
|
|
53
53
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
analyze( builder ) {
|
|
57
|
+
|
|
58
|
+
const properties = builder.getDataFromNode( this );
|
|
59
|
+
|
|
60
|
+
for ( const node of properties.nodes ) {
|
|
61
|
+
|
|
62
|
+
node.build( builder );
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
|
|
56
68
|
setup( builder ) {
|
|
57
69
|
|
|
58
70
|
const context = builder.context;
|
|
@@ -70,6 +82,11 @@ class LightsNode extends Node {
|
|
|
70
82
|
|
|
71
83
|
//
|
|
72
84
|
|
|
85
|
+
const properties = builder.getDataFromNode( this );
|
|
86
|
+
properties.nodes = stack.nodes;
|
|
87
|
+
|
|
88
|
+
//
|
|
89
|
+
|
|
73
90
|
lightingModel.start( context, stack, builder );
|
|
74
91
|
|
|
75
92
|
// lights
|
|
@@ -82,9 +99,7 @@ class LightsNode extends Node {
|
|
|
82
99
|
|
|
83
100
|
//
|
|
84
101
|
|
|
85
|
-
lightingModel.
|
|
86
|
-
lightingModel.indirectSpecular( context, stack, builder );
|
|
87
|
-
lightingModel.ambientOcclusion( context, stack, builder );
|
|
102
|
+
lightingModel.indirect( context, stack, builder );
|
|
88
103
|
|
|
89
104
|
//
|
|
90
105
|
|
|
@@ -6,7 +6,7 @@ import { objectViewPosition } from '../accessors/Object3DNode.js';
|
|
|
6
6
|
import { positionView } from '../accessors/PositionNode.js';
|
|
7
7
|
import { addNodeClass } from '../core/Node.js';
|
|
8
8
|
|
|
9
|
-
import { PointLight } from '
|
|
9
|
+
import { PointLight } from '../../lights/PointLight.js';
|
|
10
10
|
|
|
11
11
|
class PointLightNode extends AnalyticLightNode {
|
|
12
12
|
|
|
@@ -54,8 +54,7 @@ class PointLightNode extends AnalyticLightNode {
|
|
|
54
54
|
lightingModel.direct( {
|
|
55
55
|
lightDirection,
|
|
56
56
|
lightColor,
|
|
57
|
-
reflectedLight
|
|
58
|
-
shadowMask: this.shadowMaskNode
|
|
57
|
+
reflectedLight
|
|
59
58
|
}, builder.stack, builder );
|
|
60
59
|
|
|
61
60
|
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import AnalyticLightNode from './AnalyticLightNode.js';
|
|
2
|
+
import { addLightNode } from './LightsNode.js';
|
|
3
|
+
import { texture } from '../accessors/TextureNode.js';
|
|
4
|
+
import { uniform } from '../core/UniformNode.js';
|
|
5
|
+
import { objectViewPosition } from '../accessors/Object3DNode.js';
|
|
6
|
+
import { addNodeClass } from '../core/Node.js';
|
|
7
|
+
|
|
8
|
+
import { RectAreaLight } from '../../lights/RectAreaLight.js';
|
|
9
|
+
import { Matrix4 } from '../../math/Matrix4.js';
|
|
10
|
+
import { Vector3 } from '../../math/Vector3.js';
|
|
11
|
+
|
|
12
|
+
const _matrix41 = /*@__PURE__*/ new Matrix4();
|
|
13
|
+
const _matrix42 = /*@__PURE__*/ new Matrix4();
|
|
14
|
+
|
|
15
|
+
let ltcLib = null;
|
|
16
|
+
|
|
17
|
+
class RectAreaLightNode extends AnalyticLightNode {
|
|
18
|
+
|
|
19
|
+
constructor( light = null ) {
|
|
20
|
+
|
|
21
|
+
super( light );
|
|
22
|
+
|
|
23
|
+
this.halfHeight = uniform( new Vector3() );
|
|
24
|
+
this.halfWidth = uniform( new Vector3() );
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
update( frame ) {
|
|
29
|
+
|
|
30
|
+
super.update( frame );
|
|
31
|
+
|
|
32
|
+
const { light } = this;
|
|
33
|
+
|
|
34
|
+
const viewMatrix = frame.camera.matrixWorldInverse;
|
|
35
|
+
|
|
36
|
+
_matrix42.identity();
|
|
37
|
+
_matrix41.copy( light.matrixWorld );
|
|
38
|
+
_matrix41.premultiply( viewMatrix );
|
|
39
|
+
_matrix42.extractRotation( _matrix41 );
|
|
40
|
+
|
|
41
|
+
this.halfWidth.value.set( light.width * 0.5, 0.0, 0.0 );
|
|
42
|
+
this.halfHeight.value.set( 0.0, light.height * 0.5, 0.0 );
|
|
43
|
+
|
|
44
|
+
this.halfWidth.value.applyMatrix4( _matrix42 );
|
|
45
|
+
this.halfHeight.value.applyMatrix4( _matrix42 );
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
setup( builder ) {
|
|
50
|
+
|
|
51
|
+
super.setup( builder );
|
|
52
|
+
|
|
53
|
+
let ltc_1, ltc_2;
|
|
54
|
+
|
|
55
|
+
if ( builder.isAvailable( 'float32Filterable' ) ) {
|
|
56
|
+
|
|
57
|
+
ltc_1 = texture( ltcLib.LTC_FLOAT_1 );
|
|
58
|
+
ltc_2 = texture( ltcLib.LTC_FLOAT_2 );
|
|
59
|
+
|
|
60
|
+
} else {
|
|
61
|
+
|
|
62
|
+
ltc_1 = texture( ltcLib.LTC_HALF_1 );
|
|
63
|
+
ltc_2 = texture( ltcLib.LTC_HALF_2 );
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const { colorNode, light } = this;
|
|
68
|
+
const lightingModel = builder.context.lightingModel;
|
|
69
|
+
|
|
70
|
+
const lightPosition = objectViewPosition( light );
|
|
71
|
+
const reflectedLight = builder.context.reflectedLight;
|
|
72
|
+
|
|
73
|
+
lightingModel.directRectArea( {
|
|
74
|
+
lightColor: colorNode,
|
|
75
|
+
lightPosition,
|
|
76
|
+
halfWidth: this.halfWidth,
|
|
77
|
+
halfHeight: this.halfHeight,
|
|
78
|
+
reflectedLight,
|
|
79
|
+
ltc_1,
|
|
80
|
+
ltc_2
|
|
81
|
+
}, builder.stack, builder );
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
static setLTC( ltc ) {
|
|
86
|
+
|
|
87
|
+
ltcLib = ltc;
|
|
88
|
+
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export default RectAreaLightNode;
|
|
94
|
+
|
|
95
|
+
addNodeClass( 'RectAreaLightNode', RectAreaLightNode );
|
|
96
|
+
|
|
97
|
+
addLightNode( RectAreaLight, RectAreaLightNode );
|
|
@@ -8,7 +8,7 @@ import { objectViewPosition } from '../accessors/Object3DNode.js';
|
|
|
8
8
|
import { positionView } from '../accessors/PositionNode.js';
|
|
9
9
|
import { addNodeClass } from '../core/Node.js';
|
|
10
10
|
|
|
11
|
-
import { SpotLight } from '
|
|
11
|
+
import { SpotLight } from '../../lights/SpotLight.js';
|
|
12
12
|
|
|
13
13
|
class SpotLightNode extends AnalyticLightNode {
|
|
14
14
|
|
|
@@ -75,8 +75,7 @@ class SpotLightNode extends AnalyticLightNode {
|
|
|
75
75
|
lightingModel.direct( {
|
|
76
76
|
lightDirection,
|
|
77
77
|
lightColor,
|
|
78
|
-
reflectedLight
|
|
79
|
-
shadowMask: this.shadowMaskNode
|
|
78
|
+
reflectedLight
|
|
80
79
|
}, builder.stack, builder );
|
|
81
80
|
|
|
82
81
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { createNodeFromType } from '../core/Node.js';
|
|
2
2
|
import { nodeObject } from '../shadernode/ShaderNode.js';
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
import { Loader } from '../../loaders/Loader.js';
|
|
5
|
+
import { FileLoader } from '../../loaders/FileLoader.js';
|
|
4
6
|
|
|
5
7
|
class NodeLoader extends Loader {
|
|
6
8
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { MaterialLoader } from 'three';
|
|
2
1
|
import { createNodeMaterialFromType } from '../materials/Materials.js';
|
|
3
2
|
|
|
3
|
+
import { MaterialLoader } from '../../loaders/MaterialLoader.js';
|
|
4
|
+
|
|
4
5
|
const superFromTypeFunction = MaterialLoader.createMaterialFromType;
|
|
5
6
|
|
|
6
7
|
MaterialLoader.createMaterialFromType = function ( type ) {
|