@photivra/engine 2.17.0 → 2.19.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.
Files changed (288) hide show
  1. package/CHANGELOG.md +116 -1
  2. package/CITATION.cff +1 -1
  3. package/README.md +6 -6
  4. package/SECURITY.md +1 -1
  5. package/dist/camera/sensor-equivalence.d.ts +156 -0
  6. package/dist/camera/sensor-equivalence.js +208 -0
  7. package/dist/camera/sensor-equivalence.js.map +1 -0
  8. package/dist/capture/focus-control.js +2 -75
  9. package/dist/capture/focus-control.js.map +1 -1
  10. package/dist/capture/native-environment-lean.d.ts +1 -0
  11. package/dist/capture/native-environment-lean.js +1 -1
  12. package/dist/capture/native-environment-lean.js.map +1 -1
  13. package/dist/capture/native-environment-optical-stage.d.ts +1 -0
  14. package/dist/capture/native-environment-optical-stage.js +2 -5
  15. package/dist/capture/native-environment-optical-stage.js.map +1 -1
  16. package/dist/capture/native-environment-raw.js +1 -5
  17. package/dist/capture/native-environment-raw.js.map +1 -1
  18. package/dist/capture/native-environment-tabulated.d.ts +5 -0
  19. package/dist/capture/native-environment-tabulated.js +1 -1
  20. package/dist/capture/native-environment-tabulated.js.map +1 -1
  21. package/dist/capture/release-sequence.js +2 -47
  22. package/dist/capture/release-sequence.js.map +1 -1
  23. package/dist/color/white-balance.d.ts +2 -0
  24. package/dist/color/white-balance.js +3 -56
  25. package/dist/color/white-balance.js.map +1 -1
  26. package/dist/composition/image-formation-plan.d.ts +1 -0
  27. package/dist/composition/image-formation-plan.js +3 -49
  28. package/dist/composition/image-formation-plan.js.map +1 -1
  29. package/dist/core/evidence-provenance.js +1 -16
  30. package/dist/core/evidence-provenance.js.map +1 -1
  31. package/dist/core/record-validation.d.ts +54 -0
  32. package/dist/core/record-validation.js +176 -0
  33. package/dist/core/record-validation.js.map +1 -1
  34. package/dist/core/scientific-assurance.js +1 -18
  35. package/dist/core/scientific-assurance.js.map +1 -1
  36. package/dist/core/shared-helpers.d.ts +33 -0
  37. package/dist/core/shared-helpers.js +34 -0
  38. package/dist/core/shared-helpers.js.map +1 -0
  39. package/dist/core/spectral-composition.js +1 -36
  40. package/dist/core/spectral-composition.js.map +1 -1
  41. package/dist/core/spectral.js +1 -19
  42. package/dist/core/spectral.js.map +1 -1
  43. package/dist/core/version.d.ts +1 -1
  44. package/dist/core/version.js +1 -1
  45. package/dist/core/version.js.map +1 -1
  46. package/dist/equipment/exposure-capabilities.d.ts +1 -0
  47. package/dist/equipment/exposure-capabilities.js +2 -36
  48. package/dist/equipment/exposure-capabilities.js.map +1 -1
  49. package/dist/equipment/ideal-lens.d.ts +25 -0
  50. package/dist/equipment/ideal-lens.js +21 -0
  51. package/dist/equipment/ideal-lens.js.map +1 -0
  52. package/dist/equipment/iso-capabilities.js +2 -49
  53. package/dist/equipment/iso-capabilities.js.map +1 -1
  54. package/dist/equipment/metering-capabilities.js +1 -26
  55. package/dist/equipment/metering-capabilities.js.map +1 -1
  56. package/dist/equipment/release-capabilities.js +1 -53
  57. package/dist/equipment/release-capabilities.js.map +1 -1
  58. package/dist/exposure/auto-iso-slowest-shutter.js +1 -7
  59. package/dist/exposure/auto-iso-slowest-shutter.js.map +1 -1
  60. package/dist/exposure/exposure-duration-control.js +1 -16
  61. package/dist/exposure/exposure-duration-control.js.map +1 -1
  62. package/dist/exposure/exposure-mode-resolver.js +1 -17
  63. package/dist/exposure/exposure-mode-resolver.js.map +1 -1
  64. package/dist/exposure/filtered-exposure-time.d.ts +93 -0
  65. package/dist/exposure/filtered-exposure-time.js +129 -0
  66. package/dist/exposure/filtered-exposure-time.js.map +1 -0
  67. package/dist/exposure/flash-ttl.d.ts +1 -0
  68. package/dist/exposure/flash-ttl.js +1 -1
  69. package/dist/exposure/flash-ttl.js.map +1 -1
  70. package/dist/exposure/flash.js +1 -49
  71. package/dist/exposure/flash.js.map +1 -1
  72. package/dist/exposure/metering-scene-radiance.js +1 -25
  73. package/dist/exposure/metering-scene-radiance.js.map +1 -1
  74. package/dist/exposure/metering-target.js +1 -30
  75. package/dist/exposure/metering-target.js.map +1 -1
  76. package/dist/exposure/metering-temporal.js +1 -8
  77. package/dist/exposure/metering-temporal.js.map +1 -1
  78. package/dist/exposure/metering.js +1 -72
  79. package/dist/exposure/metering.js.map +1 -1
  80. package/dist/exposure/program-line.js +1 -45
  81. package/dist/exposure/program-line.js.map +1 -1
  82. package/dist/facade/catalogue-lens-signal.d.ts +94 -0
  83. package/dist/facade/catalogue-lens-signal.js +362 -0
  84. package/dist/facade/catalogue-lens-signal.js.map +1 -0
  85. package/dist/facade/defocus-image-space-provider.js +5 -2
  86. package/dist/facade/defocus-image-space-provider.js.map +1 -1
  87. package/dist/facade/develop-joined-parts.d.ts +29 -0
  88. package/dist/facade/develop-joined-parts.js +33 -0
  89. package/dist/facade/develop-joined-parts.js.map +1 -0
  90. package/dist/facade/display-view-lens-signal.d.ts +32 -1
  91. package/dist/facade/display-view-lens-signal.js +85 -10
  92. package/dist/facade/display-view-lens-signal.js.map +1 -1
  93. package/dist/facade/expected-signal-setup.d.ts +8 -0
  94. package/dist/facade/expected-signal-setup.js +7 -0
  95. package/dist/facade/expected-signal-setup.js.map +1 -1
  96. package/dist/facade/expected-signal.d.ts +5 -0
  97. package/dist/facade/expected-signal.js +5 -1
  98. package/dist/facade/expected-signal.js.map +1 -1
  99. package/dist/facade/generic-lens-capture.d.ts +5 -2
  100. package/dist/facade/generic-lens-capture.js +5 -2
  101. package/dist/facade/generic-lens-capture.js.map +1 -1
  102. package/dist/facade/simulate-capture.d.ts +67 -8
  103. package/dist/facade/simulate-capture.js +262 -126
  104. package/dist/facade/simulate-capture.js.map +1 -1
  105. package/dist/facade/simulate-display-view.js +1 -1
  106. package/dist/facade/simulate-display-view.js.map +1 -1
  107. package/dist/gpu/chart-composite-gpu.js +1 -3
  108. package/dist/gpu/chart-composite-gpu.js.map +1 -1
  109. package/dist/gpu/chart-radiance-gpu.js +1 -5
  110. package/dist/gpu/chart-radiance-gpu.js.map +1 -1
  111. package/dist/gpu/display-view-quality-gpu.d.ts +13 -1
  112. package/dist/gpu/display-view-quality-gpu.js +4 -8
  113. package/dist/gpu/display-view-quality-gpu.js.map +1 -1
  114. package/dist/gpu/display-view-speed-gpu.js +3 -25
  115. package/dist/gpu/display-view-speed-gpu.js.map +1 -1
  116. package/dist/gpu/sensor-stage-gpu.js +1 -5
  117. package/dist/gpu/sensor-stage-gpu.js.map +1 -1
  118. package/dist/gpu/webgpu-runtime.d.ts +2 -0
  119. package/dist/gpu/webgpu-runtime.js +3 -0
  120. package/dist/gpu/webgpu-runtime.js.map +1 -1
  121. package/dist/index.d.ts +6 -1
  122. package/dist/index.js +5 -0
  123. package/dist/index.js.map +1 -1
  124. package/dist/motion/camera-rotation.js +1 -6
  125. package/dist/motion/camera-rotation.js.map +1 -1
  126. package/dist/motion/capture-rotation-inverse-mapping.d.ts +12 -0
  127. package/dist/motion/capture-rotation-inverse-mapping.js +2 -2
  128. package/dist/motion/capture-rotation-inverse-mapping.js.map +1 -1
  129. package/dist/motion/capture-rotation-temporal-quadrature.d.ts +1 -0
  130. package/dist/motion/capture-rotation-temporal-quadrature.js +1 -1
  131. package/dist/motion/capture-rotation-temporal-quadrature.js.map +1 -1
  132. package/dist/motion/capture-rotation-trajectory.js +2 -17
  133. package/dist/motion/capture-rotation-trajectory.js.map +1 -1
  134. package/dist/motion/capture-translation-parallax-temporal-quadrature.d.ts +1 -0
  135. package/dist/motion/capture-translation-parallax-temporal-quadrature.js +3 -14
  136. package/dist/motion/capture-translation-parallax-temporal-quadrature.js.map +1 -1
  137. package/dist/motion/extended-object-projection.js +5 -40
  138. package/dist/motion/extended-object-projection.js.map +1 -1
  139. package/dist/optics/atmospheric-haze.js +1 -7
  140. package/dist/optics/atmospheric-haze.js.map +1 -1
  141. package/dist/optics/brown-conrady-distortion.js +1 -7
  142. package/dist/optics/brown-conrady-distortion.js.map +1 -1
  143. package/dist/optics/complex-pupil-psf.d.ts +1 -0
  144. package/dist/optics/complex-pupil-psf.js +2 -84
  145. package/dist/optics/complex-pupil-psf.js.map +1 -1
  146. package/dist/optics/focus-state.js +1 -11
  147. package/dist/optics/focus-state.js.map +1 -1
  148. package/dist/optics/front-of-lens-filter.d.ts +5 -0
  149. package/dist/optics/front-of-lens-filter.js +3 -65
  150. package/dist/optics/front-of-lens-filter.js.map +1 -1
  151. package/dist/optics/generic-nd-filter-presets.d.ts +12 -0
  152. package/dist/optics/generic-nd-filter-presets.js +48 -0
  153. package/dist/optics/generic-nd-filter-presets.js.map +1 -0
  154. package/dist/optics/illumination-vignetting.js +1 -6
  155. package/dist/optics/illumination-vignetting.js.map +1 -1
  156. package/dist/optics/lens-psf-profile.d.ts +4 -1
  157. package/dist/optics/lens-psf-profile.js +12 -111
  158. package/dist/optics/lens-psf-profile.js.map +1 -1
  159. package/dist/optics/longitudinal-chromatic-aberration.js +1 -7
  160. package/dist/optics/longitudinal-chromatic-aberration.js.map +1 -1
  161. package/dist/optics/pupil-vignetting.js +1 -7
  162. package/dist/optics/pupil-vignetting.js.map +1 -1
  163. package/dist/optics/radial-distortion.js +1 -6
  164. package/dist/optics/radial-distortion.js.map +1 -1
  165. package/dist/optics/scene-to-sensor-irradiance.js +4 -96
  166. package/dist/optics/scene-to-sensor-irradiance.js.map +1 -1
  167. package/dist/optics/stray-light.d.ts +1 -0
  168. package/dist/optics/stray-light.js +1 -1
  169. package/dist/optics/stray-light.js.map +1 -1
  170. package/dist/optics/zernike-wavefront.js +1 -7
  171. package/dist/optics/zernike-wavefront.js.map +1 -1
  172. package/dist/output/capture-geometry.js +1 -8
  173. package/dist/output/capture-geometry.js.map +1 -1
  174. package/dist/output/developed-lens-corrections.d.ts +62 -0
  175. package/dist/output/developed-lens-corrections.js +135 -0
  176. package/dist/output/developed-lens-corrections.js.map +1 -0
  177. package/dist/output/generic-lens-corrections.d.ts +2 -6
  178. package/dist/output/generic-lens-corrections.js +3 -6
  179. package/dist/output/generic-lens-corrections.js.map +1 -1
  180. package/dist/output/geometric-transforms.js +1 -4
  181. package/dist/output/geometric-transforms.js.map +1 -1
  182. package/dist/output/native-capture-sdr.d.ts +2 -2
  183. package/dist/output/native-capture-sdr.js +3 -2
  184. package/dist/output/native-capture-sdr.js.map +1 -1
  185. package/dist/processing/development-detail.d.ts +29 -0
  186. package/dist/processing/development-detail.js +128 -107
  187. package/dist/processing/development-detail.js.map +1 -1
  188. package/dist/schema/illumination-temporal.js +3 -72
  189. package/dist/schema/illumination-temporal.js.map +1 -1
  190. package/dist/schema/illumination.d.ts +1 -0
  191. package/dist/schema/illumination.js +2 -65
  192. package/dist/schema/illumination.js.map +1 -1
  193. package/dist/schema/scene-radiance-temporal.js +2 -14
  194. package/dist/schema/scene-radiance-temporal.js.map +1 -1
  195. package/dist/schema/scene-radiance.js +2 -60
  196. package/dist/schema/scene-radiance.js.map +1 -1
  197. package/dist/schema/validation.d.ts +2 -0
  198. package/dist/schema/validation.js +2 -17
  199. package/dist/schema/validation.js.map +1 -1
  200. package/dist/sensor/accumulated-charge.js +2 -59
  201. package/dist/sensor/accumulated-charge.js.map +1 -1
  202. package/dist/sensor/architecture.js +1 -16
  203. package/dist/sensor/architecture.js.map +1 -1
  204. package/dist/sensor/camera-saturation-capacity.d.ts +1 -0
  205. package/dist/sensor/camera-saturation-capacity.js +3 -55
  206. package/dist/sensor/camera-saturation-capacity.js.map +1 -1
  207. package/dist/sensor/capture-color-sampling-binding.js +1 -26
  208. package/dist/sensor/capture-color-sampling-binding.js.map +1 -1
  209. package/dist/sensor/capture-mode-timing.js +1 -39
  210. package/dist/sensor/capture-mode-timing.js.map +1 -1
  211. package/dist/sensor/capture-mode.js +1 -23
  212. package/dist/sensor/capture-mode.js.map +1 -1
  213. package/dist/sensor/color-sampling.js +1 -26
  214. package/dist/sensor/color-sampling.js.map +1 -1
  215. package/dist/sensor/constant-rate-temporal-integration.js +2 -46
  216. package/dist/sensor/constant-rate-temporal-integration.js.map +1 -1
  217. package/dist/sensor/dark-current.js +2 -45
  218. package/dist/sensor/dark-current.js.map +1 -1
  219. package/dist/sensor/eqe-electron-rate.js +2 -35
  220. package/dist/sensor/eqe-electron-rate.js.map +1 -1
  221. package/dist/sensor/exposure-window.d.ts +5 -0
  222. package/dist/sensor/exposure-window.js +7 -22
  223. package/dist/sensor/exposure-window.js.map +1 -1
  224. package/dist/sensor/iso-gain.js +1 -7
  225. package/dist/sensor/iso-gain.js.map +1 -1
  226. package/dist/sensor/iso-signal-chain.js +1 -43
  227. package/dist/sensor/iso-signal-chain.js.map +1 -1
  228. package/dist/sensor/optical-stack.js +1 -25
  229. package/dist/sensor/optical-stack.js.map +1 -1
  230. package/dist/sensor/photon-energy.js +1 -26
  231. package/dist/sensor/photon-energy.js.map +1 -1
  232. package/dist/sensor/physical-charge-capacity.js +3 -77
  233. package/dist/sensor/physical-charge-capacity.js.map +1 -1
  234. package/dist/sensor/radiometry-readiness.js +2 -23
  235. package/dist/sensor/radiometry-readiness.js.map +1 -1
  236. package/dist/sensor/raw-readout.d.ts +3 -0
  237. package/dist/sensor/raw-readout.js +4 -66
  238. package/dist/sensor/raw-readout.js.map +1 -1
  239. package/dist/sensor/raw-reconstruction.js +2 -64
  240. package/dist/sensor/raw-reconstruction.js.map +1 -1
  241. package/dist/sensor/readout-exposure-linkage.js +1 -9
  242. package/dist/sensor/readout-exposure-linkage.js.map +1 -1
  243. package/dist/sensor/readout-timing.js +3 -57
  244. package/dist/sensor/readout-timing.js.map +1 -1
  245. package/dist/sensor/response-application-compatibility.d.ts +2 -0
  246. package/dist/sensor/response-application-compatibility.js +3 -29
  247. package/dist/sensor/response-application-compatibility.js.map +1 -1
  248. package/dist/sensor/response-operating-range.d.ts +1 -0
  249. package/dist/sensor/response-operating-range.js +3 -79
  250. package/dist/sensor/response-operating-range.js.map +1 -1
  251. package/dist/sensor/responsivity-photocurrent.js +4 -108
  252. package/dist/sensor/responsivity-photocurrent.js.map +1 -1
  253. package/dist/sensor/sampling-aperture.js +1 -25
  254. package/dist/sensor/sampling-aperture.js.map +1 -1
  255. package/dist/sensor/spatial-sample-reduction.js +2 -19
  256. package/dist/sensor/spatial-sample-reduction.js.map +1 -1
  257. package/dist/sensor/spatial-sampling-quadrature.js +1 -3
  258. package/dist/sensor/spatial-sampling-quadrature.js.map +1 -1
  259. package/dist/sensor/spatio-spectral-reduction.js +1 -18
  260. package/dist/sensor/spatio-spectral-reduction.js.map +1 -1
  261. package/dist/sensor/spectral-coverage.d.ts +10 -1
  262. package/dist/sensor/spectral-coverage.js +1 -1
  263. package/dist/sensor/spectral-coverage.js.map +1 -1
  264. package/dist/sensor/spectral-quadrature.js +2 -35
  265. package/dist/sensor/spectral-quadrature.js.map +1 -1
  266. package/dist/sensor/spectral-response.js +1 -47
  267. package/dist/sensor/spectral-response.js.map +1 -1
  268. package/dist/stabilization/camera-shake.js +1 -6
  269. package/dist/stabilization/camera-shake.js.map +1 -1
  270. package/dist/stabilization/system.js +2 -80
  271. package/dist/stabilization/system.js.map +1 -1
  272. package/docs/AGENT_GUIDE.md +4 -0
  273. package/docs/API_REFERENCE.md +69 -2
  274. package/docs/QUICK_START.md +136 -6
  275. package/docs/USAGE.md +89 -3
  276. package/docs/api/camera-sensor-equivalence.md +209 -0
  277. package/docs/api/core-version.md +1 -1
  278. package/docs/api/equipment-ideal-lens.md +26 -0
  279. package/docs/api/exports.json +118 -3
  280. package/docs/api/exposure-filtered-exposure-time.md +105 -0
  281. package/docs/api/facade-develop-joined-parts.md +32 -0
  282. package/docs/api/facade-simulate-capture.md +62 -8
  283. package/docs/api/optics-generic-nd-filter-presets.md +34 -0
  284. package/docs/api/optics-lens-psf-profile.md +3 -1
  285. package/docs/api/output-developed-lens-corrections.md +12 -0
  286. package/docs/api/output-generic-lens-corrections.md +0 -9
  287. package/llms.txt +3 -0
  288. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"defocus-image-space-provider.js","sourceRoot":"","sources":["../../src/facade/defocus-image-space-provider.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;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AI,MAAM,EAAE,CAAC;YACvB,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YAC1C,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC;QAClF,CAAC;IACH,CAAC;IACD,OAAO,EAAE,iBAAiB,EAAE,CAAC,EAAE,kCAAkC,EAAE,QAAQ,EAAE,oCAAoC,EAAE,UAAU,EAAE,oCAAoC,EAAE,UAAU,EAAE,CAAC;AACpL,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * `simulateCapture`'s `lens.defocus` out of focus together with a lens field mapping (`lens.projection`,\n * `lens.distortion`), `lens.vignetting` or camera rotation (#548): the geometric defocus disc applied in image space,\n * on the site lattice of the sensor, instead of on the scene plane.\n *\n * Why the object-space path does not apply. `createDiffractedPlanarProvider` convolves the scene radiance on the plane\n * lattice that the sites see through one linear map (a still, rectilinear, distortion-free camera with the same\n * radiance-to-irradiance factor everywhere). A projection, a distortion or a rotation makes the map from sensor points\n * to plane points non-linear (or time-dependent), and vignetting makes the factor vary over the field, so the disc on\n * the plane is no longer the disc on the sensor.\n *\n * The image-space model. The environment PSF quadrature (`calculateSensorPsfIrradianceQuadrature`, the per-tap path\n * `lens.diffraction` falls back to) defines a sensor-plane PSF K as\n * E(q, λ, t) = Σ_k K(k)·F(s_k)·C·L(D_t(s_k), λ),\n * with s_k = q + k·p the tap source points on the sensor (p the site pitch), D_t the scene ray of a sensor point at\n * time t (inverse distortion, the declared projection, the camera rotation at t), F = T·A the field factor (vignetting\n * throughput T, applied once before the PSF spreads the light, and the distortion area factor A = 1/det J) and C the\n * paraxial radiance-to-irradiance factor π/(4·N_w²), the same everywhere. With K the defocus disc sampled on the site\n * lattice (`createDefocusDiscSiteKernel`), every source point of a site-centre query is another lattice point, so\n * E(q, λ, t) = C·G_t(q, λ), G_t = K ⊛ (F·L∘D_t) sampled on the lattice,\n * the same sum in a different floating-point order. This provider computes G_t once per spectral node and time on the\n * sensor lattice (in row bands, as the diffraction provider does) and answers the query of lattice point q at time t with\n * G_t(q, λ) / F(q); the environment multiplies by F(q)·C again, so each site gets C·G_t(q, λ). For the still,\n * rectilinear, distortion-free camera without vignetting it is the object-space convolution (F = 1 and D linear).\n *\n * The lattices. As in the diffraction provider, a pixel aperture or anti-aliasing spots add query offsets; each distinct\n * fractional offset gets its own shifted lattice of sensor points, and every tap of a query on one lattice is on the same\n * lattice. A query is located on its lattice by mapping its scene ray back to the sensor (camera rotation inverted at the\n * request's time, the forward projection, the forward distortion), within 1e-4 site; a query that lands on no lattice point\n * is refused rather than approximated.\n *\n * Time. With camera rotation each environment temporal midpoint is a still camera, so the disc is applied to that\n * instant's image in that instant's frame: one G_t per distinct request time, cached per band. Without rotation the image\n * does not depend on time and one G is kept. The facade refuses rotation with a rolling shutter (each row's instants differ).\n *\n * What is approximate is the disc itself (`lens.defocus` labels it; the facade records the field-variation bounds of\n * each combination), not this evaluation of it.\n */\n\n// #564: a defocus kernel above 64 sites (`largeKernel`) takes the run lattice of large-defocus-lattice.ts instead of the bands:\n// the samples F·L at the same lattice points, convolved by runs in fixed tiles, then divided by each queried point's own F.\nimport { InvalidConfigurationError } from \"../core/configuration-error.js\";\nimport { hypot3 } from \"../core/portable-math.js\";\nimport { isInternalSceneRadianceEvaluator, markInternalSceneRadianceEvaluator, registerInternalRadianceAccess } from \"../core/internal-radiance-evaluator.js\";\nimport type { SceneRadianceEvaluationRequest, SceneRadianceEvaluationResult } from \"../schema/scene-radiance.js\";\nimport { lensProjectionDirectionValue, lensProjectionImagePointValue, type LensProjectionModel } from \"../camera/lens-projection.js\";\nimport { applyPhysicalCameraRotation, resolveProjectionDistanceMm, type CameraAngularVelocityRadPerSec } from \"../motion/camera-rotation.js\";\nimport { prepareIlluminationVignettingThroughput, type IlluminationVignettingProfile } from \"../optics/illumination-vignetting.js\";\nimport { distortedImagePoint, undistortedImagePoint, type PreparedEnvironmentLensFieldMapping } from \"../optics/sensor-environment-query.js\";\nimport { checkedSiteKernel, createZonedGather, gatherInterior, kernelTaps, type SiteKernelFieldZones } from \"./diffraction-provider.js\";\nimport type { PlanarSceneRadianceProvider } from \"./scene-radiance.js\";\nimport { LARGE_DEFOCUS_CACHE_BYTES, createLargeDefocusNodeLattice, type LargeDefocusKernel, type LargeDefocusNodeLattice } from \"./large-defocus-lattice.js\";\n\n/** Rows of native sites per band; bands kept per time. Banding changes memory only, never values. */\nconst BAND_ROWS = 32;\nconst CACHED_BANDS = 2;\nconst LATTICE_TOLERANCE_SITES = 1e-4;\n\n/** The camera geometry the environment uses for each site query (the same options as the site inputs). */\nexport interface DefocusImageSpaceGeometry {\n focalLengthMm: number;\n focusDistanceM: number;\n angularVelocityRadPerSec: CameraAngularVelocityRadPerSec;\n /** The site inputs' `lensFieldMapping`, prepared; omitted for the ideal rectilinear, distortion-free mapping. */\n lensMapping?: PreparedEnvironmentLensFieldMapping;\n /** The site inputs' radial-illumination-vignetting profile; omitted for unity field throughput. */\n vignetting?: IlluminationVignettingProfile;\n}\n\n/** Internal: the scene ray and field factor of sensor points, and the sensor point of a scene ray, for one geometry. */\nexport interface PreparedDefocusImageSpaceGeometry {\n /**\n * The unit look direction (toward the scene, reference camera axes at exposure start) of native sensor point (x, y) mm\n * (+X right, +Y down) at time t, and its field factor F = T·A (vignetting throughput × distortion area factor).\n */\n lookOf(xMm: number, yMm: number, timeSeconds: number): { x: number; y: number; z: number; factor: number };\n /** The native sensor point (mm, +Y down) whose scene ray at time t is the look direction; undefined outside the mapping. */\n sensorPointOf(look: { x: number; y: number; z: number }, timeSeconds: number): { x: number; y: number } | undefined;\n /** True with camera rotation: the ray of a sensor point depends on time. */\n timeDependent: boolean;\n}\n\n/** Internal: prepares {@link PreparedDefocusImageSpaceGeometry} with the environment's own conventions and arithmetic. */\nexport function prepareDefocusImageSpaceGeometry(geometry: DefocusImageSpaceGeometry): PreparedDefocusImageSpaceGeometry {\n const { focalLengthMm, focusDistanceM, angularVelocityRadPerSec: omega, lensMapping, vignetting } = geometry;\n // The projection scale: the thin-lens image distance at the finite focus, for every projection model (the environment's).\n const pd = resolveProjectionDistanceMm(focalLengthMm, focusDistanceM).projectionDistanceMm;\n const model: LensProjectionModel = lensMapping?.mapping.projectionModel ?? \"rectilinear\";\n const timeDependent = omega.pitch !== 0 || omega.yaw !== 0 || omega.roll !== 0;\n // calculateIlluminationVignetting's throughput with the profile validated once (#563: the same numbers, without a result envelope per point).\n const throughputAt = vignetting ? prepareIlluminationVignettingThroughput(vignetting) : undefined;\n const displacement = (t: number): { pitch: number; yaw: number; roll: number } =>\n timeDependent ? { pitch: omega.pitch * t, yaw: omega.yaw * t, roll: omega.roll * t } : { pitch: 0, yaw: 0, roll: 0 };\n // The reference-to-camera rotation at the last time asked, as a matrix (its columns: the rotated basis vectors), so a lattice\n // lookup costs no trigonometry; the rotation is linear, so this equals rotating the vector, up to rounding.\n let matrixTime = NaN, m: number[] = [];\n const toCamera = (v: { x: number; y: number; z: number }, t: number): { x: number; y: number; z: number } => {\n if (t !== matrixTime) {\n const d = displacement(t), ex = applyPhysicalCameraRotation({ x: 1, y: 0, z: 0 }, d, \"reference-to-camera\"),\n ey = applyPhysicalCameraRotation({ x: 0, y: 1, z: 0 }, d, \"reference-to-camera\"), ez = applyPhysicalCameraRotation({ x: 0, y: 0, z: 1 }, d, \"reference-to-camera\");\n m = [ex.x, ey.x, ez.x, ex.y, ey.y, ez.y, ex.z, ey.z, ez.z];\n matrixTime = t;\n }\n return { x: m[0]! * v.x + m[1]! * v.y + m[2]! * v.z, y: m[3]! * v.x + m[4]! * v.y + m[5]! * v.z, z: m[6]! * v.x + m[7]! * v.y + m[8]! * v.z };\n };\n return {\n timeDependent,\n lookOf(xMm, yMm, t): { x: number; y: number; z: number; factor: number } {\n const image = { x: xMm, y: -yMm };\n const { ideal, distortionAreaFactor } = lensMapping ? undistortedImagePoint(lensMapping, image) : { ideal: image, distortionAreaFactor: 1 };\n let lx: number, ly: number, lz: number;\n if (model === \"rectilinear\") {\n // calculateInverseCameraRotationImageMapping: the captured ray (x/pd, y/pd, 1) in reference axes, projected at pd.\n const reference = applyPhysicalCameraRotation({ x: ideal.x / pd, y: ideal.y / pd, z: 1 }, displacement(t), \"camera-to-reference\");\n if (!(reference.z > 0)) throw new InvalidConfigurationError(\"lens.defocus: a lattice point's ray points to or behind the reference camera plane.\");\n lx = pd * (reference.x / reference.z); ly = pd * (reference.y / reference.z); lz = pd;\n } else {\n const reference = applyPhysicalCameraRotation(lensProjectionDirectionValue(model, pd, ideal.x, ideal.y), displacement(t), \"camera-to-reference\");\n lx = reference.x; ly = reference.y; lz = reference.z;\n }\n const length = hypot3(lx, ly, lz);\n const throughput = throughputAt ? throughputAt(image) : 1;\n return { x: lx / length, y: ly / length, z: lz / length, factor: throughput * distortionAreaFactor };\n },\n sensorPointOf(look, t): { x: number; y: number } | undefined {\n try {\n const c = timeDependent ? toCamera(look, t) : look;\n let ideal: { x: number; y: number };\n if (model === \"rectilinear\") {\n if (!(c.z > 0)) return undefined;\n ideal = { x: pd * (c.x / c.z), y: pd * (c.y / c.z) };\n } else ideal = lensProjectionImagePointValue(model, pd, c.x, c.y, c.z).imagePointMm;\n const image = lensMapping ? distortedImagePoint(lensMapping, ideal).pointMm : ideal;\n return Number.isFinite(image.x) && Number.isFinite(image.y) ? { x: image.x, y: -image.y } : undefined;\n } catch {\n return undefined;\n }\n }\n };\n}\n\nexport interface DefocusImageSpaceProviderInput {\n base: PlanarSceneRadianceProvider;\n geometry: PreparedDefocusImageSpaceGeometry;\n /** Each spectral node's kernel on the site lattice, (2·kernelRadius + 1)² taps, row-major (the disc, or diffraction ⊛ disc). */\n siteKernels: (wavelengthNm: number) => Float64Array;\n wavelengthsNm: readonly number[];\n kernelRadius: number;\n nativeWidth: number;\n nativeHeight: number;\n sitePitchMicrometers: number;\n /** Planar geometry of the base provider (plane distance and frame-unit scale), to find the plane point of a ray as it does. */\n distanceM: number;\n metresPerFrameUnit: number;\n /** Offsets of the query points from the site centres, in sites (+x right, +y down). Default: one zero offset. */\n queryOffsetsSites?: readonly { x: number; y: number }[];\n /** Region renders: the native sites that will be queried. Values are bit-identical to the whole render's. Default: the whole raster. */\n window?: { x: number; y: number; width: number; height: number };\n /** Most distinct request times kept per band (the temporal sample count). Default 1. */\n timesPerBand?: number;\n /** Called with the duration in ms of each band convolution (diagnostics only). */\n onConvolution?: (milliseconds: number) => void;\n /**\n * #564: a defocus kernel above the direct radius, convolved by runs in fixed tiles (`large-defocus-lattice.ts`), with each\n * node's diffraction kernel after it; used instead of `siteKernels` (`kernelRadius` is then unused).\n */\n largeKernel?: LargeDefocusKernel;\n /** #553: a field-varying kernel by zones (the cat's eye of lens.defocus), gathered instead of `siteKernels`, the same at every node. */\n fieldZones?: SiteKernelFieldZones;\n}\n\n/** Internal (not exported from the package): the base provider with the defocus disc applied in image space (#548). */\nexport function createDefocusImageSpaceProvider(input: DefocusImageSpaceProviderInput): PlanarSceneRadianceProvider {\n const { base, geometry, wavelengthsNm, nativeWidth: W, nativeHeight: H, kernelRadius: R } = input;\n const mmPerSite = input.sitePitchMicrometers / 1000;\n const index = new Map(wavelengthsNm.map((nm, i) => [nm, i]));\n const offsets = input.queryOffsetsSites ?? [{ x: 0, y: 0 }];\n const fraction = (value: number): number => { const f = value - Math.floor(value); return f > 1 - 1e-6 ? 0 : f < 1e-6 ? 0 : f; };\n const shifts: { x: number; y: number }[] = [];\n for (const o of offsets) {\n const f = { x: fraction(o.x), y: fraction(o.y) };\n if (!shifts.some((s) => Math.abs(s.x - f.x) <= 1e-6 && Math.abs(s.y - f.y) <= 1e-6)) shifts.push(f);\n }\n const M = Math.max(0, ...offsets.map((o) => Math.ceil(Math.max(Math.abs(o.x), Math.abs(o.y)) - 1e-6)));\n const LW = W + 2 * M, LH = H + 2 * M;\n const win = input.window ?? { x: 0, y: 0, width: W, height: H };\n const lx0 = Math.max(0, win.x), lx1 = Math.min(LW, win.x + win.width + 2 * M);\n const ly0 = Math.max(0, win.y), ly1 = Math.min(LH, win.y + win.height + 2 * M);\n if (!(lx0 < lx1 && ly0 < ly1)) throw new InvalidConfigurationError(\"Defocus window must overlap the native raster.\");\n const NW = lx1 - lx0, gridWidth = NW + 2 * R;\n const large = input.largeKernel;\n const kernels = large ? [] : wavelengthsNm.map((nm) => checkedSiteKernel(input.siteKernels(nm), R));\n const taps = kernels.map((kernel) => kernelTaps(kernel, R, gridWidth));\n const zonedGather = input.fieldZones ? createZonedGather(input.fieldZones, R, gridWidth, W, H, M) : undefined;\n const sharedKernel = !large && (zonedGather !== undefined || kernels.every((kernel) => kernel === kernels[0]));\n const scale = input.metresPerFrameUnit, distance = input.distanceM;\n const materialAt = base.chartMaterialAt?.bind(base), materialRadiance = base.materialRadiance?.bind(base);\n const now = (): number => globalThis.performance?.now() ?? Date.now();\n // Lattice point (li, lj) of shift s, as a native sensor point in mm (+Y down): site centre plus the shift.\n const xMmOf = (li: number, s: { x: number }): number => (li - M + 0.5 + s.x - W / 2) * mmPerSite;\n const yMmOf = (lj: number, s: { y: number }): number => (lj - M + 0.5 + s.y - H / 2) * mmPerSite;\n // Bands per time (LRU over (time, band)): values[shift][node] holds G_t / F at the band's own lattice points.\n const cache = new Map<string, Float64Array[][]>();\n const capacity = CACHED_BANDS * Math.max(1, input.timesPerBand ?? 1);\n // The last band read, so consecutive queries of one band skip the cache key (most queries).\n let lastBand = -1, lastTime = NaN, lastValues: Float64Array[][] | undefined;\n function band(b: number, time: number): Float64Array[][] {\n if (b === lastBand && time === lastTime) return lastValues!;\n const values = bandOf(b, time);\n lastBand = b; lastTime = time; lastValues = values;\n return values;\n }\n function bandOf(b: number, time: number): Float64Array[][] {\n const key = time + \":\" + b, cached = cache.get(key);\n if (cached) { cache.delete(key); cache.set(key, cached); return cached; }\n const started = input.onConvolution ? now() : 0;\n const y0 = ly0 + b * BAND_ROWS, rows = Math.min(BAND_ROWS, ly1 - y0), gridHeight = rows + 2 * R, size = gridWidth * gridHeight;\n const values = shifts.map((shift) => {\n // Each grid point's field factor and plane point (or material), shared by the spectral nodes.\n const factor = new Float64Array(size), u = new Float64Array(size), v = new Float64Array(size);\n const material = materialAt && materialRadiance ? new Int32Array(size) : undefined;\n for (let gy = 0; gy < gridHeight; gy++) {\n const yMm = yMmOf(y0 + gy - R, shift);\n for (let gx = 0; gx < gridWidth; gx++) {\n const k = gy * gridWidth + gx, look = geometry.lookOf(xMmOf(lx0 + gx - R, shift), yMm, time);\n if (!(look.z > 0)) throw new InvalidConfigurationError(\"lens.defocus: a lattice point's ray does not point toward the scene plane.\");\n // The base provider's own plane-point arithmetic for the outgoing direction −look.\n const t = distance / look.z;\n factor[k] = look.factor; u[k] = look.x * t / scale; v[k] = look.y * t / scale;\n if (material) material[k] = materialAt!(u[k]!, v[k]!);\n }\n }\n // The band's own lattice points' factors, to answer each query with G / F.\n const own = new Float64Array(rows * NW);\n for (let y = 0; y < rows; y++) for (let x = 0; x < NW; x++) own[y * NW + x] = factor[(y + R) * gridWidth + x + R]!;\n // One kernel for every node (the disc without diffraction) and fewer materials than nodes: the convolution is linear, so\n // G_λ = Σ_m L_m(λ)·(K ⊛ F·[material = m]); one convolution per material instead of one per node, the same sum regrouped.\n if (material && sharedKernel) {\n const present = [...new Set(material)];\n if (present.length < wavelengthsNm.length) {\n const perMaterial = present.map((m) => {\n const samples = new Float64Array(size);\n for (let k = 0; k < size; k++) if (material[k] === m) samples[k] = factor[k]!;\n return zonedGather ? zonedGather(samples, lx0, y0, NW, rows) : gatherInterior(samples, taps[0]!, gridWidth, NW, rows, R);\n });\n return wavelengthsNm.map((nm) => {\n const radiance = present.map((m) => materialRadiance!(m, nm)), out = new Float64Array(rows * NW);\n for (const value of radiance) if (!(value >= 0 && value <= 2 ** 100)) throw new InvalidConfigurationError(\"Irradiance samples must be finite, non-negative and within the declared magnitude.\");\n for (let k = 0; k < out.length; k++) {\n let sum = 0;\n for (let i = 0; i < present.length; i++) sum += radiance[i]! * perMaterial[i]![k]!;\n out[k] = sum / own[k]!;\n }\n return out;\n });\n }\n }\n return wavelengthsNm.map((nm, w) => {\n const samples = new Float64Array(size);\n if (material) {\n const radiance = new Map<number, number>();\n for (let k = 0; k < size; k++) {\n const m = material[k]!;\n let value = radiance.get(m);\n if (value === undefined) { value = materialRadiance!(m, nm); radiance.set(m, value); }\n samples[k] = factor[k]! * value;\n }\n } else for (let k = 0; k < size; k++) samples[k] = factor[k]! * base.radianceAt(u[k]!, v[k]!, nm);\n const gathered = zonedGather ? zonedGather(samples, lx0, y0, NW, rows) : gatherInterior(samples, taps[w]!, gridWidth, NW, rows, R);\n for (let k = 0; k < gathered.length; k++) gathered[k] = gathered[k]! / own[k]!;\n return gathered;\n });\n });\n cache.set(key, values);\n if (cache.size > capacity) cache.delete(cache.keys().next().value!);\n if (input.onConvolution) input.onConvolution(now() - started);\n return values;\n }\n /** The lattice key ((shift·LH + lj)·LW + li) of a look direction at time t, or undefined off the lattices or outside the window. */\n function keyOf(look: { x: number; y: number; z: number }, t: number): number | undefined {\n const point = geometry.sensorPointOf(look, t);\n if (point === undefined) return undefined;\n const fi = point.x / mmPerSite + W / 2 - 0.5, fj = point.y / mmPerSite + H / 2 - 0.5;\n for (let s = 0; s < shifts.length; s++) {\n const shift = shifts[s]!, i = Math.round(fi - shift.x), j = Math.round(fj - shift.y);\n if (Math.abs(fi - shift.x - i) > LATTICE_TOLERANCE_SITES || Math.abs(fj - shift.y - j) > LATTICE_TOLERANCE_SITES) continue;\n const li = i + M, lj = j + M;\n if (li < lx0 || lj < ly0 || li >= lx1 || lj >= ly1) return undefined;\n return (s * LH + lj) * LW + li;\n }\n return undefined;\n }\n function valueOf(key: number, t: number, nm: number): number {\n const w = index.get(nm);\n if (w === undefined) throw new InvalidConfigurationError(\"Defocus query is off the sensor site lattice; the image-space convolution does not apply.\");\n const li = key % LW, rest = (key - li) / LW, lj = rest % LH, s = (rest - lj) / LH;\n if (large) return largeValue(s, t, w, li, lj);\n return band(Math.floor((lj - ly0) / BAND_ROWS), t)[s]![w]![((lj - ly0) % BAND_ROWS) * NW + li - lx0]!;\n }\n // #564: one run lattice per (time, shift) of the samples F·L at the lattice points, and the own field factors F by tile, so a\n // query is answered with (K ⊛ D ⊛ F·L) / F as on the band path.\n const largeLattices = new Map<string, { lattice: LargeDefocusNodeLattice; own: Map<number, Float64Array> }>();\n const largeLatticeCount = shifts.length * Math.max(1, input.timesPerBand ?? 1);\n // Lattice points at most `reach` beyond the lattice feed queried values: the defocus kernel's radius plus the diffraction kernel's.\n const reach = large ? large.runs.radius + (large.diffraction ? large.diffraction.radius : 0) : 0;\n function largeValue(s: number, time: number, w: number, li: number, lj: number): number {\n const key = time + \":\" + s;\n let entry = largeLattices.get(key);\n if (!entry) {\n const shift = shifts[s]!;\n const lattice = createLargeDefocusNodeLattice({ kernel: large!, wavelengthsNm, capacityBytes: LARGE_DEFOCUS_CACHE_BYTES / largeLatticeCount, ...(input.onConvolution ? { onTile: input.onConvolution } : {}),\n source: (x0, y0, width, height) => {\n const size = width * height, factor = new Float64Array(size), u = new Float64Array(size), v = new Float64Array(size);\n const material = materialAt && materialRadiance ? new Int32Array(size) : undefined, beyond = new Uint8Array(size);\n for (let y = 0; y < height; y++) {\n const yMm = yMmOf(y0 + y, shift);\n for (let x = 0; x < width; x++) {\n const k = y * width + x;\n // A fixed tile's source reaches past the lattice: points beyond its reach feed no queried value, so they are 0 and never\n // mapped (the lens profiles are checked only up to the reach).\n if (x0 + x < -reach || x0 + x >= LW + reach || y0 + y < -reach || y0 + y >= LH + reach) { beyond[k] = 1; continue; }\n const look = geometry.lookOf(xMmOf(x0 + x, shift), yMm, time);\n if (!(look.z > 0)) throw new InvalidConfigurationError(\"lens.defocus: a lattice point's ray does not point toward the scene plane.\");\n const t = distance / look.z;\n factor[k] = look.factor; u[k] = look.x * t / scale; v[k] = look.y * t / scale;\n if (material) material[k] = materialAt!(u[k]!, v[k]!);\n }\n }\n return (node: number): Float64Array => {\n const nm = wavelengthsNm[node]!, samples = new Float64Array(size);\n if (material) {\n const radiance = new Map<number, number>();\n for (let k = 0; k < size; k++) {\n if (beyond[k]) continue;\n const m = material[k]!;\n let value = radiance.get(m);\n if (value === undefined) { value = materialRadiance!(m, nm); radiance.set(m, value); }\n samples[k] = factor[k]! * value;\n }\n } else for (let k = 0; k < size; k++) if (!beyond[k]) samples[k] = factor[k]! * base.radianceAt(u[k]!, v[k]!, nm);\n return samples;\n };\n } });\n entry = { lattice, own: new Map() };\n largeLattices.set(key, entry);\n if (largeLattices.size > largeLatticeCount) largeLattices.delete(largeLattices.keys().next().value!);\n }\n // The own factor of the lattice point, by 64-point tiles (kept for the request: 8 bytes per lattice point read).\n const T = 64, tx = Math.floor(li / T), ty = Math.floor(lj / T), tileKey = ty * 1048576 + tx;\n let own = entry.own.get(tileKey);\n if (!own) {\n own = new Float64Array(T * T);\n const shift = shifts[s]!;\n // Only the lattice's own points are queried; the rest of the tile is never read (and may lie beyond the lens profiles).\n for (let y = 0; y < T && ty * T + y < LH; y++) { const yMm = yMmOf(ty * T + y, shift); for (let x = 0; x < T && tx * T + x < LW; x++) own[y * T + x] = geometry.lookOf(xMmOf(tx * T + x, shift), yMm, time).factor; }\n entry.own.set(tileKey, own);\n }\n return entry.lattice.valueAt(w, li, lj) / own[(lj - ty * T) * T + li - tx * T]!;\n }\n function blurredAt(look: { x: number; y: number; z: number }, time: number, nm: number): number {\n const t = geometry.timeDependent ? time : 0, key = keyOf(look, t);\n if (key === undefined) throw new InvalidConfigurationError(\"Defocus query is off the sensor site lattice; the image-space convolution does not apply.\");\n return valueOf(key, t, nm);\n }\n const baseEvaluate = base.evaluateRadiance;\n const evaluateRadiance = (request: Readonly<SceneRadianceEvaluationRequest>): SceneRadianceEvaluationResult => {\n const result = baseEvaluate.call(base, request), o = (request.target as { outgoingDirectionUnitVector: { x: number; y: number; z: number } }).outgoingDirectionUnitVector;\n return { ...result, spectralRadianceWattsPerSquareMeterSteradianNanometer: blurredAt({ x: -o.x, y: -o.y, z: -o.z }, request.timeSecondsFromExposureStart, request.wavelengthNanometers) };\n };\n // The result is the base result with only its radiance replaced, so an engine-built base evaluator keeps its mark. Its radiance is\n // a pure function of the lattice key (and, with rotation, the request time) and the wavelength, so the lean executor may read it by\n // key, as for the diffraction provider.\n if (isInternalSceneRadianceEvaluator(baseEvaluate)) {\n markInternalSceneRadianceEvaluator(evaluateRadiance);\n // With rotation the key also carries the request time, as an index into the distinct times seen (one per temporal midpoint).\n const times: number[] = [], timeIndex = new Map<number, number>(), latticeKeys = shifts.length * LH * LW;\n registerInternalRadianceAccess(evaluateRadiance, {\n tabulated: false,\n keyOfDirection(o, time): number | undefined {\n const t = geometry.timeDependent ? time : 0, key = keyOf({ x: -o.x, y: -o.y, z: -o.z }, t);\n if (key === undefined) return undefined;\n let index = timeIndex.get(t);\n if (index === undefined) { index = times.length; times.push(t); timeIndex.set(t, index); }\n return index * latticeKeys + key;\n },\n radianceOfKey(key, nm): number {\n const index = Math.floor(key / latticeKeys);\n return valueOf(key - index * latticeKeys, times[index]!, nm);\n }\n });\n }\n return {\n sceneId: base.sceneId, providerProfileId: base.providerProfileId, radianceAt: base.radianceAt,\n evaluateRadiance,\n evaluateApertureRadiance(): SceneRadianceEvaluationResult {\n throw new InvalidConfigurationError(\"Defocus by image-space convolution does not take pupil rays.\");\n }\n };\n}\n\n/** Field-variation bounds of the image-space disc for one request (#548), recorded in the `lens.defocus` assumption. */\nexport interface DefocusFieldVariation {\n /** Sensor points the bounds were evaluated at: a grid of this many points per side over the native raster, edges included. */\n gridPointsPerSide: number;\n /**\n * Camera rotation (pitch or yaw tilts the scene plane in the camera frame): the largest change of the disc diameter, in\n * sites, between the axial depth of each scene point in the rotated camera frame and the subject distance, over the grid and\n * the rendered temporal midpoints. 0 for roll only; null without rotation.\n */\n rotationMaximumDiameterChangeSites: number | null;\n /**\n * Distortion: the largest deviation from 1 of the local scale of the distortion map (singular values of d distorted / d ideal)\n * over the grid: the relative disc-size difference to a model that blurs the ideal image and then distorts it. Null without distortion.\n */\n distortionMaximumLocalScaleDeviation: number | null;\n /**\n * A non-rectilinear projection: the largest change of the disc diameter, in sites, between the distance along each scene\n * point's ray and its axial depth (the thin-lens model uses the axial depth). Null for the rectilinear projection.\n */\n projectionMaximumDiameterChangeSites: number | null;\n}\n\n/** Internal: {@link DefocusFieldVariation} on a 9 × 9 grid of sensor points (the extremes of these smooth maps lie on the frame's edges). */\nexport function calculateDefocusFieldVariation(input: { geometry: PreparedDefocusImageSpaceGeometry; lensMapping?: PreparedEnvironmentLensFieldMapping;\n focalLengthMm: number; fNumber: number; focusDistanceM: number; subjectDistanceM: number; pitchMicrometers: number; nativeWidth: number; nativeHeight: number;\n angularVelocityRadPerSec: CameraAngularVelocityRadPerSec; temporalMidpointsSeconds: readonly number[]; diameterSites: number;\n discAt: (subjectDistanceM: number) => number }): DefocusFieldVariation {\n const { geometry, lensMapping, pitchMicrometers: pitch, nativeWidth: W, nativeHeight: H, subjectDistanceM: d, diameterSites, discAt } = input;\n const G = 9, points: { x: number; y: number }[] = [];\n for (let j = 0; j < G; j++) for (let i = 0; i < G; i++) points.push({ x: (i / (G - 1) - 0.5) * W * pitch / 1000, y: (j / (G - 1) - 0.5) * H * pitch / 1000 });\n let rotation: number | null = null;\n if (geometry.timeDependent) {\n rotation = 0;\n const omega = input.angularVelocityRadPerSec;\n for (const t of input.temporalMidpointsSeconds) {\n // The camera's optical axis at t in the reference axes; a scene point's axial depth in the rotated camera is P·axis.\n const axis = applyPhysicalCameraRotation({ x: 0, y: 0, z: 1 }, { pitch: omega.pitch * t, yaw: omega.yaw * t, roll: omega.roll * t }, \"camera-to-reference\");\n for (const p of points) {\n const look = geometry.lookOf(p.x, p.y, t), reach = d / look.z;\n const depth = reach * (look.x * axis.x + look.y * axis.y + look.z * axis.z);\n rotation = Math.max(rotation, Math.abs(discAt(depth) - diameterSites));\n }\n }\n }\n let distortion: number | null = null;\n if (lensMapping && lensMapping.mapping.distortion.kind !== \"none\") {\n distortion = 0;\n for (const p of points) {\n const scales = distortedImagePoint(lensMapping, undistortedImagePoint(lensMapping, { x: p.x, y: -p.y }).ideal);\n distortion = Math.max(distortion, scales.largestScale - 1, 1 - scales.smallestScale);\n }\n }\n let projection: number | null = null;\n if (lensMapping && lensMapping.mapping.projectionModel !== \"rectilinear\") {\n projection = 0;\n for (const p of points) {\n const look = geometry.lookOf(p.x, p.y, 0);\n projection = Math.max(projection, Math.abs(discAt(d / look.z) - diameterSites));\n }\n }\n return { gridPointsPerSide: G, rotationMaximumDiameterChangeSites: rotation, distortionMaximumLocalScaleDeviation: distortion, projectionMaximumDiameterChangeSites: projection };\n}\n"]}
