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
|
@@ -3,28 +3,29 @@ import { nodeObject, addNodeElement, tslFn, float, vec2, vec4 } from '../shadern
|
|
|
3
3
|
import { NodeUpdateType } from '../core/constants.js';
|
|
4
4
|
import { mul } from '../math/OperatorNode.js';
|
|
5
5
|
import { uv } from '../accessors/UVNode.js';
|
|
6
|
-
import {
|
|
6
|
+
import { passTexture } from './PassNode.js';
|
|
7
7
|
import { uniform } from '../core/UniformNode.js';
|
|
8
|
-
import
|
|
9
|
-
|
|
8
|
+
import QuadMesh from '../../renderers/common/QuadMesh.js';
|
|
9
|
+
|
|
10
|
+
import { Vector2 } from '../../math/Vector2.js';
|
|
11
|
+
import { RenderTarget } from '../../core/RenderTarget.js';
|
|
10
12
|
|
|
11
13
|
// WebGPU: The use of a single QuadMesh for both gaussian blur passes results in a single RenderObject with a SampledTexture binding that
|
|
12
14
|
// alternates between source textures and triggers creation of new BindGroups and BindGroupLayouts every frame.
|
|
13
15
|
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
+
const _quadMesh1 = /*@__PURE__*/ new QuadMesh();
|
|
17
|
+
const _quadMesh2 = /*@__PURE__*/ new QuadMesh();
|
|
16
18
|
|
|
17
19
|
class GaussianBlurNode extends TempNode {
|
|
18
20
|
|
|
19
|
-
constructor( textureNode, sigma = 2 ) {
|
|
21
|
+
constructor( textureNode, directionNode = null, sigma = 2 ) {
|
|
20
22
|
|
|
21
23
|
super( 'vec4' );
|
|
22
24
|
|
|
23
25
|
this.textureNode = textureNode;
|
|
26
|
+
this.directionNode = directionNode;
|
|
24
27
|
this.sigma = sigma;
|
|
25
28
|
|
|
26
|
-
this.directionNode = vec2( 1 );
|
|
27
|
-
|
|
28
29
|
this._invSize = uniform( new Vector2() );
|
|
29
30
|
this._passDirection = uniform( new Vector2() );
|
|
30
31
|
|
|
@@ -33,7 +34,7 @@ class GaussianBlurNode extends TempNode {
|
|
|
33
34
|
this._verticalRT = new RenderTarget();
|
|
34
35
|
this._verticalRT.texture.name = 'GaussianBlurNode.vertical';
|
|
35
36
|
|
|
36
|
-
this._textureNode =
|
|
37
|
+
this._textureNode = passTexture( this, this._verticalRT.texture );
|
|
37
38
|
|
|
38
39
|
this.updateBeforeType = NodeUpdateType.RENDER;
|
|
39
40
|
|
|
@@ -60,10 +61,12 @@ class GaussianBlurNode extends TempNode {
|
|
|
60
61
|
const map = textureNode.value;
|
|
61
62
|
|
|
62
63
|
const currentRenderTarget = renderer.getRenderTarget();
|
|
64
|
+
const currentMRT = renderer.getMRT();
|
|
65
|
+
|
|
63
66
|
const currentTexture = textureNode.value;
|
|
64
67
|
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
_quadMesh1.material = this._material;
|
|
69
|
+
_quadMesh2.material = this._material;
|
|
67
70
|
|
|
68
71
|
this.setSize( map.image.width, map.image.height );
|
|
69
72
|
|
|
@@ -72,13 +75,17 @@ class GaussianBlurNode extends TempNode {
|
|
|
72
75
|
this._horizontalRT.texture.type = textureType;
|
|
73
76
|
this._verticalRT.texture.type = textureType;
|
|
74
77
|
|
|
78
|
+
// clear
|
|
79
|
+
|
|
80
|
+
renderer.setMRT( null );
|
|
81
|
+
|
|
75
82
|
// horizontal
|
|
76
83
|
|
|
77
84
|
renderer.setRenderTarget( this._horizontalRT );
|
|
78
85
|
|
|
79
86
|
this._passDirection.value.set( 1, 0 );
|
|
80
87
|
|
|
81
|
-
|
|
88
|
+
_quadMesh1.render( renderer );
|
|
82
89
|
|
|
83
90
|
// vertical
|
|
84
91
|
|
|
@@ -87,11 +94,12 @@ class GaussianBlurNode extends TempNode {
|
|
|
87
94
|
|
|
88
95
|
this._passDirection.value.set( 0, 1 );
|
|
89
96
|
|
|
90
|
-
|
|
97
|
+
_quadMesh2.render( renderer );
|
|
91
98
|
|
|
92
99
|
// restore
|
|
93
100
|
|
|
94
101
|
renderer.setRenderTarget( currentRenderTarget );
|
|
102
|
+
renderer.setMRT( currentMRT );
|
|
95
103
|
textureNode.value = currentTexture;
|
|
96
104
|
|
|
97
105
|
}
|
|
@@ -117,8 +125,9 @@ class GaussianBlurNode extends TempNode {
|
|
|
117
125
|
//
|
|
118
126
|
|
|
119
127
|
const uvNode = textureNode.uvNode || uv();
|
|
128
|
+
const directionNode = vec2( this.directionNode || 1 );
|
|
120
129
|
|
|
121
|
-
const sampleTexture = ( uv ) => textureNode.
|
|
130
|
+
const sampleTexture = ( uv ) => textureNode.uv( uv );
|
|
122
131
|
|
|
123
132
|
const blur = tslFn( () => {
|
|
124
133
|
|
|
@@ -126,7 +135,7 @@ class GaussianBlurNode extends TempNode {
|
|
|
126
135
|
const gaussianCoefficients = this._getCoefficients( kernelSize );
|
|
127
136
|
|
|
128
137
|
const invSize = this._invSize;
|
|
129
|
-
const direction =
|
|
138
|
+
const direction = directionNode.mul( this._passDirection );
|
|
130
139
|
|
|
131
140
|
const weightSum = float( gaussianCoefficients[ 0 ] ).toVar();
|
|
132
141
|
const diffuseSum = vec4( sampleTexture( uvNode ).mul( weightSum ) ).toVar();
|
|
@@ -153,7 +162,8 @@ class GaussianBlurNode extends TempNode {
|
|
|
153
162
|
//
|
|
154
163
|
|
|
155
164
|
const material = this._material || ( this._material = builder.createNodeMaterial() );
|
|
156
|
-
material.fragmentNode = blur();
|
|
165
|
+
material.fragmentNode = blur().context( builder.getSharedContext() );
|
|
166
|
+
material.needsUpdate = true;
|
|
157
167
|
|
|
158
168
|
//
|
|
159
169
|
|
|
@@ -166,6 +176,13 @@ class GaussianBlurNode extends TempNode {
|
|
|
166
176
|
|
|
167
177
|
}
|
|
168
178
|
|
|
179
|
+
dispose() {
|
|
180
|
+
|
|
181
|
+
this._horizontalRT.dispose();
|
|
182
|
+
this._verticalRT.dispose();
|
|
183
|
+
|
|
184
|
+
}
|
|
185
|
+
|
|
169
186
|
_getCoefficients( kernelRadius ) {
|
|
170
187
|
|
|
171
188
|
const coefficients = [];
|
|
@@ -182,7 +199,7 @@ class GaussianBlurNode extends TempNode {
|
|
|
182
199
|
|
|
183
200
|
}
|
|
184
201
|
|
|
185
|
-
export const gaussianBlur = ( node, sigma ) => nodeObject( new GaussianBlurNode( nodeObject( node ), sigma ) );
|
|
202
|
+
export const gaussianBlur = ( node, directionNode, sigma ) => nodeObject( new GaussianBlurNode( nodeObject( node ).toTexture(), directionNode, sigma ) );
|
|
186
203
|
|
|
187
204
|
addNodeElement( 'gaussianBlur', gaussianBlur );
|
|
188
205
|
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import TempNode from '../core/TempNode.js';
|
|
2
|
+
import { addNodeElement, tslFn, nodeObject, vec3, vec4, float } from '../shadernode/ShaderNode.js';
|
|
3
|
+
import { uniform } from '../core/UniformNode.js';
|
|
4
|
+
import { mix } from '../math/MathNode.js';
|
|
5
|
+
|
|
6
|
+
class Lut3DNode extends TempNode {
|
|
7
|
+
|
|
8
|
+
constructor( inputNode, lutNode, size, intensityNode ) {
|
|
9
|
+
|
|
10
|
+
super();
|
|
11
|
+
|
|
12
|
+
this.inputNode = inputNode;
|
|
13
|
+
this.lutNode = lutNode;
|
|
14
|
+
this.size = uniform( size );
|
|
15
|
+
this.intensityNode = intensityNode;
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
setup() {
|
|
20
|
+
|
|
21
|
+
const { inputNode, lutNode } = this;
|
|
22
|
+
|
|
23
|
+
const sampleLut = ( uv ) => lutNode.uv( uv );
|
|
24
|
+
|
|
25
|
+
const lut3D = tslFn( () => {
|
|
26
|
+
|
|
27
|
+
const base = inputNode;
|
|
28
|
+
|
|
29
|
+
// pull the sample in by half a pixel so the sample begins at the center of the edge pixels.
|
|
30
|
+
|
|
31
|
+
const pixelWidth = float( 1.0 ).div( this.size );
|
|
32
|
+
const halfPixelWidth = float( 0.5 ).div( this.size );
|
|
33
|
+
const uvw = vec3( halfPixelWidth ).add( base.rgb.mul( float( 1.0 ).sub( pixelWidth ) ) );
|
|
34
|
+
|
|
35
|
+
const lutValue = vec4( sampleLut( uvw ).rgb, base.a );
|
|
36
|
+
|
|
37
|
+
return vec4( mix( base, lutValue, this.intensityNode ) );
|
|
38
|
+
|
|
39
|
+
} );
|
|
40
|
+
|
|
41
|
+
const outputNode = lut3D();
|
|
42
|
+
|
|
43
|
+
return outputNode;
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const lut3D = ( node, lut, size, intensity ) => nodeObject( new Lut3DNode( nodeObject( node ), nodeObject( lut ), size, nodeObject( intensity ) ) );
|
|
50
|
+
|
|
51
|
+
addNodeElement( 'lut3D', lut3D );
|
|
52
|
+
|
|
53
|
+
export default Lut3DNode;
|
|
@@ -10,7 +10,7 @@ import { faceDirection } from './FrontFacingNode.js';
|
|
|
10
10
|
import { addNodeClass } from '../core/Node.js';
|
|
11
11
|
import { addNodeElement, tslFn, nodeProxy, vec3 } from '../shadernode/ShaderNode.js';
|
|
12
12
|
|
|
13
|
-
import { TangentSpaceNormalMap, ObjectSpaceNormalMap } from '
|
|
13
|
+
import { TangentSpaceNormalMap, ObjectSpaceNormalMap } from '../../constants.js';
|
|
14
14
|
|
|
15
15
|
// Normal Mapping Without Precomputed Tangents
|
|
16
16
|
// http://www.thetenthplanet.de/archives/1180
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import { addNodeClass } from '../core/Node.js';
|
|
2
|
+
import TempNode from '../core/TempNode.js';
|
|
3
|
+
import { default as TextureNode/*, texture*/ } from '../accessors/TextureNode.js';
|
|
4
|
+
import { NodeUpdateType } from '../core/constants.js';
|
|
5
|
+
import { nodeObject } from '../shadernode/ShaderNode.js';
|
|
6
|
+
import { uniform } from '../core/UniformNode.js';
|
|
7
|
+
import { viewZToOrthographicDepth, perspectiveDepthToViewZ } from './ViewportDepthNode.js';
|
|
8
|
+
|
|
9
|
+
import { HalfFloatType/*, FloatType*/ } from '../../constants.js';
|
|
10
|
+
import { Vector2 } from '../../math/Vector2.js';
|
|
11
|
+
import { DepthTexture } from '../../textures/DepthTexture.js';
|
|
12
|
+
import { RenderTarget } from '../../core/RenderTarget.js';
|
|
13
|
+
|
|
14
|
+
const _size = /*@__PURE__*/ new Vector2();
|
|
15
|
+
|
|
16
|
+
class PassTextureNode extends TextureNode {
|
|
17
|
+
|
|
18
|
+
constructor( passNode, texture ) {
|
|
19
|
+
|
|
20
|
+
super( texture );
|
|
21
|
+
|
|
22
|
+
this.passNode = passNode;
|
|
23
|
+
|
|
24
|
+
this.setUpdateMatrix( false );
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
setup( builder ) {
|
|
29
|
+
|
|
30
|
+
this.passNode.build( builder );
|
|
31
|
+
|
|
32
|
+
return super.setup( builder );
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
clone() {
|
|
37
|
+
|
|
38
|
+
return new this.constructor( this.passNode, this.value );
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
class PassMultipleTextureNode extends PassTextureNode {
|
|
45
|
+
|
|
46
|
+
constructor( passNode, textureName ) {
|
|
47
|
+
|
|
48
|
+
super( passNode, null );
|
|
49
|
+
|
|
50
|
+
this.textureName = textureName;
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
setup( builder ) {
|
|
55
|
+
|
|
56
|
+
this.value = this.passNode.getTexture( this.textureName );
|
|
57
|
+
|
|
58
|
+
return super.setup( builder );
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
clone() {
|
|
63
|
+
|
|
64
|
+
return new this.constructor( this.passNode, this.textureName );
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
class PassNode extends TempNode {
|
|
71
|
+
|
|
72
|
+
constructor( scope, scene, camera, options = {} ) {
|
|
73
|
+
|
|
74
|
+
super( 'vec4' );
|
|
75
|
+
|
|
76
|
+
this.scope = scope;
|
|
77
|
+
this.scene = scene;
|
|
78
|
+
this.camera = camera;
|
|
79
|
+
this.options = options;
|
|
80
|
+
|
|
81
|
+
this._pixelRatio = 1;
|
|
82
|
+
this._width = 1;
|
|
83
|
+
this._height = 1;
|
|
84
|
+
|
|
85
|
+
const depthTexture = new DepthTexture();
|
|
86
|
+
depthTexture.isRenderTargetTexture = true;
|
|
87
|
+
//depthTexture.type = FloatType;
|
|
88
|
+
depthTexture.name = 'depth';
|
|
89
|
+
|
|
90
|
+
const renderTarget = new RenderTarget( this._width * this._pixelRatio, this._height * this._pixelRatio, { type: HalfFloatType, ...options, } );
|
|
91
|
+
renderTarget.texture.name = 'output';
|
|
92
|
+
renderTarget.depthTexture = depthTexture;
|
|
93
|
+
|
|
94
|
+
this.renderTarget = renderTarget;
|
|
95
|
+
|
|
96
|
+
this.updateBeforeType = NodeUpdateType.FRAME;
|
|
97
|
+
|
|
98
|
+
this._textures = {
|
|
99
|
+
output: renderTarget.texture,
|
|
100
|
+
depth: depthTexture
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
this._textureNodes = {};
|
|
104
|
+
this._linearDepthNodes = {};
|
|
105
|
+
this._viewZNodes = {};
|
|
106
|
+
|
|
107
|
+
this._cameraNear = uniform( 0 );
|
|
108
|
+
this._cameraFar = uniform( 0 );
|
|
109
|
+
|
|
110
|
+
this._mrt = null;
|
|
111
|
+
|
|
112
|
+
this.isPassNode = true;
|
|
113
|
+
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
setMRT( mrt ) {
|
|
117
|
+
|
|
118
|
+
this._mrt = mrt;
|
|
119
|
+
|
|
120
|
+
return this;
|
|
121
|
+
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
getMRT() {
|
|
125
|
+
|
|
126
|
+
return this._mrt;
|
|
127
|
+
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
isGlobal() {
|
|
131
|
+
|
|
132
|
+
return true;
|
|
133
|
+
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
getTexture( name ) {
|
|
137
|
+
|
|
138
|
+
let texture = this._textures[ name ];
|
|
139
|
+
|
|
140
|
+
if ( texture === undefined ) {
|
|
141
|
+
|
|
142
|
+
const refTexture = this.renderTarget.texture;
|
|
143
|
+
|
|
144
|
+
texture = refTexture.clone();
|
|
145
|
+
texture.isRenderTargetTexture = true;
|
|
146
|
+
texture.name = name;
|
|
147
|
+
|
|
148
|
+
this._textures[ name ] = texture;
|
|
149
|
+
|
|
150
|
+
this.renderTarget.textures.push( texture );
|
|
151
|
+
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return texture;
|
|
155
|
+
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
getTextureNode( name = 'output' ) {
|
|
159
|
+
|
|
160
|
+
let textureNode = this._textureNodes[ name ];
|
|
161
|
+
|
|
162
|
+
if ( textureNode === undefined ) {
|
|
163
|
+
|
|
164
|
+
this._textureNodes[ name ] = textureNode = nodeObject( new PassMultipleTextureNode( this, name ) );
|
|
165
|
+
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return textureNode;
|
|
169
|
+
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
getViewZNode( name = 'depth' ) {
|
|
173
|
+
|
|
174
|
+
let viewZNode = this._viewZNodes[ name ];
|
|
175
|
+
|
|
176
|
+
if ( viewZNode === undefined ) {
|
|
177
|
+
|
|
178
|
+
const cameraNear = this._cameraNear;
|
|
179
|
+
const cameraFar = this._cameraFar;
|
|
180
|
+
|
|
181
|
+
this._viewZNodes[ name ] = viewZNode = perspectiveDepthToViewZ( this.getTextureNode( name ), cameraNear, cameraFar );
|
|
182
|
+
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return viewZNode;
|
|
186
|
+
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
getLinearDepthNode( name = 'depth' ) {
|
|
190
|
+
|
|
191
|
+
let linearDepthNode = this._linearDepthNodes[ name ];
|
|
192
|
+
|
|
193
|
+
if ( linearDepthNode === undefined ) {
|
|
194
|
+
|
|
195
|
+
const cameraNear = this._cameraNear;
|
|
196
|
+
const cameraFar = this._cameraFar;
|
|
197
|
+
const viewZNode = this.getViewZNode( name );
|
|
198
|
+
|
|
199
|
+
// TODO: just if ( builder.camera.isPerspectiveCamera )
|
|
200
|
+
|
|
201
|
+
this._linearDepthNodes[ name ] = linearDepthNode = viewZToOrthographicDepth( viewZNode, cameraNear, cameraFar );
|
|
202
|
+
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return linearDepthNode;
|
|
206
|
+
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
setup( { renderer } ) {
|
|
210
|
+
|
|
211
|
+
this.renderTarget.samples = this.options.samples === undefined ? renderer.samples : this.options.samples;
|
|
212
|
+
|
|
213
|
+
// Disable MSAA for WebGL backend for now
|
|
214
|
+
if ( renderer.backend.isWebGLBackend === true ) {
|
|
215
|
+
|
|
216
|
+
this.renderTarget.samples = 0;
|
|
217
|
+
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
this.renderTarget.depthTexture.isMultisampleRenderTargetTexture = this.renderTarget.samples > 1;
|
|
221
|
+
|
|
222
|
+
return this.scope === PassNode.COLOR ? this.getTextureNode() : this.getLinearDepthNode();
|
|
223
|
+
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
updateBefore( frame ) {
|
|
227
|
+
|
|
228
|
+
const { renderer } = frame;
|
|
229
|
+
const { scene, camera } = this;
|
|
230
|
+
|
|
231
|
+
this._pixelRatio = renderer.getPixelRatio();
|
|
232
|
+
|
|
233
|
+
const size = renderer.getSize( _size );
|
|
234
|
+
|
|
235
|
+
this.setSize( size.width, size.height );
|
|
236
|
+
|
|
237
|
+
const currentRenderTarget = renderer.getRenderTarget();
|
|
238
|
+
const currentMRT = renderer.getMRT();
|
|
239
|
+
|
|
240
|
+
this._cameraNear.value = camera.near;
|
|
241
|
+
this._cameraFar.value = camera.far;
|
|
242
|
+
|
|
243
|
+
renderer.setRenderTarget( this.renderTarget );
|
|
244
|
+
renderer.setMRT( this._mrt );
|
|
245
|
+
|
|
246
|
+
renderer.render( scene, camera );
|
|
247
|
+
|
|
248
|
+
renderer.setRenderTarget( currentRenderTarget );
|
|
249
|
+
renderer.setMRT( currentMRT );
|
|
250
|
+
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
setSize( width, height ) {
|
|
254
|
+
|
|
255
|
+
this._width = width;
|
|
256
|
+
this._height = height;
|
|
257
|
+
|
|
258
|
+
const effectiveWidth = this._width * this._pixelRatio;
|
|
259
|
+
const effectiveHeight = this._height * this._pixelRatio;
|
|
260
|
+
|
|
261
|
+
this.renderTarget.setSize( effectiveWidth, effectiveHeight );
|
|
262
|
+
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
setPixelRatio( pixelRatio ) {
|
|
266
|
+
|
|
267
|
+
this._pixelRatio = pixelRatio;
|
|
268
|
+
|
|
269
|
+
this.setSize( this._width, this._height );
|
|
270
|
+
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
dispose() {
|
|
274
|
+
|
|
275
|
+
this.renderTarget.dispose();
|
|
276
|
+
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
PassNode.COLOR = 'color';
|
|
283
|
+
PassNode.DEPTH = 'depth';
|
|
284
|
+
|
|
285
|
+
export default PassNode;
|
|
286
|
+
|
|
287
|
+
export const pass = ( scene, camera, options ) => nodeObject( new PassNode( PassNode.COLOR, scene, camera, options ) );
|
|
288
|
+
export const passTexture = ( pass, texture ) => nodeObject( new PassTextureNode( pass, texture ) );
|
|
289
|
+
export const depthPass = ( scene, camera ) => nodeObject( new PassNode( PassNode.DEPTH, scene, camera ) );
|
|
290
|
+
|
|
291
|
+
addNodeClass( 'PassNode', PassNode );
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import TempNode from '../core/TempNode.js';
|
|
2
|
+
import { uv } from '../accessors/UVNode.js';
|
|
3
|
+
import { addNodeElement, tslFn, nodeObject, vec2, vec3, float, If } from '../shadernode/ShaderNode.js';
|
|
4
|
+
import { NodeUpdateType } from '../core/constants.js';
|
|
5
|
+
import { uniform } from '../core/UniformNode.js';
|
|
6
|
+
import { dot, clamp, smoothstep, sign, step, floor } from '../math/MathNode.js';
|
|
7
|
+
import { Vector4 } from '../../math/Vector4.js';
|
|
8
|
+
import { output, property } from '../core/PropertyNode.js';
|
|
9
|
+
import PassNode from './PassNode.js';
|
|
10
|
+
import { mrt } from '../core/MRTNode.js';
|
|
11
|
+
import { normalView } from '../accessors/NormalNode.js';
|
|
12
|
+
import { NearestFilter } from '../../constants.js';
|
|
13
|
+
|
|
14
|
+
class PixelationNode extends TempNode {
|
|
15
|
+
|
|
16
|
+
constructor( textureNode, depthNode, normalNode, pixelSize, normalEdgeStrength, depthEdgeStrength ) {
|
|
17
|
+
|
|
18
|
+
super();
|
|
19
|
+
|
|
20
|
+
// Input textures
|
|
21
|
+
|
|
22
|
+
this.textureNode = textureNode;
|
|
23
|
+
this.depthNode = depthNode;
|
|
24
|
+
this.normalNode = normalNode;
|
|
25
|
+
|
|
26
|
+
// Input uniforms
|
|
27
|
+
|
|
28
|
+
this.pixelSize = pixelSize;
|
|
29
|
+
this.normalEdgeStrength = normalEdgeStrength;
|
|
30
|
+
this.depthEdgeStrength = depthEdgeStrength;
|
|
31
|
+
|
|
32
|
+
// Private uniforms
|
|
33
|
+
|
|
34
|
+
this._resolution = uniform( new Vector4() );
|
|
35
|
+
|
|
36
|
+
this.updateBeforeType = NodeUpdateType.RENDER;
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
updateBefore() {
|
|
41
|
+
|
|
42
|
+
const map = this.textureNode.value;
|
|
43
|
+
|
|
44
|
+
const width = map.image.width;
|
|
45
|
+
const height = map.image.height;
|
|
46
|
+
|
|
47
|
+
this._resolution.value.set( width, height, 1 / width, 1 / height );
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
setup() {
|
|
52
|
+
|
|
53
|
+
const { textureNode, depthNode, normalNode } = this;
|
|
54
|
+
|
|
55
|
+
const uvNodeTexture = textureNode.uvNode || uv();
|
|
56
|
+
const uvNodeDepth = depthNode.uvNode || uv();
|
|
57
|
+
const uvNodeNormal = normalNode.uvNode || uv();
|
|
58
|
+
|
|
59
|
+
const sampleTexture = () => textureNode.uv( uvNodeTexture );
|
|
60
|
+
|
|
61
|
+
const sampleDepth = ( x, y ) => depthNode.uv( uvNodeDepth.add( vec2( x, y ).mul( this._resolution.zw ) ) ).r;
|
|
62
|
+
|
|
63
|
+
const sampleNormal = ( x, y ) => normalNode.uv( uvNodeNormal.add( vec2( x, y ).mul( this._resolution.zw ) ) ).rgb.normalize();
|
|
64
|
+
|
|
65
|
+
const depthEdgeIndicator = ( depth ) => {
|
|
66
|
+
|
|
67
|
+
const diff = property( 'float', 'diff' );
|
|
68
|
+
diff.addAssign( clamp( sampleDepth( 1, 0 ).sub( depth ) ) );
|
|
69
|
+
diff.addAssign( clamp( sampleDepth( - 1, 0 ).sub( depth ) ) );
|
|
70
|
+
diff.addAssign( clamp( sampleDepth( 0, 1 ).sub( depth ) ) );
|
|
71
|
+
diff.addAssign( clamp( sampleDepth( 0, - 1 ).sub( depth ) ) );
|
|
72
|
+
|
|
73
|
+
return floor( smoothstep( 0.01, 0.02, diff ).mul( 2 ) ).div( 2 );
|
|
74
|
+
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const neighborNormalEdgeIndicator = ( x, y, depth, normal ) => {
|
|
78
|
+
|
|
79
|
+
const depthDiff = sampleDepth( x, y ).sub( depth );
|
|
80
|
+
const neighborNormal = sampleNormal( x, y );
|
|
81
|
+
|
|
82
|
+
// Edge pixels should yield to faces who's normals are closer to the bias normal.
|
|
83
|
+
|
|
84
|
+
const normalEdgeBias = vec3( 1, 1, 1 ); // This should probably be a parameter.
|
|
85
|
+
const normalDiff = dot( normal.sub( neighborNormal ), normalEdgeBias );
|
|
86
|
+
const normalIndicator = clamp( smoothstep( - 0.01, 0.01, normalDiff ), 0.0, 1.0 );
|
|
87
|
+
|
|
88
|
+
// Only the shallower pixel should detect the normal edge.
|
|
89
|
+
|
|
90
|
+
const depthIndicator = clamp( sign( depthDiff.mul( .25 ).add( .0025 ) ), 0.0, 1.0 );
|
|
91
|
+
|
|
92
|
+
return float( 1.0 ).sub( dot( normal, neighborNormal ) ).mul( depthIndicator ).mul( normalIndicator );
|
|
93
|
+
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const normalEdgeIndicator = ( depth, normal ) => {
|
|
97
|
+
|
|
98
|
+
const indicator = property( 'float', 'indicator' );
|
|
99
|
+
|
|
100
|
+
indicator.addAssign( neighborNormalEdgeIndicator( 0, - 1, depth, normal ) );
|
|
101
|
+
indicator.addAssign( neighborNormalEdgeIndicator( 0, 1, depth, normal ) );
|
|
102
|
+
indicator.addAssign( neighborNormalEdgeIndicator( - 1, 0, depth, normal ) );
|
|
103
|
+
indicator.addAssign( neighborNormalEdgeIndicator( 1, 0, depth, normal ) );
|
|
104
|
+
|
|
105
|
+
return step( 0.1, indicator );
|
|
106
|
+
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const pixelation = tslFn( () => {
|
|
110
|
+
|
|
111
|
+
const texel = sampleTexture();
|
|
112
|
+
|
|
113
|
+
const depth = property( 'float', 'depth' );
|
|
114
|
+
const normal = property( 'vec3', 'normal' );
|
|
115
|
+
|
|
116
|
+
If( this.depthEdgeStrength.greaterThan( 0.0 ).or( this.normalEdgeStrength.greaterThan( 0.0 ) ), () => {
|
|
117
|
+
|
|
118
|
+
depth.assign( sampleDepth( 0, 0 ) );
|
|
119
|
+
normal.assign( sampleNormal( 0, 0 ) );
|
|
120
|
+
|
|
121
|
+
} );
|
|
122
|
+
|
|
123
|
+
const dei = property( 'float', 'dei' );
|
|
124
|
+
|
|
125
|
+
If( this.depthEdgeStrength.greaterThan( 0.0 ), () => {
|
|
126
|
+
|
|
127
|
+
dei.assign( depthEdgeIndicator( depth ) );
|
|
128
|
+
|
|
129
|
+
} );
|
|
130
|
+
|
|
131
|
+
const nei = property( 'float', 'nei' );
|
|
132
|
+
|
|
133
|
+
If( this.normalEdgeStrength.greaterThan( 0.0 ), () => {
|
|
134
|
+
|
|
135
|
+
nei.assign( normalEdgeIndicator( depth, normal ) );
|
|
136
|
+
|
|
137
|
+
} );
|
|
138
|
+
|
|
139
|
+
const strength = dei.greaterThan( 0 ).cond( float( 1.0 ).sub( dei.mul( this.depthEdgeStrength ) ), nei.mul( this.normalEdgeStrength ).add( 1 ) );
|
|
140
|
+
|
|
141
|
+
return texel.mul( strength );
|
|
142
|
+
|
|
143
|
+
} );
|
|
144
|
+
|
|
145
|
+
const outputNode = pixelation();
|
|
146
|
+
|
|
147
|
+
return outputNode;
|
|
148
|
+
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const pixelation = ( node, depthNode, normalNode, pixelSize = 6, normalEdgeStrength = 0.3, depthEdgeStrength = 0.4 ) => nodeObject( new PixelationNode( nodeObject( node ).toTexture(), nodeObject( depthNode ).toTexture(), nodeObject( normalNode ).toTexture(), nodeObject( pixelSize ), nodeObject( normalEdgeStrength ), nodeObject( depthEdgeStrength ) ) );
|
|
154
|
+
|
|
155
|
+
addNodeElement( 'pixelation', pixelation );
|
|
156
|
+
|
|
157
|
+
class PixelationPassNode extends PassNode {
|
|
158
|
+
|
|
159
|
+
constructor( scene, camera, pixelSize = 6, normalEdgeStrength = 0.3, depthEdgeStrength = 0.4 ) {
|
|
160
|
+
|
|
161
|
+
super( 'color', scene, camera, { minFilter: NearestFilter, magFilter: NearestFilter } );
|
|
162
|
+
|
|
163
|
+
this.pixelSize = pixelSize;
|
|
164
|
+
this.normalEdgeStrength = normalEdgeStrength;
|
|
165
|
+
this.depthEdgeStrength = depthEdgeStrength;
|
|
166
|
+
|
|
167
|
+
this.isPixelationPassNode = true;
|
|
168
|
+
|
|
169
|
+
this._mrt = mrt( {
|
|
170
|
+
output: output,
|
|
171
|
+
normal: normalView
|
|
172
|
+
} );
|
|
173
|
+
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
setSize( width, height ) {
|
|
177
|
+
|
|
178
|
+
const pixelSize = this.pixelSize.value ? this.pixelSize.value : this.pixelSize;
|
|
179
|
+
|
|
180
|
+
const adjustedWidth = Math.floor( width / pixelSize );
|
|
181
|
+
const adjustedHeight = Math.floor( height / pixelSize );
|
|
182
|
+
|
|
183
|
+
super.setSize( adjustedWidth, adjustedHeight );
|
|
184
|
+
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
setup() {
|
|
188
|
+
|
|
189
|
+
const color = super.getTextureNode( 'output' );
|
|
190
|
+
const depth = super.getTextureNode( 'depth' );
|
|
191
|
+
const normal = super.getTextureNode( 'normal' );
|
|
192
|
+
|
|
193
|
+
return pixelation( color, depth, normal, this.pixelSize, this.normalEdgeStrength, this.depthEdgeStrength );
|
|
194
|
+
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export const pixelationPass = ( scene, camera, pixelSize, normalEdgeStrength, depthEdgeStrength ) => nodeObject( new PixelationPassNode( scene, camera, pixelSize, normalEdgeStrength, depthEdgeStrength ) );
|
|
200
|
+
|
|
201
|
+
export default PixelationPassNode;
|