@gnsx/three 0.185.16 → 0.186.1
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,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { overloadingFn } from '../../utils/FunctionOverloadingNode.js';
|
|
9
|
-
import { Loop } from '../../utils/LoopNode.js';
|
|
1
|
+
import { int, uint, float, vec3, bool, uvec3, vec2, vec4, If, Fn } from '../tsl/TSLBase.js';
|
|
2
|
+
import { select } from '../math/ConditionalNode.js';
|
|
3
|
+
import { add, sub, mul } from '../math/OperatorNode.js';
|
|
4
|
+
import { floor, abs, max, dot, sqrt, clamp, fract } from '../math/MathNode.js';
|
|
5
|
+
import { overloadingFn } from '../utils/FunctionOverloadingNode.js';
|
|
6
|
+
import { Loop } from '../utils/LoopNode.js';
|
|
7
|
+
import { mx_rotate2d, mx_rotate3d } from './MaterialXCore.js';
|
|
10
8
|
|
|
11
9
|
|
|
12
10
|
export const mx_select = /*@__PURE__*/ Fn( ( [ b_immutable, t_immutable, f_immutable ] ) => {
|
|
@@ -66,6 +64,22 @@ export const mx_floorfrac = /*@__PURE__*/ Fn( ( [ x_immutable, i ] ) => {
|
|
|
66
64
|
|
|
67
65
|
} );
|
|
68
66
|
|
|
67
|
+
const mxBilerpValue = ( v0, v1, v2, v3, s, t ) => {
|
|
68
|
+
|
|
69
|
+
const s1 = float( sub( 1.0, s ) ).toVar();
|
|
70
|
+
return sub( 1.0, t ).mul( v0.mul( s1 ).add( v1.mul( s ) ) ).add( t.mul( v2.mul( s1 ).add( v3.mul( s ) ) ) );
|
|
71
|
+
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const mxTrilerpValue = ( v0, v1, v2, v3, v4, v5, v6, v7, s, t, r ) => {
|
|
75
|
+
|
|
76
|
+
const s1 = float( sub( 1.0, s ) ).toVar();
|
|
77
|
+
const t1 = float( sub( 1.0, t ) ).toVar();
|
|
78
|
+
const r1 = float( sub( 1.0, r ) ).toVar();
|
|
79
|
+
return r1.mul( t1.mul( v0.mul( s1 ).add( v1.mul( s ) ) ).add( t.mul( v2.mul( s1 ).add( v3.mul( s ) ) ) ) ).add( r.mul( t1.mul( v4.mul( s1 ).add( v5.mul( s ) ) ).add( t.mul( v6.mul( s1 ).add( v7.mul( s ) ) ) ) ) );
|
|
80
|
+
|
|
81
|
+
};
|
|
82
|
+
|
|
69
83
|
export const mx_bilerp_0 = /*@__PURE__*/ Fn( ( [ v0_immutable, v1_immutable, v2_immutable, v3_immutable, s_immutable, t_immutable ] ) => {
|
|
70
84
|
|
|
71
85
|
const t = float( t_immutable ).toVar();
|
|
@@ -74,9 +88,8 @@ export const mx_bilerp_0 = /*@__PURE__*/ Fn( ( [ v0_immutable, v1_immutable, v2_
|
|
|
74
88
|
const v2 = float( v2_immutable ).toVar();
|
|
75
89
|
const v1 = float( v1_immutable ).toVar();
|
|
76
90
|
const v0 = float( v0_immutable ).toVar();
|
|
77
|
-
const s1 = float( sub( 1.0, s ) ).toVar();
|
|
78
91
|
|
|
79
|
-
return
|
|
92
|
+
return mxBilerpValue( v0, v1, v2, v3, s, t );
|
|
80
93
|
|
|
81
94
|
} ).setLayout( {
|
|
82
95
|
name: 'mx_bilerp_0',
|
|
@@ -99,9 +112,8 @@ export const mx_bilerp_1 = /*@__PURE__*/ Fn( ( [ v0_immutable, v1_immutable, v2_
|
|
|
99
112
|
const v2 = vec3( v2_immutable ).toVar();
|
|
100
113
|
const v1 = vec3( v1_immutable ).toVar();
|
|
101
114
|
const v0 = vec3( v0_immutable ).toVar();
|
|
102
|
-
const s1 = float( sub( 1.0, s ) ).toVar();
|
|
103
115
|
|
|
104
|
-
return
|
|
116
|
+
return mxBilerpValue( v0, v1, v2, v3, s, t );
|
|
105
117
|
|
|
106
118
|
} ).setLayout( {
|
|
107
119
|
name: 'mx_bilerp_1',
|
|
@@ -131,11 +143,8 @@ export const mx_trilerp_0 = /*@__PURE__*/ Fn( ( [ v0_immutable, v1_immutable, v2
|
|
|
131
143
|
const v2 = float( v2_immutable ).toVar();
|
|
132
144
|
const v1 = float( v1_immutable ).toVar();
|
|
133
145
|
const v0 = float( v0_immutable ).toVar();
|
|
134
|
-
const s1 = float( sub( 1.0, s ) ).toVar();
|
|
135
|
-
const t1 = float( sub( 1.0, t ) ).toVar();
|
|
136
|
-
const r1 = float( sub( 1.0, r ) ).toVar();
|
|
137
146
|
|
|
138
|
-
return
|
|
147
|
+
return mxTrilerpValue( v0, v1, v2, v3, v4, v5, v6, v7, s, t, r );
|
|
139
148
|
|
|
140
149
|
} ).setLayout( {
|
|
141
150
|
name: 'mx_trilerp_0',
|
|
@@ -168,11 +177,8 @@ export const mx_trilerp_1 = /*@__PURE__*/ Fn( ( [ v0_immutable, v1_immutable, v2
|
|
|
168
177
|
const v2 = vec3( v2_immutable ).toVar();
|
|
169
178
|
const v1 = vec3( v1_immutable ).toVar();
|
|
170
179
|
const v0 = vec3( v0_immutable ).toVar();
|
|
171
|
-
const s1 = float( sub( 1.0, s ) ).toVar();
|
|
172
|
-
const t1 = float( sub( 1.0, t ) ).toVar();
|
|
173
|
-
const r1 = float( sub( 1.0, r ) ).toVar();
|
|
174
180
|
|
|
175
|
-
return
|
|
181
|
+
return mxTrilerpValue( v0, v1, v2, v3, v4, v5, v6, v7, s, t, r );
|
|
176
182
|
|
|
177
183
|
} ).setLayout( {
|
|
178
184
|
name: 'mx_trilerp_1',
|
|
@@ -358,6 +364,9 @@ export const mx_rotl32 = /*@__PURE__*/ Fn( ( [ x_immutable, k_immutable ] ) => {
|
|
|
358
364
|
|
|
359
365
|
export const mx_bjmix = /*@__PURE__*/ Fn( ( [ a, b, c ] ) => {
|
|
360
366
|
|
|
367
|
+
a = uint( a ).toVar();
|
|
368
|
+
b = uint( b ).toVar();
|
|
369
|
+
c = uint( c ).toVar();
|
|
361
370
|
a.subAssign( c );
|
|
362
371
|
a.bitXorAssign( mx_rotl32( c, int( 4 ) ) );
|
|
363
372
|
c.addAssign( b );
|
|
@@ -377,6 +386,16 @@ export const mx_bjmix = /*@__PURE__*/ Fn( ( [ a, b, c ] ) => {
|
|
|
377
386
|
c.bitXorAssign( mx_rotl32( b, int( 4 ) ) );
|
|
378
387
|
b.addAssign( a );
|
|
379
388
|
|
|
389
|
+
return uvec3( a, b, c );
|
|
390
|
+
|
|
391
|
+
} ).setLayout( {
|
|
392
|
+
name: 'mx_bjmix',
|
|
393
|
+
type: 'uvec3',
|
|
394
|
+
inputs: [
|
|
395
|
+
{ name: 'a', type: 'uint' },
|
|
396
|
+
{ name: 'b', type: 'uint' },
|
|
397
|
+
{ name: 'c', type: 'uint' }
|
|
398
|
+
]
|
|
380
399
|
} );
|
|
381
400
|
|
|
382
401
|
export const mx_bjfinal = /*@__PURE__*/ Fn( ( [ a_immutable, b_immutable, c_immutable ] ) => {
|
|
@@ -415,7 +434,7 @@ export const mx_bits_to_01 = /*@__PURE__*/ Fn( ( [ bits_immutable ] ) => {
|
|
|
415
434
|
|
|
416
435
|
const bits = uint( bits_immutable ).toVar();
|
|
417
436
|
|
|
418
|
-
return float( bits ).div( float( uint(
|
|
437
|
+
return float( bits ).div( float( uint( 0xffffffff ) ) );
|
|
419
438
|
|
|
420
439
|
} ).setLayout( {
|
|
421
440
|
name: 'mx_bits_to_01',
|
|
@@ -443,7 +462,7 @@ export const mx_hash_int_0 = /*@__PURE__*/ Fn( ( [ x_immutable ] ) => {
|
|
|
443
462
|
|
|
444
463
|
const x = int( x_immutable ).toVar();
|
|
445
464
|
const len = uint( uint( 1 ) ).toVar();
|
|
446
|
-
const seed = uint( uint(
|
|
465
|
+
const seed = uint( uint( 0xdeadbeef ).add( len.shiftLeft( uint( 2 ) ) ).add( uint( 13 ) ) ).toVar();
|
|
447
466
|
|
|
448
467
|
return mx_bjfinal( seed.add( uint( x ) ), seed, seed );
|
|
449
468
|
|
|
@@ -461,7 +480,7 @@ export const mx_hash_int_1 = /*@__PURE__*/ Fn( ( [ x_immutable, y_immutable ] )
|
|
|
461
480
|
const x = int( x_immutable ).toVar();
|
|
462
481
|
const len = uint( uint( 2 ) ).toVar();
|
|
463
482
|
const a = uint().toVar(), b = uint().toVar(), c = uint().toVar();
|
|
464
|
-
a.assign( b.assign( c.assign( uint(
|
|
483
|
+
a.assign( b.assign( c.assign( uint( 0xdeadbeef ).add( len.shiftLeft( uint( 2 ) ) ).add( uint( 13 ) ) ) ) );
|
|
465
484
|
a.addAssign( uint( x ) );
|
|
466
485
|
b.addAssign( uint( y ) );
|
|
467
486
|
|
|
@@ -483,7 +502,7 @@ export const mx_hash_int_2 = /*@__PURE__*/ Fn( ( [ x_immutable, y_immutable, z_i
|
|
|
483
502
|
const x = int( x_immutable ).toVar();
|
|
484
503
|
const len = uint( uint( 3 ) ).toVar();
|
|
485
504
|
const a = uint().toVar(), b = uint().toVar(), c = uint().toVar();
|
|
486
|
-
a.assign( b.assign( c.assign( uint(
|
|
505
|
+
a.assign( b.assign( c.assign( uint( 0xdeadbeef ).add( len.shiftLeft( uint( 2 ) ) ).add( uint( 13 ) ) ) ) );
|
|
487
506
|
a.addAssign( uint( x ) );
|
|
488
507
|
b.addAssign( uint( y ) );
|
|
489
508
|
c.addAssign( uint( z ) );
|
|
@@ -508,11 +527,14 @@ export const mx_hash_int_3 = /*@__PURE__*/ Fn( ( [ x_immutable, y_immutable, z_i
|
|
|
508
527
|
const x = int( x_immutable ).toVar();
|
|
509
528
|
const len = uint( uint( 4 ) ).toVar();
|
|
510
529
|
const a = uint().toVar(), b = uint().toVar(), c = uint().toVar();
|
|
511
|
-
a.assign( b.assign( c.assign( uint(
|
|
530
|
+
a.assign( b.assign( c.assign( uint( 0xdeadbeef ).add( len.shiftLeft( uint( 2 ) ) ).add( uint( 13 ) ) ) ) );
|
|
512
531
|
a.addAssign( uint( x ) );
|
|
513
532
|
b.addAssign( uint( y ) );
|
|
514
533
|
c.addAssign( uint( z ) );
|
|
515
|
-
mx_bjmix( a, b, c );
|
|
534
|
+
const mixed = uvec3( mx_bjmix( a, b, c ) ).toVar();
|
|
535
|
+
a.assign( mixed.x );
|
|
536
|
+
b.assign( mixed.y );
|
|
537
|
+
c.assign( mixed.z );
|
|
516
538
|
a.addAssign( uint( xx ) );
|
|
517
539
|
|
|
518
540
|
return mx_bjfinal( a, b, c );
|
|
@@ -537,11 +559,14 @@ export const mx_hash_int_4 = /*@__PURE__*/ Fn( ( [ x_immutable, y_immutable, z_i
|
|
|
537
559
|
const x = int( x_immutable ).toVar();
|
|
538
560
|
const len = uint( uint( 5 ) ).toVar();
|
|
539
561
|
const a = uint().toVar(), b = uint().toVar(), c = uint().toVar();
|
|
540
|
-
a.assign( b.assign( c.assign( uint(
|
|
562
|
+
a.assign( b.assign( c.assign( uint( 0xdeadbeef ).add( len.shiftLeft( uint( 2 ) ) ).add( uint( 13 ) ) ) ) );
|
|
541
563
|
a.addAssign( uint( x ) );
|
|
542
564
|
b.addAssign( uint( y ) );
|
|
543
565
|
c.addAssign( uint( z ) );
|
|
544
|
-
mx_bjmix( a, b, c );
|
|
566
|
+
const mixed = uvec3( mx_bjmix( a, b, c ) ).toVar();
|
|
567
|
+
a.assign( mixed.x );
|
|
568
|
+
b.assign( mixed.y );
|
|
569
|
+
c.assign( mixed.z );
|
|
545
570
|
a.addAssign( uint( xx ) );
|
|
546
571
|
b.addAssign( uint( yy ) );
|
|
547
572
|
|
|
@@ -768,7 +793,11 @@ export const mx_cell_noise_vec3_0 = /*@__PURE__*/ Fn( ( [ p_immutable ] ) => {
|
|
|
768
793
|
const p = float( p_immutable ).toVar();
|
|
769
794
|
const ix = int( mx_floor( p ) ).toVar();
|
|
770
795
|
|
|
771
|
-
return vec3(
|
|
796
|
+
return vec3(
|
|
797
|
+
mx_bits_to_01( mx_hash_int( ix, int( 0 ) ) ),
|
|
798
|
+
mx_bits_to_01( mx_hash_int( ix, int( 1 ) ) ),
|
|
799
|
+
mx_bits_to_01( mx_hash_int( ix, int( 2 ) ) )
|
|
800
|
+
);
|
|
772
801
|
|
|
773
802
|
} ).setLayout( {
|
|
774
803
|
name: 'mx_cell_noise_vec3_0',
|
|
@@ -784,7 +813,11 @@ export const mx_cell_noise_vec3_1 = /*@__PURE__*/ Fn( ( [ p_immutable ] ) => {
|
|
|
784
813
|
const ix = int( mx_floor( p.x ) ).toVar();
|
|
785
814
|
const iy = int( mx_floor( p.y ) ).toVar();
|
|
786
815
|
|
|
787
|
-
return vec3(
|
|
816
|
+
return vec3(
|
|
817
|
+
mx_bits_to_01( mx_hash_int( ix, iy, int( 0 ) ) ),
|
|
818
|
+
mx_bits_to_01( mx_hash_int( ix, iy, int( 1 ) ) ),
|
|
819
|
+
mx_bits_to_01( mx_hash_int( ix, iy, int( 2 ) ) )
|
|
820
|
+
);
|
|
788
821
|
|
|
789
822
|
} ).setLayout( {
|
|
790
823
|
name: 'mx_cell_noise_vec3_1',
|
|
@@ -794,14 +827,29 @@ export const mx_cell_noise_vec3_1 = /*@__PURE__*/ Fn( ( [ p_immutable ] ) => {
|
|
|
794
827
|
]
|
|
795
828
|
} );
|
|
796
829
|
|
|
797
|
-
export const mx_cell_noise_vec3_2 = /*@__PURE__*/ Fn( ( [
|
|
830
|
+
export const mx_cell_noise_vec3_2 = /*@__PURE__*/ Fn( ( [ positionInput ] ) => {
|
|
798
831
|
|
|
799
|
-
const
|
|
800
|
-
const ix = int(
|
|
801
|
-
const iy = int(
|
|
802
|
-
const iz = int(
|
|
803
|
-
|
|
804
|
-
|
|
832
|
+
const position = vec3( positionInput ).toVar();
|
|
833
|
+
const ix = int( floor( position.x ) ).toVar();
|
|
834
|
+
const iy = int( floor( position.y ) ).toVar();
|
|
835
|
+
const iz = int( floor( position.z ) ).toVar();
|
|
836
|
+
const seed = uint( 0xdeadbeef + ( 4 << 2 ) + 13 ).toVar();
|
|
837
|
+
const a = uint().toVar(), b = uint().toVar(), c = uint().toVar();
|
|
838
|
+
a.assign( b.assign( c.assign( seed ) ) );
|
|
839
|
+
a.addAssign( uint( ix ) );
|
|
840
|
+
b.addAssign( uint( iy ) );
|
|
841
|
+
c.addAssign( uint( iz ) );
|
|
842
|
+
|
|
843
|
+
const mixed = uvec3( mx_bjmix( a, b, c ) ).toVar();
|
|
844
|
+
const hash0 = mx_bjfinal( mixed.x, mixed.y, mixed.z );
|
|
845
|
+
const hash1 = mx_bjfinal( add( mixed.x, uint( 1 ) ), mixed.y, mixed.z );
|
|
846
|
+
const hash2 = mx_bjfinal( add( mixed.x, uint( 2 ) ), mixed.y, mixed.z );
|
|
847
|
+
|
|
848
|
+
return vec3(
|
|
849
|
+
mx_bits_to_01( hash0 ),
|
|
850
|
+
mx_bits_to_01( hash1 ),
|
|
851
|
+
mx_bits_to_01( hash2 )
|
|
852
|
+
);
|
|
805
853
|
|
|
806
854
|
} ).setLayout( {
|
|
807
855
|
name: 'mx_cell_noise_vec3_2',
|
|
@@ -818,8 +866,24 @@ export const mx_cell_noise_vec3_3 = /*@__PURE__*/ Fn( ( [ p_immutable ] ) => {
|
|
|
818
866
|
const iy = int( mx_floor( p.y ) ).toVar();
|
|
819
867
|
const iz = int( mx_floor( p.z ) ).toVar();
|
|
820
868
|
const iw = int( mx_floor( p.w ) ).toVar();
|
|
821
|
-
|
|
822
|
-
|
|
869
|
+
const seed = uint( 0xdeadbeef + ( 5 << 2 ) + 13 ).toVar();
|
|
870
|
+
const a = uint().toVar(), b = uint().toVar(), c = uint().toVar();
|
|
871
|
+
a.assign( b.assign( c.assign( seed ) ) );
|
|
872
|
+
a.addAssign( uint( ix ) );
|
|
873
|
+
b.addAssign( uint( iy ) );
|
|
874
|
+
c.addAssign( uint( iz ) );
|
|
875
|
+
|
|
876
|
+
const mixed = uvec3( mx_bjmix( a, b, c ) ).toVar();
|
|
877
|
+
a.assign( mixed.x );
|
|
878
|
+
b.assign( mixed.y );
|
|
879
|
+
c.assign( mixed.z );
|
|
880
|
+
a.addAssign( uint( iw ) );
|
|
881
|
+
|
|
882
|
+
return vec3(
|
|
883
|
+
mx_bits_to_01( mx_bjfinal( a, b, c ) ),
|
|
884
|
+
mx_bits_to_01( mx_bjfinal( a, add( b, uint( 1 ) ), c ) ),
|
|
885
|
+
mx_bits_to_01( mx_bjfinal( a, add( b, uint( 2 ) ), c ) )
|
|
886
|
+
);
|
|
823
887
|
|
|
824
888
|
} ).setLayout( {
|
|
825
889
|
name: 'mx_cell_noise_vec3_3',
|
|
@@ -831,6 +895,62 @@ export const mx_cell_noise_vec3_3 = /*@__PURE__*/ Fn( ( [ p_immutable ] ) => {
|
|
|
831
895
|
|
|
832
896
|
export const mx_cell_noise_vec3 = /*@__PURE__*/ overloadingFn( [ mx_cell_noise_vec3_0, mx_cell_noise_vec3_1, mx_cell_noise_vec3_2, mx_cell_noise_vec3_3 ] );
|
|
833
897
|
|
|
898
|
+
const mx_cell_noise_vec3_3d = /*@__PURE__*/ Fn( ( [ positionInput ] ) => {
|
|
899
|
+
|
|
900
|
+
const position = vec3( positionInput ).toVar();
|
|
901
|
+
const ix = int( floor( position.x ) ).toVar();
|
|
902
|
+
const iy = int( floor( position.y ) ).toVar();
|
|
903
|
+
const iz = int( floor( position.z ) ).toVar();
|
|
904
|
+
const seed = uint( 0xdeadbeef + ( 4 << 2 ) + 13 ).toVar();
|
|
905
|
+
const a = uint().toVar(), b = uint().toVar(), c = uint().toVar();
|
|
906
|
+
a.assign( b.assign( c.assign( seed ) ) );
|
|
907
|
+
a.addAssign( uint( ix ) );
|
|
908
|
+
b.addAssign( uint( iy ) );
|
|
909
|
+
c.addAssign( uint( iz ) );
|
|
910
|
+
|
|
911
|
+
const mixed = uvec3( mx_bjmix( a, b, c ) ).toVar();
|
|
912
|
+
const hash0 = mx_bjfinal( mixed.x, mixed.y, mixed.z );
|
|
913
|
+
const hash1 = mx_bjfinal( add( mixed.x, uint( 1 ) ), mixed.y, mixed.z );
|
|
914
|
+
const hash2 = mx_bjfinal( add( mixed.x, uint( 2 ) ), mixed.y, mixed.z );
|
|
915
|
+
|
|
916
|
+
return vec3(
|
|
917
|
+
mx_bits_to_01( hash0 ),
|
|
918
|
+
mx_bits_to_01( hash1 ),
|
|
919
|
+
mx_bits_to_01( hash2 )
|
|
920
|
+
);
|
|
921
|
+
|
|
922
|
+
} );
|
|
923
|
+
|
|
924
|
+
export const mx_fractal_noise_float_2d = /*@__PURE__*/ Fn( ( [ p_immutable, octaves_immutable, lacunarity_immutable, diminish_immutable ] ) => {
|
|
925
|
+
|
|
926
|
+
const diminish = float( diminish_immutable ).toVar();
|
|
927
|
+
const lacunarity = float( lacunarity_immutable ).toVar();
|
|
928
|
+
const octaves = int( octaves_immutable ).toVar();
|
|
929
|
+
const p = vec2( p_immutable ).toVar();
|
|
930
|
+
const result = float( 0.0 ).toVar();
|
|
931
|
+
const amplitude = float( 1.0 ).toVar();
|
|
932
|
+
|
|
933
|
+
Loop( octaves, () => {
|
|
934
|
+
|
|
935
|
+
result.addAssign( amplitude.mul( mx_perlin_noise_float( p ) ) );
|
|
936
|
+
amplitude.mulAssign( diminish );
|
|
937
|
+
p.mulAssign( lacunarity );
|
|
938
|
+
|
|
939
|
+
} );
|
|
940
|
+
|
|
941
|
+
return result;
|
|
942
|
+
|
|
943
|
+
} ).setLayout( {
|
|
944
|
+
name: 'mx_fractal_noise_float_2d',
|
|
945
|
+
type: 'float',
|
|
946
|
+
inputs: [
|
|
947
|
+
{ name: 'p', type: 'vec2' },
|
|
948
|
+
{ name: 'octaves', type: 'int' },
|
|
949
|
+
{ name: 'lacunarity', type: 'float' },
|
|
950
|
+
{ name: 'diminish', type: 'float' }
|
|
951
|
+
]
|
|
952
|
+
} );
|
|
953
|
+
|
|
834
954
|
export const mx_fractal_noise_float = /*@__PURE__*/ Fn( ( [ p_immutable, octaves_immutable, lacunarity_immutable, diminish_immutable ] ) => {
|
|
835
955
|
|
|
836
956
|
const diminish = float( diminish_immutable ).toVar();
|
|
@@ -989,7 +1109,7 @@ export const mx_worley_distance_1 = /*@__PURE__*/ Fn( ( [ p_immutable, x_immutab
|
|
|
989
1109
|
const y = int( y_immutable ).toVar();
|
|
990
1110
|
const x = int( x_immutable ).toVar();
|
|
991
1111
|
const p = vec3( p_immutable ).toVar();
|
|
992
|
-
const off = vec3(
|
|
1112
|
+
const off = vec3( mx_cell_noise_vec3_3d( vec3( x.add( xoff ), y.add( yoff ), z.add( zoff ) ) ) ).toVar();
|
|
993
1113
|
off.subAssign( 0.5 );
|
|
994
1114
|
off.mulAssign( jitter );
|
|
995
1115
|
off.addAssign( 0.5 );
|
|
@@ -1028,27 +1148,49 @@ export const mx_worley_distance_1 = /*@__PURE__*/ Fn( ( [ p_immutable, x_immutab
|
|
|
1028
1148
|
|
|
1029
1149
|
export const mx_worley_distance = /*@__PURE__*/ overloadingFn( [ mx_worley_distance_0, mx_worley_distance_1 ] );
|
|
1030
1150
|
|
|
1031
|
-
|
|
1151
|
+
const mx_perlin_noise_float_scaled = ( texcoord, amplitude = 1, pivot = 0 ) => mx_perlin_noise_float( texcoord ).mul( amplitude ).add( pivot );
|
|
1032
1152
|
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
const
|
|
1036
|
-
const
|
|
1037
|
-
const
|
|
1153
|
+
export const mx_worley_noise_float_3d = /*@__PURE__*/ Fn( ( [ positionInput, jitterInput, styleInput ] ) => {
|
|
1154
|
+
|
|
1155
|
+
const position = vec3( positionInput ).toVar();
|
|
1156
|
+
const jitter = float( jitterInput ).toVar();
|
|
1157
|
+
const style = int( styleInput ).toVar();
|
|
1158
|
+
const X = int().toVar(), Y = int().toVar(), Z = int().toVar();
|
|
1159
|
+
const localpos = vec3( mx_floorfrac( position.x, X ), mx_floorfrac( position.y, Y ), mx_floorfrac( position.z, Z ) ).toVar();
|
|
1038
1160
|
const sqdist = float( 1e6 ).toVar();
|
|
1161
|
+
const minpos = vec3( 0, 0, 0 ).toVar();
|
|
1039
1162
|
|
|
1040
1163
|
Loop( { start: - 1, end: int( 1 ), name: 'x', condition: '<=' }, ( { x } ) => {
|
|
1041
1164
|
|
|
1042
1165
|
Loop( { start: - 1, end: int( 1 ), name: 'y', condition: '<=' }, ( { y } ) => {
|
|
1043
1166
|
|
|
1044
|
-
|
|
1045
|
-
|
|
1167
|
+
Loop( { start: - 1, end: int( 1 ), name: 'z', condition: '<=' }, ( { z } ) => {
|
|
1168
|
+
|
|
1169
|
+
const dist = float( mx_worley_distance( localpos, x, y, z, X, Y, Z, jitter, int( 0 ) ) ).toVar();
|
|
1170
|
+
const off = vec3( mx_cell_noise_vec3_3d( vec3( X.add( x ), Y.add( y ), Z.add( z ) ) ) ).toVar();
|
|
1171
|
+
off.subAssign( 0.5 );
|
|
1172
|
+
off.mulAssign( jitter );
|
|
1173
|
+
off.addAssign( 0.5 );
|
|
1174
|
+
const cellpos = vec3( vec3( float( x ), float( y ), float( z ) ).add( off ).sub( localpos ) ).toVar();
|
|
1175
|
+
|
|
1176
|
+
If( dist.lessThan( sqdist ), () => {
|
|
1177
|
+
|
|
1178
|
+
sqdist.assign( dist );
|
|
1179
|
+
minpos.assign( cellpos );
|
|
1180
|
+
|
|
1181
|
+
} );
|
|
1182
|
+
|
|
1183
|
+
} );
|
|
1046
1184
|
|
|
1047
1185
|
} );
|
|
1048
1186
|
|
|
1049
1187
|
} );
|
|
1050
1188
|
|
|
1051
|
-
If(
|
|
1189
|
+
If( style.equal( int( 1 ) ), () => {
|
|
1190
|
+
|
|
1191
|
+
sqdist.assign( mx_cell_noise_float( minpos.add( position ) ) );
|
|
1192
|
+
|
|
1193
|
+
} ).Else( () => {
|
|
1052
1194
|
|
|
1053
1195
|
sqdist.assign( sqrt( sqdist ) );
|
|
1054
1196
|
|
|
@@ -1056,16 +1198,58 @@ export const mx_worley_noise_float_0 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter
|
|
|
1056
1198
|
|
|
1057
1199
|
return sqdist;
|
|
1058
1200
|
|
|
1059
|
-
} ).setLayout( {
|
|
1060
|
-
name: 'mx_worley_noise_float_0',
|
|
1061
|
-
type: 'float',
|
|
1062
|
-
inputs: [
|
|
1063
|
-
{ name: 'p', type: 'vec2' },
|
|
1064
|
-
{ name: 'jitter', type: 'float' },
|
|
1065
|
-
{ name: 'metric', type: 'int' }
|
|
1066
|
-
]
|
|
1067
1201
|
} );
|
|
1068
1202
|
|
|
1203
|
+
export const mx_worley_noise_float_2d = /*@__PURE__*/ Fn( ( [ texcoordInput, jitterInput, styleInput ] ) => {
|
|
1204
|
+
|
|
1205
|
+
const texcoord = vec2( texcoordInput ).toVar();
|
|
1206
|
+
const jitter = float( jitterInput ).toVar();
|
|
1207
|
+
const style = int( styleInput ).toVar();
|
|
1208
|
+
const floorPos = floor( texcoord ).toVar();
|
|
1209
|
+
const localpos = vec2( fract( texcoord.x ), fract( texcoord.y ) ).toVar();
|
|
1210
|
+
const sqdist = float( 1e6 ).toVar();
|
|
1211
|
+
const minpos = vec2( 0, 0 ).toVar();
|
|
1212
|
+
|
|
1213
|
+
Loop( { start: - 1, end: int( 1 ), name: 'x', condition: '<=' }, ( { x } ) => {
|
|
1214
|
+
|
|
1215
|
+
Loop( { start: - 1, end: int( 1 ), name: 'y', condition: '<=' }, ( { y } ) => {
|
|
1216
|
+
|
|
1217
|
+
const cell = vec2( float( x ), float( y ) ).toVar();
|
|
1218
|
+
const seed = vec2( cell.x.add( floorPos.x ), cell.y.add( floorPos.y ) ).toVar();
|
|
1219
|
+
const off = vec2( mx_cell_noise_float( vec3( seed.x, seed.y, 0 ) ), mx_cell_noise_float( vec3( seed.x, seed.y, 1 ) ) ).toVar();
|
|
1220
|
+
off.subAssign( 0.5 );
|
|
1221
|
+
off.mulAssign( jitter );
|
|
1222
|
+
off.addAssign( 0.5 );
|
|
1223
|
+
const cellpos = vec2( cell.add( off ).sub( localpos ) ).toVar();
|
|
1224
|
+
const dist = dot( cellpos, cellpos ).toVar();
|
|
1225
|
+
|
|
1226
|
+
If( dist.lessThan( sqdist ), () => {
|
|
1227
|
+
|
|
1228
|
+
sqdist.assign( dist );
|
|
1229
|
+
minpos.assign( cellpos );
|
|
1230
|
+
|
|
1231
|
+
} );
|
|
1232
|
+
|
|
1233
|
+
} );
|
|
1234
|
+
|
|
1235
|
+
} );
|
|
1236
|
+
|
|
1237
|
+
If( style.equal( int( 1 ) ), () => {
|
|
1238
|
+
|
|
1239
|
+
sqdist.assign( mx_cell_noise_float( minpos.add( texcoord ) ) );
|
|
1240
|
+
|
|
1241
|
+
} ).Else( () => {
|
|
1242
|
+
|
|
1243
|
+
sqdist.assign( sqrt( sqdist ) );
|
|
1244
|
+
|
|
1245
|
+
} );
|
|
1246
|
+
|
|
1247
|
+
return sqdist;
|
|
1248
|
+
|
|
1249
|
+
} );
|
|
1250
|
+
|
|
1251
|
+
export const mx_worley_noise_float = /*@__PURE__*/ overloadingFn( [ mx_worley_noise_float_2d, mx_worley_noise_float_3d ] );
|
|
1252
|
+
|
|
1069
1253
|
export const mx_worley_noise_vec2_0 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter_immutable, metric_immutable ] ) => {
|
|
1070
1254
|
|
|
1071
1255
|
const metric = int( metric_immutable ).toVar();
|
|
@@ -1168,14 +1352,14 @@ export const mx_worley_noise_vec3_0 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter_
|
|
|
1168
1352
|
]
|
|
1169
1353
|
} );
|
|
1170
1354
|
|
|
1171
|
-
export const
|
|
1355
|
+
export const mx_worley_noise_vec2_1 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter_immutable, metric_immutable ] ) => {
|
|
1172
1356
|
|
|
1173
1357
|
const metric = int( metric_immutable ).toVar();
|
|
1174
1358
|
const jitter = float( jitter_immutable ).toVar();
|
|
1175
1359
|
const p = vec3( p_immutable ).toVar();
|
|
1176
1360
|
const X = int().toVar(), Y = int().toVar(), Z = int().toVar();
|
|
1177
1361
|
const localpos = vec3( mx_floorfrac( p.x, X ), mx_floorfrac( p.y, Y ), mx_floorfrac( p.z, Z ) ).toVar();
|
|
1178
|
-
const sqdist =
|
|
1362
|
+
const sqdist = vec2( 1e6, 1e6 ).toVar();
|
|
1179
1363
|
|
|
1180
1364
|
Loop( { start: - 1, end: int( 1 ), name: 'x', condition: '<=' }, ( { x } ) => {
|
|
1181
1365
|
|
|
@@ -1184,7 +1368,17 @@ export const mx_worley_noise_float_1 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter
|
|
|
1184
1368
|
Loop( { start: - 1, end: int( 1 ), name: 'z', condition: '<=' }, ( { z } ) => {
|
|
1185
1369
|
|
|
1186
1370
|
const dist = float( mx_worley_distance( localpos, x, y, z, X, Y, Z, jitter, metric ) ).toVar();
|
|
1187
|
-
|
|
1371
|
+
|
|
1372
|
+
If( dist.lessThan( sqdist.x ), () => {
|
|
1373
|
+
|
|
1374
|
+
sqdist.y.assign( sqdist.x );
|
|
1375
|
+
sqdist.x.assign( dist );
|
|
1376
|
+
|
|
1377
|
+
} ).ElseIf( dist.lessThan( sqdist.y ), () => {
|
|
1378
|
+
|
|
1379
|
+
sqdist.y.assign( dist );
|
|
1380
|
+
|
|
1381
|
+
} );
|
|
1188
1382
|
|
|
1189
1383
|
} );
|
|
1190
1384
|
|
|
@@ -1201,8 +1395,8 @@ export const mx_worley_noise_float_1 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter
|
|
|
1201
1395
|
return sqdist;
|
|
1202
1396
|
|
|
1203
1397
|
} ).setLayout( {
|
|
1204
|
-
name: '
|
|
1205
|
-
type: '
|
|
1398
|
+
name: 'mx_worley_noise_vec2_1',
|
|
1399
|
+
type: 'vec2',
|
|
1206
1400
|
inputs: [
|
|
1207
1401
|
{ name: 'p', type: 'vec3' },
|
|
1208
1402
|
{ name: 'jitter', type: 'float' },
|
|
@@ -1210,16 +1404,16 @@ export const mx_worley_noise_float_1 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter
|
|
|
1210
1404
|
]
|
|
1211
1405
|
} );
|
|
1212
1406
|
|
|
1213
|
-
export const
|
|
1407
|
+
export const mx_worley_noise_vec2 = /*@__PURE__*/ overloadingFn( [ mx_worley_noise_vec2_0, mx_worley_noise_vec2_1 ] );
|
|
1214
1408
|
|
|
1215
|
-
export const
|
|
1409
|
+
export const mx_worley_noise_vec3_1 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter_immutable, metric_immutable ] ) => {
|
|
1216
1410
|
|
|
1217
1411
|
const metric = int( metric_immutable ).toVar();
|
|
1218
1412
|
const jitter = float( jitter_immutable ).toVar();
|
|
1219
1413
|
const p = vec3( p_immutable ).toVar();
|
|
1220
1414
|
const X = int().toVar(), Y = int().toVar(), Z = int().toVar();
|
|
1221
1415
|
const localpos = vec3( mx_floorfrac( p.x, X ), mx_floorfrac( p.y, Y ), mx_floorfrac( p.z, Z ) ).toVar();
|
|
1222
|
-
const sqdist =
|
|
1416
|
+
const sqdist = vec3( 1e6, 1e6, 1e6 ).toVar();
|
|
1223
1417
|
|
|
1224
1418
|
Loop( { start: - 1, end: int( 1 ), name: 'x', condition: '<=' }, ( { x } ) => {
|
|
1225
1419
|
|
|
@@ -1231,13 +1425,19 @@ export const mx_worley_noise_vec2_1 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter_
|
|
|
1231
1425
|
|
|
1232
1426
|
If( dist.lessThan( sqdist.x ), () => {
|
|
1233
1427
|
|
|
1428
|
+
sqdist.z.assign( sqdist.y );
|
|
1234
1429
|
sqdist.y.assign( sqdist.x );
|
|
1235
1430
|
sqdist.x.assign( dist );
|
|
1236
1431
|
|
|
1237
1432
|
} ).ElseIf( dist.lessThan( sqdist.y ), () => {
|
|
1238
1433
|
|
|
1434
|
+
sqdist.z.assign( sqdist.y );
|
|
1239
1435
|
sqdist.y.assign( dist );
|
|
1240
1436
|
|
|
1437
|
+
} ).ElseIf( dist.lessThan( sqdist.z ), () => {
|
|
1438
|
+
|
|
1439
|
+
sqdist.z.assign( dist );
|
|
1440
|
+
|
|
1241
1441
|
} );
|
|
1242
1442
|
|
|
1243
1443
|
} );
|
|
@@ -1255,8 +1455,8 @@ export const mx_worley_noise_vec2_1 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter_
|
|
|
1255
1455
|
return sqdist;
|
|
1256
1456
|
|
|
1257
1457
|
} ).setLayout( {
|
|
1258
|
-
name: '
|
|
1259
|
-
type: '
|
|
1458
|
+
name: 'mx_worley_noise_vec3_1',
|
|
1459
|
+
type: 'vec3',
|
|
1260
1460
|
inputs: [
|
|
1261
1461
|
{ name: 'p', type: 'vec3' },
|
|
1262
1462
|
{ name: 'jitter', type: 'float' },
|
|
@@ -1264,16 +1464,72 @@ export const mx_worley_noise_vec2_1 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter_
|
|
|
1264
1464
|
]
|
|
1265
1465
|
} );
|
|
1266
1466
|
|
|
1267
|
-
export const
|
|
1467
|
+
export const mx_worley_noise_vec3 = /*@__PURE__*/ overloadingFn( [ mx_worley_noise_vec3_0, mx_worley_noise_vec3_1 ] );
|
|
1268
1468
|
|
|
1269
|
-
export const
|
|
1469
|
+
export const mx_worley_noise_vec3_style_0 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter_immutable, style_immutable, metric_immutable ] ) => {
|
|
1270
1470
|
|
|
1271
1471
|
const metric = int( metric_immutable ).toVar();
|
|
1472
|
+
const style = int( style_immutable ).toVar();
|
|
1473
|
+
const jitter = float( jitter_immutable ).toVar();
|
|
1474
|
+
const p = vec2( p_immutable ).toVar();
|
|
1475
|
+
const X = int().toVar(), Y = int().toVar();
|
|
1476
|
+
const localpos = vec2( mx_floorfrac( p.x, X ), mx_floorfrac( p.y, Y ) ).toVar();
|
|
1477
|
+
const sqdist = float( 1e6 ).toVar();
|
|
1478
|
+
const minpos = vec2( 0, 0 ).toVar();
|
|
1479
|
+
|
|
1480
|
+
Loop( { start: - 1, end: int( 1 ), name: 'x', condition: '<=' }, ( { x } ) => {
|
|
1481
|
+
|
|
1482
|
+
Loop( { start: - 1, end: int( 1 ), name: 'y', condition: '<=' }, ( { y } ) => {
|
|
1483
|
+
|
|
1484
|
+
const dist = float( mx_worley_distance( localpos, x, y, X, Y, jitter, metric ) ).toVar();
|
|
1485
|
+
const tmp = vec3( mx_cell_noise_vec3( vec2( X.add( x ), Y.add( y ) ) ) ).toVar();
|
|
1486
|
+
const off = vec2( tmp.x, tmp.y ).toVar();
|
|
1487
|
+
off.subAssign( 0.5 );
|
|
1488
|
+
off.mulAssign( jitter );
|
|
1489
|
+
off.addAssign( 0.5 );
|
|
1490
|
+
const cellpos = vec2( vec2( float( x ), float( y ) ).add( off ).sub( localpos ) ).toVar();
|
|
1491
|
+
|
|
1492
|
+
If( dist.lessThan( sqdist ), () => {
|
|
1493
|
+
|
|
1494
|
+
sqdist.assign( dist );
|
|
1495
|
+
minpos.assign( cellpos );
|
|
1496
|
+
|
|
1497
|
+
} );
|
|
1498
|
+
|
|
1499
|
+
} );
|
|
1500
|
+
|
|
1501
|
+
} );
|
|
1502
|
+
|
|
1503
|
+
const result = vec3( mx_worley_noise_vec3( p, jitter, metric ) ).toVar();
|
|
1504
|
+
If( style.equal( int( 1 ) ), () => {
|
|
1505
|
+
|
|
1506
|
+
result.assign( mx_cell_noise_vec3( minpos.add( p ) ) );
|
|
1507
|
+
|
|
1508
|
+
} );
|
|
1509
|
+
|
|
1510
|
+
return result;
|
|
1511
|
+
|
|
1512
|
+
} ).setLayout( {
|
|
1513
|
+
name: 'mx_worley_noise_vec3_style_0',
|
|
1514
|
+
type: 'vec3',
|
|
1515
|
+
inputs: [
|
|
1516
|
+
{ name: 'p', type: 'vec2' },
|
|
1517
|
+
{ name: 'jitter', type: 'float' },
|
|
1518
|
+
{ name: 'style', type: 'int' },
|
|
1519
|
+
{ name: 'metric', type: 'int' }
|
|
1520
|
+
]
|
|
1521
|
+
} );
|
|
1522
|
+
|
|
1523
|
+
export const mx_worley_noise_vec3_style_1 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter_immutable, style_immutable, metric_immutable ] ) => {
|
|
1524
|
+
|
|
1525
|
+
const metric = int( metric_immutable ).toVar();
|
|
1526
|
+
const style = int( style_immutable ).toVar();
|
|
1272
1527
|
const jitter = float( jitter_immutable ).toVar();
|
|
1273
1528
|
const p = vec3( p_immutable ).toVar();
|
|
1274
1529
|
const X = int().toVar(), Y = int().toVar(), Z = int().toVar();
|
|
1275
1530
|
const localpos = vec3( mx_floorfrac( p.x, X ), mx_floorfrac( p.y, Y ), mx_floorfrac( p.z, Z ) ).toVar();
|
|
1276
|
-
const sqdist =
|
|
1531
|
+
const sqdist = float( 1e6 ).toVar();
|
|
1532
|
+
const minpos = vec3( 0, 0, 0 ).toVar();
|
|
1277
1533
|
|
|
1278
1534
|
Loop( { start: - 1, end: int( 1 ), name: 'x', condition: '<=' }, ( { x } ) => {
|
|
1279
1535
|
|
|
@@ -1282,21 +1538,16 @@ export const mx_worley_noise_vec3_1 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter_
|
|
|
1282
1538
|
Loop( { start: - 1, end: int( 1 ), name: 'z', condition: '<=' }, ( { z } ) => {
|
|
1283
1539
|
|
|
1284
1540
|
const dist = float( mx_worley_distance( localpos, x, y, z, X, Y, Z, jitter, metric ) ).toVar();
|
|
1541
|
+
const off = vec3( mx_cell_noise_vec3_3d( vec3( X.add( x ), Y.add( y ), Z.add( z ) ) ) ).toVar();
|
|
1542
|
+
off.subAssign( 0.5 );
|
|
1543
|
+
off.mulAssign( jitter );
|
|
1544
|
+
off.addAssign( 0.5 );
|
|
1545
|
+
const cellpos = vec3( vec3( float( x ), float( y ), float( z ) ).add( off ).sub( localpos ) ).toVar();
|
|
1285
1546
|
|
|
1286
|
-
If( dist.lessThan( sqdist
|
|
1287
|
-
|
|
1288
|
-
sqdist.z.assign( sqdist.y );
|
|
1289
|
-
sqdist.y.assign( sqdist.x );
|
|
1290
|
-
sqdist.x.assign( dist );
|
|
1547
|
+
If( dist.lessThan( sqdist ), () => {
|
|
1291
1548
|
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
sqdist.z.assign( sqdist.y );
|
|
1295
|
-
sqdist.y.assign( dist );
|
|
1296
|
-
|
|
1297
|
-
} ).ElseIf( dist.lessThan( sqdist.z ), () => {
|
|
1298
|
-
|
|
1299
|
-
sqdist.z.assign( dist );
|
|
1549
|
+
sqdist.assign( dist );
|
|
1550
|
+
minpos.assign( cellpos );
|
|
1300
1551
|
|
|
1301
1552
|
} );
|
|
1302
1553
|
|
|
@@ -1306,186 +1557,164 @@ export const mx_worley_noise_vec3_1 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter_
|
|
|
1306
1557
|
|
|
1307
1558
|
} );
|
|
1308
1559
|
|
|
1309
|
-
|
|
1560
|
+
const result = vec3( mx_worley_noise_vec3( p, jitter, metric ) ).toVar();
|
|
1561
|
+
If( style.equal( int( 1 ) ), () => {
|
|
1310
1562
|
|
|
1311
|
-
|
|
1563
|
+
result.assign( mx_cell_noise_vec3_3d( minpos.add( p ) ) );
|
|
1312
1564
|
|
|
1313
1565
|
} );
|
|
1314
1566
|
|
|
1315
|
-
return
|
|
1567
|
+
return result;
|
|
1316
1568
|
|
|
1317
1569
|
} ).setLayout( {
|
|
1318
|
-
name: '
|
|
1570
|
+
name: 'mx_worley_noise_vec3_style_1',
|
|
1319
1571
|
type: 'vec3',
|
|
1320
1572
|
inputs: [
|
|
1321
1573
|
{ name: 'p', type: 'vec3' },
|
|
1322
1574
|
{ name: 'jitter', type: 'float' },
|
|
1575
|
+
{ name: 'style', type: 'int' },
|
|
1323
1576
|
{ name: 'metric', type: 'int' }
|
|
1324
1577
|
]
|
|
1325
1578
|
} );
|
|
1326
1579
|
|
|
1327
|
-
export const
|
|
1580
|
+
export const mx_worley_noise_vec3_style = /*@__PURE__*/ overloadingFn( [ mx_worley_noise_vec3_style_0, mx_worley_noise_vec3_style_1 ] );
|
|
1328
1581
|
|
|
1329
1582
|
// Unified Noise 2D
|
|
1330
1583
|
export const mx_unifiednoise2d = /*@__PURE__*/ Fn( ( [
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1584
|
+
noiseTypeInput,
|
|
1585
|
+
texcoordInput,
|
|
1586
|
+
freqInput,
|
|
1587
|
+
offsetInput,
|
|
1588
|
+
jitterInput,
|
|
1589
|
+
outminInput,
|
|
1590
|
+
outmaxInput,
|
|
1591
|
+
clampoutputInput,
|
|
1592
|
+
octavesInput,
|
|
1593
|
+
lacunarityInput,
|
|
1594
|
+
diminishInput,
|
|
1595
|
+
styleInput
|
|
1334
1596
|
] ) => {
|
|
1335
1597
|
|
|
1336
|
-
const noiseType = int(
|
|
1337
|
-
const texcoord = vec2(
|
|
1338
|
-
const freq = vec2(
|
|
1339
|
-
const offset = vec2(
|
|
1340
|
-
const jitter = float(
|
|
1341
|
-
const outmin = float(
|
|
1342
|
-
const outmax = float(
|
|
1343
|
-
const clampoutput =
|
|
1344
|
-
const octaves = int(
|
|
1345
|
-
const lacunarity = float(
|
|
1346
|
-
const diminish = float(
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
const
|
|
1350
|
-
|
|
1351
|
-
const
|
|
1598
|
+
const noiseType = int( noiseTypeInput ).toVar();
|
|
1599
|
+
const texcoord = vec2( texcoordInput ).toVar();
|
|
1600
|
+
const freq = vec2( freqInput ).toVar();
|
|
1601
|
+
const offset = vec2( offsetInput ).toVar();
|
|
1602
|
+
const jitter = float( jitterInput ).toVar();
|
|
1603
|
+
const outmin = float( outminInput ).toVar();
|
|
1604
|
+
const outmax = float( outmaxInput ).toVar();
|
|
1605
|
+
const clampoutput = float( clampoutputInput ).toVar();
|
|
1606
|
+
const octaves = int( octavesInput ).toVar();
|
|
1607
|
+
const lacunarity = float( lacunarityInput ).toVar();
|
|
1608
|
+
const diminish = float( diminishInput ).toVar();
|
|
1609
|
+
const style = int( styleInput ).toVar();
|
|
1610
|
+
|
|
1611
|
+
const applyFreq = mul( texcoord, freq ).toVar();
|
|
1612
|
+
const applyOffset = add( applyFreq, offset ).toVar();
|
|
1613
|
+
const cellJitterMult = mul( sub( jitter, 1 ), 90000 ).toVar();
|
|
1614
|
+
const applyCellJitter = mx_rotate2d( applyOffset, cellJitterMult ).toVar();
|
|
1615
|
+
const fractalInput = vec3( applyOffset.x, applyOffset.y, cellJitterMult ).toVar();
|
|
1616
|
+
const result = float( 0 ).toVar();
|
|
1352
1617
|
|
|
1353
|
-
// Perlin
|
|
1354
1618
|
If( noiseType.equal( int( 0 ) ), () => {
|
|
1355
1619
|
|
|
1356
|
-
result.assign(
|
|
1620
|
+
result.assign( mx_perlin_noise_float_scaled( applyCellJitter, 0.5, 0.5 ) );
|
|
1357
1621
|
|
|
1358
1622
|
} );
|
|
1359
|
-
|
|
1360
|
-
// Cell
|
|
1361
1623
|
If( noiseType.equal( int( 1 ) ), () => {
|
|
1362
1624
|
|
|
1363
|
-
result.assign(
|
|
1625
|
+
result.assign( mx_cell_noise_float( applyCellJitter ) );
|
|
1364
1626
|
|
|
1365
1627
|
} );
|
|
1366
|
-
|
|
1367
|
-
// Worley (metric=0 = euclidean)
|
|
1368
1628
|
If( noiseType.equal( int( 2 ) ), () => {
|
|
1369
1629
|
|
|
1370
|
-
result.assign(
|
|
1630
|
+
result.assign( mx_worley_noise_float_2d( applyOffset, jitter, style ) );
|
|
1371
1631
|
|
|
1372
1632
|
} );
|
|
1373
|
-
|
|
1374
|
-
// Fractal (use vec3(p, 0.0) for 2D input)
|
|
1375
1633
|
If( noiseType.equal( int( 3 ) ), () => {
|
|
1376
1634
|
|
|
1377
|
-
result.assign(
|
|
1635
|
+
result.assign( mx_fractal_noise_float( fractalInput, octaves, lacunarity, diminish ) );
|
|
1378
1636
|
|
|
1379
1637
|
} );
|
|
1380
1638
|
|
|
1381
|
-
|
|
1382
|
-
|
|
1639
|
+
const ranged = add( outmin, mul( result, sub( outmax, outmin ) ) ).toVar();
|
|
1640
|
+
const clamped = clamp( ranged, outmin, outmax ).toVar();
|
|
1641
|
+
const output = ranged.toVar();
|
|
1383
1642
|
|
|
1384
|
-
|
|
1385
|
-
If( clampoutput, () => {
|
|
1643
|
+
If( clampoutput.equal( float( 1 ) ), () => {
|
|
1386
1644
|
|
|
1387
|
-
|
|
1645
|
+
output.assign( clamped );
|
|
1388
1646
|
|
|
1389
1647
|
} );
|
|
1390
1648
|
|
|
1391
|
-
return
|
|
1649
|
+
return output;
|
|
1392
1650
|
|
|
1393
|
-
} ).setLayout( {
|
|
1394
|
-
name: 'mx_unifiednoise2d',
|
|
1395
|
-
type: 'float',
|
|
1396
|
-
inputs: [
|
|
1397
|
-
{ name: 'noiseType', type: 'int' },
|
|
1398
|
-
{ name: 'texcoord', type: 'vec2' },
|
|
1399
|
-
{ name: 'freq', type: 'vec2' },
|
|
1400
|
-
{ name: 'offset', type: 'vec2' },
|
|
1401
|
-
{ name: 'jitter', type: 'float' },
|
|
1402
|
-
{ name: 'outmin', type: 'float' },
|
|
1403
|
-
{ name: 'outmax', type: 'float' },
|
|
1404
|
-
{ name: 'clampoutput', type: 'bool' },
|
|
1405
|
-
{ name: 'octaves', type: 'int' },
|
|
1406
|
-
{ name: 'lacunarity', type: 'float' },
|
|
1407
|
-
{ name: 'diminish', type: 'float' }
|
|
1408
|
-
]
|
|
1409
1651
|
} );
|
|
1410
1652
|
|
|
1411
1653
|
// Unified Noise 3D
|
|
1412
1654
|
export const mx_unifiednoise3d = /*@__PURE__*/ Fn( ( [
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1655
|
+
noiseTypeInput,
|
|
1656
|
+
positionInput,
|
|
1657
|
+
freqInput,
|
|
1658
|
+
offsetInput,
|
|
1659
|
+
jitterInput,
|
|
1660
|
+
outminInput,
|
|
1661
|
+
outmaxInput,
|
|
1662
|
+
clampoutputInput,
|
|
1663
|
+
octavesInput,
|
|
1664
|
+
lacunarityInput,
|
|
1665
|
+
diminishInput,
|
|
1666
|
+
styleInput
|
|
1416
1667
|
] ) => {
|
|
1417
1668
|
|
|
1418
|
-
const noiseType = int(
|
|
1419
|
-
const position = vec3(
|
|
1420
|
-
const freq = vec3(
|
|
1421
|
-
const offset = vec3(
|
|
1422
|
-
const jitter = float(
|
|
1423
|
-
const outmin = float(
|
|
1424
|
-
const outmax = float(
|
|
1425
|
-
const clampoutput =
|
|
1426
|
-
const octaves = int(
|
|
1427
|
-
const lacunarity = float(
|
|
1428
|
-
const diminish = float(
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
const
|
|
1432
|
-
|
|
1433
|
-
const
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
} );
|
|
1669
|
+
const noiseType = int( noiseTypeInput ).toVar();
|
|
1670
|
+
const position = vec3( positionInput ).toVar();
|
|
1671
|
+
const freq = vec3( freqInput ).toVar();
|
|
1672
|
+
const offset = vec3( offsetInput ).toVar();
|
|
1673
|
+
const jitter = float( jitterInput ).toVar();
|
|
1674
|
+
const outmin = float( outminInput ).toVar();
|
|
1675
|
+
const outmax = float( outmaxInput ).toVar();
|
|
1676
|
+
const clampoutput = float( clampoutputInput ).toVar();
|
|
1677
|
+
const octaves = int( octavesInput ).toVar();
|
|
1678
|
+
const lacunarity = float( lacunarityInput ).toVar();
|
|
1679
|
+
const diminish = float( diminishInput ).toVar();
|
|
1680
|
+
const style = int( styleInput ).toVar();
|
|
1681
|
+
|
|
1682
|
+
const applyFreq = mul( position, freq ).toVar();
|
|
1683
|
+
const applyOffset = add( applyFreq, offset ).toVar();
|
|
1684
|
+
const cellJitterMult = mul( sub( jitter, 1 ), 90000 ).toVar();
|
|
1685
|
+
const applyCellJitter = mx_rotate3d( applyOffset, cellJitterMult, vec3( 0.1, 1, 0 ) ).toVar();
|
|
1686
|
+
const perlin = mx_perlin_noise_float_scaled( applyCellJitter, 0.5, 0.5 );
|
|
1687
|
+
const cell = mx_cell_noise_float( applyCellJitter );
|
|
1688
|
+
const worley = mx_worley_noise_float_3d( applyOffset, jitter, style );
|
|
1689
|
+
const fractal = mx_fractal_noise_float( applyCellJitter, octaves, lacunarity, diminish );
|
|
1690
|
+
const result = perlin.toVar();
|
|
1441
1691
|
|
|
1442
|
-
// Cell
|
|
1443
1692
|
If( noiseType.equal( int( 1 ) ), () => {
|
|
1444
1693
|
|
|
1445
|
-
result.assign(
|
|
1694
|
+
result.assign( cell );
|
|
1446
1695
|
|
|
1447
1696
|
} );
|
|
1448
|
-
|
|
1449
|
-
// Worley (metric=0 = euclidean)
|
|
1450
1697
|
If( noiseType.equal( int( 2 ) ), () => {
|
|
1451
1698
|
|
|
1452
|
-
result.assign(
|
|
1699
|
+
result.assign( worley );
|
|
1453
1700
|
|
|
1454
1701
|
} );
|
|
1455
|
-
|
|
1456
|
-
// Fractal
|
|
1457
1702
|
If( noiseType.equal( int( 3 ) ), () => {
|
|
1458
1703
|
|
|
1459
|
-
result.assign(
|
|
1704
|
+
result.assign( fractal );
|
|
1460
1705
|
|
|
1461
1706
|
} );
|
|
1462
1707
|
|
|
1463
|
-
|
|
1464
|
-
|
|
1708
|
+
const ranged = add( outmin, mul( result, sub( outmax, outmin ) ) ).toVar();
|
|
1709
|
+
const clamped = clamp( ranged, outmin, outmax ).toVar();
|
|
1710
|
+
const output = ranged.toVar();
|
|
1465
1711
|
|
|
1466
|
-
|
|
1467
|
-
If( clampoutput, () => {
|
|
1712
|
+
If( clampoutput.equal( float( 1 ) ), () => {
|
|
1468
1713
|
|
|
1469
|
-
|
|
1714
|
+
output.assign( clamped );
|
|
1470
1715
|
|
|
1471
1716
|
} );
|
|
1472
1717
|
|
|
1473
|
-
return
|
|
1718
|
+
return output;
|
|
1474
1719
|
|
|
1475
|
-
} ).setLayout( {
|
|
1476
|
-
name: 'mx_unifiednoise3d',
|
|
1477
|
-
type: 'float',
|
|
1478
|
-
inputs: [
|
|
1479
|
-
{ name: 'noiseType', type: 'int' },
|
|
1480
|
-
{ name: 'position', type: 'vec3' },
|
|
1481
|
-
{ name: 'freq', type: 'vec3' },
|
|
1482
|
-
{ name: 'offset', type: 'vec3' },
|
|
1483
|
-
{ name: 'jitter', type: 'float' },
|
|
1484
|
-
{ name: 'outmin', type: 'float' },
|
|
1485
|
-
{ name: 'outmax', type: 'float' },
|
|
1486
|
-
{ name: 'clampoutput', type: 'bool' },
|
|
1487
|
-
{ name: 'octaves', type: 'int' },
|
|
1488
|
-
{ name: 'lacunarity', type: 'float' },
|
|
1489
|
-
{ name: 'diminish', type: 'float' }
|
|
1490
|
-
]
|
|
1491
1720
|
} );
|