super-three 0.165.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/build/three.cjs +706 -383
- package/build/three.module.js +702 -384
- 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/csm/CSMShader.js +4 -4
- package/examples/jsm/exporters/GLTFExporter.js +7 -3
- package/examples/jsm/geometries/TeapotGeometry.js +1 -1
- package/examples/jsm/helpers/ViewHelper.js +51 -2
- package/examples/jsm/libs/tween.module.js +64 -75
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +91 -0
- package/examples/jsm/lights/RectAreaLightUniformsLib.js +8 -63
- package/examples/jsm/lines/webgpu/Line2.js +20 -0
- package/examples/jsm/lines/webgpu/LineSegments2.js +376 -0
- package/examples/jsm/loaders/FBXLoader.js +23 -45
- package/examples/jsm/loaders/GLTFLoader.js +10 -4
- 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/SimplifyModifier.js +2 -1
- package/examples/jsm/objects/InstancedPoints.js +2 -2
- 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/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/package.json +7 -6
- package/src/Three.WebGPU.js +194 -0
- package/src/Three.js +2 -0
- package/src/constants.js +4 -1
- package/src/core/Object3D.js +22 -22
- 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/ObjectLoader.js +33 -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 +30 -12
- package/{examples/jsm → src}/nodes/accessors/BatchNode.js +28 -10
- package/{examples/jsm → src}/nodes/accessors/BufferAttributeNode.js +36 -1
- 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 +22 -2
- package/{examples/jsm → src}/nodes/accessors/ModelNode.js +2 -1
- package/{examples/jsm → src}/nodes/accessors/MorphNode.js +24 -20
- package/{examples/jsm → src}/nodes/accessors/NormalNode.js +1 -1
- package/{examples/jsm → src}/nodes/accessors/Object3DNode.js +1 -1
- package/{examples/jsm → src}/nodes/accessors/ReferenceNode.js +1 -1
- package/{examples/jsm → src}/nodes/accessors/ReflectVectorNode.js +4 -0
- package/{examples/jsm → src}/nodes/accessors/StorageBufferNode.js +50 -1
- package/{examples/jsm → src}/nodes/accessors/StorageTextureNode.js +12 -3
- package/{examples/jsm → src}/nodes/accessors/TextureNode.js +55 -18
- 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 +20 -6
- package/{examples/jsm → src}/nodes/core/CacheNode.js +7 -10
- 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 +18 -12
- package/{examples/jsm → src}/nodes/core/NodeBuilder.js +175 -37
- 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/NodeUniform.js +1 -2
- package/{examples/jsm → src}/nodes/core/NodeUtils.js +6 -1
- package/{examples/jsm → src}/nodes/core/PropertyNode.js +1 -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/{examples/jsm → src}/nodes/core/VaryingNode.js +8 -0
- package/{examples/jsm → src}/nodes/display/AfterImageNode.js +19 -27
- 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 +2 -1
- 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 +42 -1
- package/{examples/jsm → src}/nodes/functions/ToonLightingModel.js +3 -1
- 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 +1 -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 +3 -3
- package/{examples/jsm → src}/nodes/materials/LineBasicNodeMaterial.js +3 -3
- package/{examples/jsm → src}/nodes/materials/LineDashedNodeMaterial.js +4 -3
- package/src/nodes/materials/MeshBasicNodeMaterial.js +73 -0
- package/{examples/jsm → src}/nodes/materials/MeshLambertNodeMaterial.js +12 -3
- package/{examples/jsm → src}/nodes/materials/MeshMatcapNodeMaterial.js +6 -5
- 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 +5 -4
- package/{examples/jsm → src}/nodes/materials/MeshStandardNodeMaterial.js +14 -3
- package/{examples/jsm → src}/nodes/materials/MeshToonNodeMaterial.js +3 -3
- package/{examples/jsm → src}/nodes/materials/NodeMaterial.js +85 -20
- 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/{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/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 +2 -0
- 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/MaxMipLevelNode.js +8 -2
- package/src/nodes/utils/RTTNode.js +130 -0
- package/{examples/jsm → src}/nodes/utils/ReflectorNode.js +9 -1
- package/src/objects/BatchedMesh.js +168 -188
- package/src/objects/InstancedMesh.js +1 -1
- package/src/renderers/WebGLRenderer.js +38 -25
- package/{examples/jsm → src}/renderers/common/Attributes.js +2 -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 +38 -23
- package/{examples/jsm → src}/renderers/common/ClippingContext.js +4 -2
- 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/src/renderers/common/PostProcessing.js +87 -0
- package/{examples/jsm/objects → src/renderers/common}/QuadMesh.js +6 -3
- 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/RenderObject.js +44 -11
- package/{examples/jsm → src}/renderers/common/Renderer.js +84 -32
- 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 +9 -4
- 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 +6 -5
- package/{examples/jsm → src}/renderers/common/nodes/NodeSampler.js +2 -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 +16 -1
- package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +1 -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/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/WebGLBufferRenderer.js +6 -19
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +6 -18
- package/src/renderers/webgl/WebGLLights.js +6 -0
- package/src/renderers/webgl/WebGLProgram.js +26 -0
- package/src/renderers/webgl/WebGLPrograms.js +1 -1
- package/src/renderers/webgl/WebGLTextures.js +14 -53
- 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 +178 -43
- 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 +34 -2
- package/{examples/jsm/renderers/webgl → src/renderers/webgl-fallback}/utils/WebGLUtils.js +1 -1
- package/{examples/jsm → src}/renderers/webgpu/WebGPUBackend.js +164 -76
- package/{examples/jsm → src}/renderers/webgpu/WebGPURenderer.js +2 -2
- package/{examples/jsm → src}/renderers/webgpu/nodes/WGSLNodeBuilder.js +194 -56
- 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 +20 -13
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUConstants.js +3 -1
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUPipelineUtils.js +28 -21
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUTextureUtils.js +40 -23
- package/{examples/jsm → src}/renderers/webgpu/utils/WebGPUUtils.js +24 -3
- package/src/renderers/webxr/WebXRDepthSensing.js +6 -0
- package/src/renderers/webxr/WebXRManager.js +6 -0
- package/src/textures/CompressedArrayTexture.js +1 -1
- package/examples/jsm/nodes/accessors/CameraNode.js +0 -12
- package/examples/jsm/nodes/accessors/InstanceNode.js +0 -94
- package/examples/jsm/nodes/core/NodeCache.js +0 -26
- package/examples/jsm/nodes/display/PassNode.js +0 -201
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +0 -256
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +0 -28
- 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/BitangentNode.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/BufferNode.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/PositionNode.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/TangentNode.js +0 -0
- /package/{examples/jsm → src}/nodes/accessors/Texture3DNode.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/UVNode.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/ContextNode.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/NodeKeywords.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/OutputStructNode.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/Materials.js +0 -0
- /package/{examples/jsm → src}/nodes/materials/MeshSSSNodeMaterial.js +0 -0
- /package/{examples/jsm → src}/nodes/materials/VolumeNodeMaterial.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/HashNode.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/ArrayElementNode.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/MatcapUVNode.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/TimerNode.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/ChainMap.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/Pipelines.js +0 -0
- /package/{examples/jsm → src}/renderers/common/ProgrammableStage.js +0 -0
- /package/{examples/jsm → src}/renderers/common/RenderBundle.js +0 -0
- /package/{examples/jsm → src}/renderers/common/RenderBundles.js +0 -0
- /package/{examples/jsm → src}/renderers/common/RenderList.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,78 @@
|
|
|
1
|
+
import LightingModel from '../core/LightingModel.js';
|
|
2
|
+
import { diffuseColor } from '../core/PropertyNode.js';
|
|
3
|
+
import { MultiplyOperation, MixOperation, AddOperation } from '../../constants.js';
|
|
4
|
+
import { materialSpecularStrength, materialReflectivity } from '../accessors/MaterialNode.js';
|
|
5
|
+
import { mix } from '../math/MathNode.js';
|
|
6
|
+
import { vec4 } from '../shadernode/ShaderNode.js';
|
|
7
|
+
|
|
8
|
+
class BasicLightingModel extends LightingModel {
|
|
9
|
+
|
|
10
|
+
constructor() {
|
|
11
|
+
|
|
12
|
+
super();
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
indirect( context, stack, builder ) {
|
|
17
|
+
|
|
18
|
+
const ambientOcclusion = context.ambientOcclusion;
|
|
19
|
+
const reflectedLight = context.reflectedLight;
|
|
20
|
+
const irradianceLightMap = builder.context.irradianceLightMap;
|
|
21
|
+
|
|
22
|
+
reflectedLight.indirectDiffuse.assign( vec4( 0.0 ) );
|
|
23
|
+
|
|
24
|
+
// accumulation (baked indirect lighting only)
|
|
25
|
+
|
|
26
|
+
if ( irradianceLightMap ) {
|
|
27
|
+
|
|
28
|
+
reflectedLight.indirectDiffuse.addAssign( irradianceLightMap );
|
|
29
|
+
|
|
30
|
+
} else {
|
|
31
|
+
|
|
32
|
+
reflectedLight.indirectDiffuse.addAssign( vec4( 1.0, 1.0, 1.0, 0.0 ) );
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// modulation
|
|
37
|
+
|
|
38
|
+
reflectedLight.indirectDiffuse.mulAssign( ambientOcclusion );
|
|
39
|
+
|
|
40
|
+
reflectedLight.indirectDiffuse.mulAssign( diffuseColor.rgb );
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
finish( context, stack, builder ) {
|
|
45
|
+
|
|
46
|
+
const material = builder.material;
|
|
47
|
+
const outgoingLight = context.outgoingLight;
|
|
48
|
+
const envNode = builder.context.environment;
|
|
49
|
+
|
|
50
|
+
if ( envNode ) {
|
|
51
|
+
|
|
52
|
+
switch ( material.combine ) {
|
|
53
|
+
|
|
54
|
+
case MultiplyOperation:
|
|
55
|
+
outgoingLight.rgb.assign( mix( outgoingLight.rgb, outgoingLight.rgb.mul( envNode.rgb ), materialSpecularStrength.mul( materialReflectivity ) ) );
|
|
56
|
+
break;
|
|
57
|
+
|
|
58
|
+
case MixOperation:
|
|
59
|
+
outgoingLight.rgb.assign( mix( outgoingLight.rgb, envNode.rgb, materialSpecularStrength.mul( materialReflectivity ) ) );
|
|
60
|
+
break;
|
|
61
|
+
|
|
62
|
+
case AddOperation:
|
|
63
|
+
outgoingLight.rgb.addAssign( envNode.rgb.mul( materialSpecularStrength.mul( materialReflectivity ) ) );
|
|
64
|
+
break;
|
|
65
|
+
|
|
66
|
+
default:
|
|
67
|
+
console.warn( 'THREE.BasicLightingModel: Unsupported .combine value:', material.combine );
|
|
68
|
+
break;
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export default BasicLightingModel;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import BasicLightingModel from './BasicLightingModel.js';
|
|
2
2
|
import F_Schlick from './BSDF/F_Schlick.js';
|
|
3
3
|
import BRDF_Lambert from './BSDF/BRDF_Lambert.js';
|
|
4
4
|
import { diffuseColor } from '../core/PropertyNode.js';
|
|
@@ -31,7 +31,7 @@ const BRDF_BlinnPhong = tslFn( ( { lightDirection } ) => {
|
|
|
31
31
|
|
|
32
32
|
} );
|
|
33
33
|
|
|
34
|
-
class PhongLightingModel extends
|
|
34
|
+
class PhongLightingModel extends BasicLightingModel {
|
|
35
35
|
|
|
36
36
|
constructor( specular = true ) {
|
|
37
37
|
|
|
@@ -56,10 +56,12 @@ class PhongLightingModel extends LightingModel {
|
|
|
56
56
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
indirect( { ambientOcclusion, irradiance, reflectedLight } ) {
|
|
60
60
|
|
|
61
61
|
reflectedLight.indirectDiffuse.addAssign( irradiance.mul( BRDF_Lambert( { diffuseColor } ) ) );
|
|
62
62
|
|
|
63
|
+
reflectedLight.indirectDiffuse.mulAssign( ambientOcclusion );
|
|
64
|
+
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
}
|
|
@@ -5,10 +5,11 @@ import EnvironmentBRDF from './BSDF/EnvironmentBRDF.js';
|
|
|
5
5
|
import F_Schlick from './BSDF/F_Schlick.js';
|
|
6
6
|
import Schlick_to_F0 from './BSDF/Schlick_to_F0.js';
|
|
7
7
|
import BRDF_Sheen from './BSDF/BRDF_Sheen.js';
|
|
8
|
+
import { LTC_Evaluate, LTC_Uv } from './BSDF/LTC.js';
|
|
8
9
|
import LightingModel from '../core/LightingModel.js';
|
|
9
10
|
import { diffuseColor, specularColor, specularF90, roughness, clearcoat, clearcoatRoughness, sheen, sheenRoughness, iridescence, iridescenceIOR, iridescenceThickness, ior, thickness, transmission, attenuationDistance, attenuationColor, dispersion } from '../core/PropertyNode.js';
|
|
10
11
|
import { transformedNormalView, transformedClearcoatNormalView, transformedNormalWorld } from '../accessors/NormalNode.js';
|
|
11
|
-
import { positionViewDirection, positionWorld } from '../accessors/PositionNode.js';
|
|
12
|
+
import { positionViewDirection, positionView, positionWorld } from '../accessors/PositionNode.js';
|
|
12
13
|
import { tslFn, float, vec2, vec3, vec4, mat3, If } from '../shadernode/ShaderNode.js';
|
|
13
14
|
import { cond } from '../math/CondNode.js';
|
|
14
15
|
import { mix, normalize, refract, length, clamp, log2, log, exp, smoothstep } from '../math/MathNode.js';
|
|
@@ -474,6 +475,46 @@ class PhysicalLightingModel extends LightingModel {
|
|
|
474
475
|
|
|
475
476
|
}
|
|
476
477
|
|
|
478
|
+
directRectArea( { lightColor, lightPosition, halfWidth, halfHeight, reflectedLight, ltc_1, ltc_2 } ) {
|
|
479
|
+
|
|
480
|
+
const p0 = lightPosition.add( halfWidth ).sub( halfHeight ); // counterclockwise; light shines in local neg z direction
|
|
481
|
+
const p1 = lightPosition.sub( halfWidth ).sub( halfHeight );
|
|
482
|
+
const p2 = lightPosition.sub( halfWidth ).add( halfHeight );
|
|
483
|
+
const p3 = lightPosition.add( halfWidth ).add( halfHeight );
|
|
484
|
+
|
|
485
|
+
const N = transformedNormalView;
|
|
486
|
+
const V = positionViewDirection;
|
|
487
|
+
const P = positionView.toVar();
|
|
488
|
+
|
|
489
|
+
const uv = LTC_Uv( { N, V, roughness } );
|
|
490
|
+
|
|
491
|
+
const t1 = ltc_1.uv( uv ).toVar();
|
|
492
|
+
const t2 = ltc_2.uv( uv ).toVar();
|
|
493
|
+
|
|
494
|
+
const mInv = mat3(
|
|
495
|
+
vec3( t1.x, 0, t1.y ),
|
|
496
|
+
vec3( 0, 1, 0 ),
|
|
497
|
+
vec3( t1.z, 0, t1.w )
|
|
498
|
+
).toVar();
|
|
499
|
+
|
|
500
|
+
// LTC Fresnel Approximation by Stephen Hill
|
|
501
|
+
// http://blog.selfshadow.com/publications/s2016-advances/s2016_ltc_fresnel.pdf
|
|
502
|
+
const fresnel = specularColor.mul( t2.x ).add( specularColor.oneMinus().mul( t2.y ) ).toVar();
|
|
503
|
+
|
|
504
|
+
reflectedLight.directSpecular.addAssign( lightColor.mul( fresnel ).mul( LTC_Evaluate( { N, V, P, mInv, p0, p1, p2, p3 } ) ) );
|
|
505
|
+
|
|
506
|
+
reflectedLight.directDiffuse.addAssign( lightColor.mul( diffuseColor ).mul( LTC_Evaluate( { N, V, P, mInv: mat3( 1, 0, 0, 0, 1, 0, 0, 0, 1 ), p0, p1, p2, p3 } ) ) );
|
|
507
|
+
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
indirect( context, stack, builder ) {
|
|
511
|
+
|
|
512
|
+
this.indirectDiffuse( context, stack, builder );
|
|
513
|
+
this.indirectSpecular( context, stack, builder );
|
|
514
|
+
this.ambientOcclusion( context, stack, builder );
|
|
515
|
+
|
|
516
|
+
}
|
|
517
|
+
|
|
477
518
|
indirectDiffuse( { irradiance, reflectedLight } ) {
|
|
478
519
|
|
|
479
520
|
reflectedLight.indirectDiffuse.addAssign( irradiance.mul( BRDF_Lambert( { diffuseColor } ) ) );
|
|
@@ -38,10 +38,12 @@ class ToonLightingModel extends LightingModel {
|
|
|
38
38
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
indirect( { ambientOcclusion, irradiance, reflectedLight } ) {
|
|
42
42
|
|
|
43
43
|
reflectedLight.indirectDiffuse.addAssign( irradiance.mul( BRDF_Lambert( { diffuseColor } ) ) );
|
|
44
44
|
|
|
45
|
+
reflectedLight.indirectDiffuse.mulAssign( ambientOcclusion );
|
|
46
|
+
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import Node, { addNodeClass } from '../core/Node.js';
|
|
2
2
|
import { getValueType } from '../core/NodeUtils.js';
|
|
3
3
|
import { buffer } from '../accessors/BufferNode.js';
|
|
4
|
-
|
|
4
|
+
import { instancedBufferAttribute } from '../accessors/BufferAttributeNode.js';
|
|
5
5
|
import { instanceIndex } from '../core/IndexNode.js';
|
|
6
6
|
import { nodeProxy, float } from '../shadernode/ShaderNode.js';
|
|
7
7
|
|
|
8
|
-
import { Vector4
|
|
8
|
+
import { Vector4 } from '../../math/Vector4.js';
|
|
9
|
+
import { MathUtils } from '../../math/MathUtils.js';
|
|
10
|
+
import { InstancedBufferAttribute } from '../../core/InstancedBufferAttribute.js';
|
|
9
11
|
|
|
10
12
|
let min = null;
|
|
11
13
|
let max = null;
|
|
@@ -32,7 +34,7 @@ class RangeNode extends Node {
|
|
|
32
34
|
|
|
33
35
|
getNodeType( builder ) {
|
|
34
36
|
|
|
35
|
-
return builder.object.
|
|
37
|
+
return builder.object.count > 1 ? builder.getTypeFromLength( this.getVectorLength( builder ) ) : 'float';
|
|
36
38
|
|
|
37
39
|
}
|
|
38
40
|
|
|
@@ -42,7 +44,7 @@ class RangeNode extends Node {
|
|
|
42
44
|
|
|
43
45
|
let output = null;
|
|
44
46
|
|
|
45
|
-
if ( object.
|
|
47
|
+
if ( object.count > 1 ) {
|
|
46
48
|
|
|
47
49
|
const minValue = this.minNode.value;
|
|
48
50
|
const maxValue = this.maxNode.value;
|
|
@@ -82,8 +84,19 @@ class RangeNode extends Node {
|
|
|
82
84
|
|
|
83
85
|
const nodeType = this.getNodeType( builder );
|
|
84
86
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
+
if ( object.count <= 4096 ) {
|
|
88
|
+
|
|
89
|
+
output = buffer( array, 'vec4', object.count ).element( instanceIndex ).convert( nodeType );
|
|
90
|
+
|
|
91
|
+
} else {
|
|
92
|
+
|
|
93
|
+
// TODO: Improve anonymous buffer attribute creation removing this part
|
|
94
|
+
const bufferAttribute = new InstancedBufferAttribute( array, 4 );
|
|
95
|
+
builder.geometry.setAttribute( '__range' + this.id, bufferAttribute );
|
|
96
|
+
|
|
97
|
+
output = instancedBufferAttribute( bufferAttribute ).convert( nodeType );
|
|
98
|
+
|
|
99
|
+
}
|
|
87
100
|
|
|
88
101
|
} else {
|
|
89
102
|
|
|
@@ -13,10 +13,7 @@ class AONode extends LightingNode {
|
|
|
13
13
|
|
|
14
14
|
setup( builder ) {
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
const aoNode = this.aoNode.x.sub( 1.0 ).mul( aoIntensity ).add( 1.0 );
|
|
18
|
-
|
|
19
|
-
builder.context.ambientOcclusion.mulAssign( aoNode );
|
|
16
|
+
builder.context.ambientOcclusion.mulAssign( this.aoNode );
|
|
20
17
|
|
|
21
18
|
}
|
|
22
19
|
|
|
@@ -2,7 +2,7 @@ import AnalyticLightNode from './AnalyticLightNode.js';
|
|
|
2
2
|
import { addLightNode } from './LightsNode.js';
|
|
3
3
|
import { addNodeClass } from '../core/Node.js';
|
|
4
4
|
|
|
5
|
-
import { AmbientLight } from '
|
|
5
|
+
import { AmbientLight } from '../../lights/AmbientLight.js';
|
|
6
6
|
|
|
7
7
|
class AmbientLightNode extends AnalyticLightNode {
|
|
8
8
|
|
|
@@ -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
|
}
|