@gnsx/three 0.185.16 → 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 +1309 -807
- 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/src/utils.js +6 -79
- 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
|
@@ -25,9 +25,9 @@ import {
|
|
|
25
25
|
* sky.scale.setScalar( 10000 );
|
|
26
26
|
* scene.add( sky );
|
|
27
27
|
* ```
|
|
28
|
-
*
|
|
28
|
+
*
|
|
29
29
|
* It can be useful to hide the sun disc when generating an environment map to avoid artifacts
|
|
30
|
-
*
|
|
30
|
+
*
|
|
31
31
|
* ```js
|
|
32
32
|
* // disable before rendering environment map
|
|
33
33
|
* sky.material.uniforms.showSunDisc.value = false;
|
|
@@ -82,9 +82,8 @@ Sky.SkyShader = {
|
|
|
82
82
|
'mieCoefficient': { value: 0.005 },
|
|
83
83
|
'mieDirectionalG': { value: 0.8 },
|
|
84
84
|
'sunPosition': { value: new Vector3() },
|
|
85
|
-
'up': { value: new Vector3( 0, 1, 0 ) },
|
|
86
85
|
'cloudScale': { value: 0.0002 },
|
|
87
|
-
'cloudSpeed': { value: 0.
|
|
86
|
+
'cloudSpeed': { value: 0.00002 },
|
|
88
87
|
'cloudCoverage': { value: 0.4 },
|
|
89
88
|
'cloudDensity': { value: 0.4 },
|
|
90
89
|
'cloudElevation': { value: 0.5 },
|
|
@@ -97,7 +96,6 @@ Sky.SkyShader = {
|
|
|
97
96
|
uniform float rayleigh;
|
|
98
97
|
uniform float turbidity;
|
|
99
98
|
uniform float mieCoefficient;
|
|
100
|
-
uniform vec3 up;
|
|
101
99
|
|
|
102
100
|
varying vec3 vWorldPosition;
|
|
103
101
|
varying vec3 vSunDirection;
|
|
@@ -149,7 +147,7 @@ Sky.SkyShader = {
|
|
|
149
147
|
|
|
150
148
|
vSunDirection = normalize( sunPosition );
|
|
151
149
|
|
|
152
|
-
vSunE = sunIntensity(
|
|
150
|
+
vSunE = sunIntensity( vSunDirection.y );
|
|
153
151
|
|
|
154
152
|
vSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 );
|
|
155
153
|
|
|
@@ -172,7 +170,6 @@ Sky.SkyShader = {
|
|
|
172
170
|
varying float vSunE;
|
|
173
171
|
|
|
174
172
|
uniform float mieDirectionalG;
|
|
175
|
-
uniform vec3 up;
|
|
176
173
|
uniform float cloudScale;
|
|
177
174
|
uniform float cloudSpeed;
|
|
178
175
|
uniform float cloudCoverage;
|
|
@@ -181,31 +178,35 @@ Sky.SkyShader = {
|
|
|
181
178
|
uniform float showSunDisc;
|
|
182
179
|
uniform float time;
|
|
183
180
|
|
|
184
|
-
//
|
|
185
|
-
|
|
186
|
-
|
|
181
|
+
// gradient at a lattice corner; sinless hash so every GPU produces the same clouds
|
|
182
|
+
vec2 gradient( vec2 i ) {
|
|
183
|
+
vec3 p = fract( i.xyx * vec3( 0.1031, 0.1030, 0.0973 ) );
|
|
184
|
+
p += dot( p, p.yzx + 33.33 );
|
|
185
|
+
return fract( ( p.xx + p.yz ) * p.zy ) * 2.0 - 1.0;
|
|
187
186
|
}
|
|
188
187
|
|
|
188
|
+
// 2D gradient noise: isotropic lobes like Perlin at value-noise cost
|
|
189
189
|
float noise( vec2 p ) {
|
|
190
190
|
vec2 i = floor( p );
|
|
191
191
|
vec2 f = fract( p );
|
|
192
|
-
|
|
193
|
-
float a =
|
|
194
|
-
float b =
|
|
195
|
-
float c =
|
|
196
|
-
float d =
|
|
197
|
-
return mix( mix( a, b,
|
|
192
|
+
vec2 u = f * f * f * ( f * ( f * 6.0 - 15.0 ) + 10.0 ); // quintic fade
|
|
193
|
+
float a = dot( gradient( i ), f );
|
|
194
|
+
float b = dot( gradient( i + vec2( 1.0, 0.0 ) ), f - vec2( 1.0, 0.0 ) );
|
|
195
|
+
float c = dot( gradient( i + vec2( 0.0, 1.0 ) ), f - vec2( 0.0, 1.0 ) );
|
|
196
|
+
float d = dot( gradient( i + vec2( 1.0, 1.0 ) ), f - vec2( 1.0, 1.0 ) );
|
|
197
|
+
return mix( mix( a, b, u.x ), mix( c, d, u.x ), u.y ) * 1.6; // ~[-1,1]
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
float
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
p
|
|
200
|
+
// fbm; per-octave drift makes clouds billow instead of scrolling as a rigid stamp
|
|
201
|
+
float fbm( vec2 p, float drift ) {
|
|
202
|
+
float result = 0.0;
|
|
203
|
+
float amplitude = 1.0;
|
|
204
|
+
for ( int i = 0; i < 4; i ++ ) {
|
|
205
|
+
result += amplitude * noise( p );
|
|
206
206
|
amplitude *= 0.5;
|
|
207
|
+
p = p * 2.0 + drift;
|
|
207
208
|
}
|
|
208
|
-
return
|
|
209
|
+
return result;
|
|
209
210
|
}
|
|
210
211
|
|
|
211
212
|
// constants for atmospheric scattering
|
|
@@ -241,7 +242,7 @@ Sky.SkyShader = {
|
|
|
241
242
|
|
|
242
243
|
// optical length
|
|
243
244
|
// cutoff angle at 90 to avoid singularity in next formula.
|
|
244
|
-
float zenithAngle = acos( max( 0.0,
|
|
245
|
+
float zenithAngle = acos( max( 0.0, direction.y ) );
|
|
245
246
|
float inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) );
|
|
246
247
|
float sR = rayleighZenithLength * inverse;
|
|
247
248
|
float sM = mieZenithLength * inverse;
|
|
@@ -259,7 +260,7 @@ Sky.SkyShader = {
|
|
|
259
260
|
vec3 betaMTheta = vBetaM * mPhase;
|
|
260
261
|
|
|
261
262
|
vec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) );
|
|
262
|
-
Lin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 -
|
|
263
|
+
Lin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - vSunDirection.y, 5.0 ), 0.0, 1.0 ) );
|
|
263
264
|
|
|
264
265
|
// nightsky
|
|
265
266
|
float theta = acos( direction.y ); // elevation --> y-axis, [-pi/2, pi/2]
|
|
@@ -268,10 +269,10 @@ Sky.SkyShader = {
|
|
|
268
269
|
vec3 L0 = vec3( 0.1 ) * Fex;
|
|
269
270
|
|
|
270
271
|
// composition + solar disc
|
|
271
|
-
float sundisc =
|
|
272
|
-
|
|
272
|
+
float sundisc = clamp( ( cosTheta - sunAngularDiameterCos ) * 50000.0, 0.0, 1.0 ) * showSunDisc;
|
|
273
|
+
vec3 sundiscColor = ( 760.0 * sundisc ) * min( vSunE * Fex, 80.0 );
|
|
273
274
|
|
|
274
|
-
vec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );
|
|
275
|
+
vec3 texColor = ( Lin + L0 ) * 0.04 + sundiscColor + vec3( 0.0, 0.0003, 0.00075 );
|
|
275
276
|
|
|
276
277
|
// Clouds
|
|
277
278
|
if ( direction.y > 0.0 && cloudCoverage > 0.0 ) {
|
|
@@ -282,30 +283,50 @@ Sky.SkyShader = {
|
|
|
282
283
|
cloudUV *= cloudScale;
|
|
283
284
|
cloudUV += time * cloudSpeed;
|
|
284
285
|
|
|
285
|
-
//
|
|
286
|
-
float
|
|
287
|
-
cloudNoise
|
|
288
|
-
cloudNoise = cloudNoise * 0.5 + 0.5;
|
|
286
|
+
// Cloud density field
|
|
287
|
+
float evolve = time * cloudSpeed * 300.0;
|
|
288
|
+
float cloudNoise = clamp( fbm( cloudUV * 1000.0, evolve ) * 0.7 + 0.5, 0.0, 1.0 );
|
|
289
289
|
|
|
290
|
-
//
|
|
291
|
-
float
|
|
290
|
+
// Large-scale coverage variation: clear gaps next to dense banks
|
|
291
|
+
float region = noise( cloudUV * 300.0 ) * 0.37 + 0.5;
|
|
292
|
+
float cov = clamp( cloudCoverage + ( region - 0.5 ) * 0.6, 0.0, 1.0 );
|
|
293
|
+
|
|
294
|
+
// Carve clouds where noise rises above the coverage level
|
|
295
|
+
float threshold = 1.0 - cov;
|
|
296
|
+
float cloudMask = smoothstep( threshold, threshold + 0.3, cloudNoise );
|
|
292
297
|
|
|
293
298
|
// Fade clouds near horizon (adjusted by elevation)
|
|
294
|
-
float horizonFade = smoothstep( 0.0, 0.
|
|
299
|
+
float horizonFade = smoothstep( 0.0, 0.03 + 0.06 * cloudElevation, direction.y );
|
|
295
300
|
cloudMask *= horizonFade;
|
|
296
301
|
|
|
297
|
-
// Cloud lighting
|
|
298
|
-
float
|
|
299
|
-
|
|
302
|
+
// Cloud lighting from the sky's own radiance
|
|
303
|
+
float dayFactor = smoothstep( -0.08, 0.3, vSunDirection.y );
|
|
304
|
+
vec3 sunColor = vSunE * Fex * 0.22 * 0.04; // 0.22 ~ albedo/pi, 0.04 = exposure; the aerial composite adds the eye-leg extinction
|
|
305
|
+
vec3 skyAmbient = Lin * 0.04 + vec3( 0.0, 0.0003, 0.00075 );
|
|
306
|
+
|
|
307
|
+
// Beer-powder self-shadow from the sampled density
|
|
308
|
+
float depth = max( 0.0, cloudNoise - threshold );
|
|
309
|
+
float beer = exp( depth * -4.0 );
|
|
310
|
+
float powder = 1.0 - beer * beer; // beer*beer == exp(-8*depth)
|
|
311
|
+
float shade = mix( 0.45, 1.0, clamp( beer * powder * 2.6, 0.0, 1.0 ) ); // 2.6 = 1/0.385, normalizes beer*powder peak to 1
|
|
312
|
+
|
|
313
|
+
// Henyey-Greenstein forward lobe ( g = 0.7 ): silver lining on rims toward the sun
|
|
314
|
+
float silver = clamp( 0.51 / pow( 1.49 - cosTheta * 1.4, 1.5 ), 0.0, 3.0 ); // 0.51=1-g^2, 1.49=1+g^2, 1.4=2g
|
|
315
|
+
float edge = cloudMask * ( 1.0 - cloudMask ) * 4.0;
|
|
316
|
+
|
|
317
|
+
vec3 cloudColor = skyAmbient + sunColor * shade;
|
|
318
|
+
cloudColor += sunColor * silver * edge * 0.6;
|
|
319
|
+
cloudColor *= max( dayFactor, 0.03 );
|
|
320
|
+
|
|
321
|
+
// Cloud opacity via Beer's law: density sets how solid the clouds get
|
|
322
|
+
float alpha = ( 1.0 - exp( depth * cloudDensity * -12.0 ) ) * horizonFade;
|
|
300
323
|
|
|
301
|
-
//
|
|
302
|
-
|
|
303
|
-
vec3 cloudColor = mix( vec3( 0.3 ), vec3( 1.0 ), daylight );
|
|
304
|
-
cloudColor = mix( cloudColor, atmosphereColor + vec3( 1.0 ), sunInfluence * 0.5 );
|
|
305
|
-
cloudColor *= vSunE * 0.00002;
|
|
324
|
+
// Occlude the sun disc/glow behind opaque cloud
|
|
325
|
+
texColor -= L0 * 0.04 * alpha;
|
|
306
326
|
|
|
307
|
-
//
|
|
308
|
-
|
|
327
|
+
// Composite through the atmosphere so distant clouds dissolve into haze
|
|
328
|
+
vec3 cloudAerial = mix( texColor, cloudColor, Fex );
|
|
329
|
+
texColor = mix( texColor, cloudAerial, alpha );
|
|
309
330
|
|
|
310
331
|
}
|
|
311
332
|
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
NodeMaterial
|
|
7
7
|
} from '@gnsx/three/webgpu';
|
|
8
8
|
|
|
9
|
-
import { Fn, float, vec2, vec3, acos, add, mul, clamp, cos, dot, exp, max, mix, modelViewProjection, normalize, positionWorld, pow, smoothstep, sub, varyingProperty, vec4, uniform, cameraPosition,
|
|
9
|
+
import { Fn, float, floor, fract, vec2, vec3, acos, add, mul, clamp, cos, dot, exp, max, min, mix, modelViewProjection, normalize, positionWorld, pow, smoothstep, sub, varyingProperty, vec4, uniform, cameraPosition, time, If, Loop } from '@gnsx/three/tsl';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Represents a skydome for scene backgrounds. Based on [A Practical Analytic Model for Daylight](https://www.researchgate.net/publication/220720443_A_Practical_Analytic_Model_for_Daylight)
|
|
@@ -27,7 +27,7 @@ import { Fn, float, vec2, vec3, acos, add, mul, clamp, cos, dot, exp, max, mix,
|
|
|
27
27
|
* ```
|
|
28
28
|
*
|
|
29
29
|
* It can be useful to hide the sun disc when generating an environment map to avoid artifacts
|
|
30
|
-
*
|
|
30
|
+
*
|
|
31
31
|
* ```js
|
|
32
32
|
* // disable before rendering environment map
|
|
33
33
|
* sky.showSunDisc.value = false;
|
|
@@ -85,13 +85,6 @@ class SkyMesh extends Mesh {
|
|
|
85
85
|
*/
|
|
86
86
|
this.sunPosition = uniform( new Vector3() );
|
|
87
87
|
|
|
88
|
-
/**
|
|
89
|
-
* The up position.
|
|
90
|
-
*
|
|
91
|
-
* @type {UniformNode<vec3>}
|
|
92
|
-
*/
|
|
93
|
-
this.upUniform = uniform( new Vector3( 0, 1, 0 ) );
|
|
94
|
-
|
|
95
88
|
/**
|
|
96
89
|
* The cloud scale uniform.
|
|
97
90
|
*
|
|
@@ -104,7 +97,7 @@ class SkyMesh extends Mesh {
|
|
|
104
97
|
*
|
|
105
98
|
* @type {UniformNode<float>}
|
|
106
99
|
*/
|
|
107
|
-
this.cloudSpeed = uniform( 0.
|
|
100
|
+
this.cloudSpeed = uniform( 0.00002 );
|
|
108
101
|
|
|
109
102
|
/**
|
|
110
103
|
* The cloud coverage uniform.
|
|
@@ -192,7 +185,7 @@ class SkyMesh extends Mesh {
|
|
|
192
185
|
|
|
193
186
|
// varying sun intensity
|
|
194
187
|
|
|
195
|
-
const angle =
|
|
188
|
+
const angle = sunDirection.y;
|
|
196
189
|
const zenithAngleCos = clamp( angle, - 1, 1 );
|
|
197
190
|
const sunIntensity = EE.mul( max( 0.0, float( 1.0 ).sub( pow( e, cutoffAngle.sub( acos( zenithAngleCos ) ).div( steepness ).negate() ) ) ) );
|
|
198
191
|
vSunE.assign( sunIntensity );
|
|
@@ -247,7 +240,7 @@ class SkyMesh extends Mesh {
|
|
|
247
240
|
|
|
248
241
|
// optical length
|
|
249
242
|
// cutoff angle at 90 to avoid singularity in next formula.
|
|
250
|
-
const zenithAngle = acos( max( 0.0,
|
|
243
|
+
const zenithAngle = acos( max( 0.0, direction.y ) );
|
|
251
244
|
const inverse = float( 1.0 ).div( cos( zenithAngle ).add( float( 0.15 ).mul( pow( float( 93.885 ).sub( zenithAngle.mul( 180.0 ).div( pi ) ), - 1.253 ) ) ) );
|
|
252
245
|
const sR = rayleighZenithLength.mul( inverse );
|
|
253
246
|
const sM = mieZenithLength.mul( inverse );
|
|
@@ -272,56 +265,60 @@ class SkyMesh extends Mesh {
|
|
|
272
265
|
const betaMTheta = vBetaM.mul( mPhase );
|
|
273
266
|
|
|
274
267
|
const Lin = pow( vSunE.mul( add( betaRTheta, betaMTheta ).div( add( vBetaR, vBetaM ) ) ).mul( sub( 1.0, Fex ) ), vec3( 1.5 ) );
|
|
275
|
-
Lin.mulAssign( mix( vec3( 1.0 ), pow( vSunE.mul( add( betaRTheta, betaMTheta ).div( add( vBetaR, vBetaM ) ) ).mul( Fex ), vec3( 1.0 / 2.0 ) ), clamp( pow( sub( 1.0,
|
|
268
|
+
Lin.mulAssign( mix( vec3( 1.0 ), pow( vSunE.mul( add( betaRTheta, betaMTheta ).div( add( vBetaR, vBetaM ) ) ).mul( Fex ), vec3( 1.0 / 2.0 ) ), clamp( pow( sub( 1.0, vSunDirection.y ), 5.0 ), 0.0, 1.0 ) ) );
|
|
276
269
|
|
|
277
270
|
// nightsky
|
|
278
271
|
|
|
279
272
|
const L0 = vec3( 0.1 ).mul( Fex );
|
|
280
273
|
|
|
281
274
|
// composition + solar disc
|
|
282
|
-
const sundisc =
|
|
283
|
-
|
|
275
|
+
const sundisc = clamp( cosTheta.sub( sunAngularDiameterCos ).mul( 50000.0 ), 0.0, 1.0 ).mul( this.showSunDisc );
|
|
276
|
+
const sundiscColor = min( vSunE.mul( Fex ), 80.0 ).mul( 760.0 ).mul( sundisc );
|
|
284
277
|
|
|
285
|
-
const texColor = add( Lin, L0 ).mul( 0.04 ).add( vec3( 0.0, 0.0003, 0.00075 ) ).toVar();
|
|
278
|
+
const texColor = add( Lin, L0 ).mul( 0.04 ).add( sundiscColor ).add( vec3( 0.0, 0.0003, 0.00075 ) ).toVar();
|
|
286
279
|
|
|
287
|
-
//
|
|
288
|
-
const
|
|
280
|
+
// gradient at a lattice corner; sinless hash so every GPU produces the same clouds
|
|
281
|
+
const gradient = Fn( ( [ i ] ) => {
|
|
289
282
|
|
|
290
|
-
|
|
283
|
+
const p = fract( i.xyx.mul( vec3( 0.1031, 0.1030, 0.0973 ) ) ).toVar();
|
|
284
|
+
p.addAssign( dot( p, p.yzx.add( 33.33 ) ) );
|
|
285
|
+
|
|
286
|
+
return fract( p.xx.add( p.yz ).mul( p.zy ) ).mul( 2.0 ).sub( 1.0 );
|
|
291
287
|
|
|
292
288
|
} );
|
|
293
289
|
|
|
294
|
-
|
|
290
|
+
// 2D gradient noise: isotropic lobes like Perlin at value-noise cost
|
|
291
|
+
const noise = Fn( ( [ p ] ) => {
|
|
295
292
|
|
|
296
|
-
const p = vec2( p_immutable ).toVar();
|
|
297
293
|
const i = floor( p );
|
|
298
294
|
const f = fract( p );
|
|
299
|
-
const
|
|
295
|
+
const u = f.mul( f ).mul( f ).mul( f.mul( f.mul( 6.0 ).sub( 15.0 ) ).add( 10.0 ) ); // quintic fade
|
|
300
296
|
|
|
301
|
-
const a =
|
|
302
|
-
const b =
|
|
303
|
-
const c =
|
|
304
|
-
const d =
|
|
297
|
+
const a = dot( gradient( i ), f );
|
|
298
|
+
const b = dot( gradient( i.add( vec2( 1.0, 0.0 ) ) ), f.sub( vec2( 1.0, 0.0 ) ) );
|
|
299
|
+
const c = dot( gradient( i.add( vec2( 0.0, 1.0 ) ) ), f.sub( vec2( 0.0, 1.0 ) ) );
|
|
300
|
+
const d = dot( gradient( i.add( vec2( 1.0, 1.0 ) ) ), f.sub( vec2( 1.0, 1.0 ) ) );
|
|
305
301
|
|
|
306
|
-
return mix( mix( a, b,
|
|
302
|
+
return mix( mix( a, b, u.x ), mix( c, d, u.x ), u.y ).mul( 1.6 ); // ~[-1,1]
|
|
307
303
|
|
|
308
304
|
} );
|
|
309
305
|
|
|
310
|
-
|
|
306
|
+
// fbm; per-octave drift makes clouds billow instead of scrolling as a rigid stamp
|
|
307
|
+
const fbm = Fn( ( [ position, drift ] ) => {
|
|
311
308
|
|
|
312
|
-
const p = vec2(
|
|
313
|
-
const
|
|
314
|
-
const amplitude = float( 0
|
|
309
|
+
const p = vec2( position ).toVar();
|
|
310
|
+
const result = float( 0.0 ).toVar();
|
|
311
|
+
const amplitude = float( 1.0 ).toVar();
|
|
315
312
|
|
|
316
|
-
Loop(
|
|
313
|
+
Loop( 4, () => {
|
|
317
314
|
|
|
318
|
-
|
|
319
|
-
p.mulAssign( 2.0 );
|
|
315
|
+
result.addAssign( amplitude.mul( noise( p ) ) );
|
|
320
316
|
amplitude.mulAssign( 0.5 );
|
|
317
|
+
p.mulAssign( 2.0 ).addAssign( drift );
|
|
321
318
|
|
|
322
319
|
} );
|
|
323
320
|
|
|
324
|
-
return
|
|
321
|
+
return result;
|
|
325
322
|
|
|
326
323
|
} );
|
|
327
324
|
|
|
@@ -334,29 +331,50 @@ class SkyMesh extends Mesh {
|
|
|
334
331
|
cloudUV.mulAssign( this.cloudScale );
|
|
335
332
|
cloudUV.addAssign( time.mul( this.cloudSpeed ) );
|
|
336
333
|
|
|
337
|
-
//
|
|
338
|
-
const
|
|
339
|
-
cloudNoise.
|
|
334
|
+
// Cloud density field
|
|
335
|
+
const evolve = time.mul( this.cloudSpeed ).mul( 300.0 );
|
|
336
|
+
const cloudNoise = fbm( cloudUV.mul( 1000.0 ), evolve ).mul( 0.7 ).add( 0.5 ).clamp( 0.0, 1.0 ).toVar();
|
|
337
|
+
|
|
338
|
+
// Large-scale coverage variation: clear gaps next to dense banks
|
|
339
|
+
const region = noise( cloudUV.mul( 300.0 ) ).mul( 0.37 ).add( 0.5 );
|
|
340
|
+
const cov = clamp( this.cloudCoverage.add( region.sub( 0.5 ).mul( 0.6 ) ), 0.0, 1.0 );
|
|
340
341
|
|
|
341
|
-
//
|
|
342
|
-
const
|
|
342
|
+
// Carve clouds where noise rises above the coverage level
|
|
343
|
+
const threshold = sub( 1.0, cov ).toVar();
|
|
344
|
+
const cloudMask = smoothstep( threshold, threshold.add( 0.3 ), cloudNoise ).toVar();
|
|
343
345
|
|
|
344
346
|
// Fade clouds near horizon (adjusted by elevation)
|
|
345
|
-
const horizonFade = smoothstep( 0.0, add( 0.
|
|
347
|
+
const horizonFade = smoothstep( 0.0, add( 0.03, mul( 0.06, this.cloudElevation ) ), direction.y );
|
|
346
348
|
cloudMask.mulAssign( horizonFade );
|
|
347
349
|
|
|
348
|
-
// Cloud lighting
|
|
349
|
-
const
|
|
350
|
-
const
|
|
350
|
+
// Cloud lighting from the sky's own radiance
|
|
351
|
+
const dayFactor = smoothstep( - 0.08, 0.3, vSunDirection.y );
|
|
352
|
+
const sunColor = vSunE.mul( Fex ).mul( 0.22 ).mul( 0.04 ).toVar(); // 0.22 ~ albedo/pi, 0.04 = exposure; the aerial composite adds the eye-leg extinction
|
|
353
|
+
const skyAmbient = Lin.mul( 0.04 ).add( vec3( 0.0, 0.0003, 0.00075 ) );
|
|
354
|
+
|
|
355
|
+
// Beer-powder self-shadow from the sampled density
|
|
356
|
+
const depth = max( 0.0, cloudNoise.sub( threshold ) ).toVar();
|
|
357
|
+
const beer = exp( depth.mul( - 4.0 ) ).toVar();
|
|
358
|
+
const powder = sub( 1.0, beer.mul( beer ) ); // beer*beer == exp(-8*depth)
|
|
359
|
+
const shade = mix( 0.45, 1.0, beer.mul( powder ).mul( 2.6 ).clamp( 0.0, 1.0 ) ); // 2.6 = 1/0.385, normalizes beer*powder peak to 1
|
|
360
|
+
|
|
361
|
+
// Henyey-Greenstein forward lobe ( g = 0.7 ): silver lining on rims toward the sun
|
|
362
|
+
const silver = float( 0.51 ).div( pow( sub( 1.49, cosTheta.mul( 1.4 ) ), 1.5 ) ).clamp( 0.0, 3.0 ); // 0.51=1-g^2, 1.49=1+g^2, 1.4=2g
|
|
363
|
+
const edge = cloudMask.mul( sub( 1.0, cloudMask ) ).mul( 4.0 );
|
|
364
|
+
|
|
365
|
+
const cloudColor = skyAmbient.add( sunColor.mul( shade ) ).toVar();
|
|
366
|
+
cloudColor.addAssign( sunColor.mul( silver ).mul( edge ).mul( 0.6 ) );
|
|
367
|
+
cloudColor.mulAssign( dayFactor.max( 0.03 ) );
|
|
368
|
+
|
|
369
|
+
// Cloud opacity via Beer's law: density sets how solid the clouds get
|
|
370
|
+
const alpha = sub( 1.0, exp( depth.mul( this.cloudDensity ).mul( - 12.0 ) ) ).mul( horizonFade ).toVar();
|
|
351
371
|
|
|
352
|
-
//
|
|
353
|
-
|
|
354
|
-
const cloudColor = mix( vec3( 0.3 ), vec3( 1.0 ), daylight ).toVar();
|
|
355
|
-
cloudColor.assign( mix( cloudColor, atmosphereColor.add( vec3( 1.0 ) ), sunInfluence.mul( 0.5 ) ) );
|
|
356
|
-
cloudColor.mulAssign( vSunE.mul( 0.00002 ) );
|
|
372
|
+
// Occlude the sun disc/glow behind opaque cloud
|
|
373
|
+
texColor.subAssign( L0.mul( 0.04 ).add( sundiscColor ).mul( alpha ) );
|
|
357
374
|
|
|
358
|
-
//
|
|
359
|
-
|
|
375
|
+
// Composite through the atmosphere so distant clouds dissolve into haze
|
|
376
|
+
const cloudAerial = mix( texColor, cloudColor, Fex );
|
|
377
|
+
texColor.assign( mix( texColor, cloudAerial, alpha ) );
|
|
360
378
|
|
|
361
379
|
} );
|
|
362
380
|
|
|
@@ -366,6 +384,7 @@ class SkyMesh extends Mesh {
|
|
|
366
384
|
|
|
367
385
|
material.side = BackSide;
|
|
368
386
|
material.depthWrite = false;
|
|
387
|
+
material.fog = false;
|
|
369
388
|
|
|
370
389
|
material.vertexNode = vertexNode;
|
|
371
390
|
material.colorNode = colorNode;
|
|
@@ -76,12 +76,14 @@ class AfterimagePass extends Pass {
|
|
|
76
76
|
|
|
77
77
|
this._textureComp = new WebGLRenderTarget( window.innerWidth, window.innerHeight, {
|
|
78
78
|
magFilter: NearestFilter,
|
|
79
|
-
type: HalfFloatType
|
|
79
|
+
type: HalfFloatType,
|
|
80
|
+
depthBuffer: false
|
|
80
81
|
} );
|
|
81
82
|
|
|
82
83
|
this._textureOld = new WebGLRenderTarget( window.innerWidth, window.innerHeight, {
|
|
83
84
|
magFilter: NearestFilter,
|
|
84
|
-
type: HalfFloatType
|
|
85
|
+
type: HalfFloatType,
|
|
86
|
+
depthBuffer: false
|
|
85
87
|
} );
|
|
86
88
|
|
|
87
89
|
this._compFsQuad = new FullScreenQuad( this.compFsMaterial );
|
|
@@ -104,9 +104,9 @@ class BloomPass extends Pass {
|
|
|
104
104
|
|
|
105
105
|
// internals
|
|
106
106
|
|
|
107
|
-
this._renderTargetX = new WebGLRenderTarget( 1, 1, { type: HalfFloatType } ); // will be resized later
|
|
107
|
+
this._renderTargetX = new WebGLRenderTarget( 1, 1, { type: HalfFloatType, depthBuffer: false } ); // will be resized later
|
|
108
108
|
this._renderTargetX.texture.name = 'BloomPass.x';
|
|
109
|
-
this._renderTargetY = new WebGLRenderTarget( 1, 1, { type: HalfFloatType } ); // will be resized later
|
|
109
|
+
this._renderTargetY = new WebGLRenderTarget( 1, 1, { type: HalfFloatType, depthBuffer: false } ); // will be resized later
|
|
110
110
|
this._renderTargetY.texture.name = 'BloomPass.y';
|
|
111
111
|
|
|
112
112
|
this._fsQuad = new FullScreenQuad( null );
|
|
@@ -140,7 +140,7 @@ class GTAOPass extends Pass {
|
|
|
140
140
|
this.gtaoNoiseTexture = generateMagicSquareNoise();
|
|
141
141
|
this.pdNoiseTexture = this._generateNoise();
|
|
142
142
|
|
|
143
|
-
this.gtaoRenderTarget = new WebGLRenderTarget( this.width, this.height, { type: HalfFloatType } );
|
|
143
|
+
this.gtaoRenderTarget = new WebGLRenderTarget( this.width, this.height, { type: HalfFloatType, depthBuffer: false } );
|
|
144
144
|
this.pdRenderTarget = this.gtaoRenderTarget.clone();
|
|
145
145
|
|
|
146
146
|
this.gtaoMaterial = new ShaderMaterial( {
|
|
@@ -170,22 +170,22 @@ class OutlinePass extends Pass {
|
|
|
170
170
|
this.renderTargetDepthBuffer.texture.name = 'OutlinePass.depth';
|
|
171
171
|
this.renderTargetDepthBuffer.texture.generateMipmaps = false;
|
|
172
172
|
|
|
173
|
-
this.renderTargetMaskDownSampleBuffer = new WebGLRenderTarget( resx, resy, { type: HalfFloatType } );
|
|
173
|
+
this.renderTargetMaskDownSampleBuffer = new WebGLRenderTarget( resx, resy, { type: HalfFloatType, depthBuffer: false } );
|
|
174
174
|
this.renderTargetMaskDownSampleBuffer.texture.name = 'OutlinePass.depthDownSample';
|
|
175
175
|
this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps = false;
|
|
176
176
|
|
|
177
|
-
this.renderTargetBlurBuffer1 = new WebGLRenderTarget( resx, resy, { type: HalfFloatType } );
|
|
177
|
+
this.renderTargetBlurBuffer1 = new WebGLRenderTarget( resx, resy, { type: HalfFloatType, depthBuffer: false } );
|
|
178
178
|
this.renderTargetBlurBuffer1.texture.name = 'OutlinePass.blur1';
|
|
179
179
|
this.renderTargetBlurBuffer1.texture.generateMipmaps = false;
|
|
180
|
-
this.renderTargetBlurBuffer2 = new WebGLRenderTarget( Math.round( resx / 2 ), Math.round( resy / 2 ), { type: HalfFloatType } );
|
|
180
|
+
this.renderTargetBlurBuffer2 = new WebGLRenderTarget( Math.round( resx / 2 ), Math.round( resy / 2 ), { type: HalfFloatType, depthBuffer: false } );
|
|
181
181
|
this.renderTargetBlurBuffer2.texture.name = 'OutlinePass.blur2';
|
|
182
182
|
this.renderTargetBlurBuffer2.texture.generateMipmaps = false;
|
|
183
183
|
|
|
184
184
|
this.edgeDetectionMaterial = this._getEdgeDetectionMaterial();
|
|
185
|
-
this.renderTargetEdgeBuffer1 = new WebGLRenderTarget( resx, resy, { type: HalfFloatType } );
|
|
185
|
+
this.renderTargetEdgeBuffer1 = new WebGLRenderTarget( resx, resy, { type: HalfFloatType, depthBuffer: false } );
|
|
186
186
|
this.renderTargetEdgeBuffer1.texture.name = 'OutlinePass.edge1';
|
|
187
187
|
this.renderTargetEdgeBuffer1.texture.generateMipmaps = false;
|
|
188
|
-
this.renderTargetEdgeBuffer2 = new WebGLRenderTarget( Math.round( resx / 2 ), Math.round( resy / 2 ), { type: HalfFloatType } );
|
|
188
|
+
this.renderTargetEdgeBuffer2 = new WebGLRenderTarget( Math.round( resx / 2 ), Math.round( resy / 2 ), { type: HalfFloatType, depthBuffer: false } );
|
|
189
189
|
this.renderTargetEdgeBuffer2.texture.name = 'OutlinePass.edge2';
|
|
190
190
|
this.renderTargetEdgeBuffer2.texture.generateMipmaps = false;
|
|
191
191
|
|
|
@@ -108,7 +108,7 @@ class SAOPass extends Pass {
|
|
|
108
108
|
*/
|
|
109
109
|
this.resolution = new Vector2( resolution.x, resolution.y );
|
|
110
110
|
|
|
111
|
-
this.saoRenderTarget = new WebGLRenderTarget( this.resolution.x, this.resolution.y, { type: HalfFloatType } );
|
|
111
|
+
this.saoRenderTarget = new WebGLRenderTarget( this.resolution.x, this.resolution.y, { type: HalfFloatType, depthBuffer: false } );
|
|
112
112
|
this.blurIntermediateRenderTarget = this.saoRenderTarget.clone();
|
|
113
113
|
|
|
114
114
|
const depthTexture = new DepthTexture();
|
|
@@ -163,7 +163,7 @@ class SSAOPass extends Pass {
|
|
|
163
163
|
|
|
164
164
|
// ssao render target
|
|
165
165
|
|
|
166
|
-
this.ssaoRenderTarget = new WebGLRenderTarget( this.width, this.height, { type: HalfFloatType } );
|
|
166
|
+
this.ssaoRenderTarget = new WebGLRenderTarget( this.width, this.height, { type: HalfFloatType, depthBuffer: false } );
|
|
167
167
|
|
|
168
168
|
this.blurRenderTarget = this.ssaoRenderTarget.clone();
|
|
169
169
|
|
|
@@ -315,7 +315,8 @@ class SSRPass extends Pass {
|
|
|
315
315
|
//for bouncing
|
|
316
316
|
this.prevRenderTarget = new WebGLRenderTarget( this.width, this.height, {
|
|
317
317
|
minFilter: NearestFilter,
|
|
318
|
-
magFilter: NearestFilter
|
|
318
|
+
magFilter: NearestFilter,
|
|
319
|
+
depthBuffer: false
|
|
319
320
|
} );
|
|
320
321
|
|
|
321
322
|
// normal render target
|
|
@@ -340,7 +341,8 @@ class SSRPass extends Pass {
|
|
|
340
341
|
|
|
341
342
|
this.ssrRenderTarget = new WebGLRenderTarget( this.width, this.height, {
|
|
342
343
|
minFilter: NearestFilter,
|
|
343
|
-
magFilter: NearestFilter
|
|
344
|
+
magFilter: NearestFilter,
|
|
345
|
+
depthBuffer: false
|
|
344
346
|
} );
|
|
345
347
|
|
|
346
348
|
this.blurRenderTarget = this.ssrRenderTarget.clone();
|
|
@@ -61,7 +61,7 @@ class SavePass extends Pass {
|
|
|
61
61
|
|
|
62
62
|
if ( this.renderTarget === undefined ) {
|
|
63
63
|
|
|
64
|
-
this.renderTarget = new WebGLRenderTarget( 1, 1, { type: HalfFloatType } ); // will be resized later
|
|
64
|
+
this.renderTarget = new WebGLRenderTarget( 1, 1, { type: HalfFloatType, depthBuffer: false } ); // will be resized later
|
|
65
65
|
this.renderTarget.texture.name = 'SavePass.rt';
|
|
66
66
|
|
|
67
67
|
}
|
|
@@ -101,7 +101,7 @@ class TAARenderPass extends SSAARenderPass {
|
|
|
101
101
|
|
|
102
102
|
if ( this._holdRenderTarget === null ) {
|
|
103
103
|
|
|
104
|
-
this._holdRenderTarget = new WebGLRenderTarget( readBuffer.width, readBuffer.height, { type: HalfFloatType } );
|
|
104
|
+
this._holdRenderTarget = new WebGLRenderTarget( readBuffer.width, readBuffer.height, { type: HalfFloatType, depthBuffer: false } );
|
|
105
105
|
this._holdRenderTarget.texture.name = 'TAARenderPass.hold';
|
|
106
106
|
|
|
107
107
|
}
|
|
@@ -102,20 +102,20 @@ class UnrealBloomPass extends Pass {
|
|
|
102
102
|
let resx = Math.round( this.resolution.x / 2 );
|
|
103
103
|
let resy = Math.round( this.resolution.y / 2 );
|
|
104
104
|
|
|
105
|
-
this.renderTargetBright = new WebGLRenderTarget( resx, resy, { type: HalfFloatType } );
|
|
105
|
+
this.renderTargetBright = new WebGLRenderTarget( resx, resy, { type: HalfFloatType, depthBuffer: false } );
|
|
106
106
|
this.renderTargetBright.texture.name = 'UnrealBloomPass.bright';
|
|
107
107
|
this.renderTargetBright.texture.generateMipmaps = false;
|
|
108
108
|
|
|
109
109
|
for ( let i = 0; i < this.nMips; i ++ ) {
|
|
110
110
|
|
|
111
|
-
const renderTargetHorizontal = new WebGLRenderTarget( resx, resy, { type: HalfFloatType } );
|
|
111
|
+
const renderTargetHorizontal = new WebGLRenderTarget( resx, resy, { type: HalfFloatType, depthBuffer: false } );
|
|
112
112
|
|
|
113
113
|
renderTargetHorizontal.texture.name = 'UnrealBloomPass.h' + i;
|
|
114
114
|
renderTargetHorizontal.texture.generateMipmaps = false;
|
|
115
115
|
|
|
116
116
|
this.renderTargetsHorizontal.push( renderTargetHorizontal );
|
|
117
117
|
|
|
118
|
-
const renderTargetVertical = new WebGLRenderTarget( resx, resy, { type: HalfFloatType } );
|
|
118
|
+
const renderTargetVertical = new WebGLRenderTarget( resx, resy, { type: HalfFloatType, depthBuffer: false } );
|
|
119
119
|
|
|
120
120
|
renderTargetVertical.texture.name = 'UnrealBloomPass.v' + i;
|
|
121
121
|
renderTargetVertical.texture.generateMipmaps = false;
|
|
@@ -387,17 +387,35 @@ class UnrealBloomPass extends Pass {
|
|
|
387
387
|
|
|
388
388
|
}
|
|
389
389
|
|
|
390
|
+
// merge adjacent taps into single bilinear fetches (linear sampling)
|
|
391
|
+
|
|
392
|
+
const offsets = [];
|
|
393
|
+
const weights = [];
|
|
394
|
+
|
|
395
|
+
for ( let i = 1; i < kernelRadius; i += 2 ) {
|
|
396
|
+
|
|
397
|
+
const wa = coefficients[ i ];
|
|
398
|
+
const wb = ( i + 1 < kernelRadius ) ? coefficients[ i + 1 ] : 0;
|
|
399
|
+
const w = wa + wb;
|
|
400
|
+
|
|
401
|
+
offsets.push( ( i * wa + ( i + 1 ) * wb ) / w );
|
|
402
|
+
weights.push( w );
|
|
403
|
+
|
|
404
|
+
}
|
|
405
|
+
|
|
390
406
|
return new ShaderMaterial( {
|
|
391
407
|
|
|
392
408
|
defines: {
|
|
393
|
-
'
|
|
409
|
+
'KERNEL_PAIRS': offsets.length
|
|
394
410
|
},
|
|
395
411
|
|
|
396
412
|
uniforms: {
|
|
397
413
|
'colorTexture': { value: null },
|
|
398
414
|
'invSize': { value: new Vector2( 0.5, 0.5 ) }, // inverse texture size
|
|
399
415
|
'direction': { value: new Vector2( 0.5, 0.5 ) },
|
|
400
|
-
'
|
|
416
|
+
'centerWeight': { value: coefficients[ 0 ] },
|
|
417
|
+
'gaussianOffsets': { value: offsets },
|
|
418
|
+
'gaussianWeights': { value: weights }
|
|
401
419
|
},
|
|
402
420
|
|
|
403
421
|
vertexShader: /* glsl */`
|
|
@@ -420,21 +438,20 @@ class UnrealBloomPass extends Pass {
|
|
|
420
438
|
uniform sampler2D colorTexture;
|
|
421
439
|
uniform vec2 invSize;
|
|
422
440
|
uniform vec2 direction;
|
|
423
|
-
uniform float
|
|
441
|
+
uniform float centerWeight;
|
|
442
|
+
uniform float gaussianOffsets[KERNEL_PAIRS];
|
|
443
|
+
uniform float gaussianWeights[KERNEL_PAIRS];
|
|
424
444
|
|
|
425
445
|
void main() {
|
|
426
446
|
|
|
427
|
-
|
|
428
|
-
vec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * weightSum;
|
|
447
|
+
vec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * centerWeight;
|
|
429
448
|
|
|
430
|
-
for ( int i =
|
|
449
|
+
for ( int i = 0; i < KERNEL_PAIRS; i ++ ) {
|
|
431
450
|
|
|
432
|
-
|
|
433
|
-
float w = gaussianCoefficients[i];
|
|
434
|
-
vec2 uvOffset = direction * invSize * x;
|
|
451
|
+
vec2 uvOffset = direction * invSize * gaussianOffsets[ i ];
|
|
435
452
|
vec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb;
|
|
436
453
|
vec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb;
|
|
437
|
-
diffuseSum += ( sample1 + sample2 ) *
|
|
454
|
+
diffuseSum += ( sample1 + sample2 ) * gaussianWeights[ i ];
|
|
438
455
|
|
|
439
456
|
}
|
|
440
457
|
|