@photivra/engine 1.4.0 → 2.0.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/CHANGELOG.md +401 -6
- package/CITATION.cff +1 -1
- package/NODE_SUPPORT.md +64 -12
- package/README.md +301 -182
- package/SECURITY.md +37 -28
- package/THIRD_PARTY.md +148 -4
- package/dist/camera/equivalent-focal-length.d.ts +13 -14
- package/dist/camera/equivalent-focal-length.js +15 -13
- package/dist/camera/equivalent-focal-length.js.map +1 -1
- package/dist/camera/field-of-view.d.ts +30 -19
- package/dist/camera/field-of-view.js +67 -18
- package/dist/camera/field-of-view.js.map +1 -1
- package/dist/camera/lens-projection.d.ts +170 -0
- package/dist/camera/lens-projection.js +444 -0
- package/dist/camera/lens-projection.js.map +1 -0
- package/dist/camera/projected-object-size.d.ts +10 -11
- package/dist/camera/projected-object-size.js +12 -10
- package/dist/camera/projected-object-size.js.map +1 -1
- package/dist/capture/capture-export-metadata.d.ts +9 -10
- package/dist/capture/capture-export-metadata.js +8 -5
- package/dist/capture/capture-export-metadata.js.map +1 -1
- package/dist/capture/dng-import.d.ts +91 -0
- package/dist/capture/dng-import.js +343 -0
- package/dist/capture/dng-import.js.map +1 -0
- package/dist/capture/environment-raw-producer.d.ts +37 -17
- package/dist/capture/environment-raw-producer.js +43 -19
- package/dist/capture/environment-raw-producer.js.map +1 -1
- package/dist/capture/export-jpeg.d.ts +35 -4
- package/dist/capture/export-jpeg.js +133 -47
- package/dist/capture/export-jpeg.js.map +1 -1
- package/dist/capture/export-tiff.d.ts +48 -24
- package/dist/capture/export-tiff.js +91 -31
- package/dist/capture/export-tiff.js.map +1 -1
- package/dist/capture/focus-control.d.ts +42 -65
- package/dist/capture/focus-control.js +56 -75
- package/dist/capture/focus-control.js.map +1 -1
- package/dist/capture/host-yield-cadence.d.ts +25 -0
- package/dist/capture/host-yield-cadence.js +25 -0
- package/dist/capture/host-yield-cadence.js.map +1 -0
- package/dist/capture/linear-encoding.d.ts +14 -12
- package/dist/capture/linear-encoding.js +14 -13
- package/dist/capture/linear-encoding.js.map +1 -1
- package/dist/capture/lossless-jpeg.d.ts +27 -0
- package/dist/capture/lossless-jpeg.js +237 -0
- package/dist/capture/lossless-jpeg.js.map +1 -0
- package/dist/capture/native-environment-lean.d.ts +227 -0
- package/dist/capture/native-environment-lean.js +974 -0
- package/dist/capture/native-environment-lean.js.map +1 -0
- package/dist/capture/native-environment-optical-stage.d.ts +97 -0
- package/dist/capture/native-environment-optical-stage.js +340 -0
- package/dist/capture/native-environment-optical-stage.js.map +1 -0
- package/dist/capture/native-environment-raw.d.ts +140 -6
- package/dist/capture/native-environment-raw.js +435 -34
- package/dist/capture/native-environment-raw.js.map +1 -1
- package/dist/capture/native-raw-development.d.ts +118 -5
- package/dist/capture/native-raw-development.js +224 -59
- package/dist/capture/native-raw-development.js.map +1 -1
- package/dist/capture/native-raw-dng.d.ts +60 -0
- package/dist/capture/native-raw-dng.js +167 -0
- package/dist/capture/native-raw-dng.js.map +1 -0
- package/dist/capture/native-raw.d.ts +67 -10
- package/dist/capture/native-raw.js +90 -24
- package/dist/capture/native-raw.js.map +1 -1
- package/dist/capture/packed-sensor-raw.d.ts +160 -0
- package/dist/capture/packed-sensor-raw.js +221 -0
- package/dist/capture/packed-sensor-raw.js.map +1 -0
- package/dist/capture/photographic-export.d.ts +58 -35
- package/dist/capture/photographic-export.js +177 -70
- package/dist/capture/photographic-export.js.map +1 -1
- package/dist/capture/raw-development-kernel.d.ts +52 -0
- package/dist/capture/raw-development-kernel.js +88 -0
- package/dist/capture/raw-development-kernel.js.map +1 -0
- package/dist/capture/raw-frame-limits.d.ts +7 -7
- package/dist/capture/raw-frame-limits.js +7 -6
- package/dist/capture/raw-frame-limits.js.map +1 -1
- package/dist/capture/raw-frame-reconstruction.d.ts +8 -9
- package/dist/capture/raw-frame-reconstruction.js +9 -8
- package/dist/capture/raw-frame-reconstruction.js.map +1 -1
- package/dist/capture/raw-white-level.d.ts +55 -0
- package/dist/capture/raw-white-level.js +165 -0
- package/dist/capture/raw-white-level.js.map +1 -0
- package/dist/capture/release-sequence.d.ts +5 -7
- package/dist/capture/release-sequence.js +15 -13
- package/dist/capture/release-sequence.js.map +1 -1
- package/dist/capture/sensor-raw-frame.d.ts +5 -6
- package/dist/capture/sensor-raw-frame.js +26 -9
- package/dist/capture/sensor-raw-frame.js.map +1 -1
- package/dist/capture/sensor-raw-producer.d.ts +21 -13
- package/dist/capture/sensor-raw-producer.js +86 -25
- package/dist/capture/sensor-raw-producer.js.map +1 -1
- package/dist/capture/simulated-capture.d.ts +15 -16
- package/dist/capture/simulated-capture.js +22 -12
- package/dist/capture/simulated-capture.js.map +1 -1
- package/dist/color/camera-color-matrix.d.ts +69 -0
- package/dist/color/camera-color-matrix.js +132 -0
- package/dist/color/camera-color-matrix.js.map +1 -0
- package/dist/color/capture-color.d.ts +17 -10
- package/dist/color/capture-color.js +50 -17
- package/dist/color/capture-color.js.map +1 -1
- package/dist/color/chromatic-adaptation.d.ts +63 -0
- package/dist/color/chromatic-adaptation.js +91 -0
- package/dist/color/chromatic-adaptation.js.map +1 -0
- package/dist/color/color-difference.d.ts +104 -0
- package/dist/color/color-difference.js +205 -0
- package/dist/color/color-difference.js.map +1 -0
- package/dist/color/color-matching-functions.d.ts +168 -0
- package/dist/color/color-matching-functions.js +309 -0
- package/dist/color/color-matching-functions.js.map +1 -0
- package/dist/color/colorimetry-math.d.ts +52 -0
- package/dist/color/colorimetry-math.js +144 -0
- package/dist/color/colorimetry-math.js.map +1 -0
- package/dist/color/gamut-mapping.d.ts +54 -0
- package/dist/color/gamut-mapping.js +107 -0
- package/dist/color/gamut-mapping.js.map +1 -0
- package/dist/color/illuminants.d.ts +182 -0
- package/dist/color/illuminants.js +434 -0
- package/dist/color/illuminants.js.map +1 -0
- package/dist/color/rgb-color-spaces.d.ts +79 -0
- package/dist/color/rgb-color-spaces.js +115 -0
- package/dist/color/rgb-color-spaces.js.map +1 -0
- package/dist/color/sensor-color-development.d.ts +33 -11
- package/dist/color/sensor-color-development.js +104 -30
- package/dist/color/sensor-color-development.js.map +1 -1
- package/dist/color/srgb-icc.d.ts +9 -2
- package/dist/color/srgb-icc.js +16 -5
- package/dist/color/srgb-icc.js.map +1 -1
- package/dist/color/srgb-transfer.d.ts +1 -2
- package/dist/color/srgb-transfer.js +1 -1
- package/dist/color/srgb-transfer.js.map +1 -1
- package/dist/color/white-balance.d.ts +68 -19
- package/dist/color/white-balance.js +168 -35
- package/dist/color/white-balance.js.map +1 -1
- package/dist/composition/image-formation-plan.d.ts +152 -128
- package/dist/composition/image-formation-plan.js +292 -138
- package/dist/composition/image-formation-plan.js.map +1 -1
- package/dist/composition/plan-consumer.d.ts +6 -7
- package/dist/composition/plan-consumer.js +14 -11
- package/dist/composition/plan-consumer.js.map +1 -1
- package/dist/core/calculation-result.d.ts +21 -14
- package/dist/core/calculation-result.js +209 -11
- package/dist/core/calculation-result.js.map +1 -1
- package/dist/core/canonical-json.d.ts +13 -8
- package/dist/core/canonical-json.js +34 -15
- package/dist/core/canonical-json.js.map +1 -1
- package/dist/core/configuration-error.d.ts +5 -4
- package/dist/core/configuration-error.js +5 -3
- package/dist/core/configuration-error.js.map +1 -1
- package/dist/core/evidence-provenance.d.ts +12 -12
- package/dist/core/evidence-provenance.js +10 -9
- package/dist/core/evidence-provenance.js.map +1 -1
- package/dist/core/image-formation.d.ts +11 -10
- package/dist/core/image-formation.js +11 -9
- package/dist/core/image-formation.js.map +1 -1
- package/dist/core/owned-data.d.ts +9 -17
- package/dist/core/owned-data.js +9 -16
- package/dist/core/owned-data.js.map +1 -1
- package/dist/core/portable-math.d.ts +15 -0
- package/dist/core/portable-math.js +56 -0
- package/dist/core/portable-math.js.map +1 -0
- package/dist/core/record-validation.d.ts +48 -9
- package/dist/core/record-validation.js +93 -19
- package/dist/core/record-validation.js.map +1 -1
- package/dist/core/scientific-assurance.d.ts +16 -14
- package/dist/core/scientific-assurance.js +22 -18
- package/dist/core/scientific-assurance.js.map +1 -1
- package/dist/core/spectral-composition.d.ts +13 -14
- package/dist/core/spectral-composition.js +30 -27
- package/dist/core/spectral-composition.js.map +1 -1
- package/dist/core/spectral.d.ts +5 -6
- package/dist/core/spectral.js +9 -7
- package/dist/core/spectral.js.map +1 -1
- package/dist/core/validation.d.ts +3 -6
- package/dist/core/validation.js +3 -5
- package/dist/core/validation.js.map +1 -1
- package/dist/core/version.d.ts +6 -6
- package/dist/core/version.js +6 -5
- package/dist/core/version.js.map +1 -1
- package/dist/equipment/exposure-capabilities.d.ts +10 -10
- package/dist/equipment/exposure-capabilities.js +40 -30
- package/dist/equipment/exposure-capabilities.js.map +1 -1
- package/dist/equipment/generic-tier-assets.d.ts +13 -6
- package/dist/equipment/generic-tier-assets.js +34 -15
- package/dist/equipment/generic-tier-assets.js.map +1 -1
- package/dist/equipment/generic-tier-presets.d.ts +5 -6
- package/dist/equipment/generic-tier-presets.js +15 -13
- package/dist/equipment/generic-tier-presets.js.map +1 -1
- package/dist/equipment/iso-capabilities.d.ts +21 -22
- package/dist/equipment/iso-capabilities.js +49 -44
- package/dist/equipment/iso-capabilities.js.map +1 -1
- package/dist/equipment/metering-capabilities.d.ts +5 -6
- package/dist/equipment/metering-capabilities.js +22 -19
- package/dist/equipment/metering-capabilities.js.map +1 -1
- package/dist/equipment/release-capabilities.d.ts +3 -4
- package/dist/equipment/release-capabilities.js +18 -14
- package/dist/equipment/release-capabilities.js.map +1 -1
- package/dist/exposure/exposure-duration-control.d.ts +19 -17
- package/dist/exposure/exposure-duration-control.js +27 -23
- package/dist/exposure/exposure-duration-control.js.map +1 -1
- package/dist/exposure/exposure-mode-resolver.d.ts +42 -39
- package/dist/exposure/exposure-mode-resolver.js +127 -82
- package/dist/exposure/exposure-mode-resolver.js.map +1 -1
- package/dist/exposure/exposure.d.ts +17 -16
- package/dist/exposure/exposure.js +22 -15
- package/dist/exposure/exposure.js.map +1 -1
- package/dist/exposure/flash-ttl.d.ts +135 -0
- package/dist/exposure/flash-ttl.js +193 -0
- package/dist/exposure/flash-ttl.js.map +1 -0
- package/dist/exposure/flash.d.ts +144 -36
- package/dist/exposure/flash.js +259 -59
- package/dist/exposure/flash.js.map +1 -1
- package/dist/exposure/metering-scene-radiance.d.ts +10 -10
- package/dist/exposure/metering-scene-radiance.js +42 -23
- package/dist/exposure/metering-scene-radiance.js.map +1 -1
- package/dist/exposure/metering-target.d.ts +8 -8
- package/dist/exposure/metering-target.js +30 -20
- package/dist/exposure/metering-target.js.map +1 -1
- package/dist/exposure/metering-temporal.d.ts +16 -15
- package/dist/exposure/metering-temporal.js +41 -19
- package/dist/exposure/metering-temporal.js.map +1 -1
- package/dist/exposure/metering.d.ts +64 -17
- package/dist/exposure/metering.js +159 -30
- package/dist/exposure/metering.js.map +1 -1
- package/dist/exposure/program-line.d.ts +5 -5
- package/dist/exposure/program-line.js +20 -13
- package/dist/exposure/program-line.js.map +1 -1
- package/dist/facade/camera-preset.d.ts +8 -0
- package/dist/facade/camera-preset.js +102 -0
- package/dist/facade/camera-preset.js.map +1 -0
- package/dist/facade/chart-radiance-batch.d.ts +57 -0
- package/dist/facade/chart-radiance-batch.js +121 -0
- package/dist/facade/chart-radiance-batch.js.map +1 -0
- package/dist/facade/chart-scenes.d.ts +177 -0
- package/dist/facade/chart-scenes.js +232 -0
- package/dist/facade/chart-scenes.js.map +1 -0
- package/dist/facade/host-yield.d.ts +7 -0
- package/dist/facade/host-yield.js +23 -0
- package/dist/facade/host-yield.js.map +1 -0
- package/dist/facade/scene-radiance.d.ts +117 -0
- package/dist/facade/scene-radiance.js +205 -0
- package/dist/facade/scene-radiance.js.map +1 -0
- package/dist/facade/simulate-capture.d.ts +284 -0
- package/dist/facade/simulate-capture.js +1026 -0
- package/dist/facade/simulate-capture.js.map +1 -0
- package/dist/gpu/chart-radiance-gpu.d.ts +17 -0
- package/dist/gpu/chart-radiance-gpu.js +176 -0
- package/dist/gpu/chart-radiance-gpu.js.map +1 -0
- package/dist/gpu/image-kernel-accelerator.d.ts +132 -0
- package/dist/gpu/image-kernel-accelerator.js +720 -0
- package/dist/gpu/image-kernel-accelerator.js.map +1 -0
- package/dist/gpu/image-kernel-execution.d.ts +92 -0
- package/dist/gpu/image-kernel-execution.js +84 -0
- package/dist/gpu/image-kernel-execution.js.map +1 -0
- package/dist/gpu/sensor-stage-gpu.d.ts +44 -0
- package/dist/gpu/sensor-stage-gpu.js +317 -0
- package/dist/gpu/sensor-stage-gpu.js.map +1 -0
- package/dist/gpu/temporal-sum-gpu.d.ts +23 -0
- package/dist/gpu/temporal-sum-gpu.js +150 -0
- package/dist/gpu/temporal-sum-gpu.js.map +1 -0
- package/dist/gpu/webgpu-runtime.d.ts +63 -0
- package/dist/gpu/webgpu-runtime.js +215 -0
- package/dist/gpu/webgpu-runtime.js.map +1 -0
- package/dist/gpu/wgsl-chart-kernel.d.ts +30 -0
- package/dist/gpu/wgsl-chart-kernel.js +165 -0
- package/dist/gpu/wgsl-chart-kernel.js.map +1 -0
- package/dist/gpu/wgsl-kernels.d.ts +53 -0
- package/dist/gpu/wgsl-kernels.js +365 -0
- package/dist/gpu/wgsl-kernels.js.map +1 -0
- package/dist/gpu/wgsl-sensor-kernel.d.ts +64 -0
- package/dist/gpu/wgsl-sensor-kernel.js +409 -0
- package/dist/gpu/wgsl-sensor-kernel.js.map +1 -0
- package/dist/index.d.ts +89 -25
- package/dist/index.js +59 -15
- package/dist/index.js.map +1 -1
- package/dist/motion/camera-rotation.d.ts +92 -40
- package/dist/motion/camera-rotation.js +84 -47
- package/dist/motion/camera-rotation.js.map +1 -1
- package/dist/motion/capture-rotation-inverse-mapping.d.ts +37 -34
- package/dist/motion/capture-rotation-inverse-mapping.js +32 -24
- package/dist/motion/capture-rotation-inverse-mapping.js.map +1 -1
- package/dist/motion/capture-rotation-temporal-quadrature.d.ts +39 -35
- package/dist/motion/capture-rotation-temporal-quadrature.js +37 -28
- package/dist/motion/capture-rotation-temporal-quadrature.js.map +1 -1
- package/dist/motion/capture-rotation-trajectory.d.ts +32 -28
- package/dist/motion/capture-rotation-trajectory.js +36 -26
- package/dist/motion/capture-rotation-trajectory.js.map +1 -1
- package/dist/motion/capture-translation-parallax-temporal-quadrature.d.ts +23 -21
- package/dist/motion/capture-translation-parallax-temporal-quadrature.js +33 -14
- package/dist/motion/capture-translation-parallax-temporal-quadrature.js.map +1 -1
- package/dist/motion/extended-object-projection.d.ts +19 -16
- package/dist/motion/extended-object-projection.js +38 -18
- package/dist/motion/extended-object-projection.js.map +1 -1
- package/dist/motion/projected-motion.d.ts +18 -17
- package/dist/motion/projected-motion.js +25 -17
- package/dist/motion/projected-motion.js.map +1 -1
- package/dist/motion/temporal-exposure-sum.d.ts +55 -0
- package/dist/motion/temporal-exposure-sum.js +141 -0
- package/dist/motion/temporal-exposure-sum.js.map +1 -0
- package/dist/motion/video-sequence.d.ts +111 -0
- package/dist/motion/video-sequence.js +179 -0
- package/dist/motion/video-sequence.js.map +1 -0
- package/dist/optics/aperture.d.ts +14 -15
- package/dist/optics/aperture.js +13 -11
- package/dist/optics/aperture.js.map +1 -1
- package/dist/optics/atmospheric-haze.d.ts +83 -0
- package/dist/optics/atmospheric-haze.js +113 -0
- package/dist/optics/atmospheric-haze.js.map +1 -0
- package/dist/optics/brown-conrady-distortion.d.ts +116 -0
- package/dist/optics/brown-conrady-distortion.js +291 -0
- package/dist/optics/brown-conrady-distortion.js.map +1 -0
- package/dist/optics/circle-of-confusion.d.ts +10 -10
- package/dist/optics/circle-of-confusion.js +15 -11
- package/dist/optics/circle-of-confusion.js.map +1 -1
- package/dist/optics/complex-pupil-psf.d.ts +64 -33
- package/dist/optics/complex-pupil-psf.js +190 -98
- package/dist/optics/complex-pupil-psf.js.map +1 -1
- package/dist/optics/depth-of-field.d.ts +25 -15
- package/dist/optics/depth-of-field.js +67 -27
- package/dist/optics/depth-of-field.js.map +1 -1
- package/dist/optics/diffraction.d.ts +14 -13
- package/dist/optics/diffraction.js +14 -10
- package/dist/optics/diffraction.js.map +1 -1
- package/dist/optics/focus-breathing.d.ts +88 -27
- package/dist/optics/focus-breathing.js +114 -23
- package/dist/optics/focus-breathing.js.map +1 -1
- package/dist/optics/focus-state.d.ts +18 -18
- package/dist/optics/focus-state.js +21 -15
- package/dist/optics/focus-state.js.map +1 -1
- package/dist/optics/front-of-lens-filter.d.ts +45 -14
- package/dist/optics/front-of-lens-filter.js +259 -88
- package/dist/optics/front-of-lens-filter.js.map +1 -1
- package/dist/optics/illumination-vignetting.d.ts +16 -17
- package/dist/optics/illumination-vignetting.js +40 -17
- package/dist/optics/illumination-vignetting.js.map +1 -1
- package/dist/optics/irradiance-convolution.d.ts +59 -0
- package/dist/optics/irradiance-convolution.js +138 -0
- package/dist/optics/irradiance-convolution.js.map +1 -0
- package/dist/optics/lateral-chromatic-aberration.d.ts +33 -30
- package/dist/optics/lateral-chromatic-aberration.js +33 -23
- package/dist/optics/lateral-chromatic-aberration.js.map +1 -1
- package/dist/optics/lens-psf-kernels.d.ts +89 -0
- package/dist/optics/lens-psf-kernels.js +175 -0
- package/dist/optics/lens-psf-kernels.js.map +1 -0
- package/dist/optics/lens-psf-profile.d.ts +78 -46
- package/dist/optics/lens-psf-profile.js +335 -124
- package/dist/optics/lens-psf-profile.js.map +1 -1
- package/dist/optics/longitudinal-chromatic-aberration.d.ts +102 -0
- package/dist/optics/longitudinal-chromatic-aberration.js +210 -0
- package/dist/optics/longitudinal-chromatic-aberration.js.map +1 -0
- package/dist/optics/polygon-diffraction.d.ts +80 -23
- package/dist/optics/polygon-diffraction.js +130 -25
- package/dist/optics/polygon-diffraction.js.map +1 -1
- package/dist/optics/profile-contract.d.ts +5 -6
- package/dist/optics/profile-contract.js +14 -11
- package/dist/optics/profile-contract.js.map +1 -1
- package/dist/optics/psf-foundation.d.ts +23 -23
- package/dist/optics/psf-foundation.js +24 -21
- package/dist/optics/psf-foundation.js.map +1 -1
- package/dist/optics/pupil-vignetting.d.ts +118 -0
- package/dist/optics/pupil-vignetting.js +264 -0
- package/dist/optics/pupil-vignetting.js.map +1 -0
- package/dist/optics/radial-distortion.d.ts +34 -33
- package/dist/optics/radial-distortion.js +37 -30
- package/dist/optics/radial-distortion.js.map +1 -1
- package/dist/optics/scene-to-sensor-irradiance.d.ts +47 -33
- package/dist/optics/scene-to-sensor-irradiance.js +73 -45
- package/dist/optics/scene-to-sensor-irradiance.js.map +1 -1
- package/dist/optics/scene-to-sensor-quadrature.d.ts +23 -18
- package/dist/optics/scene-to-sensor-quadrature.js +16 -11
- package/dist/optics/scene-to-sensor-quadrature.js.map +1 -1
- package/dist/optics/sensor-aperture-rays.d.ts +20 -4
- package/dist/optics/sensor-aperture-rays.js +32 -14
- package/dist/optics/sensor-aperture-rays.js.map +1 -1
- package/dist/optics/sensor-environment-query.d.ts +81 -16
- package/dist/optics/sensor-environment-query.js +145 -12
- package/dist/optics/sensor-environment-query.js.map +1 -1
- package/dist/optics/sensor-psf-quadrature.d.ts +12 -10
- package/dist/optics/sensor-psf-quadrature.js +18 -11
- package/dist/optics/sensor-psf-quadrature.js.map +1 -1
- package/dist/optics/sensor-psf-support.d.ts +8 -6
- package/dist/optics/sensor-psf-support.js +8 -5
- package/dist/optics/sensor-psf-support.js.map +1 -1
- package/dist/optics/stray-light.d.ts +22 -19
- package/dist/optics/stray-light.js +18 -12
- package/dist/optics/stray-light.js.map +1 -1
- package/dist/optics/thin-lens.d.ts +10 -9
- package/dist/optics/thin-lens.js +12 -8
- package/dist/optics/thin-lens.js.map +1 -1
- package/dist/optics/zernike-wavefront.d.ts +154 -0
- package/dist/optics/zernike-wavefront.js +352 -0
- package/dist/optics/zernike-wavefront.js.map +1 -0
- package/dist/output/capture-corrected-sdr.d.ts +16 -8
- package/dist/output/capture-corrected-sdr.js +16 -8
- package/dist/output/capture-corrected-sdr.js.map +1 -1
- package/dist/output/capture-geometry.d.ts +34 -36
- package/dist/output/capture-geometry.js +52 -32
- package/dist/output/capture-geometry.js.map +1 -1
- package/dist/output/capture-sdr.d.ts +7 -6
- package/dist/output/capture-sdr.js +11 -8
- package/dist/output/capture-sdr.js.map +1 -1
- package/dist/output/crop.d.ts +22 -6
- package/dist/output/crop.js +40 -6
- package/dist/output/crop.js.map +1 -1
- package/dist/output/geometric-transforms.d.ts +60 -23
- package/dist/output/geometric-transforms.js +111 -24
- package/dist/output/geometric-transforms.js.map +1 -1
- package/dist/output/lens-corrections.d.ts +27 -19
- package/dist/output/lens-corrections.js +29 -13
- package/dist/output/lens-corrections.js.map +1 -1
- package/dist/output/native-capture-sdr.d.ts +71 -16
- package/dist/output/native-capture-sdr.js +190 -33
- package/dist/output/native-capture-sdr.js.map +1 -1
- package/dist/output/png-encoder.d.ts +65 -0
- package/dist/output/png-encoder.js +461 -0
- package/dist/output/png-encoder.js.map +1 -0
- package/dist/output/print-contrast-reference.d.ts +10 -9
- package/dist/output/print-contrast-reference.js +10 -8
- package/dist/output/print-contrast-reference.js.map +1 -1
- package/dist/output/print-detail.d.ts +18 -17
- package/dist/output/print-detail.js +12 -10
- package/dist/output/print-detail.js.map +1 -1
- package/dist/output/print-jpeg.d.ts +26 -5
- package/dist/output/print-jpeg.js +117 -50
- package/dist/output/print-jpeg.js.map +1 -1
- package/dist/output/print-plan.d.ts +19 -19
- package/dist/output/print-plan.js +11 -10
- package/dist/output/print-plan.js.map +1 -1
- package/dist/output/print-region-statistics.d.ts +14 -15
- package/dist/output/print-region-statistics.js +11 -11
- package/dist/output/print-region-statistics.js.map +1 -1
- package/dist/output/sdr-rendering.d.ts +48 -10
- package/dist/output/sdr-rendering.js +114 -25
- package/dist/output/sdr-rendering.js.map +1 -1
- package/dist/output/subject-framing-crop.d.ts +6 -10
- package/dist/output/subject-framing-crop.js +23 -13
- package/dist/output/subject-framing-crop.js.map +1 -1
- package/dist/processing/demosaic.d.ts +90 -0
- package/dist/processing/demosaic.js +275 -0
- package/dist/processing/demosaic.js.map +1 -0
- package/dist/processing/denoise.d.ts +68 -0
- package/dist/processing/denoise.js +214 -0
- package/dist/processing/denoise.js.map +1 -0
- package/dist/processing/focus-stacking.d.ts +17 -0
- package/dist/processing/focus-stacking.js +80 -0
- package/dist/processing/focus-stacking.js.map +1 -0
- package/dist/processing/hdr.d.ts +54 -0
- package/dist/processing/hdr.js +172 -0
- package/dist/processing/hdr.js.map +1 -0
- package/dist/processing/image-ops.d.ts +66 -0
- package/dist/processing/image-ops.js +192 -0
- package/dist/processing/image-ops.js.map +1 -0
- package/dist/processing/panorama.d.ts +51 -0
- package/dist/processing/panorama.js +305 -0
- package/dist/processing/panorama.js.map +1 -0
- package/dist/processing/processing-task.d.ts +85 -0
- package/dist/processing/processing-task.js +164 -0
- package/dist/processing/processing-task.js.map +1 -0
- package/dist/processing/tone-mapping.d.ts +69 -0
- package/dist/processing/tone-mapping.js +310 -0
- package/dist/processing/tone-mapping.js.map +1 -0
- package/dist/schema/camera.d.ts +5 -4
- package/dist/schema/illumination-spectral.d.ts +13 -19
- package/dist/schema/illumination-spectral.js +23 -19
- package/dist/schema/illumination-spectral.js.map +1 -1
- package/dist/schema/illumination-temporal.d.ts +12 -15
- package/dist/schema/illumination-temporal.js +43 -28
- package/dist/schema/illumination-temporal.js.map +1 -1
- package/dist/schema/illumination.d.ts +5 -4
- package/dist/schema/illumination.js +55 -20
- package/dist/schema/illumination.js.map +1 -1
- package/dist/schema/scene-radiance-temporal.d.ts +9 -11
- package/dist/schema/scene-radiance-temporal.js +26 -23
- package/dist/schema/scene-radiance-temporal.js.map +1 -1
- package/dist/schema/scene-radiance.d.ts +17 -17
- package/dist/schema/scene-radiance.js +56 -34
- package/dist/schema/scene-radiance.js.map +1 -1
- package/dist/schema/scene.d.ts +14 -13
- package/dist/schema/validation.d.ts +0 -1
- package/dist/schema/validation.js +17 -15
- package/dist/schema/validation.js.map +1 -1
- package/dist/sensor/accumulated-charge.d.ts +45 -64
- package/dist/sensor/accumulated-charge.js +41 -47
- package/dist/sensor/accumulated-charge.js.map +1 -1
- package/dist/sensor/architecture.d.ts +22 -25
- package/dist/sensor/architecture.js +17 -16
- package/dist/sensor/architecture.js.map +1 -1
- package/dist/sensor/camera-saturation-capacity.d.ts +21 -28
- package/dist/sensor/camera-saturation-capacity.js +36 -34
- package/dist/sensor/camera-saturation-capacity.js.map +1 -1
- package/dist/sensor/capture-color-sampling-binding.d.ts +46 -51
- package/dist/sensor/capture-color-sampling-binding.js +39 -41
- package/dist/sensor/capture-color-sampling-binding.js.map +1 -1
- package/dist/sensor/capture-mode-timing.d.ts +8 -9
- package/dist/sensor/capture-mode-timing.js +24 -21
- package/dist/sensor/capture-mode-timing.js.map +1 -1
- package/dist/sensor/capture-mode.d.ts +28 -30
- package/dist/sensor/capture-mode.js +33 -31
- package/dist/sensor/capture-mode.js.map +1 -1
- package/dist/sensor/color-sampling.d.ts +30 -33
- package/dist/sensor/color-sampling.js +32 -37
- package/dist/sensor/color-sampling.js.map +1 -1
- package/dist/sensor/constant-rate-temporal-integration.d.ts +19 -23
- package/dist/sensor/constant-rate-temporal-integration.js +28 -26
- package/dist/sensor/constant-rate-temporal-integration.js.map +1 -1
- package/dist/sensor/dark-current.d.ts +53 -49
- package/dist/sensor/dark-current.js +87 -46
- package/dist/sensor/dark-current.js.map +1 -1
- package/dist/sensor/environment-photo-signal.d.ts +71 -30
- package/dist/sensor/environment-photo-signal.js +127 -46
- package/dist/sensor/environment-photo-signal.js.map +1 -1
- package/dist/sensor/eqe-electron-rate.d.ts +14 -13
- package/dist/sensor/eqe-electron-rate.js +34 -14
- package/dist/sensor/eqe-electron-rate.js.map +1 -1
- package/dist/sensor/eqe-local-exposure.d.ts +24 -24
- package/dist/sensor/eqe-local-exposure.js +15 -11
- package/dist/sensor/eqe-local-exposure.js.map +1 -1
- package/dist/sensor/eqe-temporal-exposure.d.ts +11 -11
- package/dist/sensor/eqe-temporal-exposure.js +15 -10
- package/dist/sensor/eqe-temporal-exposure.js.map +1 -1
- package/dist/sensor/exposure-window.d.ts +48 -34
- package/dist/sensor/exposure-window.js +77 -36
- package/dist/sensor/exposure-window.js.map +1 -1
- package/dist/sensor/fixed-pattern-noise.d.ts +108 -0
- package/dist/sensor/fixed-pattern-noise.js +166 -0
- package/dist/sensor/fixed-pattern-noise.js.map +1 -0
- package/dist/sensor/iso-gain.d.ts +44 -0
- package/dist/sensor/iso-gain.js +119 -0
- package/dist/sensor/iso-gain.js.map +1 -0
- package/dist/sensor/iso-signal-chain.d.ts +25 -48
- package/dist/sensor/iso-signal-chain.js +52 -66
- package/dist/sensor/iso-signal-chain.js.map +1 -1
- package/dist/sensor/local-exposure-binding.d.ts +21 -21
- package/dist/sensor/local-exposure-binding.js +22 -18
- package/dist/sensor/local-exposure-binding.js.map +1 -1
- package/dist/sensor/optical-stack.d.ts +36 -40
- package/dist/sensor/optical-stack.js +34 -37
- package/dist/sensor/optical-stack.js.map +1 -1
- package/dist/sensor/photon-energy.d.ts +22 -28
- package/dist/sensor/photon-energy.js +42 -34
- package/dist/sensor/photon-energy.js.map +1 -1
- package/dist/sensor/physical-charge-capacity.d.ts +20 -30
- package/dist/sensor/physical-charge-capacity.js +35 -36
- package/dist/sensor/physical-charge-capacity.js.map +1 -1
- package/dist/sensor/pixel-pitch.d.ts +2 -3
- package/dist/sensor/pixel-pitch.js +4 -2
- package/dist/sensor/pixel-pitch.js.map +1 -1
- package/dist/sensor/radiometry-readiness.d.ts +13 -15
- package/dist/sensor/radiometry-readiness.js +20 -17
- package/dist/sensor/radiometry-readiness.js.map +1 -1
- package/dist/sensor/raw-readout.d.ts +173 -83
- package/dist/sensor/raw-readout.js +425 -160
- package/dist/sensor/raw-readout.js.map +1 -1
- package/dist/sensor/raw-reconstruction.d.ts +112 -44
- package/dist/sensor/raw-reconstruction.js +200 -47
- package/dist/sensor/raw-reconstruction.js.map +1 -1
- package/dist/sensor/readout-exposure-linkage.d.ts +103 -34
- package/dist/sensor/readout-exposure-linkage.js +125 -27
- package/dist/sensor/readout-exposure-linkage.js.map +1 -1
- package/dist/sensor/readout-timing.d.ts +43 -44
- package/dist/sensor/readout-timing.js +38 -30
- package/dist/sensor/readout-timing.js.map +1 -1
- package/dist/sensor/response-application-compatibility.d.ts +21 -28
- package/dist/sensor/response-application-compatibility.js +35 -34
- package/dist/sensor/response-application-compatibility.js.map +1 -1
- package/dist/sensor/response-operating-range.d.ts +26 -35
- package/dist/sensor/response-operating-range.js +40 -39
- package/dist/sensor/response-operating-range.js.map +1 -1
- package/dist/sensor/responsivity-photocurrent.d.ts +21 -29
- package/dist/sensor/responsivity-photocurrent.js +57 -40
- package/dist/sensor/responsivity-photocurrent.js.map +1 -1
- package/dist/sensor/sampling-aperture.d.ts +21 -25
- package/dist/sensor/sampling-aperture.js +29 -28
- package/dist/sensor/sampling-aperture.js.map +1 -1
- package/dist/sensor/scene-eqe-temporal-exposure.d.ts +14 -12
- package/dist/sensor/scene-eqe-temporal-exposure.js +13 -8
- package/dist/sensor/scene-eqe-temporal-exposure.js.map +1 -1
- package/dist/sensor/sensor-geometry.d.ts +28 -32
- package/dist/sensor/sensor-geometry.js +35 -20
- package/dist/sensor/sensor-geometry.js.map +1 -1
- package/dist/sensor/signal-noise.d.ts +14 -16
- package/dist/sensor/signal-noise.js +15 -13
- package/dist/sensor/signal-noise.js.map +1 -1
- package/dist/sensor/spatial-sample-reduction.d.ts +45 -60
- package/dist/sensor/spatial-sample-reduction.js +39 -48
- package/dist/sensor/spatial-sample-reduction.js.map +1 -1
- package/dist/sensor/spatial-sampling-quadrature.d.ts +46 -54
- package/dist/sensor/spatial-sampling-quadrature.js +31 -36
- package/dist/sensor/spatial-sampling-quadrature.js.map +1 -1
- package/dist/sensor/spatio-spectral-reduction.d.ts +32 -42
- package/dist/sensor/spatio-spectral-reduction.js +24 -29
- package/dist/sensor/spatio-spectral-reduction.js.map +1 -1
- package/dist/sensor/spectral-coverage.d.ts +6 -9
- package/dist/sensor/spectral-coverage.js +9 -6
- package/dist/sensor/spectral-coverage.js.map +1 -1
- package/dist/sensor/spectral-quadrature.d.ts +46 -60
- package/dist/sensor/spectral-quadrature.js +38 -48
- package/dist/sensor/spectral-quadrature.js.map +1 -1
- package/dist/sensor/spectral-response.d.ts +53 -41
- package/dist/sensor/spectral-response.js +80 -47
- package/dist/sensor/spectral-response.js.map +1 -1
- package/dist/sensor/stochastic-seed.d.ts +50 -0
- package/dist/sensor/stochastic-seed.js +123 -0
- package/dist/sensor/stochastic-seed.js.map +1 -0
- package/dist/sensor/temporal-eqe-sum.d.ts +2 -4
- package/dist/sensor/temporal-eqe-sum.js +5 -6
- package/dist/sensor/temporal-eqe-sum.js.map +1 -1
- package/dist/sensor/temporal-photo-signal.d.ts +5 -6
- package/dist/sensor/temporal-photo-signal.js +11 -10
- package/dist/sensor/temporal-photo-signal.js.map +1 -1
- package/dist/sensor/temporal-sample-binding.d.ts +1 -2
- package/dist/sensor/temporal-sample-binding.js +3 -3
- package/dist/sensor/temporal-sample-binding.js.map +1 -1
- package/dist/simulation/poc-simulation.d.ts +16 -16
- package/dist/simulation/poc-simulation.js +20 -15
- package/dist/simulation/poc-simulation.js.map +1 -1
- package/dist/stabilization/camera-shake.d.ts +42 -18
- package/dist/stabilization/camera-shake.js +43 -20
- package/dist/stabilization/camera-shake.js.map +1 -1
- package/dist/stabilization/system.d.ts +44 -41
- package/dist/stabilization/system.js +196 -108
- package/dist/stabilization/system.js.map +1 -1
- package/docs/AGENT_GUIDE.md +183 -0
- package/docs/API_REFERENCE.md +761 -2
- package/docs/QUICK_START.md +495 -0
- package/docs/USAGE.md +1719 -714
- package/docs/api/camera-equivalent-focal-length.md +6 -7
- package/docs/api/camera-field-of-view.md +16 -8
- package/docs/api/camera-lens-projection.md +246 -0
- package/docs/api/camera-projected-object-size.md +6 -5
- package/docs/api/capture-capture-export-metadata.md +10 -10
- package/docs/api/capture-dng-import.md +134 -0
- package/docs/api/capture-environment-raw-producer.md +17 -11
- package/docs/api/capture-export-jpeg.md +16 -0
- package/docs/api/capture-focus-control.md +25 -47
- package/docs/api/capture-linear-encoding.md +21 -12
- package/docs/api/capture-lossless-jpeg.md +49 -0
- package/docs/api/capture-native-environment-optical-stage.md +75 -0
- package/docs/api/capture-native-environment-raw.md +161 -4
- package/docs/api/capture-native-raw-development.md +69 -4
- package/docs/api/capture-native-raw-dng.md +84 -0
- package/docs/api/capture-native-raw.md +23 -8
- package/docs/api/capture-packed-sensor-raw.md +156 -0
- package/docs/api/capture-photographic-export.md +69 -31
- package/docs/api/capture-raw-frame-reconstruction.md +8 -8
- package/docs/api/capture-raw-white-level.md +37 -0
- package/docs/api/capture-release-sequence.md +6 -7
- package/docs/api/capture-sensor-raw-frame.md +6 -6
- package/docs/api/capture-sensor-raw-producer.md +17 -11
- package/docs/api/capture-simulated-capture.md +15 -15
- package/docs/api/color-camera-color-matrix.md +103 -0
- package/docs/api/color-capture-color.md +22 -11
- package/docs/api/color-chromatic-adaptation.md +82 -0
- package/docs/api/color-color-difference.md +134 -0
- package/docs/api/color-color-matching-functions.md +259 -0
- package/docs/api/color-colorimetry-math.md +54 -0
- package/docs/api/color-gamut-mapping.md +72 -0
- package/docs/api/color-illuminants.md +280 -0
- package/docs/api/color-rgb-color-spaces.md +151 -0
- package/docs/api/color-sensor-color-development.md +27 -0
- package/docs/api/color-srgb-icc.md +2 -4
- package/docs/api/color-white-balance.md +95 -19
- package/docs/api/composition-image-formation-plan.md +124 -95
- package/docs/api/composition-plan-consumer.md +7 -7
- package/docs/api/core-calculation-result.md +18 -14
- package/docs/api/core-configuration-error.md +1 -1
- package/docs/api/core-image-formation.md +7 -7
- package/docs/api/core-scientific-assurance.md +12 -10
- package/docs/api/core-spectral-composition.md +14 -14
- package/docs/api/core-spectral.md +6 -6
- package/docs/api/core-validation.md +3 -3
- package/docs/api/core-version.md +7 -6
- package/docs/api/equipment-exposure-capabilities.md +11 -10
- package/docs/api/equipment-generic-tier-assets.md +7 -2
- package/docs/api/equipment-generic-tier-presets.md +6 -6
- package/docs/api/equipment-iso-capabilities.md +18 -18
- package/docs/api/equipment-metering-capabilities.md +6 -6
- package/docs/api/equipment-release-capabilities.md +4 -4
- package/docs/api/exports.json +2213 -8
- package/docs/api/exposure-exposure-duration-control.md +9 -9
- package/docs/api/exposure-exposure-mode-resolver.md +35 -31
- package/docs/api/exposure-exposure.md +10 -10
- package/docs/api/exposure-flash-ttl.md +182 -0
- package/docs/api/exposure-flash.md +183 -28
- package/docs/api/exposure-metering-scene-radiance.md +11 -10
- package/docs/api/exposure-metering-target.md +9 -8
- package/docs/api/exposure-metering-temporal.md +8 -8
- package/docs/api/exposure-metering.md +69 -9
- package/docs/api/exposure-program-line.md +6 -5
- package/docs/api/facade-chart-radiance-batch.md +96 -0
- package/docs/api/facade-chart-scenes.md +240 -0
- package/docs/api/facade-scene-radiance.md +122 -0
- package/docs/api/facade-simulate-capture.md +324 -0
- package/docs/api/gpu-image-kernel-accelerator.md +157 -0
- package/docs/api/gpu-image-kernel-execution.md +152 -0
- package/docs/api/motion-camera-rotation.md +43 -26
- package/docs/api/motion-capture-rotation-inverse-mapping.md +24 -23
- package/docs/api/motion-capture-rotation-temporal-quadrature.md +22 -22
- package/docs/api/motion-capture-rotation-trajectory.md +15 -15
- package/docs/api/motion-capture-translation-parallax-temporal-quadrature.md +15 -14
- package/docs/api/motion-extended-object-projection.md +10 -8
- package/docs/api/motion-projected-motion.md +8 -8
- package/docs/api/motion-temporal-exposure-sum.md +98 -0
- package/docs/api/motion-video-sequence.md +159 -0
- package/docs/api/optics-aperture.md +8 -8
- package/docs/api/optics-atmospheric-haze.md +104 -0
- package/docs/api/optics-brown-conrady-distortion.md +123 -0
- package/docs/api/optics-circle-of-confusion.md +5 -4
- package/docs/api/optics-complex-pupil-psf.md +57 -16
- package/docs/api/optics-depth-of-field.md +12 -6
- package/docs/api/optics-diffraction.md +8 -7
- package/docs/api/optics-focus-breathing.md +104 -16
- package/docs/api/optics-focus-state.md +9 -10
- package/docs/api/optics-front-of-lens-filter.md +72 -14
- package/docs/api/optics-illumination-vignetting.md +10 -10
- package/docs/api/optics-irradiance-convolution.md +95 -0
- package/docs/api/optics-lateral-chromatic-aberration.md +22 -21
- package/docs/api/optics-lens-psf-kernels.md +72 -0
- package/docs/api/optics-lens-psf-profile.md +48 -26
- package/docs/api/optics-longitudinal-chromatic-aberration.md +128 -0
- package/docs/api/optics-polygon-diffraction.md +78 -13
- package/docs/api/optics-profile-contract.md +4 -4
- package/docs/api/optics-psf-foundation.md +12 -12
- package/docs/api/optics-pupil-vignetting.md +132 -0
- package/docs/api/optics-radial-distortion.md +12 -12
- package/docs/api/optics-scene-to-sensor-irradiance.md +25 -14
- package/docs/api/optics-scene-to-sensor-quadrature.md +15 -12
- package/docs/api/optics-sensor-aperture-rays.md +3 -2
- package/docs/api/optics-sensor-environment-query.md +52 -9
- package/docs/api/optics-sensor-psf-quadrature.md +13 -10
- package/docs/api/optics-stray-light.md +12 -11
- package/docs/api/optics-thin-lens.md +4 -3
- package/docs/api/optics-zernike-wavefront.md +229 -0
- package/docs/api/output-capture-corrected-sdr.md +10 -7
- package/docs/api/output-capture-geometry.md +35 -36
- package/docs/api/output-capture-sdr.md +4 -4
- package/docs/api/output-crop.md +7 -4
- package/docs/api/output-geometric-transforms.md +65 -19
- package/docs/api/output-lens-corrections.md +17 -15
- package/docs/api/output-native-capture-sdr.md +26 -13
- package/docs/api/output-png-encoder.md +105 -0
- package/docs/api/output-print-contrast-reference.md +8 -8
- package/docs/api/output-print-detail.md +14 -14
- package/docs/api/output-print-jpeg.md +22 -5
- package/docs/api/output-print-plan.md +18 -18
- package/docs/api/output-print-region-statistics.md +14 -14
- package/docs/api/output-sdr-rendering.md +52 -10
- package/docs/api/output-subject-framing-crop.md +5 -6
- package/docs/api/processing-demosaic.md +120 -0
- package/docs/api/processing-denoise.md +148 -0
- package/docs/api/processing-focus-stacking.md +41 -0
- package/docs/api/processing-hdr.md +113 -0
- package/docs/api/processing-panorama.md +82 -0
- package/docs/api/processing-processing-task.md +107 -0
- package/docs/api/processing-tone-mapping.md +142 -0
- package/docs/api/schema-camera.md +6 -4
- package/docs/api/schema-illumination-spectral.md +10 -11
- package/docs/api/schema-illumination-temporal.md +13 -15
- package/docs/api/schema-illumination.md +4 -4
- package/docs/api/schema-scene-radiance-temporal.md +10 -11
- package/docs/api/schema-scene-radiance.md +18 -17
- package/docs/api/schema-scene.md +9 -9
- package/docs/api/schema-validation.md +1 -1
- package/docs/api/sensor-accumulated-charge.md +12 -20
- package/docs/api/sensor-architecture.md +15 -16
- package/docs/api/sensor-camera-saturation-capacity.md +9 -11
- package/docs/api/sensor-capture-color-sampling-binding.md +47 -51
- package/docs/api/sensor-capture-mode-timing.md +9 -9
- package/docs/api/sensor-capture-mode.md +29 -30
- package/docs/api/sensor-color-sampling.md +31 -33
- package/docs/api/sensor-constant-rate-temporal-integration.md +10 -11
- package/docs/api/sensor-dark-current.md +30 -14
- package/docs/api/sensor-environment-photo-signal.md +13 -6
- package/docs/api/sensor-eqe-electron-rate.md +9 -8
- package/docs/api/sensor-eqe-local-exposure.md +18 -17
- package/docs/api/sensor-eqe-temporal-exposure.md +12 -11
- package/docs/api/sensor-exposure-window.md +24 -24
- package/docs/api/sensor-fixed-pattern-noise.md +104 -0
- package/docs/api/sensor-iso-gain.md +63 -0
- package/docs/api/sensor-iso-signal-chain.md +13 -22
- package/docs/api/sensor-local-exposure-binding.md +12 -13
- package/docs/api/sensor-optical-stack.md +37 -40
- package/docs/api/sensor-photon-energy.md +10 -11
- package/docs/api/sensor-physical-charge-capacity.md +8 -13
- package/docs/api/sensor-pixel-pitch.md +1 -1
- package/docs/api/sensor-radiometry-readiness.md +9 -9
- package/docs/api/sensor-raw-readout.md +118 -52
- package/docs/api/sensor-raw-reconstruction.md +97 -20
- package/docs/api/sensor-readout-exposure-linkage.md +120 -24
- package/docs/api/sensor-readout-timing.md +33 -35
- package/docs/api/sensor-response-application-compatibility.md +9 -11
- package/docs/api/sensor-response-operating-range.md +14 -18
- package/docs/api/sensor-responsivity-photocurrent.md +9 -12
- package/docs/api/sensor-sampling-aperture.md +22 -25
- package/docs/api/sensor-scene-eqe-temporal-exposure.md +9 -8
- package/docs/api/sensor-sensor-geometry.md +23 -24
- package/docs/api/sensor-signal-noise.md +10 -10
- package/docs/api/sensor-spatial-sample-reduction.md +27 -30
- package/docs/api/sensor-spatial-sampling-quadrature.md +37 -39
- package/docs/api/sensor-spatio-spectral-reduction.md +27 -29
- package/docs/api/sensor-spectral-coverage.md +5 -5
- package/docs/api/sensor-spectral-quadrature.md +33 -35
- package/docs/api/sensor-spectral-response.md +28 -16
- package/docs/api/sensor-temporal-photo-signal.md +6 -6
- package/docs/api/simulation-poc-simulation.md +17 -16
- package/docs/api/stabilization-camera-shake.md +29 -10
- package/docs/api/stabilization-system.md +25 -21
- package/docs/examples/production-request.json +3821 -2157
- package/docs/examples/simulate-capture.mjs +14 -0
- package/llms.txt +35 -0
- package/package.json +32 -12
- package/AGENTS.md +0 -674
- package/CONTRIBUTING.md +0 -76
- package/DCO +0 -33
- package/dist/camera/equivalent-focal-length.d.ts.map +0 -1
- package/dist/camera/field-of-view.d.ts.map +0 -1
- package/dist/camera/projected-object-size.d.ts.map +0 -1
- package/dist/capture/capture-export-metadata.d.ts.map +0 -1
- package/dist/capture/environment-raw-producer.d.ts.map +0 -1
- package/dist/capture/export-jpeg.d.ts.map +0 -1
- package/dist/capture/export-tiff.d.ts.map +0 -1
- package/dist/capture/focus-control.d.ts.map +0 -1
- package/dist/capture/linear-encoding.d.ts.map +0 -1
- package/dist/capture/native-environment-raw.d.ts.map +0 -1
- package/dist/capture/native-raw-development.d.ts.map +0 -1
- package/dist/capture/native-raw.d.ts.map +0 -1
- package/dist/capture/photographic-export.d.ts.map +0 -1
- package/dist/capture/raw-frame-limits.d.ts.map +0 -1
- package/dist/capture/raw-frame-reconstruction.d.ts.map +0 -1
- package/dist/capture/release-sequence.d.ts.map +0 -1
- package/dist/capture/sensor-raw-frame.d.ts.map +0 -1
- package/dist/capture/sensor-raw-producer.d.ts.map +0 -1
- package/dist/capture/simulated-capture.d.ts.map +0 -1
- package/dist/color/capture-color.d.ts.map +0 -1
- package/dist/color/sensor-color-development.d.ts.map +0 -1
- package/dist/color/srgb-icc.d.ts.map +0 -1
- package/dist/color/srgb-transfer.d.ts.map +0 -1
- package/dist/color/white-balance.d.ts.map +0 -1
- package/dist/composition/image-formation-plan.d.ts.map +0 -1
- package/dist/composition/plan-consumer.d.ts.map +0 -1
- package/dist/core/calculation-result.d.ts.map +0 -1
- package/dist/core/canonical-json.d.ts.map +0 -1
- package/dist/core/configuration-error.d.ts.map +0 -1
- package/dist/core/evidence-provenance.d.ts.map +0 -1
- package/dist/core/image-formation.d.ts.map +0 -1
- package/dist/core/owned-data.d.ts.map +0 -1
- package/dist/core/record-validation.d.ts.map +0 -1
- package/dist/core/scientific-assurance.d.ts.map +0 -1
- package/dist/core/spectral-composition.d.ts.map +0 -1
- package/dist/core/spectral.d.ts.map +0 -1
- package/dist/core/validation.d.ts.map +0 -1
- package/dist/core/version.d.ts.map +0 -1
- package/dist/equipment/exposure-capabilities.d.ts.map +0 -1
- package/dist/equipment/generic-tier-assets.d.ts.map +0 -1
- package/dist/equipment/generic-tier-presets.d.ts.map +0 -1
- package/dist/equipment/iso-capabilities.d.ts.map +0 -1
- package/dist/equipment/metering-capabilities.d.ts.map +0 -1
- package/dist/equipment/release-capabilities.d.ts.map +0 -1
- package/dist/exposure/exposure-duration-control.d.ts.map +0 -1
- package/dist/exposure/exposure-mode-resolver.d.ts.map +0 -1
- package/dist/exposure/exposure.d.ts.map +0 -1
- package/dist/exposure/flash.d.ts.map +0 -1
- package/dist/exposure/metering-scene-radiance.d.ts.map +0 -1
- package/dist/exposure/metering-target.d.ts.map +0 -1
- package/dist/exposure/metering-temporal.d.ts.map +0 -1
- package/dist/exposure/metering.d.ts.map +0 -1
- package/dist/exposure/program-line.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/motion/camera-rotation.d.ts.map +0 -1
- package/dist/motion/capture-rotation-inverse-mapping.d.ts.map +0 -1
- package/dist/motion/capture-rotation-temporal-quadrature.d.ts.map +0 -1
- package/dist/motion/capture-rotation-trajectory.d.ts.map +0 -1
- package/dist/motion/capture-translation-parallax-temporal-quadrature.d.ts.map +0 -1
- package/dist/motion/extended-object-projection.d.ts.map +0 -1
- package/dist/motion/projected-motion.d.ts.map +0 -1
- package/dist/optics/aperture.d.ts.map +0 -1
- package/dist/optics/circle-of-confusion.d.ts.map +0 -1
- package/dist/optics/complex-pupil-psf.d.ts.map +0 -1
- package/dist/optics/depth-of-field.d.ts.map +0 -1
- package/dist/optics/diffraction.d.ts.map +0 -1
- package/dist/optics/focus-breathing.d.ts.map +0 -1
- package/dist/optics/focus-state.d.ts.map +0 -1
- package/dist/optics/front-of-lens-filter.d.ts.map +0 -1
- package/dist/optics/illumination-vignetting.d.ts.map +0 -1
- package/dist/optics/lateral-chromatic-aberration.d.ts.map +0 -1
- package/dist/optics/lens-psf-profile.d.ts.map +0 -1
- package/dist/optics/polygon-diffraction.d.ts.map +0 -1
- package/dist/optics/profile-contract.d.ts.map +0 -1
- package/dist/optics/psf-foundation.d.ts.map +0 -1
- package/dist/optics/radial-distortion.d.ts.map +0 -1
- package/dist/optics/scene-to-sensor-irradiance.d.ts.map +0 -1
- package/dist/optics/scene-to-sensor-quadrature.d.ts.map +0 -1
- package/dist/optics/sensor-aperture-rays.d.ts.map +0 -1
- package/dist/optics/sensor-environment-query.d.ts.map +0 -1
- package/dist/optics/sensor-psf-quadrature.d.ts.map +0 -1
- package/dist/optics/sensor-psf-support.d.ts.map +0 -1
- package/dist/optics/stray-light.d.ts.map +0 -1
- package/dist/optics/thin-lens.d.ts.map +0 -1
- package/dist/output/capture-corrected-sdr.d.ts.map +0 -1
- package/dist/output/capture-geometry.d.ts.map +0 -1
- package/dist/output/capture-sdr.d.ts.map +0 -1
- package/dist/output/crop.d.ts.map +0 -1
- package/dist/output/geometric-transforms.d.ts.map +0 -1
- package/dist/output/lens-corrections.d.ts.map +0 -1
- package/dist/output/native-capture-sdr.d.ts.map +0 -1
- package/dist/output/print-contrast-reference.d.ts.map +0 -1
- package/dist/output/print-detail.d.ts.map +0 -1
- package/dist/output/print-jpeg.d.ts.map +0 -1
- package/dist/output/print-plan.d.ts.map +0 -1
- package/dist/output/print-region-statistics.d.ts.map +0 -1
- package/dist/output/sdr-rendering.d.ts.map +0 -1
- package/dist/output/subject-framing-crop.d.ts.map +0 -1
- package/dist/schema/camera.d.ts.map +0 -1
- package/dist/schema/camera.js +0 -3
- package/dist/schema/camera.js.map +0 -1
- package/dist/schema/illumination-spectral.d.ts.map +0 -1
- package/dist/schema/illumination-temporal.d.ts.map +0 -1
- package/dist/schema/illumination.d.ts.map +0 -1
- package/dist/schema/scene-radiance-temporal.d.ts.map +0 -1
- package/dist/schema/scene-radiance.d.ts.map +0 -1
- package/dist/schema/scene.d.ts.map +0 -1
- package/dist/schema/scene.js +0 -3
- package/dist/schema/scene.js.map +0 -1
- package/dist/schema/validation.d.ts.map +0 -1
- package/dist/sensor/accumulated-charge.d.ts.map +0 -1
- package/dist/sensor/architecture.d.ts.map +0 -1
- package/dist/sensor/camera-saturation-capacity.d.ts.map +0 -1
- package/dist/sensor/capture-color-sampling-binding.d.ts.map +0 -1
- package/dist/sensor/capture-mode-timing.d.ts.map +0 -1
- package/dist/sensor/capture-mode.d.ts.map +0 -1
- package/dist/sensor/color-sampling.d.ts.map +0 -1
- package/dist/sensor/constant-rate-temporal-integration.d.ts.map +0 -1
- package/dist/sensor/dark-current.d.ts.map +0 -1
- package/dist/sensor/environment-photo-signal.d.ts.map +0 -1
- package/dist/sensor/eqe-electron-rate.d.ts.map +0 -1
- package/dist/sensor/eqe-local-exposure.d.ts.map +0 -1
- package/dist/sensor/eqe-temporal-exposure.d.ts.map +0 -1
- package/dist/sensor/exposure-window.d.ts.map +0 -1
- package/dist/sensor/iso-signal-chain.d.ts.map +0 -1
- package/dist/sensor/local-exposure-binding.d.ts.map +0 -1
- package/dist/sensor/optical-stack.d.ts.map +0 -1
- package/dist/sensor/photon-energy.d.ts.map +0 -1
- package/dist/sensor/physical-charge-capacity.d.ts.map +0 -1
- package/dist/sensor/pixel-pitch.d.ts.map +0 -1
- package/dist/sensor/radiometry-readiness.d.ts.map +0 -1
- package/dist/sensor/raw-readout.d.ts.map +0 -1
- package/dist/sensor/raw-reconstruction.d.ts.map +0 -1
- package/dist/sensor/readout-exposure-linkage.d.ts.map +0 -1
- package/dist/sensor/readout-timing.d.ts.map +0 -1
- package/dist/sensor/response-application-compatibility.d.ts.map +0 -1
- package/dist/sensor/response-operating-range.d.ts.map +0 -1
- package/dist/sensor/responsivity-photocurrent.d.ts.map +0 -1
- package/dist/sensor/sampling-aperture.d.ts.map +0 -1
- package/dist/sensor/scene-eqe-temporal-exposure.d.ts.map +0 -1
- package/dist/sensor/sensor-geometry.d.ts.map +0 -1
- package/dist/sensor/signal-noise.d.ts.map +0 -1
- package/dist/sensor/spatial-sample-reduction.d.ts.map +0 -1
- package/dist/sensor/spatial-sampling-quadrature.d.ts.map +0 -1
- package/dist/sensor/spatio-spectral-reduction.d.ts.map +0 -1
- package/dist/sensor/spectral-coverage.d.ts.map +0 -1
- package/dist/sensor/spectral-quadrature.d.ts.map +0 -1
- package/dist/sensor/spectral-response.d.ts.map +0 -1
- package/dist/sensor/temporal-eqe-sum.d.ts.map +0 -1
- package/dist/sensor/temporal-photo-signal.d.ts.map +0 -1
- package/dist/sensor/temporal-sample-binding.d.ts.map +0 -1
- package/dist/simulation/poc-simulation.d.ts.map +0 -1
- package/dist/stabilization/camera-shake.d.ts.map +0 -1
- package/dist/stabilization/system.d.ts.map +0 -1
- package/docs/API_STYLE.md +0 -235
- package/docs/ARCHITECTURE.md +0 -356
- package/docs/AUTOMATION_COORDINATION.md +0 -190
- package/docs/CAPTURE_COLOR.md +0 -25
- package/docs/CAPTURE_CORRECTED_SDR.md +0 -25
- package/docs/CAPTURE_EXPORT_METADATA.md +0 -27
- package/docs/CAPTURE_SDR.md +0 -22
- package/docs/DEVELOPERS.md +0 -68
- package/docs/DIGITAL_OPTICS_FOUNDATION.md +0 -69
- package/docs/ENVIRONMENT_RAW_CAPTURE.md +0 -208
- package/docs/EXPORT_ACCEPTANCE.md +0 -133
- package/docs/GENERIC_TIER_PRESETS.md +0 -269
- package/docs/GEOMETRIC_PREPARATION_REUSE.md +0 -141
- package/docs/IMAGE_FORMATION.md +0 -247
- package/docs/LINEAR_CAPTURE_ENCODING.md +0 -25
- package/docs/MOTION_AND_SIGNAL.md +0 -250
- package/docs/NATIVE_CAPTURE_SDR.md +0 -70
- package/docs/NATIVE_CAPTURE_SDR_REVIEW.md +0 -37
- package/docs/NATIVE_CAPTURE_SDR_VALIDATION.md +0 -34
- package/docs/NATIVE_RAW_AND_PRINT.md +0 -47
- package/docs/NUMERICAL_CORRECTNESS.md +0 -191
- package/docs/PERFORMANCE_BASELINE.md +0 -56
- package/docs/PHOTOGRAPHIC_EXPORT.md +0 -206
- package/docs/PHYSICS_FOUNDATION.md +0 -426
- package/docs/POC_API.md +0 -278
- package/docs/POC_PROJECTION_PLATFORM_REFERENCE.md +0 -12
- package/docs/POC_PROJECTION_REUSE.md +0 -124
- package/docs/PRINT_195_196_REVIEW.md +0 -93
- package/docs/PRINT_196_ENGINE_ACCEPTANCE.md +0 -45
- package/docs/PRINT_CONTRAST_REFERENCE.md +0 -43
- package/docs/PRINT_DETAIL_ASSESSMENT.md +0 -81
- package/docs/PRINT_DETAIL_JPEG_EVIDENCE.md +0 -36
- package/docs/PRINT_DETAIL_SDR_EVIDENCE.md +0 -29
- package/docs/PRINT_DETAIL_VALIDATION.md +0 -36
- package/docs/PRINT_PLANNING.md +0 -75
- package/docs/PRINT_REGION_STATISTICS.md +0 -38
- package/docs/PROCESSED_OUTPUT.md +0 -157
- package/docs/PRODUCTION_COMPOSITION.md +0 -373
- package/docs/PRODUCTION_ENVIRONMENT_CAPTURE.md +0 -131
- package/docs/PROVENANCE.md +0 -115
- package/docs/PSF_FOUNDATION.md +0 -165
- package/docs/RAW_FRAME_ENVELOPE.md +0 -56
- package/docs/RAW_FRAME_RECONSTRUCTION.md +0 -30
- package/docs/RELEASE_1_0.md +0 -66
- package/docs/RELEASE_1_0_1.md +0 -61
- package/docs/RELEASE_1_1_0.md +0 -25
- package/docs/RELEASE_1_2_0.md +0 -51
- package/docs/RELEASE_1_3_0.md +0 -15
- package/docs/RELEASE_1_4_0.md +0 -23
- package/docs/RELEASE_AUDIT.md +0 -39
- package/docs/SCENE_RADIANCE_AND_ILLUMINATION.md +0 -298
- package/docs/SCENE_SENSOR_QUADRATURE.md +0 -98
- package/docs/SCENE_SENSOR_TEMPORAL_EXPOSURE.md +0 -86
- package/docs/SCIENTIFIC_ASSURANCE.md +0 -280
- package/docs/SCIENTIFIC_CONFORMANCE.md +0 -83
- package/docs/SDR_RENDERING.md +0 -33
- package/docs/SENSOR_APERTURE_RAYS.md +0 -23
- package/docs/SENSOR_ENVIRONMENT_QUERY.md +0 -86
- package/docs/SENSOR_EQE_LOCAL_EXPOSURE.md +0 -104
- package/docs/SENSOR_EQE_TEMPORAL_EXPOSURE.md +0 -74
- package/docs/SENSOR_PSF_QUADRATURE.md +0 -90
- package/docs/SENSOR_RAW_FRAME.md +0 -20
- package/docs/SENSOR_RAW_PRODUCER.md +0 -77
- package/docs/SIGNAL_CONFORMANCE.md +0 -23
- package/docs/SIMULATED_CAPTURE.md +0 -65
- package/docs/STABILIZATION.md +0 -234
- package/docs/TEMPORAL_PHOTO_RAW.md +0 -83
- package/docs/TIER_ACCEPTANCE.md +0 -129
- package/docs/TIER_PRESET_ACCEPTANCE.md +0 -59
- package/docs/V1_COMPOSITION_MAP.md +0 -123
- package/docs/V1_HELPER_REUSE_REVIEW.md +0 -60
- package/docs/V1_PERFORMANCE_DISPOSITION.md +0 -88
- package/docs/benchmarks/2026-10-01-main-baseline.json +0 -694
- package/docs/benchmarks/2026-10-02-geometric-preparation-reuse.json +0 -2190
- package/docs/benchmarks/2026-10-02-poc-projection-reuse.json +0 -2423
- package/docs/benchmarks/2026-10-02-v1-environment-gc-profile.json +0 -210
- package/docs/benchmarks/2026-10-02-v1-environment-ordinary.json +0 -187
- package/docs/benchmarks/2026-10-02-v1-geometry-gc-profile.json +0 -756
- package/docs/benchmarks/2026-10-02-v1-geometry-ordinary-1.json +0 -711
- package/docs/benchmarks/2026-10-02-v1-geometry-ordinary-2.json +0 -711
- package/docs/benchmarks/2026-10-02-v1-poc-gc-profile.json +0 -885
- package/docs/benchmarks/2026-10-02-v1-poc-ordinary-1.json +0 -868
- package/docs/benchmarks/2026-10-02-v1-poc-ordinary-2.json +0 -868
- package/docs/licenses/castleCSF-MIT.txt +0 -21
- package/docs/validation/documentation-fragments.json +0 -212
- package/docs/validation/native-capture-sdr-darwin-arm64-node26-review.jsonl +0 -4
- package/docs/validation/native-capture-sdr-darwin-arm64.jsonl +0 -3
- package/docs/validation/native-raw-print-2026-10-04/fractional-asymmetric-crop.jpg +0 -0
- package/docs/validation/native-raw-print-2026-10-04/gray-ramp.jpg +0 -0
- package/docs/validation/native-raw-print-2026-10-04/linear-area-checker.jpg +0 -0
- package/docs/validation/native-raw-print-2026-10-04/manifest.json +0 -218
- package/docs/validation/native-raw-print-2026-10-04/megapixel-native.jpg +0 -0
- package/docs/validation/native-raw-print-2026-10-04/native-color.jpg +0 -0
- package/docs/validation/native-raw-print-2026-10-04/photivra-native-full-megapixel-validation.json +0 -9
- package/docs/validation/native-raw-print-2026-10-04/photivra-native-full-megapixel.json +0 -29
- package/docs/validation/native-raw-print-2026-10-04/photivra-native-full-megapixel.json.codes.u16le.gz +0 -0
- package/docs/validation/native-raw-print-2026-10-04/photivra-native-full-megapixel.json.jpg +0 -0
- package/docs/validation/native-raw-print-2026-10-04/photivra-native-full-megapixel.json.rgb.gz +0 -0
- package/docs/validation/native-raw-print-2026-10-04/srgb.icc +0 -0
- package/docs/validation/native-raw-print-2026-10-04/validation.json +0 -41
- package/docs/validation/print-196-candidate-capabilities.json +0 -28
- package/docs/validation/print-196-candidate-evidence.json +0 -356
- package/docs/validation/print-196-engine-acceptance.json +0 -81
- package/docs/validation/print-detail-capabilities.json +0 -103
- package/docs/validation/print-detail-jpeg-evidence.json +0 -116
- package/docs/validation/print-detail-sdr-evidence.json +0 -81
- package/docs/validation/release-audit-inventory.json +0 -1306
- package/docs/validation/tier-acceptance-report-v1.json +0 -2538
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
/**
|
|
3
|
+
* The project's own WGSL (WebGPU shader language) compute kernels for the `webgpu-f32` image-kernel
|
|
4
|
+
* backend. Each kernel evaluates the same equations, in the same order, as its float64 CPU reference:
|
|
5
|
+
* - SDR: `calculateSdrRendering` / native capture SDR (exposure → tone → gamut → sRGB → nearest-ties-up);
|
|
6
|
+
* - RAW development: `createNativeRawDevelopmentTask` (CFA kernel sums → WB gains → camera→XYZ →
|
|
7
|
+
* XYZ→linear sRGB → SDR);
|
|
8
|
+
* - irradiance convolution: `convolveIrradianceRows` (source-indexed isoplanatic-patch gather).
|
|
9
|
+
* The host packers in image-kernel-accelerator.ts use matching uniform layouts.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Counter slots shared by the SDR-producing kernels. `linearBoundBits` holds the float32 bits of the
|
|
13
|
+
* largest per-sample linear bound of a luminance tone curve (a maximum, not a sum: non-negative float32
|
|
14
|
+
* bit patterns order like their values). `luminanceDomain` counts samples outside the float32 domain.
|
|
15
|
+
*/
|
|
16
|
+
export const SDR_COUNTER = Object.freeze({ negative: 0, above: 1, changed: 2, low: 3, high: 4, outOfGamut: 5, uncertain: 6, gamutUncertain: 7,
|
|
17
|
+
saturatedPixels: 8, whiteBalanceClipped: 9, reconstructedPixels: 10, linearBoundBits: 11, luminanceDomain: 12 });
|
|
18
|
+
export const SDR_COUNTER_SLOTS = 16;
|
|
19
|
+
/** Tone modes of the luminance kernels (`Params.tone_mode`); 0 is a per-channel curve. */
|
|
20
|
+
export const SDR_TONE_MODE = Object.freeze({ perChannel: 0, extendedReinhard: 1, nakaRushton: 2 });
|
|
21
|
+
export const LINEAR_WORKGROUP_SIZE = 256;
|
|
22
|
+
/** RAW_HIGHLIGHT_RECONSTRUCTION_START as a WGSL literal (rounded once to float32 by the compiler). */
|
|
23
|
+
const RAW_HIGHLIGHT_START_WGSL = "0.8";
|
|
24
|
+
export const CONVOLUTION_WORKGROUP_EDGE = 16;
|
|
25
|
+
/**
|
|
26
|
+
* Shared SDR sample renderer. `band0`/`band1` are absolute classification bands around 0 and 1 inside
|
|
27
|
+
* which the float32 decision may differ from float64; such samples increment the uncertainty counter.
|
|
28
|
+
* A zero result from a non-zero source (underflow) and tiny positive Reinhard inputs are also uncertain.
|
|
29
|
+
*/
|
|
30
|
+
const SDR_FUNCTIONS = /* wgsl */ `
|
|
31
|
+
var<workgroup> local_counters: array<atomic<u32>, ${SDR_COUNTER_SLOTS}>;
|
|
32
|
+
fn count(slot: u32) { atomicAdd(&local_counters[slot], 1u); }
|
|
33
|
+
fn encode_srgb(x: f32) -> f32 {
|
|
34
|
+
if (x == 1.0) { return 1.0; }
|
|
35
|
+
if (x <= 0.0031308) { return x * 12.92; }
|
|
36
|
+
return 1.055 * pow(x, 1.0 / 2.4) - 0.055;
|
|
37
|
+
}
|
|
38
|
+
fn render_sample(e: f32, source_nonzero: bool, band0: f32, band1: f32, reinhard: bool, reject: bool, maximum: f32) -> u32 {
|
|
39
|
+
// Gamut decisions (mapped < 0, mapped > 1) depend only on the sign band and, for identity tone, the band at 1.
|
|
40
|
+
var gamut_uncertain = (e == 0.0 && source_nonzero) || (!reinhard && abs(e - 1.0) <= band1);
|
|
41
|
+
if (band0 > 0.0 && abs(e) <= band0) { gamut_uncertain = true; }
|
|
42
|
+
var uncertain = gamut_uncertain || abs(e - 1.0) <= band1;
|
|
43
|
+
if (reinhard && e > 0.0 && e < 9.5367431640625e-7) { uncertain = true; }
|
|
44
|
+
if (uncertain) { count(${SDR_COUNTER.uncertain}u); }
|
|
45
|
+
if (gamut_uncertain) { count(${SDR_COUNTER.gamutUncertain}u); }
|
|
46
|
+
if (e < 0.0) { count(${SDR_COUNTER.negative}u); }
|
|
47
|
+
if (e > 1.0) { count(${SDR_COUNTER.above}u); }
|
|
48
|
+
var mapped = e;
|
|
49
|
+
if (reinhard && e > 0.0) { mapped = e / (1.0 + e); }
|
|
50
|
+
if (mapped != e) { count(${SDR_COUNTER.changed}u); }
|
|
51
|
+
var linear = mapped;
|
|
52
|
+
if (mapped < 0.0 || mapped > 1.0) {
|
|
53
|
+
if (reject) { count(${SDR_COUNTER.outOfGamut}u); }
|
|
54
|
+
else if (mapped < 0.0) { count(${SDR_COUNTER.low}u); linear = 0.0; }
|
|
55
|
+
else { count(${SDR_COUNTER.high}u); linear = 1.0; }
|
|
56
|
+
}
|
|
57
|
+
let code = floor(encode_srgb(linear) * maximum + 0.5);
|
|
58
|
+
return u32(clamp(code, 0.0, maximum));
|
|
59
|
+
}
|
|
60
|
+
fn clear_counters(local_index: u32) {
|
|
61
|
+
if (local_index < ${SDR_COUNTER_SLOTS}u) { atomicStore(&local_counters[local_index], 0u); }
|
|
62
|
+
workgroupBarrier();
|
|
63
|
+
}
|
|
64
|
+
fn flush_counters(local_index: u32) {
|
|
65
|
+
workgroupBarrier();
|
|
66
|
+
if (local_index < ${SDR_COUNTER_SLOTS}u) {
|
|
67
|
+
let value = atomicLoad(&local_counters[local_index]);
|
|
68
|
+
if (local_index == ${SDR_COUNTER.linearBoundBits}u) { atomicMax(&counters[local_index], value); }
|
|
69
|
+
else if (value > 0u) { atomicAdd(&counters[local_index], value); }
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
`;
|
|
73
|
+
/**
|
|
74
|
+
* Luminance tone curves (`prepareSdrPixelTone`): every component of a pixel is scaled by h(L) = f(L)/L,
|
|
75
|
+
* L = kr·r + kg·g + kb·b, when L > 0. The kernel evaluates h directly (algebraically equal to f(L)/L):
|
|
76
|
+
* - extended Reinhard: h = (1 + L/Lw²)/(1 + L);
|
|
77
|
+
* - Naka–Rushton: h = (1/g(Lw))/(L·(1 + (σ/L)ⁿ)), with P = (σ/L)ⁿ = exp2(n·log2(σ/L)) and, for P ≥ 1,
|
|
78
|
+
* the equal form (1/g(Lw))·P⁻¹/(L·(1 + P⁻¹)) so nothing overflows.
|
|
79
|
+
* Per sample it also evaluates an a-priori bound on |m_gpu − m_reference| from the inputs' bounds ε
|
|
80
|
+
* (see docs/WEBGPU.md, "Luminance tone curves"). The bound itself is evaluated in float32 and inflated.
|
|
81
|
+
* Uniform fields used: tone_mode, tone = (Reinhard: 1/Lw²; Naka–Rushton: σ, n, 1/g(Lw), σⁿ), lum = (kr, kg, kb, T).
|
|
82
|
+
*/
|
|
83
|
+
const LUMINANCE_FUNCTIONS = /* wgsl */ `
|
|
84
|
+
const LU: f32 = 5.9604644775390625e-8;
|
|
85
|
+
const ULP1: f32 = 1.1920928955078125e-7;
|
|
86
|
+
fn count_max(slot: u32, value: f32) { atomicMax(&local_counters[slot], bitcast<u32>(max(value, 0.0))); }
|
|
87
|
+
// (h, eta, abs_h): |h_gpu - h(l)| <= eta*h(l) + abs_h for the exact h at this float32 l > 0.
|
|
88
|
+
fn tone_h(l: f32) -> vec3<f32> {
|
|
89
|
+
if (params.tone_mode == ${SDR_TONE_MODE.extendedReinhard}u) {
|
|
90
|
+
return vec3<f32>((1.0 + l * params.tone.x) / (1.0 + l), 14.0 * LU, 0.0);
|
|
91
|
+
}
|
|
92
|
+
let lg = log2(params.tone.x / l);
|
|
93
|
+
let n = params.tone.y;
|
|
94
|
+
let z = n * lg;
|
|
95
|
+
// log2: 2^-21 absolute or 3 ULP; the sigma/l division and sigma's rounding; the product's rounding.
|
|
96
|
+
let dz = n * (4.76837158203125e-7 + 3.0 * ULP1 * abs(lg) + 9.0 * LU) + 2.0 * LU * abs(z);
|
|
97
|
+
// exp2: 3 + 2|z| ULP; plus slack for the float64 reference's pow.
|
|
98
|
+
let rho = 0.7 * dz * (1.0 + dz) + (3.0 + 2.0 * abs(z)) * ULP1 + 9.094947e-13 * (1.0 + abs(z));
|
|
99
|
+
let eta = 2.0 * rho + 16.0 * LU;
|
|
100
|
+
if (z >= 0.0) {
|
|
101
|
+
let p = exp2(-z);
|
|
102
|
+
var abs_h = 0.0;
|
|
103
|
+
// Below 2^-120 the power may have flushed to zero: bound h absolutely instead.
|
|
104
|
+
if (p < 7.52316384526264e-37) { abs_h = params.tone.z * 3.009265538105056e-36 / l; }
|
|
105
|
+
return vec3<f32>(params.tone.z * p / (l * (1.0 + p)), eta, abs_h);
|
|
106
|
+
}
|
|
107
|
+
let p = exp2(z);
|
|
108
|
+
return vec3<f32>(params.tone.z / (l * (1.0 + p)), eta, 0.0);
|
|
109
|
+
}
|
|
110
|
+
struct Toned { m: vec3<f32>, delta: vec3<f32>, changed_uncertain: bool };
|
|
111
|
+
fn luminance_tone(e: vec3<f32>, eps: vec3<f32>) -> Toned {
|
|
112
|
+
var t: Toned;
|
|
113
|
+
let ae = abs(e);
|
|
114
|
+
let ea = ae + eps;
|
|
115
|
+
let s = (params.lum.x * ae.x + params.lum.y * ae.y) + params.lum.z * ae.z;
|
|
116
|
+
let l = (params.lum.x * e.x + params.lum.y * e.y) + params.lum.z * e.z;
|
|
117
|
+
let lambda = (((params.lum.x * eps.x + params.lum.y * eps.y) + params.lum.z * eps.z) + 6.0 * LU * s) * 1.001;
|
|
118
|
+
if (l < -2.0 * lambda || (l == 0.0 && lambda == 0.0)) {
|
|
119
|
+
// L < 0 for the reference too: both keep the exposed values.
|
|
120
|
+
t.m = e; t.delta = eps; t.changed_uncertain = false;
|
|
121
|
+
return t;
|
|
122
|
+
}
|
|
123
|
+
if (l > 2.0 * lambda) {
|
|
124
|
+
let r = tone_h(l);
|
|
125
|
+
let q = lambda / l;
|
|
126
|
+
let f = exp2(params.lum.w * log2((1.0 + q) / (1.0 - q))) / (1.0 - q) * 1.01;
|
|
127
|
+
let fq = params.lum.w * f * q;
|
|
128
|
+
let hh = r.x * (1.0 + 2.0 * r.y) + r.z;
|
|
129
|
+
t.m = e * r.x;
|
|
130
|
+
t.delta = (eps * hh * (1.0 + fq) + ea * (hh * (r.y + fq) + r.z) + 2.0 * LU * abs(t.m)) * 1.001;
|
|
131
|
+
t.changed_uncertain = abs(r.x - 1.0) <= 2.0 * (r.y + fq) * max(1.0, r.x) + r.z + 4.0 * LU;
|
|
132
|
+
return t;
|
|
133
|
+
}
|
|
134
|
+
// |L| is inside its classification band: either branch may run, so bound both.
|
|
135
|
+
var hsup = max(1.0, params.tone.x);
|
|
136
|
+
if (params.tone_mode == ${SDR_TONE_MODE.nakaRushton}u) {
|
|
137
|
+
hsup = params.tone.z * exp2((params.tone.y - 1.0) * log2(3.0 * lambda)) / params.tone.w * 1.01;
|
|
138
|
+
}
|
|
139
|
+
var m = e;
|
|
140
|
+
if (l > 0.0) { m = e * tone_h(l).x; }
|
|
141
|
+
t.m = m;
|
|
142
|
+
t.delta = (2.0 * ea * (1.0 + hsup * (1.0 + 1e-3))) * 1.001;
|
|
143
|
+
t.changed_uncertain = true;
|
|
144
|
+
return t;
|
|
145
|
+
}
|
|
146
|
+
// Classification, gamut handling and encoding of one luminance-toned sample (e exposed, m toned).
|
|
147
|
+
fn render_toned(e: f32, source_nonzero: bool, band0: f32, band1: f32, m: f32, delta: f32, changed_uncertain: bool, reject: bool, maximum: f32) -> u32 {
|
|
148
|
+
var uncertain = (e == 0.0 && source_nonzero) || abs(e - 1.0) <= band1 || (band0 > 0.0 && abs(e) <= band0) || (changed_uncertain && e != 0.0);
|
|
149
|
+
// The reference value lies in [m - delta, m + delta]: uncertain only if that interval straddles a decision.
|
|
150
|
+
let gamut_uncertain = (m - delta < 0.0 && m + delta >= 0.0) || (m + delta > 1.0 && m - delta <= 1.0);
|
|
151
|
+
if (gamut_uncertain) { uncertain = true; count(${SDR_COUNTER.gamutUncertain}u); }
|
|
152
|
+
if (uncertain) { count(${SDR_COUNTER.uncertain}u); }
|
|
153
|
+
if (e < 0.0) { count(${SDR_COUNTER.negative}u); }
|
|
154
|
+
if (e > 1.0) { count(${SDR_COUNTER.above}u); }
|
|
155
|
+
if (m != e) { count(${SDR_COUNTER.changed}u); }
|
|
156
|
+
if (!(abs(m) + delta <= 1.2676506002282294e30)) { count(${SDR_COUNTER.luminanceDomain}u); }
|
|
157
|
+
var linear = m;
|
|
158
|
+
var bound = min(delta, 1.0);
|
|
159
|
+
if (m < 0.0 || m > 1.0) {
|
|
160
|
+
if (reject) { count(${SDR_COUNTER.outOfGamut}u); }
|
|
161
|
+
else if (m < 0.0) { count(${SDR_COUNTER.low}u); linear = 0.0; }
|
|
162
|
+
else { count(${SDR_COUNTER.high}u); linear = 1.0; }
|
|
163
|
+
}
|
|
164
|
+
// Clipping is 1-Lipschitz; when both values clip to the same end the difference is zero.
|
|
165
|
+
if (!reject && (m - delta >= 1.0 || m + delta <= 0.0)) { bound = 0.0; }
|
|
166
|
+
count_max(${SDR_COUNTER.linearBoundBits}u, bound);
|
|
167
|
+
let code = floor(encode_srgb(linear) * maximum + 0.5);
|
|
168
|
+
return u32(clamp(code, 0.0, maximum));
|
|
169
|
+
}
|
|
170
|
+
`;
|
|
171
|
+
/** Pointwise SDR over a packed float32 band; one invocation per sample. */
|
|
172
|
+
export const SDR_WGSL = /* wgsl */ `
|
|
173
|
+
struct Params { count: u32, reinhard: u32, reject: u32, pad0: u32, scale: f32, maximum: f32, band1: f32, pad1: f32 };
|
|
174
|
+
@group(0) @binding(0) var<uniform> params: Params;
|
|
175
|
+
@group(0) @binding(1) var<storage, read> source: array<f32>;
|
|
176
|
+
@group(0) @binding(2) var<storage, read_write> codes: array<u32>;
|
|
177
|
+
@group(0) @binding(3) var<storage, read_write> counters: array<atomic<u32>, ${SDR_COUNTER_SLOTS}>;
|
|
178
|
+
${SDR_FUNCTIONS}
|
|
179
|
+
@compute @workgroup_size(${LINEAR_WORKGROUP_SIZE})
|
|
180
|
+
fn main(@builtin(global_invocation_id) gid: vec3<u32>, @builtin(local_invocation_index) local_index: u32,
|
|
181
|
+
@builtin(num_workgroups) groups: vec3<u32>) {
|
|
182
|
+
clear_counters(local_index);
|
|
183
|
+
let i = gid.x + gid.y * groups.x * ${LINEAR_WORKGROUP_SIZE}u;
|
|
184
|
+
if (i < params.count) {
|
|
185
|
+
let s = source[i];
|
|
186
|
+
codes[i] = render_sample(s * params.scale, s != 0.0, 0.0, params.band1, params.reinhard != 0u, params.reject != 0u, params.maximum);
|
|
187
|
+
}
|
|
188
|
+
flush_counters(local_index);
|
|
189
|
+
}
|
|
190
|
+
`;
|
|
191
|
+
/** Pointwise SDR with a luminance tone curve over a packed float32 band; one invocation per pixel. */
|
|
192
|
+
export const SDR_LUMINANCE_WGSL = /* wgsl */ `
|
|
193
|
+
struct Params { pixels: u32, reject: u32, tone_mode: u32, pad0: u32, scale: f32, maximum: f32, band1: f32, pad1: f32,
|
|
194
|
+
tone: vec4<f32>, lum: vec4<f32> };
|
|
195
|
+
@group(0) @binding(0) var<uniform> params: Params;
|
|
196
|
+
@group(0) @binding(1) var<storage, read> source: array<f32>;
|
|
197
|
+
@group(0) @binding(2) var<storage, read_write> codes: array<u32>;
|
|
198
|
+
@group(0) @binding(3) var<storage, read_write> counters: array<atomic<u32>, ${SDR_COUNTER_SLOTS}>;
|
|
199
|
+
${SDR_FUNCTIONS}
|
|
200
|
+
${LUMINANCE_FUNCTIONS}
|
|
201
|
+
@compute @workgroup_size(${LINEAR_WORKGROUP_SIZE})
|
|
202
|
+
fn main(@builtin(global_invocation_id) gid: vec3<u32>, @builtin(local_invocation_index) local_index: u32,
|
|
203
|
+
@builtin(num_workgroups) groups: vec3<u32>) {
|
|
204
|
+
clear_counters(local_index);
|
|
205
|
+
let i = gid.x + gid.y * groups.x * ${LINEAR_WORKGROUP_SIZE}u;
|
|
206
|
+
if (i < params.pixels) {
|
|
207
|
+
let s = vec3<f32>(source[i * 3u], source[i * 3u + 1u], source[i * 3u + 2u]);
|
|
208
|
+
let e = s * params.scale;
|
|
209
|
+
// Source, scale and product roundings (plus the reference's own), and an absolute term where a non-zero source may underflow.
|
|
210
|
+
var eps = 4.0 * LU * abs(e);
|
|
211
|
+
for (var j = 0u; j < 3u; j++) {
|
|
212
|
+
if (s[j] != 0.0 && abs(e[j]) < 7.888609052210118e-31) { eps[j] = eps[j] + 2.350988701644575e-38 * max(1.0, params.scale); }
|
|
213
|
+
}
|
|
214
|
+
let t = luminance_tone(e, eps);
|
|
215
|
+
let reject = params.reject != 0u;
|
|
216
|
+
for (var j = 0u; j < 3u; j++) {
|
|
217
|
+
codes[i * 3u + j] = render_toned(e[j], s[j] != 0.0, 0.0, params.band1, t.m[j], t.delta[j], t.changed_uncertain, reject, params.maximum);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
flush_counters(local_index);
|
|
221
|
+
}
|
|
222
|
+
`;
|
|
223
|
+
/**
|
|
224
|
+
* Packed native RAW development of one band of output rows; one invocation per output pixel.
|
|
225
|
+
* `normalized` holds the host's float64 site values, rounded once to float32. A saturated site
|
|
226
|
+
* (flagged, or at or above its phase white level) is exactly 1. Any other site is
|
|
227
|
+
* (code − black)/(white − black) ≤ 1 − 1/65535. So a saturated contributing site is recognised exactly.
|
|
228
|
+
* Highlight handling matches `prepareSensorColorDevelopment` (clip at the smallest applied gain, or the
|
|
229
|
+
* declared neutral blend).
|
|
230
|
+
*/
|
|
231
|
+
export const RAW_DEVELOPMENT_WGSL = /* wgsl */ `
|
|
232
|
+
struct Params {
|
|
233
|
+
width: u32, count: u32, row0: u32, reinhard: u32,
|
|
234
|
+
reject: u32, repeat_w: u32, repeat_h: u32, region_w: u32,
|
|
235
|
+
origin_x: i32, origin_y: i32, axx: i32, axy: i32,
|
|
236
|
+
ayx: i32, ayy: i32, region_x: i32, region_y: i32,
|
|
237
|
+
scale: f32, maximum: f32, band0: f32, band1: f32,
|
|
238
|
+
clip_level: f32, reconstruct: u32, band_u: f32, band_s: f32,
|
|
239
|
+
gains: vec4<f32>,
|
|
240
|
+
m0: vec4<f32>, m1: vec4<f32>, m2: vec4<f32>,
|
|
241
|
+
x0: vec4<f32>, x1: vec4<f32>, x2: vec4<f32>,
|
|
242
|
+
tone_mode: u32, pad0: u32, pad1: u32, pad2: u32,
|
|
243
|
+
tone: vec4<f32>, lum: vec4<f32>,
|
|
244
|
+
};
|
|
245
|
+
struct Tap { ox: i32, oy: i32, w: f32, pad: f32 };
|
|
246
|
+
@group(0) @binding(0) var<uniform> params: Params;
|
|
247
|
+
@group(0) @binding(1) var<storage, read> normalized: array<f32>;
|
|
248
|
+
@group(0) @binding(2) var<storage, read> taps: array<Tap>;
|
|
249
|
+
@group(0) @binding(3) var<storage, read> phases: array<vec2<u32>>;
|
|
250
|
+
@group(0) @binding(4) var<storage, read_write> codes: array<u32>;
|
|
251
|
+
@group(0) @binding(5) var<storage, read_write> counters: array<atomic<u32>, ${SDR_COUNTER_SLOTS}>;
|
|
252
|
+
${SDR_FUNCTIONS}
|
|
253
|
+
${LUMINANCE_FUNCTIONS}
|
|
254
|
+
var<private> saturated: bool;
|
|
255
|
+
fn channel(phase: u32, c: u32, nx: i32, ny: i32) -> f32 {
|
|
256
|
+
let range = phases[phase * 3u + c];
|
|
257
|
+
var value = 0.0;
|
|
258
|
+
for (var k = 0u; k < range.y; k++) {
|
|
259
|
+
let t = taps[range.x + k];
|
|
260
|
+
let sx = nx + t.ox - params.region_x;
|
|
261
|
+
let sy = ny + t.oy - params.region_y;
|
|
262
|
+
let site = normalized[u32(sy) * params.region_w + u32(sx)];
|
|
263
|
+
if (site == 1.0) { saturated = true; }
|
|
264
|
+
value = value + site * t.w;
|
|
265
|
+
}
|
|
266
|
+
return value;
|
|
267
|
+
}
|
|
268
|
+
fn row3(m: vec4<f32>, v: vec3<f32>) -> f32 { return ((0.0 + m.x * v.x) + m.y * v.y) + m.z * v.z; }
|
|
269
|
+
fn max3(v: vec3<f32>) -> f32 {
|
|
270
|
+
if (v.x > v.y) { if (v.x > v.z) { return v.x; } return v.z; }
|
|
271
|
+
if (v.y > v.z) { return v.y; }
|
|
272
|
+
return v.z;
|
|
273
|
+
}
|
|
274
|
+
@compute @workgroup_size(${LINEAR_WORKGROUP_SIZE})
|
|
275
|
+
fn main(@builtin(global_invocation_id) gid: vec3<u32>, @builtin(local_invocation_index) local_index: u32,
|
|
276
|
+
@builtin(num_workgroups) groups: vec3<u32>) {
|
|
277
|
+
clear_counters(local_index);
|
|
278
|
+
let i = gid.x + gid.y * groups.x * ${LINEAR_WORKGROUP_SIZE}u;
|
|
279
|
+
if (i < params.count) {
|
|
280
|
+
let col = i32(i % params.width);
|
|
281
|
+
let row = i32(params.row0 + i / params.width);
|
|
282
|
+
let nx = params.origin_x + params.axx * col + params.axy * row;
|
|
283
|
+
let ny = params.origin_y + params.ayx * col + params.ayy * row;
|
|
284
|
+
let phase = (u32(ny) % params.repeat_h) * params.repeat_w + u32(nx) % params.repeat_w;
|
|
285
|
+
saturated = false;
|
|
286
|
+
let c = vec3<f32>(channel(phase, 0u, nx, ny), channel(phase, 1u, nx, ny), channel(phase, 2u, nx, ny));
|
|
287
|
+
if (saturated) { count(${SDR_COUNTER.saturatedPixels}u); }
|
|
288
|
+
let u = vec3<f32>(c.x * params.gains.x, c.y * params.gains.y, c.z * params.gains.z);
|
|
289
|
+
let clip = params.clip_level;
|
|
290
|
+
let k = vec3<f32>(select(u.x, clip, u.x > clip), select(u.y, clip, u.y > clip), select(u.z, clip, u.z > clip));
|
|
291
|
+
var b = k;
|
|
292
|
+
if (params.reconstruct == 0u) {
|
|
293
|
+
for (var j = 0u; j < 3u; j++) {
|
|
294
|
+
if (u[j] > clip) { count(${SDR_COUNTER.whiteBalanceClipped}u); }
|
|
295
|
+
if (abs(u[j] - clip) <= params.band_u) { count(${SDR_COUNTER.uncertain}u); }
|
|
296
|
+
}
|
|
297
|
+
} else {
|
|
298
|
+
let s = max3(c);
|
|
299
|
+
if (abs(s - ${RAW_HIGHLIGHT_START_WGSL}) <= params.band_s) { count(${SDR_COUNTER.uncertain}u); }
|
|
300
|
+
if (s > ${RAW_HIGHLIGHT_START_WGSL}) {
|
|
301
|
+
var t = 1.0;
|
|
302
|
+
if (s < 1.0) { t = (s - ${RAW_HIGHLIGHT_START_WGSL}) / (1.0 - ${RAW_HIGHLIGHT_START_WGSL}); }
|
|
303
|
+
let n = max3(k);
|
|
304
|
+
b = (1.0 - t) * u + t * vec3<f32>(n, n, n);
|
|
305
|
+
count(${SDR_COUNTER.reconstructedPixels}u);
|
|
306
|
+
} else {
|
|
307
|
+
b = u;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
let xyz = vec3<f32>(row3(params.m0, b), row3(params.m1, b), row3(params.m2, b));
|
|
311
|
+
let rgb = vec3<f32>(row3(params.x0, xyz), row3(params.x1, xyz), row3(params.x2, xyz));
|
|
312
|
+
let reinhard = params.reinhard != 0u;
|
|
313
|
+
let reject = params.reject != 0u;
|
|
314
|
+
if (params.tone_mode == ${SDR_TONE_MODE.perChannel}u) {
|
|
315
|
+
for (var j = 0u; j < 3u; j++) {
|
|
316
|
+
codes[i * 3u + j] = render_sample(rgb[j] * params.scale, false, params.band0, params.band1, reinhard, reject, params.maximum);
|
|
317
|
+
}
|
|
318
|
+
} else {
|
|
319
|
+
// band0 bounds each exposed value against the reference (the development chain's a-priori bound).
|
|
320
|
+
let e = rgb * params.scale;
|
|
321
|
+
let t = luminance_tone(e, vec3<f32>(params.band0, params.band0, params.band0));
|
|
322
|
+
for (var j = 0u; j < 3u; j++) {
|
|
323
|
+
codes[i * 3u + j] = render_toned(e[j], false, params.band0, params.band1, t.m[j], t.delta[j], t.changed_uncertain, reject, params.maximum);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
flush_counters(local_index);
|
|
328
|
+
}
|
|
329
|
+
`;
|
|
330
|
+
/** Source-indexed isoplanatic-patch convolution of one output-row band; one invocation per output site. */
|
|
331
|
+
export const IRRADIANCE_CONVOLUTION_WGSL = /* wgsl */ `
|
|
332
|
+
struct Params {
|
|
333
|
+
width: u32, height: u32, radius: u32, size: u32,
|
|
334
|
+
patch_w: u32, patch_h: u32, cols: u32, rows: u32,
|
|
335
|
+
out_row0: u32, out_rows: u32, in_row0: u32, taps: u32,
|
|
336
|
+
};
|
|
337
|
+
@group(0) @binding(0) var<uniform> params: Params;
|
|
338
|
+
@group(0) @binding(1) var<storage, read> source: array<f32>;
|
|
339
|
+
@group(0) @binding(2) var<storage, read> kernels: array<f32>;
|
|
340
|
+
@group(0) @binding(3) var<storage, read_write> result: array<f32>;
|
|
341
|
+
@compute @workgroup_size(${CONVOLUTION_WORKGROUP_EDGE}, ${CONVOLUTION_WORKGROUP_EDGE})
|
|
342
|
+
fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
|
|
343
|
+
let x = gid.x;
|
|
344
|
+
let local_y = gid.y;
|
|
345
|
+
if (x >= params.width || local_y >= params.out_rows) { return; }
|
|
346
|
+
let y = i32(params.out_row0 + local_y);
|
|
347
|
+
let r = i32(params.radius);
|
|
348
|
+
var sum = 0.0;
|
|
349
|
+
for (var v = -r; v <= r; v++) {
|
|
350
|
+
let sy = y - v;
|
|
351
|
+
if (sy < 0 || sy >= i32(params.height)) { continue; }
|
|
352
|
+
let patch_row = min(u32(sy) / params.patch_h, params.rows - 1u) * params.cols;
|
|
353
|
+
let kernel_row = (v + r) * i32(params.size) + r;
|
|
354
|
+
let source_row = (u32(sy) - params.in_row0) * params.width;
|
|
355
|
+
for (var u = -r; u <= r; u++) {
|
|
356
|
+
let sx = i32(x) - u;
|
|
357
|
+
if (sx < 0 || sx >= i32(params.width)) { continue; }
|
|
358
|
+
let patch_index = patch_row + min(u32(sx) / params.patch_w, params.cols - 1u);
|
|
359
|
+
sum = sum + source[source_row + u32(sx)] * kernels[patch_index * params.taps + u32(kernel_row + u)];
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
result[local_y * params.width + x] = sum;
|
|
363
|
+
}
|
|
364
|
+
`;
|
|
365
|
+
//# sourceMappingURL=wgsl-kernels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wgsl-kernels.js","sourceRoot":"","sources":["../../src/gpu/wgsl-kernels.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;;;;GAQG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC;IAC3I,eAAe,EAAE,CAAC,EAAE,mBAAmB,EAAE,CAAC,EAAE,mBAAmB,EAAE,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC,CAAC;AACnH,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AACpC,0FAA0F;AAC1F,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,gBAAgB,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC,CAAC;AACnG,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AACzC,sGAAsG;AACtG,MAAM,wBAAwB,GAAG,KAAK,CAAC;AACvC,MAAM,CAAC,MAAM,0BAA0B,GAAG,EAAE,CAAC;AAE7C;;;;GAIG;AACH,MAAM,aAAa,GAAG,UAAU,CAAC;oDACmB,iBAAiB;;;;;;;;;;;;;2BAa1C,WAAW,CAAC,SAAS;iCACf,WAAW,CAAC,cAAc;yBAClC,WAAW,CAAC,QAAQ;yBACpB,WAAW,CAAC,KAAK;;;6BAGb,WAAW,CAAC,OAAO;;;0BAGtB,WAAW,CAAC,UAAU;qCACX,WAAW,CAAC,GAAG;mBACjC,WAAW,CAAC,IAAI;;;;;;sBAMb,iBAAiB;;;;;sBAKjB,iBAAiB;;yBAEd,WAAW,CAAC,eAAe;;;;CAInD,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,mBAAmB,GAAG,UAAU,CAAC;;;;;;4BAMX,aAAa,CAAC,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BA+C9B,aAAa,CAAC,WAAW;;;;;;;;;;;;;;;mDAeF,WAAW,CAAC,cAAc;2BAClD,WAAW,CAAC,SAAS;yBACvB,WAAW,CAAC,QAAQ;yBACpB,WAAW,CAAC,KAAK;wBAClB,WAAW,CAAC,OAAO;4DACiB,WAAW,CAAC,eAAe;;;;0BAI7D,WAAW,CAAC,UAAU;gCAChB,WAAW,CAAC,GAAG;mBAC5B,WAAW,CAAC,IAAI;;;;cAIrB,WAAW,CAAC,eAAe;;;;CAIxC,CAAC;AAEF,2EAA2E;AAC3E,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAC;;;;;8EAK2C,iBAAiB;EAC7F,aAAa;2BACY,qBAAqB;;;;uCAIT,qBAAqB;;;;;;;CAO3D,CAAC;AAEF,sGAAsG;AACtG,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;;;;;;8EAMiC,iBAAiB;EAC7F,aAAa;EACb,mBAAmB;2BACM,qBAAqB;;;;uCAIT,qBAAqB;;;;;;;;;;;;;;;;;CAiB3D,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;8EAoB+B,iBAAiB;EAC7F,aAAa;EACb,mBAAmB;;;;;;;;;;;;;;;;;;;;;2BAqBM,qBAAqB;;;;uCAIT,qBAAqB;;;;;;;;;6BAS/B,WAAW,CAAC,eAAe;;;;;;;mCAOrB,WAAW,CAAC,mBAAmB;yDACT,WAAW,CAAC,SAAS;;;;oBAI1D,wBAAwB,+BAA+B,WAAW,CAAC,SAAS;gBAChF,wBAAwB;;kCAEN,wBAAwB,cAAc,wBAAwB;;;gBAGhF,WAAW,CAAC,mBAAmB;;;;;;;;;8BASjB,aAAa,CAAC,UAAU;;;;;;;;;;;;;;;CAerD,CAAC;AAEF,2GAA2G;AAC3G,MAAM,CAAC,MAAM,2BAA2B,GAAG,UAAU,CAAC;;;;;;;;;;2BAU3B,0BAA0B,KAAK,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;CAuBnF,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * The project's own WGSL (WebGPU shader language) compute kernels for the `webgpu-f32` image-kernel\n * backend. Each kernel evaluates the same equations, in the same order, as its float64 CPU reference:\n * - SDR: `calculateSdrRendering` / native capture SDR (exposure → tone → gamut → sRGB → nearest-ties-up);\n * - RAW development: `createNativeRawDevelopmentTask` (CFA kernel sums → WB gains → camera→XYZ →\n * XYZ→linear sRGB → SDR);\n * - irradiance convolution: `convolveIrradianceRows` (source-indexed isoplanatic-patch gather).\n * The host packers in image-kernel-accelerator.ts use matching uniform layouts.\n */\n\n/**\n * Counter slots shared by the SDR-producing kernels. `linearBoundBits` holds the float32 bits of the\n * largest per-sample linear bound of a luminance tone curve (a maximum, not a sum: non-negative float32\n * bit patterns order like their values). `luminanceDomain` counts samples outside the float32 domain.\n */\nexport const SDR_COUNTER = Object.freeze({ negative: 0, above: 1, changed: 2, low: 3, high: 4, outOfGamut: 5, uncertain: 6, gamutUncertain: 7,\n saturatedPixels: 8, whiteBalanceClipped: 9, reconstructedPixels: 10, linearBoundBits: 11, luminanceDomain: 12 });\nexport const SDR_COUNTER_SLOTS = 16;\n/** Tone modes of the luminance kernels (`Params.tone_mode`); 0 is a per-channel curve. */\nexport const SDR_TONE_MODE = Object.freeze({ perChannel: 0, extendedReinhard: 1, nakaRushton: 2 });\nexport const LINEAR_WORKGROUP_SIZE = 256;\n/** RAW_HIGHLIGHT_RECONSTRUCTION_START as a WGSL literal (rounded once to float32 by the compiler). */\nconst RAW_HIGHLIGHT_START_WGSL = \"0.8\";\nexport const CONVOLUTION_WORKGROUP_EDGE = 16;\n\n/**\n * Shared SDR sample renderer. `band0`/`band1` are absolute classification bands around 0 and 1 inside\n * which the float32 decision may differ from float64; such samples increment the uncertainty counter.\n * A zero result from a non-zero source (underflow) and tiny positive Reinhard inputs are also uncertain.\n */\nconst SDR_FUNCTIONS = /* wgsl */ `\nvar<workgroup> local_counters: array<atomic<u32>, ${SDR_COUNTER_SLOTS}>;\nfn count(slot: u32) { atomicAdd(&local_counters[slot], 1u); }\nfn encode_srgb(x: f32) -> f32 {\n if (x == 1.0) { return 1.0; }\n if (x <= 0.0031308) { return x * 12.92; }\n return 1.055 * pow(x, 1.0 / 2.4) - 0.055;\n}\nfn render_sample(e: f32, source_nonzero: bool, band0: f32, band1: f32, reinhard: bool, reject: bool, maximum: f32) -> u32 {\n // Gamut decisions (mapped < 0, mapped > 1) depend only on the sign band and, for identity tone, the band at 1.\n var gamut_uncertain = (e == 0.0 && source_nonzero) || (!reinhard && abs(e - 1.0) <= band1);\n if (band0 > 0.0 && abs(e) <= band0) { gamut_uncertain = true; }\n var uncertain = gamut_uncertain || abs(e - 1.0) <= band1;\n if (reinhard && e > 0.0 && e < 9.5367431640625e-7) { uncertain = true; }\n if (uncertain) { count(${SDR_COUNTER.uncertain}u); }\n if (gamut_uncertain) { count(${SDR_COUNTER.gamutUncertain}u); }\n if (e < 0.0) { count(${SDR_COUNTER.negative}u); }\n if (e > 1.0) { count(${SDR_COUNTER.above}u); }\n var mapped = e;\n if (reinhard && e > 0.0) { mapped = e / (1.0 + e); }\n if (mapped != e) { count(${SDR_COUNTER.changed}u); }\n var linear = mapped;\n if (mapped < 0.0 || mapped > 1.0) {\n if (reject) { count(${SDR_COUNTER.outOfGamut}u); }\n else if (mapped < 0.0) { count(${SDR_COUNTER.low}u); linear = 0.0; }\n else { count(${SDR_COUNTER.high}u); linear = 1.0; }\n }\n let code = floor(encode_srgb(linear) * maximum + 0.5);\n return u32(clamp(code, 0.0, maximum));\n}\nfn clear_counters(local_index: u32) {\n if (local_index < ${SDR_COUNTER_SLOTS}u) { atomicStore(&local_counters[local_index], 0u); }\n workgroupBarrier();\n}\nfn flush_counters(local_index: u32) {\n workgroupBarrier();\n if (local_index < ${SDR_COUNTER_SLOTS}u) {\n let value = atomicLoad(&local_counters[local_index]);\n if (local_index == ${SDR_COUNTER.linearBoundBits}u) { atomicMax(&counters[local_index], value); }\n else if (value > 0u) { atomicAdd(&counters[local_index], value); }\n }\n}\n`;\n\n/**\n * Luminance tone curves (`prepareSdrPixelTone`): every component of a pixel is scaled by h(L) = f(L)/L,\n * L = kr·r + kg·g + kb·b, when L > 0. The kernel evaluates h directly (algebraically equal to f(L)/L):\n * - extended Reinhard: h = (1 + L/Lw²)/(1 + L);\n * - Naka–Rushton: h = (1/g(Lw))/(L·(1 + (σ/L)ⁿ)), with P = (σ/L)ⁿ = exp2(n·log2(σ/L)) and, for P ≥ 1,\n * the equal form (1/g(Lw))·P⁻¹/(L·(1 + P⁻¹)) so nothing overflows.\n * Per sample it also evaluates an a-priori bound on |m_gpu − m_reference| from the inputs' bounds ε\n * (see docs/WEBGPU.md, \"Luminance tone curves\"). The bound itself is evaluated in float32 and inflated.\n * Uniform fields used: tone_mode, tone = (Reinhard: 1/Lw²; Naka–Rushton: σ, n, 1/g(Lw), σⁿ), lum = (kr, kg, kb, T).\n */\nconst LUMINANCE_FUNCTIONS = /* wgsl */ `\nconst LU: f32 = 5.9604644775390625e-8;\nconst ULP1: f32 = 1.1920928955078125e-7;\nfn count_max(slot: u32, value: f32) { atomicMax(&local_counters[slot], bitcast<u32>(max(value, 0.0))); }\n// (h, eta, abs_h): |h_gpu - h(l)| <= eta*h(l) + abs_h for the exact h at this float32 l > 0.\nfn tone_h(l: f32) -> vec3<f32> {\n if (params.tone_mode == ${SDR_TONE_MODE.extendedReinhard}u) {\n return vec3<f32>((1.0 + l * params.tone.x) / (1.0 + l), 14.0 * LU, 0.0);\n }\n let lg = log2(params.tone.x / l);\n let n = params.tone.y;\n let z = n * lg;\n // log2: 2^-21 absolute or 3 ULP; the sigma/l division and sigma's rounding; the product's rounding.\n let dz = n * (4.76837158203125e-7 + 3.0 * ULP1 * abs(lg) + 9.0 * LU) + 2.0 * LU * abs(z);\n // exp2: 3 + 2|z| ULP; plus slack for the float64 reference's pow.\n let rho = 0.7 * dz * (1.0 + dz) + (3.0 + 2.0 * abs(z)) * ULP1 + 9.094947e-13 * (1.0 + abs(z));\n let eta = 2.0 * rho + 16.0 * LU;\n if (z >= 0.0) {\n let p = exp2(-z);\n var abs_h = 0.0;\n // Below 2^-120 the power may have flushed to zero: bound h absolutely instead.\n if (p < 7.52316384526264e-37) { abs_h = params.tone.z * 3.009265538105056e-36 / l; }\n return vec3<f32>(params.tone.z * p / (l * (1.0 + p)), eta, abs_h);\n }\n let p = exp2(z);\n return vec3<f32>(params.tone.z / (l * (1.0 + p)), eta, 0.0);\n}\nstruct Toned { m: vec3<f32>, delta: vec3<f32>, changed_uncertain: bool };\nfn luminance_tone(e: vec3<f32>, eps: vec3<f32>) -> Toned {\n var t: Toned;\n let ae = abs(e);\n let ea = ae + eps;\n let s = (params.lum.x * ae.x + params.lum.y * ae.y) + params.lum.z * ae.z;\n let l = (params.lum.x * e.x + params.lum.y * e.y) + params.lum.z * e.z;\n let lambda = (((params.lum.x * eps.x + params.lum.y * eps.y) + params.lum.z * eps.z) + 6.0 * LU * s) * 1.001;\n if (l < -2.0 * lambda || (l == 0.0 && lambda == 0.0)) {\n // L < 0 for the reference too: both keep the exposed values.\n t.m = e; t.delta = eps; t.changed_uncertain = false;\n return t;\n }\n if (l > 2.0 * lambda) {\n let r = tone_h(l);\n let q = lambda / l;\n let f = exp2(params.lum.w * log2((1.0 + q) / (1.0 - q))) / (1.0 - q) * 1.01;\n let fq = params.lum.w * f * q;\n let hh = r.x * (1.0 + 2.0 * r.y) + r.z;\n t.m = e * r.x;\n t.delta = (eps * hh * (1.0 + fq) + ea * (hh * (r.y + fq) + r.z) + 2.0 * LU * abs(t.m)) * 1.001;\n t.changed_uncertain = abs(r.x - 1.0) <= 2.0 * (r.y + fq) * max(1.0, r.x) + r.z + 4.0 * LU;\n return t;\n }\n // |L| is inside its classification band: either branch may run, so bound both.\n var hsup = max(1.0, params.tone.x);\n if (params.tone_mode == ${SDR_TONE_MODE.nakaRushton}u) {\n hsup = params.tone.z * exp2((params.tone.y - 1.0) * log2(3.0 * lambda)) / params.tone.w * 1.01;\n }\n var m = e;\n if (l > 0.0) { m = e * tone_h(l).x; }\n t.m = m;\n t.delta = (2.0 * ea * (1.0 + hsup * (1.0 + 1e-3))) * 1.001;\n t.changed_uncertain = true;\n return t;\n}\n// Classification, gamut handling and encoding of one luminance-toned sample (e exposed, m toned).\nfn render_toned(e: f32, source_nonzero: bool, band0: f32, band1: f32, m: f32, delta: f32, changed_uncertain: bool, reject: bool, maximum: f32) -> u32 {\n var uncertain = (e == 0.0 && source_nonzero) || abs(e - 1.0) <= band1 || (band0 > 0.0 && abs(e) <= band0) || (changed_uncertain && e != 0.0);\n // The reference value lies in [m - delta, m + delta]: uncertain only if that interval straddles a decision.\n let gamut_uncertain = (m - delta < 0.0 && m + delta >= 0.0) || (m + delta > 1.0 && m - delta <= 1.0);\n if (gamut_uncertain) { uncertain = true; count(${SDR_COUNTER.gamutUncertain}u); }\n if (uncertain) { count(${SDR_COUNTER.uncertain}u); }\n if (e < 0.0) { count(${SDR_COUNTER.negative}u); }\n if (e > 1.0) { count(${SDR_COUNTER.above}u); }\n if (m != e) { count(${SDR_COUNTER.changed}u); }\n if (!(abs(m) + delta <= 1.2676506002282294e30)) { count(${SDR_COUNTER.luminanceDomain}u); }\n var linear = m;\n var bound = min(delta, 1.0);\n if (m < 0.0 || m > 1.0) {\n if (reject) { count(${SDR_COUNTER.outOfGamut}u); }\n else if (m < 0.0) { count(${SDR_COUNTER.low}u); linear = 0.0; }\n else { count(${SDR_COUNTER.high}u); linear = 1.0; }\n }\n // Clipping is 1-Lipschitz; when both values clip to the same end the difference is zero.\n if (!reject && (m - delta >= 1.0 || m + delta <= 0.0)) { bound = 0.0; }\n count_max(${SDR_COUNTER.linearBoundBits}u, bound);\n let code = floor(encode_srgb(linear) * maximum + 0.5);\n return u32(clamp(code, 0.0, maximum));\n}\n`;\n\n/** Pointwise SDR over a packed float32 band; one invocation per sample. */\nexport const SDR_WGSL = /* wgsl */ `\nstruct Params { count: u32, reinhard: u32, reject: u32, pad0: u32, scale: f32, maximum: f32, band1: f32, pad1: f32 };\n@group(0) @binding(0) var<uniform> params: Params;\n@group(0) @binding(1) var<storage, read> source: array<f32>;\n@group(0) @binding(2) var<storage, read_write> codes: array<u32>;\n@group(0) @binding(3) var<storage, read_write> counters: array<atomic<u32>, ${SDR_COUNTER_SLOTS}>;\n${SDR_FUNCTIONS}\n@compute @workgroup_size(${LINEAR_WORKGROUP_SIZE})\nfn main(@builtin(global_invocation_id) gid: vec3<u32>, @builtin(local_invocation_index) local_index: u32,\n @builtin(num_workgroups) groups: vec3<u32>) {\n clear_counters(local_index);\n let i = gid.x + gid.y * groups.x * ${LINEAR_WORKGROUP_SIZE}u;\n if (i < params.count) {\n let s = source[i];\n codes[i] = render_sample(s * params.scale, s != 0.0, 0.0, params.band1, params.reinhard != 0u, params.reject != 0u, params.maximum);\n }\n flush_counters(local_index);\n}\n`;\n\n/** Pointwise SDR with a luminance tone curve over a packed float32 band; one invocation per pixel. */\nexport const SDR_LUMINANCE_WGSL = /* wgsl */ `\nstruct Params { pixels: u32, reject: u32, tone_mode: u32, pad0: u32, scale: f32, maximum: f32, band1: f32, pad1: f32,\n tone: vec4<f32>, lum: vec4<f32> };\n@group(0) @binding(0) var<uniform> params: Params;\n@group(0) @binding(1) var<storage, read> source: array<f32>;\n@group(0) @binding(2) var<storage, read_write> codes: array<u32>;\n@group(0) @binding(3) var<storage, read_write> counters: array<atomic<u32>, ${SDR_COUNTER_SLOTS}>;\n${SDR_FUNCTIONS}\n${LUMINANCE_FUNCTIONS}\n@compute @workgroup_size(${LINEAR_WORKGROUP_SIZE})\nfn main(@builtin(global_invocation_id) gid: vec3<u32>, @builtin(local_invocation_index) local_index: u32,\n @builtin(num_workgroups) groups: vec3<u32>) {\n clear_counters(local_index);\n let i = gid.x + gid.y * groups.x * ${LINEAR_WORKGROUP_SIZE}u;\n if (i < params.pixels) {\n let s = vec3<f32>(source[i * 3u], source[i * 3u + 1u], source[i * 3u + 2u]);\n let e = s * params.scale;\n // Source, scale and product roundings (plus the reference's own), and an absolute term where a non-zero source may underflow.\n var eps = 4.0 * LU * abs(e);\n for (var j = 0u; j < 3u; j++) {\n if (s[j] != 0.0 && abs(e[j]) < 7.888609052210118e-31) { eps[j] = eps[j] + 2.350988701644575e-38 * max(1.0, params.scale); }\n }\n let t = luminance_tone(e, eps);\n let reject = params.reject != 0u;\n for (var j = 0u; j < 3u; j++) {\n codes[i * 3u + j] = render_toned(e[j], s[j] != 0.0, 0.0, params.band1, t.m[j], t.delta[j], t.changed_uncertain, reject, params.maximum);\n }\n }\n flush_counters(local_index);\n}\n`;\n\n/**\n * Packed native RAW development of one band of output rows; one invocation per output pixel.\n * `normalized` holds the host's float64 site values, rounded once to float32. A saturated site\n * (flagged, or at or above its phase white level) is exactly 1. Any other site is\n * (code − black)/(white − black) ≤ 1 − 1/65535. So a saturated contributing site is recognised exactly.\n * Highlight handling matches `prepareSensorColorDevelopment` (clip at the smallest applied gain, or the\n * declared neutral blend).\n */\nexport const RAW_DEVELOPMENT_WGSL = /* wgsl */ `\nstruct Params {\n width: u32, count: u32, row0: u32, reinhard: u32,\n reject: u32, repeat_w: u32, repeat_h: u32, region_w: u32,\n origin_x: i32, origin_y: i32, axx: i32, axy: i32,\n ayx: i32, ayy: i32, region_x: i32, region_y: i32,\n scale: f32, maximum: f32, band0: f32, band1: f32,\n clip_level: f32, reconstruct: u32, band_u: f32, band_s: f32,\n gains: vec4<f32>,\n m0: vec4<f32>, m1: vec4<f32>, m2: vec4<f32>,\n x0: vec4<f32>, x1: vec4<f32>, x2: vec4<f32>,\n tone_mode: u32, pad0: u32, pad1: u32, pad2: u32,\n tone: vec4<f32>, lum: vec4<f32>,\n};\nstruct Tap { ox: i32, oy: i32, w: f32, pad: f32 };\n@group(0) @binding(0) var<uniform> params: Params;\n@group(0) @binding(1) var<storage, read> normalized: array<f32>;\n@group(0) @binding(2) var<storage, read> taps: array<Tap>;\n@group(0) @binding(3) var<storage, read> phases: array<vec2<u32>>;\n@group(0) @binding(4) var<storage, read_write> codes: array<u32>;\n@group(0) @binding(5) var<storage, read_write> counters: array<atomic<u32>, ${SDR_COUNTER_SLOTS}>;\n${SDR_FUNCTIONS}\n${LUMINANCE_FUNCTIONS}\nvar<private> saturated: bool;\nfn channel(phase: u32, c: u32, nx: i32, ny: i32) -> f32 {\n let range = phases[phase * 3u + c];\n var value = 0.0;\n for (var k = 0u; k < range.y; k++) {\n let t = taps[range.x + k];\n let sx = nx + t.ox - params.region_x;\n let sy = ny + t.oy - params.region_y;\n let site = normalized[u32(sy) * params.region_w + u32(sx)];\n if (site == 1.0) { saturated = true; }\n value = value + site * t.w;\n }\n return value;\n}\nfn row3(m: vec4<f32>, v: vec3<f32>) -> f32 { return ((0.0 + m.x * v.x) + m.y * v.y) + m.z * v.z; }\nfn max3(v: vec3<f32>) -> f32 {\n if (v.x > v.y) { if (v.x > v.z) { return v.x; } return v.z; }\n if (v.y > v.z) { return v.y; }\n return v.z;\n}\n@compute @workgroup_size(${LINEAR_WORKGROUP_SIZE})\nfn main(@builtin(global_invocation_id) gid: vec3<u32>, @builtin(local_invocation_index) local_index: u32,\n @builtin(num_workgroups) groups: vec3<u32>) {\n clear_counters(local_index);\n let i = gid.x + gid.y * groups.x * ${LINEAR_WORKGROUP_SIZE}u;\n if (i < params.count) {\n let col = i32(i % params.width);\n let row = i32(params.row0 + i / params.width);\n let nx = params.origin_x + params.axx * col + params.axy * row;\n let ny = params.origin_y + params.ayx * col + params.ayy * row;\n let phase = (u32(ny) % params.repeat_h) * params.repeat_w + u32(nx) % params.repeat_w;\n saturated = false;\n let c = vec3<f32>(channel(phase, 0u, nx, ny), channel(phase, 1u, nx, ny), channel(phase, 2u, nx, ny));\n if (saturated) { count(${SDR_COUNTER.saturatedPixels}u); }\n let u = vec3<f32>(c.x * params.gains.x, c.y * params.gains.y, c.z * params.gains.z);\n let clip = params.clip_level;\n let k = vec3<f32>(select(u.x, clip, u.x > clip), select(u.y, clip, u.y > clip), select(u.z, clip, u.z > clip));\n var b = k;\n if (params.reconstruct == 0u) {\n for (var j = 0u; j < 3u; j++) {\n if (u[j] > clip) { count(${SDR_COUNTER.whiteBalanceClipped}u); }\n if (abs(u[j] - clip) <= params.band_u) { count(${SDR_COUNTER.uncertain}u); }\n }\n } else {\n let s = max3(c);\n if (abs(s - ${RAW_HIGHLIGHT_START_WGSL}) <= params.band_s) { count(${SDR_COUNTER.uncertain}u); }\n if (s > ${RAW_HIGHLIGHT_START_WGSL}) {\n var t = 1.0;\n if (s < 1.0) { t = (s - ${RAW_HIGHLIGHT_START_WGSL}) / (1.0 - ${RAW_HIGHLIGHT_START_WGSL}); }\n let n = max3(k);\n b = (1.0 - t) * u + t * vec3<f32>(n, n, n);\n count(${SDR_COUNTER.reconstructedPixels}u);\n } else {\n b = u;\n }\n }\n let xyz = vec3<f32>(row3(params.m0, b), row3(params.m1, b), row3(params.m2, b));\n let rgb = vec3<f32>(row3(params.x0, xyz), row3(params.x1, xyz), row3(params.x2, xyz));\n let reinhard = params.reinhard != 0u;\n let reject = params.reject != 0u;\n if (params.tone_mode == ${SDR_TONE_MODE.perChannel}u) {\n for (var j = 0u; j < 3u; j++) {\n codes[i * 3u + j] = render_sample(rgb[j] * params.scale, false, params.band0, params.band1, reinhard, reject, params.maximum);\n }\n } else {\n // band0 bounds each exposed value against the reference (the development chain's a-priori bound).\n let e = rgb * params.scale;\n let t = luminance_tone(e, vec3<f32>(params.band0, params.band0, params.band0));\n for (var j = 0u; j < 3u; j++) {\n codes[i * 3u + j] = render_toned(e[j], false, params.band0, params.band1, t.m[j], t.delta[j], t.changed_uncertain, reject, params.maximum);\n }\n }\n }\n flush_counters(local_index);\n}\n`;\n\n/** Source-indexed isoplanatic-patch convolution of one output-row band; one invocation per output site. */\nexport const IRRADIANCE_CONVOLUTION_WGSL = /* wgsl */ `\nstruct Params {\n width: u32, height: u32, radius: u32, size: u32,\n patch_w: u32, patch_h: u32, cols: u32, rows: u32,\n out_row0: u32, out_rows: u32, in_row0: u32, taps: u32,\n};\n@group(0) @binding(0) var<uniform> params: Params;\n@group(0) @binding(1) var<storage, read> source: array<f32>;\n@group(0) @binding(2) var<storage, read> kernels: array<f32>;\n@group(0) @binding(3) var<storage, read_write> result: array<f32>;\n@compute @workgroup_size(${CONVOLUTION_WORKGROUP_EDGE}, ${CONVOLUTION_WORKGROUP_EDGE})\nfn main(@builtin(global_invocation_id) gid: vec3<u32>) {\n let x = gid.x;\n let local_y = gid.y;\n if (x >= params.width || local_y >= params.out_rows) { return; }\n let y = i32(params.out_row0 + local_y);\n let r = i32(params.radius);\n var sum = 0.0;\n for (var v = -r; v <= r; v++) {\n let sy = y - v;\n if (sy < 0 || sy >= i32(params.height)) { continue; }\n let patch_row = min(u32(sy) / params.patch_h, params.rows - 1u) * params.cols;\n let kernel_row = (v + r) * i32(params.size) + r;\n let source_row = (u32(sy) - params.in_row0) * params.width;\n for (var u = -r; u <= r; u++) {\n let sx = i32(x) - u;\n if (sx < 0 || sx >= i32(params.width)) { continue; }\n let patch_index = patch_row + min(u32(sx) / params.patch_w, params.cols - 1u);\n sum = sum + source[source_row + u32(sx)] * kernels[patch_index * params.taps + u32(kernel_row + u)];\n }\n }\n result[local_y * params.width + x] = sum;\n}\n`;\n"]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WGSL kernel for the `webgpu-f32` sensor stage (#277), one invocation per native site. It evaluates the
|
|
3
|
+
* reference `simulatePackedSensorSite` (packed-sensor-raw.ts) with the same seeded noise model
|
|
4
|
+
* (`photivra-native-raw-noise` 0.4.0):
|
|
5
|
+
* - the MurmurHash3_x86_32 site seeds, fmix32 scrambling and xorshift32 streams are 32-bit integer
|
|
6
|
+
* arithmetic, so every random state is bit-identical to the reference;
|
|
7
|
+
* - every comparison against a uniform value is made exactly on the integer state where the reference
|
|
8
|
+
* value is an exact dyadic rational;
|
|
9
|
+
* - every other decision (Poisson multiplication-method threshold, PTRS floor and acceptance tests,
|
|
10
|
+
* physical and pre-ADC limits, ADC and digital-gain rounding) is evaluated in float32 together with an
|
|
11
|
+
* a-priori bound on how far the float32 value can be from the float64 reference value. A site where any
|
|
12
|
+
* decision falls inside its bound is flagged. An unflagged site therefore makes every decision exactly
|
|
13
|
+
* as the reference does, and its code and flags equal the reference.
|
|
14
|
+
* - Fixed-pattern noise and additional stored-charge components (2.0): the host evaluates the
|
|
15
|
+
* fixed-pattern values in float64 with the model's own functions and packs, per site, the Poisson means
|
|
16
|
+
* already multiplied by the PRNU and dark factors (exactly the reference's products), the pre-ADC limit
|
|
17
|
+
* minus the readout offset and the offset in codes. Additional Poisson components are drawn from the
|
|
18
|
+
* charge stream after photo and dark charge, in declaration order; deterministic components enter as an
|
|
19
|
+
* exact integer part plus a float32 fraction, with their own bounds.
|
|
20
|
+
*
|
|
21
|
+
* The bounds use u = 2^-24 and the WGSL accuracy table (W3C WGSL, "Floating Point Accuracy"): correctly
|
|
22
|
+
* rounded + − ×, division 2.5 ULP, sqrt inherited from 1/inverseSqrt (≤ 4.5 ULP), exp 3 + 2|x| ULP,
|
|
23
|
+
* log 3 ULP or 2^-21 absolute on [0.5, 2]. WGSL's built-in cos has only a 2^-11 absolute bound, so
|
|
24
|
+
* the kernel uses its own range-reduced Taylor polynomials. Every margin is doubled (`MARGIN`).
|
|
25
|
+
* See docs/WEBGPU.md.
|
|
26
|
+
*/
|
|
27
|
+
/** Output word: code in bits 0–15, saturation flags in bits 16–19, the flagged (uncertain) bit 20. */
|
|
28
|
+
export declare const SENSOR_OUTPUT: Readonly<{
|
|
29
|
+
codeMask: 65535;
|
|
30
|
+
flagShift: 16;
|
|
31
|
+
uncertainBit: number;
|
|
32
|
+
}>;
|
|
33
|
+
/** Auxiliary table layout (float32 words). */
|
|
34
|
+
export declare const SENSOR_AUX: Readonly<{
|
|
35
|
+
stirlingRemainder: 0;
|
|
36
|
+
sigma: 256;
|
|
37
|
+
inversePieces: 272;
|
|
38
|
+
digitalPieces: 276;
|
|
39
|
+
knots: 280;
|
|
40
|
+
}>;
|
|
41
|
+
export declare const SENSOR_WORKGROUP_SIZE = 256;
|
|
42
|
+
/**
|
|
43
|
+
* Per-site packed words: photo word, photo fraction bits, dark word, dark fraction bits; then 2 words per
|
|
44
|
+
* additional Poisson component; then, with deterministic components, their sum (integer part, fraction
|
|
45
|
+
* bits); then, with fixed-pattern noise, (threshold − offset) and offset/gain as (floor, fraction bits).
|
|
46
|
+
*/
|
|
47
|
+
export declare const SENSOR_SITE_WORDS = 4;
|
|
48
|
+
/** Bits of `Params.extras`. */
|
|
49
|
+
export declare const SENSOR_EXTRAS: Readonly<{
|
|
50
|
+
deterministic: 1;
|
|
51
|
+
fixedPattern: 2;
|
|
52
|
+
}>;
|
|
53
|
+
/** Partial charge sums saturate here: above every supported capacity (2^24), so no decision changes. */
|
|
54
|
+
export declare const SENSOR_REALIZED_CLAMP: number;
|
|
55
|
+
/** Mean categories in bits 30–31 of a mean word, mirroring `samplePoisson`'s branches. */
|
|
56
|
+
export declare const SENSOR_MEAN_CATEGORY: Readonly<{
|
|
57
|
+
zero: 0;
|
|
58
|
+
multiplication: 1;
|
|
59
|
+
transformedRejection: 2;
|
|
60
|
+
normal: 3;
|
|
61
|
+
}>;
|
|
62
|
+
/** Smallest integer m with (m + 0.5)/2^32 ≥ t, so `uS ≥ t` ⇔ `m ≥ result` exactly. */
|
|
63
|
+
export declare function uniformThresholdInteger(t: number): number;
|
|
64
|
+
export declare const SENSOR_RAW_WGSL: string;
|