@luma.gl/shaders 0.0.0-stage → 10.0.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +38 -0
- package/README.md +25 -2
- package/dist/dist.dev.js +19686 -0
- package/dist/dist.min.js +12180 -0
- package/dist/glsl.cjs +33 -0
- package/dist/glsl.cjs.map +6 -0
- package/dist/glsl.d.ts +6 -0
- package/dist/glsl.d.ts.map +1 -0
- package/dist/glsl.js +7 -0
- package/dist/glsl.js.map +1 -0
- package/dist/index.cjs +243 -0
- package/dist/index.cjs.map +6 -0
- package/dist/index.d.ts +91 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +65 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/color/normalize-byte-colors.cjs +50 -0
- package/dist/lib/color/normalize-byte-colors.d.ts +23 -0
- package/dist/lib/color/normalize-byte-colors.d.ts.map +1 -0
- package/dist/lib/color/normalize-byte-colors.js +42 -0
- package/dist/lib/color/normalize-byte-colors.js.map +1 -0
- package/dist/lib/filters/prop-types.cjs +90 -0
- package/dist/lib/filters/prop-types.d.ts +44 -0
- package/dist/lib/filters/prop-types.d.ts.map +1 -0
- package/dist/lib/filters/prop-types.js +96 -0
- package/dist/lib/filters/prop-types.js.map +1 -0
- package/dist/lib/glsl-shader-assembler.cjs +50 -0
- package/dist/lib/glsl-shader-assembler.d.ts +19 -0
- package/dist/lib/glsl-shader-assembler.d.ts.map +1 -0
- package/dist/lib/glsl-shader-assembler.js +29 -0
- package/dist/lib/glsl-shader-assembler.js.map +1 -0
- package/dist/lib/glsl-utils/get-shader-info.cjs +52 -0
- package/dist/lib/glsl-utils/get-shader-info.d.ts +9 -0
- package/dist/lib/glsl-utils/get-shader-info.d.ts.map +1 -0
- package/dist/lib/glsl-utils/get-shader-info.js +33 -0
- package/dist/lib/glsl-utils/get-shader-info.js.map +1 -0
- package/dist/lib/glsl-utils/shader-utils.cjs +126 -0
- package/dist/lib/glsl-utils/shader-utils.d.ts +23 -0
- package/dist/lib/glsl-utils/shader-utils.d.ts.map +1 -0
- package/dist/lib/glsl-utils/shader-utils.js +92 -0
- package/dist/lib/glsl-utils/shader-utils.js.map +1 -0
- package/dist/lib/preprocessor/preprocessor.cjs +107 -0
- package/dist/lib/preprocessor/preprocessor.d.ts +15 -0
- package/dist/lib/preprocessor/preprocessor.d.ts.map +1 -0
- package/dist/lib/preprocessor/preprocessor.js +99 -0
- package/dist/lib/preprocessor/preprocessor.js.map +1 -0
- package/dist/lib/shader-assembler-base.cjs +133 -0
- package/dist/lib/shader-assembler-base.d.ts +52 -0
- package/dist/lib/shader-assembler-base.d.ts.map +1 -0
- package/dist/lib/shader-assembler-base.js +128 -0
- package/dist/lib/shader-assembler-base.js.map +1 -0
- package/dist/lib/shader-assembler.cjs +33 -0
- package/dist/lib/shader-assembler.d.ts +4 -0
- package/dist/lib/shader-assembler.d.ts.map +1 -0
- package/dist/lib/shader-assembler.js +7 -0
- package/dist/lib/shader-assembler.js.map +1 -0
- package/dist/lib/shader-assembly/assemble-glsl-shaders.cjs +200 -0
- package/dist/lib/shader-assembly/assemble-glsl-shaders.d.ts +69 -0
- package/dist/lib/shader-assembly/assemble-glsl-shaders.d.ts.map +1 -0
- package/dist/lib/shader-assembly/assemble-glsl-shaders.js +221 -0
- package/dist/lib/shader-assembly/assemble-glsl-shaders.js.map +1 -0
- package/dist/lib/shader-assembly/assemble-shaders.cjs +42 -0
- package/dist/lib/shader-assembly/assemble-shaders.d.ts +10 -0
- package/dist/lib/shader-assembly/assemble-shaders.d.ts.map +1 -0
- package/dist/lib/shader-assembly/assemble-shaders.js +10 -0
- package/dist/lib/shader-assembly/assemble-shaders.js.map +1 -0
- package/dist/lib/shader-assembly/assemble-wgsl-shaders.cjs +501 -0
- package/dist/lib/shader-assembly/assemble-wgsl-shaders.d.ts +71 -0
- package/dist/lib/shader-assembly/assemble-wgsl-shaders.d.ts.map +1 -0
- package/dist/lib/shader-assembly/assemble-wgsl-shaders.js +473 -0
- package/dist/lib/shader-assembly/assemble-wgsl-shaders.js.map +1 -0
- package/dist/lib/shader-assembly/platform-defines.cjs +79 -0
- package/dist/lib/shader-assembly/platform-defines.d.ts +4 -0
- package/dist/lib/shader-assembly/platform-defines.d.ts.map +1 -0
- package/dist/lib/shader-assembly/platform-defines.js +52 -0
- package/dist/lib/shader-assembly/platform-defines.js.map +1 -0
- package/dist/lib/shader-assembly/platform-info.cjs +15 -0
- package/dist/lib/shader-assembly/platform-info.d.ts +20 -0
- package/dist/lib/shader-assembly/platform-info.d.ts.map +1 -0
- package/dist/lib/shader-assembly/platform-info.js +5 -0
- package/dist/lib/shader-assembly/platform-info.js.map +1 -0
- package/dist/lib/shader-assembly/shader-assembly-shared.cjs +96 -0
- package/dist/lib/shader-assembly/shader-assembly-shared.d.ts +16 -0
- package/dist/lib/shader-assembly/shader-assembly-shared.d.ts.map +1 -0
- package/dist/lib/shader-assembly/shader-assembly-shared.js +79 -0
- package/dist/lib/shader-assembly/shader-assembly-shared.js.map +1 -0
- package/dist/lib/shader-assembly/shader-assembly-types.cjs +15 -0
- package/dist/lib/shader-assembly/shader-assembly-types.d.ts +128 -0
- package/dist/lib/shader-assembly/shader-assembly-types.d.ts.map +1 -0
- package/dist/lib/shader-assembly/shader-assembly-types.js +5 -0
- package/dist/lib/shader-assembly/shader-assembly-types.js.map +1 -0
- package/dist/lib/shader-assembly/shader-hooks.cjs +103 -0
- package/dist/lib/shader-assembly/shader-hooks.d.ts +45 -0
- package/dist/lib/shader-assembly/shader-hooks.d.ts.map +1 -0
- package/dist/lib/shader-assembly/shader-hooks.js +84 -0
- package/dist/lib/shader-assembly/shader-hooks.js.map +1 -0
- package/dist/lib/shader-assembly/shader-injections.cjs +180 -0
- package/dist/lib/shader-assembly/shader-injections.d.ts +34 -0
- package/dist/lib/shader-assembly/shader-injections.d.ts.map +1 -0
- package/dist/lib/shader-assembly/shader-injections.js +183 -0
- package/dist/lib/shader-assembly/shader-injections.js.map +1 -0
- package/dist/lib/shader-assembly/shader-plugin-varyings.cjs +417 -0
- package/dist/lib/shader-assembly/shader-plugin-varyings.d.ts +15 -0
- package/dist/lib/shader-assembly/shader-plugin-varyings.d.ts.map +1 -0
- package/dist/lib/shader-assembly/shader-plugin-varyings.js +412 -0
- package/dist/lib/shader-assembly/shader-plugin-varyings.js.map +1 -0
- package/dist/lib/shader-assembly/shader-plugin-vertex-inputs.cjs +254 -0
- package/dist/lib/shader-assembly/shader-plugin-vertex-inputs.d.ts +12 -0
- package/dist/lib/shader-assembly/shader-plugin-vertex-inputs.d.ts.map +1 -0
- package/dist/lib/shader-assembly/shader-plugin-vertex-inputs.js +237 -0
- package/dist/lib/shader-assembly/shader-plugin-vertex-inputs.js.map +1 -0
- package/dist/lib/shader-assembly/wgsl-binding-debug.cjs +166 -0
- package/dist/lib/shader-assembly/wgsl-binding-debug.d.ts +37 -0
- package/dist/lib/shader-assembly/wgsl-binding-debug.d.ts.map +1 -0
- package/dist/lib/shader-assembly/wgsl-binding-debug.js +144 -0
- package/dist/lib/shader-assembly/wgsl-binding-debug.js.map +1 -0
- package/dist/lib/shader-assembly/wgsl-binding-scan.cjs +184 -0
- package/dist/lib/shader-assembly/wgsl-binding-scan.d.ts +19 -0
- package/dist/lib/shader-assembly/wgsl-binding-scan.d.ts.map +1 -0
- package/dist/lib/shader-assembly/wgsl-binding-scan.js +151 -0
- package/dist/lib/shader-assembly/wgsl-binding-scan.js.map +1 -0
- package/dist/lib/shader-assembly/wgsl-interface-scan.cjs +502 -0
- package/dist/lib/shader-assembly/wgsl-interface-scan.d.ts +14 -0
- package/dist/lib/shader-assembly/wgsl-interface-scan.d.ts.map +1 -0
- package/dist/lib/shader-assembly/wgsl-interface-scan.js +498 -0
- package/dist/lib/shader-assembly/wgsl-interface-scan.js.map +1 -0
- package/dist/lib/shader-generator/generate-shader.cjs +36 -0
- package/dist/lib/shader-generator/generate-shader.d.ts +8 -0
- package/dist/lib/shader-generator/generate-shader.d.ts.map +1 -0
- package/dist/lib/shader-generator/generate-shader.js +15 -0
- package/dist/lib/shader-generator/generate-shader.js.map +1 -0
- package/dist/lib/shader-generator/glsl/generate-glsl.cjs +94 -0
- package/dist/lib/shader-generator/glsl/generate-glsl.d.ts +7 -0
- package/dist/lib/shader-generator/glsl/generate-glsl.d.ts.map +1 -0
- package/dist/lib/shader-generator/glsl/generate-glsl.js +79 -0
- package/dist/lib/shader-generator/glsl/generate-glsl.js.map +1 -0
- package/dist/lib/shader-generator/utils/capitalize.cjs +29 -0
- package/dist/lib/shader-generator/utils/capitalize.d.ts +7 -0
- package/dist/lib/shader-generator/utils/capitalize.d.ts.map +1 -0
- package/dist/lib/shader-generator/utils/capitalize.js +12 -0
- package/dist/lib/shader-generator/utils/capitalize.js.map +1 -0
- package/dist/lib/shader-generator/wgsl/generate-wgsl.cjs +46 -0
- package/dist/lib/shader-generator/wgsl/generate-wgsl.d.ts +7 -0
- package/dist/lib/shader-generator/wgsl/generate-wgsl.d.ts.map +1 -0
- package/dist/lib/shader-generator/wgsl/generate-wgsl.js +23 -0
- package/dist/lib/shader-generator/wgsl/generate-wgsl.js.map +1 -0
- package/dist/lib/shader-module/composite-shader-pass.cjs +15 -0
- package/dist/lib/shader-module/composite-shader-pass.d.ts +41 -0
- package/dist/lib/shader-module/composite-shader-pass.d.ts.map +1 -0
- package/dist/lib/shader-module/composite-shader-pass.js +5 -0
- package/dist/lib/shader-module/composite-shader-pass.js.map +1 -0
- package/dist/lib/shader-module/shader-module-dependencies.cjs +83 -0
- package/dist/lib/shader-module/shader-module-dependencies.d.ts +39 -0
- package/dist/lib/shader-module/shader-module-dependencies.d.ts.map +1 -0
- package/dist/lib/shader-module/shader-module-dependencies.js +103 -0
- package/dist/lib/shader-module/shader-module-dependencies.js.map +1 -0
- package/dist/lib/shader-module/shader-module-uniform-layout.cjs +224 -0
- package/dist/lib/shader-module/shader-module-uniform-layout.d.ts +91 -0
- package/dist/lib/shader-module/shader-module-uniform-layout.d.ts.map +1 -0
- package/dist/lib/shader-module/shader-module-uniform-layout.js +253 -0
- package/dist/lib/shader-module/shader-module-uniform-layout.js.map +1 -0
- package/dist/lib/shader-module/shader-module.cjs +105 -0
- package/dist/lib/shader-module/shader-module.d.ts +98 -0
- package/dist/lib/shader-module/shader-module.d.ts.map +1 -0
- package/dist/lib/shader-module/shader-module.js +104 -0
- package/dist/lib/shader-module/shader-module.js.map +1 -0
- package/dist/lib/shader-module/shader-pass.cjs +15 -0
- package/dist/lib/shader-module/shader-pass.d.ts +48 -0
- package/dist/lib/shader-module/shader-pass.d.ts.map +1 -0
- package/dist/lib/shader-module/shader-pass.js +5 -0
- package/dist/lib/shader-module/shader-pass.js.map +1 -0
- package/dist/lib/shader-plugin.cjs +117 -0
- package/dist/lib/shader-plugin.d.ts +68 -0
- package/dist/lib/shader-plugin.d.ts.map +1 -0
- package/dist/lib/shader-plugin.js +98 -0
- package/dist/lib/shader-plugin.js.map +1 -0
- package/dist/lib/shader-transpiler/shader-transpiler.cjs +15 -0
- package/dist/lib/shader-transpiler/shader-transpiler.d.ts +27 -0
- package/dist/lib/shader-transpiler/shader-transpiler.d.ts.map +1 -0
- package/dist/lib/shader-transpiler/shader-transpiler.js +5 -0
- package/dist/lib/shader-transpiler/shader-transpiler.js.map +1 -0
- package/dist/lib/shader-transpiler/transpile-glsl-shader.cjs +71 -0
- package/dist/lib/shader-transpiler/transpile-glsl-shader.d.ts +9 -0
- package/dist/lib/shader-transpiler/transpile-glsl-shader.d.ts.map +1 -0
- package/dist/lib/shader-transpiler/transpile-glsl-shader.js +69 -0
- package/dist/lib/shader-transpiler/transpile-glsl-shader.js.map +1 -0
- package/dist/lib/utils/assert.cjs +34 -0
- package/dist/lib/utils/assert.d.ts +2 -0
- package/dist/lib/utils/assert.d.ts.map +1 -0
- package/dist/lib/utils/assert.js +13 -0
- package/dist/lib/utils/assert.js.map +1 -0
- package/dist/lib/utils/uniform-types.cjs +15 -0
- package/dist/lib/utils/uniform-types.d.ts +18 -0
- package/dist/lib/utils/uniform-types.d.ts.map +1 -0
- package/dist/lib/utils/uniform-types.js +5 -0
- package/dist/lib/utils/uniform-types.js.map +1 -0
- package/dist/lib/wgsl-shader-assembler.cjs +99 -0
- package/dist/lib/wgsl-shader-assembler.d.ts +34 -0
- package/dist/lib/wgsl-shader-assembler.d.ts.map +1 -0
- package/dist/lib/wgsl-shader-assembler.js +84 -0
- package/dist/lib/wgsl-shader-assembler.js.map +1 -0
- package/dist/module-injectors.cjs +59 -0
- package/dist/module-injectors.d.ts +3 -0
- package/dist/module-injectors.d.ts.map +1 -0
- package/dist/module-injectors.js +31 -0
- package/dist/module-injectors.js.map +1 -0
- package/dist/modules/color/float-colors.cjs +275 -0
- package/dist/modules/color/float-colors.d.ts +132 -0
- package/dist/modules/color/float-colors.d.ts.map +1 -0
- package/dist/modules/color/float-colors.js +248 -0
- package/dist/modules/color/float-colors.js.map +1 -0
- package/dist/modules/engine/clip/clip.cjs +152 -0
- package/dist/modules/engine/clip/clip.d.ts +12 -0
- package/dist/modules/engine/clip/clip.d.ts.map +1 -0
- package/dist/modules/engine/clip/clip.js +129 -0
- package/dist/modules/engine/clip/clip.js.map +1 -0
- package/dist/modules/engine/filter/filter.cjs +111 -0
- package/dist/modules/engine/filter/filter.d.ts +12 -0
- package/dist/modules/engine/filter/filter.d.ts.map +1 -0
- package/dist/modules/engine/filter/filter.js +88 -0
- package/dist/modules/engine/filter/filter.js.map +1 -0
- package/dist/modules/engine/geometry/geometry.cjs +63 -0
- package/dist/modules/engine/geometry/geometry.d.ts +9 -0
- package/dist/modules/engine/geometry/geometry.d.ts.map +1 -0
- package/dist/modules/engine/geometry/geometry.js +42 -0
- package/dist/modules/engine/geometry/geometry.js.map +1 -0
- package/dist/modules/engine/gpu-animation/gpu-animation.cjs +255 -0
- package/dist/modules/engine/gpu-animation/gpu-animation.d.ts +34 -0
- package/dist/modules/engine/gpu-animation/gpu-animation.d.ts.map +1 -0
- package/dist/modules/engine/gpu-animation/gpu-animation.js +228 -0
- package/dist/modules/engine/gpu-animation/gpu-animation.js.map +1 -0
- package/dist/modules/engine/picking/picking.cjs +210 -0
- package/dist/modules/engine/picking/picking.d.ts +77 -0
- package/dist/modules/engine/picking/picking.d.ts.map +1 -0
- package/dist/modules/engine/picking/picking.js +198 -0
- package/dist/modules/engine/picking/picking.js.map +1 -0
- package/dist/modules/engine/project/project.cjs +138 -0
- package/dist/modules/engine/project/project.d.ts +39 -0
- package/dist/modules/engine/project/project.d.ts.map +1 -0
- package/dist/modules/engine/project/project.js +129 -0
- package/dist/modules/engine/project/project.js.map +1 -0
- package/dist/modules/engine/skin/skin.cjs +212 -0
- package/dist/modules/engine/skin/skin.d.ts +52 -0
- package/dist/modules/engine/skin/skin.d.ts.map +1 -0
- package/dist/modules/engine/skin/skin.js +179 -0
- package/dist/modules/engine/skin/skin.js.map +1 -0
- package/dist/modules/engine/transform/transform.cjs +72 -0
- package/dist/modules/engine/transform/transform.d.ts +6 -0
- package/dist/modules/engine/transform/transform.d.ts.map +1 -0
- package/dist/modules/engine/transform/transform.js +49 -0
- package/dist/modules/engine/transform/transform.js.map +1 -0
- package/dist/modules/geometry/path-dash/path-dash.cjs +93 -0
- package/dist/modules/geometry/path-dash/path-dash.d.ts +10 -0
- package/dist/modules/geometry/path-dash/path-dash.d.ts.map +1 -0
- package/dist/modules/geometry/path-dash/path-dash.js +66 -0
- package/dist/modules/geometry/path-dash/path-dash.js.map +1 -0
- package/dist/modules/geometry/pattern-fill/pattern-fill-shaders.cjs +117 -0
- package/dist/modules/geometry/pattern-fill/pattern-fill-shaders.d.ts +3 -0
- package/dist/modules/geometry/pattern-fill/pattern-fill-shaders.d.ts.map +1 -0
- package/dist/modules/geometry/pattern-fill/pattern-fill-shaders.js +87 -0
- package/dist/modules/geometry/pattern-fill/pattern-fill-shaders.js.map +1 -0
- package/dist/modules/geometry/pattern-fill/pattern-fill.cjs +64 -0
- package/dist/modules/geometry/pattern-fill/pattern-fill.d.ts +14 -0
- package/dist/modules/geometry/pattern-fill/pattern-fill.d.ts.map +1 -0
- package/dist/modules/geometry/pattern-fill/pattern-fill.js +43 -0
- package/dist/modules/geometry/pattern-fill/pattern-fill.js.map +1 -0
- package/dist/modules/geometry/point-glow/point-glow.cjs +104 -0
- package/dist/modules/geometry/point-glow/point-glow.d.ts +11 -0
- package/dist/modules/geometry/point-glow/point-glow.d.ts.map +1 -0
- package/dist/modules/geometry/point-glow/point-glow.js +77 -0
- package/dist/modules/geometry/point-glow/point-glow.js.map +1 -0
- package/dist/modules/geometry/precipitation/precipitation.cjs +122 -0
- package/dist/modules/geometry/precipitation/precipitation.d.ts +40 -0
- package/dist/modules/geometry/precipitation/precipitation.d.ts.map +1 -0
- package/dist/modules/geometry/precipitation/precipitation.js +95 -0
- package/dist/modules/geometry/precipitation/precipitation.js.map +1 -0
- package/dist/modules/geometry/sketch-stroke/sketch-stroke.cjs +158 -0
- package/dist/modules/geometry/sketch-stroke/sketch-stroke.d.ts +60 -0
- package/dist/modules/geometry/sketch-stroke/sketch-stroke.d.ts.map +1 -0
- package/dist/modules/geometry/sketch-stroke/sketch-stroke.js +137 -0
- package/dist/modules/geometry/sketch-stroke/sketch-stroke.js.map +1 -0
- package/dist/modules/geospatial/dggs/dggs-wgsl.cjs +2304 -0
- package/dist/modules/geospatial/dggs/dggs-wgsl.d.ts +3 -0
- package/dist/modules/geospatial/dggs/dggs-wgsl.d.ts.map +1 -0
- package/dist/modules/geospatial/dggs/dggs-wgsl.js +2283 -0
- package/dist/modules/geospatial/dggs/dggs-wgsl.js.map +1 -0
- package/dist/modules/geospatial/dggs/dggs.cjs +31 -0
- package/dist/modules/geospatial/dggs/dggs.d.ts +6 -0
- package/dist/modules/geospatial/dggs/dggs.d.ts.map +1 -0
- package/dist/modules/geospatial/dggs/dggs.js +10 -0
- package/dist/modules/geospatial/dggs/dggs.js.map +1 -0
- package/dist/modules/lighting/area-lighting/area-light-types.cjs +68 -0
- package/dist/modules/lighting/area-lighting/area-light-types.d.ts +34 -0
- package/dist/modules/lighting/area-lighting/area-light-types.d.ts.map +1 -0
- package/dist/modules/lighting/area-lighting/area-light-types.js +40 -0
- package/dist/modules/lighting/area-lighting/area-light-types.js.map +1 -0
- package/dist/modules/lighting/area-lighting/area-lighting-shaders.cjs +101 -0
- package/dist/modules/lighting/area-lighting/area-lighting-shaders.d.ts +3 -0
- package/dist/modules/lighting/area-lighting/area-lighting-shaders.d.ts.map +1 -0
- package/dist/modules/lighting/area-lighting/area-lighting-shaders.js +71 -0
- package/dist/modules/lighting/area-lighting/area-lighting-shaders.js.map +1 -0
- package/dist/modules/lighting/area-lighting/area-lighting.cjs +62 -0
- package/dist/modules/lighting/area-lighting/area-lighting.d.ts +89 -0
- package/dist/modules/lighting/area-lighting/area-lighting.d.ts.map +1 -0
- package/dist/modules/lighting/area-lighting/area-lighting.js +41 -0
- package/dist/modules/lighting/area-lighting/area-lighting.js.map +1 -0
- package/dist/modules/lighting/area-lighting/ltc-shaders.cjs +192 -0
- package/dist/modules/lighting/area-lighting/ltc-shaders.d.ts +3 -0
- package/dist/modules/lighting/area-lighting/ltc-shaders.d.ts.map +1 -0
- package/dist/modules/lighting/area-lighting/ltc-shaders.js +162 -0
- package/dist/modules/lighting/area-lighting/ltc-shaders.js.map +1 -0
- package/dist/modules/lighting/atmosphere/atmosphere.cjs +253 -0
- package/dist/modules/lighting/atmosphere/atmosphere.d.ts +45 -0
- package/dist/modules/lighting/atmosphere/atmosphere.d.ts.map +1 -0
- package/dist/modules/lighting/atmosphere/atmosphere.js +228 -0
- package/dist/modules/lighting/atmosphere/atmosphere.js.map +1 -0
- package/dist/modules/lighting/clouds/clouds.cjs +216 -0
- package/dist/modules/lighting/clouds/clouds.d.ts +58 -0
- package/dist/modules/lighting/clouds/clouds.d.ts.map +1 -0
- package/dist/modules/lighting/clouds/clouds.js +192 -0
- package/dist/modules/lighting/clouds/clouds.js.map +1 -0
- package/dist/modules/lighting/firefly/firefly.cjs +74 -0
- package/dist/modules/lighting/firefly/firefly.d.ts +36 -0
- package/dist/modules/lighting/firefly/firefly.d.ts.map +1 -0
- package/dist/modules/lighting/firefly/firefly.js +53 -0
- package/dist/modules/lighting/firefly/firefly.js.map +1 -0
- package/dist/modules/lighting/globe-clouds/globe-clouds.cjs +143 -0
- package/dist/modules/lighting/globe-clouds/globe-clouds.d.ts +53 -0
- package/dist/modules/lighting/globe-clouds/globe-clouds.d.ts.map +1 -0
- package/dist/modules/lighting/globe-clouds/globe-clouds.js +119 -0
- package/dist/modules/lighting/globe-clouds/globe-clouds.js.map +1 -0
- package/dist/modules/lighting/gouraud-material/gouraud-material.cjs +61 -0
- package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts +12 -0
- package/dist/modules/lighting/gouraud-material/gouraud-material.d.ts.map +1 -0
- package/dist/modules/lighting/gouraud-material/gouraud-material.js +40 -0
- package/dist/modules/lighting/gouraud-material/gouraud-material.js.map +1 -0
- package/dist/modules/lighting/height-fog/height-fog-functions.cjs +139 -0
- package/dist/modules/lighting/height-fog/height-fog-functions.d.ts +14 -0
- package/dist/modules/lighting/height-fog/height-fog-functions.d.ts.map +1 -0
- package/dist/modules/lighting/height-fog/height-fog-functions.js +114 -0
- package/dist/modules/lighting/height-fog/height-fog-functions.js.map +1 -0
- package/dist/modules/lighting/height-fog/height-fog.cjs +104 -0
- package/dist/modules/lighting/height-fog/height-fog.d.ts +60 -0
- package/dist/modules/lighting/height-fog/height-fog.d.ts.map +1 -0
- package/dist/modules/lighting/height-fog/height-fog.js +77 -0
- package/dist/modules/lighting/height-fog/height-fog.js.map +1 -0
- package/dist/modules/lighting/ibl/ibl.cjs +63 -0
- package/dist/modules/lighting/ibl/ibl.d.ts +25 -0
- package/dist/modules/lighting/ibl/ibl.d.ts.map +1 -0
- package/dist/modules/lighting/ibl/ibl.js +33 -0
- package/dist/modules/lighting/ibl/ibl.js.map +1 -0
- package/dist/modules/lighting/lambert-material/lambert-material.cjs +54 -0
- package/dist/modules/lighting/lambert-material/lambert-material.d.ts +10 -0
- package/dist/modules/lighting/lambert-material/lambert-material.d.ts.map +1 -0
- package/dist/modules/lighting/lambert-material/lambert-material.js +33 -0
- package/dist/modules/lighting/lambert-material/lambert-material.js.map +1 -0
- package/dist/modules/lighting/lambert-material/lambert-shaders-glsl.cjs +88 -0
- package/dist/modules/lighting/lambert-material/lambert-shaders-glsl.d.ts +3 -0
- package/dist/modules/lighting/lambert-material/lambert-shaders-glsl.d.ts.map +1 -0
- package/dist/modules/lighting/lambert-material/lambert-shaders-glsl.js +60 -0
- package/dist/modules/lighting/lambert-material/lambert-shaders-glsl.js.map +1 -0
- package/dist/modules/lighting/lambert-material/lambert-shaders-wgsl.cjs +97 -0
- package/dist/modules/lighting/lambert-material/lambert-shaders-wgsl.d.ts +2 -0
- package/dist/modules/lighting/lambert-material/lambert-shaders-wgsl.d.ts.map +1 -0
- package/dist/modules/lighting/lambert-material/lambert-shaders-wgsl.js +73 -0
- package/dist/modules/lighting/lambert-material/lambert-shaders-wgsl.js.map +1 -0
- package/dist/modules/lighting/lights/lighting-glsl.cjs +116 -0
- package/dist/modules/lighting/lights/lighting-glsl.d.ts +2 -0
- package/dist/modules/lighting/lights/lighting-glsl.d.ts.map +1 -0
- package/dist/modules/lighting/lights/lighting-glsl.js +92 -0
- package/dist/modules/lighting/lights/lighting-glsl.js.map +1 -0
- package/dist/modules/lighting/lights/lighting-wgsl.cjs +115 -0
- package/dist/modules/lighting/lights/lighting-wgsl.d.ts +2 -0
- package/dist/modules/lighting/lights/lighting-wgsl.d.ts.map +1 -0
- package/dist/modules/lighting/lights/lighting-wgsl.js +91 -0
- package/dist/modules/lighting/lights/lighting-wgsl.js.map +1 -0
- package/dist/modules/lighting/lights/lighting.cjs +210 -0
- package/dist/modules/lighting/lights/lighting.d.ts +163 -0
- package/dist/modules/lighting/lights/lighting.d.ts.map +1 -0
- package/dist/modules/lighting/lights/lighting.js +208 -0
- package/dist/modules/lighting/lights/lighting.js.map +1 -0
- package/dist/modules/lighting/no-material/dirlight.cjs +112 -0
- package/dist/modules/lighting/no-material/dirlight.d.ts +33 -0
- package/dist/modules/lighting/no-material/dirlight.d.ts.map +1 -0
- package/dist/modules/lighting/no-material/dirlight.js +86 -0
- package/dist/modules/lighting/no-material/dirlight.js.map +1 -0
- package/dist/modules/lighting/pbr-material/pbr-material-glsl.cjs +1767 -0
- package/dist/modules/lighting/pbr-material/pbr-material-glsl.d.ts +3 -0
- package/dist/modules/lighting/pbr-material/pbr-material-glsl.d.ts.map +1 -0
- package/dist/modules/lighting/pbr-material/pbr-material-glsl.js +1745 -0
- package/dist/modules/lighting/pbr-material/pbr-material-glsl.js.map +1 -0
- package/dist/modules/lighting/pbr-material/pbr-material-wgsl.cjs +2062 -0
- package/dist/modules/lighting/pbr-material/pbr-material-wgsl.d.ts +3 -0
- package/dist/modules/lighting/pbr-material/pbr-material-wgsl.d.ts.map +1 -0
- package/dist/modules/lighting/pbr-material/pbr-material-wgsl.js +2040 -0
- package/dist/modules/lighting/pbr-material/pbr-material-wgsl.js.map +1 -0
- package/dist/modules/lighting/pbr-material/pbr-material.cjs +315 -0
- package/dist/modules/lighting/pbr-material/pbr-material.d.ts +516 -0
- package/dist/modules/lighting/pbr-material/pbr-material.d.ts.map +1 -0
- package/dist/modules/lighting/pbr-material/pbr-material.js +292 -0
- package/dist/modules/lighting/pbr-material/pbr-material.js.map +1 -0
- package/dist/modules/lighting/pbr-material/pbr-projection.cjs +63 -0
- package/dist/modules/lighting/pbr-material/pbr-projection.d.ts +10 -0
- package/dist/modules/lighting/pbr-material/pbr-projection.d.ts.map +1 -0
- package/dist/modules/lighting/pbr-material/pbr-projection.js +37 -0
- package/dist/modules/lighting/pbr-material/pbr-projection.js.map +1 -0
- package/dist/modules/lighting/pbr-material/pbr-scene.cjs +109 -0
- package/dist/modules/lighting/pbr-material/pbr-scene.d.ts +52 -0
- package/dist/modules/lighting/pbr-material/pbr-scene.d.ts.map +1 -0
- package/dist/modules/lighting/pbr-material/pbr-scene.js +83 -0
- package/dist/modules/lighting/pbr-material/pbr-scene.js.map +1 -0
- package/dist/modules/lighting/phong-material/phong-material.cjs +61 -0
- package/dist/modules/lighting/phong-material/phong-material.d.ts +13 -0
- package/dist/modules/lighting/phong-material/phong-material.d.ts.map +1 -0
- package/dist/modules/lighting/phong-material/phong-material.js +40 -0
- package/dist/modules/lighting/phong-material/phong-material.js.map +1 -0
- package/dist/modules/lighting/phong-material/phong-shaders-glsl.cjs +100 -0
- package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts +3 -0
- package/dist/modules/lighting/phong-material/phong-shaders-glsl.d.ts.map +1 -0
- package/dist/modules/lighting/phong-material/phong-shaders-glsl.js +72 -0
- package/dist/modules/lighting/phong-material/phong-shaders-glsl.js.map +1 -0
- package/dist/modules/lighting/phong-material/phong-shaders-wgsl.cjs +153 -0
- package/dist/modules/lighting/phong-material/phong-shaders-wgsl.d.ts +2 -0
- package/dist/modules/lighting/phong-material/phong-shaders-wgsl.d.ts.map +1 -0
- package/dist/modules/lighting/phong-material/phong-shaders-wgsl.js +129 -0
- package/dist/modules/lighting/phong-material/phong-shaders-wgsl.js.map +1 -0
- package/dist/modules/lighting/surface-weather/surface-weather.cjs +199 -0
- package/dist/modules/lighting/surface-weather/surface-weather.d.ts +54 -0
- package/dist/modules/lighting/surface-weather/surface-weather.d.ts.map +1 -0
- package/dist/modules/lighting/surface-weather/surface-weather.js +175 -0
- package/dist/modules/lighting/surface-weather/surface-weather.js.map +1 -0
- package/dist/modules/lighting/water-material/river-water-material.cjs +56 -0
- package/dist/modules/lighting/water-material/river-water-material.d.ts +21 -0
- package/dist/modules/lighting/water-material/river-water-material.d.ts.map +1 -0
- package/dist/modules/lighting/water-material/river-water-material.js +36 -0
- package/dist/modules/lighting/water-material/river-water-material.js.map +1 -0
- package/dist/modules/lighting/water-material/river-water-shaders.cjs +261 -0
- package/dist/modules/lighting/water-material/river-water-shaders.d.ts +3 -0
- package/dist/modules/lighting/water-material/river-water-shaders.d.ts.map +1 -0
- package/dist/modules/lighting/water-material/river-water-shaders.js +233 -0
- package/dist/modules/lighting/water-material/river-water-shaders.js.map +1 -0
- package/dist/modules/lighting/water-material/water-material.cjs +188 -0
- package/dist/modules/lighting/water-material/water-material.d.ts +28 -0
- package/dist/modules/lighting/water-material/water-material.d.ts.map +1 -0
- package/dist/modules/lighting/water-material/water-material.js +179 -0
- package/dist/modules/lighting/water-material/water-material.js.map +1 -0
- package/dist/modules/lighting/water-material/water-shaders-glsl.cjs +260 -0
- package/dist/modules/lighting/water-material/water-shaders-glsl.d.ts +3 -0
- package/dist/modules/lighting/water-material/water-shaders-glsl.d.ts.map +1 -0
- package/dist/modules/lighting/water-material/water-shaders-glsl.js +232 -0
- package/dist/modules/lighting/water-material/water-shaders-glsl.js.map +1 -0
- package/dist/modules/lighting/water-material/water-shaders-wgsl.cjs +254 -0
- package/dist/modules/lighting/water-material/water-shaders-wgsl.d.ts +2 -0
- package/dist/modules/lighting/water-material/water-shaders-wgsl.d.ts.map +1 -0
- package/dist/modules/lighting/water-material/water-shaders-wgsl.js +230 -0
- package/dist/modules/lighting/water-material/water-shaders-wgsl.js.map +1 -0
- package/dist/modules/math/fp16/fp16-utils.cjs +112 -0
- package/dist/modules/math/fp16/fp16-utils.d.ts +13 -0
- package/dist/modules/math/fp16/fp16-utils.d.ts.map +1 -0
- package/dist/modules/math/fp16/fp16-utils.js +118 -0
- package/dist/modules/math/fp16/fp16-utils.js.map +1 -0
- package/dist/modules/math/fp32/fp32.cjs +310 -0
- package/dist/modules/math/fp32/fp32.d.ts +9 -0
- package/dist/modules/math/fp32/fp32.d.ts.map +1 -0
- package/dist/modules/math/fp32/fp32.js +288 -0
- package/dist/modules/math/fp32/fp32.js.map +1 -0
- package/dist/modules/math/fp64/fp64-arithmetic-glsl.cjs +229 -0
- package/dist/modules/math/fp64/fp64-arithmetic-glsl.d.ts +2 -0
- package/dist/modules/math/fp64/fp64-arithmetic-glsl.d.ts.map +1 -0
- package/dist/modules/math/fp64/fp64-arithmetic-glsl.js +205 -0
- package/dist/modules/math/fp64/fp64-arithmetic-glsl.js.map +1 -0
- package/dist/modules/math/fp64/fp64-arithmetic-wgsl-hybrid.cjs +144 -0
- package/dist/modules/math/fp64/fp64-arithmetic-wgsl-hybrid.d.ts +10 -0
- package/dist/modules/math/fp64/fp64-arithmetic-wgsl-hybrid.d.ts.map +1 -0
- package/dist/modules/math/fp64/fp64-arithmetic-wgsl-hybrid.js +128 -0
- package/dist/modules/math/fp64/fp64-arithmetic-wgsl-hybrid.js.map +1 -0
- package/dist/modules/math/fp64/fp64-arithmetic-wgsl-integer.cjs +583 -0
- package/dist/modules/math/fp64/fp64-arithmetic-wgsl-integer.d.ts +11 -0
- package/dist/modules/math/fp64/fp64-arithmetic-wgsl-integer.d.ts.map +1 -0
- package/dist/modules/math/fp64/fp64-arithmetic-wgsl-integer.js +563 -0
- package/dist/modules/math/fp64/fp64-arithmetic-wgsl-integer.js.map +1 -0
- package/dist/modules/math/fp64/fp64-arithmetic-wgsl.cjs +946 -0
- package/dist/modules/math/fp64/fp64-arithmetic-wgsl.d.ts +3 -0
- package/dist/modules/math/fp64/fp64-arithmetic-wgsl.d.ts.map +1 -0
- package/dist/modules/math/fp64/fp64-arithmetic-wgsl.js +923 -0
- package/dist/modules/math/fp64/fp64-arithmetic-wgsl.js.map +1 -0
- package/dist/modules/math/fp64/fp64-functions-glsl.cjs +699 -0
- package/dist/modules/math/fp64/fp64-functions-glsl.d.ts +2 -0
- package/dist/modules/math/fp64/fp64-functions-glsl.d.ts.map +1 -0
- package/dist/modules/math/fp64/fp64-functions-glsl.js +675 -0
- package/dist/modules/math/fp64/fp64-functions-glsl.js.map +1 -0
- package/dist/modules/math/fp64/fp64-functions-wgsl.cjs +180 -0
- package/dist/modules/math/fp64/fp64-functions-wgsl.d.ts +3 -0
- package/dist/modules/math/fp64/fp64-functions-wgsl.d.ts.map +1 -0
- package/dist/modules/math/fp64/fp64-functions-wgsl.js +157 -0
- package/dist/modules/math/fp64/fp64-functions-wgsl.js.map +1 -0
- package/dist/modules/math/fp64/fp64-utils.cjs +50 -0
- package/dist/modules/math/fp64/fp64-utils.d.ts +22 -0
- package/dist/modules/math/fp64/fp64-utils.d.ts.map +1 -0
- package/dist/modules/math/fp64/fp64-utils.js +42 -0
- package/dist/modules/math/fp64/fp64-utils.js.map +1 -0
- package/dist/modules/math/fp64/fp64.cjs +68 -0
- package/dist/modules/math/fp64/fp64.d.ts +24 -0
- package/dist/modules/math/fp64/fp64.d.ts.map +1 -0
- package/dist/modules/math/fp64/fp64.js +46 -0
- package/dist/modules/math/fp64/fp64.js.map +1 -0
- package/dist/modules/math/random/random.cjs +46 -0
- package/dist/modules/math/random/random.d.ts +7 -0
- package/dist/modules/math/random/random.d.ts.map +1 -0
- package/dist/modules/math/random/random.js +21 -0
- package/dist/modules/math/random/random.js.map +1 -0
- package/dist/modules/math/value-noise/value-noise.cjs +95 -0
- package/dist/modules/math/value-noise/value-noise.d.ts +7 -0
- package/dist/modules/math/value-noise/value-noise.d.ts.map +1 -0
- package/dist/modules/math/value-noise/value-noise.js +68 -0
- package/dist/modules/math/value-noise/value-noise.js.map +1 -0
- package/dist/modules/volume/volume-raymarch.cjs +107 -0
- package/dist/modules/volume/volume-raymarch.d.ts +6 -0
- package/dist/modules/volume/volume-raymarch.d.ts.map +1 -0
- package/dist/modules/volume/volume-raymarch.js +84 -0
- package/dist/modules/volume/volume-raymarch.js.map +1 -0
- package/dist/types/align-to.cjs +38 -0
- package/dist/types/align-to.d.ts +3 -0
- package/dist/types/align-to.d.ts.map +1 -0
- package/dist/types/align-to.js +13 -0
- package/dist/types/align-to.js.map +1 -0
- package/dist/types/primitive-data-types.cjs +15 -0
- package/dist/types/primitive-data-types.d.ts +7 -0
- package/dist/types/primitive-data-types.d.ts.map +1 -0
- package/dist/types/primitive-data-types.js +5 -0
- package/dist/types/primitive-data-types.js.map +1 -0
- package/dist/types/sampler-props.cjs +15 -0
- package/dist/types/sampler-props.d.ts +26 -0
- package/dist/types/sampler-props.d.ts.map +1 -0
- package/dist/types/sampler-props.js +5 -0
- package/dist/types/sampler-props.js.map +1 -0
- package/dist/types/shader-block-layout.cjs +184 -0
- package/dist/types/shader-block-layout.d.ts +72 -0
- package/dist/types/shader-block-layout.d.ts.map +1 -0
- package/dist/types/shader-block-layout.js +209 -0
- package/dist/types/shader-block-layout.js.map +1 -0
- package/dist/types/shader-layout.cjs +15 -0
- package/dist/types/shader-layout.d.ts +178 -0
- package/dist/types/shader-layout.d.ts.map +1 -0
- package/dist/types/shader-layout.js +5 -0
- package/dist/types/shader-layout.js.map +1 -0
- package/dist/types/shader-type-decoder.cjs +240 -0
- package/dist/types/shader-type-decoder.d.ts +41 -0
- package/dist/types/shader-type-decoder.d.ts.map +1 -0
- package/dist/types/shader-type-decoder.js +210 -0
- package/dist/types/shader-type-decoder.js.map +1 -0
- package/dist/types/shader-types.cjs +15 -0
- package/dist/types/shader-types.d.ts +101 -0
- package/dist/types/shader-types.d.ts.map +1 -0
- package/dist/types/shader-types.js +30 -0
- package/dist/types/shader-types.js.map +1 -0
- package/dist/types/texture-formats.cjs +15 -0
- package/dist/types/texture-formats.d.ts +24 -0
- package/dist/types/texture-formats.d.ts.map +1 -0
- package/dist/types/texture-formats.js +5 -0
- package/dist/types/texture-formats.js.map +1 -0
- package/dist/types.cjs +42 -0
- package/dist/types.cjs.map +6 -0
- package/dist/types.d.ts +14 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +12 -0
- package/dist/types.js.map +1 -0
- package/dist/wgsl.cjs +39 -0
- package/dist/wgsl.cjs.map +6 -0
- package/dist/wgsl.d.ts +8 -0
- package/dist/wgsl.d.ts.map +1 -0
- package/dist/wgsl.js +9 -0
- package/dist/wgsl.js.map +1 -0
- package/package.json +65 -4
- package/src/glsl.ts +13 -0
- package/src/index.ts +259 -0
- package/src/lib/color/normalize-byte-colors.ts +57 -0
- package/src/lib/filters/prop-types.ts +150 -0
- package/src/lib/glsl-shader-assembler.ts +39 -0
- package/src/lib/glsl-utils/get-shader-info.ts +42 -0
- package/src/lib/glsl-utils/shader-utils.ts +110 -0
- package/src/lib/preprocessor/preprocessor.ts +132 -0
- package/src/lib/shader-assembler-base.ts +170 -0
- package/src/lib/shader-assembler.ts +7 -0
- package/src/lib/shader-assembly/assemble-glsl-shaders.ts +305 -0
- package/src/lib/shader-assembly/assemble-shaders.ts +13 -0
- package/src/lib/shader-assembly/assemble-wgsl-shaders.ts +801 -0
- package/src/lib/shader-assembly/platform-defines.ts +58 -0
- package/src/lib/shader-assembly/platform-info.ts +23 -0
- package/src/lib/shader-assembly/shader-assembly-shared.ts +95 -0
- package/src/lib/shader-assembly/shader-assembly-types.ts +142 -0
- package/src/lib/shader-assembly/shader-hooks.ts +141 -0
- package/src/lib/shader-assembly/shader-injections.ts +250 -0
- package/src/lib/shader-assembly/shader-plugin-varyings.ts +524 -0
- package/src/lib/shader-assembly/shader-plugin-vertex-inputs.ts +279 -0
- package/src/lib/shader-assembly/wgsl-binding-debug.ts +227 -0
- package/src/lib/shader-assembly/wgsl-binding-scan.ts +228 -0
- package/src/lib/shader-assembly/wgsl-interface-scan.ts +676 -0
- package/src/lib/shader-generator/generate-shader.ts +27 -0
- package/src/lib/shader-generator/glsl/generate-glsl.ts +101 -0
- package/src/lib/shader-generator/utils/capitalize.ts +12 -0
- package/src/lib/shader-generator/wgsl/generate-wgsl.ts +40 -0
- package/src/lib/shader-module/composite-shader-pass.ts +47 -0
- package/src/lib/shader-module/shader-module-dependencies.ts +128 -0
- package/src/lib/shader-module/shader-module-uniform-layout.ts +420 -0
- package/src/lib/shader-module/shader-module.ts +244 -0
- package/src/lib/shader-module/shader-pass.ts +69 -0
- package/src/lib/shader-plugin.ts +214 -0
- package/src/lib/shader-transpiler/shader-transpiler.ts +34 -0
- package/src/lib/shader-transpiler/transpile-glsl-shader.ts +78 -0
- package/src/lib/utils/assert.ts +13 -0
- package/src/lib/utils/uniform-types.ts +89 -0
- package/src/lib/wgsl-shader-assembler.ts +122 -0
- package/src/module-injectors.ts +32 -0
- package/src/modules/color/float-colors.ts +334 -0
- package/src/modules/engine/clip/clip.ts +149 -0
- package/src/modules/engine/filter/filter.ts +107 -0
- package/src/modules/engine/geometry/geometry.ts +45 -0
- package/src/modules/engine/gpu-animation/gpu-animation.ts +244 -0
- package/src/modules/engine/picking/README.md +88 -0
- package/src/modules/engine/picking/picking.ts +252 -0
- package/src/modules/engine/project/project.ts +166 -0
- package/src/modules/engine/skin/skin.ts +233 -0
- package/src/modules/engine/transform/transform.ts +50 -0
- package/src/modules/geometry/path-dash/path-dash.ts +68 -0
- package/src/modules/geometry/pattern-fill/pattern-fill-shaders.ts +88 -0
- package/src/modules/geometry/pattern-fill/pattern-fill.ts +54 -0
- package/src/modules/geometry/point-glow/point-glow.ts +87 -0
- package/src/modules/geometry/precipitation/README.md +19 -0
- package/src/modules/geometry/precipitation/precipitation.ts +108 -0
- package/src/modules/geometry/sketch-stroke/sketch-stroke.ts +160 -0
- package/src/modules/geospatial/dggs/dggs-wgsl.ts +2284 -0
- package/src/modules/geospatial/dggs/dggs.ts +12 -0
- package/src/modules/lighting/area-lighting/area-light-types.ts +71 -0
- package/src/modules/lighting/area-lighting/area-lighting-shaders.ts +72 -0
- package/src/modules/lighting/area-lighting/area-lighting.ts +63 -0
- package/src/modules/lighting/area-lighting/ltc-shaders.ts +163 -0
- package/src/modules/lighting/atmosphere/README.md +25 -0
- package/src/modules/lighting/atmosphere/atmosphere.ts +246 -0
- package/src/modules/lighting/clouds/README.md +24 -0
- package/src/modules/lighting/clouds/clouds.ts +216 -0
- package/src/modules/lighting/firefly/firefly.ts +64 -0
- package/src/modules/lighting/globe-clouds/globe-clouds.ts +124 -0
- package/src/modules/lighting/gouraud-material/gouraud-material.ts +55 -0
- package/src/modules/lighting/height-fog/README.md +36 -0
- package/src/modules/lighting/height-fog/height-fog-functions.ts +116 -0
- package/src/modules/lighting/height-fog/height-fog.ts +96 -0
- package/src/modules/lighting/ibl/ibl.ts +43 -0
- package/src/modules/lighting/lambert-material/lambert-material.ts +42 -0
- package/src/modules/lighting/lambert-material/lambert-shaders-glsl.ts +61 -0
- package/src/modules/lighting/lambert-material/lambert-shaders-wgsl.ts +73 -0
- package/src/modules/lighting/lights/lighting-glsl.ts +92 -0
- package/src/modules/lighting/lights/lighting-wgsl.ts +91 -0
- package/src/modules/lighting/lights/lighting.ts +385 -0
- package/src/modules/lighting/no-material/dirlight.ts +101 -0
- package/src/modules/lighting/pbr-material/pbr-material-glsl.ts +1748 -0
- package/src/modules/lighting/pbr-material/pbr-material-wgsl.ts +2043 -0
- package/src/modules/lighting/pbr-material/pbr-material.ts +517 -0
- package/src/modules/lighting/pbr-material/pbr-projection.ts +50 -0
- package/src/modules/lighting/pbr-material/pbr-scene.ts +112 -0
- package/src/modules/lighting/phong-material/phong-material.ts +53 -0
- package/src/modules/lighting/phong-material/phong-shaders-glsl.ts +73 -0
- package/src/modules/lighting/phong-material/phong-shaders-wgsl.ts +129 -0
- package/src/modules/lighting/surface-weather/README.md +28 -0
- package/src/modules/lighting/surface-weather/surface-weather.ts +198 -0
- package/src/modules/lighting/water-material/river-water-material.ts +58 -0
- package/src/modules/lighting/water-material/river-water-shaders.ts +234 -0
- package/src/modules/lighting/water-material/water-material.ts +234 -0
- package/src/modules/lighting/water-material/water-shaders-glsl.ts +233 -0
- package/src/modules/lighting/water-material/water-shaders-wgsl.ts +230 -0
- package/src/modules/math/fp16/fp16-utils.ts +156 -0
- package/src/modules/math/fp32/fp32.ts +291 -0
- package/src/modules/math/fp64/fp64-arithmetic-glsl.ts +205 -0
- package/src/modules/math/fp64/fp64-arithmetic-wgsl-hybrid.ts +129 -0
- package/src/modules/math/fp64/fp64-arithmetic-wgsl-integer.ts +564 -0
- package/src/modules/math/fp64/fp64-arithmetic-wgsl.ts +924 -0
- package/src/modules/math/fp64/fp64-functions-glsl.ts +675 -0
- package/src/modules/math/fp64/fp64-functions-wgsl.ts +157 -0
- package/src/modules/math/fp64/fp64-utils.ts +46 -0
- package/src/modules/math/fp64/fp64.ts +64 -0
- package/src/modules/math/random/random.ts +25 -0
- package/src/modules/math/value-noise/value-noise.ts +70 -0
- package/src/modules/volume/volume-raymarch.ts +87 -0
- package/src/types/align-to.ts +13 -0
- package/src/types/primitive-data-types.ts +10 -0
- package/src/types/sampler-props.ts +39 -0
- package/src/types/shader-block-layout.ts +340 -0
- package/src/types/shader-layout.ts +208 -0
- package/src/types/shader-type-decoder.ts +285 -0
- package/src/types/shader-types.ts +207 -0
- package/src/types/texture-formats.ts +155 -0
- package/src/types.ts +48 -0
- package/src/wgsl.ts +23 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var fp64_arithmetic_glsl_exports = {};
|
|
19
|
+
__export(fp64_arithmetic_glsl_exports, {
|
|
20
|
+
fp64arithmeticShader: () => fp64arithmeticShader
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(fp64_arithmetic_glsl_exports);
|
|
23
|
+
const fp64arithmeticShader = (
|
|
24
|
+
/* glsl */
|
|
25
|
+
`
|
|
26
|
+
layout(std140) uniform fp64arithmeticUniforms {
|
|
27
|
+
uniform float ONE;
|
|
28
|
+
uniform float SPLIT;
|
|
29
|
+
} fp64;
|
|
30
|
+
|
|
31
|
+
/*
|
|
32
|
+
About LUMA_FP64_CODE_ELIMINATION_WORKAROUND
|
|
33
|
+
|
|
34
|
+
The purpose of this workaround is to prevent shader compilers from
|
|
35
|
+
optimizing away necessary arithmetic operations by swapping their sequences
|
|
36
|
+
or transform the equation to some 'equivalent' form.
|
|
37
|
+
|
|
38
|
+
These helpers implement Dekker/Veltkamp-style error tracking. If the compiler
|
|
39
|
+
folds constants or reassociates the arithmetic, the high/low split can stop
|
|
40
|
+
tracking the rounding error correctly. That failure mode tends to look fine in
|
|
41
|
+
simple coordinate setup, but then breaks down inside iterative arithmetic such
|
|
42
|
+
as fp64 Mandelbrot loops.
|
|
43
|
+
|
|
44
|
+
The method is to multiply an artifical variable, ONE, which will be known to
|
|
45
|
+
the compiler to be 1 only at runtime. The whole expression is then represented
|
|
46
|
+
as a polynomial with respective to ONE. In the coefficients of all terms, only one a
|
|
47
|
+
and one b should appear
|
|
48
|
+
|
|
49
|
+
err = (a + b) * ONE^6 - a * ONE^5 - (a + b) * ONE^4 + a * ONE^3 - b - (a + b) * ONE^2 + a * ONE
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
float prevent_fp64_optimization(float value) {
|
|
53
|
+
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
|
|
54
|
+
return value + fp64.ONE * 0.0;
|
|
55
|
+
#else
|
|
56
|
+
return value;
|
|
57
|
+
#endif
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Divide float number to high and low floats to extend fraction bits
|
|
61
|
+
vec2 split(float a) {
|
|
62
|
+
// Keep SPLIT as a runtime uniform so the compiler cannot fold the Dekker
|
|
63
|
+
// split into a constant expression and reassociate the recovery steps.
|
|
64
|
+
float split = prevent_fp64_optimization(fp64.SPLIT);
|
|
65
|
+
float t = prevent_fp64_optimization(a * split);
|
|
66
|
+
float temp = t - a;
|
|
67
|
+
float a_hi = t - temp;
|
|
68
|
+
float a_lo = a - a_hi;
|
|
69
|
+
return vec2(a_hi, a_lo);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Divide float number again when high float uses too many fraction bits
|
|
73
|
+
vec2 split2(vec2 a) {
|
|
74
|
+
vec2 b = split(a.x);
|
|
75
|
+
b.y += a.y;
|
|
76
|
+
return b;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Special sum operation when a > b
|
|
80
|
+
vec2 quickTwoSum(float a, float b) {
|
|
81
|
+
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
|
|
82
|
+
float sum = (a + b) * fp64.ONE;
|
|
83
|
+
float err = b - (sum - a) * fp64.ONE;
|
|
84
|
+
#else
|
|
85
|
+
float sum = a + b;
|
|
86
|
+
float err = b - (sum - a);
|
|
87
|
+
#endif
|
|
88
|
+
return vec2(sum, err);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// General sum operation
|
|
92
|
+
vec2 twoSum(float a, float b) {
|
|
93
|
+
float s = (a + b);
|
|
94
|
+
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
|
|
95
|
+
float v = (s * fp64.ONE - a) * fp64.ONE;
|
|
96
|
+
float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE + (b - v);
|
|
97
|
+
#else
|
|
98
|
+
float v = s - a;
|
|
99
|
+
float err = (a - (s - v)) + (b - v);
|
|
100
|
+
#endif
|
|
101
|
+
return vec2(s, err);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
vec2 twoSub(float a, float b) {
|
|
105
|
+
float s = (a - b);
|
|
106
|
+
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
|
|
107
|
+
float v = (s * fp64.ONE - a) * fp64.ONE;
|
|
108
|
+
float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE - (b + v);
|
|
109
|
+
#else
|
|
110
|
+
float v = s - a;
|
|
111
|
+
float err = (a - (s - v)) - (b + v);
|
|
112
|
+
#endif
|
|
113
|
+
return vec2(s, err);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
vec2 twoSqr(float a) {
|
|
117
|
+
float prod = a * a;
|
|
118
|
+
vec2 a_fp64 = split(a);
|
|
119
|
+
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
|
|
120
|
+
float err = ((a_fp64.x * a_fp64.x - prod) * fp64.ONE + 2.0 * a_fp64.x *
|
|
121
|
+
a_fp64.y * fp64.ONE * fp64.ONE) + a_fp64.y * a_fp64.y * fp64.ONE * fp64.ONE * fp64.ONE;
|
|
122
|
+
#else
|
|
123
|
+
float err = ((a_fp64.x * a_fp64.x - prod) + 2.0 * a_fp64.x * a_fp64.y) + a_fp64.y * a_fp64.y;
|
|
124
|
+
#endif
|
|
125
|
+
return vec2(prod, err);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
vec2 twoProd(float a, float b) {
|
|
129
|
+
float prod = a * b;
|
|
130
|
+
vec2 a_fp64 = split(a);
|
|
131
|
+
vec2 b_fp64 = split(b);
|
|
132
|
+
// twoProd is especially sensitive because mul_fp64 and div_fp64 both depend
|
|
133
|
+
// on the split terms and cross terms staying in the original evaluation
|
|
134
|
+
// order. If the compiler folds or reassociates them, the low part tends to
|
|
135
|
+
// collapse to zero or NaN on some drivers.
|
|
136
|
+
float highProduct = prevent_fp64_optimization(a_fp64.x * b_fp64.x);
|
|
137
|
+
float crossProduct1 = prevent_fp64_optimization(a_fp64.x * b_fp64.y);
|
|
138
|
+
float crossProduct2 = prevent_fp64_optimization(a_fp64.y * b_fp64.x);
|
|
139
|
+
float lowProduct = prevent_fp64_optimization(a_fp64.y * b_fp64.y);
|
|
140
|
+
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
|
|
141
|
+
float err1 = (highProduct - prod) * fp64.ONE;
|
|
142
|
+
float err2 = crossProduct1 * fp64.ONE * fp64.ONE;
|
|
143
|
+
float err3 = crossProduct2 * fp64.ONE * fp64.ONE * fp64.ONE;
|
|
144
|
+
float err4 = lowProduct * fp64.ONE * fp64.ONE * fp64.ONE * fp64.ONE;
|
|
145
|
+
#else
|
|
146
|
+
float err1 = highProduct - prod;
|
|
147
|
+
float err2 = crossProduct1;
|
|
148
|
+
float err3 = crossProduct2;
|
|
149
|
+
float err4 = lowProduct;
|
|
150
|
+
#endif
|
|
151
|
+
float err = ((err1 + err2) + err3) + err4;
|
|
152
|
+
return vec2(prod, err);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
vec2 sum_fp64(vec2 a, vec2 b) {
|
|
156
|
+
vec2 s, t;
|
|
157
|
+
s = twoSum(a.x, b.x);
|
|
158
|
+
t = twoSum(a.y, b.y);
|
|
159
|
+
s.y += t.x;
|
|
160
|
+
s = quickTwoSum(s.x, s.y);
|
|
161
|
+
s.y += t.y;
|
|
162
|
+
s = quickTwoSum(s.x, s.y);
|
|
163
|
+
return s;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
vec2 sub_fp64(vec2 a, vec2 b) {
|
|
167
|
+
vec2 s, t;
|
|
168
|
+
s = twoSub(a.x, b.x);
|
|
169
|
+
t = twoSub(a.y, b.y);
|
|
170
|
+
s.y += t.x;
|
|
171
|
+
s = quickTwoSum(s.x, s.y);
|
|
172
|
+
s.y += t.y;
|
|
173
|
+
s = quickTwoSum(s.x, s.y);
|
|
174
|
+
return s;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
vec2 mul_fp64(vec2 a, vec2 b) {
|
|
178
|
+
vec2 prod = twoProd(a.x, b.x);
|
|
179
|
+
// y component is for the error
|
|
180
|
+
prod.y += a.x * b.y;
|
|
181
|
+
#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)
|
|
182
|
+
prod = split2(prod);
|
|
183
|
+
#endif
|
|
184
|
+
prod = quickTwoSum(prod.x, prod.y);
|
|
185
|
+
prod.y += a.y * b.x;
|
|
186
|
+
#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)
|
|
187
|
+
prod = split2(prod);
|
|
188
|
+
#endif
|
|
189
|
+
prod = quickTwoSum(prod.x, prod.y);
|
|
190
|
+
return prod;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
vec2 div_fp64(vec2 a, vec2 b) {
|
|
194
|
+
float xn = 1.0 / b.x;
|
|
195
|
+
#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)
|
|
196
|
+
vec2 yn = mul_fp64(a, vec2(xn, 0));
|
|
197
|
+
#else
|
|
198
|
+
vec2 yn = a * xn;
|
|
199
|
+
#endif
|
|
200
|
+
float diff = (sub_fp64(a, mul_fp64(b, yn))).x;
|
|
201
|
+
vec2 prod = twoProd(xn, diff);
|
|
202
|
+
return sum_fp64(yn, prod);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
vec2 sqrt_fp64(vec2 a) {
|
|
206
|
+
if (a.x == 0.0 && a.y == 0.0) return vec2(0.0, 0.0);
|
|
207
|
+
if (a.x < 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0);
|
|
208
|
+
|
|
209
|
+
float x = 1.0 / sqrt(a.x);
|
|
210
|
+
float yn = a.x * x;
|
|
211
|
+
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
|
|
212
|
+
vec2 yn_sqr = twoSqr(yn) * fp64.ONE;
|
|
213
|
+
#else
|
|
214
|
+
vec2 yn_sqr = twoSqr(yn);
|
|
215
|
+
#endif
|
|
216
|
+
float diff = sub_fp64(a, yn_sqr).x;
|
|
217
|
+
vec2 prod = twoProd(x * 0.5, diff);
|
|
218
|
+
#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)
|
|
219
|
+
return sum_fp64(split(yn), prod);
|
|
220
|
+
#else
|
|
221
|
+
return sum_fp64(vec2(yn, 0.0), prod);
|
|
222
|
+
#endif
|
|
223
|
+
}
|
|
224
|
+
`
|
|
225
|
+
);
|
|
226
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
227
|
+
0 && (module.exports = {
|
|
228
|
+
fp64arithmeticShader
|
|
229
|
+
});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const fp64arithmeticShader = "\nlayout(std140) uniform fp64arithmeticUniforms {\n uniform float ONE;\n uniform float SPLIT;\n} fp64;\n\n/*\nAbout LUMA_FP64_CODE_ELIMINATION_WORKAROUND\n\nThe purpose of this workaround is to prevent shader compilers from\noptimizing away necessary arithmetic operations by swapping their sequences\nor transform the equation to some 'equivalent' form.\n\nThese helpers implement Dekker/Veltkamp-style error tracking. If the compiler\nfolds constants or reassociates the arithmetic, the high/low split can stop\ntracking the rounding error correctly. That failure mode tends to look fine in\nsimple coordinate setup, but then breaks down inside iterative arithmetic such\nas fp64 Mandelbrot loops.\n\nThe method is to multiply an artifical variable, ONE, which will be known to\nthe compiler to be 1 only at runtime. The whole expression is then represented\nas a polynomial with respective to ONE. In the coefficients of all terms, only one a\nand one b should appear\n\nerr = (a + b) * ONE^6 - a * ONE^5 - (a + b) * ONE^4 + a * ONE^3 - b - (a + b) * ONE^2 + a * ONE\n*/\n\nfloat prevent_fp64_optimization(float value) {\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n return value + fp64.ONE * 0.0;\n#else\n return value;\n#endif\n}\n\n// Divide float number to high and low floats to extend fraction bits\nvec2 split(float a) {\n // Keep SPLIT as a runtime uniform so the compiler cannot fold the Dekker\n // split into a constant expression and reassociate the recovery steps.\n float split = prevent_fp64_optimization(fp64.SPLIT);\n float t = prevent_fp64_optimization(a * split);\n float temp = t - a;\n float a_hi = t - temp;\n float a_lo = a - a_hi;\n return vec2(a_hi, a_lo);\n}\n\n// Divide float number again when high float uses too many fraction bits\nvec2 split2(vec2 a) {\n vec2 b = split(a.x);\n b.y += a.y;\n return b;\n}\n\n// Special sum operation when a > b\nvec2 quickTwoSum(float a, float b) {\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float sum = (a + b) * fp64.ONE;\n float err = b - (sum - a) * fp64.ONE;\n#else\n float sum = a + b;\n float err = b - (sum - a);\n#endif\n return vec2(sum, err);\n}\n\n// General sum operation\nvec2 twoSum(float a, float b) {\n float s = (a + b);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float v = (s * fp64.ONE - a) * fp64.ONE;\n float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE + (b - v);\n#else\n float v = s - a;\n float err = (a - (s - v)) + (b - v);\n#endif\n return vec2(s, err);\n}\n\nvec2 twoSub(float a, float b) {\n float s = (a - b);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float v = (s * fp64.ONE - a) * fp64.ONE;\n float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE - (b + v);\n#else\n float v = s - a;\n float err = (a - (s - v)) - (b + v);\n#endif\n return vec2(s, err);\n}\n\nvec2 twoSqr(float a) {\n float prod = a * a;\n vec2 a_fp64 = split(a);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float err = ((a_fp64.x * a_fp64.x - prod) * fp64.ONE + 2.0 * a_fp64.x *\n a_fp64.y * fp64.ONE * fp64.ONE) + a_fp64.y * a_fp64.y * fp64.ONE * fp64.ONE * fp64.ONE;\n#else\n float err = ((a_fp64.x * a_fp64.x - prod) + 2.0 * a_fp64.x * a_fp64.y) + a_fp64.y * a_fp64.y;\n#endif\n return vec2(prod, err);\n}\n\nvec2 twoProd(float a, float b) {\n float prod = a * b;\n vec2 a_fp64 = split(a);\n vec2 b_fp64 = split(b);\n // twoProd is especially sensitive because mul_fp64 and div_fp64 both depend\n // on the split terms and cross terms staying in the original evaluation\n // order. If the compiler folds or reassociates them, the low part tends to\n // collapse to zero or NaN on some drivers.\n float highProduct = prevent_fp64_optimization(a_fp64.x * b_fp64.x);\n float crossProduct1 = prevent_fp64_optimization(a_fp64.x * b_fp64.y);\n float crossProduct2 = prevent_fp64_optimization(a_fp64.y * b_fp64.x);\n float lowProduct = prevent_fp64_optimization(a_fp64.y * b_fp64.y);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n float err1 = (highProduct - prod) * fp64.ONE;\n float err2 = crossProduct1 * fp64.ONE * fp64.ONE;\n float err3 = crossProduct2 * fp64.ONE * fp64.ONE * fp64.ONE;\n float err4 = lowProduct * fp64.ONE * fp64.ONE * fp64.ONE * fp64.ONE;\n#else\n float err1 = highProduct - prod;\n float err2 = crossProduct1;\n float err3 = crossProduct2;\n float err4 = lowProduct;\n#endif\n float err = ((err1 + err2) + err3) + err4;\n return vec2(prod, err);\n}\n\nvec2 sum_fp64(vec2 a, vec2 b) {\n vec2 s, t;\n s = twoSum(a.x, b.x);\n t = twoSum(a.y, b.y);\n s.y += t.x;\n s = quickTwoSum(s.x, s.y);\n s.y += t.y;\n s = quickTwoSum(s.x, s.y);\n return s;\n}\n\nvec2 sub_fp64(vec2 a, vec2 b) {\n vec2 s, t;\n s = twoSub(a.x, b.x);\n t = twoSub(a.y, b.y);\n s.y += t.x;\n s = quickTwoSum(s.x, s.y);\n s.y += t.y;\n s = quickTwoSum(s.x, s.y);\n return s;\n}\n\nvec2 mul_fp64(vec2 a, vec2 b) {\n vec2 prod = twoProd(a.x, b.x);\n // y component is for the error\n prod.y += a.x * b.y;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n prod = split2(prod);\n#endif\n prod = quickTwoSum(prod.x, prod.y);\n prod.y += a.y * b.x;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n prod = split2(prod);\n#endif\n prod = quickTwoSum(prod.x, prod.y);\n return prod;\n}\n\nvec2 div_fp64(vec2 a, vec2 b) {\n float xn = 1.0 / b.x;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n vec2 yn = mul_fp64(a, vec2(xn, 0));\n#else\n vec2 yn = a * xn;\n#endif\n float diff = (sub_fp64(a, mul_fp64(b, yn))).x;\n vec2 prod = twoProd(xn, diff);\n return sum_fp64(yn, prod);\n}\n\nvec2 sqrt_fp64(vec2 a) {\n if (a.x == 0.0 && a.y == 0.0) return vec2(0.0, 0.0);\n if (a.x < 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0);\n\n float x = 1.0 / sqrt(a.x);\n float yn = a.x * x;\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\n vec2 yn_sqr = twoSqr(yn) * fp64.ONE;\n#else\n vec2 yn_sqr = twoSqr(yn);\n#endif\n float diff = sub_fp64(a, yn_sqr).x;\n vec2 prod = twoProd(x * 0.5, diff);\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\n return sum_fp64(split(yn), prod);\n#else\n return sum_fp64(vec2(yn, 0.0), prod);\n#endif\n}\n";
|
|
2
|
+
//# sourceMappingURL=fp64-arithmetic-glsl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fp64-arithmetic-glsl.d.ts","sourceRoot":"","sources":["../../../../src/modules/math/fp64/fp64-arithmetic-glsl.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,oBAAoB,ijMAwMhC,CAAC"}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
export const fp64arithmeticShader = /* glsl */ `\
|
|
5
|
+
|
|
6
|
+
layout(std140) uniform fp64arithmeticUniforms {
|
|
7
|
+
uniform float ONE;
|
|
8
|
+
uniform float SPLIT;
|
|
9
|
+
} fp64;
|
|
10
|
+
|
|
11
|
+
/*
|
|
12
|
+
About LUMA_FP64_CODE_ELIMINATION_WORKAROUND
|
|
13
|
+
|
|
14
|
+
The purpose of this workaround is to prevent shader compilers from
|
|
15
|
+
optimizing away necessary arithmetic operations by swapping their sequences
|
|
16
|
+
or transform the equation to some 'equivalent' form.
|
|
17
|
+
|
|
18
|
+
These helpers implement Dekker/Veltkamp-style error tracking. If the compiler
|
|
19
|
+
folds constants or reassociates the arithmetic, the high/low split can stop
|
|
20
|
+
tracking the rounding error correctly. That failure mode tends to look fine in
|
|
21
|
+
simple coordinate setup, but then breaks down inside iterative arithmetic such
|
|
22
|
+
as fp64 Mandelbrot loops.
|
|
23
|
+
|
|
24
|
+
The method is to multiply an artifical variable, ONE, which will be known to
|
|
25
|
+
the compiler to be 1 only at runtime. The whole expression is then represented
|
|
26
|
+
as a polynomial with respective to ONE. In the coefficients of all terms, only one a
|
|
27
|
+
and one b should appear
|
|
28
|
+
|
|
29
|
+
err = (a + b) * ONE^6 - a * ONE^5 - (a + b) * ONE^4 + a * ONE^3 - b - (a + b) * ONE^2 + a * ONE
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
float prevent_fp64_optimization(float value) {
|
|
33
|
+
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
|
|
34
|
+
return value + fp64.ONE * 0.0;
|
|
35
|
+
#else
|
|
36
|
+
return value;
|
|
37
|
+
#endif
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Divide float number to high and low floats to extend fraction bits
|
|
41
|
+
vec2 split(float a) {
|
|
42
|
+
// Keep SPLIT as a runtime uniform so the compiler cannot fold the Dekker
|
|
43
|
+
// split into a constant expression and reassociate the recovery steps.
|
|
44
|
+
float split = prevent_fp64_optimization(fp64.SPLIT);
|
|
45
|
+
float t = prevent_fp64_optimization(a * split);
|
|
46
|
+
float temp = t - a;
|
|
47
|
+
float a_hi = t - temp;
|
|
48
|
+
float a_lo = a - a_hi;
|
|
49
|
+
return vec2(a_hi, a_lo);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Divide float number again when high float uses too many fraction bits
|
|
53
|
+
vec2 split2(vec2 a) {
|
|
54
|
+
vec2 b = split(a.x);
|
|
55
|
+
b.y += a.y;
|
|
56
|
+
return b;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Special sum operation when a > b
|
|
60
|
+
vec2 quickTwoSum(float a, float b) {
|
|
61
|
+
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
|
|
62
|
+
float sum = (a + b) * fp64.ONE;
|
|
63
|
+
float err = b - (sum - a) * fp64.ONE;
|
|
64
|
+
#else
|
|
65
|
+
float sum = a + b;
|
|
66
|
+
float err = b - (sum - a);
|
|
67
|
+
#endif
|
|
68
|
+
return vec2(sum, err);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// General sum operation
|
|
72
|
+
vec2 twoSum(float a, float b) {
|
|
73
|
+
float s = (a + b);
|
|
74
|
+
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
|
|
75
|
+
float v = (s * fp64.ONE - a) * fp64.ONE;
|
|
76
|
+
float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE + (b - v);
|
|
77
|
+
#else
|
|
78
|
+
float v = s - a;
|
|
79
|
+
float err = (a - (s - v)) + (b - v);
|
|
80
|
+
#endif
|
|
81
|
+
return vec2(s, err);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
vec2 twoSub(float a, float b) {
|
|
85
|
+
float s = (a - b);
|
|
86
|
+
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
|
|
87
|
+
float v = (s * fp64.ONE - a) * fp64.ONE;
|
|
88
|
+
float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE - (b + v);
|
|
89
|
+
#else
|
|
90
|
+
float v = s - a;
|
|
91
|
+
float err = (a - (s - v)) - (b + v);
|
|
92
|
+
#endif
|
|
93
|
+
return vec2(s, err);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
vec2 twoSqr(float a) {
|
|
97
|
+
float prod = a * a;
|
|
98
|
+
vec2 a_fp64 = split(a);
|
|
99
|
+
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
|
|
100
|
+
float err = ((a_fp64.x * a_fp64.x - prod) * fp64.ONE + 2.0 * a_fp64.x *
|
|
101
|
+
a_fp64.y * fp64.ONE * fp64.ONE) + a_fp64.y * a_fp64.y * fp64.ONE * fp64.ONE * fp64.ONE;
|
|
102
|
+
#else
|
|
103
|
+
float err = ((a_fp64.x * a_fp64.x - prod) + 2.0 * a_fp64.x * a_fp64.y) + a_fp64.y * a_fp64.y;
|
|
104
|
+
#endif
|
|
105
|
+
return vec2(prod, err);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
vec2 twoProd(float a, float b) {
|
|
109
|
+
float prod = a * b;
|
|
110
|
+
vec2 a_fp64 = split(a);
|
|
111
|
+
vec2 b_fp64 = split(b);
|
|
112
|
+
// twoProd is especially sensitive because mul_fp64 and div_fp64 both depend
|
|
113
|
+
// on the split terms and cross terms staying in the original evaluation
|
|
114
|
+
// order. If the compiler folds or reassociates them, the low part tends to
|
|
115
|
+
// collapse to zero or NaN on some drivers.
|
|
116
|
+
float highProduct = prevent_fp64_optimization(a_fp64.x * b_fp64.x);
|
|
117
|
+
float crossProduct1 = prevent_fp64_optimization(a_fp64.x * b_fp64.y);
|
|
118
|
+
float crossProduct2 = prevent_fp64_optimization(a_fp64.y * b_fp64.x);
|
|
119
|
+
float lowProduct = prevent_fp64_optimization(a_fp64.y * b_fp64.y);
|
|
120
|
+
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
|
|
121
|
+
float err1 = (highProduct - prod) * fp64.ONE;
|
|
122
|
+
float err2 = crossProduct1 * fp64.ONE * fp64.ONE;
|
|
123
|
+
float err3 = crossProduct2 * fp64.ONE * fp64.ONE * fp64.ONE;
|
|
124
|
+
float err4 = lowProduct * fp64.ONE * fp64.ONE * fp64.ONE * fp64.ONE;
|
|
125
|
+
#else
|
|
126
|
+
float err1 = highProduct - prod;
|
|
127
|
+
float err2 = crossProduct1;
|
|
128
|
+
float err3 = crossProduct2;
|
|
129
|
+
float err4 = lowProduct;
|
|
130
|
+
#endif
|
|
131
|
+
float err = ((err1 + err2) + err3) + err4;
|
|
132
|
+
return vec2(prod, err);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
vec2 sum_fp64(vec2 a, vec2 b) {
|
|
136
|
+
vec2 s, t;
|
|
137
|
+
s = twoSum(a.x, b.x);
|
|
138
|
+
t = twoSum(a.y, b.y);
|
|
139
|
+
s.y += t.x;
|
|
140
|
+
s = quickTwoSum(s.x, s.y);
|
|
141
|
+
s.y += t.y;
|
|
142
|
+
s = quickTwoSum(s.x, s.y);
|
|
143
|
+
return s;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
vec2 sub_fp64(vec2 a, vec2 b) {
|
|
147
|
+
vec2 s, t;
|
|
148
|
+
s = twoSub(a.x, b.x);
|
|
149
|
+
t = twoSub(a.y, b.y);
|
|
150
|
+
s.y += t.x;
|
|
151
|
+
s = quickTwoSum(s.x, s.y);
|
|
152
|
+
s.y += t.y;
|
|
153
|
+
s = quickTwoSum(s.x, s.y);
|
|
154
|
+
return s;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
vec2 mul_fp64(vec2 a, vec2 b) {
|
|
158
|
+
vec2 prod = twoProd(a.x, b.x);
|
|
159
|
+
// y component is for the error
|
|
160
|
+
prod.y += a.x * b.y;
|
|
161
|
+
#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)
|
|
162
|
+
prod = split2(prod);
|
|
163
|
+
#endif
|
|
164
|
+
prod = quickTwoSum(prod.x, prod.y);
|
|
165
|
+
prod.y += a.y * b.x;
|
|
166
|
+
#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)
|
|
167
|
+
prod = split2(prod);
|
|
168
|
+
#endif
|
|
169
|
+
prod = quickTwoSum(prod.x, prod.y);
|
|
170
|
+
return prod;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
vec2 div_fp64(vec2 a, vec2 b) {
|
|
174
|
+
float xn = 1.0 / b.x;
|
|
175
|
+
#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)
|
|
176
|
+
vec2 yn = mul_fp64(a, vec2(xn, 0));
|
|
177
|
+
#else
|
|
178
|
+
vec2 yn = a * xn;
|
|
179
|
+
#endif
|
|
180
|
+
float diff = (sub_fp64(a, mul_fp64(b, yn))).x;
|
|
181
|
+
vec2 prod = twoProd(xn, diff);
|
|
182
|
+
return sum_fp64(yn, prod);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
vec2 sqrt_fp64(vec2 a) {
|
|
186
|
+
if (a.x == 0.0 && a.y == 0.0) return vec2(0.0, 0.0);
|
|
187
|
+
if (a.x < 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0);
|
|
188
|
+
|
|
189
|
+
float x = 1.0 / sqrt(a.x);
|
|
190
|
+
float yn = a.x * x;
|
|
191
|
+
#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)
|
|
192
|
+
vec2 yn_sqr = twoSqr(yn) * fp64.ONE;
|
|
193
|
+
#else
|
|
194
|
+
vec2 yn_sqr = twoSqr(yn);
|
|
195
|
+
#endif
|
|
196
|
+
float diff = sub_fp64(a, yn_sqr).x;
|
|
197
|
+
vec2 prod = twoProd(x * 0.5, diff);
|
|
198
|
+
#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)
|
|
199
|
+
return sum_fp64(split(yn), prod);
|
|
200
|
+
#else
|
|
201
|
+
return sum_fp64(vec2(yn, 0.0), prod);
|
|
202
|
+
#endif
|
|
203
|
+
}
|
|
204
|
+
`;
|
|
205
|
+
//# sourceMappingURL=fp64-arithmetic-glsl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fp64-arithmetic-glsl.js","sourceRoot":"","sources":["../../../../src/modules/math/fp64/fp64-arithmetic-glsl.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAE5D,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwM9C,CAAC"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var fp64_arithmetic_wgsl_hybrid_exports = {};
|
|
19
|
+
__export(fp64_arithmetic_wgsl_hybrid_exports, {
|
|
20
|
+
fp64arithmeticWGSLHybrid: () => fp64arithmeticWGSLHybrid
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(fp64_arithmetic_wgsl_hybrid_exports);
|
|
23
|
+
var import_fp64_arithmetic_wgsl_integer = require("./fp64-arithmetic-wgsl-integer.cjs");
|
|
24
|
+
const fp64arithmeticWGSLHybrid = (
|
|
25
|
+
/* wgsl */
|
|
26
|
+
`${import_fp64_arithmetic_wgsl_integer.fp64arithmeticWGSLIntegerPrimitives}
|
|
27
|
+
|
|
28
|
+
#ifndef LUMA_FP64_PREDICATE_ONLY
|
|
29
|
+
fn split(a: f32) -> vec2f {
|
|
30
|
+
let aBits = bitcast<u32>(a);
|
|
31
|
+
let decoded = fp64_decode_f32_bits(aBits);
|
|
32
|
+
if (decoded.isZero || decoded.isInf || decoded.isNan) {
|
|
33
|
+
return vec2f(a, 0.0);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var roundedHigh = decoded.significand >> 12u;
|
|
37
|
+
let remainder = decoded.significand & 0xfffu;
|
|
38
|
+
if (remainder > 0x800u || (remainder == 0x800u && (roundedHigh & 1u) == 1u)) {
|
|
39
|
+
roundedHigh = roundedHigh + 1u;
|
|
40
|
+
}
|
|
41
|
+
var highMagnitude = vec2u(0u, roundedHigh << 12u);
|
|
42
|
+
var highBits = fp64_make_f32_bits_from_u64(
|
|
43
|
+
decoded.sign,
|
|
44
|
+
highMagnitude,
|
|
45
|
+
decoded.baseExponent
|
|
46
|
+
);
|
|
47
|
+
if (fp64_decode_f32_bits(highBits).isInf) {
|
|
48
|
+
roundedHigh = decoded.significand >> 12u;
|
|
49
|
+
highMagnitude = vec2u(0u, roundedHigh << 12u);
|
|
50
|
+
highBits = fp64_make_f32_bits_from_u64(
|
|
51
|
+
decoded.sign,
|
|
52
|
+
highMagnitude,
|
|
53
|
+
decoded.baseExponent
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
let lowBits = fp64_make_residual_f32_bits(
|
|
57
|
+
decoded.sign,
|
|
58
|
+
vec2u(0u, decoded.significand),
|
|
59
|
+
decoded.baseExponent,
|
|
60
|
+
highBits
|
|
61
|
+
);
|
|
62
|
+
return vec2f(bitcast<f32>(highBits), bitcast<f32>(lowBits));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
fn split2(a: vec2f) -> vec2f {
|
|
66
|
+
var result = split(a.x);
|
|
67
|
+
result.y = result.y + a.y;
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
fn quickTwoSum(a: f32, b: f32) -> vec2f {
|
|
72
|
+
return fp64_two_sum_integer(a, b);
|
|
73
|
+
}
|
|
74
|
+
#endif
|
|
75
|
+
|
|
76
|
+
fn twoSum(a: f32, b: f32) -> vec2f {
|
|
77
|
+
return fp64_two_sum_integer(a, b);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
fn twoSub(a: f32, b: f32) -> vec2f {
|
|
81
|
+
let bBits = bitcast<u32>(b) ^ 0x80000000u;
|
|
82
|
+
let resultBits = fp64_two_sum_integer_bits(bitcast<u32>(a), bBits);
|
|
83
|
+
return vec2f(bitcast<f32>(resultBits.x), bitcast<f32>(resultBits.y));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
#ifndef LUMA_FP64_PREDICATE_ONLY
|
|
87
|
+
fn twoSqr(a: f32) -> vec2f {
|
|
88
|
+
return fp64_two_prod_integer(a, a);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
fn twoProd(a: f32, b: f32) -> vec2f {
|
|
92
|
+
return fp64_two_prod_integer(a, b);
|
|
93
|
+
}
|
|
94
|
+
#endif
|
|
95
|
+
|
|
96
|
+
fn sum_fp64(a: vec2f, b: vec2f) -> vec2f {
|
|
97
|
+
let highSum = fp64_two_sum_integer(a.x, b.x);
|
|
98
|
+
let lowSum = prevent_fp64_optimization((a.y + b.y) + highSum.y);
|
|
99
|
+
return fp64_two_sum_integer(highSum.x, lowSum);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
fn sub_fp64(a: vec2f, b: vec2f) -> vec2f {
|
|
103
|
+
let highDifference = twoSub(a.x, b.x);
|
|
104
|
+
let lowDifference = prevent_fp64_optimization((a.y - b.y) + highDifference.y);
|
|
105
|
+
return fp64_two_sum_integer(highDifference.x, lowDifference);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
fn mul_fp64(a: vec2f, b: vec2f) -> vec2f {
|
|
109
|
+
let highProduct = fp64_two_prod_integer(a.x, b.x);
|
|
110
|
+
let crossTerms = prevent_fp64_optimization(a.x * b.y + a.y * b.x);
|
|
111
|
+
let lowTerms = prevent_fp64_optimization((crossTerms + a.y * b.y) + highProduct.y);
|
|
112
|
+
return fp64_two_sum_integer(highProduct.x, lowTerms);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
#ifndef LUMA_FP64_PREDICATE_ONLY
|
|
116
|
+
fn div_fp64(a: vec2f, b: vec2f) -> vec2f {
|
|
117
|
+
let estimate = prevent_fp64_optimization(1.0 / b.x);
|
|
118
|
+
let quotient = mul_fp64(a, vec2f(estimate, fp64_runtime_zero()));
|
|
119
|
+
let remainder = prevent_fp64_optimization(sub_fp64(a, mul_fp64(b, quotient)).x);
|
|
120
|
+
return sum_fp64(quotient, twoProd(estimate, remainder));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
fn sqrt_fp64(a: vec2f) -> vec2f {
|
|
124
|
+
if (a.x == 0.0 && a.y == 0.0) {
|
|
125
|
+
return vec2f(0.0, 0.0);
|
|
126
|
+
}
|
|
127
|
+
if (a.x < 0.0) {
|
|
128
|
+
let nanValue = fp64_nan(a.x);
|
|
129
|
+
return vec2f(nanValue, nanValue);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
let reciprocalRoot = prevent_fp64_optimization(1.0 / sqrt(a.x));
|
|
133
|
+
let estimate = prevent_fp64_optimization(a.x * reciprocalRoot);
|
|
134
|
+
let difference = prevent_fp64_optimization(sub_fp64(a, twoSqr(estimate)).x);
|
|
135
|
+
let correction = twoProd(prevent_fp64_optimization(reciprocalRoot * 0.5), difference);
|
|
136
|
+
return sum_fp64(vec2f(estimate, 0.0), correction);
|
|
137
|
+
}
|
|
138
|
+
#endif
|
|
139
|
+
`
|
|
140
|
+
);
|
|
141
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
142
|
+
0 && (module.exports = {
|
|
143
|
+
fp64arithmeticWGSLHybrid
|
|
144
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optimizer-resistant double-single arithmetic that reconstructs the critical
|
|
3
|
+
* high-part residuals with integer operations while accumulating lower-order
|
|
4
|
+
* terms with native f32 arithmetic.
|
|
5
|
+
*
|
|
6
|
+
* This deliberately trades strict correctness for substantially less integer
|
|
7
|
+
* work than the fully integer-controlled implementation.
|
|
8
|
+
*/
|
|
9
|
+
export declare const fp64arithmeticWGSLHybrid = "struct Fp64F32Bits {\n sign: u32,\n baseExponent: i32,\n significand: u32,\n isZero: bool,\n isInf: bool,\n isNan: bool,\n};\n\n// Decode an f32 as (-1)^sign * significand * 2^baseExponent.\nfn fp64_decode_f32_bits(bits: u32) -> Fp64F32Bits {\n let sign = bits >> 31u;\n let exponentBits = (bits >> 23u) & 0xffu;\n let fraction = bits & 0x7fffffu;\n\n if (exponentBits == 0xffu) {\n return Fp64F32Bits(sign, 0, 0u, false, fraction == 0u, fraction != 0u);\n }\n if (exponentBits == 0u) {\n return Fp64F32Bits(sign, -149, fraction, fraction == 0u, false, false);\n }\n return Fp64F32Bits(sign, i32(exponentBits) - 150, 0x800000u | fraction, false, false, false);\n}\n\nfn fp64_f32_magnitude_compare(aBits: u32, bBits: u32) -> i32 {\n let aMagnitude = aBits & 0x7fffffffu;\n let bMagnitude = bBits & 0x7fffffffu;\n if (aMagnitude == bMagnitude) {\n return 0;\n }\n return select(-1, 1, aMagnitude > bMagnitude);\n}\n\nfn fp64_make_residual_f32_bits(\n exactSign: u32,\n exactMagnitude: vec2u,\n exactBaseExponent: i32,\n highBits: u32\n) -> u32 {\n if (fp64_u64_is_zero(exactMagnitude)) {\n return 0u;\n }\n\n let high = fp64_decode_f32_bits(highBits);\n if (high.isInf || high.isNan) {\n return exactSign << 31u;\n }\n if (high.isZero) {\n return fp64_make_f32_bits_from_u64(exactSign, exactMagnitude, exactBaseExponent);\n }\n\n let commonBaseExponent = min(exactBaseExponent, high.baseExponent);\n let exactShift = exactBaseExponent - commonBaseExponent;\n let highShift = high.baseExponent - commonBaseExponent;\n\n // A normal two-sum/two-product residual never needs a shift this large.\n // This guard gives deterministic underflow behavior outside that contract.\n if (exactShift >= 64 || highShift >= 64) {\n return exactSign << 31u;\n }\n\n let exactAligned = fp64_u64_shift_left(exactMagnitude, u32(exactShift));\n let highAligned = fp64_u64_shift_left(vec2u(0u, high.significand), u32(highShift));\n let comparison = fp64_u64_compare(exactAligned, highAligned);\n if (comparison == 0) {\n return 0u;\n }\n\n var residualSign = exactSign;\n var residualMagnitude: vec2u;\n if (comparison > 0) {\n residualMagnitude = fp64_u64_sub(exactAligned, highAligned);\n } else {\n residualSign = exactSign ^ 1u;\n residualMagnitude = fp64_u64_sub(highAligned, exactAligned);\n }\n return fp64_make_f32_bits_from_u64(\n residualSign,\n residualMagnitude,\n commonBaseExponent\n );\n}\n\nfn fp64_split_accumulator_bits(\n sign: u32,\n magnitude: vec2u,\n baseExponent: i32\n) -> vec2u {\n let highBits = fp64_make_f32_bits_from_u64(sign, magnitude, baseExponent);\n let lowBits = fp64_make_residual_f32_bits(sign, magnitude, baseExponent, highBits);\n return vec2u(highBits, lowBits);\n}\n\nfn fp64_two_sum_integer_bits(aBits: u32, bBits: u32) -> vec2u {\n let a = fp64_decode_f32_bits(aBits);\n let b = fp64_decode_f32_bits(bBits);\n\n if (a.isNan || b.isNan) {\n return vec2u(0x7fc00000u, 0u);\n }\n if (a.isInf || b.isInf) {\n if (a.isInf && b.isInf && a.sign != b.sign) {\n return vec2u(0x7fc00000u, 0u);\n }\n return select(vec2u(bBits, 0u), vec2u(aBits, 0u), a.isInf);\n }\n if (a.isZero && b.isZero) {\n return vec2u((a.sign & b.sign) << 31u, 0u);\n }\n if (a.isZero) {\n return vec2u(bBits, 0u);\n }\n if (b.isZero) {\n return vec2u(aBits, 0u);\n }\n\n let exponentDifference = select(\n b.baseExponent - a.baseExponent,\n a.baseExponent - b.baseExponent,\n a.baseExponent >= b.baseExponent\n );\n\n // Beyond half an ulp, rounding cannot change the larger operand. Returning\n // the smaller operand intact also avoids an unbounded integer alignment.\n // At a power-of-two boundary the spacing below the larger operand is half\n // the spacing above it, so an opposite-sign gap-25 operand can still change\n // the rounded high limb. Gap 26 is the first universally safe early-out.\n if (exponentDifference > 25) {\n if (fp64_f32_magnitude_compare(aBits, bBits) >= 0) {\n return vec2u(aBits, bBits);\n }\n return vec2u(bBits, aBits);\n }\n\n let commonBaseExponent = min(a.baseExponent, b.baseExponent);\n let aMagnitude = fp64_u64_shift_left(\n vec2u(0u, a.significand),\n u32(a.baseExponent - commonBaseExponent)\n );\n let bMagnitude = fp64_u64_shift_left(\n vec2u(0u, b.significand),\n u32(b.baseExponent - commonBaseExponent)\n );\n\n var resultSign = a.sign;\n var resultMagnitude: vec2u;\n if (a.sign == b.sign) {\n resultMagnitude = fp64_u64_add(aMagnitude, bMagnitude);\n } else {\n let comparison = fp64_u64_compare(aMagnitude, bMagnitude);\n if (comparison == 0) {\n return vec2u(0u, 0u);\n }\n if (comparison > 0) {\n resultMagnitude = fp64_u64_sub(aMagnitude, bMagnitude);\n } else {\n resultSign = b.sign;\n resultMagnitude = fp64_u64_sub(bMagnitude, aMagnitude);\n }\n }\n\n return fp64_split_accumulator_bits(resultSign, resultMagnitude, commonBaseExponent);\n}\n\nfn fp64_two_sum_integer(a: f32, b: f32) -> vec2f {\n let resultBits = fp64_two_sum_integer_bits(bitcast<u32>(a), bitcast<u32>(b));\n return vec2f(bitcast<f32>(resultBits.x), bitcast<f32>(resultBits.y));\n}\n\nfn fp64_multiply_significands(a: u32, b: u32) -> vec2u {\n let aLow = a & 0xffffu;\n let aHigh = a >> 16u;\n let bLow = b & 0xffffu;\n let bHigh = b >> 16u;\n let lowProduct = aLow * bLow;\n let crossProduct = aLow * bHigh + aHigh * bLow;\n let highProduct = aHigh * bHigh;\n\n var result = vec2u(0u, lowProduct);\n result = fp64_u64_add(\n result,\n fp64_u64_shift_left(vec2u(0u, crossProduct), 16u)\n );\n result = fp64_u64_add(result, vec2u(highProduct, 0u));\n return result;\n}\n\nfn fp64_two_prod_integer_bits(aBits: u32, bBits: u32) -> vec2u {\n let a = fp64_decode_f32_bits(aBits);\n let b = fp64_decode_f32_bits(bBits);\n let resultSign = a.sign ^ b.sign;\n\n if (a.isNan || b.isNan || ((a.isZero || b.isZero) && (a.isInf || b.isInf))) {\n return vec2u(0x7fc00000u, 0u);\n }\n if (a.isInf || b.isInf) {\n return vec2u((resultSign << 31u) | 0x7f800000u, resultSign << 31u);\n }\n if (a.isZero || b.isZero) {\n return vec2u(resultSign << 31u, resultSign << 31u);\n }\n\n let magnitude = fp64_multiply_significands(a.significand, b.significand);\n return fp64_split_accumulator_bits(\n resultSign,\n magnitude,\n a.baseExponent + b.baseExponent\n );\n}\n\nfn fp64_two_prod_integer(a: f32, b: f32) -> vec2f {\n let resultBits = fp64_two_prod_integer_bits(bitcast<u32>(a), bitcast<u32>(b));\n return vec2f(bitcast<f32>(resultBits.x), bitcast<f32>(resultBits.y));\n}\n\nfn fp64_round_add_integer(a: f32, b: f32) -> f32 {\n return fp64_two_sum_integer(a, b).x;\n}\n\nfn fp64_round_mul_integer(a: f32, b: f32) -> f32 {\n return fp64_two_prod_integer(a, b).x;\n}\n\n#ifndef LUMA_FP64_PREDICATE_ONLY\nfn fp64_f32_finite_exponent(value: Fp64F32Bits) -> i32 {\n let mostSignificantBit = 31u - countLeadingZeros(value.significand);\n return value.baseExponent + i32(mostSignificantBit);\n}\n\nfn fp64_scale_f32_integer(value: f32, exponent: i32) -> f32 {\n let decoded = fp64_decode_f32_bits(bitcast<u32>(value));\n if (decoded.isZero || decoded.isInf || decoded.isNan) {\n return value;\n }\n let resultBits = fp64_make_f32_bits_from_u64(\n decoded.sign,\n vec2u(0u, decoded.significand),\n decoded.baseExponent + exponent\n );\n return bitcast<f32>(resultBits);\n}\n\n// Divide normalized significands so the hardware operation cannot overflow,\n// underflow, or flush a subnormal result. Reapply the exponent with integer\n// packing, which also produces subnormal correction limbs without relying on\n// floating-point arithmetic to preserve them.\nfn fp64_divide_f32_integer(aValue: f32, bValue: f32) -> f32 {\n let a = fp64_decode_f32_bits(bitcast<u32>(aValue));\n let b = fp64_decode_f32_bits(bitcast<u32>(bValue));\n if (a.isZero || b.isZero || a.isInf || b.isInf || a.isNan || b.isNan) {\n return aValue / bValue;\n }\n\n let aMostSignificantBit = 31u - countLeadingZeros(a.significand);\n let bMostSignificantBit = 31u - countLeadingZeros(b.significand);\n let normalizedABits = fp64_make_f32_bits_from_u64(\n a.sign,\n vec2u(0u, a.significand),\n -i32(aMostSignificantBit)\n );\n let normalizedBBits = fp64_make_f32_bits_from_u64(\n b.sign,\n vec2u(0u, b.significand),\n -i32(bMostSignificantBit)\n );\n let normalizedQuotient = bitcast<f32>(normalizedABits) / bitcast<f32>(normalizedBBits);\n let quotient = fp64_decode_f32_bits(bitcast<u32>(normalizedQuotient));\n let exponentShift =\n a.baseExponent + i32(aMostSignificantBit) -\n b.baseExponent - i32(bMostSignificantBit);\n let quotientBits = fp64_make_f32_bits_from_u64(\n quotient.sign,\n vec2u(0u, quotient.significand),\n quotient.baseExponent + exponentShift\n );\n return bitcast<f32>(quotientBits);\n}\n#endif\n\n\n\n#ifndef LUMA_FP64_PREDICATE_ONLY\nfn split(a: f32) -> vec2f {\n let aBits = bitcast<u32>(a);\n let decoded = fp64_decode_f32_bits(aBits);\n if (decoded.isZero || decoded.isInf || decoded.isNan) {\n return vec2f(a, 0.0);\n }\n\n var roundedHigh = decoded.significand >> 12u;\n let remainder = decoded.significand & 0xfffu;\n if (remainder > 0x800u || (remainder == 0x800u && (roundedHigh & 1u) == 1u)) {\n roundedHigh = roundedHigh + 1u;\n }\n var highMagnitude = vec2u(0u, roundedHigh << 12u);\n var highBits = fp64_make_f32_bits_from_u64(\n decoded.sign,\n highMagnitude,\n decoded.baseExponent\n );\n if (fp64_decode_f32_bits(highBits).isInf) {\n roundedHigh = decoded.significand >> 12u;\n highMagnitude = vec2u(0u, roundedHigh << 12u);\n highBits = fp64_make_f32_bits_from_u64(\n decoded.sign,\n highMagnitude,\n decoded.baseExponent\n );\n }\n let lowBits = fp64_make_residual_f32_bits(\n decoded.sign,\n vec2u(0u, decoded.significand),\n decoded.baseExponent,\n highBits\n );\n return vec2f(bitcast<f32>(highBits), bitcast<f32>(lowBits));\n}\n\nfn split2(a: vec2f) -> vec2f {\n var result = split(a.x);\n result.y = result.y + a.y;\n return result;\n}\n\nfn quickTwoSum(a: f32, b: f32) -> vec2f {\n return fp64_two_sum_integer(a, b);\n}\n#endif\n\nfn twoSum(a: f32, b: f32) -> vec2f {\n return fp64_two_sum_integer(a, b);\n}\n\nfn twoSub(a: f32, b: f32) -> vec2f {\n let bBits = bitcast<u32>(b) ^ 0x80000000u;\n let resultBits = fp64_two_sum_integer_bits(bitcast<u32>(a), bBits);\n return vec2f(bitcast<f32>(resultBits.x), bitcast<f32>(resultBits.y));\n}\n\n#ifndef LUMA_FP64_PREDICATE_ONLY\nfn twoSqr(a: f32) -> vec2f {\n return fp64_two_prod_integer(a, a);\n}\n\nfn twoProd(a: f32, b: f32) -> vec2f {\n return fp64_two_prod_integer(a, b);\n}\n#endif\n\nfn sum_fp64(a: vec2f, b: vec2f) -> vec2f {\n let highSum = fp64_two_sum_integer(a.x, b.x);\n let lowSum = prevent_fp64_optimization((a.y + b.y) + highSum.y);\n return fp64_two_sum_integer(highSum.x, lowSum);\n}\n\nfn sub_fp64(a: vec2f, b: vec2f) -> vec2f {\n let highDifference = twoSub(a.x, b.x);\n let lowDifference = prevent_fp64_optimization((a.y - b.y) + highDifference.y);\n return fp64_two_sum_integer(highDifference.x, lowDifference);\n}\n\nfn mul_fp64(a: vec2f, b: vec2f) -> vec2f {\n let highProduct = fp64_two_prod_integer(a.x, b.x);\n let crossTerms = prevent_fp64_optimization(a.x * b.y + a.y * b.x);\n let lowTerms = prevent_fp64_optimization((crossTerms + a.y * b.y) + highProduct.y);\n return fp64_two_sum_integer(highProduct.x, lowTerms);\n}\n\n#ifndef LUMA_FP64_PREDICATE_ONLY\nfn div_fp64(a: vec2f, b: vec2f) -> vec2f {\n let estimate = prevent_fp64_optimization(1.0 / b.x);\n let quotient = mul_fp64(a, vec2f(estimate, fp64_runtime_zero()));\n let remainder = prevent_fp64_optimization(sub_fp64(a, mul_fp64(b, quotient)).x);\n return sum_fp64(quotient, twoProd(estimate, remainder));\n}\n\nfn sqrt_fp64(a: vec2f) -> vec2f {\n if (a.x == 0.0 && a.y == 0.0) {\n return vec2f(0.0, 0.0);\n }\n if (a.x < 0.0) {\n let nanValue = fp64_nan(a.x);\n return vec2f(nanValue, nanValue);\n }\n\n let reciprocalRoot = prevent_fp64_optimization(1.0 / sqrt(a.x));\n let estimate = prevent_fp64_optimization(a.x * reciprocalRoot);\n let difference = prevent_fp64_optimization(sub_fp64(a, twoSqr(estimate)).x);\n let correction = twoProd(prevent_fp64_optimization(reciprocalRoot * 0.5), difference);\n return sum_fp64(vec2f(estimate, 0.0), correction);\n}\n#endif\n";
|
|
10
|
+
//# sourceMappingURL=fp64-arithmetic-wgsl-hybrid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fp64-arithmetic-wgsl-hybrid.d.ts","sourceRoot":"","sources":["../../../../src/modules/math/fp64/fp64-arithmetic-wgsl-hybrid.ts"],"names":[],"mappings":"AAMA;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,qsYAkHpC,CAAC"}
|