1
+ {"version":3,"file":"defocus-image-space-provider.js","sourceRoot":"","sources":["../../src/facade/defocus-image-space-provider.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,gIAAgI;AAChI,4HAA4H;AAC5H,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,gCAAgC,EAAE,kCAAkC,EAAE,8BAA8B,EAAE,MAAM,wCAAwC,CAAC;AAE9J,OAAO,EAAE,uBAAuB,EAAE,4BAA4B,EAAE,6BAA6B,EAA4B,MAAM,8BAA8B,CAAC;AAC9J,OAAO,EAAE,2BAA2B,EAAE,2BAA2B,EAAuC,MAAM,8BAA8B,CAAC;AAC7I,OAAO,EAAE,uCAAuC,EAAsC,MAAM,sCAAsC,CAAC;AACnI,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAA4C,MAAM,uCAAuC,CAAC;AAC7I,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,cAAc,EAAE,UA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G,IAAI,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC;QAClF,CAAC;IACH,CAAC;IACD,OAAO,EAAE,iBAAiB,EAAE,CAAC,EAAE,kCAAkC,EAAE,QAAQ,EAAE,oCAAoC,EAAE,UAAU,EAAE,oCAAoC,EAAE,UAAU,EAAE,CAAC;AACpL,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * `simulateCapture`'s `lens.defocus` out of focus together with a lens field mapping (`lens.projection`,\n * `lens.distortion`), `lens.vignetting` or camera rotation (#548): the geometric defocus disc applied in image space,\n * on the site lattice of the sensor, instead of on the scene plane.\n *\n * Why the object-space path does not apply. `createDiffractedPlanarProvider` convolves the scene radiance on the plane\n * lattice that the sites see through one linear map (a still, rectilinear, distortion-free camera with the same\n * radiance-to-irradiance factor everywhere). A projection, a distortion or a rotation makes the map from sensor points\n * to plane points non-linear (or time-dependent), and vignetting makes the factor vary over the field, so the disc on\n * the plane is no longer the disc on the sensor.\n *\n * The image-space model. The environment PSF quadrature (`calculateSensorPsfIrradianceQuadrature`, the per-tap path\n * `lens.diffraction` falls back to) defines a sensor-plane PSF K as\n * E(q, λ, t) = Σ_k K(k)·F(s_k)·C·L(D_t(s_k), λ),\n * with s_k = q + k·p the tap source points on the sensor (p the site pitch), D_t the scene ray of a sensor point at\n * time t (inverse distortion, the declared projection, the camera rotation at t), F = T·A the field factor (vignetting\n * throughput T, applied once before the PSF spreads the light, and the distortion area factor A = 1/det J) and C the\n * paraxial radiance-to-irradiance factor π/(4·N_w²), the same everywhere. With K the defocus disc sampled on the site\n * lattice (`createDefocusDiscSiteKernel`), every source point of a site-centre query is another lattice point, so\n * E(q, λ, t) = C·G_t(q, λ), G_t = K ⊛ (F·L∘D_t) sampled on the lattice,\n * the same sum in a different floating-point order. This provider computes G_t once per spectral node and time on the\n * sensor lattice (in row bands, as the diffraction provider does) and answers the query of lattice point q at time t with\n * G_t(q, λ) / F(q); the environment multiplies by F(q)·C again, so each site gets C·G_t(q, λ). For the still,\n * rectilinear, distortion-free camera without vignetting it is the object-space convolution (F = 1 and D linear).\n *\n * The lattices. As in the diffraction provider, a pixel aperture or anti-aliasing spots add query offsets; each distinct\n * fractional offset gets its own shifted lattice of sensor points, and every tap of a query on one lattice is on the same\n * lattice. A query is located on its lattice by mapping its scene ray back to the sensor (camera rotation inverted at the\n * request's time, the forward projection, the forward distortion), within 1e-4 site; a query that lands on no lattice point\n * is refused rather than approximated.\n *\n * Time. With camera rotation each environment temporal midpoint is a still camera, so the disc is applied to that\n * instant's image in that instant's frame: one G_t per distinct request time, cached per band. Without rotation the image\n * does not depend on time and one G is kept. The facade refuses rotation with a rolling shutter (each row's instants differ).\n *\n * What is approximate is the disc itself (`lens.defocus` labels it; the facade records the field-variation bounds of\n * each combination), not this evaluation of it.\n */\n\n// #564: a defocus kernel above 64 sites (`largeKernel`) takes the run lattice of large-defocus-lattice.ts instead of the bands:\n// the samples F·L at the same lattice points, convolved by runs in fixed tiles, then divided by each queried point's own F.\nimport { InvalidConfigurationError } from \"../core/configuration-error.js\";\nimport { hypot3 } from \"../core/portable-math.js\";\nimport { isInternalSceneRadianceEvaluator, markInternalSceneRadianceEvaluator, registerInternalRadianceAccess } from \"../core/internal-radiance-evaluator.js\";\nimport type { SceneRadianceEvaluationRequest, SceneRadianceEvaluationResult } from \"../schema/scene-radiance.js\";\nimport { insideRadialImageCircle, lensProjectionDirectionValue, lensProjectionImagePointValue, type LensProjectionModel } from \"../camera/lens-projection.js\";\nimport { applyPhysicalCameraRotation, resolveProjectionDistanceMm, type CameraAngularVelocityRadPerSec } from \"../motion/camera-rotation.js\";\nimport { prepareIlluminationVignettingThroughput, type IlluminationVignettingProfile } from \"../optics/illumination-vignetting.js\";\nimport { distortedImagePoint, undistortedImagePoint, type PreparedEnvironmentLensFieldMapping } from \"../optics/sensor-environment-query.js\";\nimport { checkedSiteKernel, createZonedGather, gatherInterior, kernelTaps, type SiteKernelFieldZones } from \"./diffraction-provider.js\";\nimport type { PlanarSceneRadianceProvider } from \"./scene-radiance.js\";\nimport { LARGE_DEFOCUS_CACHE_BYTES, createLargeDefocusNodeLattice, type LargeDefocusKernel, type LargeDefocusNodeLattice } from \"./large-defocus-lattice.js\";\n\n/** Rows of native sites per band; bands kept per time. Banding changes memory only, never values. */\nconst BAND_ROWS = 32;\nconst CACHED_BANDS = 2;\nconst LATTICE_TOLERANCE_SITES = 1e-4;\n\n/** The camera geometry the environment uses for each site query (the same options as the site inputs). */\nexport interface DefocusImageSpaceGeometry {\n focalLengthMm: number;\n focusDistanceM: number;\n angularVelocityRadPerSec: CameraAngularVelocityRadPerSec;\n /** The site inputs' `lensFieldMapping`, prepared; omitted for the ideal rectilinear, distortion-free mapping. */\n lensMapping?: PreparedEnvironmentLensFieldMapping;\n /** The site inputs' radial-illumination-vignetting profile; omitted for unity field throughput. */\n vignetting?: IlluminationVignettingProfile;\n}\n\n/** Internal: the scene ray and field factor of sensor points, and the sensor point of a scene ray, for one geometry. */\nexport interface PreparedDefocusImageSpaceGeometry {\n /**\n * The unit look direction (toward the scene, reference camera axes at exposure start) of native sensor point (x, y) mm\n * (+X right, +Y down) at time t, and its field factor F = T·A (vignetting throughput × distortion area factor).\n */\n lookOf(xMm: number, yMm: number, timeSeconds: number): { x: number; y: number; z: number; factor: number };\n /** The native sensor point (mm, +Y down) whose scene ray at time t is the look direction; undefined outside the mapping. */\n sensorPointOf(look: { x: number; y: number; z: number }, timeSeconds: number): { x: number; y: number } | undefined;\n /** True with camera rotation: the ray of a sensor point depends on time. */\n timeDependent: boolean;\n}\n\n/** Internal: prepares {@link PreparedDefocusImageSpaceGeometry} with the environment's own conventions and arithmetic. */\nexport function prepareDefocusImageSpaceGeometry(geometry: DefocusImageSpaceGeometry): PreparedDefocusImageSpaceGeometry {\n const { focalLengthMm, focusDistanceM, angularVelocityRadPerSec: omega, lensMapping, vignetting } = geometry;\n // The projection scale: the thin-lens image distance at the finite focus, for every projection model (the environment's).\n const pd = resolveProjectionDistanceMm(focalLengthMm, focusDistanceM).projectionDistanceMm;\n const model: LensProjectionModel = lensMapping?.mapping.projectionModel ?? \"rectilinear\";\n // #569: with \"backward-ray\" (catalogue fisheyes), a point outside the image circle looks straight back, as the environment's mapped query does.\n const backward = lensMapping?.mapping.outsideImageCircle === \"backward-ray\";\n const timeDependent = omega.pitch !== 0 || omega.yaw !== 0 || omega.roll !== 0;\n // calculateIlluminationVignetting's throughput with the profile validated once (#563: the same numbers, without a result envelope per point).\n const throughputAt = vignetting ? prepareIlluminationVignettingThroughput(vignetting) : undefined;\n const displacement = (t: number): { pitch: number; yaw: number; roll: number } =>\n timeDependent ? { pitch: omega.pitch * t, yaw: omega.yaw * t, roll: omega.roll * t } : { pitch: 0, yaw: 0, roll: 0 };\n // The reference-to-camera rotation at the last time asked, as a matrix (its columns: the rotated basis vectors), so a lattice\n // lookup costs no trigonometry; the rotation is linear, so this equals rotating the vector, up to rounding.\n let matrixTime = NaN, m: number[] = [];\n const toCamera = (v: { x: number; y: number; z: number }, t: number): { x: number; y: number; z: number } => {\n if (t !== matrixTime) {\n const d = displacement(t), ex = applyPhysicalCameraRotation({ x: 1, y: 0, z: 0 }, d, \"reference-to-camera\"),\n ey = applyPhysicalCameraRotation({ x: 0, y: 1, z: 0 }, d, \"reference-to-camera\"), ez = applyPhysicalCameraRotation({ x: 0, y: 0, z: 1 }, d, \"reference-to-camera\");\n m = [ex.x, ey.x, ez.x, ex.y, ey.y, ez.y, ex.z, ey.z, ez.z];\n matrixTime = t;\n }\n return { x: m[0]! * v.x + m[1]! * v.y + m[2]! * v.z, y: m[3]! * v.x + m[4]! * v.y + m[5]! * v.z, z: m[6]! * v.x + m[7]! * v.y + m[8]! * v.z };\n };\n return {\n timeDependent,\n lookOf(xMm, yMm, t): { x: number; y: number; z: number; factor: number } {\n const image = { x: xMm, y: -yMm };\n const { ideal, distortionAreaFactor } = lensMapping ? undistortedImagePoint(lensMapping, image) : { ideal: image, distortionAreaFactor: 1 };\n let lx: number, ly: number, lz: number;\n if (model === \"rectilinear\") {\n // calculateInverseCameraRotationImageMapping: the captured ray (x/pd, y/pd, 1) in reference axes, projected at pd.\n const reference = applyPhysicalCameraRotation({ x: ideal.x / pd, y: ideal.y / pd, z: 1 }, displacement(t), \"camera-to-reference\");\n if (!(reference.z > 0)) throw new InvalidConfigurationError(\"lens.defocus: a lattice point's ray points to or behind the reference camera plane.\");\n lx = pd * (reference.x / reference.z); ly = pd * (reference.y / reference.z); lz = pd;\n } else {\n const reference = applyPhysicalCameraRotation(backward && !insideRadialImageCircle(model, pd, Math.hypot(ideal.x, ideal.y)) ? { x: 0, y: 0, z: -1 } :\n lensProjectionDirectionValue(model, pd, ideal.x, ideal.y), displacement(t), \"camera-to-reference\");\n lx = reference.x; ly = reference.y; lz = reference.z;\n }\n const length = hypot3(lx, ly, lz);\n const throughput = throughputAt ? throughputAt(image) : 1;\n return { x: lx / length, y: ly / length, z: lz / length, factor: throughput * distortionAreaFactor };\n },\n sensorPointOf(look, t): { x: number; y: number } | undefined {\n try {\n const c = timeDependent ? toCamera(look, t) : look;\n let ideal: { x: number; y: number };\n if (model === \"rectilinear\") {\n if (!(c.z > 0)) return undefined;\n ideal = { x: pd * (c.x / c.z), y: pd * (c.y / c.z) };\n } else ideal = lensProjectionImagePointValue(model, pd, c.x, c.y, c.z).imagePointMm;\n const image = lensMapping ? distortedImagePoint(lensMapping, ideal).pointMm : ideal;\n return Number.isFinite(image.x) && Number.isFinite(image.y) ? { x: image.x, y: -image.y } : undefined;\n } catch {\n return undefined;\n }\n }\n };\n}\n\nexport interface DefocusImageSpaceProviderInput {\n base: PlanarSceneRadianceProvider;\n geometry: PreparedDefocusImageSpaceGeometry;\n /** Each spectral node's kernel on the site lattice, (2·kernelRadius + 1)² taps, row-major (the disc, or diffraction ⊛ disc). */\n siteKernels: (wavelengthNm: number) => Float64Array;\n wavelengthsNm: readonly number[];\n kernelRadius: number;\n nativeWidth: number;\n nativeHeight: number;\n sitePitchMicrometers: number;\n /** Planar geometry of the base provider (plane distance and frame-unit scale), to find the plane point of a ray as it does. */\n distanceM: number;\n metresPerFrameUnit: number;\n /** Offsets of the query points from the site centres, in sites (+x right, +y down). Default: one zero offset. */\n queryOffsetsSites?: readonly { x: number; y: number }[];\n /** Region renders: the native sites that will be queried. Values are bit-identical to the whole render's. Default: the whole raster. */\n window?: { x: number; y: number; width: number; height: number };\n /** Most distinct request times kept per band (the temporal sample count). Default 1. */\n timesPerBand?: number;\n /** Called with the duration in ms of each band convolution (diagnostics only). */\n onConvolution?: (milliseconds: number) => void;\n /**\n * #564: a defocus kernel above the direct radius, convolved by runs in fixed tiles (`large-defocus-lattice.ts`), with each\n * node's diffraction kernel after it; used instead of `siteKernels` (`kernelRadius` is then unused).\n */\n largeKernel?: LargeDefocusKernel;\n /** #553: a field-varying kernel by zones (the cat's eye of lens.defocus), gathered instead of `siteKernels`, the same at every node. */\n fieldZones?: SiteKernelFieldZones;\n}\n\n/** Internal (not exported from the package): the base provider with the defocus disc applied in image space (#548). */\nexport function createDefocusImageSpaceProvider(input: DefocusImageSpaceProviderInput): PlanarSceneRadianceProvider {\n const { base, geometry, wavelengthsNm, nativeWidth: W, nativeHeight: H, kernelRadius: R } = input;\n const mmPerSite = input.sitePitchMicrometers / 1000;\n const index = new Map(wavelengthsNm.map((nm, i) => [nm, i]));\n const offsets = input.queryOffsetsSites ?? [{ x: 0, y: 0 }];\n const fraction = (value: number): number => { const f = value - Math.floor(value); return f > 1 - 1e-6 ? 0 : f < 1e-6 ? 0 : f; };\n const shifts: { x: number; y: number }[] = [];\n for (const o of offsets) {\n const f = { x: fraction(o.x), y: fraction(o.y) };\n if (!shifts.some((s) => Math.abs(s.x - f.x) <= 1e-6 && Math.abs(s.y - f.y) <= 1e-6)) shifts.push(f);\n }\n const M = Math.max(0, ...offsets.map((o) => Math.ceil(Math.max(Math.abs(o.x), Math.abs(o.y)) - 1e-6)));\n const LW = W + 2 * M, LH = H + 2 * M;\n const win = input.window ?? { x: 0, y: 0, width: W, height: H };\n const lx0 = Math.max(0, win.x), lx1 = Math.min(LW, win.x + win.width + 2 * M);\n const ly0 = Math.max(0, win.y), ly1 = Math.min(LH, win.y + win.height + 2 * M);\n if (!(lx0 < lx1 && ly0 < ly1)) throw new InvalidConfigurationError(\"Defocus window must overlap the native raster.\");\n const NW = lx1 - lx0, gridWidth = NW + 2 * R;\n const large = input.largeKernel;\n const kernels = large ? [] : wavelengthsNm.map((nm) => checkedSiteKernel(input.siteKernels(nm), R));\n const taps = kernels.map((kernel) => kernelTaps(kernel, R, gridWidth));\n const zonedGather = input.fieldZones ? createZonedGather(input.fieldZones, R, gridWidth, W, H, M) : undefined;\n const sharedKernel = !large && (zonedGather !== undefined || kernels.every((kernel) => kernel === kernels[0]));\n const scale = input.metresPerFrameUnit, distance = input.distanceM;\n const materialAt = base.chartMaterialAt?.bind(base), materialRadiance = base.materialRadiance?.bind(base);\n const now = (): number => globalThis.performance?.now() ?? Date.now();\n // Lattice point (li, lj) of shift s, as a native sensor point in mm (+Y down): site centre plus the shift.\n const xMmOf = (li: number, s: { x: number }): number => (li - M + 0.5 + s.x - W / 2) * mmPerSite;\n const yMmOf = (lj: number, s: { y: number }): number => (lj - M + 0.5 + s.y - H / 2) * mmPerSite;\n // Bands per time (LRU over (time, band)): values[shift][node] holds G_t / F at the band's own lattice points.\n const cache = new Map<string, Float64Array[][]>();\n const capacity = CACHED_BANDS * Math.max(1, input.timesPerBand ?? 1);\n // The last band read, so consecutive queries of one band skip the cache key (most queries).\n let lastBand = -1, lastTime = NaN, lastValues: Float64Array[][] | undefined;\n function band(b: number, time: number): Float64Array[][] {\n if (b === lastBand && time === lastTime) return lastValues!;\n const values = bandOf(b, time);\n lastBand = b; lastTime = time; lastValues = values;\n return values;\n }\n function bandOf(b: number, time: number): Float64Array[][] {\n const key = time + \":\" + b, cached = cache.get(key);\n if (cached) { cache.delete(key); cache.set(key, cached); return cached; }\n const started = input.onConvolution ? now() : 0;\n const y0 = ly0 + b * BAND_ROWS, rows = Math.min(BAND_ROWS, ly1 - y0), gridHeight = rows + 2 * R, size = gridWidth * gridHeight;\n const values = shifts.map((shift) => {\n // Each grid point's field factor and plane point (or material), shared by the spectral nodes.\n const factor = new Float64Array(size), u = new Float64Array(size), v = new Float64Array(size);\n const material = materialAt && materialRadiance ? new Int32Array(size) : undefined;\n for (let gy = 0; gy < gridHeight; gy++) {\n const yMm = yMmOf(y0 + gy - R, shift);\n for (let gx = 0; gx < gridWidth; gx++) {\n const k = gy * gridWidth + gx, look = geometry.lookOf(xMmOf(lx0 + gx - R, shift), yMm, time);\n if (!(look.z > 0)) throw new InvalidConfigurationError(\"lens.defocus: a lattice point's ray does not point toward the scene plane.\");\n // The base provider's own plane-point arithmetic for the outgoing direction −look.\n const t = distance / look.z;\n factor[k] = look.factor; u[k] = look.x * t / scale; v[k] = look.y * t / scale;\n if (material) material[k] = materialAt!(u[k]!, v[k]!);\n }\n }\n // The band's own lattice points' factors, to answer each query with G / F.\n const own = new Float64Array(rows * NW);\n for (let y = 0; y < rows; y++) for (let x = 0; x < NW; x++) own[y * NW + x] = factor[(y + R) * gridWidth + x + R]!;\n // One kernel for every node (the disc without diffraction) and fewer materials than nodes: the convolution is linear, so\n // G_λ = Σ_m L_m(λ)·(K ⊛ F·[material = m]); one convolution per material instead of one per node, the same sum regrouped.\n if (material && sharedKernel) {\n const present = [...new Set(material)];\n if (present.length < wavelengthsNm.length) {\n const perMaterial = present.map((m) => {\n const samples = new Float64Array(size);\n for (let k = 0; k < size; k++) if (material[k] === m) samples[k] = factor[k]!;\n return zonedGather ? zonedGather(samples, lx0, y0, NW, rows) : gatherInterior(samples, taps[0]!, gridWidth, NW, rows, R);\n });\n return wavelengthsNm.map((nm) => {\n const radiance = present.map((m) => materialRadiance!(m, nm)), out = new Float64Array(rows * NW);\n for (const value of radiance) if (!(value >= 0 && value <= 2 ** 100)) throw new InvalidConfigurationError(\"Irradiance samples must be finite, non-negative and within the declared magnitude.\");\n for (let k = 0; k < out.length; k++) {\n let sum = 0;\n for (let i = 0; i < present.length; i++) sum += radiance[i]! * perMaterial[i]![k]!;\n out[k] = sum / own[k]!;\n }\n return out;\n });\n }\n }\n return wavelengthsNm.map((nm, w) => {\n const samples = new Float64Array(size);\n if (material) {\n const radiance = new Map<number, number>();\n for (let k = 0; k < size; k++) {\n const m = material[k]!;\n let value = radiance.get(m);\n if (value === undefined) { value = materialRadiance!(m, nm); radiance.set(m, value); }\n samples[k] = factor[k]! * value;\n }\n } else for (let k = 0; k < size; k++) samples[k] = factor[k]! * base.radianceAt(u[k]!, v[k]!, nm);\n const gathered = zonedGather ? zonedGather(samples, lx0, y0, NW, rows) : gatherInterior(samples, taps[w]!, gridWidth, NW, rows, R);\n for (let k = 0; k < gathered.length; k++) gathered[k] = gathered[k]! / own[k]!;\n return gathered;\n });\n });\n cache.set(key, values);\n if (cache.size > capacity) cache.delete(cache.keys().next().value!);\n if (input.onConvolution) input.onConvolution(now() - started);\n return values;\n }\n /** The lattice key ((shift·LH + lj)·LW + li) of a look direction at time t, or undefined off the lattices or outside the window. */\n function keyOf(look: { x: number; y: number; z: number }, t: number): number | undefined {\n const point = geometry.sensorPointOf(look, t);\n if (point === undefined) return undefined;\n const fi = point.x / mmPerSite + W / 2 - 0.5, fj = point.y / mmPerSite + H / 2 - 0.5;\n for (let s = 0; s < shifts.length; s++) {\n const shift = shifts[s]!, i = Math.round(fi - shift.x), j = Math.round(fj - shift.y);\n if (Math.abs(fi - shift.x - i) > LATTICE_TOLERANCE_SITES || Math.abs(fj - shift.y - j) > LATTICE_TOLERANCE_SITES) continue;\n const li = i + M, lj = j + M;\n if (li < lx0 || lj < ly0 || li >= lx1 || lj >= ly1) return undefined;\n return (s * LH + lj) * LW + li;\n }\n return undefined;\n }\n function valueOf(key: number, t: number, nm: number): number {\n const w = index.get(nm);\n if (w === undefined) throw new InvalidConfigurationError(\"Defocus query is off the sensor site lattice; the image-space convolution does not apply.\");\n const li = key % LW, rest = (key - li) / LW, lj = rest % LH, s = (rest - lj) / LH;\n if (large) return largeValue(s, t, w, li, lj);\n return band(Math.floor((lj - ly0) / BAND_ROWS), t)[s]![w]![((lj - ly0) % BAND_ROWS) * NW + li - lx0]!;\n }\n // #564: one run lattice per (time, shift) of the samples F·L at the lattice points, and the own field factors F by tile, so a\n // query is answered with (K ⊛ D ⊛ F·L) / F as on the band path.\n const largeLattices = new Map<string, { lattice: LargeDefocusNodeLattice; own: Map<number, Float64Array> }>();\n const largeLatticeCount = shifts.length * Math.max(1, input.timesPerBand ?? 1);\n // Lattice points at most `reach` beyond the lattice feed queried values: the defocus kernel's radius plus the diffraction kernel's.\n const reach = large ? large.runs.radius + (large.diffraction ? large.diffraction.radius : 0) : 0;\n function largeValue(s: number, time: number, w: number, li: number, lj: number): number {\n const key = time + \":\" + s;\n let entry = largeLattices.get(key);\n if (!entry) {\n const shift = shifts[s]!;\n const lattice = createLargeDefocusNodeLattice({ kernel: large!, wavelengthsNm, capacityBytes: LARGE_DEFOCUS_CACHE_BYTES / largeLatticeCount, ...(input.onConvolution ? { onTile: input.onConvolution } : {}),\n source: (x0, y0, width, height) => {\n const size = width * height, factor = new Float64Array(size), u = new Float64Array(size), v = new Float64Array(size);\n const material = materialAt && materialRadiance ? new Int32Array(size) : undefined, beyond = new Uint8Array(size);\n for (let y = 0; y < height; y++) {\n const yMm = yMmOf(y0 + y, shift);\n for (let x = 0; x < width; x++) {\n const k = y * width + x;\n // A fixed tile's source reaches past the lattice: points beyond its reach feed no queried value, so they are 0 and never\n // mapped (the lens profiles are checked only up to the reach).\n if (x0 + x < -reach || x0 + x >= LW + reach || y0 + y < -reach || y0 + y >= LH + reach) { beyond[k] = 1; continue; }\n const look = geometry.lookOf(xMmOf(x0 + x, shift), yMm, time);\n if (!(look.z > 0)) throw new InvalidConfigurationError(\"lens.defocus: a lattice point's ray does not point toward the scene plane.\");\n const t = distance / look.z;\n factor[k] = look.factor; u[k] = look.x * t / scale; v[k] = look.y * t / scale;\n if (material) material[k] = materialAt!(u[k]!, v[k]!);\n }\n }\n return (node: number): Float64Array => {\n const nm = wavelengthsNm[node]!, samples = new Float64Array(size);\n if (material) {\n const radiance = new Map<number, number>();\n for (let k = 0; k < size; k++) {\n if (beyond[k]) continue;\n const m = material[k]!;\n let value = radiance.get(m);\n if (value === undefined) { value = materialRadiance!(m, nm); radiance.set(m, value); }\n samples[k] = factor[k]! * value;\n }\n } else for (let k = 0; k < size; k++) if (!beyond[k]) samples[k] = factor[k]! * base.radianceAt(u[k]!, v[k]!, nm);\n return samples;\n };\n } });\n entry = { lattice, own: new Map() };\n largeLattices.set(key, entry);\n if (largeLattices.size > largeLatticeCount) largeLattices.delete(largeLattices.keys().next().value!);\n }\n // The own factor of the lattice point, by 64-point tiles (kept for the request: 8 bytes per lattice point read).\n const T = 64, tx = Math.floor(li / T), ty = Math.floor(lj / T), tileKey = ty * 1048576 + tx;\n let own = entry.own.get(tileKey);\n if (!own) {\n own = new Float64Array(T * T);\n const shift = shifts[s]!;\n // Only the lattice's own points are queried; the rest of the tile is never read (and may lie beyond the lens profiles).\n for (let y = 0; y < T && ty * T + y < LH; y++) { const yMm = yMmOf(ty * T + y, shift); for (let x = 0; x < T && tx * T + x < LW; x++) own[y * T + x] = geometry.lookOf(xMmOf(tx * T + x, shift), yMm, time).factor; }\n entry.own.set(tileKey, own);\n }\n return entry.lattice.valueAt(w, li, lj) / own[(lj - ty * T) * T + li - tx * T]!;\n }\n function blurredAt(look: { x: number; y: number; z: number }, time: number, nm: number): number {\n const t = geometry.timeDependent ? time : 0, key = keyOf(look, t);\n if (key === undefined) throw new InvalidConfigurationError(\"Defocus query is off the sensor site lattice; the image-space convolution does not apply.\");\n return valueOf(key, t, nm);\n }\n const baseEvaluate = base.evaluateRadiance;\n const evaluateRadiance = (request: Readonly<SceneRadianceEvaluationRequest>): SceneRadianceEvaluationResult => {\n const result = baseEvaluate.call(base, request), o = (request.target as { outgoingDirectionUnitVector: { x: number; y: number; z: number } }).outgoingDirectionUnitVector;\n return { ...result, spectralRadianceWattsPerSquareMeterSteradianNanometer: blurredAt({ x: -o.x, y: -o.y, z: -o.z }, request.timeSecondsFromExposureStart, request.wavelengthNanometers) };\n };\n // The result is the base result with only its radiance replaced, so an engine-built base evaluator keeps its mark. Its radiance is\n // a pure function of the lattice key (and, with rotation, the request time) and the wavelength, so the lean executor may read it by\n // key, as for the diffraction provider.\n if (isInternalSceneRadianceEvaluator(baseEvaluate)) {\n markInternalSceneRadianceEvaluator(evaluateRadiance);\n // With rotation the key also carries the request time, as an index into the distinct times seen (one per temporal midpoint).\n const times: number[] = [], timeIndex = new Map<number, number>(), latticeKeys = shifts.length * LH * LW;\n registerInternalRadianceAccess(evaluateRadiance, {\n tabulated: false,\n keyOfDirection(o, time): number | undefined {\n const t = geometry.timeDependent ? time : 0, key = keyOf({ x: -o.x, y: -o.y, z: -o.z }, t);\n if (key === undefined) return undefined;\n let index = timeIndex.get(t);\n if (index === undefined) { index = times.length; times.push(t); timeIndex.set(t, index); }\n return index * latticeKeys + key;\n },\n radianceOfKey(key, nm): number {\n const index = Math.floor(key / latticeKeys);\n return valueOf(key - index * latticeKeys, times[index]!, nm);\n }\n });\n }\n return {\n sceneId: base.sceneId, providerProfileId: base.providerProfileId, radianceAt: base.radianceAt,\n evaluateRadiance,\n evaluateApertureRadiance(): SceneRadianceEvaluationResult {\n throw new InvalidConfigurationError(\"Defocus by image-space convolution does not take pupil rays.\");\n }\n };\n}\n\n/** Field-variation bounds of the image-space disc for one request (#548), recorded in the `lens.defocus` assumption. */\nexport interface DefocusFieldVariation {\n /** Sensor points the bounds were evaluated at: a grid of this many points per side over the native raster, edges included. */\n gridPointsPerSide: number;\n /**\n * Camera rotation (pitch or yaw tilts the scene plane in the camera frame): the largest change of the disc diameter, in\n * sites, between the axial depth of each scene point in the rotated camera frame and the subject distance, over the grid and\n * the rendered temporal midpoints. 0 for roll only; null without rotation.\n */\n rotationMaximumDiameterChangeSites: number | null;\n /**\n * Distortion: the largest deviation from 1 of the local scale of the distortion map (singular values of d distorted / d ideal)\n * over the grid: the relative disc-size difference to a model that blurs the ideal image and then distorts it. Null without distortion.\n */\n distortionMaximumLocalScaleDeviation: number | null;\n /**\n * A non-rectilinear projection: the largest change of the disc diameter, in sites, between the distance along each scene\n * point's ray and its axial depth (the thin-lens model uses the axial depth). Null for the rectilinear projection.\n */\n projectionMaximumDiameterChangeSites: number | null;\n}\n\n/** Internal: {@link DefocusFieldVariation} on a 9 × 9 grid of sensor points (the extremes of these smooth maps lie on the frame's edges). */\nexport function calculateDefocusFieldVariation(input: { geometry: PreparedDefocusImageSpaceGeometry; lensMapping?: PreparedEnvironmentLensFieldMapping;\n focalLengthMm: number; fNumber: number; focusDistanceM: number; subjectDistanceM: number; pitchMicrometers: number; nativeWidth: number; nativeHeight: number;\n angularVelocityRadPerSec: CameraAngularVelocityRadPerSec; temporalMidpointsSeconds: readonly number[]; diameterSites: number;\n discAt: (subjectDistanceM: number) => number }): DefocusFieldVariation {\n const { geometry, lensMapping, pitchMicrometers: pitch, nativeWidth: W, nativeHeight: H, subjectDistanceM: d, diameterSites, discAt } = input;\n const G = 9, points: { x: number; y: number }[] = [];\n for (let j = 0; j < G; j++) for (let i = 0; i < G; i++) points.push({ x: (i / (G - 1) - 0.5) * W * pitch / 1000, y: (j / (G - 1) - 0.5) * H * pitch / 1000 });\n let rotation: number | null = null;\n if (geometry.timeDependent) {\n rotation = 0;\n const omega = input.angularVelocityRadPerSec;\n for (const t of input.temporalMidpointsSeconds) {\n // The camera's optical axis at t in the reference axes; a scene point's axial depth in the rotated camera is P·axis.\n const axis = applyPhysicalCameraRotation({ x: 0, y: 0, z: 1 }, { pitch: omega.pitch * t, yaw: omega.yaw * t, roll: omega.roll * t }, \"camera-to-reference\");\n for (const p of points) {\n const look = geometry.lookOf(p.x, p.y, t), reach = d / look.z;\n const depth = reach * (look.x * axis.x + look.y * axis.y + look.z * axis.z);\n rotation = Math.max(rotation, Math.abs(discAt(depth) - diameterSites));\n }\n }\n }\n let distortion: number | null = null;\n if (lensMapping && lensMapping.mapping.distortion.kind !== \"none\") {\n distortion = 0;\n for (const p of points) {\n const scales = distortedImagePoint(lensMapping, undistortedImagePoint(lensMapping, { x: p.x, y: -p.y }).ideal);\n distortion = Math.max(distortion, scales.largestScale - 1, 1 - scales.smallestScale);\n }\n }\n let projection: number | null = null;\n if (lensMapping && lensMapping.mapping.projectionModel !== \"rectilinear\") {\n projection = 0;\n for (const p of points) {\n const look = geometry.lookOf(p.x, p.y, 0);\n projection = Math.max(projection, Math.abs(discAt(d / look.z) - diameterSites));\n }\n }\n return { gridPointsPerSide: G, rotationMaximumDiameterChangeSites: rotation, distortionMaximumLocalScaleDeviation: distortion, projectionMaximumDiameterChangeSites: projection };\n}\n"]}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Develop joined parts (#571): the whole-image development steps of a capture whose RAW was rendered in parts.
3
+ * @see docs/QUICK_START.md, "Developing a capture rendered in parts".
4
+ */
5
+ import { type SimulateCaptureDngPart, type SimulateCaptureOptions, type SimulateCaptureResult } from "./simulate-capture.js";
6
+ /**
7
+ * Develops the whole frame of `options` from the packed RAW of region renders of the same request (#571), so a capture can
8
+ * render its RAW in parallel parts and still take the development steps that filter across the whole image:
9
+ * `output.diffractionCorrection` and `output.sharpening`, which a region render refuses, and `output.lensCorrections` (#570), which
10
+ * runs on the whole developed frame here exactly as in `simulateCapture(options)`. The parts are joined exactly as
11
+ * {@link serializeSimulatedCaptureDngFromParts} joins them (they must cover every native site and agree where they overlap),
12
+ * and the joined RAW is the whole render's RAW, so the result's `image` (samples and JPEG or PNG bytes), `raw` codes and
13
+ * `plan` are those of `simulateCapture(options)`, bit for bit.
14
+ *
15
+ * `options` is the whole request (no `output.region`), with the development options it should have; render the parts with
16
+ * the same request plus `output.region`, without `output.diffractionCorrection`, `output.sharpening` and `output.dng`, and with a
17
+ * fixed white balance in place of `"auto"` (none of these change the RAW codes; auto white balance is measured here over the
18
+ * joined frame). A part may keep or drop `output.lensCorrections` (a corrected region only widens its `region.nativeRect`).
19
+ * Any `output.format` serves for a part.
20
+ *
21
+ * `onProgress` reports the `white-balance` (with auto white balance), `development`, `diffraction-correction`, `sharpening` and
22
+ * `jpeg` stages, the detail stages once per output row, so a host can show "Applying sharpening to the whole image". The lens
23
+ * corrections report no stage of their own: they run between `diffraction-correction` and `sharpening`.
24
+ * No `raw` stage is reported: no RAW is rendered. What differs from the whole render's result: `diagnostics.providerEvaluationCount`
25
+ * is 0, `diagnostics.timingsMs` are this call's, `diagnostics.fast` and the `raw.*` assumptions of how the RAW was rendered are
26
+ * not repeated (they are in the parts' results), and a `parts` assumption records the join.
27
+ * @returns The capture result of `options`, developed from the joined RAW.
28
+ */
29
+ export declare function simulateCaptureFromParts(options: SimulateCaptureOptions, parts: readonly SimulateCaptureDngPart[]): Promise<SimulateCaptureResult>;
@@ -0,0 +1,33 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ /**
3
+ * Develop joined parts (#571): the whole-image development steps of a capture whose RAW was rendered in parts.
4
+ * @see docs/QUICK_START.md, "Developing a capture rendered in parts".
5
+ */
6
+ import { runCapture } from "./simulate-capture.js";
7
+ /**
8
+ * Develops the whole frame of `options` from the packed RAW of region renders of the same request (#571), so a capture can
9
+ * render its RAW in parallel parts and still take the development steps that filter across the whole image:
10
+ * `output.diffractionCorrection` and `output.sharpening`, which a region render refuses, and `output.lensCorrections` (#570), which
11
+ * runs on the whole developed frame here exactly as in `simulateCapture(options)`. The parts are joined exactly as
12
+ * {@link serializeSimulatedCaptureDngFromParts} joins them (they must cover every native site and agree where they overlap),
13
+ * and the joined RAW is the whole render's RAW, so the result's `image` (samples and JPEG or PNG bytes), `raw` codes and
14
+ * `plan` are those of `simulateCapture(options)`, bit for bit.
15
+ *
16
+ * `options` is the whole request (no `output.region`), with the development options it should have; render the parts with
17
+ * the same request plus `output.region`, without `output.diffractionCorrection`, `output.sharpening` and `output.dng`, and with a
18
+ * fixed white balance in place of `"auto"` (none of these change the RAW codes; auto white balance is measured here over the
19
+ * joined frame). A part may keep or drop `output.lensCorrections` (a corrected region only widens its `region.nativeRect`).
20
+ * Any `output.format` serves for a part.
21
+ *
22
+ * `onProgress` reports the `white-balance` (with auto white balance), `development`, `diffraction-correction`, `sharpening` and
23
+ * `jpeg` stages, the detail stages once per output row, so a host can show "Applying sharpening to the whole image". The lens
24
+ * corrections report no stage of their own: they run between `diffraction-correction` and `sharpening`.
25
+ * No `raw` stage is reported: no RAW is rendered. What differs from the whole render's result: `diagnostics.providerEvaluationCount`
26
+ * is 0, `diagnostics.timingsMs` are this call's, `diagnostics.fast` and the `raw.*` assumptions of how the RAW was rendered are
27
+ * not repeated (they are in the parts' results), and a `parts` assumption records the join.
28
+ * @returns The capture result of `options`, developed from the joined RAW.
29
+ */
30
+ export async function simulateCaptureFromParts(options, parts) {
31
+ return await runCapture(options, "develop-from-parts", parts);
32
+ }
33
+ //# sourceMappingURL=develop-joined-parts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"develop-joined-parts.js","sourceRoot":"","sources":["../../src/facade/develop-joined-parts.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAwF,MAAM,uBAAuB,CAAC;AAEzI;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,OAA+B,EAAE,KAAwC;IACtH,OAAO,MAAM,UAAU,CAAC,OAAO,EAAE,oBAAoB,EAAE,KAAK,CAA0B,CAAC;AACzF,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Develop joined parts (#571): the whole-image development steps of a capture whose RAW was rendered in parts.\n * @see docs/QUICK_START.md, \"Developing a capture rendered in parts\".\n */\n\nimport { runCapture, type SimulateCaptureDngPart, type SimulateCaptureOptions, type SimulateCaptureResult } from \"./simulate-capture.js\";\n\n/**\n * Develops the whole frame of `options` from the packed RAW of region renders of the same request (#571), so a capture can\n * render its RAW in parallel parts and still take the development steps that filter across the whole image:\n * `output.diffractionCorrection` and `output.sharpening`, which a region render refuses, and `output.lensCorrections` (#570), which\n * runs on the whole developed frame here exactly as in `simulateCapture(options)`. The parts are joined exactly as\n * {@link serializeSimulatedCaptureDngFromParts} joins them (they must cover every native site and agree where they overlap),\n * and the joined RAW is the whole render's RAW, so the result's `image` (samples and JPEG or PNG bytes), `raw` codes and\n * `plan` are those of `simulateCapture(options)`, bit for bit.\n *\n * `options` is the whole request (no `output.region`), with the development options it should have; render the parts with\n * the same request plus `output.region`, without `output.diffractionCorrection`, `output.sharpening` and `output.dng`, and with a\n * fixed white balance in place of `\"auto\"` (none of these change the RAW codes; auto white balance is measured here over the\n * joined frame). A part may keep or drop `output.lensCorrections` (a corrected region only widens its `region.nativeRect`).\n * Any `output.format` serves for a part.\n *\n * `onProgress` reports the `white-balance` (with auto white balance), `development`, `diffraction-correction`, `sharpening` and\n * `jpeg` stages, the detail stages once per output row, so a host can show \"Applying sharpening to the whole image\". The lens\n * corrections report no stage of their own: they run between `diffraction-correction` and `sharpening`.\n * No `raw` stage is reported: no RAW is rendered. What differs from the whole render's result: `diagnostics.providerEvaluationCount`\n * is 0, `diagnostics.timingsMs` are this call's, `diagnostics.fast` and the `raw.*` assumptions of how the RAW was rendered are\n * not repeated (they are in the parts' results), and a `parts` assumption records the join.\n * @returns The capture result of `options`, developed from the joined RAW.\n */\nexport async function simulateCaptureFromParts(options: SimulateCaptureOptions, parts: readonly SimulateCaptureDngPart[]): Promise<SimulateCaptureResult> {\n return await runCapture(options, \"develop-from-parts\", parts) as SimulateCaptureResult;\n}\n"]}
@@ -1,5 +1,26 @@
1
1
  import type { PreparedDefocusImageSpaceGeometry } from "./defocus-image-space-provider.js";
2
- import { type DisplayViewExpectedSignal, type DisplayViewExpectedSignalInput } from "./expected-signal.js";
2
+ import { type ResolveLensSampledPsfInput } from "../optics/lens-psf-profile.js";
3
+ import { type DisplayViewExpectedSignal, type DisplayViewExpectedSignalInput, type GroupTables } from "./expected-signal.js";
4
+ /** #569: field zones along the native raster's longer side. */
5
+ export declare const DISPLAY_VIEW_LENS_PSF_ZONES = 64;
6
+ /** #569: a field-dependent PSF for the display view (see the module comment). */
7
+ export interface DisplayViewLensPsf {
8
+ /** Kernel radius and zone side, in sites. */
9
+ readonly radius: number;
10
+ readonly zoneSites: number;
11
+ /** The kernels at the frame centre's zone, for the expected-signal input's lattice groups and reach. */
12
+ axisKernels(wavelengthsNm: readonly number[]): {
13
+ radius: number;
14
+ perNode: Float64Array[];
15
+ };
16
+ /** The combined kernels of the zone of native site (x, y), for an input whose kernels are the axis kernels. */
17
+ tables(input: DisplayViewExpectedSignalInput): (x: number, y: number) => readonly GroupTables[];
18
+ }
19
+ /**
20
+ * #569: the field-dependent PSF of a display view from the sampled PSF the capture resolves (everything but the field point and wavelength),
21
+ * of kernel radius R, on the W × H native raster of `pitch` µm.
22
+ */
23
+ export declare function createDisplayViewLensPsf(psf: Omit<ResolveLensSampledPsfInput, "fieldPointMm" | "wavelengthNm">, R: number, W: number, H: number, pitch: number): DisplayViewLensPsf;
3
24
  /** What the lens signal needs from the resolved request. */
4
25
  export interface DisplayViewLensSetup {
5
26
  geometry: PreparedDefocusImageSpaceGeometry;
@@ -21,6 +42,16 @@ export interface DisplayViewLensSetup {
21
42
  y: number;
22
43
  };
23
44
  }[];
45
+ /**
46
+ * #569: a field-dependent lens PSF (`lens.catalogue`, {@link createDisplayViewLensPsf}): each site reads its field zone's kernels
47
+ * instead of the input's. The input's kernels (the axis zone's) set the lattice groups and the reach; absent, every site reads them.
48
+ */
49
+ psf?: DisplayViewLensPsf | undefined;
50
+ /**
51
+ * #569 (catalogue fisheyes): a ray that does not point toward the scene plane sees no scene (zero radiance), as the capture's provider
52
+ * with `zeroBeyondHorizon` gives it, instead of failing.
53
+ */
54
+ zeroBeyondHorizon?: boolean | undefined;
24
55
  }
