@plastic-software/three 0.181.3 → 0.183.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/LICENSE +1 -1
- package/README.md +3 -4
- package/build/three.cjs +11330 -10017
- package/build/three.core.js +10011 -9493
- package/build/three.core.min.js +2 -2
- package/build/three.module.js +1414 -631
- package/build/three.module.min.js +2 -2
- package/build/three.tsl.js +21 -13
- package/build/three.tsl.min.js +2 -2
- package/build/three.webgpu.js +8007 -5427
- package/build/three.webgpu.min.js +2 -2
- package/build/three.webgpu.nodes.js +8005 -5426
- package/build/three.webgpu.nodes.min.js +2 -2
- package/examples/jsm/Addons.js +0 -3
- package/examples/jsm/animation/CCDIKSolver.js +2 -2
- package/examples/jsm/controls/ArcballControls.js +3 -3
- package/examples/jsm/controls/MapControls.js +55 -1
- package/examples/jsm/controls/OrbitControls.js +109 -6
- package/examples/jsm/controls/TrackballControls.js +6 -6
- package/examples/jsm/csm/CSM.js +2 -1
- package/examples/jsm/effects/AnaglyphEffect.js +102 -7
- package/examples/jsm/environments/ColorEnvironment.js +59 -0
- package/examples/jsm/environments/RoomEnvironment.js +3 -0
- package/examples/jsm/exporters/EXRExporter.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +131 -4
- package/examples/jsm/exporters/USDZExporter.js +22 -3
- package/examples/jsm/geometries/DecalGeometry.js +1 -1
- package/examples/jsm/helpers/AnimationPathHelper.js +302 -0
- package/examples/jsm/helpers/LightProbeHelperGPU.js +1 -1
- package/examples/jsm/helpers/TextureHelperGPU.js +1 -1
- package/examples/jsm/helpers/ViewHelper.js +67 -8
- package/examples/jsm/inspector/Inspector.js +74 -14
- package/examples/jsm/inspector/RendererInspector.js +12 -2
- package/examples/jsm/inspector/tabs/Console.js +41 -7
- package/examples/jsm/inspector/tabs/Parameters.js +18 -2
- package/examples/jsm/inspector/tabs/Performance.js +2 -2
- package/examples/jsm/inspector/tabs/Viewer.js +4 -4
- package/examples/jsm/inspector/ui/Profiler.js +1836 -31
- package/examples/jsm/inspector/ui/Style.js +973 -14
- package/examples/jsm/inspector/ui/Tab.js +188 -1
- package/examples/jsm/inspector/ui/Values.js +17 -1
- package/examples/jsm/libs/meshopt_decoder.module.js +6 -5
- package/examples/jsm/lines/LineMaterial.js +6 -0
- package/examples/jsm/loaders/3DMLoader.js +5 -4
- package/examples/jsm/loaders/3MFLoader.js +2 -2
- package/examples/jsm/loaders/AMFLoader.js +2 -2
- package/examples/jsm/loaders/ColladaLoader.js +24 -4026
- package/examples/jsm/loaders/DRACOLoader.js +5 -5
- package/examples/jsm/loaders/EXRLoader.js +5 -5
- package/examples/jsm/loaders/FBXLoader.js +2 -4
- package/examples/jsm/loaders/GCodeLoader.js +34 -8
- package/examples/jsm/loaders/GLTFLoader.js +122 -171
- package/examples/jsm/loaders/HDRLoader.js +0 -1
- package/examples/jsm/loaders/KMZLoader.js +5 -5
- package/examples/jsm/loaders/KTX2Loader.js +19 -3
- package/examples/jsm/loaders/LDrawLoader.js +2 -3
- package/examples/jsm/loaders/LWOLoader.js +7 -39
- package/examples/jsm/loaders/NRRDLoader.js +2 -2
- package/examples/jsm/loaders/PCDLoader.js +4 -2
- package/examples/jsm/loaders/SVGLoader.js +1 -1
- package/examples/jsm/loaders/TDSLoader.js +0 -2
- package/examples/jsm/loaders/TGALoader.js +0 -2
- package/examples/jsm/loaders/USDLoader.js +100 -40
- package/examples/jsm/loaders/UltraHDRLoader.js +285 -160
- package/examples/jsm/loaders/VOXLoader.js +660 -117
- package/examples/jsm/loaders/VRMLLoader.js +79 -2
- package/examples/jsm/loaders/VTKLoader.js +37 -24
- package/examples/jsm/loaders/collada/ColladaComposer.js +2950 -0
- package/examples/jsm/loaders/collada/ColladaParser.js +1962 -0
- package/examples/jsm/loaders/usd/USDAParser.js +447 -366
- package/examples/jsm/loaders/usd/USDCParser.js +1841 -6
- package/examples/jsm/loaders/usd/USDComposer.js +4041 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +2 -2
- package/examples/jsm/materials/WoodNodeMaterial.js +11 -11
- package/examples/jsm/math/Octree.js +131 -1
- package/examples/jsm/misc/Volume.js +0 -1
- package/examples/jsm/misc/VolumeSlice.js +0 -1
- package/examples/jsm/objects/LensflareMesh.js +1 -1
- package/examples/jsm/objects/Sky.js +76 -4
- package/examples/jsm/objects/SkyMesh.js +127 -10
- package/examples/jsm/objects/Water.js +4 -3
- package/examples/jsm/objects/Water2.js +5 -3
- package/examples/jsm/objects/WaterMesh.js +5 -7
- package/examples/jsm/physics/AmmoPhysics.js +12 -7
- package/examples/jsm/physics/JoltPhysics.js +10 -6
- package/examples/jsm/physics/RapierPhysics.js +9 -5
- package/examples/jsm/postprocessing/EffectComposer.js +7 -5
- package/examples/jsm/postprocessing/OutputPass.js +9 -0
- package/examples/jsm/postprocessing/RenderPass.js +10 -0
- package/examples/jsm/postprocessing/RenderTransitionPass.js +1 -1
- package/examples/jsm/postprocessing/UnrealBloomPass.js +48 -18
- package/examples/jsm/renderers/CSS3DRenderer.js +1 -1
- package/examples/jsm/renderers/Projector.js +268 -30
- package/examples/jsm/renderers/SVGRenderer.js +193 -60
- package/examples/jsm/shaders/GTAOShader.js +19 -6
- package/examples/jsm/shaders/HalftoneShader.js +12 -1
- package/examples/jsm/shaders/PoissonDenoiseShader.js +6 -2
- package/examples/jsm/shaders/SAOShader.js +17 -4
- package/examples/jsm/shaders/SSAOShader.js +11 -1
- package/examples/jsm/shaders/SSRShader.js +6 -5
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +2 -4
- package/examples/jsm/shaders/VignetteShader.js +1 -1
- package/examples/jsm/transpiler/AST.js +44 -0
- package/examples/jsm/transpiler/GLSLDecoder.js +61 -4
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -0
- package/examples/jsm/transpiler/TSLEncoder.js +46 -3
- package/examples/jsm/transpiler/TranspilerUtils.js +3 -3
- package/examples/jsm/transpiler/WGSLEncoder.js +27 -0
- package/examples/jsm/tsl/display/AfterImageNode.js +1 -1
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +458 -16
- package/examples/jsm/tsl/display/AnamorphicNode.js +1 -1
- package/examples/jsm/tsl/display/BilateralBlurNode.js +364 -0
- package/examples/jsm/tsl/display/BloomNode.js +16 -6
- package/examples/jsm/tsl/display/CRT.js +150 -0
- package/examples/jsm/tsl/display/DenoiseNode.js +1 -1
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +1 -1
- package/examples/jsm/tsl/display/DotScreenNode.js +1 -1
- package/examples/jsm/tsl/display/FXAANode.js +2 -2
- package/examples/jsm/tsl/display/GTAONode.js +5 -4
- package/examples/jsm/tsl/display/GaussianBlurNode.js +11 -2
- package/examples/jsm/tsl/display/GodraysNode.js +624 -0
- package/examples/jsm/tsl/display/LensflareNode.js +1 -1
- package/examples/jsm/tsl/display/Lut3DNode.js +1 -1
- package/examples/jsm/tsl/display/OutlineNode.js +3 -3
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +2 -2
- package/examples/jsm/tsl/display/PixelationPassNode.js +7 -6
- package/examples/jsm/tsl/display/RGBShiftNode.js +2 -2
- package/examples/jsm/tsl/display/RetroPassNode.js +263 -0
- package/examples/jsm/tsl/display/SMAANode.js +2 -2
- package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
- package/examples/jsm/tsl/display/SSGINode.js +8 -20
- package/examples/jsm/tsl/display/SSRNode.js +8 -8
- package/examples/jsm/tsl/display/SSSNode.js +6 -4
- package/examples/jsm/tsl/display/Shape.js +29 -0
- package/examples/jsm/tsl/display/SobelOperatorNode.js +2 -2
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +8 -1
- package/examples/jsm/tsl/display/StereoPassNode.js +1 -2
- package/examples/jsm/tsl/display/TRAANode.js +273 -125
- package/examples/jsm/tsl/display/TransitionNode.js +1 -1
- package/examples/jsm/tsl/display/depthAwareBlend.js +80 -0
- package/examples/jsm/tsl/display/radialBlur.js +68 -0
- package/examples/jsm/tsl/math/Bayer.js +40 -1
- package/examples/jsm/utils/LDrawUtils.js +1 -1
- package/examples/jsm/utils/ShadowMapViewer.js +24 -10
- package/examples/jsm/utils/ShadowMapViewerGPU.js +1 -1
- package/examples/jsm/utils/WebGPUTextureUtils.js +1 -1
- package/package.json +20 -26
- package/src/Three.Core.js +2 -1
- package/src/Three.TSL.js +19 -11
- package/src/Three.WebGPU.Nodes.js +2 -0
- package/src/Three.WebGPU.js +3 -0
- package/src/Three.js +1 -0
- package/src/animation/AnimationAction.js +1 -1
- package/src/animation/AnimationClip.js +1 -1
- package/src/animation/AnimationMixer.js +6 -0
- package/src/animation/AnimationUtils.js +1 -12
- package/src/animation/KeyframeTrack.js +47 -8
- package/src/animation/PropertyMixer.js +4 -4
- package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
- package/src/animation/tracks/ColorKeyframeTrack.js +1 -1
- package/src/animation/tracks/NumberKeyframeTrack.js +1 -1
- package/src/animation/tracks/QuaternionKeyframeTrack.js +1 -1
- package/src/animation/tracks/StringKeyframeTrack.js +1 -1
- package/src/animation/tracks/VectorKeyframeTrack.js +1 -1
- package/src/audio/Audio.js +1 -1
- package/src/audio/AudioListener.js +5 -3
- package/src/cameras/Camera.js +32 -2
- package/src/cameras/CubeCamera.js +20 -0
- package/src/constants.js +90 -5
- package/src/core/BufferGeometry.js +14 -2
- package/src/core/Clock.js +7 -0
- package/src/core/Object3D.js +56 -4
- package/src/core/Raycaster.js +2 -2
- package/src/core/RenderTarget.js +3 -4
- package/src/extras/PMREMGenerator.js +7 -18
- package/src/extras/TextureUtils.js +5 -1
- package/src/geometries/ExtrudeGeometry.js +2 -2
- package/src/geometries/PolyhedronGeometry.js +1 -1
- package/src/geometries/TorusGeometry.js +8 -3
- package/src/helpers/CameraHelper.js +3 -0
- package/src/helpers/DirectionalLightHelper.js +4 -1
- package/src/helpers/HemisphereLightHelper.js +3 -0
- package/src/helpers/PointLightHelper.js +1 -25
- package/src/helpers/SpotLightHelper.js +3 -0
- package/src/lights/DirectionalLight.js +13 -0
- package/src/lights/HemisphereLight.js +10 -0
- package/src/lights/Light.js +1 -11
- package/src/lights/LightProbe.js +0 -15
- package/src/lights/LightShadow.js +15 -6
- package/src/lights/PointLight.js +15 -0
- package/src/lights/PointLightShadow.js +0 -86
- package/src/lights/SpotLight.js +22 -1
- package/src/lights/webgpu/IESSpotLight.js +2 -1
- package/src/loaders/Cache.js +28 -0
- package/src/loaders/FileLoader.js +1 -1
- package/src/loaders/ImageBitmapLoader.js +8 -3
- package/src/loaders/Loader.js +6 -0
- package/src/loaders/MaterialLoader.js +2 -1
- package/src/loaders/ObjectLoader.js +21 -2
- package/src/loaders/nodes/NodeLoader.js +2 -2
- package/src/materials/Material.js +2 -0
- package/src/materials/MeshLambertMaterial.js +9 -0
- package/src/materials/MeshPhongMaterial.js +9 -0
- package/src/materials/ShaderMaterial.js +20 -1
- package/src/materials/nodes/Line2NodeMaterial.js +7 -7
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +5 -2
- package/src/materials/nodes/MeshStandardNodeMaterial.js +5 -4
- package/src/materials/nodes/NodeMaterial.js +72 -25
- package/src/materials/nodes/manager/NodeMaterialObserver.js +10 -4
- package/src/math/Line3.js +3 -5
- package/src/math/MathUtils.js +10 -10
- package/src/math/Matrix4.js +74 -65
- package/src/math/Quaternion.js +3 -29
- package/src/math/Sphere.js +1 -1
- package/src/math/Vector3.js +3 -5
- package/src/math/interpolants/BezierInterpolant.js +108 -0
- package/src/nodes/Nodes.js +87 -68
- package/src/nodes/TSL.js +6 -6
- package/src/nodes/accessors/Arrays.js +1 -1
- package/src/nodes/accessors/BatchNode.js +10 -10
- package/src/nodes/accessors/Bitangent.js +5 -5
- package/src/nodes/accessors/BufferAttributeNode.js +98 -12
- package/src/nodes/accessors/BufferNode.js +29 -2
- package/src/nodes/accessors/Camera.js +149 -28
- package/src/nodes/accessors/ClippingNode.js +4 -4
- package/src/nodes/accessors/CubeTextureNode.js +20 -1
- package/src/nodes/accessors/InstanceNode.js +148 -43
- package/src/nodes/accessors/MaterialNode.js +9 -1
- package/src/nodes/accessors/MaterialReferenceNode.js +1 -2
- package/src/nodes/accessors/ModelNode.js +1 -1
- package/src/nodes/accessors/Normal.js +11 -11
- package/src/nodes/accessors/Position.js +34 -2
- package/src/nodes/accessors/ReferenceBaseNode.js +4 -4
- package/src/nodes/accessors/ReferenceNode.js +4 -4
- package/src/nodes/accessors/RendererReferenceNode.js +1 -2
- package/src/nodes/accessors/SceneProperties.js +53 -0
- package/src/nodes/accessors/SkinningNode.js +27 -26
- package/src/nodes/accessors/StorageBufferNode.js +4 -21
- package/src/nodes/accessors/StorageTextureNode.js +37 -1
- package/src/nodes/accessors/Tangent.js +4 -14
- package/src/nodes/accessors/Texture3DNode.js +32 -35
- package/src/nodes/accessors/TextureNode.js +58 -22
- package/src/nodes/accessors/UniformArrayNode.js +4 -2
- package/src/nodes/accessors/UserDataNode.js +1 -2
- package/src/nodes/accessors/VertexColorNode.js +1 -2
- package/src/nodes/code/FunctionNode.js +1 -2
- package/src/nodes/core/ArrayNode.js +20 -1
- package/src/nodes/core/AssignNode.js +2 -2
- package/src/nodes/core/AttributeNode.js +2 -2
- package/src/nodes/core/ContextNode.js +103 -4
- package/src/nodes/core/MRTNode.js +48 -2
- package/src/nodes/core/Node.js +29 -3
- package/src/nodes/core/NodeBuilder.js +170 -53
- package/src/nodes/core/NodeError.js +28 -0
- package/src/nodes/core/NodeFrame.js +12 -4
- package/src/nodes/core/NodeUtils.js +10 -8
- package/src/nodes/core/OutputStructNode.js +12 -10
- package/src/nodes/core/ParameterNode.js +3 -3
- package/src/nodes/core/PropertyNode.js +19 -3
- package/src/nodes/core/StackNode.js +65 -16
- package/src/nodes/core/StackTrace.js +139 -0
- package/src/nodes/core/StructNode.js +16 -2
- package/src/nodes/core/StructTypeNode.js +11 -17
- package/src/nodes/core/SubBuildNode.js +1 -1
- package/src/nodes/core/UniformNode.js +21 -5
- package/src/nodes/core/VarNode.js +47 -22
- package/src/nodes/core/VaryingNode.js +1 -18
- package/src/nodes/display/BlendModes.js +0 -64
- package/src/nodes/display/ColorAdjustment.js +17 -0
- package/src/nodes/display/ColorSpaceNode.js +3 -3
- package/src/nodes/display/NormalMapNode.js +39 -4
- package/src/nodes/display/PassNode.js +98 -9
- package/src/nodes/display/RenderOutputNode.js +3 -3
- package/src/nodes/display/ScreenNode.js +3 -1
- package/src/nodes/display/ToneMappingNode.js +1 -1
- package/src/nodes/display/ToonOutlinePassNode.js +2 -2
- package/src/nodes/display/ViewportDepthNode.js +52 -4
- package/src/nodes/display/ViewportTextureNode.js +21 -4
- package/src/nodes/fog/Fog.js +18 -35
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +3 -3
- package/src/nodes/functions/BSDF/DFGLUT.js +56 -0
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +1 -1
- package/src/nodes/functions/PhysicalLightingModel.js +126 -45
- package/src/nodes/geometry/RangeNode.js +4 -2
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -2
- package/src/nodes/gpgpu/ComputeNode.js +5 -4
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +1 -1
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +4 -4
- package/src/nodes/lighting/AnalyticLightNode.js +53 -0
- package/src/nodes/lighting/EnvironmentNode.js +28 -3
- package/src/nodes/lighting/LightsNode.js +2 -2
- package/src/nodes/lighting/PointShadowNode.js +162 -149
- package/src/nodes/lighting/ShadowFilterNode.js +53 -65
- package/src/nodes/lighting/ShadowNode.js +97 -41
- package/src/nodes/math/BitcountNode.js +433 -0
- package/src/nodes/math/ConditionalNode.js +2 -2
- package/src/nodes/math/MathNode.js +3 -40
- package/src/nodes/math/OperatorNode.js +2 -1
- package/src/nodes/math/PackFloatNode.js +98 -0
- package/src/nodes/math/UnpackFloatNode.js +96 -0
- package/src/nodes/pmrem/PMREMNode.js +1 -1
- package/src/nodes/pmrem/PMREMUtils.js +9 -15
- package/src/nodes/tsl/TSLCore.js +17 -14
- package/src/nodes/utils/ArrayElementNode.js +13 -0
- package/src/nodes/utils/DebugNode.js +11 -11
- package/src/nodes/utils/EventNode.js +1 -2
- package/src/nodes/utils/JoinNode.js +2 -2
- package/src/nodes/utils/LoopNode.js +1 -1
- package/src/nodes/utils/MemberNode.js +1 -1
- package/src/nodes/utils/Packing.js +13 -1
- package/src/nodes/utils/PostProcessingUtils.js +33 -1
- package/src/nodes/utils/RTTNode.js +1 -1
- package/src/nodes/utils/ReflectorNode.js +3 -4
- package/src/nodes/utils/SampleNode.js +1 -1
- package/src/nodes/utils/SpriteSheetUV.js +35 -0
- package/src/nodes/utils/UVUtils.js +28 -0
- package/src/objects/BatchedMesh.js +27 -14
- package/src/objects/InstancedMesh.js +11 -0
- package/src/objects/Line.js +1 -1
- package/src/objects/Mesh.js +1 -1
- package/src/objects/Points.js +1 -1
- package/src/objects/Skeleton.js +9 -0
- package/src/renderers/WebGLRenderer.js +178 -92
- package/src/renderers/common/Backend.js +29 -0
- package/src/renderers/common/Background.js +24 -11
- package/src/renderers/common/BindGroup.js +1 -9
- package/src/renderers/common/Binding.js +11 -0
- package/src/renderers/common/Bindings.js +27 -12
- package/src/renderers/common/BlendMode.js +143 -0
- package/src/renderers/common/Buffer.js +40 -0
- package/src/renderers/common/BundleGroup.js +1 -1
- package/src/renderers/common/ChainMap.js +30 -6
- package/src/renderers/common/CubeRenderTarget.js +50 -6
- package/src/renderers/common/Geometries.js +29 -3
- package/src/renderers/common/Lighting.js +5 -21
- package/src/renderers/common/Pipelines.js +4 -4
- package/src/renderers/common/PostProcessing.js +8 -206
- package/src/renderers/common/RenderBundles.js +2 -1
- package/src/renderers/common/RenderContext.js +16 -0
- package/src/renderers/common/RenderContexts.js +33 -49
- package/src/renderers/common/RenderLists.js +2 -1
- package/src/renderers/common/RenderObject.js +15 -3
- package/src/renderers/common/RenderObjectPipeline.js +40 -0
- package/src/renderers/common/RenderObjects.js +18 -2
- package/src/renderers/common/RenderPipeline.js +203 -17
- package/src/renderers/common/Renderer.js +257 -72
- package/src/renderers/common/Sampler.js +4 -4
- package/src/renderers/common/StorageBuffer.js +13 -1
- package/src/renderers/common/Textures.js +17 -1
- package/src/renderers/common/TimestampQueryPool.js +5 -3
- package/src/renderers/common/Uniform.js +8 -0
- package/src/renderers/common/UniformsGroup.js +61 -0
- package/src/renderers/common/XRManager.js +3 -2
- package/src/renderers/common/extras/PMREMGenerator.js +2 -8
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/{Nodes.js → NodeManager.js} +18 -6
- package/src/renderers/common/nodes/NodeStorageBuffer.js +13 -2
- package/src/renderers/common/nodes/NodeUniformBuffer.js +52 -0
- package/src/renderers/shaders/DFGLUTData.js +19 -34
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +8 -10
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +7 -11
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +5 -2
- package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +6 -2
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +8 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +112 -51
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +20 -4
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +225 -186
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk.js +3 -3
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +3 -0
- package/src/renderers/shaders/ShaderLib/{distanceRGBA.glsl.js → distance.glsl.js} +1 -2
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -1
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -9
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/vsm.glsl.js +4 -6
- package/src/renderers/shaders/ShaderLib.js +7 -5
- package/src/renderers/shaders/UniformsLib.js +0 -3
- package/src/renderers/webgl/WebGLBackground.js +2 -2
- package/src/renderers/webgl/WebGLBindingStates.js +99 -27
- package/src/renderers/webgl/WebGLCapabilities.js +3 -4
- package/src/renderers/webgl/WebGLEnvironments.js +228 -0
- package/src/renderers/webgl/WebGLGeometries.js +10 -7
- package/src/renderers/webgl/WebGLLights.js +18 -1
- package/src/renderers/webgl/WebGLMaterials.js +12 -0
- package/src/renderers/webgl/WebGLObjects.js +3 -1
- package/src/renderers/webgl/WebGLOutput.js +267 -0
- package/src/renderers/webgl/WebGLProgram.js +45 -109
- package/src/renderers/webgl/WebGLPrograms.js +45 -49
- package/src/renderers/webgl/WebGLRenderLists.js +15 -0
- package/src/renderers/webgl/WebGLShadowMap.js +188 -24
- package/src/renderers/webgl/WebGLState.js +32 -37
- package/src/renderers/webgl/WebGLTextures.js +89 -28
- package/src/renderers/webgl/WebGLUniforms.js +40 -3
- package/src/renderers/webgl/WebGLUtils.js +6 -2
- package/src/renderers/webgl-fallback/WebGLBackend.js +148 -18
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +156 -35
- package/src/renderers/webgl-fallback/utils/WebGLState.js +181 -5
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +5 -3
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +9 -9
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +6 -2
- package/src/renderers/webgpu/WebGPUBackend.js +119 -13
- package/src/renderers/webgpu/WebGPURenderer.js +2 -1
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +322 -68
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +4 -17
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +357 -200
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -0
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +61 -23
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +152 -200
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +65 -42
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +7 -7
- package/src/renderers/webgpu/utils/WebGPUUtils.js +17 -11
- package/src/renderers/webxr/WebXRManager.js +2 -2
- package/src/textures/CubeDepthTexture.js +76 -0
- package/src/textures/Source.js +1 -1
- package/src/textures/Texture.js +3 -3
- package/src/utils.js +258 -3
- package/examples/jsm/materials/MeshGouraudMaterial.js +0 -434
- package/examples/jsm/materials/MeshPostProcessingMaterial.js +0 -167
- package/examples/jsm/shaders/GodRaysShader.js +0 -333
- package/src/nodes/accessors/SceneNode.js +0 -145
- package/src/nodes/code/ScriptableNode.js +0 -726
- package/src/nodes/code/ScriptableValueNode.js +0 -253
- package/src/nodes/display/PosterizeNode.js +0 -65
- package/src/nodes/functions/BSDF/DFGApprox.js +0 -71
- package/src/nodes/utils/SpriteSheetUVNode.js +0 -90
- package/src/renderers/webgl/WebGLCubeMaps.js +0 -99
- package/src/renderers/webgl/WebGLCubeUVMaps.js +0 -134
|
@@ -139,3 +139,20 @@ export const cdl = /*@__PURE__*/ Fn( ( [
|
|
|
139
139
|
return vec4( v.rgb, color.a );
|
|
140
140
|
|
|
141
141
|
} );
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* TSL function for creating a posterize effect which reduces the number of colors
|
|
145
|
+
* in an image, resulting in a more blocky and stylized appearance.
|
|
146
|
+
*
|
|
147
|
+
* @tsl
|
|
148
|
+
* @function
|
|
149
|
+
* @param {Node} sourceNode - The input color.
|
|
150
|
+
* @param {Node} stepsNode - Controls the intensity of the posterization effect. A lower number results in a more blocky appearance.
|
|
151
|
+
* @returns {Node} The posterized color.
|
|
152
|
+
*/
|
|
153
|
+
export const posterize = Fn( ( [ source, steps ] ) => {
|
|
154
|
+
|
|
155
|
+
return source.mul( steps ).floor().div( steps );
|
|
156
|
+
|
|
157
|
+
} );
|
|
158
|
+
|
|
@@ -135,7 +135,7 @@ export default ColorSpaceNode;
|
|
|
135
135
|
* @param {string} targetColorSpace - The target color space.
|
|
136
136
|
* @returns {ColorSpaceNode}
|
|
137
137
|
*/
|
|
138
|
-
export const workingToColorSpace = ( node, targetColorSpace ) =>
|
|
138
|
+
export const workingToColorSpace = ( node, targetColorSpace ) => new ColorSpaceNode( nodeObject( node ), WORKING_COLOR_SPACE, targetColorSpace );
|
|
139
139
|
|
|
140
140
|
/**
|
|
141
141
|
* TSL function for converting a given color node from the given color space to the current working color space.
|
|
@@ -146,7 +146,7 @@ export const workingToColorSpace = ( node, targetColorSpace ) => nodeObject( new
|
|
|
146
146
|
* @param {string} sourceColorSpace - The source color space.
|
|
147
147
|
* @returns {ColorSpaceNode}
|
|
148
148
|
*/
|
|
149
|
-
export const colorSpaceToWorking = ( node, sourceColorSpace ) =>
|
|
149
|
+
export const colorSpaceToWorking = ( node, sourceColorSpace ) => new ColorSpaceNode( nodeObject( node ), sourceColorSpace, WORKING_COLOR_SPACE );
|
|
150
150
|
|
|
151
151
|
/**
|
|
152
152
|
* TSL function for converting a given color node from one color space to another one.
|
|
@@ -158,7 +158,7 @@ export const colorSpaceToWorking = ( node, sourceColorSpace ) => nodeObject( new
|
|
|
158
158
|
* @param {string} targetColorSpace - The target color space.
|
|
159
159
|
* @returns {ColorSpaceNode}
|
|
160
160
|
*/
|
|
161
|
-
export const convertColorSpace = ( node, sourceColorSpace, targetColorSpace ) =>
|
|
161
|
+
export const convertColorSpace = ( node, sourceColorSpace, targetColorSpace ) => new ColorSpaceNode( nodeObject( node ), sourceColorSpace, targetColorSpace );
|
|
162
162
|
|
|
163
163
|
addMethodChaining( 'workingToColorSpace', workingToColorSpace );
|
|
164
164
|
addMethodChaining( 'colorSpaceToWorking', colorSpaceToWorking );
|
|
@@ -4,8 +4,9 @@ import { normalView, transformNormalToView } from '../accessors/Normal.js';
|
|
|
4
4
|
import { TBNViewMatrix } from '../accessors/AccessorsUtils.js';
|
|
5
5
|
import { nodeProxy, vec3 } from '../tsl/TSLBase.js';
|
|
6
6
|
|
|
7
|
-
import { TangentSpaceNormalMap, ObjectSpaceNormalMap } from '../../constants.js';
|
|
7
|
+
import { TangentSpaceNormalMap, ObjectSpaceNormalMap, NoNormalPacking, NormalRGPacking, NormalGAPacking } from '../../constants.js';
|
|
8
8
|
import { directionToFaceDirection } from './FrontFacingNode.js';
|
|
9
|
+
import { unpackNormal } from '../utils/Packing.js';
|
|
9
10
|
import { error } from '../../utils.js';
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -58,19 +59,53 @@ class NormalMapNode extends TempNode {
|
|
|
58
59
|
*/
|
|
59
60
|
this.normalMapType = TangentSpaceNormalMap;
|
|
60
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Controls how to unpack the sampled normal map values.
|
|
64
|
+
*
|
|
65
|
+
* @type {string}
|
|
66
|
+
* @default NoNormalPacking
|
|
67
|
+
*/
|
|
68
|
+
this.unpackNormalMode = NoNormalPacking;
|
|
69
|
+
|
|
61
70
|
}
|
|
62
71
|
|
|
63
|
-
setup(
|
|
72
|
+
setup( builder ) {
|
|
64
73
|
|
|
65
|
-
const { normalMapType, scaleNode } = this;
|
|
74
|
+
const { normalMapType, scaleNode, unpackNormalMode } = this;
|
|
66
75
|
|
|
67
76
|
let normalMap = this.node.mul( 2.0 ).sub( 1.0 );
|
|
68
77
|
|
|
78
|
+
if ( normalMapType === TangentSpaceNormalMap ) {
|
|
79
|
+
|
|
80
|
+
if ( unpackNormalMode === NormalRGPacking ) {
|
|
81
|
+
|
|
82
|
+
normalMap = unpackNormal( normalMap.xy );
|
|
83
|
+
|
|
84
|
+
} else if ( unpackNormalMode === NormalGAPacking ) {
|
|
85
|
+
|
|
86
|
+
normalMap = unpackNormal( normalMap.yw );
|
|
87
|
+
|
|
88
|
+
} else if ( unpackNormalMode !== NoNormalPacking ) {
|
|
89
|
+
|
|
90
|
+
console.error( `THREE.NodeMaterial: Unexpected unpack normal mode: ${ unpackNormalMode }` );
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
} else {
|
|
95
|
+
|
|
96
|
+
if ( unpackNormalMode !== NoNormalPacking ) {
|
|
97
|
+
|
|
98
|
+
console.error( `THREE.NodeMaterial: Normal map type '${ normalMapType }' is not compatible with unpack normal mode '${ unpackNormalMode }'` );
|
|
99
|
+
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
|
|
69
104
|
if ( scaleNode !== null ) {
|
|
70
105
|
|
|
71
106
|
let scale = scaleNode;
|
|
72
107
|
|
|
73
|
-
if (
|
|
108
|
+
if ( builder.isFlatShading() === true ) {
|
|
74
109
|
|
|
75
110
|
scale = directionToFaceDirection( scale );
|
|
76
111
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import TempNode from '../core/TempNode.js';
|
|
2
2
|
import { default as TextureNode/*, texture*/ } from '../accessors/TextureNode.js';
|
|
3
3
|
import { NodeUpdateType } from '../core/constants.js';
|
|
4
|
-
import {
|
|
4
|
+
import { context } from '../tsl/TSLBase.js';
|
|
5
5
|
import { uniform } from '../core/UniformNode.js';
|
|
6
6
|
import { viewZToOrthographicDepth, perspectiveDepthToViewZ } from './ViewportDepthNode.js';
|
|
7
7
|
|
|
@@ -44,13 +44,23 @@ class PassTextureNode extends TextureNode {
|
|
|
44
44
|
*/
|
|
45
45
|
this.passNode = passNode;
|
|
46
46
|
|
|
47
|
+
/**
|
|
48
|
+
* This flag can be used for type testing.
|
|
49
|
+
*
|
|
50
|
+
* @type {boolean}
|
|
51
|
+
* @default true
|
|
52
|
+
* @readonly
|
|
53
|
+
*/
|
|
54
|
+
this.isPassTextureNode = true;
|
|
55
|
+
|
|
47
56
|
this.setUpdateMatrix( false );
|
|
48
57
|
|
|
49
58
|
}
|
|
50
59
|
|
|
51
60
|
setup( builder ) {
|
|
52
61
|
|
|
53
|
-
|
|
62
|
+
const properties = builder.getNodeProperties( this );
|
|
63
|
+
properties.passNode = this.passNode;
|
|
54
64
|
|
|
55
65
|
return super.setup( builder );
|
|
56
66
|
|
|
@@ -107,6 +117,15 @@ class PassMultipleTextureNode extends PassTextureNode {
|
|
|
107
117
|
*/
|
|
108
118
|
this.previousTexture = previousTexture;
|
|
109
119
|
|
|
120
|
+
/**
|
|
121
|
+
* This flag can be used for type testing.
|
|
122
|
+
*
|
|
123
|
+
* @type {boolean}
|
|
124
|
+
* @default true
|
|
125
|
+
* @readonly
|
|
126
|
+
*/
|
|
127
|
+
this.isPassMultipleTextureNode = true;
|
|
128
|
+
|
|
110
129
|
}
|
|
111
130
|
|
|
112
131
|
/**
|
|
@@ -150,7 +169,7 @@ class PassMultipleTextureNode extends PassTextureNode {
|
|
|
150
169
|
* via MRT for further processing.
|
|
151
170
|
*
|
|
152
171
|
* ```js
|
|
153
|
-
* const postProcessing = new
|
|
172
|
+
* const postProcessing = new RenderPipeline( renderer );
|
|
154
173
|
*
|
|
155
174
|
* const scenePass = pass( scene, camera );
|
|
156
175
|
*
|
|
@@ -248,6 +267,45 @@ class PassNode extends TempNode {
|
|
|
248
267
|
*/
|
|
249
268
|
this.renderTarget = renderTarget;
|
|
250
269
|
|
|
270
|
+
/**
|
|
271
|
+
* An optional override material for the pass.
|
|
272
|
+
*
|
|
273
|
+
* @type {Material|null}
|
|
274
|
+
*/
|
|
275
|
+
this.overrideMaterial = null;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Whether the pass is transparent.
|
|
279
|
+
*
|
|
280
|
+
* @type {boolean}
|
|
281
|
+
* @default false
|
|
282
|
+
*/
|
|
283
|
+
this.transparent = true;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Whether the pass is opaque.
|
|
287
|
+
*
|
|
288
|
+
* @type {boolean}
|
|
289
|
+
* @default true
|
|
290
|
+
*/
|
|
291
|
+
this.opaque = true;
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* An optional global context for the pass.
|
|
295
|
+
*
|
|
296
|
+
* @type {ContextNode|null}
|
|
297
|
+
*/
|
|
298
|
+
this.contextNode = null;
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* A cache for the context node.
|
|
302
|
+
*
|
|
303
|
+
* @private
|
|
304
|
+
* @type {?Object}
|
|
305
|
+
* @default null
|
|
306
|
+
*/
|
|
307
|
+
this._contextNodeCache = null;
|
|
308
|
+
|
|
251
309
|
/**
|
|
252
310
|
* A dictionary holding the internal result textures.
|
|
253
311
|
*
|
|
@@ -584,7 +642,7 @@ class PassNode extends TempNode {
|
|
|
584
642
|
|
|
585
643
|
if ( textureNode === undefined ) {
|
|
586
644
|
|
|
587
|
-
textureNode =
|
|
645
|
+
textureNode = new PassMultipleTextureNode( this, name );
|
|
588
646
|
textureNode.updateTexture();
|
|
589
647
|
this._textureNodes[ name ] = textureNode;
|
|
590
648
|
|
|
@@ -608,7 +666,7 @@ class PassNode extends TempNode {
|
|
|
608
666
|
|
|
609
667
|
if ( this._textureNodes[ name ] === undefined ) this.getTextureNode( name );
|
|
610
668
|
|
|
611
|
-
textureNode =
|
|
669
|
+
textureNode = new PassMultipleTextureNode( this, name, true );
|
|
612
670
|
textureNode.updateTexture();
|
|
613
671
|
this._previousTextureNodes[ name ] = textureNode;
|
|
614
672
|
|
|
@@ -697,7 +755,7 @@ class PassNode extends TempNode {
|
|
|
697
755
|
|
|
698
756
|
this.renderTarget.samples = this.options.samples === undefined ? renderer.samples : this.options.samples;
|
|
699
757
|
|
|
700
|
-
this.renderTarget.texture.type = renderer.
|
|
758
|
+
this.renderTarget.texture.type = renderer.getOutputBufferType();
|
|
701
759
|
|
|
702
760
|
return this.scope === PassNode.COLOR ? this.getTextureNode() : this.getLinearDepthNode();
|
|
703
761
|
|
|
@@ -738,7 +796,11 @@ class PassNode extends TempNode {
|
|
|
738
796
|
const currentRenderTarget = renderer.getRenderTarget();
|
|
739
797
|
const currentMRT = renderer.getMRT();
|
|
740
798
|
const currentAutoClear = renderer.autoClear;
|
|
799
|
+
const currentTransparent = renderer.transparent;
|
|
800
|
+
const currentOpaque = renderer.opaque;
|
|
741
801
|
const currentMask = camera.layers.mask;
|
|
802
|
+
const currentContextNode = renderer.contextNode;
|
|
803
|
+
const currentOverrideMaterial = scene.overrideMaterial;
|
|
742
804
|
|
|
743
805
|
this._cameraNear.value = camera.near;
|
|
744
806
|
this._cameraFar.value = camera.far;
|
|
@@ -755,9 +817,32 @@ class PassNode extends TempNode {
|
|
|
755
817
|
|
|
756
818
|
}
|
|
757
819
|
|
|
820
|
+
if ( this.overrideMaterial !== null ) {
|
|
821
|
+
|
|
822
|
+
scene.overrideMaterial = this.overrideMaterial;
|
|
823
|
+
|
|
824
|
+
}
|
|
825
|
+
|
|
758
826
|
renderer.setRenderTarget( this.renderTarget );
|
|
759
827
|
renderer.setMRT( this._mrt );
|
|
760
828
|
renderer.autoClear = true;
|
|
829
|
+
renderer.transparent = this.transparent;
|
|
830
|
+
renderer.opaque = this.opaque;
|
|
831
|
+
|
|
832
|
+
if ( this.contextNode !== null ) {
|
|
833
|
+
|
|
834
|
+
if ( this._contextNodeCache === null || this._contextNodeCache.version !== this.version ) {
|
|
835
|
+
|
|
836
|
+
this._contextNodeCache = {
|
|
837
|
+
version: this.version,
|
|
838
|
+
context: context( { ...renderer.contextNode.getFlowContextData(), ...this.contextNode.getFlowContextData() } )
|
|
839
|
+
};
|
|
840
|
+
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
renderer.contextNode = this._contextNodeCache.context;
|
|
844
|
+
|
|
845
|
+
}
|
|
761
846
|
|
|
762
847
|
const currentSceneName = scene.name;
|
|
763
848
|
|
|
@@ -766,10 +851,14 @@ class PassNode extends TempNode {
|
|
|
766
851
|
renderer.render( scene, camera );
|
|
767
852
|
|
|
768
853
|
scene.name = currentSceneName;
|
|
854
|
+
scene.overrideMaterial = currentOverrideMaterial;
|
|
769
855
|
|
|
770
856
|
renderer.setRenderTarget( currentRenderTarget );
|
|
771
857
|
renderer.setMRT( currentMRT );
|
|
772
858
|
renderer.autoClear = currentAutoClear;
|
|
859
|
+
renderer.transparent = currentTransparent;
|
|
860
|
+
renderer.opaque = currentOpaque;
|
|
861
|
+
renderer.contextNode = currentContextNode;
|
|
773
862
|
|
|
774
863
|
camera.layers.mask = currentMask;
|
|
775
864
|
|
|
@@ -920,7 +1009,7 @@ export default PassNode;
|
|
|
920
1009
|
* @param {Object} options - Options for the internal render target.
|
|
921
1010
|
* @returns {PassNode}
|
|
922
1011
|
*/
|
|
923
|
-
export const pass = ( scene, camera, options ) =>
|
|
1012
|
+
export const pass = ( scene, camera, options ) => new PassNode( PassNode.COLOR, scene, camera, options );
|
|
924
1013
|
|
|
925
1014
|
/**
|
|
926
1015
|
* TSL function for creating a pass texture node.
|
|
@@ -931,7 +1020,7 @@ export const pass = ( scene, camera, options ) => nodeObject( new PassNode( Pass
|
|
|
931
1020
|
* @param {Texture} texture - The output texture.
|
|
932
1021
|
* @returns {PassTextureNode}
|
|
933
1022
|
*/
|
|
934
|
-
export const passTexture = ( pass, texture ) =>
|
|
1023
|
+
export const passTexture = ( pass, texture ) => new PassTextureNode( pass, texture );
|
|
935
1024
|
|
|
936
1025
|
/**
|
|
937
1026
|
* TSL function for creating a depth pass node.
|
|
@@ -943,4 +1032,4 @@ export const passTexture = ( pass, texture ) => nodeObject( new PassTextureNode(
|
|
|
943
1032
|
* @param {Object} options - Options for the internal render target.
|
|
944
1033
|
* @returns {PassNode}
|
|
945
1034
|
*/
|
|
946
|
-
export const depthPass = ( scene, camera, options ) =>
|
|
1035
|
+
export const depthPass = ( scene, camera, options ) => new PassNode( PassNode.DEPTH, scene, camera, options );
|
|
@@ -13,10 +13,10 @@ import { ColorManagement } from '../../math/ColorManagement.js';
|
|
|
13
13
|
* in the effect chain.
|
|
14
14
|
*
|
|
15
15
|
* When applying tone mapping and color space conversion manually with this node,
|
|
16
|
-
* you have to set {@link
|
|
16
|
+
* you have to set {@link RenderPipeline#outputColorTransform} to `false`.
|
|
17
17
|
*
|
|
18
18
|
* ```js
|
|
19
|
-
* const postProcessing = new
|
|
19
|
+
* const postProcessing = new RenderPipeline( renderer );
|
|
20
20
|
* postProcessing.outputColorTransform = false;
|
|
21
21
|
*
|
|
22
22
|
* const scenePass = pass( scene, camera );
|
|
@@ -145,6 +145,6 @@ export default RenderOutputNode;
|
|
|
145
145
|
* @param {?string} [outputColorSpace=null] - The output color space.
|
|
146
146
|
* @returns {RenderOutputNode}
|
|
147
147
|
*/
|
|
148
|
-
export const renderOutput = ( color, toneMapping = null, outputColorSpace = null ) =>
|
|
148
|
+
export const renderOutput = ( color, toneMapping = null, outputColorSpace = null ) => new RenderOutputNode( nodeObject( color ), toneMapping, outputColorSpace );
|
|
149
149
|
|
|
150
150
|
addMethodChaining( 'renderOutput', renderOutput );
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Node from '../core/Node.js';
|
|
2
|
+
import StackTrace from '../core/StackTrace.js';
|
|
2
3
|
import { NodeUpdateType } from '../core/constants.js';
|
|
3
4
|
import { uniform } from '../core/UniformNode.js';
|
|
4
5
|
import { Fn, nodeImmutable, vec2 } from '../tsl/TSLBase.js';
|
|
@@ -49,6 +50,7 @@ class ScreenNode extends Node {
|
|
|
49
50
|
/**
|
|
50
51
|
* This output node.
|
|
51
52
|
*
|
|
53
|
+
* @private
|
|
52
54
|
* @type {?Node}
|
|
53
55
|
* @default null
|
|
54
56
|
*/
|
|
@@ -283,7 +285,7 @@ export const viewportUV = /*@__PURE__*/ viewportCoordinate.div( viewportSize );
|
|
|
283
285
|
*/
|
|
284
286
|
export const viewportResolution = /*@__PURE__*/ ( Fn( () => { // @deprecated, r169
|
|
285
287
|
|
|
286
|
-
warn( 'TSL: "viewportResolution" is deprecated. Use "screenSize" instead.' );
|
|
288
|
+
warn( 'TSL: "viewportResolution" is deprecated. Use "screenSize" instead.', new StackTrace() );
|
|
287
289
|
|
|
288
290
|
return screenSize;
|
|
289
291
|
|
|
@@ -134,7 +134,7 @@ export default ToneMappingNode;
|
|
|
134
134
|
* @param {Node<vec3> | Color} color - The color node to process.
|
|
135
135
|
* @returns {ToneMappingNode<vec3>}
|
|
136
136
|
*/
|
|
137
|
-
export const toneMapping = ( mapping, exposure, color ) =>
|
|
137
|
+
export const toneMapping = ( mapping, exposure, color ) => new ToneMappingNode( mapping, nodeObject( exposure ), nodeObject( color ) );
|
|
138
138
|
|
|
139
139
|
/**
|
|
140
140
|
* TSL object that represents the global tone mapping exposure of the renderer.
|
|
@@ -14,7 +14,7 @@ import PassNode from './PassNode.js';
|
|
|
14
14
|
* will receive the outline.
|
|
15
15
|
*
|
|
16
16
|
* ```js
|
|
17
|
-
* const postProcessing = new
|
|
17
|
+
* const postProcessing = new RenderPipeline( renderer );
|
|
18
18
|
*
|
|
19
19
|
* const scenePass = toonOutlinePass( scene, camera );
|
|
20
20
|
*
|
|
@@ -188,4 +188,4 @@ export default ToonOutlinePassNode;
|
|
|
188
188
|
* @param {number} [alpha=1] - Defines the outline's alpha.
|
|
189
189
|
* @returns {ToonOutlinePassNode}
|
|
190
190
|
*/
|
|
191
|
-
export const toonOutlinePass = ( scene, camera, color = new Color( 0, 0, 0 ), thickness = 0.003, alpha = 1 ) =>
|
|
191
|
+
export const toonOutlinePass = ( scene, camera, color = new Color( 0, 0, 0 ), thickness = 0.003, alpha = 1 ) => new ToonOutlinePassNode( scene, camera, nodeObject( color ), nodeObject( thickness ), nodeObject( alpha ) );
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Node from '../core/Node.js';
|
|
2
|
-
import { float, log, log2, nodeImmutable, nodeProxy } from '../tsl/TSLBase.js';
|
|
2
|
+
import { float, Fn, log, log2, nodeImmutable, nodeProxy } from '../tsl/TSLBase.js';
|
|
3
3
|
import { cameraNear, cameraFar } from '../accessors/Camera.js';
|
|
4
4
|
import { positionView } from '../accessors/Position.js';
|
|
5
5
|
import { viewportDepthTexture } from './ViewportDepthTextureNode.js';
|
|
@@ -86,7 +86,7 @@ class ViewportDepthNode extends Node {
|
|
|
86
86
|
|
|
87
87
|
if ( value !== null ) {
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
node = depthBase().assign( value );
|
|
90
90
|
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -152,6 +152,18 @@ export default ViewportDepthNode;
|
|
|
152
152
|
*/
|
|
153
153
|
export const viewZToOrthographicDepth = ( viewZ, near, far ) => viewZ.add( near ).div( near.sub( far ) );
|
|
154
154
|
|
|
155
|
+
/**
|
|
156
|
+
* TSL function for converting a viewZ value to a reversed orthographic depth value.
|
|
157
|
+
*
|
|
158
|
+
* @tsl
|
|
159
|
+
* @function
|
|
160
|
+
* @param {Node<float>} viewZ - The viewZ node.
|
|
161
|
+
* @param {Node<float>} near - The camera's near value.
|
|
162
|
+
* @param {Node<float>} far - The camera's far value.
|
|
163
|
+
* @returns {Node<float>}
|
|
164
|
+
*/
|
|
165
|
+
export const viewZToReversedOrthographicDepth = ( viewZ, near, far ) => viewZ.add( far ).div( far.sub( near ) );
|
|
166
|
+
|
|
155
167
|
/**
|
|
156
168
|
* TSL function for converting an orthographic depth value to a viewZ value.
|
|
157
169
|
*
|
|
@@ -162,7 +174,19 @@ export const viewZToOrthographicDepth = ( viewZ, near, far ) => viewZ.add( near
|
|
|
162
174
|
* @param {Node<float>} far - The camera's far value.
|
|
163
175
|
* @returns {Node<float>}
|
|
164
176
|
*/
|
|
165
|
-
export const orthographicDepthToViewZ = ( depth, near, far
|
|
177
|
+
export const orthographicDepthToViewZ = /*@__PURE__*/ Fn( ( [ depth, near, far ], builder ) => {
|
|
178
|
+
|
|
179
|
+
if ( builder.renderer.reversedDepthBuffer === true ) {
|
|
180
|
+
|
|
181
|
+
return far.sub( near ).mul( depth ).sub( far );
|
|
182
|
+
|
|
183
|
+
} else {
|
|
184
|
+
|
|
185
|
+
return near.sub( far ).mul( depth ).sub( near );
|
|
186
|
+
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
} );
|
|
166
190
|
|
|
167
191
|
/**
|
|
168
192
|
* TSL function for converting a viewZ value to a perspective depth value.
|
|
@@ -178,6 +202,18 @@ export const orthographicDepthToViewZ = ( depth, near, far ) => near.sub( far ).
|
|
|
178
202
|
*/
|
|
179
203
|
export const viewZToPerspectiveDepth = ( viewZ, near, far ) => near.add( viewZ ).mul( far ).div( far.sub( near ).mul( viewZ ) );
|
|
180
204
|
|
|
205
|
+
/**
|
|
206
|
+
* TSL function for converting a viewZ value to a reversed perspective depth value.
|
|
207
|
+
*
|
|
208
|
+
* @tsl
|
|
209
|
+
* @function
|
|
210
|
+
* @param {Node<float>} viewZ - The viewZ node.
|
|
211
|
+
* @param {Node<float>} near - The camera's near value.
|
|
212
|
+
* @param {Node<float>} far - The camera's far value.
|
|
213
|
+
* @returns {Node<float>}
|
|
214
|
+
*/
|
|
215
|
+
export const viewZToReversedPerspectiveDepth = ( viewZ, near, far ) => near.mul( viewZ.add( far ) ).div( viewZ.mul( near.sub( far ) ) );
|
|
216
|
+
|
|
181
217
|
/**
|
|
182
218
|
* TSL function for converting a perspective depth value to a viewZ value.
|
|
183
219
|
*
|
|
@@ -188,7 +224,19 @@ export const viewZToPerspectiveDepth = ( viewZ, near, far ) => near.add( viewZ )
|
|
|
188
224
|
* @param {Node<float>} far - The camera's far value.
|
|
189
225
|
* @returns {Node<float>}
|
|
190
226
|
*/
|
|
191
|
-
export const perspectiveDepthToViewZ = ( depth, near, far
|
|
227
|
+
export const perspectiveDepthToViewZ = /*@__PURE__*/ Fn( ( [ depth, near, far ], builder ) => {
|
|
228
|
+
|
|
229
|
+
if ( builder.renderer.reversedDepthBuffer === true ) {
|
|
230
|
+
|
|
231
|
+
return near.mul( far ).div( near.sub( far ).mul( depth ).sub( near ) );
|
|
232
|
+
|
|
233
|
+
} else {
|
|
234
|
+
|
|
235
|
+
return near.mul( far ).div( far.sub( near ).mul( depth ).sub( far ) );
|
|
236
|
+
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
} );
|
|
192
240
|
|
|
193
241
|
/**
|
|
194
242
|
* TSL function for converting a viewZ value to a logarithmic depth value.
|
|
@@ -80,13 +80,13 @@ class ViewportTextureNode extends TextureNode {
|
|
|
80
80
|
this.isOutputTextureNode = true;
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
|
-
* The `updateBeforeType` is set to `NodeUpdateType.
|
|
84
|
-
*
|
|
83
|
+
* The `updateBeforeType` is set to `NodeUpdateType.RENDER` since the node should extract
|
|
84
|
+
* the current contents of the bound framebuffer for each render call.
|
|
85
85
|
*
|
|
86
86
|
* @type {string}
|
|
87
|
-
* @default '
|
|
87
|
+
* @default 'render'
|
|
88
88
|
*/
|
|
89
|
-
this.updateBeforeType = NodeUpdateType.
|
|
89
|
+
this.updateBeforeType = NodeUpdateType.RENDER;
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
92
|
* The framebuffer texture for the current renderer context.
|
|
@@ -226,3 +226,20 @@ export const viewportTexture = /*@__PURE__*/ nodeProxy( ViewportTextureNode ).se
|
|
|
226
226
|
* @returns {ViewportTextureNode}
|
|
227
227
|
*/
|
|
228
228
|
export const viewportMipTexture = /*@__PURE__*/ nodeProxy( ViewportTextureNode, null, null, { generateMipmaps: true } ).setParameterLength( 0, 3 );
|
|
229
|
+
|
|
230
|
+
// Singleton instances for common usage
|
|
231
|
+
const _singletonOpaqueViewportTextureNode = /*@__PURE__*/ viewportMipTexture();
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* TSL function for creating a viewport texture node with enabled mipmap generation.
|
|
235
|
+
* The texture should only contain the opaque rendering objects.
|
|
236
|
+
*
|
|
237
|
+
* This should be used just in transparent or transmissive materials.
|
|
238
|
+
*
|
|
239
|
+
* @tsl
|
|
240
|
+
* @function
|
|
241
|
+
* @param {?Node} [uv=screenUV] - The uv node.
|
|
242
|
+
* @param {?Node} [level=null] - The level node.
|
|
243
|
+
* @returns {ViewportTextureNode}
|
|
244
|
+
*/
|
|
245
|
+
export const viewportOpaqueMipTexture = ( uv = screenUV, level = null ) => _singletonOpaqueViewportTextureNode.sample( uv, level ); // TODO: Use once() when sample() supports it
|
package/src/nodes/fog/Fog.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { positionView } from '../accessors/Position.js';
|
|
1
|
+
import { positionView, positionWorld } from '../accessors/Position.js';
|
|
2
2
|
import { smoothstep } from '../math/MathNode.js';
|
|
3
3
|
import { Fn, output, vec4 } from '../tsl/TSLBase.js';
|
|
4
|
-
import { warn } from '../../utils.js';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* Returns a node that represents the `z` coordinate in view space
|
|
@@ -64,51 +63,35 @@ export const densityFogFactor = Fn( ( [ density ], builder ) => {
|
|
|
64
63
|
} );
|
|
65
64
|
|
|
66
65
|
/**
|
|
67
|
-
*
|
|
68
|
-
* Nodes of this type are assigned to `Scene.fogNode`.
|
|
66
|
+
* Constructs a new height fog factor node. This fog factor requires a Y-up coordinate system.
|
|
69
67
|
*
|
|
70
68
|
* @tsl
|
|
71
69
|
* @function
|
|
72
|
-
* @param {Node}
|
|
73
|
-
* @param {Node}
|
|
70
|
+
* @param {Node} density - Defines the fog density.
|
|
71
|
+
* @param {Node} height - The height threshold in world space. Everything below this y-coordinate is affected by fog.
|
|
74
72
|
*/
|
|
75
|
-
export const
|
|
76
|
-
|
|
77
|
-
return vec4( factor.toFloat().mix( output.rgb, color.toVec3() ), output.a );
|
|
78
|
-
|
|
79
|
-
} );
|
|
73
|
+
export const exponentialHeightFogFactor = Fn( ( [ density, height ], builder ) => {
|
|
80
74
|
|
|
81
|
-
|
|
75
|
+
const viewZ = getViewZNode( builder );
|
|
82
76
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
* @function
|
|
86
|
-
* @deprecated since r171. Use `fog( color, rangeFogFactor( near, far ) )` instead.
|
|
87
|
-
*
|
|
88
|
-
* @param {Node} color
|
|
89
|
-
* @param {Node} near
|
|
90
|
-
* @param {Node} far
|
|
91
|
-
* @returns {Function}
|
|
92
|
-
*/
|
|
93
|
-
export function rangeFog( color, near, far ) { // @deprecated, r171
|
|
77
|
+
const distance = height.sub( positionWorld.y ).max( 0 ).toConst();
|
|
78
|
+
const m = distance.mul( viewZ ).toConst();
|
|
94
79
|
|
|
95
|
-
|
|
96
|
-
return fog( color, rangeFogFactor( near, far ) );
|
|
80
|
+
return density.mul( density, m, m ).negate().exp().oneMinus();
|
|
97
81
|
|
|
98
|
-
}
|
|
82
|
+
} );
|
|
99
83
|
|
|
100
84
|
/**
|
|
85
|
+
* This class can be used to configure a fog for the scene.
|
|
86
|
+
* Nodes of this type are assigned to `Scene.fogNode`.
|
|
87
|
+
*
|
|
101
88
|
* @tsl
|
|
102
89
|
* @function
|
|
103
|
-
* @
|
|
104
|
-
*
|
|
105
|
-
* @param {Node} color
|
|
106
|
-
* @param {Node} density
|
|
107
|
-
* @returns {Function}
|
|
90
|
+
* @param {Node} color - Defines the color of the fog.
|
|
91
|
+
* @param {Node} factor - Defines how the fog is factored in the scene.
|
|
108
92
|
*/
|
|
109
|
-
export
|
|
93
|
+
export const fog = Fn( ( [ color, factor ] ) => {
|
|
110
94
|
|
|
111
|
-
|
|
112
|
-
return fog( color, densityFogFactor( density ) );
|
|
95
|
+
return vec4( factor.toFloat().mix( output.rgb, color.toVec3() ), output.a );
|
|
113
96
|
|
|
114
|
-
}
|
|
97
|
+
} );
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import BRDF_GGX from './BRDF_GGX.js';
|
|
2
|
-
import
|
|
2
|
+
import DFGLUT from './DFGLUT.js';
|
|
3
3
|
import { normalView } from '../../accessors/Normal.js';
|
|
4
4
|
import { positionViewDirection } from '../../accessors/Position.js';
|
|
5
5
|
import { EPSILON } from '../../math/MathNode.js';
|
|
@@ -19,8 +19,8 @@ const BRDF_GGX_Multiscatter = /*@__PURE__*/ Fn( ( { lightDirection, f0, f90, rou
|
|
|
19
19
|
const dotNV = normalView.dot( positionViewDirection ).clamp();
|
|
20
20
|
|
|
21
21
|
// Precomputed DFG values for view and light directions
|
|
22
|
-
const dfgV =
|
|
23
|
-
const dfgL =
|
|
22
|
+
const dfgV = DFGLUT( { roughness: _roughness, dotNV } );
|
|
23
|
+
const dfgL = DFGLUT( { roughness: _roughness, dotNV: dotNL } );
|
|
24
24
|
|
|
25
25
|
// Single-scattering energy for view and light
|
|
26
26
|
const FssEss_V = f0.mul( dfgV.x ).add( f90.mul( dfgV.y ) );
|