@gnsx/three 0.185.15 → 0.186.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 +10 -82600
- package/build/three.core.js +1303 -728
- package/build/three.module.js +439 -338
- package/build/three.tsl.js +74 -44
- package/build/three.webgpu.js +6036 -2184
- package/build/three.webgpu.nodes.js +6020 -2184
- package/examples/jsm/Addons.js +6 -6
- package/examples/jsm/controls/ArcballControls.js +1 -1
- package/examples/jsm/controls/FirstPersonControls.js +44 -20
- package/examples/jsm/controls/OrbitControls.js +9 -0
- package/examples/jsm/controls/TrackballControls.js +109 -4
- package/examples/jsm/csm/CSMShadowNode.js +13 -0
- package/examples/jsm/exporters/GLTFExporter.js +23 -7
- package/examples/jsm/exporters/USDZExporter.js +2 -2
- package/examples/jsm/generators/CityGenerator.js +377 -45
- package/examples/jsm/generators/ForestGenerator.js +12 -12
- package/examples/jsm/generators/TerrainGenerator.js +49 -37
- package/examples/jsm/generators/TreeGenerator.js +70 -76
- package/examples/jsm/generators/city/BenchGenerator.js +127 -0
- package/examples/jsm/generators/city/CarGenerator.js +479 -0
- package/examples/jsm/generators/city/CityGeneratorUtils.js +31 -0
- package/examples/jsm/generators/city/HydrantGenerator.js +106 -0
- package/examples/jsm/generators/city/InstancedMeshGenerator.js +86 -0
- package/examples/jsm/generators/city/PersonGenerator.js +447 -0
- package/examples/jsm/generators/city/SidewalkGenerator.js +33 -38
- package/examples/jsm/generators/city/SkyscraperGenerator.js +448 -48
- package/examples/jsm/generators/city/StreetTreeGenerator.js +231 -0
- package/examples/jsm/generators/city/StreetlightGenerator.js +100 -0
- package/examples/jsm/generators/city/TrafficlightGenerator.js +106 -0
- package/examples/jsm/generators/city/TrashcanGenerator.js +100 -0
- package/examples/jsm/geometries/BoxLineGeometry.js +1 -1
- package/examples/jsm/geometries/ParametricGeometry.js +1 -1
- package/examples/jsm/geometries/RoundedBoxGeometry.js +1 -1
- package/examples/jsm/gpgpu/CountingSort.js +271 -0
- package/examples/jsm/helpers/LightProbeGridHelper.js +60 -239
- package/examples/jsm/helpers/LightProbeGridHelperWebGL.js +221 -0
- package/examples/jsm/inspector/Extension.js +94 -0
- package/examples/jsm/inspector/Inspector.js +145 -41
- package/examples/jsm/inspector/RendererInspector.js +100 -52
- package/examples/jsm/inspector/extensions/color-grading/ColorGrading.js +2609 -0
- package/examples/jsm/inspector/extensions/color-grading/ColorWheel.js +352 -0
- package/examples/jsm/inspector/extensions/color-grading/CurveEditor.js +599 -0
- package/examples/jsm/inspector/extensions/color-grading/LUT3DStyle.js +1201 -0
- package/examples/jsm/inspector/extensions/color-grading/LUTMath.js +788 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/BrightnessModule.js +72 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ColorWheelModule.js +112 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ContrastModule.js +82 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/CurvesModule.js +109 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ExposureHueModule.js +110 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ExposureModule.js +73 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/HueModule.js +78 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ImportedCubeModule.js +89 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/Module.js +285 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/OutputModule.js +101 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/RendererModule.js +225 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/SatVibranceModule.js +102 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/SaturationModule.js +76 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/VibranceModule.js +76 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/WhiteBalanceModule.js +86 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.js +26 -31
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.js +1 -0
- package/examples/jsm/inspector/tabs/Memory.js +0 -2
- package/examples/jsm/inspector/tabs/Settings.js +4 -0
- package/examples/jsm/inspector/tabs/Timeline.js +223 -171
- package/examples/jsm/inspector/tabs/Viewer.js +515 -21
- package/examples/jsm/inspector/ui/List.js +15 -9
- package/examples/jsm/inspector/ui/Profiler.js +170 -14
- package/examples/jsm/inspector/ui/Style.js +269 -23
- package/examples/jsm/inspector/ui/Tab.js +2 -0
- package/examples/jsm/inspector/ui/Values.js +14 -2
- package/examples/jsm/interactive/HTMLMesh.js +19 -3
- package/examples/jsm/lighting/LightProbeGrid.js +484 -889
- package/examples/jsm/lighting/LightProbeGridUtils.js +107 -0
- package/examples/jsm/lighting/LightProbeGridWebGL.js +841 -0
- package/examples/jsm/lighting/vxgi/VXGIConeTracer.js +194 -0
- package/examples/jsm/lighting/vxgi/VXGINode.js +660 -0
- package/examples/jsm/lighting/vxgi/VXGISceneCollector.js +478 -0
- package/examples/jsm/lighting/vxgi/VXGIVolume.js +1430 -0
- package/examples/jsm/lights/SunLight.js +95 -0
- package/examples/jsm/lights/SunLightNode.js +56 -0
- package/examples/jsm/lights/SunLightShadow.js +319 -0
- package/examples/jsm/lights/SunShadowNode.js +312 -0
- package/examples/jsm/loaders/3DMLoader.js +150 -49
- package/examples/jsm/loaders/3MFLoader.js +202 -1
- package/examples/jsm/loaders/FBXLoader.js +81 -5
- package/examples/jsm/loaders/GLTFGaussianSplatLoaderExtension.js +330 -0
- package/examples/jsm/loaders/GLTFLoader.js +79 -14
- package/examples/jsm/loaders/GaussianSplatPLYLoader.js +386 -0
- package/examples/jsm/loaders/KSPLATLoader.js +463 -0
- package/examples/jsm/loaders/MaterialXLoader.js +111 -1010
- package/examples/jsm/loaders/PCDLoader.js +1 -1
- package/examples/jsm/loaders/SPLATLoader.js +139 -0
- package/examples/jsm/loaders/SPZLoader.js +561 -0
- package/examples/jsm/loaders/materialx/MaterialXArchive.js +108 -0
- package/examples/jsm/loaders/materialx/MaterialXDocument.js +878 -0
- package/examples/jsm/loaders/materialx/MaterialXHextile.js +183 -0
- package/examples/jsm/loaders/materialx/MaterialXInterfaceValidation.js +376 -0
- package/examples/jsm/loaders/materialx/MaterialXLog.js +75 -0
- package/examples/jsm/loaders/materialx/MaterialXNodeInterfaceRegistry.js +4 -0
- package/examples/jsm/loaders/materialx/MaterialXNodeLibrary.js +1021 -0
- package/examples/jsm/loaders/materialx/MaterialXSurfaceMappings.js +661 -0
- package/examples/jsm/loaders/materialx/MaterialXUtils.js +57 -0
- package/examples/jsm/loaders/materialx/compile/MaterialXCompileRegistry.js +997 -0
- package/examples/jsm/loaders/materialx/parse/MaterialXParser.js +28 -0
- package/examples/jsm/loaders/usd/USDAParser.js +15 -2
- package/examples/jsm/loaders/usd/USDCParser.js +1 -4
- package/examples/jsm/loaders/usd/USDComposer.js +80 -42
- package/examples/jsm/materials/WoodNodeMaterial.js +6 -108
- package/examples/jsm/misc/RollerCoaster.js +2 -2
- package/examples/jsm/misc/SculptGL.LICENSE.txt +21 -0
- package/examples/jsm/misc/Sculptor.js +1679 -0
- package/examples/jsm/misc/SculptorMesh.js +1504 -0
- package/examples/jsm/misc/SculptorTools.js +1180 -0
- package/examples/jsm/misc/SculptorUtils.js +345 -0
- package/examples/jsm/misc/TubePainter.js +28 -16
- package/examples/jsm/misc/VolumeSlice.js +24 -24
- package/examples/jsm/modifiers/SimplifyModifier.js +63 -556
- package/examples/jsm/objects/GaussianSplat.js +1039 -0
- package/examples/jsm/objects/Sky.js +66 -45
- package/examples/jsm/objects/SkyMesh.js +70 -51
- package/examples/jsm/physics/JoltPhysics.js +1 -1
- package/examples/jsm/postprocessing/AfterimagePass.js +4 -2
- package/examples/jsm/postprocessing/BloomPass.js +2 -2
- package/examples/jsm/postprocessing/GTAOPass.js +1 -1
- package/examples/jsm/postprocessing/OutlinePass.js +5 -5
- package/examples/jsm/postprocessing/SAOPass.js +1 -1
- package/examples/jsm/postprocessing/SSAOPass.js +1 -1
- package/examples/jsm/postprocessing/SSRPass.js +4 -2
- package/examples/jsm/postprocessing/SavePass.js +1 -1
- package/examples/jsm/postprocessing/TAARenderPass.js +1 -1
- package/examples/jsm/postprocessing/UnrealBloomPass.js +30 -13
- package/examples/jsm/renderers/CSS2DRenderer.js +29 -5
- package/examples/jsm/shaders/DepthLimitedBlurShader.js +4 -1
- package/examples/jsm/shaders/ExposureShader.js +1 -1
- package/examples/jsm/shaders/FilmShader.js +2 -1
- package/examples/jsm/transpiler/AST.js +21 -2
- package/examples/jsm/transpiler/GLSLDecoder.js +498 -8
- package/examples/jsm/transpiler/TSLEncoder.js +82 -10
- package/examples/jsm/transpiler/WGSLEncoder.js +33 -4
- package/examples/jsm/tsl/WebGLNodesHandler.js +29 -39
- package/examples/jsm/tsl/display/AfterImageNode.js +2 -0
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +3 -2
- package/examples/jsm/tsl/display/BilateralBlurNode.js +5 -2
- package/examples/jsm/tsl/display/BloomNode.js +55 -30
- package/examples/jsm/tsl/display/DenoiseNode.js +21 -1
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +24 -6
- package/examples/jsm/tsl/display/DotScreenNode.js +11 -11
- package/examples/jsm/tsl/display/FSR1Node.js +8 -4
- package/examples/jsm/tsl/display/GTAONode.js +199 -86
- package/examples/jsm/tsl/display/GaussianBlurNode.js +65 -52
- package/examples/jsm/tsl/display/GodraysNode.js +5 -2
- package/examples/jsm/tsl/display/ImportanceSampledEnvironment.js +2 -2
- package/examples/jsm/tsl/display/LensflareNode.js +5 -2
- package/examples/jsm/tsl/display/OITPassNode.js +352 -0
- package/examples/jsm/tsl/display/OutlineNode.js +2 -0
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +3 -2
- package/examples/jsm/tsl/display/RGBShiftNode.js +9 -9
- package/examples/jsm/tsl/display/RecurrentDenoiseNode.js +7 -4
- package/examples/jsm/tsl/display/RetroPassNode.js +1 -1
- package/examples/jsm/tsl/display/SMAANode.js +22 -61
- package/examples/jsm/tsl/display/SSAAPassNode.js +2 -4
- package/examples/jsm/tsl/display/SSAONode.js +436 -0
- package/examples/jsm/tsl/display/SSGINode.js +5 -2
- package/examples/jsm/tsl/display/SSRNode.js +7 -2
- package/examples/jsm/tsl/display/SSSNode.js +5 -2
- package/examples/jsm/tsl/display/SharpenNode.js +5 -4
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +1 -3
- package/examples/jsm/tsl/display/StereoPassNode.js +1 -3
- package/examples/jsm/tsl/display/TAAUNode.js +22 -125
- package/examples/jsm/tsl/display/TRAANode.js +16 -142
- package/examples/jsm/tsl/display/TemporalReprojectNode.js +21 -15
- package/examples/jsm/tsl/display/depthAwareBlur.js +63 -0
- package/examples/jsm/tsl/display/hashBlur.js +3 -2
- package/examples/jsm/tsl/lighting/ClusteredLightsNode.js +38 -27
- package/examples/jsm/tsl/lighting/LightProbeGridNode.js +136 -0
- package/examples/jsm/tsl/math/voronoiNoise.js +112 -0
- package/examples/jsm/tsl/shadows/TileShadowNode.js +4 -6
- package/examples/jsm/tsl/utils/Raymarching.js +5 -5
- package/examples/jsm/tsl/utils/SoftParticles.js +60 -0
- package/examples/jsm/tsl/utils/TAAUtils.js +195 -0
- package/examples/jsm/utils/BufferGeometryUtils.js +14 -14
- package/examples/jsm/utils/GaussianSplatUtils.js +229 -0
- package/examples/jsm/utils/WebGLTextureUtils.js +1 -1
- package/examples/jsm/utils/WebGPUTextureUtils.js +1 -1
- package/examples/jsm/webxr/WebGLXRFallback.js +2 -16
- package/examples/jsm/webxr/XRControllerModelFactory.js +16 -4
- package/package.json +9 -16
- package/src/Three.Core.js +2 -1
- package/src/Three.TSL.js +73 -43
- package/src/Three.WebGPU.Nodes.js +1 -0
- package/src/Three.WebGPU.js +1 -0
- package/src/animation/AnimationClip.js +15 -2
- package/src/animation/AnimationObjectGroup.js +18 -6
- package/src/animation/AnimationUtils.js +26 -0
- package/src/animation/KeyframeTrack.js +37 -0
- package/src/constants.js +23 -1
- package/src/core/BufferAttribute.js +3 -2
- package/src/core/BufferGeometry.js +1 -1
- package/src/core/InterleavedBuffer.js +5 -1
- package/src/core/Object3D.js +40 -12
- package/src/core/Raycaster.js +4 -0
- package/src/core/RenderTarget.js +99 -9
- package/src/core/RenderTarget3D.js +12 -8
- package/src/extras/Controls.js +0 -8
- package/src/extras/PMREMGenerator.js +99 -205
- package/src/geometries/TorusGeometry.js +1 -1
- package/src/helpers/ArrowHelper.js +2 -0
- package/src/helpers/AxesHelper.js +2 -0
- package/src/helpers/Box3Helper.js +2 -0
- package/src/helpers/BoxHelper.js +2 -0
- package/src/helpers/CameraHelper.js +2 -0
- package/src/helpers/DirectionalLightHelper.js +2 -0
- package/src/helpers/GridHelper.js +2 -0
- package/src/helpers/HemisphereLightHelper.js +2 -0
- package/src/helpers/PlaneHelper.js +2 -0
- package/src/helpers/PointLightHelper.js +2 -0
- package/src/helpers/PolarGridHelper.js +2 -0
- package/src/helpers/SkeletonHelper.js +2 -0
- package/src/helpers/SpotLightHelper.js +2 -0
- package/src/lights/Light.js +0 -10
- package/src/lights/LightShadow.js +43 -12
- package/src/lights/SpotLightShadow.js +18 -0
- package/src/loaders/BufferGeometryLoader.js +5 -0
- package/src/loaders/ImageBitmapLoader.js +3 -1
- package/src/loaders/ObjectLoader.js +8 -5
- package/src/materials/Material.js +80 -57
- package/src/materials/MeshPhysicalMaterial.js +32 -0
- package/src/materials/nodes/Line2NodeMaterial.js +17 -8
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +42 -5
- package/src/materials/nodes/NodeMaterial.js +19 -13
- package/src/materials/nodes/PointsNodeMaterial.js +2 -1
- package/src/materials/nodes/manager/NodeMaterialObserver.js +282 -55
- package/src/math/Frustum.js +9 -0
- package/src/math/FrustumArray.js +1 -1
- package/src/math/MathUtils.js +5 -3
- package/src/math/Matrix4.js +2 -9
- package/src/math/Plane.js +30 -1
- package/src/math/Quaternion.js +0 -10
- package/src/math/Ray.js +95 -45
- package/src/math/Triangle.js +0 -2
- package/src/math/Vector3.js +2 -2
- package/src/math/Vector4.js +0 -4
- package/src/math/interpolants/BezierInterpolant.js +36 -23
- package/src/nodes/Nodes.js +2 -0
- package/src/nodes/TSL.js +11 -3
- package/src/nodes/accessors/Batch.js +85 -13
- package/src/nodes/accessors/BufferAttributeNode.js +1 -1
- package/src/nodes/accessors/BuiltinNode.js +1 -1
- package/src/nodes/accessors/Instance.js +19 -18
- package/src/nodes/accessors/MaterialNode.js +9 -0
- package/src/nodes/accessors/ModelNode.js +85 -9
- package/src/nodes/accessors/ReferenceBaseNode.js +1 -70
- package/src/nodes/accessors/ReferenceElementNode.js +72 -0
- package/src/nodes/accessors/ReferenceNode.js +1 -70
- package/src/nodes/accessors/Skinning.js +124 -12
- package/src/nodes/accessors/StorageTextureNode.js +7 -3
- package/src/nodes/accessors/Texture3DNode.js +1 -1
- package/src/nodes/accessors/TextureNode.js +51 -21
- package/src/nodes/accessors/TextureSizeNode.js +4 -2
- package/src/nodes/accessors/UniformArrayNode.js +30 -5
- package/src/nodes/code/CodeNode.js +1 -1
- package/src/nodes/code/FunctionNode.js +12 -2
- package/src/nodes/core/ArrayNode.js +2 -2
- package/src/nodes/core/ContextNode.js +57 -4
- package/src/nodes/core/IndexNode.js +69 -4
- package/src/nodes/core/InspectorNode.js +2 -2
- package/src/nodes/core/MRTNode.js +44 -2
- package/src/nodes/core/Node.js +6 -3
- package/src/nodes/core/NodeBuilder.js +65 -50
- package/src/nodes/core/NodeFrame.js +11 -3
- package/src/nodes/core/NodeUtils.js +88 -0
- package/src/nodes/core/PropertyNode.js +8 -0
- package/src/nodes/core/StackNode.js +0 -1
- package/src/nodes/core/StructNode.js +4 -3
- package/src/nodes/core/UniformGroupNode.js +3 -2
- package/src/nodes/core/UniformNode.js +26 -12
- package/src/nodes/core/VarNode.js +0 -1
- package/src/nodes/display/BumpMapNode.js +2 -2
- package/src/nodes/display/ColorAdjustment.js +1 -1
- package/src/nodes/display/PassNode.js +76 -15
- package/src/nodes/display/ScreenNode.js +22 -65
- package/src/nodes/fog/Fog.js +4 -4
- package/src/nodes/functions/BSDF/BRDF_GGX.js +6 -6
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +1 -1
- package/src/nodes/functions/BSDF/DFGLUT.js +2 -1
- package/src/nodes/functions/BSDF/LTC.js +1 -1
- package/src/nodes/functions/PhongLightingModel.js +1 -1
- package/src/nodes/functions/PhysicalLightingModel.js +83 -25
- package/src/nodes/functions/ToonLightingModel.js +2 -2
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +3 -3
- package/src/nodes/gpgpu/AtomicFunctionNode.js +64 -13
- package/src/nodes/gpgpu/BarrierNode.js +13 -4
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -1
- package/src/nodes/gpgpu/ComputeNode.js +20 -17
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +165 -37
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +44 -6
- package/src/nodes/lighting/EnvironmentNode.js +40 -4
- package/src/nodes/lighting/LightsNode.js +20 -4
- package/src/nodes/lighting/ShadowBaseNode.js +158 -1
- package/src/nodes/lighting/ShadowFilterNode.js +2 -106
- package/src/nodes/lighting/ShadowNode.js +22 -91
- package/src/nodes/materialx/{lib/mx_hsv.js → MaterialXColor.js} +3 -6
- package/src/nodes/materialx/{lib/mx_transform_color.js → MaterialXColorTransform.js} +3 -6
- package/src/nodes/materialx/MaterialXCore.js +37 -0
- package/src/nodes/materialx/MaterialXNodes.js +64 -72
- package/src/nodes/materialx/{lib/mx_noise.js → MaterialXNoise.js} +426 -197
- package/src/nodes/math/BitcountNode.js +24 -4
- package/src/nodes/math/MathNode.js +4 -4
- package/src/nodes/math/MathUtils.js +15 -4
- package/src/nodes/math/OperatorNode.js +2 -2
- package/src/nodes/math/PackFloatNode.js +29 -1
- package/src/nodes/math/Packed4x8IntegerNode.js +433 -0
- package/src/nodes/math/UnpackFloatNode.js +30 -2
- package/src/nodes/parsers/GLSLNodeFunction.js +1 -1
- package/src/nodes/pmrem/PMREMNode.js +1 -1
- package/src/nodes/pmrem/PMREMUtils.js +31 -74
- package/src/nodes/shapes/Shapes.js +1 -1
- package/src/nodes/tsl/TSLCore.js +1 -31
- package/src/nodes/utils/EventNode.js +75 -0
- package/src/nodes/utils/LoopNode.js +54 -13
- package/src/nodes/utils/PostProcessingUtils.js +23 -2
- package/src/nodes/utils/RTTNode.js +97 -32
- package/src/nodes/utils/ReflectorNode.js +8 -4
- package/src/nodes/utils/RotateNode.js +85 -8
- package/src/nodes/utils/SpriteUtils.js +58 -23
- package/src/objects/BatchedMesh.js +6 -0
- package/src/objects/InstancedMesh.js +1 -1
- package/src/objects/LOD.js +1 -1
- package/src/objects/Line.js +12 -0
- package/src/objects/Mesh.js +12 -0
- package/src/objects/Points.js +12 -0
- package/src/objects/Sprite.js +12 -0
- package/src/renderers/WebGLRenderer.js +93 -27
- package/src/renderers/common/Animation.js +12 -2
- package/src/renderers/common/Backend.js +38 -10
- package/src/renderers/common/BindGroup.js +0 -1
- package/src/renderers/common/Bindings.js +50 -4
- package/src/renderers/common/BundleGroup.js +4 -0
- package/src/renderers/common/ClippingContext.js +11 -1
- package/src/renderers/common/Color4.js +9 -0
- package/src/renderers/common/Constants.js +0 -5
- package/src/renderers/common/DirectRenderPipeline.js +233 -0
- package/src/renderers/common/Geometries.js +24 -3
- package/src/renderers/common/Info.js +3 -3
- package/src/renderers/common/InspectorBase.js +37 -8
- package/src/renderers/common/Lighting.js +11 -4
- package/src/renderers/common/Pipelines.js +6 -4
- package/src/renderers/common/QuadMesh.js +16 -2
- package/src/renderers/common/RenderContext.js +8 -0
- package/src/renderers/common/RenderList.js +53 -19
- package/src/renderers/common/RenderLists.js +58 -11
- package/src/renderers/common/RenderObject.js +14 -0
- package/src/renderers/common/RenderObjects.js +14 -9
- package/src/renderers/common/RenderPipeline.js +52 -44
- package/src/renderers/common/Renderer.js +226 -55
- package/src/renderers/common/Storage3DTexture.js +16 -0
- package/src/renderers/common/Textures.js +3 -3
- package/src/renderers/common/XRManager.js +79 -72
- package/src/renderers/common/extras/PMREMGenerator.js +76 -144
- package/src/renderers/common/nodes/NodeManager.js +144 -6
- package/src/renderers/common/nodes/NodeStorageBuffer.js +3 -1
- package/src/renderers/common/nodes/NodeUniformBuffer.js +3 -1
- package/src/renderers/shaders/DFGLUTData.js +2 -1
- package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +4 -2
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +48 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +53 -4
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +20 -2
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +20 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +61 -57
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +82 -0
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +9 -0
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +8 -1
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +15 -0
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -0
- package/src/renderers/shaders/ShaderLib.js +1 -0
- package/src/renderers/shaders/UniformsLib.js +16 -0
- package/src/renderers/webgl/WebGLAnimation.js +2 -2
- package/src/renderers/webgl/WebGLCapabilities.js +2 -2
- package/src/renderers/webgl/WebGLLights.js +74 -4
- package/src/renderers/webgl/WebGLMaterials.js +6 -0
- package/src/renderers/webgl/WebGLOutput.js +36 -24
- package/src/renderers/webgl/WebGLProgram.js +3 -0
- package/src/renderers/webgl/WebGLPrograms.js +8 -0
- package/src/renderers/webgl/WebGLRenderLists.js +6 -10
- package/src/renderers/webgl/WebGLShadowMap.js +47 -44
- package/src/renderers/webgl/WebGLTextures.js +7 -7
- package/src/renderers/webgl-fallback/WebGLBackend.js +153 -45
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +83 -29
- package/src/renderers/webgl-fallback/utils/WebGLState.js +163 -17
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +32 -5
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +11 -4
- package/src/renderers/webgpu/WebGPUBackend.js +513 -145
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +99 -20
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +2 -1
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +3 -12
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +24 -14
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +80 -14
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +62 -7
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +9 -3
- package/src/renderers/webgpu/utils/WebGPUUtils.js +16 -4
- package/src/renderers/webxr/WebXRManager.js +25 -2
- package/src/scenes/Scene.js +3 -3
- package/src/textures/CompressedArrayTexture.js +16 -0
- package/src/textures/Data3DTexture.js +16 -0
- package/src/textures/DataArrayTexture.js +16 -0
- package/src/textures/DepthTexture.js +3 -3
- package/src/textures/Texture.js +3 -3
- package/src/textures/{Source.js → TextureSource.js} +39 -8
- package/build/three.core.min.js +0 -6
- package/build/three.module.min.js +0 -6
- package/build/three.tsl.min.js +0 -6
- package/build/three.webgpu.min.js +0 -6
- package/build/three.webgpu.nodes.min.js +0 -6
- package/examples/jsm/libs/ecsy.module.js +0 -1792
- package/examples/jsm/loaders/LottieLoader.js +0 -130
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +0 -52
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RenderTarget, Vector2, TempNode, QuadMesh, NodeMaterial, RendererUtils, MathUtils, RGBFormat, RedFormat, UnsignedInt101111Type, UnsignedByteType } from '@gnsx/three/webgpu';
|
|
2
|
-
import { clamp, normalize, reference, Fn, NodeUpdateType, uniform, vec4, passTexture, uv, logarithmicDepthToViewZ, viewZToPerspectiveDepth, getViewPosition, screenCoordinate, float, sub, fract, dot, vec2, rand, vec3, Loop, mul, PI, cos, sin, uint, cross, acos, sign, pow, luminance, If, max, abs, Break, sqrt, HALF_PI, div, ceil, shiftRight, convertToTexture, bool, getNormalFromDepth, countOneBits, interleavedGradientNoise, property, outputStruct } from '@gnsx/three/tsl';
|
|
2
|
+
import { clamp, normalize, reference, Fn, NodeUpdateType, uniform, vec4, passTexture, uv, logarithmicDepthToViewZ, viewZToPerspectiveDepth, getViewPosition, screenCoordinate, float, sub, fract, dot, vec2, rand, vec3, Loop, mul, PI, cos, sin, uint, cross, acos, sign, pow, luminance, If, max, abs, Break, sqrt, HALF_PI, div, ceil, shiftRight, convertToTexture, bool, getNormalFromDepth, countOneBits, interleavedGradientNoise, property, outputStruct, context } from '@gnsx/three/tsl';
|
|
3
3
|
|
|
4
4
|
const _quadMesh = /*@__PURE__*/ new QuadMesh();
|
|
5
5
|
const _size = /*@__PURE__*/ new Vector2();
|
|
@@ -648,7 +648,8 @@ class SSGINode extends TempNode {
|
|
|
648
648
|
|
|
649
649
|
} );
|
|
650
650
|
|
|
651
|
-
this._material.
|
|
651
|
+
this._material.contextNode = context( builder.getSharedContext() );
|
|
652
|
+
this._material.colorNode = gi();
|
|
652
653
|
this._material.outputNode = outputNode;
|
|
653
654
|
this._material.needsUpdate = true;
|
|
654
655
|
|
|
@@ -664,6 +665,8 @@ class SSGINode extends TempNode {
|
|
|
664
665
|
*/
|
|
665
666
|
dispose() {
|
|
666
667
|
|
|
668
|
+
super.dispose();
|
|
669
|
+
|
|
667
670
|
this._ssgiRenderTarget.dispose();
|
|
668
671
|
|
|
669
672
|
this._material.dispose();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Break, Continue, Fn, If, Loop, abs, bool, cross, distance, div, dot, float, getScreenPosition, getViewPosition, int, logarithmicDepthToViewZ, luminance, max, min, mix, mul, nodeObject, normalize, orthographicDepthToViewZ, passTexture, perspectiveDepthToViewZ, reference, reflect, sub, texture, trunc, uniform, uv, vec2, vec3, vec4, viewZToPerspectiveDepth } from '@gnsx/three/tsl';
|
|
1
|
+
import { Break, Continue, Fn, If, Loop, abs, bool, cross, distance, div, dot, float, getScreenPosition, getViewPosition, int, logarithmicDepthToViewZ, luminance, max, min, mix, mul, nodeObject, normalize, orthographicDepthToViewZ, passTexture, perspectiveDepthToViewZ, reference, reflect, sub, texture, trunc, uniform, uv, vec2, vec3, vec4, viewZToPerspectiveDepth, context } from '@gnsx/three/tsl';
|
|
2
2
|
import { HalfFloatType, LinearFilter, LinearMipmapLinearFilter, Matrix4, NodeMaterial, NodeUpdateType, QuadMesh, RenderTarget, RendererUtils, TempNode, Vector2, Vector3 } from '@gnsx/three/webgpu';
|
|
3
3
|
import { bindAnalyticNoise } from '../utils/RNoise.js';
|
|
4
4
|
import { ENV_RAY_LENGTH, getSpecularDominantFactor, ggxReflectionSample } from '../utils/SpecularHelpers.js';
|
|
@@ -625,7 +625,8 @@ class SSRNode extends TempNode {
|
|
|
625
625
|
|
|
626
626
|
if ( this._ssrFn === null ) return;
|
|
627
627
|
|
|
628
|
-
this._ssrMaterial.
|
|
628
|
+
this._ssrMaterial.contextNode = context( this._sharedContext );
|
|
629
|
+
this._ssrMaterial.fragmentNode = this._ssrFn();
|
|
629
630
|
this._ssrMaterial.needsUpdate = true;
|
|
630
631
|
|
|
631
632
|
}
|
|
@@ -953,6 +954,8 @@ class SSRNode extends TempNode {
|
|
|
953
954
|
|
|
954
955
|
sampleEnvReflection = () => {
|
|
955
956
|
|
|
957
|
+
if ( this._importanceEnvironment === null ) return vec3( 0 );
|
|
958
|
+
|
|
956
959
|
const envColor = vec3( 0 ).toVar();
|
|
957
960
|
|
|
958
961
|
if ( this.envImportanceSampling ) {
|
|
@@ -1314,6 +1317,8 @@ class SSRNode extends TempNode {
|
|
|
1314
1317
|
*/
|
|
1315
1318
|
dispose() {
|
|
1316
1319
|
|
|
1320
|
+
super.dispose();
|
|
1321
|
+
|
|
1317
1322
|
this._ssrRenderTarget.dispose();
|
|
1318
1323
|
this._blurRenderTarget.dispose();
|
|
1319
1324
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RedFormat, RenderTarget, Vector2, RendererUtils, QuadMesh, TempNode, NodeMaterial, NodeUpdateType, UnsignedByteType } from '@gnsx/three/webgpu';
|
|
2
|
-
import { reference, viewZToPerspectiveDepth, logarithmicDepthToViewZ, getScreenPosition, getViewPosition, float, Break, Loop, int, max, abs, If, interleavedGradientNoise, screenCoordinate, Fn, passTexture, uv, uniform, perspectiveDepthToViewZ, orthographicDepthToViewZ, vec2, lightPosition, lightTargetPosition, fract, rand, mix } from '@gnsx/three/tsl';
|
|
2
|
+
import { reference, viewZToPerspectiveDepth, logarithmicDepthToViewZ, getScreenPosition, getViewPosition, float, Break, Loop, int, max, abs, If, interleavedGradientNoise, screenCoordinate, Fn, passTexture, uv, uniform, perspectiveDepthToViewZ, orthographicDepthToViewZ, vec2, lightPosition, lightTargetPosition, fract, rand, mix, context } from '@gnsx/three/tsl';
|
|
3
3
|
|
|
4
4
|
const _quadMesh = /*@__PURE__*/ new QuadMesh();
|
|
5
5
|
const _size = /*@__PURE__*/ new Vector2();
|
|
@@ -454,7 +454,8 @@ class SSSNode extends TempNode {
|
|
|
454
454
|
|
|
455
455
|
} );
|
|
456
456
|
|
|
457
|
-
this._material.
|
|
457
|
+
this._material.contextNode = context( builder.getSharedContext() );
|
|
458
|
+
this._material.fragmentNode = sss();
|
|
458
459
|
this._material.needsUpdate = true;
|
|
459
460
|
|
|
460
461
|
return this._textureNode;
|
|
@@ -467,6 +468,8 @@ class SSSNode extends TempNode {
|
|
|
467
468
|
*/
|
|
468
469
|
dispose() {
|
|
469
470
|
|
|
471
|
+
super.dispose();
|
|
472
|
+
|
|
470
473
|
this._sssRenderTarget.dispose();
|
|
471
474
|
|
|
472
475
|
this._material.dispose();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HalfFloatType, RenderTarget, Vector2, NodeMaterial, RendererUtils, QuadMesh, TempNode, NodeUpdateType } from '@gnsx/three/webgpu';
|
|
2
|
-
import { Fn, float, vec3, vec4, ivec2, int, uv, floor, abs, max, min, exp2, nodeObject, passTexture, textureSize, textureLoad, convertToTexture } from '@gnsx/three/tsl';
|
|
2
|
+
import { Fn, float, vec3, vec4, ivec2, int, uv, floor, abs, max, min, exp2, nodeObject, passTexture, textureSize, textureLoad, convertToTexture, context } from '@gnsx/three/tsl';
|
|
3
3
|
|
|
4
4
|
const _quadMesh = /*@__PURE__*/ new QuadMesh();
|
|
5
5
|
const _size = /*@__PURE__*/ new Vector2();
|
|
@@ -236,10 +236,9 @@ class SharpenNode extends TempNode {
|
|
|
236
236
|
|
|
237
237
|
//
|
|
238
238
|
|
|
239
|
-
const context = builder.getSharedContext();
|
|
240
|
-
|
|
241
239
|
const material = this._material || ( this._material = new NodeMaterial() );
|
|
242
|
-
material.
|
|
240
|
+
material.contextNode = context( builder.getSharedContext() );
|
|
241
|
+
material.fragmentNode = rcas();
|
|
243
242
|
material.name = 'Sharpen_RCAS';
|
|
244
243
|
material.needsUpdate = true;
|
|
245
244
|
|
|
@@ -260,6 +259,8 @@ class SharpenNode extends TempNode {
|
|
|
260
259
|
*/
|
|
261
260
|
dispose() {
|
|
262
261
|
|
|
262
|
+
super.dispose();
|
|
263
|
+
|
|
263
264
|
this._renderTarget.dispose();
|
|
264
265
|
|
|
265
266
|
if ( this._material !== null ) this._material.dispose();
|
|
@@ -139,11 +139,9 @@ class StereoCompositePassNode extends PassNode {
|
|
|
139
139
|
|
|
140
140
|
//
|
|
141
141
|
|
|
142
|
-
this._pixelRatio = renderer.getPixelRatio();
|
|
143
|
-
|
|
144
142
|
this.updateStereoCamera( renderer.coordinateSystem );
|
|
145
143
|
|
|
146
|
-
const size = renderer.
|
|
144
|
+
const size = renderer.getDrawingBufferSize( _size );
|
|
147
145
|
this.setSize( size.width, size.height );
|
|
148
146
|
|
|
149
147
|
// left
|
|
@@ -61,13 +61,11 @@ class StereoPassNode extends PassNode {
|
|
|
61
61
|
|
|
62
62
|
//
|
|
63
63
|
|
|
64
|
-
this._pixelRatio = renderer.getPixelRatio();
|
|
65
|
-
|
|
66
64
|
stereo.cameraL.coordinateSystem = renderer.coordinateSystem;
|
|
67
65
|
stereo.cameraR.coordinateSystem = renderer.coordinateSystem;
|
|
68
66
|
stereo.update( camera );
|
|
69
67
|
|
|
70
|
-
const size = renderer.
|
|
68
|
+
const size = renderer.getDrawingBufferSize( _size );
|
|
71
69
|
this.setSize( size.width, size.height );
|
|
72
70
|
|
|
73
71
|
renderer.autoClear = false;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { HalfFloatType, Vector2, RenderTarget, RendererUtils, QuadMesh, NodeMaterial, TempNode, NodeUpdateType, Matrix4, DepthTexture } from '@gnsx/three/webgpu';
|
|
2
|
-
import {
|
|
1
|
+
import { HalfFloatType, Vector2, RenderTarget, RendererUtils, QuadMesh, NodeMaterial, TempNode, NodeUpdateType, Matrix4, DepthTexture, FloatType } from '@gnsx/three/webgpu';
|
|
2
|
+
import { exp, float, Fn, max, texture, uniform, uv, vec2, vec4, luminance, convertToTexture, passTexture, velocity, ivec2, mix, property, outputStruct, context, OnBeforeRenderPipeline, OnAfterRenderPipeline } from '@gnsx/three/tsl';
|
|
3
|
+
import { clipAABB, computeHaltonOffsets, flickerReduction, sampleCurrentDepth, samplePreviousDepth } from '../utils/TAAUtils.js';
|
|
3
4
|
|
|
4
5
|
const _quadMesh = /*@__PURE__*/ new QuadMesh();
|
|
5
6
|
const _size = /*@__PURE__*/ new Vector2();
|
|
@@ -367,7 +368,7 @@ class TAAUNode extends TempNode {
|
|
|
367
368
|
// update jitter index
|
|
368
369
|
|
|
369
370
|
this._jitterIndex ++;
|
|
370
|
-
this._jitterIndex = this._jitterIndex %
|
|
371
|
+
this._jitterIndex = this._jitterIndex % _haltonOffsets.length;
|
|
371
372
|
|
|
372
373
|
}
|
|
373
374
|
|
|
@@ -501,13 +502,13 @@ class TAAUNode extends TempNode {
|
|
|
501
502
|
*/
|
|
502
503
|
setup( builder ) {
|
|
503
504
|
|
|
504
|
-
|
|
505
|
+
if ( builder.renderPipeline && ! builder.context.renderPipelineState.viewOffsetOwner ) {
|
|
505
506
|
|
|
506
|
-
|
|
507
|
+
builder.context.renderPipelineState.viewOffsetOwner = this;
|
|
507
508
|
|
|
508
509
|
this._needsPostProcessingSync = true;
|
|
509
510
|
|
|
510
|
-
|
|
511
|
+
OnBeforeRenderPipeline( () => {
|
|
511
512
|
|
|
512
513
|
const beautyRenderTarget = ( this.beautyNode.isRTTNode ) ? this.beautyNode.renderTarget : this.beautyNode.passNode.renderTarget;
|
|
513
514
|
|
|
@@ -516,112 +517,21 @@ class TAAUNode extends TempNode {
|
|
|
516
517
|
|
|
517
518
|
this.setViewOffset( inputWidth, inputHeight );
|
|
518
519
|
|
|
519
|
-
};
|
|
520
|
+
} );
|
|
520
521
|
|
|
521
|
-
|
|
522
|
+
OnAfterRenderPipeline( () => {
|
|
522
523
|
|
|
523
524
|
this.clearViewOffset();
|
|
524
525
|
|
|
525
|
-
};
|
|
526
|
+
} );
|
|
526
527
|
|
|
527
528
|
}
|
|
528
529
|
|
|
529
|
-
|
|
530
|
+
if ( builder.renderer.reversedDepthBuffer === true ) {
|
|
530
531
|
|
|
531
|
-
|
|
532
|
-
closestPositionTexel: 'vec2',
|
|
533
|
-
farthestDepth: 'float',
|
|
532
|
+
this._previousDepthRenderTarget.depthTexture.type = FloatType;
|
|
534
533
|
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
// Samples 3×3 neighborhood pixels and returns the closest and farthest depths.
|
|
538
|
-
const sampleCurrentDepth = Fn( ( [ positionTexel ] ) => {
|
|
539
|
-
|
|
540
|
-
const closestDepth = float( 2 ).toVar();
|
|
541
|
-
const closestPositionTexel = vec2( 0 ).toVar();
|
|
542
|
-
const farthestDepth = float( - 1 ).toVar();
|
|
543
|
-
|
|
544
|
-
for ( let x = - 1; x <= 1; ++ x ) {
|
|
545
|
-
|
|
546
|
-
for ( let y = - 1; y <= 1; ++ y ) {
|
|
547
|
-
|
|
548
|
-
const neighbor = positionTexel.add( vec2( x, y ) ).toVar();
|
|
549
|
-
const depth = this.depthNode.load( neighbor ).r.toVar();
|
|
550
|
-
|
|
551
|
-
If( depth.lessThan( closestDepth ), () => {
|
|
552
|
-
|
|
553
|
-
closestDepth.assign( depth );
|
|
554
|
-
closestPositionTexel.assign( neighbor );
|
|
555
|
-
|
|
556
|
-
} );
|
|
557
|
-
|
|
558
|
-
If( depth.greaterThan( farthestDepth ), () => {
|
|
559
|
-
|
|
560
|
-
farthestDepth.assign( depth );
|
|
561
|
-
|
|
562
|
-
} );
|
|
563
|
-
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
return currentDepthStruct( closestDepth, closestPositionTexel, farthestDepth );
|
|
569
|
-
|
|
570
|
-
} );
|
|
571
|
-
|
|
572
|
-
// Samples a previous depth and reproject it using the current camera matrices.
|
|
573
|
-
const samplePreviousDepth = ( uv ) => {
|
|
574
|
-
|
|
575
|
-
const depth = this._previousDepthNode.sample( uv ).r;
|
|
576
|
-
const positionView = getViewPosition( uv, depth, this._previousCameraProjectionMatrixInverse );
|
|
577
|
-
const positionWorld = this._previousCameraWorldMatrix.mul( vec4( positionView, 1 ) ).xyz;
|
|
578
|
-
const viewZ = this._cameraWorldMatrixInverse.mul( vec4( positionWorld, 1 ) ).z;
|
|
579
|
-
return viewZToPerspectiveDepth( viewZ, this._cameraNearFar.x, this._cameraNearFar.y );
|
|
580
|
-
|
|
581
|
-
};
|
|
582
|
-
|
|
583
|
-
// Optimized version of AABB clipping.
|
|
584
|
-
// Reference: https://github.com/playdeadgames/temporal
|
|
585
|
-
const clipAABB = Fn( ( [ currentColor, historyColor, minColor, maxColor ] ) => {
|
|
586
|
-
|
|
587
|
-
const pClip = maxColor.rgb.add( minColor.rgb ).mul( 0.5 );
|
|
588
|
-
const eClip = maxColor.rgb.sub( minColor.rgb ).mul( 0.5 ).add( 1e-7 );
|
|
589
|
-
const vClip = historyColor.sub( vec4( pClip, currentColor.a ) );
|
|
590
|
-
const vUnit = vClip.xyz.div( eClip );
|
|
591
|
-
const absUnit = vUnit.abs();
|
|
592
|
-
const maxUnit = max( absUnit.x, absUnit.y, absUnit.z );
|
|
593
|
-
return maxUnit.greaterThan( 1 ).select(
|
|
594
|
-
vec4( pClip, currentColor.a ).add( vClip.div( maxUnit ) ),
|
|
595
|
-
historyColor
|
|
596
|
-
);
|
|
597
|
-
|
|
598
|
-
} ).setLayout( {
|
|
599
|
-
name: 'clipAABB',
|
|
600
|
-
type: 'vec4',
|
|
601
|
-
inputs: [
|
|
602
|
-
{ name: 'currentColor', type: 'vec4' },
|
|
603
|
-
{ name: 'historyColor', type: 'vec4' },
|
|
604
|
-
{ name: 'minColor', type: 'vec4' },
|
|
605
|
-
{ name: 'maxColor', type: 'vec4' }
|
|
606
|
-
]
|
|
607
|
-
} );
|
|
608
|
-
|
|
609
|
-
// Flicker reduction based on luminance weighing.
|
|
610
|
-
const flickerReduction = Fn( ( [ currentColor, historyColor, currentWeight ] ) => {
|
|
611
|
-
|
|
612
|
-
const historyWeight = currentWeight.oneMinus();
|
|
613
|
-
const compressedCurrent = currentColor.mul( float( 1 ).div( ( max( currentColor.r, currentColor.g, currentColor.b ).add( 1 ) ) ) );
|
|
614
|
-
const compressedHistory = historyColor.mul( float( 1 ).div( ( max( historyColor.r, historyColor.g, historyColor.b ).add( 1 ) ) ) );
|
|
615
|
-
|
|
616
|
-
const luminanceCurrent = luminance( compressedCurrent.rgb );
|
|
617
|
-
const luminanceHistory = luminance( compressedHistory.rgb );
|
|
618
|
-
|
|
619
|
-
currentWeight.mulAssign( float( 1 ).div( luminanceCurrent.add( 1 ) ) );
|
|
620
|
-
historyWeight.mulAssign( float( 1 ).div( luminanceHistory.add( 1 ) ) );
|
|
621
|
-
|
|
622
|
-
return add( currentColor.mul( currentWeight ), historyColor.mul( historyWeight ) ).div( max( currentWeight.add( historyWeight ), 0.00001 ) ).toVar();
|
|
623
|
-
|
|
624
|
-
} );
|
|
534
|
+
}
|
|
625
535
|
|
|
626
536
|
const historyNode = texture( this._historyRenderTarget.textures[ 0 ] );
|
|
627
537
|
const lockNode = texture( this._historyRenderTarget.textures[ 1 ] );
|
|
@@ -660,7 +570,7 @@ class TAAUNode extends TempNode {
|
|
|
660
570
|
|
|
661
571
|
// depth dilation around the closest input tap
|
|
662
572
|
|
|
663
|
-
const currentDepth = sampleCurrentDepth( closestTapF );
|
|
573
|
+
const currentDepth = sampleCurrentDepth( this.depthNode, closestTapF, this._cameraNearFar );
|
|
664
574
|
const closestDepth = currentDepth.get( 'closestDepth' );
|
|
665
575
|
const closestPositionTexel = currentDepth.get( 'closestPositionTexel' );
|
|
666
576
|
const farthestDepth = currentDepth.get( 'farthestDepth' );
|
|
@@ -669,7 +579,7 @@ class TAAUNode extends TempNode {
|
|
|
669
579
|
|
|
670
580
|
const offsetUV = this.velocityNode.load( closestPositionTexel ).xy.mul( vec2( 0.5, - 0.5 ) );
|
|
671
581
|
const historyUV = uvNode.sub( offsetUV );
|
|
672
|
-
const previousDepth = samplePreviousDepth( historyUV );
|
|
582
|
+
const previousDepth = samplePreviousDepth( this._previousDepthNode, historyUV, this._previousCameraProjectionMatrixInverse, this._previousCameraWorldMatrix, this._cameraWorldMatrixInverse, this._cameraNearFar, this.camera );
|
|
673
583
|
|
|
674
584
|
// history validity
|
|
675
585
|
|
|
@@ -763,6 +673,9 @@ class TAAUNode extends TempNode {
|
|
|
763
673
|
|
|
764
674
|
// materials
|
|
765
675
|
|
|
676
|
+
const sharedContext = context( builder.getSharedContext() );
|
|
677
|
+
|
|
678
|
+
this._resolveMaterial.contextNode = sharedContext;
|
|
766
679
|
this._resolveMaterial.colorNode = resolve();
|
|
767
680
|
this._resolveMaterial.outputNode = outputNode;
|
|
768
681
|
|
|
@@ -775,6 +688,7 @@ class TAAUNode extends TempNode {
|
|
|
775
688
|
|
|
776
689
|
} )();
|
|
777
690
|
|
|
691
|
+
this._seedMaterial.contextNode = sharedContext;
|
|
778
692
|
this._seedMaterial.outputNode = outputNode;
|
|
779
693
|
|
|
780
694
|
return this._textureNode;
|
|
@@ -787,6 +701,8 @@ class TAAUNode extends TempNode {
|
|
|
787
701
|
*/
|
|
788
702
|
dispose() {
|
|
789
703
|
|
|
704
|
+
super.dispose();
|
|
705
|
+
|
|
790
706
|
this._historyRenderTarget.dispose();
|
|
791
707
|
this._resolveRenderTarget.dispose();
|
|
792
708
|
this._previousDepthRenderTarget.dispose();
|
|
@@ -800,26 +716,7 @@ class TAAUNode extends TempNode {
|
|
|
800
716
|
|
|
801
717
|
export default TAAUNode;
|
|
802
718
|
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
let fraction = 1;
|
|
806
|
-
let result = 0;
|
|
807
|
-
while ( index > 0 ) {
|
|
808
|
-
|
|
809
|
-
fraction /= base;
|
|
810
|
-
result += fraction * ( index % base );
|
|
811
|
-
index = Math.floor( index / base );
|
|
812
|
-
|
|
813
|
-
}
|
|
814
|
-
|
|
815
|
-
return result;
|
|
816
|
-
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
const _haltonOffsets = /*@__PURE__*/ Array.from(
|
|
820
|
-
{ length: 32 },
|
|
821
|
-
( _, index ) => [ _halton( index + 1, 2 ), _halton( index + 1, 3 ) ]
|
|
822
|
-
);
|
|
719
|
+
const _haltonOffsets = /*@__PURE__*/ computeHaltonOffsets( 32 );
|
|
823
720
|
|
|
824
721
|
/**
|
|
825
722
|
* TSL function for creating a TAAU node for Temporal Anti-Aliasing Upscaling.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { HalfFloatType, Vector2, RenderTarget, RendererUtils, QuadMesh, NodeMaterial, TempNode, NodeUpdateType, Matrix4, DepthTexture, FloatType } from '@gnsx/three/webgpu';
|
|
2
|
-
import {
|
|
2
|
+
import { float, Fn, max, texture, uniform, uv, vec2, convertToTexture, passTexture, velocity, ivec2, mix, context, OnBeforeRenderPipeline, OnAfterRenderPipeline } from '@gnsx/three/tsl';
|
|
3
|
+
import { clipAABB, computeHaltonOffsets, flickerReduction, sampleCurrentDepth, samplePreviousDepth } from '../utils/TAAUtils.js';
|
|
3
4
|
|
|
4
5
|
const _quadMesh = /*@__PURE__*/ new QuadMesh();
|
|
5
6
|
const _size = /*@__PURE__*/ new Vector2();
|
|
@@ -334,7 +335,7 @@ class TRAANode extends TempNode {
|
|
|
334
335
|
// update jitter index
|
|
335
336
|
|
|
336
337
|
this._jitterIndex ++;
|
|
337
|
-
this._jitterIndex = this._jitterIndex %
|
|
338
|
+
this._jitterIndex = this._jitterIndex % _haltonOffsets.length;
|
|
338
339
|
|
|
339
340
|
}
|
|
340
341
|
|
|
@@ -442,24 +443,24 @@ class TRAANode extends TempNode {
|
|
|
442
443
|
*/
|
|
443
444
|
setup( builder ) {
|
|
444
445
|
|
|
445
|
-
|
|
446
|
+
if ( builder.renderPipeline && ! builder.context.renderPipelineState.viewOffsetOwner ) {
|
|
446
447
|
|
|
447
|
-
|
|
448
|
+
builder.context.renderPipelineState.viewOffsetOwner = this;
|
|
448
449
|
|
|
449
450
|
this._needsPostProcessingSync = true;
|
|
450
451
|
|
|
451
|
-
|
|
452
|
+
OnBeforeRenderPipeline( () => {
|
|
452
453
|
|
|
453
454
|
const size = builder.renderer.getDrawingBufferSize( _size );
|
|
454
455
|
this.setViewOffset( size.width, size.height );
|
|
455
456
|
|
|
456
|
-
};
|
|
457
|
+
} );
|
|
457
458
|
|
|
458
|
-
|
|
459
|
+
OnAfterRenderPipeline( () => {
|
|
459
460
|
|
|
460
461
|
this.clearViewOffset();
|
|
461
462
|
|
|
462
|
-
};
|
|
463
|
+
} );
|
|
463
464
|
|
|
464
465
|
}
|
|
465
466
|
|
|
@@ -479,100 +480,6 @@ class TRAANode extends TempNode {
|
|
|
479
480
|
|
|
480
481
|
}
|
|
481
482
|
|
|
482
|
-
const logarithmicToPerspectiveDepth = ( depth ) => {
|
|
483
|
-
|
|
484
|
-
const { x: near, y: far } = this._cameraNearFar;
|
|
485
|
-
const viewZ = logarithmicDepthToViewZ( depth, near, far );
|
|
486
|
-
return viewZToPerspectiveDepth( viewZ, near, far );
|
|
487
|
-
|
|
488
|
-
};
|
|
489
|
-
|
|
490
|
-
const currentDepthStruct = struct( {
|
|
491
|
-
|
|
492
|
-
closestDepth: 'float',
|
|
493
|
-
closestPositionTexel: 'vec2',
|
|
494
|
-
farthestDepth: 'float',
|
|
495
|
-
|
|
496
|
-
} );
|
|
497
|
-
|
|
498
|
-
// Samples 3×3 neighborhood pixels and returns the closest and farthest depths.
|
|
499
|
-
const sampleCurrentDepth = Fn( ( [ positionTexel ] ) => {
|
|
500
|
-
|
|
501
|
-
const closestDepth = float( 2 ).toVar();
|
|
502
|
-
const closestPositionTexel = vec2( 0 ).toVar();
|
|
503
|
-
const farthestDepth = float( - 1 ).toVar();
|
|
504
|
-
|
|
505
|
-
for ( let x = - 1; x <= 1; ++ x ) {
|
|
506
|
-
|
|
507
|
-
for ( let y = - 1; y <= 1; ++ y ) {
|
|
508
|
-
|
|
509
|
-
const neighbor = positionTexel.add( vec2( x, y ) ).toVar();
|
|
510
|
-
let depth = this.depthNode.load( neighbor ).r;
|
|
511
|
-
if ( builder.renderer.reversedDepthBuffer ) depth = depth.oneMinus();
|
|
512
|
-
if ( builder.renderer.logarithmicDepthBuffer ) depth = logarithmicToPerspectiveDepth( depth );
|
|
513
|
-
depth = depth.toVar();
|
|
514
|
-
|
|
515
|
-
If( depth.lessThan( closestDepth ), () => {
|
|
516
|
-
|
|
517
|
-
closestDepth.assign( depth );
|
|
518
|
-
closestPositionTexel.assign( neighbor );
|
|
519
|
-
|
|
520
|
-
} );
|
|
521
|
-
|
|
522
|
-
If( depth.greaterThan( farthestDepth ), () => {
|
|
523
|
-
|
|
524
|
-
farthestDepth.assign( depth );
|
|
525
|
-
|
|
526
|
-
} );
|
|
527
|
-
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
return currentDepthStruct( closestDepth, closestPositionTexel, farthestDepth );
|
|
533
|
-
|
|
534
|
-
} );
|
|
535
|
-
|
|
536
|
-
// Samples a previous depth and reproject it using the current camera matrices.
|
|
537
|
-
const samplePreviousDepth = ( uv ) => {
|
|
538
|
-
|
|
539
|
-
let depth = this._previousDepthNode.sample( uv ).r;
|
|
540
|
-
if ( builder.renderer.logarithmicDepthBuffer ) depth = logarithmicToPerspectiveDepth( depth );
|
|
541
|
-
const positionView = getViewPosition( uv, depth, this._previousCameraProjectionMatrixInverse );
|
|
542
|
-
const positionWorld = this._previousCameraWorldMatrix.mul( vec4( positionView, 1 ) ).xyz;
|
|
543
|
-
const viewZ = this._cameraWorldMatrixInverse.mul( vec4( positionWorld, 1 ) ).z;
|
|
544
|
-
return this.camera.isOrthographicCamera
|
|
545
|
-
? viewZToOrthographicDepth( viewZ, this._cameraNearFar.x, this._cameraNearFar.y )
|
|
546
|
-
: viewZToPerspectiveDepth( viewZ, this._cameraNearFar.x, this._cameraNearFar.y );
|
|
547
|
-
|
|
548
|
-
};
|
|
549
|
-
|
|
550
|
-
// Optimized version of AABB clipping.
|
|
551
|
-
// Reference: https://github.com/playdeadgames/temporal
|
|
552
|
-
const clipAABB = Fn( ( [ currentColor, historyColor, minColor, maxColor ] ) => {
|
|
553
|
-
|
|
554
|
-
const pClip = maxColor.rgb.add( minColor.rgb ).mul( 0.5 );
|
|
555
|
-
const eClip = maxColor.rgb.sub( minColor.rgb ).mul( 0.5 ).add( 1e-7 );
|
|
556
|
-
const vClip = historyColor.sub( vec4( pClip, currentColor.a ) );
|
|
557
|
-
const vUnit = vClip.xyz.div( eClip );
|
|
558
|
-
const absUnit = vUnit.abs();
|
|
559
|
-
const maxUnit = max( absUnit.x, absUnit.y, absUnit.z );
|
|
560
|
-
return maxUnit.greaterThan( 1 ).select(
|
|
561
|
-
vec4( pClip, currentColor.a ).add( vClip.div( maxUnit ) ),
|
|
562
|
-
historyColor
|
|
563
|
-
);
|
|
564
|
-
|
|
565
|
-
} ).setLayout( {
|
|
566
|
-
name: 'clipAABB',
|
|
567
|
-
type: 'vec4',
|
|
568
|
-
inputs: [
|
|
569
|
-
{ name: 'currentColor', type: 'vec4' },
|
|
570
|
-
{ name: 'historyColor', type: 'vec4' },
|
|
571
|
-
{ name: 'minColor', type: 'vec4' },
|
|
572
|
-
{ name: 'maxColor', type: 'vec4' }
|
|
573
|
-
]
|
|
574
|
-
} );
|
|
575
|
-
|
|
576
483
|
// Performs variance clipping.
|
|
577
484
|
// See: https://developer.download.nvidia.com/gameworks/events/GDC2016/msalvi_temporal_supersampling.pdf
|
|
578
485
|
const varianceClipping = Fn( ( [ positionTexel, currentColor, historyColor, gamma ] ) => {
|
|
@@ -627,23 +534,6 @@ class TRAANode extends TempNode {
|
|
|
627
534
|
]
|
|
628
535
|
} );
|
|
629
536
|
|
|
630
|
-
// Flicker reduction based on luminance weighing.
|
|
631
|
-
const flickerReduction = Fn( ( [ currentColor, historyColor, currentWeight ] ) => {
|
|
632
|
-
|
|
633
|
-
const historyWeight = currentWeight.oneMinus();
|
|
634
|
-
const compressedCurrent = currentColor.mul( float( 1 ).div( ( max( currentColor.r, currentColor.g, currentColor.b ).add( 1 ) ) ) );
|
|
635
|
-
const compressedHistory = historyColor.mul( float( 1 ).div( ( max( historyColor.r, historyColor.g, historyColor.b ).add( 1 ) ) ) );
|
|
636
|
-
|
|
637
|
-
const luminanceCurrent = luminance( compressedCurrent.rgb );
|
|
638
|
-
const luminanceHistory = luminance( compressedHistory.rgb );
|
|
639
|
-
|
|
640
|
-
currentWeight.mulAssign( float( 1 ).div( luminanceCurrent.add( 1 ) ) );
|
|
641
|
-
historyWeight.mulAssign( float( 1 ).div( luminanceHistory.add( 1 ) ) );
|
|
642
|
-
|
|
643
|
-
return add( currentColor.mul( currentWeight ), historyColor.mul( historyWeight ) ).div( max( currentWeight.add( historyWeight ), 0.00001 ) ).toVar();
|
|
644
|
-
|
|
645
|
-
} );
|
|
646
|
-
|
|
647
537
|
const historyNode = texture( this._historyRenderTarget.texture );
|
|
648
538
|
|
|
649
539
|
const resolve = Fn( () => {
|
|
@@ -654,7 +544,7 @@ class TRAANode extends TempNode {
|
|
|
654
544
|
|
|
655
545
|
// sample the closest and farthest depths in the current buffer
|
|
656
546
|
|
|
657
|
-
const currentDepth = sampleCurrentDepth( positionTexel );
|
|
547
|
+
const currentDepth = sampleCurrentDepth( this.depthNode, positionTexel, this._cameraNearFar );
|
|
658
548
|
const closestDepth = currentDepth.get( 'closestDepth' );
|
|
659
549
|
const closestPositionTexel = currentDepth.get( 'closestPositionTexel' );
|
|
660
550
|
const farthestDepth = currentDepth.get( 'farthestDepth' );
|
|
@@ -666,7 +556,7 @@ class TRAANode extends TempNode {
|
|
|
666
556
|
// sample the previous depth
|
|
667
557
|
|
|
668
558
|
const historyUV = uvNode.sub( offsetUV );
|
|
669
|
-
const previousDepth = samplePreviousDepth( historyUV );
|
|
559
|
+
const previousDepth = samplePreviousDepth( this._previousDepthNode, historyUV, this._previousCameraProjectionMatrixInverse, this._previousCameraWorldMatrix, this._cameraWorldMatrixInverse, this._cameraNearFar, this.camera );
|
|
670
560
|
|
|
671
561
|
// history is considered valid when the UV is in range and there's no disocclusion except on edges
|
|
672
562
|
|
|
@@ -678,7 +568,7 @@ class TRAANode extends TempNode {
|
|
|
678
568
|
// sample the current and previous colors
|
|
679
569
|
|
|
680
570
|
const currentColor = this.beautyNode.sample( uvNode );
|
|
681
|
-
const historyColor = historyNode.sample(
|
|
571
|
+
const historyColor = historyNode.sample( historyUV );
|
|
682
572
|
|
|
683
573
|
// increase the weight towards the current frame under motion
|
|
684
574
|
|
|
@@ -709,6 +599,7 @@ class TRAANode extends TempNode {
|
|
|
709
599
|
|
|
710
600
|
// materials
|
|
711
601
|
|
|
602
|
+
this._resolveMaterial.contextNode = context( builder.getSharedContext() );
|
|
712
603
|
this._resolveMaterial.colorNode = resolve();
|
|
713
604
|
|
|
714
605
|
return this._textureNode;
|
|
@@ -721,6 +612,8 @@ class TRAANode extends TempNode {
|
|
|
721
612
|
*/
|
|
722
613
|
dispose() {
|
|
723
614
|
|
|
615
|
+
super.dispose();
|
|
616
|
+
|
|
724
617
|
this._historyRenderTarget.dispose();
|
|
725
618
|
this._resolveRenderTarget.dispose();
|
|
726
619
|
|
|
@@ -732,26 +625,7 @@ class TRAANode extends TempNode {
|
|
|
732
625
|
|
|
733
626
|
export default TRAANode;
|
|
734
627
|
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
let fraction = 1;
|
|
738
|
-
let result = 0;
|
|
739
|
-
while ( index > 0 ) {
|
|
740
|
-
|
|
741
|
-
fraction /= base;
|
|
742
|
-
result += fraction * ( index % base );
|
|
743
|
-
index = Math.floor( index / base );
|
|
744
|
-
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
return result;
|
|
748
|
-
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
const _haltonOffsets = /*@__PURE__*/ Array.from(
|
|
752
|
-
{ length: 32 },
|
|
753
|
-
( _, index ) => [ _halton( index + 1, 2 ), _halton( index + 1, 3 ) ]
|
|
754
|
-
);
|
|
628
|
+
const _haltonOffsets = /*@__PURE__*/ computeHaltonOffsets( 32 );
|
|
755
629
|
|
|
756
630
|
/**
|
|
757
631
|
* TSL function for creating a TRAA node for Temporal Reprojection Anti-Aliasing.
|