25
56
  /**
26
57
  * Checks that the mapping and the vignetting profile cover the farthest source point the view reads, (W/2 + reachSites, H/2 + reachSites)
@@ -26,6 +26,15 @@
26
26
  * ring tagged with the point, sized from the window and capped at LATTICE_CACHE_LIMIT entries (beyond it, points are
27
27
  * evaluated as they are read).
28
28
  *
29
+ * Field-dependent PSF (#569, `lens.catalogue`; {@link createDisplayViewLensPsf}). The capture's environment PSF quadrature resolves the
30
+ * catalogue lens's sampled PSF at each query point's own field position. The view cuts the native raster into square zones of
31
+ * Z = ⌈max(W, H) / DISPLAY_VIEW_LENS_PSF_ZONES⌉ sites (one site on frames of at most that many sites a side) and every site of a zone
32
+ * takes the PSF the capture's own resolver gives at the zone's centre, at each spectral node (an approximation: the PSF's change
33
+ * across half a zone). A profile kernel's rows run with image +Y (up) and its tap (i, j) reads (x − (i − c)·p, y + (j − c)·p) in
34
+ * native coordinates (`sensorPsfSourcePoint`), so the view's kernel (reading in(x − t)) is the profile kernel flipped vertically.
35
+ * Each zone's combined kernels are the expected signal's own tables (`buildTables`) with the zone's kernels, built when a site of
36
+ * the zone is first read and kept per input in a least-recently-used cache of at most 64 MB (at least four zones).
37
+ *
29
38
  * Large defocus kernels (#564, `input.largeKernel`, radius above 64 sites). The image-space disc D is the same at every lattice
30
39
  * group, spectral node and temporal midpoint, so it commutes with those sums as in the rectilinear signal (`expected-signal.ts`):
31
40
  * μ_c(x) = Σ_s D(s)·E_c(x − s), with E_c(x) the sum above through the in-focus kernels (each node's diffraction kernel, or a unit
@@ -35,7 +44,62 @@
35
44
  */
