@gnsx/three 0.185.15 → 0.186.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/three.cjs +10 -82600
- package/build/three.core.js +1303 -728
- package/build/three.module.js +439 -338
- package/build/three.tsl.js +74 -44
- package/build/three.webgpu.js +6036 -2184
- package/build/three.webgpu.nodes.js +6020 -2184
- package/examples/jsm/Addons.js +6 -6
- package/examples/jsm/controls/ArcballControls.js +1 -1
- package/examples/jsm/controls/FirstPersonControls.js +44 -20
- package/examples/jsm/controls/OrbitControls.js +9 -0
- package/examples/jsm/controls/TrackballControls.js +109 -4
- package/examples/jsm/csm/CSMShadowNode.js +13 -0
- package/examples/jsm/exporters/GLTFExporter.js +23 -7
- package/examples/jsm/exporters/USDZExporter.js +2 -2
- package/examples/jsm/generators/CityGenerator.js +377 -45
- package/examples/jsm/generators/ForestGenerator.js +12 -12
- package/examples/jsm/generators/TerrainGenerator.js +49 -37
- package/examples/jsm/generators/TreeGenerator.js +70 -76
- package/examples/jsm/generators/city/BenchGenerator.js +127 -0
- package/examples/jsm/generators/city/CarGenerator.js +479 -0
- package/examples/jsm/generators/city/CityGeneratorUtils.js +31 -0
- package/examples/jsm/generators/city/HydrantGenerator.js +106 -0
- package/examples/jsm/generators/city/InstancedMeshGenerator.js +86 -0
- package/examples/jsm/generators/city/PersonGenerator.js +447 -0
- package/examples/jsm/generators/city/SidewalkGenerator.js +33 -38
- package/examples/jsm/generators/city/SkyscraperGenerator.js +448 -48
- package/examples/jsm/generators/city/StreetTreeGenerator.js +231 -0
- package/examples/jsm/generators/city/StreetlightGenerator.js +100 -0
- package/examples/jsm/generators/city/TrafficlightGenerator.js +106 -0
- package/examples/jsm/generators/city/TrashcanGenerator.js +100 -0
- package/examples/jsm/geometries/BoxLineGeometry.js +1 -1
- package/examples/jsm/geometries/ParametricGeometry.js +1 -1
- package/examples/jsm/geometries/RoundedBoxGeometry.js +1 -1
- package/examples/jsm/gpgpu/CountingSort.js +271 -0
- package/examples/jsm/helpers/LightProbeGridHelper.js +60 -239
- package/examples/jsm/helpers/LightProbeGridHelperWebGL.js +221 -0
- package/examples/jsm/inspector/Extension.js +94 -0
- package/examples/jsm/inspector/Inspector.js +145 -41
- package/examples/jsm/inspector/RendererInspector.js +100 -52
- package/examples/jsm/inspector/extensions/color-grading/ColorGrading.js +2609 -0
- package/examples/jsm/inspector/extensions/color-grading/ColorWheel.js +352 -0
- package/examples/jsm/inspector/extensions/color-grading/CurveEditor.js +599 -0
- package/examples/jsm/inspector/extensions/color-grading/LUT3DStyle.js +1201 -0
- package/examples/jsm/inspector/extensions/color-grading/LUTMath.js +788 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/BrightnessModule.js +72 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ColorWheelModule.js +112 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ContrastModule.js +82 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/CurvesModule.js +109 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ExposureHueModule.js +110 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ExposureModule.js +73 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/HueModule.js +78 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/ImportedCubeModule.js +89 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/Module.js +285 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/OutputModule.js +101 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/RendererModule.js +225 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/SatVibranceModule.js +102 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/SaturationModule.js +76 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/VibranceModule.js +76 -0
- package/examples/jsm/inspector/extensions/color-grading/modules/WhiteBalanceModule.js +86 -0
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.js +26 -31
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.js +1 -0
- package/examples/jsm/inspector/tabs/Memory.js +0 -2
- package/examples/jsm/inspector/tabs/Settings.js +4 -0
- package/examples/jsm/inspector/tabs/Timeline.js +223 -171
- package/examples/jsm/inspector/tabs/Viewer.js +515 -21
- package/examples/jsm/inspector/ui/List.js +15 -9
- package/examples/jsm/inspector/ui/Profiler.js +170 -14
- package/examples/jsm/inspector/ui/Style.js +269 -23
- package/examples/jsm/inspector/ui/Tab.js +2 -0
- package/examples/jsm/inspector/ui/Values.js +14 -2
- package/examples/jsm/interactive/HTMLMesh.js +19 -3
- package/examples/jsm/lighting/LightProbeGrid.js +484 -889
- package/examples/jsm/lighting/LightProbeGridUtils.js +107 -0
- package/examples/jsm/lighting/LightProbeGridWebGL.js +841 -0
- package/examples/jsm/lighting/vxgi/VXGIConeTracer.js +194 -0
- package/examples/jsm/lighting/vxgi/VXGINode.js +660 -0
- package/examples/jsm/lighting/vxgi/VXGISceneCollector.js +478 -0
- package/examples/jsm/lighting/vxgi/VXGIVolume.js +1430 -0
- package/examples/jsm/lights/SunLight.js +95 -0
- package/examples/jsm/lights/SunLightNode.js +56 -0
- package/examples/jsm/lights/SunLightShadow.js +319 -0
- package/examples/jsm/lights/SunShadowNode.js +312 -0
- package/examples/jsm/loaders/3DMLoader.js +150 -49
- package/examples/jsm/loaders/3MFLoader.js +202 -1
- package/examples/jsm/loaders/FBXLoader.js +81 -5
- package/examples/jsm/loaders/GLTFGaussianSplatLoaderExtension.js +330 -0
- package/examples/jsm/loaders/GLTFLoader.js +79 -14
- package/examples/jsm/loaders/GaussianSplatPLYLoader.js +386 -0
- package/examples/jsm/loaders/KSPLATLoader.js +463 -0
- package/examples/jsm/loaders/MaterialXLoader.js +111 -1010
- package/examples/jsm/loaders/PCDLoader.js +1 -1
- package/examples/jsm/loaders/SPLATLoader.js +139 -0
- package/examples/jsm/loaders/SPZLoader.js +561 -0
- package/examples/jsm/loaders/materialx/MaterialXArchive.js +108 -0
- package/examples/jsm/loaders/materialx/MaterialXDocument.js +878 -0
- package/examples/jsm/loaders/materialx/MaterialXHextile.js +183 -0
- package/examples/jsm/loaders/materialx/MaterialXInterfaceValidation.js +376 -0
- package/examples/jsm/loaders/materialx/MaterialXLog.js +75 -0
- package/examples/jsm/loaders/materialx/MaterialXNodeInterfaceRegistry.js +4 -0
- package/examples/jsm/loaders/materialx/MaterialXNodeLibrary.js +1021 -0
- package/examples/jsm/loaders/materialx/MaterialXSurfaceMappings.js +661 -0
- package/examples/jsm/loaders/materialx/MaterialXUtils.js +57 -0
- package/examples/jsm/loaders/materialx/compile/MaterialXCompileRegistry.js +997 -0
- package/examples/jsm/loaders/materialx/parse/MaterialXParser.js +28 -0
- package/examples/jsm/loaders/usd/USDAParser.js +15 -2
- package/examples/jsm/loaders/usd/USDCParser.js +1 -4
- package/examples/jsm/loaders/usd/USDComposer.js +80 -42
- package/examples/jsm/materials/WoodNodeMaterial.js +6 -108
- package/examples/jsm/misc/RollerCoaster.js +2 -2
- package/examples/jsm/misc/SculptGL.LICENSE.txt +21 -0
- package/examples/jsm/misc/Sculptor.js +1679 -0
- package/examples/jsm/misc/SculptorMesh.js +1504 -0
- package/examples/jsm/misc/SculptorTools.js +1180 -0
- package/examples/jsm/misc/SculptorUtils.js +345 -0
- package/examples/jsm/misc/TubePainter.js +28 -16
- package/examples/jsm/misc/VolumeSlice.js +24 -24
- package/examples/jsm/modifiers/SimplifyModifier.js +63 -556
- package/examples/jsm/objects/GaussianSplat.js +1039 -0
- package/examples/jsm/objects/Sky.js +66 -45
- package/examples/jsm/objects/SkyMesh.js +70 -51
- package/examples/jsm/physics/JoltPhysics.js +1 -1
- package/examples/jsm/postprocessing/AfterimagePass.js +4 -2
- package/examples/jsm/postprocessing/BloomPass.js +2 -2
- package/examples/jsm/postprocessing/GTAOPass.js +1 -1
- package/examples/jsm/postprocessing/OutlinePass.js +5 -5
- package/examples/jsm/postprocessing/SAOPass.js +1 -1
- package/examples/jsm/postprocessing/SSAOPass.js +1 -1
- package/examples/jsm/postprocessing/SSRPass.js +4 -2
- package/examples/jsm/postprocessing/SavePass.js +1 -1
- package/examples/jsm/postprocessing/TAARenderPass.js +1 -1
- package/examples/jsm/postprocessing/UnrealBloomPass.js +30 -13
- package/examples/jsm/renderers/CSS2DRenderer.js +29 -5
- package/examples/jsm/shaders/DepthLimitedBlurShader.js +4 -1
- package/examples/jsm/shaders/ExposureShader.js +1 -1
- package/examples/jsm/shaders/FilmShader.js +2 -1
- package/examples/jsm/transpiler/AST.js +21 -2
- package/examples/jsm/transpiler/GLSLDecoder.js +498 -8
- package/examples/jsm/transpiler/TSLEncoder.js +82 -10
- package/examples/jsm/transpiler/WGSLEncoder.js +33 -4
- package/examples/jsm/tsl/WebGLNodesHandler.js +29 -39
- package/examples/jsm/tsl/display/AfterImageNode.js +2 -0
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +3 -2
- package/examples/jsm/tsl/display/BilateralBlurNode.js +5 -2
- package/examples/jsm/tsl/display/BloomNode.js +55 -30
- package/examples/jsm/tsl/display/DenoiseNode.js +21 -1
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +24 -6
- package/examples/jsm/tsl/display/DotScreenNode.js +11 -11
- package/examples/jsm/tsl/display/FSR1Node.js +8 -4
- package/examples/jsm/tsl/display/GTAONode.js +199 -86
- package/examples/jsm/tsl/display/GaussianBlurNode.js +65 -52
- package/examples/jsm/tsl/display/GodraysNode.js +5 -2
- package/examples/jsm/tsl/display/ImportanceSampledEnvironment.js +2 -2
- package/examples/jsm/tsl/display/LensflareNode.js +5 -2
- package/examples/jsm/tsl/display/OITPassNode.js +352 -0
- package/examples/jsm/tsl/display/OutlineNode.js +2 -0
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +3 -2
- package/examples/jsm/tsl/display/RGBShiftNode.js +9 -9
- package/examples/jsm/tsl/display/RecurrentDenoiseNode.js +7 -4
- package/examples/jsm/tsl/display/RetroPassNode.js +1 -1
- package/examples/jsm/tsl/display/SMAANode.js +22 -61
- package/examples/jsm/tsl/display/SSAAPassNode.js +2 -4
- package/examples/jsm/tsl/display/SSAONode.js +436 -0
- package/examples/jsm/tsl/display/SSGINode.js +5 -2
- package/examples/jsm/tsl/display/SSRNode.js +7 -2
- package/examples/jsm/tsl/display/SSSNode.js +5 -2
- package/examples/jsm/tsl/display/SharpenNode.js +5 -4
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +1 -3
- package/examples/jsm/tsl/display/StereoPassNode.js +1 -3
- package/examples/jsm/tsl/display/TAAUNode.js +22 -125
- package/examples/jsm/tsl/display/TRAANode.js +16 -142
- package/examples/jsm/tsl/display/TemporalReprojectNode.js +21 -15
- package/examples/jsm/tsl/display/depthAwareBlur.js +63 -0
- package/examples/jsm/tsl/display/hashBlur.js +3 -2
- package/examples/jsm/tsl/lighting/ClusteredLightsNode.js +38 -27
- package/examples/jsm/tsl/lighting/LightProbeGridNode.js +136 -0
- package/examples/jsm/tsl/math/voronoiNoise.js +112 -0
- package/examples/jsm/tsl/shadows/TileShadowNode.js +4 -6
- package/examples/jsm/tsl/utils/Raymarching.js +5 -5
- package/examples/jsm/tsl/utils/SoftParticles.js +60 -0
- package/examples/jsm/tsl/utils/TAAUtils.js +195 -0
- package/examples/jsm/utils/BufferGeometryUtils.js +14 -14
- package/examples/jsm/utils/GaussianSplatUtils.js +229 -0
- package/examples/jsm/utils/WebGLTextureUtils.js +1 -1
- package/examples/jsm/utils/WebGPUTextureUtils.js +1 -1
- package/examples/jsm/webxr/WebGLXRFallback.js +2 -16
- package/examples/jsm/webxr/XRControllerModelFactory.js +16 -4
- package/package.json +9 -16
- package/src/Three.Core.js +2 -1
- package/src/Three.TSL.js +73 -43
- package/src/Three.WebGPU.Nodes.js +1 -0
- package/src/Three.WebGPU.js +1 -0
- package/src/animation/AnimationClip.js +15 -2
- package/src/animation/AnimationObjectGroup.js +18 -6
- package/src/animation/AnimationUtils.js +26 -0
- package/src/animation/KeyframeTrack.js +37 -0
- package/src/constants.js +23 -1
- package/src/core/BufferAttribute.js +3 -2
- package/src/core/BufferGeometry.js +1 -1
- package/src/core/InterleavedBuffer.js +5 -1
- package/src/core/Object3D.js +40 -12
- package/src/core/Raycaster.js +4 -0
- package/src/core/RenderTarget.js +99 -9
- package/src/core/RenderTarget3D.js +12 -8
- package/src/extras/Controls.js +0 -8
- package/src/extras/PMREMGenerator.js +99 -205
- package/src/geometries/TorusGeometry.js +1 -1
- package/src/helpers/ArrowHelper.js +2 -0
- package/src/helpers/AxesHelper.js +2 -0
- package/src/helpers/Box3Helper.js +2 -0
- package/src/helpers/BoxHelper.js +2 -0
- package/src/helpers/CameraHelper.js +2 -0
- package/src/helpers/DirectionalLightHelper.js +2 -0
- package/src/helpers/GridHelper.js +2 -0
- package/src/helpers/HemisphereLightHelper.js +2 -0
- package/src/helpers/PlaneHelper.js +2 -0
- package/src/helpers/PointLightHelper.js +2 -0
- package/src/helpers/PolarGridHelper.js +2 -0
- package/src/helpers/SkeletonHelper.js +2 -0
- package/src/helpers/SpotLightHelper.js +2 -0
- package/src/lights/Light.js +0 -10
- package/src/lights/LightShadow.js +43 -12
- package/src/lights/SpotLightShadow.js +18 -0
- package/src/loaders/BufferGeometryLoader.js +5 -0
- package/src/loaders/ImageBitmapLoader.js +3 -1
- package/src/loaders/ObjectLoader.js +8 -5
- package/src/materials/Material.js +80 -57
- package/src/materials/MeshPhysicalMaterial.js +32 -0
- package/src/materials/nodes/Line2NodeMaterial.js +17 -8
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +42 -5
- package/src/materials/nodes/NodeMaterial.js +19 -13
- package/src/materials/nodes/PointsNodeMaterial.js +2 -1
- package/src/materials/nodes/manager/NodeMaterialObserver.js +282 -55
- package/src/math/Frustum.js +9 -0
- package/src/math/FrustumArray.js +1 -1
- package/src/math/MathUtils.js +5 -3
- package/src/math/Matrix4.js +2 -9
- package/src/math/Plane.js +30 -1
- package/src/math/Quaternion.js +0 -10
- package/src/math/Ray.js +95 -45
- package/src/math/Triangle.js +0 -2
- package/src/math/Vector3.js +2 -2
- package/src/math/Vector4.js +0 -4
- package/src/math/interpolants/BezierInterpolant.js +36 -23
- package/src/nodes/Nodes.js +2 -0
- package/src/nodes/TSL.js +11 -3
- package/src/nodes/accessors/Batch.js +85 -13
- package/src/nodes/accessors/BufferAttributeNode.js +1 -1
- package/src/nodes/accessors/BuiltinNode.js +1 -1
- package/src/nodes/accessors/Instance.js +19 -18
- package/src/nodes/accessors/MaterialNode.js +9 -0
- package/src/nodes/accessors/ModelNode.js +85 -9
- package/src/nodes/accessors/ReferenceBaseNode.js +1 -70
- package/src/nodes/accessors/ReferenceElementNode.js +72 -0
- package/src/nodes/accessors/ReferenceNode.js +1 -70
- package/src/nodes/accessors/Skinning.js +124 -12
- package/src/nodes/accessors/StorageTextureNode.js +7 -3
- package/src/nodes/accessors/Texture3DNode.js +1 -1
- package/src/nodes/accessors/TextureNode.js +51 -21
- package/src/nodes/accessors/TextureSizeNode.js +4 -2
- package/src/nodes/accessors/UniformArrayNode.js +30 -5
- package/src/nodes/code/CodeNode.js +1 -1
- package/src/nodes/code/FunctionNode.js +12 -2
- package/src/nodes/core/ArrayNode.js +2 -2
- package/src/nodes/core/ContextNode.js +57 -4
- package/src/nodes/core/IndexNode.js +69 -4
- package/src/nodes/core/InspectorNode.js +2 -2
- package/src/nodes/core/MRTNode.js +44 -2
- package/src/nodes/core/Node.js +6 -3
- package/src/nodes/core/NodeBuilder.js +65 -50
- package/src/nodes/core/NodeFrame.js +11 -3
- package/src/nodes/core/NodeUtils.js +88 -0
- package/src/nodes/core/PropertyNode.js +8 -0
- package/src/nodes/core/StackNode.js +0 -1
- package/src/nodes/core/StructNode.js +4 -3
- package/src/nodes/core/UniformGroupNode.js +3 -2
- package/src/nodes/core/UniformNode.js +26 -12
- package/src/nodes/core/VarNode.js +0 -1
- package/src/nodes/display/BumpMapNode.js +2 -2
- package/src/nodes/display/ColorAdjustment.js +1 -1
- package/src/nodes/display/PassNode.js +76 -15
- package/src/nodes/display/ScreenNode.js +22 -65
- package/src/nodes/fog/Fog.js +4 -4
- package/src/nodes/functions/BSDF/BRDF_GGX.js +6 -6
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +1 -1
- package/src/nodes/functions/BSDF/DFGLUT.js +2 -1
- package/src/nodes/functions/BSDF/LTC.js +1 -1
- package/src/nodes/functions/PhongLightingModel.js +1 -1
- package/src/nodes/functions/PhysicalLightingModel.js +83 -25
- package/src/nodes/functions/ToonLightingModel.js +2 -2
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +3 -3
- package/src/nodes/gpgpu/AtomicFunctionNode.js +64 -13
- package/src/nodes/gpgpu/BarrierNode.js +13 -4
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -1
- package/src/nodes/gpgpu/ComputeNode.js +20 -17
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +165 -37
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +44 -6
- package/src/nodes/lighting/EnvironmentNode.js +40 -4
- package/src/nodes/lighting/LightsNode.js +20 -4
- package/src/nodes/lighting/ShadowBaseNode.js +158 -1
- package/src/nodes/lighting/ShadowFilterNode.js +2 -106
- package/src/nodes/lighting/ShadowNode.js +22 -91
- package/src/nodes/materialx/{lib/mx_hsv.js → MaterialXColor.js} +3 -6
- package/src/nodes/materialx/{lib/mx_transform_color.js → MaterialXColorTransform.js} +3 -6
- package/src/nodes/materialx/MaterialXCore.js +37 -0
- package/src/nodes/materialx/MaterialXNodes.js +64 -72
- package/src/nodes/materialx/{lib/mx_noise.js → MaterialXNoise.js} +426 -197
- package/src/nodes/math/BitcountNode.js +24 -4
- package/src/nodes/math/MathNode.js +4 -4
- package/src/nodes/math/MathUtils.js +15 -4
- package/src/nodes/math/OperatorNode.js +2 -2
- package/src/nodes/math/PackFloatNode.js +29 -1
- package/src/nodes/math/Packed4x8IntegerNode.js +433 -0
- package/src/nodes/math/UnpackFloatNode.js +30 -2
- package/src/nodes/parsers/GLSLNodeFunction.js +1 -1
- package/src/nodes/pmrem/PMREMNode.js +1 -1
- package/src/nodes/pmrem/PMREMUtils.js +31 -74
- package/src/nodes/shapes/Shapes.js +1 -1
- package/src/nodes/tsl/TSLCore.js +1 -31
- package/src/nodes/utils/EventNode.js +75 -0
- package/src/nodes/utils/LoopNode.js +54 -13
- package/src/nodes/utils/PostProcessingUtils.js +23 -2
- package/src/nodes/utils/RTTNode.js +97 -32
- package/src/nodes/utils/ReflectorNode.js +8 -4
- package/src/nodes/utils/RotateNode.js +85 -8
- package/src/nodes/utils/SpriteUtils.js +58 -23
- package/src/objects/BatchedMesh.js +6 -0
- package/src/objects/InstancedMesh.js +1 -1
- package/src/objects/LOD.js +1 -1
- package/src/objects/Line.js +12 -0
- package/src/objects/Mesh.js +12 -0
- package/src/objects/Points.js +12 -0
- package/src/objects/Sprite.js +12 -0
- package/src/renderers/WebGLRenderer.js +93 -27
- package/src/renderers/common/Animation.js +12 -2
- package/src/renderers/common/Backend.js +38 -10
- package/src/renderers/common/BindGroup.js +0 -1
- package/src/renderers/common/Bindings.js +50 -4
- package/src/renderers/common/BundleGroup.js +4 -0
- package/src/renderers/common/ClippingContext.js +11 -1
- package/src/renderers/common/Color4.js +9 -0
- package/src/renderers/common/Constants.js +0 -5
- package/src/renderers/common/DirectRenderPipeline.js +233 -0
- package/src/renderers/common/Geometries.js +24 -3
- package/src/renderers/common/Info.js +3 -3
- package/src/renderers/common/InspectorBase.js +37 -8
- package/src/renderers/common/Lighting.js +11 -4
- package/src/renderers/common/Pipelines.js +6 -4
- package/src/renderers/common/QuadMesh.js +16 -2
- package/src/renderers/common/RenderContext.js +8 -0
- package/src/renderers/common/RenderList.js +53 -19
- package/src/renderers/common/RenderLists.js +58 -11
- package/src/renderers/common/RenderObject.js +14 -0
- package/src/renderers/common/RenderObjects.js +14 -9
- package/src/renderers/common/RenderPipeline.js +52 -44
- package/src/renderers/common/Renderer.js +226 -55
- package/src/renderers/common/Storage3DTexture.js +16 -0
- package/src/renderers/common/Textures.js +3 -3
- package/src/renderers/common/XRManager.js +79 -72
- package/src/renderers/common/extras/PMREMGenerator.js +76 -144
- package/src/renderers/common/nodes/NodeManager.js +144 -6
- package/src/renderers/common/nodes/NodeStorageBuffer.js +3 -1
- package/src/renderers/common/nodes/NodeUniformBuffer.js +3 -1
- package/src/renderers/shaders/DFGLUTData.js +2 -1
- package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +4 -2
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +48 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +53 -4
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +20 -2
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +20 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +61 -57
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +82 -0
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +9 -0
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +8 -1
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +15 -0
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -0
- package/src/renderers/shaders/ShaderLib.js +1 -0
- package/src/renderers/shaders/UniformsLib.js +16 -0
- package/src/renderers/webgl/WebGLAnimation.js +2 -2
- package/src/renderers/webgl/WebGLCapabilities.js +2 -2
- package/src/renderers/webgl/WebGLLights.js +74 -4
- package/src/renderers/webgl/WebGLMaterials.js +6 -0
- package/src/renderers/webgl/WebGLOutput.js +36 -24
- package/src/renderers/webgl/WebGLProgram.js +3 -0
- package/src/renderers/webgl/WebGLPrograms.js +8 -0
- package/src/renderers/webgl/WebGLRenderLists.js +6 -10
- package/src/renderers/webgl/WebGLShadowMap.js +47 -44
- package/src/renderers/webgl/WebGLTextures.js +7 -7
- package/src/renderers/webgl-fallback/WebGLBackend.js +153 -45
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +83 -29
- package/src/renderers/webgl-fallback/utils/WebGLState.js +163 -17
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +32 -5
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +11 -4
- package/src/renderers/webgpu/WebGPUBackend.js +513 -145
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +99 -20
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +2 -1
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +3 -12
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +24 -14
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +80 -14
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +62 -7
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +9 -3
- package/src/renderers/webgpu/utils/WebGPUUtils.js +16 -4
- package/src/renderers/webxr/WebXRManager.js +25 -2
- package/src/scenes/Scene.js +3 -3
- package/src/textures/CompressedArrayTexture.js +16 -0
- package/src/textures/Data3DTexture.js +16 -0
- package/src/textures/DataArrayTexture.js +16 -0
- package/src/textures/DepthTexture.js +3 -3
- package/src/textures/Texture.js +3 -3
- package/src/textures/{Source.js → TextureSource.js} +39 -8
- package/build/three.core.min.js +0 -6
- package/build/three.module.min.js +0 -6
- package/build/three.tsl.min.js +0 -6
- package/build/three.webgpu.min.js +0 -6
- package/build/three.webgpu.nodes.min.js +0 -6
- package/examples/jsm/libs/ecsy.module.js +0 -1792
- package/examples/jsm/loaders/LottieLoader.js +0 -130
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +0 -52
|
@@ -130,6 +130,12 @@ class BitcountNode extends MathNode {
|
|
|
130
130
|
|
|
131
131
|
const fnDef = Fn( ( [ value ] ) => {
|
|
132
132
|
|
|
133
|
+
If( value.equal( uint( 0 ) ), () => {
|
|
134
|
+
|
|
135
|
+
return uint( 32 );
|
|
136
|
+
|
|
137
|
+
} );
|
|
138
|
+
|
|
133
139
|
const v = uint( 0.0 );
|
|
134
140
|
|
|
135
141
|
this._resolveElementType( value, v, elementType );
|
|
@@ -388,14 +394,28 @@ class BitcountNode extends MathNode {
|
|
|
388
394
|
|
|
389
395
|
}
|
|
390
396
|
|
|
397
|
+
static get COUNT_TRAILING_ZEROS() {
|
|
398
|
+
|
|
399
|
+
return 'countTrailingZeros';
|
|
400
|
+
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
static get COUNT_LEADING_ZEROS() {
|
|
404
|
+
|
|
405
|
+
return 'countLeadingZeros';
|
|
406
|
+
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
static get COUNT_ONE_BITS() {
|
|
410
|
+
|
|
411
|
+
return 'countOneBits';
|
|
412
|
+
|
|
413
|
+
}
|
|
414
|
+
|
|
391
415
|
}
|
|
392
416
|
|
|
393
417
|
export default BitcountNode;
|
|
394
418
|
|
|
395
|
-
BitcountNode.COUNT_TRAILING_ZEROS = 'countTrailingZeros';
|
|
396
|
-
BitcountNode.COUNT_LEADING_ZEROS = 'countLeadingZeros';
|
|
397
|
-
BitcountNode.COUNT_ONE_BITS = 'countOneBits';
|
|
398
|
-
|
|
399
419
|
/**
|
|
400
420
|
* Finds the number of consecutive 0 bits from the least significant bit of the input value,
|
|
401
421
|
* which is also the index of the least significant bit of the input value.
|
|
@@ -2,7 +2,7 @@ import TempNode from '../core/TempNode.js';
|
|
|
2
2
|
import { sub, mul, div, mod } from './OperatorNode.js';
|
|
3
3
|
import { addMethodChaining, nodeObject, nodeProxyIntent, float, vec2, vec3, vec4, Fn } from '../tsl/TSLCore.js';
|
|
4
4
|
import { WebGLCoordinateSystem, WebGPUCoordinateSystem } from '../../constants.js';
|
|
5
|
-
import {
|
|
5
|
+
import { error } from '../../utils.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* This node represents a variety of mathematical methods available in shaders.
|
|
@@ -137,7 +137,7 @@ class MathNode extends TempNode {
|
|
|
137
137
|
|
|
138
138
|
const method = this.method;
|
|
139
139
|
|
|
140
|
-
if ( method === MathNode.LENGTH || method === MathNode.DISTANCE || method === MathNode.DOT ) {
|
|
140
|
+
if ( method === MathNode.LENGTH || method === MathNode.DISTANCE || method === MathNode.DOT || method === MathNode.DETERMINANT ) {
|
|
141
141
|
|
|
142
142
|
return 'float';
|
|
143
143
|
|
|
@@ -260,7 +260,7 @@ class MathNode extends TempNode {
|
|
|
260
260
|
|
|
261
261
|
params.push(
|
|
262
262
|
a.build( builder, inputType ),
|
|
263
|
-
b.build( builder, builder.getTypeLength( b.getNodeType( builder ) ) === 1 ?
|
|
263
|
+
b.build( builder, builder.getTypeLength( b.getNodeType( builder ) ) === 1 ? builder.getComponentType( inputType ) : inputType )
|
|
264
264
|
);
|
|
265
265
|
|
|
266
266
|
} else if ( method === MathNode.REFRACT ) {
|
|
@@ -289,7 +289,7 @@ class MathNode extends TempNode {
|
|
|
289
289
|
|
|
290
290
|
if ( builder.shaderStage !== 'fragment' && ( method === MathNode.DFDX || method === MathNode.DFDY ) ) {
|
|
291
291
|
|
|
292
|
-
|
|
292
|
+
error( `TSL: '${ method }' is not supported in the ${ builder.shaderStage } stage.`, this.stackTrace );
|
|
293
293
|
|
|
294
294
|
method = '/*' + method + '*/';
|
|
295
295
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { sub, mul, div, add } from './OperatorNode.js';
|
|
2
|
-
import { PI, pow, sin } from './MathNode.js';
|
|
2
|
+
import { PI, pow, sin, abs } from './MathNode.js';
|
|
3
|
+
import { select } from './ConditionalNode.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* A function that remaps the `[0,1]` interval into the `[0,1]` interval.
|
|
@@ -25,7 +26,11 @@ export const parabola = ( x, k ) => pow( mul( 4.0, x.mul( sub( 1.0, x ) ) ), k )
|
|
|
25
26
|
* @param {Node<float>} k - `k=1` is the identity curve,`k<1` produces the classic `gain()` shape, and `k>1` produces "s" shaped curves.
|
|
26
27
|
* @return {Node<float>} The remapped value.
|
|
27
28
|
*/
|
|
28
|
-
export const gain = ( x, k ) =>
|
|
29
|
+
export const gain = ( x, k ) => select(
|
|
30
|
+
x.lessThan( 0.5 ),
|
|
31
|
+
pow( mul( 2.0, x ), k ).mul( 0.5 ),
|
|
32
|
+
sub( 1.0, pow( mul( 2.0, sub( 1.0, x ) ), k ).mul( 0.5 ) )
|
|
33
|
+
);
|
|
29
34
|
|
|
30
35
|
/**
|
|
31
36
|
* A function that remaps the `[0,1]` interval into the `[0,1]` interval.
|
|
@@ -39,7 +44,7 @@ export const gain = ( x, k ) => x.lessThan( 0.5 ) ? parabola( x.mul( 2.0 ), k ).
|
|
|
39
44
|
* @param {Node<float>} b - Second control parameter.
|
|
40
45
|
* @return {Node<float>} The remapped value.
|
|
41
46
|
*/
|
|
42
|
-
export const pcurve = ( x, a, b ) => pow( div( pow( x, a ), add( pow( x, a ), pow( sub( 1.0, x ), b ) ) ), 1.0
|
|
47
|
+
export const pcurve = ( x, a, b ) => pow( div( pow( x, a ), add( pow( x, a ), pow( sub( 1.0, x ), b ) ) ), div( 1.0, a ) );
|
|
43
48
|
|
|
44
49
|
/**
|
|
45
50
|
* A phase shifted sinus curve that starts at zero and ends at zero, with bouncing behavior.
|
|
@@ -51,4 +56,10 @@ export const pcurve = ( x, a, b ) => pow( div( pow( x, a ), add( pow( x, a ), po
|
|
|
51
56
|
* @param {Node<float>} k - Controls the amount of bounces.
|
|
52
57
|
* @return {Node<float>} The result value.
|
|
53
58
|
*/
|
|
54
|
-
export const sinc = ( x, k ) =>
|
|
59
|
+
export const sinc = ( x, k ) => {
|
|
60
|
+
|
|
61
|
+
const arg = abs( PI.mul( k.mul( x ).sub( 1.0 ) ) ).max( 1e-6 ).toConst();
|
|
62
|
+
|
|
63
|
+
return sin( arg ).div( arg );
|
|
64
|
+
|
|
65
|
+
};
|
|
@@ -670,7 +670,7 @@ export const shiftRight = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '>>' ).se
|
|
|
670
670
|
* @param {Node} a - The node to increment.
|
|
671
671
|
* @returns {OperatorNode}
|
|
672
672
|
*/
|
|
673
|
-
export const incrementBefore = Fn( ( [ a ] ) => {
|
|
673
|
+
export const incrementBefore = /*@__PURE__*/ Fn( ( [ a ] ) => {
|
|
674
674
|
|
|
675
675
|
a.addAssign( 1 );
|
|
676
676
|
return a;
|
|
@@ -685,7 +685,7 @@ export const incrementBefore = Fn( ( [ a ] ) => {
|
|
|
685
685
|
* @param {Node} a - The node to decrement.
|
|
686
686
|
* @returns {OperatorNode}
|
|
687
687
|
*/
|
|
688
|
-
export const decrementBefore = Fn( ( [ a ] ) => {
|
|
688
|
+
export const decrementBefore = /*@__PURE__*/ Fn( ( [ a ] ) => {
|
|
689
689
|
|
|
690
690
|
a.subAssign( 1 );
|
|
691
691
|
return a;
|
|
@@ -37,6 +37,14 @@ class PackFloatNode extends TempNode {
|
|
|
37
37
|
*/
|
|
38
38
|
this.encoding = encoding;
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* The component layout of the packed integer.
|
|
42
|
+
*
|
|
43
|
+
* @type {'2x16' | '4x8'}
|
|
44
|
+
* @default '2x16'
|
|
45
|
+
*/
|
|
46
|
+
this.layout = '2x16';
|
|
47
|
+
|
|
40
48
|
/**
|
|
41
49
|
* This flag can be used for type testing.
|
|
42
50
|
*
|
|
@@ -57,7 +65,7 @@ class PackFloatNode extends TempNode {
|
|
|
57
65
|
generate( builder ) {
|
|
58
66
|
|
|
59
67
|
const inputType = this.vectorNode.getNodeType( builder );
|
|
60
|
-
return `${ builder.getFloatPackingMethod( this.encoding ) }(${ this.vectorNode.build( builder, inputType )})`;
|
|
68
|
+
return `${ builder.getFloatPackingMethod( this.encoding, this.layout ) }(${ this.vectorNode.build( builder, inputType )})`;
|
|
61
69
|
|
|
62
70
|
}
|
|
63
71
|
|
|
@@ -96,3 +104,23 @@ export const packUnorm2x16 = /*@__PURE__*/ nodeProxyIntent( PackFloatNode, 'unor
|
|
|
96
104
|
* @returns {Node}
|
|
97
105
|
*/
|
|
98
106
|
export const packHalf2x16 = /*@__PURE__*/ nodeProxyIntent( PackFloatNode, 'float16' ).setParameterLength( 1 );
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Converts each component of the normalized float to 8-bit integer values. The results are packed into a single unsigned integer.
|
|
110
|
+
*
|
|
111
|
+
* @tsl
|
|
112
|
+
* @function
|
|
113
|
+
* @param {Node<vec4>} value - The 4-component vector to be packed
|
|
114
|
+
* @returns {Node}
|
|
115
|
+
*/
|
|
116
|
+
export const packSnorm4x8 = /*@__PURE__*/ nodeProxyIntent( PackFloatNode, 'snorm', null, { layout: '4x8' } ).setParameterLength( 1 );
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Converts each component of the normalized float to 8-bit integer values. The results are packed into a single unsigned integer.
|
|
120
|
+
*
|
|
121
|
+
* @tsl
|
|
122
|
+
* @function
|
|
123
|
+
* @param {Node<vec4>} value - The 4-component vector to be packed
|
|
124
|
+
* @returns {Node}
|
|
125
|
+
*/
|
|
126
|
+
export const packUnorm4x8 = /*@__PURE__*/ nodeProxyIntent( PackFloatNode, 'unorm', null, { layout: '4x8' } ).setParameterLength( 1 );
|
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
import TempNode from '../core/TempNode.js';
|
|
2
|
+
import { nodeProxyIntent, Fn, uint, int, ivec4, uvec4 } from '../tsl/TSLCore.js';
|
|
3
|
+
import { clamp } from './MathNode.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents one of the built-in functions of WGSL's `packed_4x8_integer_dot_product`
|
|
7
|
+
* language extension. If the extension is not available, the node falls back to an
|
|
8
|
+
* emulation with plain integer bit operations.
|
|
9
|
+
*
|
|
10
|
+
* @augments TempNode
|
|
11
|
+
*/
|
|
12
|
+
class Packed4x8IntegerNode extends TempNode {
|
|
13
|
+
|
|
14
|
+
static get type() {
|
|
15
|
+
|
|
16
|
+
return 'Packed4x8IntegerNode';
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Constructs a packed 4x8 integer function node.
|
|
22
|
+
*
|
|
23
|
+
* @param {string} method - The WGSL built-in function name.
|
|
24
|
+
* @param {Node} aNode - The first argument.
|
|
25
|
+
* @param {?Node} [bNode=null] - The optional second argument.
|
|
26
|
+
*/
|
|
27
|
+
constructor( method, aNode, bNode = null ) {
|
|
28
|
+
|
|
29
|
+
super();
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The WGSL built-in function name.
|
|
33
|
+
*
|
|
34
|
+
* @type {string}
|
|
35
|
+
*/
|
|
36
|
+
this.method = method;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The first argument.
|
|
40
|
+
*
|
|
41
|
+
* @type {Node}
|
|
42
|
+
*/
|
|
43
|
+
this.aNode = aNode;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The optional second argument.
|
|
47
|
+
*
|
|
48
|
+
* @type {?Node}
|
|
49
|
+
*/
|
|
50
|
+
this.bNode = bNode;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* This flag can be used for type testing.
|
|
54
|
+
*
|
|
55
|
+
* @type {boolean}
|
|
56
|
+
* @readonly
|
|
57
|
+
* @default true
|
|
58
|
+
*/
|
|
59
|
+
this.isPacked4x8IntegerNode = true;
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
getInputType() {
|
|
64
|
+
|
|
65
|
+
const method = this.method;
|
|
66
|
+
|
|
67
|
+
if ( method === Packed4x8IntegerNode.PACK4X_I8 || method === Packed4x8IntegerNode.PACK4X_I8_CLAMP ) {
|
|
68
|
+
|
|
69
|
+
return 'ivec4';
|
|
70
|
+
|
|
71
|
+
} else if ( method === Packed4x8IntegerNode.PACK4X_U8 || method === Packed4x8IntegerNode.PACK4X_U8_CLAMP ) {
|
|
72
|
+
|
|
73
|
+
return 'uvec4';
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return 'uint';
|
|
78
|
+
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
generateNodeType() {
|
|
82
|
+
|
|
83
|
+
const method = this.method;
|
|
84
|
+
|
|
85
|
+
if ( method === Packed4x8IntegerNode.DOT4_I8_PACKED ) {
|
|
86
|
+
|
|
87
|
+
return 'int';
|
|
88
|
+
|
|
89
|
+
} else if ( method === Packed4x8IntegerNode.UNPACK4X_I8 ) {
|
|
90
|
+
|
|
91
|
+
return 'ivec4';
|
|
92
|
+
|
|
93
|
+
} else if ( method === Packed4x8IntegerNode.UNPACK4X_U8 ) {
|
|
94
|
+
|
|
95
|
+
return 'uvec4';
|
|
96
|
+
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return 'uint';
|
|
100
|
+
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Returns the reusable `Fn()` definition that emulates this node's method.
|
|
105
|
+
*
|
|
106
|
+
* @private
|
|
107
|
+
* @returns {Function} The emulation function.
|
|
108
|
+
*/
|
|
109
|
+
_getEmulatedFn() {
|
|
110
|
+
|
|
111
|
+
switch ( this.method ) {
|
|
112
|
+
|
|
113
|
+
case Packed4x8IntegerNode.DOT4_U8_PACKED: return emulatedDot4U8Packed;
|
|
114
|
+
case Packed4x8IntegerNode.DOT4_I8_PACKED: return emulatedDot4I8Packed;
|
|
115
|
+
case Packed4x8IntegerNode.PACK4X_I8: return emulatedPack4xI8;
|
|
116
|
+
case Packed4x8IntegerNode.PACK4X_U8: return emulatedPack4xU8;
|
|
117
|
+
case Packed4x8IntegerNode.PACK4X_I8_CLAMP: return emulatedPack4xI8Clamp;
|
|
118
|
+
case Packed4x8IntegerNode.PACK4X_U8_CLAMP: return emulatedPack4xU8Clamp;
|
|
119
|
+
case Packed4x8IntegerNode.UNPACK4X_I8: return emulatedUnpack4xI8;
|
|
120
|
+
case Packed4x8IntegerNode.UNPACK4X_U8: return emulatedUnpack4xU8;
|
|
121
|
+
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
setup( builder ) {
|
|
127
|
+
|
|
128
|
+
// check for native language support
|
|
129
|
+
|
|
130
|
+
if ( builder.renderer.backend.isWebGPUBackend === true &&
|
|
131
|
+
typeof navigator !== 'undefined' && navigator.gpu !== undefined &&
|
|
132
|
+
navigator.gpu.wgslLanguageFeatures !== undefined && navigator.gpu.wgslLanguageFeatures.has( 'packed_4x8_integer_dot_product' )
|
|
133
|
+
) {
|
|
134
|
+
|
|
135
|
+
return super.setup( builder );
|
|
136
|
+
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// emulation
|
|
140
|
+
|
|
141
|
+
const { aNode, bNode } = this;
|
|
142
|
+
const fn = this._getEmulatedFn();
|
|
143
|
+
|
|
144
|
+
return bNode !== null ? fn( aNode, bNode ) : fn( aNode );
|
|
145
|
+
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
generate( builder, output ) {
|
|
149
|
+
|
|
150
|
+
const properties = builder.getNodeProperties( this );
|
|
151
|
+
|
|
152
|
+
if ( properties.outputNode ) {
|
|
153
|
+
|
|
154
|
+
return super.generate( builder, output );
|
|
155
|
+
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// generate native WGSL call
|
|
159
|
+
|
|
160
|
+
const type = this.getNodeType( builder );
|
|
161
|
+
const inputType = this.getInputType();
|
|
162
|
+
const params = [ this.aNode.build( builder, inputType ) ];
|
|
163
|
+
|
|
164
|
+
if ( this.bNode !== null ) params.push( this.bNode.build( builder, inputType ) );
|
|
165
|
+
|
|
166
|
+
return builder.format( `${this.method}( ${params.join( ', ' )} )`, type, output );
|
|
167
|
+
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
serialize( data ) {
|
|
171
|
+
|
|
172
|
+
super.serialize( data );
|
|
173
|
+
|
|
174
|
+
data.method = this.method;
|
|
175
|
+
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
deserialize( data ) {
|
|
179
|
+
|
|
180
|
+
super.deserialize( data );
|
|
181
|
+
|
|
182
|
+
this.method = data.method;
|
|
183
|
+
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
static get DOT4_U8_PACKED() {
|
|
187
|
+
|
|
188
|
+
return 'dot4U8Packed';
|
|
189
|
+
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
static get DOT4_I8_PACKED() {
|
|
193
|
+
|
|
194
|
+
return 'dot4I8Packed';
|
|
195
|
+
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
static get PACK4X_I8() {
|
|
199
|
+
|
|
200
|
+
return 'pack4xI8';
|
|
201
|
+
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
static get PACK4X_U8() {
|
|
205
|
+
|
|
206
|
+
return 'pack4xU8';
|
|
207
|
+
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
static get PACK4X_I8_CLAMP() {
|
|
211
|
+
|
|
212
|
+
return 'pack4xI8Clamp';
|
|
213
|
+
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
static get PACK4X_U8_CLAMP() {
|
|
217
|
+
|
|
218
|
+
return 'pack4xU8Clamp';
|
|
219
|
+
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
static get UNPACK4X_I8() {
|
|
223
|
+
|
|
224
|
+
return 'unpack4xI8';
|
|
225
|
+
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
static get UNPACK4X_U8() {
|
|
229
|
+
|
|
230
|
+
return 'unpack4xU8';
|
|
231
|
+
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// emulations
|
|
237
|
+
|
|
238
|
+
const emulatedPack4xU8 = /*@__PURE__*/ Fn( ( [ v ] ) => {
|
|
239
|
+
|
|
240
|
+
const x = v.x.bitAnd( uint( 0xff ) );
|
|
241
|
+
const y = v.y.bitAnd( uint( 0xff ) );
|
|
242
|
+
const z = v.z.bitAnd( uint( 0xff ) );
|
|
243
|
+
const w = v.w.bitAnd( uint( 0xff ) );
|
|
244
|
+
|
|
245
|
+
return x.bitOr( y.shiftLeft( uint( 8 ) ) ).bitOr( z.shiftLeft( uint( 16 ) ) ).bitOr( w.shiftLeft( uint( 24 ) ) );
|
|
246
|
+
|
|
247
|
+
} ).setLayout( {
|
|
248
|
+
name: 'tsl_packed4x8_pack4xU8',
|
|
249
|
+
type: 'uint',
|
|
250
|
+
inputs: [ { name: 'v', type: 'uvec4' } ]
|
|
251
|
+
} );
|
|
252
|
+
|
|
253
|
+
const emulatedPack4xI8 = /*@__PURE__*/ Fn( ( [ v ] ) => {
|
|
254
|
+
|
|
255
|
+
return emulatedPack4xU8( uvec4( v ) );
|
|
256
|
+
|
|
257
|
+
} ).setLayout( {
|
|
258
|
+
name: 'tsl_packed4x8_pack4xI8',
|
|
259
|
+
type: 'uint',
|
|
260
|
+
inputs: [ { name: 'v', type: 'ivec4' } ]
|
|
261
|
+
} );
|
|
262
|
+
|
|
263
|
+
const emulatedPack4xU8Clamp = /*@__PURE__*/ Fn( ( [ v ] ) => {
|
|
264
|
+
|
|
265
|
+
return emulatedPack4xU8( clamp( v, uvec4( 0 ), uvec4( 255 ) ) );
|
|
266
|
+
|
|
267
|
+
} ).setLayout( {
|
|
268
|
+
name: 'tsl_packed4x8_pack4xU8Clamp',
|
|
269
|
+
type: 'uint',
|
|
270
|
+
inputs: [ { name: 'v', type: 'uvec4' } ]
|
|
271
|
+
} );
|
|
272
|
+
|
|
273
|
+
const emulatedPack4xI8Clamp = /*@__PURE__*/ Fn( ( [ v ] ) => {
|
|
274
|
+
|
|
275
|
+
return emulatedPack4xI8( clamp( v, ivec4( - 128 ), ivec4( 127 ) ) );
|
|
276
|
+
|
|
277
|
+
} ).setLayout( {
|
|
278
|
+
name: 'tsl_packed4x8_pack4xI8Clamp',
|
|
279
|
+
type: 'uint',
|
|
280
|
+
inputs: [ { name: 'v', type: 'ivec4' } ]
|
|
281
|
+
} );
|
|
282
|
+
|
|
283
|
+
const emulatedUnpack4xU8 = /*@__PURE__*/ Fn( ( [ v ] ) => {
|
|
284
|
+
|
|
285
|
+
return uvec4(
|
|
286
|
+
v.bitAnd( uint( 0xff ) ),
|
|
287
|
+
v.shiftRight( uint( 8 ) ).bitAnd( uint( 0xff ) ),
|
|
288
|
+
v.shiftRight( uint( 16 ) ).bitAnd( uint( 0xff ) ),
|
|
289
|
+
v.shiftRight( uint( 24 ) ).bitAnd( uint( 0xff ) )
|
|
290
|
+
);
|
|
291
|
+
|
|
292
|
+
} ).setLayout( {
|
|
293
|
+
name: 'tsl_packed4x8_unpack4xU8',
|
|
294
|
+
type: 'uvec4',
|
|
295
|
+
inputs: [ { name: 'v', type: 'uint' } ]
|
|
296
|
+
} );
|
|
297
|
+
|
|
298
|
+
function signExtendByte( v, byteShift ) {
|
|
299
|
+
|
|
300
|
+
return int( v.shiftLeft( uint( 24 - byteShift ) ) ).shiftRight( int( 24 ) );
|
|
301
|
+
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
const emulatedUnpack4xI8 = /*@__PURE__*/ Fn( ( [ v ] ) => {
|
|
305
|
+
|
|
306
|
+
return ivec4(
|
|
307
|
+
signExtendByte( v, 0 ),
|
|
308
|
+
signExtendByte( v, 8 ),
|
|
309
|
+
signExtendByte( v, 16 ),
|
|
310
|
+
signExtendByte( v, 24 )
|
|
311
|
+
);
|
|
312
|
+
|
|
313
|
+
} ).setLayout( {
|
|
314
|
+
name: 'tsl_packed4x8_unpack4xI8',
|
|
315
|
+
type: 'ivec4',
|
|
316
|
+
inputs: [ { name: 'v', type: 'uint' } ]
|
|
317
|
+
} );
|
|
318
|
+
|
|
319
|
+
const emulatedDot4U8Packed = /*@__PURE__*/ Fn( ( [ a, b ] ) => {
|
|
320
|
+
|
|
321
|
+
const ua = emulatedUnpack4xU8( a );
|
|
322
|
+
const ub = emulatedUnpack4xU8( b );
|
|
323
|
+
|
|
324
|
+
return ua.x.mul( ub.x ).add( ua.y.mul( ub.y ) ).add( ua.z.mul( ub.z ) ).add( ua.w.mul( ub.w ) );
|
|
325
|
+
|
|
326
|
+
} ).setLayout( {
|
|
327
|
+
name: 'tsl_packed4x8_dot4U8Packed',
|
|
328
|
+
type: 'uint',
|
|
329
|
+
inputs: [ { name: 'a', type: 'uint' }, { name: 'b', type: 'uint' } ]
|
|
330
|
+
} );
|
|
331
|
+
|
|
332
|
+
const emulatedDot4I8Packed = /*@__PURE__*/ Fn( ( [ a, b ] ) => {
|
|
333
|
+
|
|
334
|
+
const ia = emulatedUnpack4xI8( a );
|
|
335
|
+
const ib = emulatedUnpack4xI8( b );
|
|
336
|
+
|
|
337
|
+
return ia.x.mul( ib.x ).add( ia.y.mul( ib.y ) ).add( ia.z.mul( ib.z ) ).add( ia.w.mul( ib.w ) );
|
|
338
|
+
|
|
339
|
+
} ).setLayout( {
|
|
340
|
+
name: 'tsl_packed4x8_dot4I8Packed',
|
|
341
|
+
type: 'int',
|
|
342
|
+
inputs: [ { name: 'a', type: 'uint' }, { name: 'b', type: 'uint' } ]
|
|
343
|
+
} );
|
|
344
|
+
|
|
345
|
+
// exports
|
|
346
|
+
|
|
347
|
+
export default Packed4x8IntegerNode;
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Computes the dot product of four unsigned 8-bit integer components packed
|
|
351
|
+
* into each input.
|
|
352
|
+
*
|
|
353
|
+
* @tsl
|
|
354
|
+
* @function
|
|
355
|
+
* @param {Node<uint>} a - The first packed unsigned integer vector.
|
|
356
|
+
* @param {Node<uint>} b - The second packed unsigned integer vector.
|
|
357
|
+
* @returns {Node<uint>} The dot product.
|
|
358
|
+
*/
|
|
359
|
+
export const dot4U8Packed = /*@__PURE__*/ nodeProxyIntent( Packed4x8IntegerNode, Packed4x8IntegerNode.DOT4_U8_PACKED ).setParameterLength( 2 );
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Computes the dot product of four signed 8-bit integer components packed
|
|
363
|
+
* into each input.
|
|
364
|
+
*
|
|
365
|
+
* @tsl
|
|
366
|
+
* @function
|
|
367
|
+
* @param {Node<uint>} a - The first packed signed integer vector.
|
|
368
|
+
* @param {Node<uint>} b - The second packed signed integer vector.
|
|
369
|
+
* @returns {Node<int>} The dot product.
|
|
370
|
+
*/
|
|
371
|
+
export const dot4I8Packed = /*@__PURE__*/ nodeProxyIntent( Packed4x8IntegerNode, Packed4x8IntegerNode.DOT4_I8_PACKED ).setParameterLength( 2 );
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Packs the least significant 8 bits of four signed integers into a `uint`.
|
|
375
|
+
*
|
|
376
|
+
* @tsl
|
|
377
|
+
* @function
|
|
378
|
+
* @param {Node<ivec4>} value - The signed integer vector to pack.
|
|
379
|
+
* @returns {Node<uint>} The packed value.
|
|
380
|
+
*/
|
|
381
|
+
export const pack4xI8 = /*@__PURE__*/ nodeProxyIntent( Packed4x8IntegerNode, Packed4x8IntegerNode.PACK4X_I8 ).setParameterLength( 1 );
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Packs the least significant 8 bits of four unsigned integers into a `uint`.
|
|
385
|
+
*
|
|
386
|
+
* @tsl
|
|
387
|
+
* @function
|
|
388
|
+
* @param {Node<uvec4>} value - The unsigned integer vector to pack.
|
|
389
|
+
* @returns {Node<uint>} The packed value.
|
|
390
|
+
*/
|
|
391
|
+
export const pack4xU8 = /*@__PURE__*/ nodeProxyIntent( Packed4x8IntegerNode, Packed4x8IntegerNode.PACK4X_U8 ).setParameterLength( 1 );
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Clamps four signed integers to the signed 8-bit range and packs them into a
|
|
395
|
+
* `uint`.
|
|
396
|
+
*
|
|
397
|
+
* @tsl
|
|
398
|
+
* @function
|
|
399
|
+
* @param {Node<ivec4>} value - The signed integer vector to clamp and pack.
|
|
400
|
+
* @returns {Node<uint>} The packed value.
|
|
401
|
+
*/
|
|
402
|
+
export const pack4xI8Clamp = /*@__PURE__*/ nodeProxyIntent( Packed4x8IntegerNode, Packed4x8IntegerNode.PACK4X_I8_CLAMP ).setParameterLength( 1 );
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Clamps four unsigned integers to the unsigned 8-bit range and packs them
|
|
406
|
+
* into a `uint`.
|
|
407
|
+
*
|
|
408
|
+
* @tsl
|
|
409
|
+
* @function
|
|
410
|
+
* @param {Node<uvec4>} value - The unsigned integer vector to clamp and pack.
|
|
411
|
+
* @returns {Node<uint>} The packed value.
|
|
412
|
+
*/
|
|
413
|
+
export const pack4xU8Clamp = /*@__PURE__*/ nodeProxyIntent( Packed4x8IntegerNode, Packed4x8IntegerNode.PACK4X_U8_CLAMP ).setParameterLength( 1 );
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Unpacks a `uint` into four sign-extended signed 8-bit integer components.
|
|
417
|
+
*
|
|
418
|
+
* @tsl
|
|
419
|
+
* @function
|
|
420
|
+
* @param {Node<uint>} value - The packed value.
|
|
421
|
+
* @returns {Node<ivec4>} The unpacked signed integer vector.
|
|
422
|
+
*/
|
|
423
|
+
export const unpack4xI8 = /*@__PURE__*/ nodeProxyIntent( Packed4x8IntegerNode, Packed4x8IntegerNode.UNPACK4X_I8 ).setParameterLength( 1 );
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Unpacks a `uint` into four zero-extended unsigned 8-bit integer components.
|
|
427
|
+
*
|
|
428
|
+
* @tsl
|
|
429
|
+
* @function
|
|
430
|
+
* @param {Node<uint>} value - The packed value.
|
|
431
|
+
* @returns {Node<uvec4>} The unpacked unsigned integer vector.
|
|
432
|
+
*/
|
|
433
|
+
export const unpack4xU8 = /*@__PURE__*/ nodeProxyIntent( Packed4x8IntegerNode, Packed4x8IntegerNode.UNPACK4X_U8 ).setParameterLength( 1 );
|
|
@@ -37,6 +37,14 @@ class UnpackFloatNode extends TempNode {
|
|
|
37
37
|
*/
|
|
38
38
|
this.encoding = encoding;
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* The component layout of the packed integer.
|
|
42
|
+
*
|
|
43
|
+
* @type {'2x16' | '4x8'}
|
|
44
|
+
* @default '2x16'
|
|
45
|
+
*/
|
|
46
|
+
this.layout = '2x16';
|
|
47
|
+
|
|
40
48
|
/**
|
|
41
49
|
* This flag can be used for type testing.
|
|
42
50
|
*
|
|
@@ -50,14 +58,14 @@ class UnpackFloatNode extends TempNode {
|
|
|
50
58
|
|
|
51
59
|
generateNodeType() {
|
|
52
60
|
|
|
53
|
-
return 'vec2';
|
|
61
|
+
return this.layout === '4x8' ? 'vec4' : 'vec2';
|
|
54
62
|
|
|
55
63
|
}
|
|
56
64
|
|
|
57
65
|
generate( builder ) {
|
|
58
66
|
|
|
59
67
|
const inputType = this.uintNode.getNodeType( builder );
|
|
60
|
-
return `${ builder.getFloatUnpackingMethod( this.encoding ) }(${ this.uintNode.build( builder, inputType )})`;
|
|
68
|
+
return `${ builder.getFloatUnpackingMethod( this.encoding, this.layout ) }(${ this.uintNode.build( builder, inputType )})`;
|
|
61
69
|
|
|
62
70
|
}
|
|
63
71
|
|
|
@@ -94,3 +102,23 @@ export const unpackUnorm2x16 = /*@__PURE__*/ nodeProxyIntent( UnpackFloatNode, '
|
|
|
94
102
|
* @returns {Node}
|
|
95
103
|
*/
|
|
96
104
|
export const unpackHalf2x16 = /*@__PURE__*/ nodeProxyIntent( UnpackFloatNode, 'float16' ).setParameterLength( 1 );
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Unpacks a 32-bit unsigned integer into four 8-bit values, interpreted as normalized signed integers. Returns a vec4 with all values.
|
|
108
|
+
*
|
|
109
|
+
* @tsl
|
|
110
|
+
* @function
|
|
111
|
+
* @param {Node<uint>} value - The unsigned integer to be unpacked
|
|
112
|
+
* @returns {Node}
|
|
113
|
+
*/
|
|
114
|
+
export const unpackSnorm4x8 = /*@__PURE__*/ nodeProxyIntent( UnpackFloatNode, 'snorm', null, { layout: '4x8' } ).setParameterLength( 1 );
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Unpacks a 32-bit unsigned integer into four 8-bit values, interpreted as normalized unsigned integers. Returns a vec4 with all values.
|
|
118
|
+
*
|
|
119
|
+
* @tsl
|
|
120
|
+
* @function
|
|
121
|
+
* @param {Node<uint>} value - The unsigned integer to be unpacked
|
|
122
|
+
* @returns {Node}
|
|
123
|
+
*/
|
|
124
|
+
export const unpackUnorm4x8 = /*@__PURE__*/ nodeProxyIntent( UnpackFloatNode, 'unorm', null, { layout: '4x8' } ).setParameterLength( 1 );
|
|
@@ -12,7 +12,7 @@ const parse = ( source ) => {
|
|
|
12
12
|
|
|
13
13
|
const pragmaMainIndex = source.indexOf( pragmaMain );
|
|
14
14
|
|
|
15
|
-
const mainCode = pragmaMainIndex !== - 1 ? source.slice( pragmaMainIndex + pragmaMain.length ) : source;
|
|
15
|
+
const mainCode = ( pragmaMainIndex !== - 1 ? source.slice( pragmaMainIndex + pragmaMain.length ) : source ).replace( /^(?:\s*\/\/[^\r\n]*|\s*\/\*[\s\S]*?\*\/|\s*)+/, '' );
|
|
16
16
|
|
|
17
17
|
const declaration = mainCode.match( declarationRegexp );
|
|
18
18
|
|
|
@@ -343,7 +343,7 @@ class PMREMNode extends TempNode {
|
|
|
343
343
|
// PMREMGenerator renders into a render target with inverted Y, so its output needs the Y
|
|
344
344
|
// flip on sampling. Externally authored PMREMs follow the standard convention and don't.
|
|
345
345
|
|
|
346
|
-
uvNode = this._pmrem.isRenderTargetTexture
|
|
346
|
+
uvNode = this._pmrem === null || this._pmrem.isRenderTargetTexture
|
|
347
347
|
? materialEnvRotation.mul( vec3( uvNode.x, uvNode.y.negate(), uvNode.z ) )
|
|
348
348
|
: materialEnvRotation.mul( uvNode );
|
|
349
349
|
|