36
45
  import { InvalidConfigurationError } from "../core/configuration-error.js";
37
46
  import { createSiteKernelRunsLattice } from "../optics/site-kernel-runs.js";
38
- import { displayViewSignalTables } from "./expected-signal.js";
47
+ import { resolveLensSampledPsfKernel } from "../optics/lens-psf-profile.js";
48
+ import { buildTables, displayViewSignalTables } from "./expected-signal.js";
49
+ /** #569: field zones along the native raster's longer side. */
50
+ export const DISPLAY_VIEW_LENS_PSF_ZONES = 64;
51
+ /**
52
+ * #569: the field-dependent PSF of a display view from the sampled PSF the capture resolves (everything but the field point and wavelength),
53
+ * of kernel radius R, on the W × H native raster of `pitch` µm.
54
+ */
55
+ export function createDisplayViewLensPsf(psf, R, W, H, pitch) {
56
+ const Z = Math.ceil(Math.max(W, H) / DISPLAY_VIEW_LENS_PSF_ZONES), zonesX = Math.ceil(W / Z), w = 2 * R + 1;
57
+ const zoneOf = (x, y) => Math.floor(y / Z) * zonesX + Math.floor(x / Z);
58
+ const kernelsOf = (zone, wavelengthsNm) => {
59
+ // The zone's centre in sites from the top-left corner (an edge zone may be narrower), in image millimetres (+Y up).
60
+ const zx = zone % zonesX, zy = (zone - zx) / zonesX, fieldPointMm = { x: ((zx * Z + Math.min(W, zx * Z + Z)) / 2 - W / 2) * pitch / 1000,
61
+ y: (H / 2 - (zy * Z + Math.min(H, zy * Z + Z)) / 2) * pitch / 1000 };
62
+ return wavelengthsNm.map((wavelengthNm) => {
63
+ // Every node of the engine-built profile has the same (2R + 1)² window, so every resolved kernel has it too.
64
+ const values = resolveLensSampledPsfKernel({ ...psf, fieldPointMm, wavelengthNm }).normalizedIntensity, out = new Float64Array(w * w);
65
+ for (let j = 0; j < w; j++)
66
+ for (let i = 0; i < w; i++)
67
+ out[(w - 1 - j) * w + i] = values[j * w + i];
68
+ return out;
69
+ });
70
+ };
71
+ const caches = new WeakMap();
72
+ return { radius: R, zoneSites: Z,
73
+ axisKernels: (wavelengthsNm) => ({ radius: R, perNode: kernelsOf(zoneOf(W >> 1, H >> 1), wavelengthsNm) }),
74
+ tables(input) {
75
+ let read = caches.get(input);
76
+ if (read)
77
+ return read;
78
+ const cache = new Map();
79
+ let kept = 0, last = -1, lastTables = [];
80
+ read = (x, y) => {
81
+ const zone = zoneOf(x, y);
82
+ if (zone === last)
83
+ return lastTables;
84
+ let tables = cache.get(zone);
85
+ if (tables)
86
+ cache.delete(zone);
87
+ else {
88
+ tables = buildTables({ ...input, kernels: { radius: R, perNode: kernelsOf(zone, input.wavelengthsNm) } }).groups;
89
+ // Zones kept: at least 4, and at most 64 MB of them (every zone's tables have the same size).
90
+ kept ||= Math.max(4, (1 << 23) / tables.reduce((n, g) => n + g.cw * g.ch * (g.neutral.length + g.spectral.flat().length + g.perNode.flat().length), 0));
91
+ if (cache.size >= kept)
92
+ cache.delete(cache.keys().next().value);
93
+ }
94
+ cache.set(zone, tables);
95
+ last = zone;
96
+ lastTables = tables;
97
+ return tables;
98
+ };
99
+ caches.set(input, read);
100
+ return read;
101
+ } };
102
+ }
39
103
  /** Largest lattice cache, in entries over all lattice groups and temporal midpoints (times the spectral nodes for radiance scenes). */
40
104
  const LATTICE_CACHE_LIMIT = 1 << 22;
41
105
  const pow2 = (n) => { let p = 1; while (p < n)
@@ -50,7 +114,7 @@ export function prepareDisplayViewLensSignal(lens, nativeWidth, nativeHeight, re
50
114
  for (const t of lens.times)
51
115
  for (const [x, y] of [[-xMm, -yMm], [xMm, -yMm], [-xMm, yMm], [xMm, yMm]]) {
52
116
  try {
53
- if (!(lens.geometry.lookOf(x, y, t).z > 0))
117
+ if (!(lens.geometry.lookOf(x, y, t).z > 0) && !lens.zeroBeyondHorizon)
54
118
  throw new InvalidConfigurationError("its ray does not point toward the scene plane.");
55
119
  }
56
120
  catch (error) {
@@ -67,14 +131,25 @@ function createLensSignal(lens, input, spanColumns) {
67
131
  const materials = scene.kind === "materials" ? scene : undefined, radianceAt = scene.kind === "radiance" ? scene.radianceAt : undefined;
68
132
  const { reflectance, spectralIndex, neutralDirect, spectralDirect, groups } = displayViewSignalTables(input);
69
133
  const kernels = input.kernels, R = kernels ? kernels.radius : 0;
134
+ /** #569: the combined kernels of the zone of site (x, y), or the input's own without a field-dependent PSF. */
135
+ const zoneTables = lens.psf ? lens.psf.tables(input) : () => groups;
70
136
  let lookups = 0;
71
137
  // The plane point (frame units) and field factor of native sensor point (x, y) mm at time t: the environment's mapping (lookOf) and
72
138
  // the planar provider's own arithmetic for the outgoing direction −look.
73
- let pu = 0, pv = 0, pf = 0;
139
+ // #569: with zeroBeyondHorizon, a ray at or beyond 90° reads the plane's origin with a zero factor (zero radiance; `beyond` is set).
140
+ let pu = 0, pv = 0, pf = 0, beyond = false;
141
+ const zeroBeyond = lens.zeroBeyondHorizon === true;
74
142
  const map = (xMm, yMm, t) => {
75
143
  const look = geometry.lookOf(xMm, yMm, t);
76
- if (!(look.z > 0))
77
- throw new InvalidConfigurationError("simulateDisplayView: a query ray does not point toward the scene plane.");
144
+ beyond = !(look.z > 0);
145
+ if (beyond) {
146
+ if (!zeroBeyond || !Number.isFinite(look.z))
147
+ throw new InvalidConfigurationError("simulateDisplayView: a query ray does not point toward the scene plane.");
148
+ pu = 0;
149
+ pv = 0;
150
+ pf = 0;
151
+ return;
152
+ }
78
153
  const s = distance / look.z;
79
154
  pu = look.x * s / scale;
80
155
  pv = look.y * s / scale;
@@ -157,14 +232,14 @@ function createLensSignal(lens, input, spanColumns) {
157
232
  }
158
233
  }
159
234
  function kernelSite(x, y) {
160
- const c = channelAt(x, y), rowMask = cacheRows - 1, colMask = cacheCols - 1;
235
+ const c = channelAt(x, y), rowMask = cacheRows - 1, colMask = cacheCols - 1, zone = zoneTables(x, y);
161
236
  let total = 0;
162
237
  for (let ti = 0; ti < T; ti++) {
163
238
  let sum = 0;
164
239
  for (let g = 0; g < G; g++) {
165
- const group = groups[g], p0 = x + group.minIx - R, q0 = y + group.minIy - R, cw = group.cw, ch = group.ch;
240
+ const group = groups[g], p0 = x + group.minIx - R, q0 = y + group.minIy - R, cw = group.cw, ch = group.ch, weights = zone[g];
166
241
  if (materials) {
167
- const nk = group.neutral[c], sk = group.spectral[c];
242
+ const nk = weights.neutral[c], sk = weights.spectral[c];
168
243
  for (let dy = 0, t = 0; dy < ch; dy++) {
169
244
  // The cache row of lattice row q (read inline: the common case is a hit).
170
245
  const q = q0 + dy, row = cacheRows > 0 ? ((g * T + ti) * cacheRows + (q & rowMask)) * cacheCols : -1;
@@ -187,7 +262,7 @@ function createLensSignal(lens, input, spanColumns) {
187
262
  lattice(g, ti, p0 + dx, q0 + dy);
188
263
  let value = 0;
189
264
  for (let n = 0; n < nodes; n++)
190
- value += group.perNode[n][c][t] * radiance[n];
265
+ value += weights.perNode[n][c][t] * radiance[n];
191
266
  sum += lf * value;
192
267
  }
193
268
  }
@@ -358,7 +433,7 @@ function createLensSignal(lens, input, spanColumns) {
358
433
  try {
359
434
  for (let ti = 0; ti < T; ti++) {
360
435
  map(xMm, yMm, times[ti]);
361
- const value = materials ? materials.materialAt(pu, pv) : radianceAt(pu, pv, pilotNode);
436
+ const value = beyond ? -1 : materials ? materials.materialAt(pu, pv) : radianceAt(pu, pv, pilotNode);
362
437
  lookups++;
363
438
  if (ti === 0)
364
439
  first = value;