@photivra/engine 2.20.0 → 2.22.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 (275) hide show
  1. package/CHANGELOG.md +295 -1
  2. package/CITATION.cff +1 -1
  3. package/README.md +7 -6
  4. package/SECURITY.md +1 -1
  5. package/THIRD_PARTY.md +18 -0
  6. package/dist/capture/c2pa-embed.d.ts +116 -0
  7. package/dist/capture/c2pa-embed.js +493 -0
  8. package/dist/capture/c2pa-embed.js.map +1 -0
  9. package/dist/capture/dng-import.d.ts +73 -8
  10. package/dist/capture/dng-import.js +315 -80
  11. package/dist/capture/dng-import.js.map +1 -1
  12. package/dist/capture/dng-lens-correction-opcodes.d.ts +2 -2
  13. package/dist/capture/dng-lens-correction-opcodes.js +2 -2
  14. package/dist/capture/dng-lens-correction-opcodes.js.map +1 -1
  15. package/dist/capture/dng-opcodes.d.ts +96 -0
  16. package/dist/capture/dng-opcodes.js +391 -0
  17. package/dist/capture/dng-opcodes.js.map +1 -0
  18. package/dist/capture/dng-profile-maps.d.ts +99 -0
  19. package/dist/capture/dng-profile-maps.js +381 -0
  20. package/dist/capture/dng-profile-maps.js.map +1 -0
  21. package/dist/capture/dng-stage-image.d.ts +23 -0
  22. package/dist/capture/dng-stage-image.js +65 -0
  23. package/dist/capture/dng-stage-image.js.map +1 -0
  24. package/dist/capture/exposure-build-up-stage.d.ts +16 -0
  25. package/dist/capture/exposure-build-up-stage.js +4 -0
  26. package/dist/capture/exposure-build-up-stage.js.map +1 -0
  27. package/dist/capture/jpeg-xl-tiles.d.ts +22 -0
  28. package/dist/capture/jpeg-xl-tiles.js +151 -0
  29. package/dist/capture/jpeg-xl-tiles.js.map +1 -0
  30. package/dist/capture/lossy-jpeg.d.ts +17 -0
  31. package/dist/capture/lossy-jpeg.js +369 -0
  32. package/dist/capture/lossy-jpeg.js.map +1 -0
  33. package/dist/capture/native-environment-lean.d.ts +2 -1
  34. package/dist/capture/native-environment-lean.js +41 -73
  35. package/dist/capture/native-environment-lean.js.map +1 -1
  36. package/dist/capture/native-environment-tabulated.js +4 -3
  37. package/dist/capture/native-environment-tabulated.js.map +1 -1
  38. package/dist/capture/native-raw-development.d.ts +2 -1
  39. package/dist/capture/native-raw-development.js.map +1 -1
  40. package/dist/capture/native-raw.d.ts +3 -2
  41. package/dist/capture/native-raw.js +5 -4
  42. package/dist/capture/native-raw.js.map +1 -1
  43. package/dist/capture/sensor-raw-producer.d.ts +4 -1
  44. package/dist/capture/sensor-raw-producer.js +12 -3
  45. package/dist/capture/sensor-raw-producer.js.map +1 -1
  46. package/dist/color/neighbor-highlight-reconstruction.d.ts +66 -0
  47. package/dist/color/neighbor-highlight-reconstruction.js +234 -0
  48. package/dist/color/neighbor-highlight-reconstruction.js.map +1 -0
  49. package/dist/color/sensor-color-development.d.ts +5 -0
  50. package/dist/color/sensor-color-development.js +7 -1
  51. package/dist/color/sensor-color-development.js.map +1 -1
  52. package/dist/color/spectral-spikiness.d.ts +11 -0
  53. package/dist/color/spectral-spikiness.js +23 -0
  54. package/dist/color/spectral-spikiness.js.map +1 -0
  55. package/dist/core/execution-error.d.ts +21 -0
  56. package/dist/core/execution-error.js +12 -0
  57. package/dist/core/execution-error.js.map +1 -0
  58. package/dist/core/version.d.ts +1 -1
  59. package/dist/core/version.js +1 -1
  60. package/dist/core/version.js.map +1 -1
  61. package/dist/equipment/generic-lens-catalogue.d.ts +3 -2
  62. package/dist/equipment/generic-lens-catalogue.js +18 -5
  63. package/dist/equipment/generic-lens-catalogue.js.map +1 -1
  64. package/dist/equipment/generic-tier-assets.d.ts +32 -0
  65. package/dist/equipment/generic-tier-assets.js +16 -11
  66. package/dist/equipment/generic-tier-assets.js.map +1 -1
  67. package/dist/equipment/sensor-profile-body.d.ts +78 -0
  68. package/dist/equipment/sensor-profile-body.js +77 -0
  69. package/dist/equipment/sensor-profile-body.js.map +1 -0
  70. package/dist/equipment/sensor-profiles.d.ts +8 -0
  71. package/dist/equipment/sensor-profiles.js +82 -0
  72. package/dist/equipment/sensor-profiles.js.map +1 -0
  73. package/dist/facade/catalogue-lens-signal.d.ts +28 -3
  74. package/dist/facade/catalogue-lens-signal.js +83 -78
  75. package/dist/facade/catalogue-lens-signal.js.map +1 -1
  76. package/dist/facade/chart-radiance-batch.js +2 -1
  77. package/dist/facade/chart-radiance-batch.js.map +1 -1
  78. package/dist/facade/defocus-image-space-provider.d.ts +7 -0
  79. package/dist/facade/defocus-image-space-provider.js +64 -76
  80. package/dist/facade/defocus-image-space-provider.js.map +1 -1
  81. package/dist/facade/diffraction-provider.d.ts +1 -1
  82. package/dist/facade/diffraction-provider.js +4 -4
  83. package/dist/facade/diffraction-provider.js.map +1 -1
  84. package/dist/facade/display-view-gpu-session.js +39 -5
  85. package/dist/facade/display-view-gpu-session.js.map +1 -1
  86. package/dist/facade/display-view-gpu.d.ts +19 -6
  87. package/dist/facade/display-view-gpu.js.map +1 -1
  88. package/dist/facade/display-view-lens-signal.js +25 -23
  89. package/dist/facade/display-view-lens-signal.js.map +1 -1
  90. package/dist/facade/display-view-normal.d.ts +15 -0
  91. package/dist/facade/display-view-normal.js +44 -0
  92. package/dist/facade/display-view-normal.js.map +1 -0
  93. package/dist/facade/display-view-rendering.d.ts +97 -0
  94. package/dist/facade/display-view-rendering.js +598 -0
  95. package/dist/facade/display-view-rendering.js.map +1 -0
  96. package/dist/facade/display-view.d.ts +37 -65
  97. package/dist/facade/display-view.js +152 -499
  98. package/dist/facade/display-view.js.map +1 -1
  99. package/dist/facade/expected-signal-setup.d.ts +3 -1
  100. package/dist/facade/expected-signal-setup.js +3 -3
  101. package/dist/facade/expected-signal-setup.js.map +1 -1
  102. package/dist/facade/expected-signal.d.ts +47 -14
  103. package/dist/facade/expected-signal.js +117 -112
  104. package/dist/facade/expected-signal.js.map +1 -1
  105. package/dist/facade/exposure-build-up.d.ts +70 -0
  106. package/dist/facade/exposure-build-up.js +164 -0
  107. package/dist/facade/exposure-build-up.js.map +1 -0
  108. package/dist/facade/fast-methods.d.ts +1 -1
  109. package/dist/facade/fast-methods.js +46 -9
  110. package/dist/facade/fast-methods.js.map +1 -1
  111. package/dist/facade/generic-lens-capture.d.ts +3 -3
  112. package/dist/facade/generic-lens-capture.js +3 -3
  113. package/dist/facade/generic-lens-capture.js.map +1 -1
  114. package/dist/facade/image-plane-enable.d.ts +7 -0
  115. package/dist/facade/image-plane-enable.js +17 -0
  116. package/dist/facade/image-plane-enable.js.map +1 -0
  117. package/dist/facade/image-plane-lattice-data.d.ts +6 -0
  118. package/dist/facade/image-plane-lattice-data.js +10 -0
  119. package/dist/facade/image-plane-lattice-data.js.map +1 -0
  120. package/dist/facade/image-plane-support.d.ts +33 -0
  121. package/dist/facade/image-plane-support.js +11 -0
  122. package/dist/facade/image-plane-support.js.map +1 -0
  123. package/dist/facade/image-plane.d.ts +36 -0
  124. package/dist/facade/image-plane.js +384 -0
  125. package/dist/facade/image-plane.js.map +1 -0
  126. package/dist/facade/mixed-illumination.d.ts +108 -0
  127. package/dist/facade/mixed-illumination.js +174 -0
  128. package/dist/facade/mixed-illumination.js.map +1 -0
  129. package/dist/facade/on-demand-kits.d.ts +14 -0
  130. package/dist/facade/on-demand-kits.js +36 -0
  131. package/dist/facade/on-demand-kits.js.map +1 -0
  132. package/dist/facade/opt-in-kit.d.ts +9 -0
  133. package/dist/facade/opt-in-kit.js +11 -0
  134. package/dist/facade/opt-in-kit.js.map +1 -0
  135. package/dist/facade/quality-kit.d.ts +21 -0
  136. package/dist/facade/quality-kit.js +23 -0
  137. package/dist/facade/quality-kit.js.map +1 -0
  138. package/dist/facade/quality-paths.d.ts +22 -0
  139. package/dist/facade/quality-paths.js +44 -0
  140. package/dist/facade/quality-paths.js.map +1 -0
  141. package/dist/facade/representative-light-sources.d.ts +72 -0
  142. package/dist/facade/representative-light-sources.js +124 -0
  143. package/dist/facade/representative-light-sources.js.map +1 -0
  144. package/dist/facade/scene-radiance.d.ts +145 -4
  145. package/dist/facade/scene-radiance.js +50 -13
  146. package/dist/facade/scene-radiance.js.map +1 -1
  147. package/dist/facade/simulate-capture.d.ts +68 -20
  148. package/dist/facade/simulate-capture.js +399 -146
  149. package/dist/facade/simulate-capture.js.map +1 -1
  150. package/dist/facade/simulate-display-view.d.ts +10 -12
  151. package/dist/facade/simulate-display-view.js +70 -53
  152. package/dist/facade/simulate-display-view.js.map +1 -1
  153. package/dist/gpu/chart-composite-gpu.d.ts +13 -1
  154. package/dist/gpu/chart-composite-gpu.js +48 -9
  155. package/dist/gpu/chart-composite-gpu.js.map +1 -1
  156. package/dist/gpu/chart-radiance-gpu.js +4 -30
  157. package/dist/gpu/chart-radiance-gpu.js.map +1 -1
  158. package/dist/gpu/display-view-composite-material-module.d.ts +10 -4
  159. package/dist/gpu/display-view-composite-material-module.js +39 -13
  160. package/dist/gpu/display-view-composite-material-module.js.map +1 -1
  161. package/dist/gpu/display-view-gpu-renderer.d.ts +43 -0
  162. package/dist/gpu/display-view-gpu-renderer.js +134 -0
  163. package/dist/gpu/display-view-gpu-renderer.js.map +1 -0
  164. package/dist/gpu/display-view-image-material-module.d.ts +87 -0
  165. package/dist/gpu/display-view-image-material-module.js +361 -0
  166. package/dist/gpu/display-view-image-material-module.js.map +1 -0
  167. package/dist/gpu/display-view-image-quality.d.ts +87 -0
  168. package/dist/gpu/display-view-image-quality.js +625 -0
  169. package/dist/gpu/display-view-image-quality.js.map +1 -0
  170. package/dist/gpu/display-view-quality-gpu.d.ts +80 -65
  171. package/dist/gpu/display-view-quality-gpu.js +187 -445
  172. package/dist/gpu/display-view-quality-gpu.js.map +1 -1
  173. package/dist/gpu/display-view-speed-gpu.d.ts +67 -19
  174. package/dist/gpu/display-view-speed-gpu.js +181 -105
  175. package/dist/gpu/display-view-speed-gpu.js.map +1 -1
  176. package/dist/gpu/image-kernel-accelerator.js +3 -0
  177. package/dist/gpu/image-kernel-accelerator.js.map +1 -1
  178. package/dist/gpu/image-kernel-execution.d.ts +2 -13
  179. package/dist/gpu/image-kernel-execution.js +2 -10
  180. package/dist/gpu/image-kernel-execution.js.map +1 -1
  181. package/dist/gpu/wgsl-display-view-coupled-stub.d.ts +8 -0
  182. package/dist/gpu/wgsl-display-view-coupled-stub.js +21 -0
  183. package/dist/gpu/wgsl-display-view-coupled-stub.js.map +1 -0
  184. package/dist/gpu/wgsl-display-view-coupled.d.ts +88 -0
  185. package/dist/gpu/wgsl-display-view-coupled.js +353 -0
  186. package/dist/gpu/wgsl-display-view-coupled.js.map +1 -0
  187. package/dist/gpu/wgsl-display-view-quality-kernel.d.ts +33 -24
  188. package/dist/gpu/wgsl-display-view-quality-kernel.js +166 -146
  189. package/dist/gpu/wgsl-display-view-quality-kernel.js.map +1 -1
  190. package/dist/gpu/wgsl-display-view-speed-kernel.d.ts +19 -44
  191. package/dist/gpu/wgsl-display-view-speed-kernel.js +116 -18
  192. package/dist/gpu/wgsl-display-view-speed-kernel.js.map +1 -1
  193. package/dist/gpu/wgsl-exact-sum.d.ts +20 -0
  194. package/dist/gpu/wgsl-exact-sum.js +42 -0
  195. package/dist/gpu/wgsl-exact-sum.js.map +1 -0
  196. package/dist/index.d.ts +22 -6
  197. package/dist/index.js +16 -2
  198. package/dist/index.js.map +1 -1
  199. package/dist/motion/subject-motion.d.ts +66 -0
  200. package/dist/motion/subject-motion.js +52 -0
  201. package/dist/motion/subject-motion.js.map +1 -0
  202. package/dist/optics/generic-lens-lateral-color.d.ts +83 -0
  203. package/dist/optics/generic-lens-lateral-color.js +77 -0
  204. package/dist/optics/generic-lens-lateral-color.js.map +1 -0
  205. package/dist/optics/generic-lens-psf.js +54 -46
  206. package/dist/optics/generic-lens-psf.js.map +1 -1
  207. package/dist/optics/lens-psf-profile.d.ts +7 -0
  208. package/dist/optics/lens-psf-profile.js +2 -1
  209. package/dist/optics/lens-psf-profile.js.map +1 -1
  210. package/dist/output/camera-channel-response.d.ts +50 -0
  211. package/dist/output/camera-channel-response.js +69 -0
  212. package/dist/output/camera-channel-response.js.map +1 -0
  213. package/dist/output/developed-lens-corrections.d.ts +19 -5
  214. package/dist/output/developed-lens-corrections.js +28 -9
  215. package/dist/output/developed-lens-corrections.js.map +1 -1
  216. package/dist/output/generic-lens-corrections.d.ts +41 -5
  217. package/dist/output/generic-lens-corrections.js +52 -8
  218. package/dist/output/generic-lens-corrections.js.map +1 -1
  219. package/dist/output/native-capture-sdr.js +5 -2
  220. package/dist/output/native-capture-sdr.js.map +1 -1
  221. package/dist/output/print-plan.d.ts +41 -5
  222. package/dist/output/print-plan.js +59 -14
  223. package/dist/output/print-plan.js.map +1 -1
  224. package/dist/output/sdr-rendering.d.ts +18 -1
  225. package/dist/output/sdr-rendering.js +39 -2
  226. package/dist/output/sdr-rendering.js.map +1 -1
  227. package/dist/sensor/binomial-sample.d.ts +3 -0
  228. package/dist/sensor/binomial-sample.js +86 -0
  229. package/dist/sensor/binomial-sample.js.map +1 -0
  230. package/dist/sensor/native-sensor-report.d.ts +10 -0
  231. package/dist/sensor/native-sensor-report.js +16 -0
  232. package/dist/sensor/native-sensor-report.js.map +1 -0
  233. package/dist/sensor/sensor-characteristics.d.ts +91 -13
  234. package/dist/sensor/sensor-characteristics.js +30 -15
  235. package/dist/sensor/sensor-characteristics.js.map +1 -1
  236. package/docs/AGENT_GUIDE.md +1 -0
  237. package/docs/API_REFERENCE.md +214 -4
  238. package/docs/QUICK_START.md +162 -8
  239. package/docs/USAGE.md +195 -22
  240. package/docs/api/capture-c2pa-embed.md +177 -0
  241. package/docs/api/capture-dng-import.md +86 -10
  242. package/docs/api/capture-dng-opcodes.md +93 -0
  243. package/docs/api/capture-dng-profile-maps.md +141 -0
  244. package/docs/api/capture-dng-stage-image.md +43 -0
  245. package/docs/api/capture-jpeg-xl-tiles.md +33 -0
  246. package/docs/api/capture-lossy-jpeg.md +41 -0
  247. package/docs/api/capture-native-raw-development.md +2 -1
  248. package/docs/api/core-execution-error.md +43 -0
  249. package/docs/api/core-version.md +1 -1
  250. package/docs/api/equipment-generic-lens-catalogue.md +10 -5
  251. package/docs/api/equipment-sensor-profile-body.md +64 -0
  252. package/docs/api/equipment-sensor-profiles.md +86 -0
  253. package/docs/api/exports.json +460 -5
  254. package/docs/api/facade-display-view-gpu.md +5 -2
  255. package/docs/api/facade-display-view.md +11 -15
  256. package/docs/api/facade-exposure-build-up.md +105 -0
  257. package/docs/api/facade-fast-methods.md +47 -10
  258. package/docs/api/facade-image-plane-enable.md +16 -0
  259. package/docs/api/facade-mixed-illumination.md +67 -0
  260. package/docs/api/facade-quality-paths.md +24 -0
  261. package/docs/api/facade-representative-light-sources.md +131 -0
  262. package/docs/api/facade-scene-radiance.md +54 -3
  263. package/docs/api/facade-simulate-capture.md +48 -11
  264. package/docs/api/facade-simulate-display-view.md +10 -12
  265. package/docs/api/gpu-image-kernel-execution.md +0 -36
  266. package/docs/api/motion-subject-motion.md +23 -0
  267. package/docs/api/optics-generic-lens-lateral-color.md +79 -0
  268. package/docs/api/output-camera-channel-response.md +55 -0
  269. package/docs/api/output-developed-lens-corrections.md +10 -1
  270. package/docs/api/output-generic-lens-corrections.md +40 -4
  271. package/docs/api/output-print-plan.md +35 -1
  272. package/docs/api/output-sdr-rendering.md +6 -1
  273. package/docs/api/sensor-sensor-characteristics.md +54 -2
  274. package/llms.txt +3 -0
  275. package/package.json +6 -5
@@ -164,6 +164,7 @@ export function buildPlanarSceneRadianceProvider(input) {
164
164
  const evidence = input.evidence, limitations = input.limitations;
165
165
  const caller = "kind" in scene ? scene : undefined, chart = caller ? undefined : scene;
166
166
  const materialScene = caller?.kind === "material-function" ? caller : undefined, materials = chart ? chart.materials : materialScene?.materials;
167
+ const imageScene = caller?.kind === "image-plane" ? caller : undefined;
167
168
  const placed = geometry.chart, half = placed ? placed.widthM / 2 : 0, chartAspect = placed ? placed.heightM / placed.widthM : 0;
168
169
  const shapeAt = tabulatedSpectrum(illuminant.shape);
169
170
  /** A material scene's material at a frame point: the caller's index, or `materials.length` for a fixed-size chart's surround. */
@@ -183,6 +184,30 @@ export function buildPlanarSceneRadianceProvider(input) {
183
184
  throw new InvalidConfigurationError("Scene materialAt must return an index into its materials.");
184
185
  return index;
185
186
  }
187
+ const light = input.irradianceAt;
188
+ if (light && caller?.kind === "radiance-function")
189
+ throw new InvalidConfigurationError("illumination needs a lit scene; a radiance-function scene ignores the illuminant.");
190
+ // #597 (2.22.0): mixed light over a print reads the print's reflectance spectrum (its pixels' spectra, cached per spectral node) times the
191
+ // blended irradiance at each point; no per-pixel signal is cached (the image access below is left out), so every site integrates at use.
192
+ /** #550: reflectance × the blended irradiance at the point (chart-local units with a fixed-size chart) / π. */
193
+ function litRadianceAt(u, v, nm) {
194
+ let cu = u, cv = v, reflectance;
195
+ if (placed) {
196
+ cu = u * scale / half;
197
+ cv = v * scale / half;
198
+ }
199
+ if (materialScene)
200
+ reflectance = materialReflectanceOf(callerMaterialAt(u, v), nm);
201
+ else if (placed && !(Math.abs(cu) <= 1 && Math.abs(cv) <= chartAspect))
202
+ reflectance = placed.surroundReflectance;
203
+ else if (chart)
204
+ reflectance = chart.reflectanceAt(cu, cv, nm);
205
+ else if (imageScene)
206
+ reflectance = imageScene.reflectanceAt(cu, cv, nm);
207
+ else
208
+ reflectance = callerReflectance(placed ? { xM: u * scale, yM: v * scale, u, v, wavelengthNanometers: nm, chartU: cu, chartV: cv } : { xM: u * scale, yM: v * scale, u, v, wavelengthNanometers: nm });
209
+ return reflectance * light(cu, cv, u * scale, v * scale, nm) / Math.PI;
210
+ }
186
211
  function radianceAt(u, v, nm) {
187
212
  if (materialScene)
188
213
  return materialRadianceOf(callerMaterialAt(u, v), nm);
@@ -191,21 +216,26 @@ export function buildPlanarSceneRadianceProvider(input) {
191
216
  const xM = u * scale, yM = v * scale, cu = xM / half, cv = yM / half;
192
217
  if (!(Math.abs(cu) <= 1 && Math.abs(cv) <= chartAspect))
193
218
  return placed.surroundReflectance * irradianceScale * shapeAt(nm) / Math.PI;
194
- if (chart)
195
- return chart.reflectanceAt(cu, cv, nm) * irradianceScale * shapeAt(nm) / Math.PI;
219
+ // #581: an image-plane print, like a chart, in print-local units.
220
+ const planar = chart ?? imageScene;
221
+ if (planar)
222
+ return planar.reflectanceAt(cu, cv, nm) * irradianceScale * shapeAt(nm) / Math.PI;
196
223
  return callerValue({ xM, yM, u, v, wavelengthNanometers: nm, chartU: cu, chartV: cv }, nm);
197
224
  }
198
225
  if (chart)
199
226
  return chart.reflectanceAt(u, v, nm) * irradianceScale * shapeAt(nm) / Math.PI;
200
227
  return callerValue({ xM: u * scale, yM: v * scale, u, v, wavelengthNanometers: nm }, nm);
201
228
  }
229
+ function callerReflectance(point) {
230
+ const value = caller.evaluate(point);
231
+ if (typeof value !== "number" || !Number.isFinite(value) || value < 0 || value > 1)
232
+ throw new InvalidConfigurationError("Scene reflectance function must return a value in [0, 1].");
233
+ return value;
234
+ }
202
235
  function callerValue(point, nm) {
236
+ if (caller.kind === "reflectance-function")
237
+ return callerReflectance(point) * irradianceScale * shapeAt(nm) / Math.PI;
203
238
  const value = caller.evaluate(point);
204
- if (caller.kind === "reflectance-function") {
205
- if (typeof value !== "number" || !Number.isFinite(value) || value < 0 || value > 1)
206
- throw new InvalidConfigurationError("Scene reflectance function must return a value in [0, 1].");
207
- return value * irradianceScale * shapeAt(nm) / Math.PI;
208
- }
209
239
  if (typeof value !== "number" || !Number.isFinite(value) || value < 0)
210
240
  throw new InvalidConfigurationError("Scene radiance function must return a finite non-negative radiance.");
211
241
  return value;
@@ -217,6 +247,9 @@ export function buildPlanarSceneRadianceProvider(input) {
217
247
  }
218
248
  /** Spectral radiance of material `material` (`materials.length`: a fixed-size chart's surround), in the chart's expression order. */
219
249
  function materialRadianceOf(material, nm) {
250
+ return materialReflectanceOf(material, nm) * irradianceScale * shapeAt(nm) / Math.PI;
251
+ }
252
+ function materialReflectanceOf(material, nm) {
220
253
  const m = materials[material];
221
254
  let value;
222
255
  if (m === undefined)
@@ -230,7 +263,7 @@ export function buildPlanarSceneRadianceProvider(input) {
230
263
  }
231
264
  if (!(value >= 0))
232
265
  throw new InvalidConfigurationError("Unknown chart material.");
233
- return value * irradianceScale * shapeAt(nm) / Math.PI;
266
+ return value;
234
267
  }
235
268
  function chartMaterialAt(u, v) {
236
269
  if (!placed)
@@ -238,10 +271,13 @@ export function buildPlanarSceneRadianceProvider(input) {
238
271
  const cu = u * scale / half, cv = v * scale / half;
239
272
  return Math.abs(cu) <= 1 && Math.abs(cv) <= chartAspect ? chart.materialAt(cu, cv) : chart.materials.length;
240
273
  }
241
- const chartAccess = chart ? { chartMaterialAt, materialRadiance: materialRadianceOf } :
274
+ const chartAccess = light ? {} : chart ? { chartMaterialAt, materialRadiance: materialRadianceOf } :
242
275
  materialScene ? { chartMaterialAt: callerMaterialAt, materialRadiance: materialRadianceOf } : {};
276
+ // #581: an image-plane print in node values at a frame point (the surround outside it), for the tabulated expected signal.
277
+ // #597: under mixed light the scene has no per-pixel signals: every renderer integrates litRadianceAt, and the GPU pass lights each point.
278
+ const imageAccess = imageScene ? { imageSignalScene: (wavelengths, perNode) => imageScene.signalScene(wavelengths, perNode, Float64Array.from(wavelengths, (nm) => irradianceScale * shapeAt(nm) / Math.PI), light ? litRadianceAt : radianceAt, scale, half, placed.surroundReflectance, light ? input.illumination ?? null : undefined) } : {};
243
279
  // #394: evaluateRadiance's own plane-point arithmetic; radianceAt is then materialRadianceOf(material, nm) for both scene forms.
244
- const materialAtPoint = chart ? chartMaterialAt : materialScene ? callerMaterialAt : undefined;
280
+ const materialAtPoint = light ? undefined : chart ? chartMaterialAt : materialScene ? callerMaterialAt : undefined;
245
281
  const materialOfDirection = materialAtPoint === undefined ? undefined : (o) => {
246
282
  const lz = -o.z;
247
283
  if (!(lz > 0))
@@ -249,8 +285,9 @@ export function buildPlanarSceneRadianceProvider(input) {
249
285
  const t = distance / lz;
250
286
  return materialAtPoint(-o.x * t / scale, -o.y * t / scale);
251
287
  };
288
+ const radiance = light ? litRadianceAt : radianceAt;
252
289
  const provider = {
253
- sceneId, providerProfileId, radianceAt, ...chartAccess,
290
+ sceneId, providerProfileId, radianceAt: radiance, ...chartAccess, ...imageAccess,
254
291
  evaluateRadiance(request) {
255
292
  const target = request.target;
256
293
  if (target.kind !== "environment-direction")
@@ -262,14 +299,14 @@ export function buildPlanarSceneRadianceProvider(input) {
262
299
  throw new InvalidConfigurationError("Planar scene query does not point toward the scene plane.");
263
300
  }
264
301
  const t = distance / lz;
265
- return result(request, radianceAt(-o.x * t / scale, -o.y * t / scale, request.wavelengthNanometers));
302
+ return result(request, radiance(-o.x * t / scale, -o.y * t / scale, request.wavelengthNanometers));
266
303
  },
267
304
  evaluateApertureRadiance(request, ray) {
268
305
  const d = ray.directionUnitVector, origin = ray.originM;
269
306
  if (!(d.z > 0))
270
307
  throw new InvalidConfigurationError("Planar scene pupil ray does not point toward the scene plane.");
271
308
  const t = (distance - origin.z) / d.z;
272
- return result(request, radianceAt((origin.x + d.x * t) / scale, (origin.y + d.y * t) / scale, request.wavelengthNanometers));
309
+ return result(request, radiance((origin.x + d.x * t) / scale, (origin.y + d.y * t) / scale, request.wavelengthNanometers));
273
310
  }
274
311
  };
275
312
  if (materialOfDirection)
@@ -1 +1 @@
1
- {"version":3,"file":"scene-radiance.js","sourceRoot":"","sources":["../../src/facade/scene-radiance.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,qCAAqC,EAAE,2BAA2B,EACtC,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAAE,4BAA4B,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,iCAAiC,EAAE,oCAAoC,EAChK,+BAA+B,EAAyB,MAAM,yBAAyB,CAAC;AAI1F,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAmE,MAAM,mBAAmB,CAAC;AAC7I,OAAO,EAAE,0BAA0B,EAAgC,MA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CAAC,GAAG,MAAM,CAAC,SAAsB,CAAC,CAAC;QAClD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,mBAA4B,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,CAAC,UAAuD;YAC5J,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,oBAAoB,CAAC,CAAC,EAAE,kBAAkB,GAAG,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC;YAC7G,cAAc,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACjG,CAAC;IACD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;QAAE,IAAI,GAAG,KAAK,MAAM,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,UAAU;YAAE,MAAM,IAAI,yBAAyB,CAAC,uBAAuB,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC;IAC/K,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,sBAAsB,IAAI,MAAM,CAAC,IAAI,KAAK,mBAAmB,CAAC,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,UAAU;QAC1H,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,IAAI,CAAC,oCAAoC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;QAAE,MAAM,IAAI,yBAAyB,CAAC,uEAAuE,CAAC,CAAC;IACjN,OAAO,MAAiE,CAAC;AAC3E,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Turns a facade scene and an illuminant into a scene radiance provider for the existing native\n * environment RAW contract (`NativeEnvironmentRawProvider.evaluateRadiance` and, for pupil sampling,\n * `evaluateApertureRadiance`). The scene is an engine chart, a caller reflectance function or a caller\n * radiance function.\n *\n * Geometry: one plane perpendicular to the optical axis at `distanceM` in front of the camera. A query's\n * outgoing direction o (scene toward camera, see docs/SENSOR_ENVIRONMENT_QUERY.md) gives the look\n * direction l = -o; the plane point is l·distanceM/l.z. With a pupil ray, the plane point is the ray from\n * its lens origin to z = distanceM.\n *\n * Radiometry: a Lambertian reflector of reflectance ρ(λ) under irradiance E(λ) has radiance\n * L(λ) = ρ(λ)·E(λ)/π (W·m⁻²·sr⁻¹·nm⁻¹). The illuminant spectral shape S(λ) is scaled so that the\n * plane illuminance is E_v = K_m ∫ E(λ) V(λ) dλ with K_m = 683 lm/W (CIE photometric definition) and\n * V(λ) = ȳ(λ) from the engine's analytic CIE 1931 fit. The light is uniform\n * over the plane, with no shadows. Inter-reflection, gloss and fluorescence are not modelled.\n * @see docs/QUICK_START.md\n */\n\nimport { InvalidConfigurationError } from \"../core/configuration-error.js\";\nimport { requireInputObject } from \"../core/record-validation.js\";\nimport { estimateCie1931ColorMatchingFunctions, prepareColorimetricSpectrum, type ColorimetricSpectrum,\n type PreparedColorimetricSpectrum } from \"../color/color-matching-functions.js\";\nimport { createCieIlluminantASpectrum, createCieDaylightSpectrum, createPlanckianSpectrum, createPortableCieDaylightSpectrum, createPortableCieIlluminantASpectrum,\n createPortablePlanckianSpectrum, type CieDaylightBasis } from \"../color/illuminants.js\";\nimport type { SceneRadianceEvaluationRequest, SceneRadianceEvaluationResult } from \"../schema/scene-radiance.js\";\nimport type { EvidenceProvenance } from \"../core/evidence-provenance.js\";\nimport type { SensorApertureRay } from \"../optics/sensor-aperture-rays.js\";\nimport { resolveChartMaterial, resolveChartScene, type ChartReflectance, type ChartScene, type ResolvedChartScene } from \"./chart-scenes.js\";\nimport { resolveChartMaterialLayers, type ChartMaterialLayerScene } from \"./chart-material-layers.js\";\n\n/** CIE maximum luminous efficacy for photopic vision, lm/W. */\nexport const PHOTOPIC_MAXIMUM_LUMINOUS_EFFICACY_LM_PER_W = 683;\n/** Wavelength range of every facade spectrum and of the facade sensor quadrature, nm. */\nexport const FACADE_SPECTRAL_RANGE_NANOMETERS = /* @__PURE__ */ Object.freeze({ minimum: 380, maximum: 780 });\n\n/**\n * Illuminant choices. CIE D65 is not bundled: its S0/S1/S2 basis tables must come from the caller\n * (`daylight`). `planckian` is Planck's law; `cie-a` is CIE illuminant A from its defining formula.\n */\nexport type CaptureIlluminant =\n | \"cie-a\"\n | { kind: \"planckian\"; temperatureKelvin: number }\n | { kind: \"cie-a\" }\n | { kind: \"daylight\"; correlatedColorTemperatureKelvin: number; basis: CieDaylightBasis }\n | { kind: \"spectrum\"; spectrum: ColorimetricSpectrum; label?: string };\n\nexport interface ResolvedCaptureIlluminant {\n /** Short public description, for example \"planckian-6500K\". */\n id: string;\n description: string;\n /** Relative spectral shape (arbitrary scale) over at least 380-780 nm. */\n shape: PreparedColorimetricSpectrum;\n /** Original spectrum, for colorimetric white-balance calculations. */\n spectrum: ColorimetricSpectrum;\n}\n\nexport function resolveCaptureIlluminant(value: CaptureIlluminant): ResolvedCaptureIlluminant {\n return resolveIlluminant(value, CAPTURE_SPECTRA);\n}\n/**\n * The spectrum constructors of the engine's own illuminant formulas: the capture's, or the portable ones (the display view).\n * They are passed in rather than chosen inside {@link resolveIlluminant}, so a bundle that only captures does not contain the\n * portable ones.\n */\ninterface IlluminantSpectra { planckian: typeof createPlanckianSpectrum; cieA: typeof createCieIlluminantASpectrum; daylight: typeof createCieDaylightSpectrum }\nconst CAPTURE_SPECTRA: IlluminantSpectra = { planckian: createPlanckianSpectrum, cieA: createCieIlluminantASpectrum, daylight: createCieDaylightSpectrum };\n/**\n * Internal (not exported from the package): {@link resolveCaptureIlluminant} with the engine's own formulas (Planckian,\n * CIE A, daylight locus) evaluated with the portable power and e^x − 1 (`portablePow`, `portableExpm1`), so the spectrum\n * has the same bits in every JavaScript engine. The display view uses it; captures keep {@link resolveCaptureIlluminant}.\n * A caller spectrum is the caller's own.\n */\nexport function resolvePortableCaptureIlluminant(value: CaptureIlluminant): ResolvedCaptureIlluminant {\n return resolveIlluminant(value, { planckian: createPortablePlanckianSpectrum, cieA: createPortableCieIlluminantASpectrum, daylight: createPortableCieDaylightSpectrum });\n}\nfunction resolveIlluminant(value: CaptureIlluminant, spectra: IlluminantSpectra): ResolvedCaptureIlluminant {\n if (value === \"cie-a\") return resolveIlluminant({ kind: \"cie-a\" }, spectra);\n requireInputObject(value, \"illuminant\");\n const record = value as unknown as Record<string, unknown>;\n const allowed: Record<string, readonly string[]> = { planckian: [\"kind\", \"temperatureKelvin\"], \"cie-a\": [\"kind\"],\n daylight: [\"kind\", \"correlatedColorTemperatureKelvin\", \"basis\"], spectrum: [\"kind\", \"spectrum\", \"label\"] };\n const keys = typeof record.kind === \"string\" ? allowed[record.kind] : undefined;\n if (!keys) throw new InvalidConfigurationError(\"Unknown illuminant kind.\");\n for (const key of Object.keys(record)) if (!keys.includes(key)) throw new InvalidConfigurationError(\"Unknown illuminant field: \" + key + \".\");\n let spectrum: ColorimetricSpectrum, id: string, description: string;\n try {\n switch (value.kind) {\n case \"planckian\": {\n const t = value.temperatureKelvin;\n if (typeof t !== \"number\" || !Number.isFinite(t) || t < 1000 || t > 25000) throw new InvalidConfigurationError(\"Planckian temperature must be 1000-25000 K.\");\n spectrum = spectra.planckian({ temperatureKelvin: t, wavelengthRangeNanometers: { ...FACADE_SPECTRAL_RANGE_NANOMETERS } });\n id = \"planckian-\" + t + \"K\"; description = \"Planck blackbody spectrum at \" + t + \" K (Planck's law).\";\n break;\n }\n case \"cie-a\":\n spectrum = spectra.cieA(); id = \"cie-a\"; description = \"CIE standard illuminant A from its defining formula: Planck's law with c2 = 1.435e-2 m·K and T = 2848 K, 100 at 560 nm.\";\n break;\n case \"daylight\":\n spectrum = spectra.daylight({ correlatedColorTemperatureKelvin: value.correlatedColorTemperatureKelvin, coefficientRounding: \"cie-three-decimals\", basis: value.basis });\n id = \"cie-daylight-\" + value.correlatedColorTemperatureKelvin + \"K\"; description = \"CIE daylight from the caller's S0/S1/S2 basis (\" + value.basis.datasetId + \").\";\n break;\n case \"spectrum\":\n spectrum = value.spectrum; id = \"caller-spectrum\";\n description = \"Caller illuminant spectrum\" + (typeof value.label === \"string\" ? \" (\" + value.label + \")\" : \"\") + \".\";\n break;\n }\n } catch (error) {\n if (error instanceof InvalidConfigurationError) throw error;\n throw new InvalidConfigurationError(\"Invalid illuminant: \" + (error instanceof Error ? error.message : \"invalid\"));\n }\n let shape: PreparedColorimetricSpectrum;\n try { shape = prepareColorimetricSpectrum(spectrum, \"illuminant\"); } catch (error) {\n throw new InvalidConfigurationError(\"Invalid illuminant spectrum: \" + (error instanceof Error ? error.message : \"invalid\"));\n }\n const range = shape.wavelengthRangeNanometers;\n if (range.minimum > FACADE_SPECTRAL_RANGE_NANOMETERS.minimum || range.maximum < FACADE_SPECTRAL_RANGE_NANOMETERS.maximum)\n throw new InvalidConfigurationError(\"The illuminant spectrum must cover 380-780 nm.\");\n for (let nm = FACADE_SPECTRAL_RANGE_NANOMETERS.minimum; nm <= FACADE_SPECTRAL_RANGE_NANOMETERS.maximum; nm += 1) {\n const s = shape.evaluate(nm);\n if (!(s >= 0)) throw new InvalidConfigurationError(\"The illuminant spectrum must be non-negative over 380-780 nm.\");\n }\n return Object.freeze({ id, description, shape, spectrum });\n}\n\n/**\n * Factor k such that k·S(λ) (W·m⁻²·nm⁻¹) gives `illuminanceLux` on the plane: E_v = 683 ∫ k S ȳ dλ,\n * integrated with the 1 nm trapezoid rule over 380-780 nm (ȳ outside this range is below 4e-5 of its peak).\n */\nexport function calculateIlluminantIrradianceScale(shape: PreparedColorimetricSpectrum, illuminanceLux: number): number {\n if (typeof shape !== \"object\" || shape === null || typeof shape.evaluate !== \"function\") throw new InvalidConfigurationError(\"A prepared illuminant spectrum is required.\");\n if (typeof illuminanceLux !== \"number\" || !Number.isFinite(illuminanceLux) || illuminanceLux <= 0 || illuminanceLux > 1e7)\n throw new InvalidConfigurationError(\"Illuminance must be a positive number of lux up to 1e7.\");\n let sum = 0;\n for (let nm = FACADE_SPECTRAL_RANGE_NANOMETERS.minimum; nm <= FACADE_SPECTRAL_RANGE_NANOMETERS.maximum; nm++) {\n const w = nm === FACADE_SPECTRAL_RANGE_NANOMETERS.minimum || nm === FACADE_SPECTRAL_RANGE_NANOMETERS.maximum ? 0.5 : 1;\n sum += w * shape.evaluate(nm) * estimateCie1931ColorMatchingFunctions(nm).y;\n }\n if (!(sum > 0)) throw new InvalidConfigurationError(\"The illuminant has no luminous power.\");\n return illuminanceLux / (PHOTOPIC_MAXIMUM_LUMINOUS_EFFICACY_LM_PER_W * sum);\n}\n\n/**\n * A point of the scene plane passed to caller scene functions: a new object for every call, which the engine does not read\n * after the call (not frozen: freezing cost about 40 % of a chart lookup).\n */\nexport interface ScenePlanePoint {\n /** Metres on the plane, from the optical axis: +x right, +y up (as seen from the camera). */\n xM: number;\n yM: number;\n /** The same point in frame units (u = ±1 at the left/right frame edges, v up on the same scale). */\n u: number;\n v: number;\n wavelengthNanometers: number;\n /**\n * 2.3, only with a fixed-size chart (`chartSize`): the point in chart-local frame units (±1 at the chart's\n * left/right edges, v up on the same scale, ±chart height/width at its top/bottom). The function is then\n * called only for points on the chart; the surround is the placement's surround reflectance.\n */\n chartU?: number;\n chartV?: number;\n}\n/** Caller Lambertian reflectance (in [0, 1]) lit by the facade illuminant. */\nexport interface CallerReflectanceScene { kind: \"reflectance-function\"; sceneId: string; evaluate(point: Readonly<ScenePlanePoint>): number }\n/** Caller absolute spectral radiance in W·m⁻²·sr⁻¹·nm⁻¹; the facade illuminant is not used. */\nexport interface CallerRadianceScene { kind: \"radiance-function\"; sceneId: string; evaluate(point: Readonly<ScenePlanePoint>): number }\n/** 2.7: a scene-plane point without a wavelength, passed to a material scene's `materialAt`. */\nexport type SceneMaterialPoint = Omit<ScenePlanePoint, \"wavelengthNanometers\">;\n/**\n * 2.7 (#386): a piecewise-constant caller scene, lit by the facade illuminant like a reflectance function. `materials` are\n * reflectances as a chart's patches take them (a neutral number in [0, 1] or a reflectance spectrum covering 380–780 nm, at\n * most {@link CALLER_MATERIAL_SCENE_MAX_MATERIALS}); `materialAt` returns the index of the material at a plane point (an\n * integer from 0 to materials.length − 1). The radiance at a point is that material's, exactly as for a reflectance function\n * returning its reflectance, but renderers can tabulate each material once: the display view then takes the chart path.\n */\nexport interface CallerMaterialScene {\n kind: \"material-function\";\n sceneId: string;\n materials: readonly ChartReflectance[];\n materialAt(point: Readonly<SceneMaterialPoint>): number;\n}\n/** Most materials a {@link CallerMaterialScene} may list. */\nexport const CALLER_MATERIAL_SCENE_MAX_MATERIALS = 65_536;\n/** Internal: a validated material scene with its materials prepared (and the caller inputs, for the scene digest). */\nexport interface ResolvedCallerMaterialScene {\n kind: \"material-function\";\n sceneId: string;\n materials: ResolvedChartScene[\"materials\"];\n materialInputs: readonly unknown[];\n materialAt(point: Readonly<SceneMaterialPoint>): number;\n}\n/** Internal: a validated caller scene. */\nexport type ResolvedCallerScene = CallerReflectanceScene | CallerRadianceScene | ResolvedCallerMaterialScene;\n\nexport interface PlanarSceneGeometry {\n distanceM: number;\n /** Metres per frame unit on the plane (half the framed width). */\n metresPerFrameUnit: number;\n /**\n * 2.3, opt-in fixed-size chart: the chart is `widthM` × `heightM` on the plane, centred on the optical axis;\n * outside it the plane is a neutral Lambertian surround of `surroundReflectance`, lit by the same illuminant.\n * A chart preset is then resolved in its own frame (aspect heightM / widthM). Without it the chart fills the frame.\n */\n chart?: { widthM: number; heightM: number; surroundReflectance: number };\n}\n\nexport interface PlanarSceneRadianceProvider {\n sceneId: string;\n providerProfileId: string;\n evaluateRadiance(request: Readonly<SceneRadianceEvaluationRequest>): SceneRadianceEvaluationResult;\n evaluateApertureRadiance(request: Readonly<SceneRadianceEvaluationRequest>, ray: Readonly<SensorApertureRay>): SceneRadianceEvaluationResult;\n /** Spectral radiance at a plane point (frame units), the same value the callbacks return. */\n radianceAt(u: number, v: number, wavelengthNanometers: number): number;\n /**\n * 2.3, chart scenes only: the chart material at a plane point (frame units), or `materials.length` for the\n * surround of a fixed-size chart; `materialRadiance` gives that material's spectral radiance, the same value\n * `radianceAt` returns at its points.\n */\n chartMaterialAt?(u: number, v: number): number;\n materialRadiance?(material: number, wavelengthNanometers: number): number;\n}\n\n/**\n * Internal (#394, not exported from the package): per provider of a chart preset or caller material scene, the material its\n * `evaluateRadiance` reads for an environment-direction query with a given outgoing direction (the same plane-point\n * arithmetic), or undefined where `evaluateRadiance` would throw. Its radiance is `materialRadiance(material, wavelength)`.\n */\nconst MATERIAL_OF_DIRECTION = new WeakMap<PlanarSceneRadianceProvider, (direction: Readonly<{ x: number; y: number; z: number }>) => number | undefined>();\n\n/** Internal (#394): the material lookup of a provider built by {@link buildPlanarSceneRadianceProvider}, if it has one. */\nexport function planarProviderMaterialOfDirection(provider: PlanarSceneRadianceProvider):\n ((direction: Readonly<{ x: number; y: number; z: number }>) => number | undefined) | undefined {\n return MATERIAL_OF_DIRECTION.get(provider);\n}\n\nconst UNCERTAINTY = /* @__PURE__ */ Object.freeze({ kind: \"not-quantified\" as const, limitation: \"Analytic planar Lambertian scene; no measured scene, BRDF or illumination.\" });\n\n/** Most distinct wavelengths {@link tabulatedSpectrum} keeps; later ones are evaluated on every call. */\nconst TABULATED_SPECTRUM_MAX_ENTRIES = 4096;\n\n/**\n * Internal (#385): `spectrum.evaluate` remembered per distinct wavelength. A prepared spectrum is a pure function of the\n * wavelength, so the table returns the same double the call would; renderers ask for the same few spectral nodes millions\n * of times, and the illuminant's formula (two transcendental evaluations) was about 30 % of a caller-scene display view.\n */\nexport function tabulatedSpectrum(spectrum: Readonly<PreparedColorimetricSpectrum>): (wavelengthNanometers: number) => number {\n const table = new Map<number, number>();\n return (nm) => {\n let value = table.get(nm);\n if (value === undefined) {\n value = spectrum.evaluate(nm);\n if (table.size < TABULATED_SPECTRUM_MAX_ENTRIES) table.set(nm, value);\n }\n return value;\n };\n}\n\n/**\n * Wraps a chart or caller scene as a provider for the native environment RAW task. `irradianceScale` is\n * from {@link calculateIlluminantIrradianceScale}; caller radiance scenes ignore the illuminant.\n */\nexport function buildPlanarSceneRadianceProvider(input: {\n scene: ResolvedChartScene | ResolvedCallerScene;\n sceneId: string;\n providerProfileId: string;\n illuminant: ResolvedCaptureIlluminant;\n irradianceScale: number;\n geometry: PlanarSceneGeometry;\n evidence: readonly EvidenceProvenance[];\n limitations: readonly string[];\n /**\n * #549, catalogue fisheyes only: a direction at or beyond 90° from the axis (or straight back) sees no scene and gets zero\n * radiance instead of failing; the plane fills the forward hemisphere only. Omitted: such a query fails, as before.\n */\n zeroBeyondHorizon?: true;\n}): PlanarSceneRadianceProvider {\n const { scene, illuminant, irradianceScale, geometry } = input, zeroBeyondHorizon = input.zeroBeyondHorizon === true;\n const scale = geometry.metresPerFrameUnit, distance = geometry.distanceM, sceneId = input.sceneId, providerProfileId = input.providerProfileId;\n const evidence = input.evidence, limitations = input.limitations;\n const caller = \"kind\" in scene ? scene : undefined, chart = caller ? undefined : scene as ResolvedChartScene;\n const materialScene = caller?.kind === \"material-function\" ? caller : undefined, materials = chart ? chart.materials : materialScene?.materials;\n const placed = geometry.chart, half = placed ? placed.widthM / 2 : 0, chartAspect = placed ? placed.heightM / placed.widthM : 0;\n const shapeAt = tabulatedSpectrum(illuminant.shape);\n /** A material scene's material at a frame point: the caller's index, or `materials.length` for a fixed-size chart's surround. */\n function callerMaterialAt(u: number, v: number): number {\n const xM = u * scale, yM = v * scale;\n let point: SceneMaterialPoint;\n if (placed) {\n const cu = xM / half, cv = yM / half;\n if (!(Math.abs(cu) <= 1 && Math.abs(cv) <= chartAspect)) return materialScene!.materials.length;\n point = { xM, yM, u, v, chartU: cu, chartV: cv };\n } else point = { xM, yM, u, v };\n const index = materialScene!.materialAt(point);\n if (!Number.isInteger(index) || index < 0 || index >= materialScene!.materials.length) throw new InvalidConfigurationError(\"Scene materialAt must return an index into its materials.\");\n return index;\n }\n function radianceAt(u: number, v: number, nm: number): number {\n if (materialScene) return materialRadianceOf(callerMaterialAt(u, v), nm);\n if (placed) {\n // Fixed-size chart (2.3): chart-local frame units from the plane point in metres.\n const xM = u * scale, yM = v * scale, cu = xM / half, cv = yM / half;\n if (!(Math.abs(cu) <= 1 && Math.abs(cv) <= chartAspect)) return placed.surroundReflectance * irradianceScale * shapeAt(nm) / Math.PI;\n if (chart) return chart.reflectanceAt(cu, cv, nm) * irradianceScale * shapeAt(nm) / Math.PI;\n return callerValue({ xM, yM, u, v, wavelengthNanometers: nm, chartU: cu, chartV: cv }, nm);\n }\n if (chart) return chart.reflectanceAt(u, v, nm) * irradianceScale * shapeAt(nm) / Math.PI;\n return callerValue({ xM: u * scale, yM: v * scale, u, v, wavelengthNanometers: nm }, nm);\n }\n function callerValue(point: Readonly<ScenePlanePoint>, nm: number): number {\n const value = (caller as CallerReflectanceScene | CallerRadianceScene).evaluate(point);\n if (caller!.kind === \"reflectance-function\") {\n if (typeof value !== \"number\" || !Number.isFinite(value) || value < 0 || value > 1) throw new InvalidConfigurationError(\"Scene reflectance function must return a value in [0, 1].\");\n return value * irradianceScale * shapeAt(nm) / Math.PI;\n }\n if (typeof value !== \"number\" || !Number.isFinite(value) || value < 0) throw new InvalidConfigurationError(\"Scene radiance function must return a finite non-negative radiance.\");\n return value;\n }\n function result(request: Readonly<SceneRadianceEvaluationRequest>, radiance: number): SceneRadianceEvaluationResult {\n return { schemaVersion: \"0.1.0\", sampleId: request.sampleId, sceneId, providerProfileId, wavelengthNanometers: request.wavelengthNanometers,\n wavelengthBasis: request.wavelengthBasis as SceneRadianceEvaluationResult[\"wavelengthBasis\"], quantity: \"outgoing-spectral-radiance\", unit: \"W/m^2/sr/nm\",\n spectralRadianceWattsPerSquareMeterSteradianNanometer: radiance, scientificStatus: \"approximation\", uncertainty: UNCERTAINTY, evidence, limitations };\n }\n /** Spectral radiance of material `material` (`materials.length`: a fixed-size chart's surround), in the chart's expression order. */\n function materialRadianceOf(material: number, nm: number): number {\n const m = materials![material];\n let value: number;\n if (m === undefined) value = placed ? placed.surroundReflectance : NaN;\n else if (m.kind === \"neutral\") value = m.reflectance;\n else {\n value = m.spectrum.evaluate(nm);\n if (!(value >= 0 && value <= 1)) throw new InvalidConfigurationError(\"Chart reflectance spectrum left [0, 1].\");\n }\n if (!(value >= 0)) throw new InvalidConfigurationError(\"Unknown chart material.\");\n return value * irradianceScale * shapeAt(nm) / Math.PI;\n }\n function chartMaterialAt(u: number, v: number): number {\n if (!placed) return chart!.materialAt(u, v);\n const cu = u * scale / half, cv = v * scale / half;\n return Math.abs(cu) <= 1 && Math.abs(cv) <= chartAspect ? chart!.materialAt(cu, cv) : chart!.materials.length;\n }\n const chartAccess = chart ? { chartMaterialAt, materialRadiance: materialRadianceOf } :\n materialScene ? { chartMaterialAt: callerMaterialAt, materialRadiance: materialRadianceOf } : {};\n // #394: evaluateRadiance's own plane-point arithmetic; radianceAt is then materialRadianceOf(material, nm) for both scene forms.\n const materialAtPoint = chart ? chartMaterialAt : materialScene ? callerMaterialAt : undefined;\n const materialOfDirection = materialAtPoint === undefined ? undefined : (o: Readonly<{ x: number; y: number; z: number }>): number | undefined => {\n const lz = -o.z;\n if (!(lz > 0)) return undefined;\n const t = distance / lz;\n return materialAtPoint(-o.x * t / scale, -o.y * t / scale);\n };\n const provider: PlanarSceneRadianceProvider = {\n sceneId, providerProfileId, radianceAt, ...chartAccess,\n evaluateRadiance(request): SceneRadianceEvaluationResult {\n const target = request.target;\n if (target.kind !== \"environment-direction\") throw new InvalidConfigurationError(\"Planar scene provider needs environment-direction queries.\");\n const o = target.outgoingDirectionUnitVector, lz = -o.z;\n if (!(lz > 0)) {\n if (zeroBeyondHorizon && Number.isFinite(lz)) return result(request, 0);\n throw new InvalidConfigurationError(\"Planar scene query does not point toward the scene plane.\");\n }\n const t = distance / lz;\n return result(request, radianceAt(-o.x * t / scale, -o.y * t / scale, request.wavelengthNanometers));\n },\n evaluateApertureRadiance(request, ray): SceneRadianceEvaluationResult {\n const d = ray.directionUnitVector, origin = ray.originM;\n if (!(d.z > 0)) throw new InvalidConfigurationError(\"Planar scene pupil ray does not point toward the scene plane.\");\n const t = (distance - origin.z) / d.z;\n return result(request, radianceAt((origin.x + d.x * t) / scale, (origin.y + d.y * t) / scale, request.wavelengthNanometers));\n }\n };\n if (materialOfDirection) MATERIAL_OF_DIRECTION.set(provider, materialOfDirection);\n return provider;\n}\n\n/** 2.3: a chart's physical size on the scene plane (`simulateCapture` `chartSize`, `createPlanarSceneRadianceProvider` `chartSize`). */\nexport interface ChartSizeOption {\n /** Chart width in metres, (0, 10 000]. */\n widthM: number;\n /** Chart height in metres. Default: widthM × the frame aspect (height / width), so the chart has the frame's shape. */\n heightM?: number;\n /** Neutral reflectance of the plane around the chart, lit by the same illuminant. Default 0.18. */\n surroundReflectance?: number;\n}\n/** Default surround of a fixed-size chart: an 18 % grey plane. */\nexport const CHART_SIZE_DEFAULT_SURROUND_REFLECTANCE = 0.18;\n/** Internal: validates a chart size and fills its defaults; `defaulted` names the fields taken from defaults. */\nexport function resolveChartSizeOption(value: unknown, frameAspect: number): { widthM: number; heightM: number; surroundReflectance: number; defaulted: (\"heightM\" | \"surroundReflectance\")[] } {\n requireInputObject(value, \"chartSize\");\n const record = value as Record<string, unknown>;\n for (const key of Object.keys(record)) if (![\"widthM\", \"heightM\", \"surroundReflectance\"].includes(key)) throw new InvalidConfigurationError(\"Unknown chartSize field: \" + key + \".\");\n const size = (x: unknown, name: string): number => {\n if (typeof x !== \"number\" || !Number.isFinite(x) || x <= 0 || x > 10_000) throw new InvalidConfigurationError(\"chartSize.\" + name + \" must be a positive number of metres up to 10000.\");\n return x;\n };\n const defaulted: (\"heightM\" | \"surroundReflectance\")[] = [];\n const widthM = size(record.widthM, \"widthM\");\n const heightM = record.heightM === undefined ? (defaulted.push(\"heightM\"), widthM * frameAspect) : size(record.heightM, \"heightM\");\n const surround = record.surroundReflectance === undefined ? (defaulted.push(\"surroundReflectance\"), CHART_SIZE_DEFAULT_SURROUND_REFLECTANCE) : record.surroundReflectance;\n if (typeof surround !== \"number\" || !Number.isFinite(surround) || surround < 0 || surround > 1) throw new InvalidConfigurationError(\"chartSize.surroundReflectance must be a reflectance in [0, 1].\");\n return { widthM, heightM, surroundReflectance: surround, defaulted };\n}\n\n/**\n * Public scene-preset provider. Places an engine chart (or a declared `material-layers` scene, #491, evaluated as\n * its `callerScene`; or a caller reflectance, radiance or material function) on\n * a plane `distanceM` in front of the camera and `framedWidthM` wide (frame units u = ±1 at its edges),\n * lit by `illuminant` at `illuminanceLux`. The returned `evaluateRadiance` and `evaluateApertureRadiance`\n * follow the native environment RAW provider contract. They answer requests for scene `sceneId` and\n * provider `providerProfileId`.\n */\nexport function createPlanarSceneRadianceProvider(input: {\n scene: ChartScene | ChartMaterialLayerScene | CallerReflectanceScene | CallerRadianceScene | CallerMaterialScene;\n illuminant: CaptureIlluminant;\n illuminanceLux: number;\n distanceM: number;\n framedWidthM: number;\n /** Frame height / width. */\n aspect: number;\n sceneId: string;\n providerProfileId: string;\n /**\n * 2.3, opt-in: place the chart at this physical size, centred, instead of filling the frame; the chart preset\n * is resolved with aspect heightM / widthM and the rest of the plane is the surround.\n */\n chartSize?: ChartSizeOption;\n}): PlanarSceneRadianceProvider & { chart: ResolvedChartScene | null } {\n requireInputObject(input, \"createPlanarSceneRadianceProvider input\");\n const keys = [\"scene\", \"illuminant\", \"illuminanceLux\", \"distanceM\", \"framedWidthM\", \"aspect\", \"sceneId\", \"providerProfileId\", \"chartSize\"];\n for (const key of Object.keys(input)) if (!keys.includes(key)) throw new InvalidConfigurationError(\"createPlanarSceneRadianceProvider input has unknown field \\\"\" + key + \"\\\".\");\n for (const key of [\"illuminanceLux\", \"distanceM\", \"framedWidthM\", \"aspect\"] as const) {\n const value = input[key];\n if (typeof value !== \"number\" || !Number.isFinite(value) || value <= 0) throw new InvalidConfigurationError(key + \" must be a positive finite number.\");\n }\n for (const key of [\"sceneId\", \"providerProfileId\"] as const) if (typeof input[key] !== \"string\" || !/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/.test(input[key])) throw new InvalidConfigurationError(key + \" must be a public opaque ID.\");\n requireInputObject(input.scene, \"scene\");\n const size = input.chartSize === undefined ? undefined : resolveChartSizeOption(input.chartSize, input.aspect), chartAspect = size ? size.heightM / size.widthM : input.aspect;\n const declared = (input.scene as { kind?: unknown }).kind === \"material-layers\" ? resolveChartMaterialLayers({ scene: input.scene as ChartMaterialLayerScene, aspect: chartAspect }) : undefined;\n const caller = declared ? requireCallerScene(declared.callerScene) : \"kind\" in input.scene ? requireCallerScene(input.scene) : undefined;\n const chart = caller ? null : resolveChartScene({ scene: input.scene as ChartScene, aspect: chartAspect });\n const illuminant = resolveCaptureIlluminant(input.illuminant);\n const provider = buildPlanarSceneRadianceProvider({ scene: chart ?? caller!, sceneId: input.sceneId, providerProfileId: input.providerProfileId, illuminant,\n irradianceScale: calculateIlluminantIrradianceScale(illuminant.shape, input.illuminanceLux),\n geometry: { distanceM: input.distanceM, metresPerFrameUnit: input.framedWidthM / 2,\n ...(size ? { chart: { widthM: size.widthM, heightM: size.heightM, surroundReflectance: size.surroundReflectance } } : {}) },\n evidence: [{ sourceOrigin: \"photivra\", sourceReference: \"photivra:planar-scene-provider\", reuseStatus: \"photivra-owned\" }],\n limitations: [\"Planar Lambertian scene under uniform illumination; no shadows, inter-reflection, gloss or fluorescence.\"] });\n return { ...provider, chart };\n}\n\n/** Validates a caller scene record (a function scene as given; a material scene with its materials prepared). */\nexport function requireCallerScene(value: unknown): ResolvedCallerScene {\n requireInputObject(value, \"scene\");\n const record = value as Record<string, unknown>;\n if (record.kind === \"material-function\") {\n for (const key of Object.keys(record)) if (key !== \"kind\" && key !== \"sceneId\" && key !== \"materials\" && key !== \"materialAt\") throw new InvalidConfigurationError(\"Unknown scene field: \" + key + \".\");\n if (typeof record.materialAt !== \"function\" || typeof record.sceneId !== \"string\" || !/^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/.test(record.sceneId) ||\n !Array.isArray(record.materials) || record.materials.length < 1 || record.materials.length > CALLER_MATERIAL_SCENE_MAX_MATERIALS)\n throw new InvalidConfigurationError(\"A material scene needs a public sceneId, 1 to \" + CALLER_MATERIAL_SCENE_MAX_MATERIALS + \" materials and a materialAt function.\");\n const inputs = [...record.materials as unknown[]];\n return Object.freeze({ kind: \"material-function\" as const, sceneId: record.sceneId, materialAt: record.materialAt as ResolvedCallerMaterialScene[\"materialAt\"],\n materials: Object.freeze(inputs.map((m, index) => resolveChartMaterial(m, \"scene.materials[\" + index + \"]\"))),\n materialInputs: Object.freeze(inputs.map((m) => (typeof m === \"number\" ? undefined : m))) });\n }\n for (const key of Object.keys(record)) if (key !== \"kind\" && key !== \"sceneId\" && key !== \"evaluate\") throw new InvalidConfigurationError(\"Unknown scene field: \" + key + \".\");\n if ((record.kind !== \"reflectance-function\" && record.kind !== \"radiance-function\") || typeof record.evaluate !== \"function\" ||\n typeof record.sceneId !== \"string\" || !/^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/.test(record.sceneId)) throw new InvalidConfigurationError(\"A caller scene needs kind, a public sceneId and an evaluate function.\");\n return record as unknown as CallerReflectanceScene | CallerRadianceScene;\n}\n"]}
1
+ {"version":3,"file":"scene-radiance.js","sourceRoot":"","sources":["../../src/facade/scene-radiance.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,qCAAqC,EAAE,2BAA2B,EACtC,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAAE,4BAA4B,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,iCAAiC,EAAE,oCAAoC,EAChK,+BAA+B,EAAyB,MAAM,yBAAyB,CAAC;AAI1F,O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,KAAK,sBAAsB,IAAI,MAAM,CAAC,IAAI,KAAK,mBAAmB,CAAC,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,UAAU;QAC1H,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,IAAI,CAAC,oCAAoC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;QAAE,MAAM,IAAI,yBAAyB,CAAC,uEAAuE,CAAC,CAAC;IACjN,OAAO,MAAiE,CAAC;AAC3E,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Turns a facade scene and an illuminant into a scene radiance provider for the existing native\n * environment RAW contract (`NativeEnvironmentRawProvider.evaluateRadiance` and, for pupil sampling,\n * `evaluateApertureRadiance`). The scene is an engine chart, a caller reflectance function or a caller\n * radiance function.\n *\n * Geometry: one plane perpendicular to the optical axis at `distanceM` in front of the camera. A query's\n * outgoing direction o (scene toward camera, see docs/SENSOR_ENVIRONMENT_QUERY.md) gives the look\n * direction l = -o; the plane point is l·distanceM/l.z. With a pupil ray, the plane point is the ray from\n * its lens origin to z = distanceM.\n *\n * Radiometry: a Lambertian reflector of reflectance ρ(λ) under irradiance E(λ) has radiance\n * L(λ) = ρ(λ)·E(λ)/π (W·m⁻²·sr⁻¹·nm⁻¹). The illuminant spectral shape S(λ) is scaled so that the\n * plane illuminance is E_v = K_m ∫ E(λ) V(λ) dλ with K_m = 683 lm/W (CIE photometric definition) and\n * V(λ) = ȳ(λ) from the engine's analytic CIE 1931 fit. The light is uniform\n * over the plane, with no shadows. Inter-reflection, gloss and fluorescence are not modelled.\n * @see docs/QUICK_START.md\n */\n\nimport { InvalidConfigurationError } from \"../core/configuration-error.js\";\nimport { requireInputObject } from \"../core/record-validation.js\";\nimport { estimateCie1931ColorMatchingFunctions, prepareColorimetricSpectrum, type ColorimetricSpectrum,\n type PreparedColorimetricSpectrum } from \"../color/color-matching-functions.js\";\nimport { createCieIlluminantASpectrum, createCieDaylightSpectrum, createPlanckianSpectrum, createPortableCieDaylightSpectrum, createPortableCieIlluminantASpectrum,\n createPortablePlanckianSpectrum, type CieDaylightBasis } from \"../color/illuminants.js\";\nimport type { SceneRadianceEvaluationRequest, SceneRadianceEvaluationResult } from \"../schema/scene-radiance.js\";\nimport type { EvidenceProvenance } from \"../core/evidence-provenance.js\";\nimport type { SensorApertureRay } from \"../optics/sensor-aperture-rays.js\";\nimport { resolveChartMaterial, resolveChartScene, type ChartReflectance, type ChartScene, type ResolvedChartScene } from \"./chart-scenes.js\";\nimport { resolveChartMaterialLayers, type ChartMaterialLayerScene } from \"./chart-material-layers.js\";\nimport type { ResolvedMixedIllumination } from \"./mixed-illumination.js\";\n\n/** CIE maximum luminous efficacy for photopic vision, lm/W. */\nexport const PHOTOPIC_MAXIMUM_LUMINOUS_EFFICACY_LM_PER_W = 683;\n/** Wavelength range of every facade spectrum and of the facade sensor quadrature, nm. */\nexport const FACADE_SPECTRAL_RANGE_NANOMETERS = /* @__PURE__ */ Object.freeze({ minimum: 380, maximum: 780 });\n\n/**\n * Illuminant choices. CIE D65 is not bundled: its S0/S1/S2 basis tables must come from the caller\n * (`daylight`). `planckian` is Planck's law; `cie-a` is CIE illuminant A from its defining formula.\n */\nexport type CaptureIlluminant =\n | \"cie-a\"\n | { kind: \"planckian\"; temperatureKelvin: number }\n | { kind: \"cie-a\" }\n | { kind: \"daylight\"; correlatedColorTemperatureKelvin: number; basis: CieDaylightBasis }\n | { kind: \"spectrum\"; spectrum: ColorimetricSpectrum; label?: string };\n\nexport interface ResolvedCaptureIlluminant {\n /** Short public description, for example \"planckian-6500K\". */\n id: string;\n description: string;\n /** Relative spectral shape (arbitrary scale) over at least 380-780 nm. */\n shape: PreparedColorimetricSpectrum;\n /** Original spectrum, for colorimetric white-balance calculations. */\n spectrum: ColorimetricSpectrum;\n}\n\nexport function resolveCaptureIlluminant(value: CaptureIlluminant): ResolvedCaptureIlluminant {\n return resolveIlluminant(value, CAPTURE_SPECTRA);\n}\n/**\n * The spectrum constructors of the engine's own illuminant formulas: the capture's, or the portable ones (the display view).\n * They are passed in rather than chosen inside {@link resolveIlluminant}, so a bundle that only captures does not contain the\n * portable ones.\n */\ninterface IlluminantSpectra { planckian: typeof createPlanckianSpectrum; cieA: typeof createCieIlluminantASpectrum; daylight: typeof createCieDaylightSpectrum }\nconst CAPTURE_SPECTRA: IlluminantSpectra = { planckian: createPlanckianSpectrum, cieA: createCieIlluminantASpectrum, daylight: createCieDaylightSpectrum };\n/**\n * Internal (not exported from the package): {@link resolveCaptureIlluminant} with the engine's own formulas (Planckian,\n * CIE A, daylight locus) evaluated with the portable power and e^x − 1 (`portablePow`, `portableExpm1`), so the spectrum\n * has the same bits in every JavaScript engine. The display view uses it; captures keep {@link resolveCaptureIlluminant}.\n * A caller spectrum is the caller's own.\n */\nexport function resolvePortableCaptureIlluminant(value: CaptureIlluminant): ResolvedCaptureIlluminant {\n return resolveIlluminant(value, { planckian: createPortablePlanckianSpectrum, cieA: createPortableCieIlluminantASpectrum, daylight: createPortableCieDaylightSpectrum });\n}\nfunction resolveIlluminant(value: CaptureIlluminant, spectra: IlluminantSpectra): ResolvedCaptureIlluminant {\n if (value === \"cie-a\") return resolveIlluminant({ kind: \"cie-a\" }, spectra);\n requireInputObject(value, \"illuminant\");\n const record = value as unknown as Record<string, unknown>;\n const allowed: Record<string, readonly string[]> = { planckian: [\"kind\", \"temperatureKelvin\"], \"cie-a\": [\"kind\"],\n daylight: [\"kind\", \"correlatedColorTemperatureKelvin\", \"basis\"], spectrum: [\"kind\", \"spectrum\", \"label\"] };\n const keys = typeof record.kind === \"string\" ? allowed[record.kind] : undefined;\n if (!keys) throw new InvalidConfigurationError(\"Unknown illuminant kind.\");\n for (const key of Object.keys(record)) if (!keys.includes(key)) throw new InvalidConfigurationError(\"Unknown illuminant field: \" + key + \".\");\n let spectrum: ColorimetricSpectrum, id: string, description: string;\n try {\n switch (value.kind) {\n case \"planckian\": {\n const t = value.temperatureKelvin;\n if (typeof t !== \"number\" || !Number.isFinite(t) || t < 1000 || t > 25000) throw new InvalidConfigurationError(\"Planckian temperature must be 1000-25000 K.\");\n spectrum = spectra.planckian({ temperatureKelvin: t, wavelengthRangeNanometers: { ...FACADE_SPECTRAL_RANGE_NANOMETERS } });\n id = \"planckian-\" + t + \"K\"; description = \"Planck blackbody spectrum at \" + t + \" K (Planck's law).\";\n break;\n }\n case \"cie-a\":\n spectrum = spectra.cieA(); id = \"cie-a\"; description = \"CIE standard illuminant A from its defining formula: Planck's law with c2 = 1.435e-2 m·K and T = 2848 K, 100 at 560 nm.\";\n break;\n case \"daylight\":\n spectrum = spectra.daylight({ correlatedColorTemperatureKelvin: value.correlatedColorTemperatureKelvin, coefficientRounding: \"cie-three-decimals\", basis: value.basis });\n id = \"cie-daylight-\" + value.correlatedColorTemperatureKelvin + \"K\"; description = \"CIE daylight from the caller's S0/S1/S2 basis (\" + value.basis.datasetId + \").\";\n break;\n case \"spectrum\":\n spectrum = value.spectrum; id = \"caller-spectrum\";\n description = \"Caller illuminant spectrum\" + (typeof value.label === \"string\" ? \" (\" + value.label + \")\" : \"\") + \".\";\n break;\n }\n } catch (error) {\n if (error instanceof InvalidConfigurationError) throw error;\n throw new InvalidConfigurationError(\"Invalid illuminant: \" + (error instanceof Error ? error.message : \"invalid\"));\n }\n let shape: PreparedColorimetricSpectrum;\n try { shape = prepareColorimetricSpectrum(spectrum, \"illuminant\"); } catch (error) {\n throw new InvalidConfigurationError(\"Invalid illuminant spectrum: \" + (error instanceof Error ? error.message : \"invalid\"));\n }\n const range = shape.wavelengthRangeNanometers;\n if (range.minimum > FACADE_SPECTRAL_RANGE_NANOMETERS.minimum || range.maximum < FACADE_SPECTRAL_RANGE_NANOMETERS.maximum)\n throw new InvalidConfigurationError(\"The illuminant spectrum must cover 380-780 nm.\");\n for (let nm = FACADE_SPECTRAL_RANGE_NANOMETERS.minimum; nm <= FACADE_SPECTRAL_RANGE_NANOMETERS.maximum; nm += 1) {\n const s = shape.evaluate(nm);\n if (!(s >= 0)) throw new InvalidConfigurationError(\"The illuminant spectrum must be non-negative over 380-780 nm.\");\n }\n return Object.freeze({ id, description, shape, spectrum });\n}\n\n/**\n * Factor k such that k·S(λ) (W·m⁻²·nm⁻¹) gives `illuminanceLux` on the plane: E_v = 683 ∫ k S ȳ dλ,\n * integrated with the 1 nm trapezoid rule over 380-780 nm (ȳ outside this range is below 4e-5 of its peak).\n */\nexport function calculateIlluminantIrradianceScale(shape: PreparedColorimetricSpectrum, illuminanceLux: number): number {\n if (typeof shape !== \"object\" || shape === null || typeof shape.evaluate !== \"function\") throw new InvalidConfigurationError(\"A prepared illuminant spectrum is required.\");\n if (typeof illuminanceLux !== \"number\" || !Number.isFinite(illuminanceLux) || illuminanceLux <= 0 || illuminanceLux > 1e7)\n throw new InvalidConfigurationError(\"Illuminance must be a positive number of lux up to 1e7.\");\n let sum = 0;\n for (let nm = FACADE_SPECTRAL_RANGE_NANOMETERS.minimum; nm <= FACADE_SPECTRAL_RANGE_NANOMETERS.maximum; nm++) {\n const w = nm === FACADE_SPECTRAL_RANGE_NANOMETERS.minimum || nm === FACADE_SPECTRAL_RANGE_NANOMETERS.maximum ? 0.5 : 1;\n sum += w * shape.evaluate(nm) * estimateCie1931ColorMatchingFunctions(nm).y;\n }\n if (!(sum > 0)) throw new InvalidConfigurationError(\"The illuminant has no luminous power.\");\n return illuminanceLux / (PHOTOPIC_MAXIMUM_LUMINOUS_EFFICACY_LM_PER_W * sum);\n}\n\n/**\n * A point of the scene plane passed to caller scene functions: a new object for every call, which the engine does not read\n * after the call (not frozen: freezing cost about 40 % of a chart lookup).\n */\nexport interface ScenePlanePoint {\n /** Metres on the plane, from the optical axis: +x right, +y up (as seen from the camera). */\n xM: number;\n yM: number;\n /** The same point in frame units (u = ±1 at the left/right frame edges, v up on the same scale). */\n u: number;\n v: number;\n wavelengthNanometers: number;\n /**\n * 2.3, only with a fixed-size chart (`chartSize`): the point in chart-local frame units (±1 at the chart's\n * left/right edges, v up on the same scale, ±chart height/width at its top/bottom). The function is then\n * called only for points on the chart; the surround is the placement's surround reflectance.\n */\n chartU?: number;\n chartV?: number;\n}\n/** Caller Lambertian reflectance (in [0, 1]) lit by the facade illuminant. */\nexport interface CallerReflectanceScene { kind: \"reflectance-function\"; sceneId: string; evaluate(point: Readonly<ScenePlanePoint>): number }\n/** Caller absolute spectral radiance in W·m⁻²·sr⁻¹·nm⁻¹; the facade illuminant is not used. */\nexport interface CallerRadianceScene { kind: \"radiance-function\"; sceneId: string; evaluate(point: Readonly<ScenePlanePoint>): number }\n/** 2.7: a scene-plane point without a wavelength, passed to a material scene's `materialAt`. */\nexport type SceneMaterialPoint = Omit<ScenePlanePoint, \"wavelengthNanometers\">;\n/**\n * 2.7 (#386): a piecewise-constant caller scene, lit by the facade illuminant like a reflectance function. `materials` are\n * reflectances as a chart's patches take them (a neutral number in [0, 1] or a reflectance spectrum covering 380–780 nm, at\n * most {@link CALLER_MATERIAL_SCENE_MAX_MATERIALS}); `materialAt` returns the index of the material at a plane point (an\n * integer from 0 to materials.length − 1). The radiance at a point is that material's, exactly as for a reflectance function\n * returning its reflectance, but renderers can tabulate each material once: the display view then takes the chart path.\n */\nexport interface CallerMaterialScene {\n kind: \"material-function\";\n sceneId: string;\n materials: readonly ChartReflectance[];\n materialAt(point: Readonly<SceneMaterialPoint>): number;\n}\n/** Most materials a {@link CallerMaterialScene} may list. */\nexport const CALLER_MATERIAL_SCENE_MAX_MATERIALS = 65_536;\n\n/**\n * 2.21 (#581): an image the caller supplies, for an {@link ImagePlaneScene}. `data` holds `width × height` pixels row by row\n * from the top, `channels` (3: RGB, 4: RGBA) samples each, in the encoding's type: `srgb-8` Uint8Array or Uint8ClampedArray\n * (canvas `ImageData.data`), `srgb-16` Uint16Array, `linear-srgb` Float32Array. sRGB primaries and white (IEC 61966-2-1) in\n * every encoding; `srgb-8` and `srgb-16` are decoded with the sRGB transfer function, `linear-srgb` is already linear and is\n * clipped to [0, 1] (the clipped samples are counted). Alpha is linear coverage over the paper. The array is read, never\n * changed or kept beyond the call.\n */\nexport interface ImagePlaneImage {\n width: number;\n height: number;\n channels: 3 | 4;\n encoding: \"srgb-8\" | \"srgb-16\" | \"linear-srgb\";\n data: Uint8Array | Uint8ClampedArray | Uint16Array | Float32Array;\n}\n/**\n * 2.21 (#581): a photo as a flat matte print on the scene plane, lit by the request's illuminant like a chart. Each pixel's\n * color becomes a reflectance spectrum through the engine's print reflectance lattice (docs/IMAGE_PLANE.md): an\n * approximation, a print of an image that was already processed, clipped and blurred by the camera that took it. The print's\n * physical size is `chartSize` (its height defaults to the image's aspect); without it the print is fitted inside the frame,\n * centered, on the 18 % surround.\n */\nexport interface ImagePlaneScene {\n kind: \"image-plane\";\n sceneId: string;\n image: ImagePlaneImage;\n /** The paper and the deepest ink: reflectances of sRGB white and black, 0 ≤ black < white ≤ 1. Defaults 0.90 and 0.01. */\n paper?: { whiteReflectance?: number; blackReflectance?: number };\n /** How the print is reconstructed between pixel centers. Default `bilinear` (the pixels' spectra, bilinearly weighted). */\n interpolation?: \"bilinear\" | \"nearest\";\n /** Opt-in raised pixel limit: an integer up to the full-resolution ceiling. Default 24 000 000 pixels. */\n maximumPixels?: number;\n}\n/**\n * Internal (#581): what a pixel's signals are integrated from (`ResolvedImagePlaneScene.pixelSignals`): the lattice's node spectra at\n * the N spectral nodes (node k's reflectance at λ_n at k·N + n), the white radiance and the channel responses per node.\n */\nexport interface ImagePlaneSpectralNodes { count: number; nodeSpectra: Float64Array; whiteRadiance: Float64Array; response: readonly Float64Array[] }\n/**\n * Internal (#581): an image-plane print as the tabulated expected signal's scene (`ResolvedImagePlaneScene.signalScene`): its radiance\n * per node, the direct path's signal (each pixel's Σ_n A_c(λ_n)·L_n integrated from its reconstructed spectrum, `pixelSignals`, then\n * interpolated between pixels), and (for the GPU module) the scene, its spectral nodes and the surround's channel signals.\n */\nexport interface ImagePlaneSignalScene {\n kind: \"radiance\";\n radianceAt(u: number, v: number, nm: number): number;\n signalAt(u: number, v: number, c: number): number;\n image: { scene: ResolvedImagePlaneScene; nodes: ImagePlaneSpectralNodes; surround: readonly [number, number, number]; whiteRadiance: Float64Array; surroundReflectance: number;\n /** #597: under mixed light, its parts and the print's half width in metres (print-local cu = ±1 at ±halfWidthM); no `signalAt` then. */\n light?: { layout: ResolvedMixedIllumination | null; halfWidthM: number } };\n}\n/** #597: an image-plane print under mixed light: the lit radiance only (every site integrates it), and the print for the GPU pass. */\nexport interface ImagePlaneLitScene { kind: \"radiance\"; radianceAt(u: number, v: number, nm: number): number; image: ImagePlaneSignalScene[\"image\"] }\n/**\n * Internal (#581): a validated image-plane scene (src/facade/image-plane.ts, a lazily loaded module), placed on a print of\n * aspect `aspect` (height / width). Print-local coordinates are the chart's: cu = ±1 at the print's left and right edges, cv up\n * on the same scale, ±aspect at its top and bottom.\n */\nexport interface ResolvedImagePlaneScene {\n kind: \"image-plane\";\n sceneId: string;\n width: number;\n height: number;\n aspect: number;\n channels: 3 | 4;\n encoding: ImagePlaneImage[\"encoding\"];\n interpolation: \"bilinear\" | \"nearest\";\n paperWhiteReflectance: number;\n paperBlackReflectance: number;\n maximumPixels: number;\n /** `linear-srgb` samples (color and alpha) clipped to [0, 1]; 0 for the integer encodings. */\n clippedSampleCount: number;\n /** SHA-256 of the image data's bytes, hex. */\n dataSha256: string;\n /** The print's reflectance at a print-local point and wavelength (nm, 380–780). */\n reflectanceAt(cu: number, cv: number, nm: number): number;\n /**\n * One pixel's three channel signals Σ_n A_c(λ_n)·ρ_n·W_n, integrated from its reconstructed spectrum ρ_n (its cell's node spectra\n * blended, then the paper) at the time of use, into `out[at..at + 2]`. No per-channel values of the lattice nodes are formed.\n */\n pixelSignals(index: number, nodes: ImagePlaneSpectralNodes, out: Float64Array, at: number): void;\n /** The print at a print-local point in node values (`nodeValues[k]` of node k, `neutral` of the flat reflectance 1). */\n sampleAt(cu: number, cv: number, nodeValues: Float64Array, neutral: number): number;\n /** One pixel (row-major index) in node values. */\n pixelValue(index: number, nodeValues: Float64Array, neutral: number): number;\n /** One pixel's lattice cell (its base node r·25 + g·5 + b, returned) and its fractions within the cell per channel (written to `out[0..2]`). */\n pixelLattice(index: number, out: Float64Array): number;\n /** Every lattice node's reflectance at one wavelength (nm, 380–780). */\n nodeReflectances(nm: number): Float64Array;\n /**\n * The print placed on the plane (frame point → print-local cu = u·scale/half, cv = v·scale/half; outside |cu| ≤ 1, |cv| ≤ aspect the\n * surround) as the expected signal's scene at these nodes, responses and white radiance (see `ImagePlaneSignalScene`). #597: with\n * `light` (mixed lighting; null when its parts are not given), the lit print: `radianceAt` only, no per-pixel signals.\n */\n signalScene(wavelengths: readonly number[], perNode: readonly Float64Array[], whiteRadiance: Float64Array, radianceAt: (u: number, v: number, nm: number) => number,\n scale: number, half: number, surroundReflectance: number): ImagePlaneSignalScene;\n signalScene(wavelengths: readonly number[], perNode: readonly Float64Array[], whiteRadiance: Float64Array, radianceAt: (u: number, v: number, nm: number) => number,\n scale: number, half: number, surroundReflectance: number, light: ResolvedMixedIllumination | null | undefined): ImagePlaneSignalScene | ImagePlaneLitScene;\n /** The scene's form in the facade's source digest (the image's SHA-256 and shape, the paper, the interpolation, the lattice version). */\n digestForm: Readonly<Record<string, unknown>>;\n /** The result's `scene.parameters`: the image, paper and interpolation, the clipped samples and the image's SHA-256. */\n parameters: Readonly<Record<string, unknown>>;\n}\n/** Internal: a validated material scene with its materials prepared (and the caller inputs, for the scene digest). */\nexport interface ResolvedCallerMaterialScene {\n kind: \"material-function\";\n sceneId: string;\n materials: ResolvedChartScene[\"materials\"];\n materialInputs: readonly unknown[];\n materialAt(point: Readonly<SceneMaterialPoint>): number;\n}\n/** Internal: a validated caller scene. */\nexport type ResolvedCallerScene = CallerReflectanceScene | CallerRadianceScene | ResolvedCallerMaterialScene | ResolvedImagePlaneScene;\n\nexport interface PlanarSceneGeometry {\n distanceM: number;\n /** Metres per frame unit on the plane (half the framed width). */\n metresPerFrameUnit: number;\n /**\n * 2.3, opt-in fixed-size chart: the chart is `widthM` × `heightM` on the plane, centred on the optical axis;\n * outside it the plane is a neutral Lambertian surround of `surroundReflectance`, lit by the same illuminant.\n * A chart preset is then resolved in its own frame (aspect heightM / widthM). Without it the chart fills the frame.\n */\n chart?: { widthM: number; heightM: number; surroundReflectance: number };\n}\n\nexport interface PlanarSceneRadianceProvider {\n sceneId: string;\n providerProfileId: string;\n evaluateRadiance(request: Readonly<SceneRadianceEvaluationRequest>): SceneRadianceEvaluationResult;\n evaluateApertureRadiance(request: Readonly<SceneRadianceEvaluationRequest>, ray: Readonly<SensorApertureRay>): SceneRadianceEvaluationResult;\n /**\n * Spectral radiance at a plane point (frame units), the same value the callbacks return. #551: a moving subject's provider\n * reads it at time `t` (seconds from the first opening, default 0); a still scene ignores it.\n */\n radianceAt(u: number, v: number, wavelengthNanometers: number, t?: number): number;\n /**\n * 2.3, chart scenes only: the chart material at a plane point (frame units), or `materials.length` for the\n * surround of a fixed-size chart; `materialRadiance` gives that material's spectral radiance, the same value\n * `radianceAt` returns at its points.\n */\n chartMaterialAt?(u: number, v: number): number;\n materialRadiance?(material: number, wavelengthNanometers: number): number;\n /**\n * 2.21 (#581), image-plane scenes only: the tabulated expected signal's scene at these spectral nodes and channel responses, its\n * radiance per node and, for the direct path, Σ_n A_c(λ_n)·L(λ_n) integrated from each pixel's reconstructed spectrum\n * (`ResolvedImagePlaneScene.pixelSignals`, the surround's reflectance times the neutral signal outside the print).\n */\n imageSignalScene?(wavelengths: readonly number[], perNode: readonly Float64Array[]): ImagePlaneSignalScene | ImagePlaneLitScene;\n}\n\n/**\n * Internal (#394, not exported from the package): per provider of a chart preset or caller material scene, the material its\n * `evaluateRadiance` reads for an environment-direction query with a given outgoing direction (the same plane-point\n * arithmetic), or undefined where `evaluateRadiance` would throw. Its radiance is `materialRadiance(material, wavelength)`.\n */\nconst MATERIAL_OF_DIRECTION = new WeakMap<PlanarSceneRadianceProvider, (direction: Readonly<{ x: number; y: number; z: number }>) => number | undefined>();\n\n/** Internal (#394): the material lookup of a provider built by {@link buildPlanarSceneRadianceProvider}, if it has one. */\nexport function planarProviderMaterialOfDirection(provider: PlanarSceneRadianceProvider):\n ((direction: Readonly<{ x: number; y: number; z: number }>) => number | undefined) | undefined {\n return MATERIAL_OF_DIRECTION.get(provider);\n}\n\nconst UNCERTAINTY = /* @__PURE__ */ Object.freeze({ kind: \"not-quantified\" as const, limitation: \"Analytic planar Lambertian scene; no measured scene, BRDF or illumination.\" });\n\n/** Most distinct wavelengths {@link tabulatedSpectrum} keeps; later ones are evaluated on every call. */\nconst TABULATED_SPECTRUM_MAX_ENTRIES = 4096;\n\n/**\n * Internal (#385): `spectrum.evaluate` remembered per distinct wavelength. A prepared spectrum is a pure function of the\n * wavelength, so the table returns the same double the call would; renderers ask for the same few spectral nodes millions\n * of times, and the illuminant's formula (two transcendental evaluations) was about 30 % of a caller-scene display view.\n */\nexport function tabulatedSpectrum(spectrum: Readonly<PreparedColorimetricSpectrum>): (wavelengthNanometers: number) => number {\n const table = new Map<number, number>();\n return (nm) => {\n let value = table.get(nm);\n if (value === undefined) {\n value = spectrum.evaluate(nm);\n if (table.size < TABULATED_SPECTRUM_MAX_ENTRIES) table.set(nm, value);\n }\n return value;\n };\n}\n\n/**\n * Wraps a chart or caller scene as a provider for the native environment RAW task. `irradianceScale` is\n * from {@link calculateIlluminantIrradianceScale}; caller radiance scenes ignore the illuminant.\n */\nexport function buildPlanarSceneRadianceProvider(input: {\n scene: ResolvedChartScene | ResolvedCallerScene;\n sceneId: string;\n providerProfileId: string;\n illuminant: ResolvedCaptureIlluminant;\n irradianceScale: number;\n geometry: PlanarSceneGeometry;\n evidence: readonly EvidenceProvenance[];\n limitations: readonly string[];\n /**\n * #549, catalogue fisheyes only: a direction at or beyond 90° from the axis (or straight back) sees no scene and gets zero\n * radiance instead of failing; the plane fills the forward hemisphere only. Omitted: such a query fails, as before.\n */\n zeroBeyondHorizon?: true;\n /**\n * #550, mixed illumination: the plane's spectral irradiance at a plane point, given in chart units (chart-local with a fixed-size\n * chart, frame units without) and in metres from the optical axis, used instead of `irradianceScale`·S(λ). The provider then has no material access (the radiance at a point is\n * no longer a function of its material alone), so every renderer reads `radianceAt`. A radiance-function scene is refused.\n */\n irradianceAt?: (u: number, v: number, xM: number, yM: number, wavelengthNanometers: number) => number;\n /** #597: the illumination's parts behind `irradianceAt`, which an image-plane print hands to the GPU's image-plane pass. */\n illumination?: ResolvedMixedIllumination;\n}): PlanarSceneRadianceProvider {\n const { scene, illuminant, irradianceScale, geometry } = input, zeroBeyondHorizon = input.zeroBeyondHorizon === true;\n const scale = geometry.metresPerFrameUnit, distance = geometry.distanceM, sceneId = input.sceneId, providerProfileId = input.providerProfileId;\n const evidence = input.evidence, limitations = input.limitations;\n const caller = \"kind\" in scene ? scene : undefined, chart = caller ? undefined : scene as ResolvedChartScene;\n const materialScene = caller?.kind === \"material-function\" ? caller : undefined, materials = chart ? chart.materials : materialScene?.materials;\n const imageScene = caller?.kind === \"image-plane\" ? caller : undefined;\n const placed = geometry.chart, half = placed ? placed.widthM / 2 : 0, chartAspect = placed ? placed.heightM / placed.widthM : 0;\n const shapeAt = tabulatedSpectrum(illuminant.shape);\n /** A material scene's material at a frame point: the caller's index, or `materials.length` for a fixed-size chart's surround. */\n function callerMaterialAt(u: number, v: number): number {\n const xM = u * scale, yM = v * scale;\n let point: SceneMaterialPoint;\n if (placed) {\n const cu = xM / half, cv = yM / half;\n if (!(Math.abs(cu) <= 1 && Math.abs(cv) <= chartAspect)) return materialScene!.materials.length;\n point = { xM, yM, u, v, chartU: cu, chartV: cv };\n } else point = { xM, yM, u, v };\n const index = materialScene!.materialAt(point);\n if (!Number.isInteger(index) || index < 0 || index >= materialScene!.materials.length) throw new InvalidConfigurationError(\"Scene materialAt must return an index into its materials.\");\n return index;\n }\n const light = input.irradianceAt;\n if (light && caller?.kind === \"radiance-function\") throw new InvalidConfigurationError(\"illumination needs a lit scene; a radiance-function scene ignores the illuminant.\");\n // #597 (2.22.0): mixed light over a print reads the print's reflectance spectrum (its pixels' spectra, cached per spectral node) times the\n // blended irradiance at each point; no per-pixel signal is cached (the image access below is left out), so every site integrates at use.\n /** #550: reflectance × the blended irradiance at the point (chart-local units with a fixed-size chart) / π. */\n function litRadianceAt(u: number, v: number, nm: number): number {\n let cu = u, cv = v, reflectance: number;\n if (placed) { cu = u * scale / half; cv = v * scale / half; }\n if (materialScene) reflectance = materialReflectanceOf(callerMaterialAt(u, v), nm);\n else if (placed && !(Math.abs(cu) <= 1 && Math.abs(cv) <= chartAspect)) reflectance = placed.surroundReflectance;\n else if (chart) reflectance = chart.reflectanceAt(cu, cv, nm);\n else if (imageScene) reflectance = imageScene.reflectanceAt(cu, cv, nm);\n else reflectance = callerReflectance(placed ? { xM: u * scale, yM: v * scale, u, v, wavelengthNanometers: nm, chartU: cu, chartV: cv } : { xM: u * scale, yM: v * scale, u, v, wavelengthNanometers: nm });\n return reflectance * light!(cu, cv, u * scale, v * scale, nm) / Math.PI;\n }\n function radianceAt(u: number, v: number, nm: number): number {\n if (materialScene) return materialRadianceOf(callerMaterialAt(u, v), nm);\n if (placed) {\n // Fixed-size chart (2.3): chart-local frame units from the plane point in metres.\n const xM = u * scale, yM = v * scale, cu = xM / half, cv = yM / half;\n if (!(Math.abs(cu) <= 1 && Math.abs(cv) <= chartAspect)) return placed.surroundReflectance * irradianceScale * shapeAt(nm) / Math.PI;\n // #581: an image-plane print, like a chart, in print-local units.\n const planar = chart ?? imageScene;\n if (planar) return planar.reflectanceAt(cu, cv, nm) * irradianceScale * shapeAt(nm) / Math.PI;\n return callerValue({ xM, yM, u, v, wavelengthNanometers: nm, chartU: cu, chartV: cv }, nm);\n }\n if (chart) return chart.reflectanceAt(u, v, nm) * irradianceScale * shapeAt(nm) / Math.PI;\n return callerValue({ xM: u * scale, yM: v * scale, u, v, wavelengthNanometers: nm }, nm);\n }\n function callerReflectance(point: Readonly<ScenePlanePoint>): number {\n const value = (caller as CallerReflectanceScene).evaluate(point);\n if (typeof value !== \"number\" || !Number.isFinite(value) || value < 0 || value > 1) throw new InvalidConfigurationError(\"Scene reflectance function must return a value in [0, 1].\");\n return value;\n }\n function callerValue(point: Readonly<ScenePlanePoint>, nm: number): number {\n if (caller!.kind === \"reflectance-function\") return callerReflectance(point) * irradianceScale * shapeAt(nm) / Math.PI;\n const value = (caller as CallerRadianceScene).evaluate(point);\n if (typeof value !== \"number\" || !Number.isFinite(value) || value < 0) throw new InvalidConfigurationError(\"Scene radiance function must return a finite non-negative radiance.\");\n return value;\n }\n function result(request: Readonly<SceneRadianceEvaluationRequest>, radiance: number): SceneRadianceEvaluationResult {\n return { schemaVersion: \"0.1.0\", sampleId: request.sampleId, sceneId, providerProfileId, wavelengthNanometers: request.wavelengthNanometers,\n wavelengthBasis: request.wavelengthBasis as SceneRadianceEvaluationResult[\"wavelengthBasis\"], quantity: \"outgoing-spectral-radiance\", unit: \"W/m^2/sr/nm\",\n spectralRadianceWattsPerSquareMeterSteradianNanometer: radiance, scientificStatus: \"approximation\", uncertainty: UNCERTAINTY, evidence, limitations };\n }\n /** Spectral radiance of material `material` (`materials.length`: a fixed-size chart's surround), in the chart's expression order. */\n function materialRadianceOf(material: number, nm: number): number {\n return materialReflectanceOf(material, nm) * irradianceScale * shapeAt(nm) / Math.PI;\n }\n function materialReflectanceOf(material: number, nm: number): number {\n const m = materials![material];\n let value: number;\n if (m === undefined) value = placed ? placed.surroundReflectance : NaN;\n else if (m.kind === \"neutral\") value = m.reflectance;\n else {\n value = m.spectrum.evaluate(nm);\n if (!(value >= 0 && value <= 1)) throw new InvalidConfigurationError(\"Chart reflectance spectrum left [0, 1].\");\n }\n if (!(value >= 0)) throw new InvalidConfigurationError(\"Unknown chart material.\");\n return value;\n }\n function chartMaterialAt(u: number, v: number): number {\n if (!placed) return chart!.materialAt(u, v);\n const cu = u * scale / half, cv = v * scale / half;\n return Math.abs(cu) <= 1 && Math.abs(cv) <= chartAspect ? chart!.materialAt(cu, cv) : chart!.materials.length;\n }\n const chartAccess = light ? {} : chart ? { chartMaterialAt, materialRadiance: materialRadianceOf } :\n materialScene ? { chartMaterialAt: callerMaterialAt, materialRadiance: materialRadianceOf } : {};\n // #581: an image-plane print in node values at a frame point (the surround outside it), for the tabulated expected signal.\n // #597: under mixed light the scene has no per-pixel signals: every renderer integrates litRadianceAt, and the GPU pass lights each point.\n const imageAccess = imageScene ? { imageSignalScene: (wavelengths: readonly number[], perNode: readonly Float64Array[]): ImagePlaneSignalScene | ImagePlaneLitScene =>\n imageScene.signalScene(wavelengths, perNode, Float64Array.from(wavelengths, (nm) => irradianceScale * shapeAt(nm) / Math.PI), light ? litRadianceAt : radianceAt, scale, half,\n placed!.surroundReflectance, light ? input.illumination ?? null : undefined) } : {};\n // #394: evaluateRadiance's own plane-point arithmetic; radianceAt is then materialRadianceOf(material, nm) for both scene forms.\n const materialAtPoint = light ? undefined : chart ? chartMaterialAt : materialScene ? callerMaterialAt : undefined;\n const materialOfDirection = materialAtPoint === undefined ? undefined : (o: Readonly<{ x: number; y: number; z: number }>): number | undefined => {\n const lz = -o.z;\n if (!(lz > 0)) return undefined;\n const t = distance / lz;\n return materialAtPoint(-o.x * t / scale, -o.y * t / scale);\n };\n const radiance = light ? litRadianceAt : radianceAt;\n const provider: PlanarSceneRadianceProvider = {\n sceneId, providerProfileId, radianceAt: radiance, ...chartAccess, ...imageAccess,\n evaluateRadiance(request): SceneRadianceEvaluationResult {\n const target = request.target;\n if (target.kind !== \"environment-direction\") throw new InvalidConfigurationError(\"Planar scene provider needs environment-direction queries.\");\n const o = target.outgoingDirectionUnitVector, lz = -o.z;\n if (!(lz > 0)) {\n if (zeroBeyondHorizon && Number.isFinite(lz)) return result(request, 0);\n throw new InvalidConfigurationError(\"Planar scene query does not point toward the scene plane.\");\n }\n const t = distance / lz;\n return result(request, radiance(-o.x * t / scale, -o.y * t / scale, request.wavelengthNanometers));\n },\n evaluateApertureRadiance(request, ray): SceneRadianceEvaluationResult {\n const d = ray.directionUnitVector, origin = ray.originM;\n if (!(d.z > 0)) throw new InvalidConfigurationError(\"Planar scene pupil ray does not point toward the scene plane.\");\n const t = (distance - origin.z) / d.z;\n return result(request, radiance((origin.x + d.x * t) / scale, (origin.y + d.y * t) / scale, request.wavelengthNanometers));\n }\n };\n if (materialOfDirection) MATERIAL_OF_DIRECTION.set(provider, materialOfDirection);\n return provider;\n}\n\n/** 2.3: a chart's physical size on the scene plane (`simulateCapture` `chartSize`, `createPlanarSceneRadianceProvider` `chartSize`). */\nexport interface ChartSizeOption {\n /** Chart width in metres, (0, 10 000]. */\n widthM: number;\n /** Chart height in metres. Default: widthM × the frame aspect (height / width), so the chart has the frame's shape. */\n heightM?: number;\n /** Neutral reflectance of the plane around the chart, lit by the same illuminant. Default 0.18. */\n surroundReflectance?: number;\n}\n/** Default surround of a fixed-size chart: an 18 % grey plane. */\nexport const CHART_SIZE_DEFAULT_SURROUND_REFLECTANCE = 0.18;\n/** Internal: validates a chart size and fills its defaults; `defaulted` names the fields taken from defaults. */\nexport function resolveChartSizeOption(value: unknown, frameAspect: number): { widthM: number; heightM: number; surroundReflectance: number; defaulted: (\"heightM\" | \"surroundReflectance\")[] } {\n requireInputObject(value, \"chartSize\");\n const record = value as Record<string, unknown>;\n for (const key of Object.keys(record)) if (![\"widthM\", \"heightM\", \"surroundReflectance\"].includes(key)) throw new InvalidConfigurationError(\"Unknown chartSize field: \" + key + \".\");\n const size = (x: unknown, name: string): number => {\n if (typeof x !== \"number\" || !Number.isFinite(x) || x <= 0 || x > 10_000) throw new InvalidConfigurationError(\"chartSize.\" + name + \" must be a positive number of metres up to 10000.\");\n return x;\n };\n const defaulted: (\"heightM\" | \"surroundReflectance\")[] = [];\n const widthM = size(record.widthM, \"widthM\");\n const heightM = record.heightM === undefined ? (defaulted.push(\"heightM\"), widthM * frameAspect) : size(record.heightM, \"heightM\");\n const surround = record.surroundReflectance === undefined ? (defaulted.push(\"surroundReflectance\"), CHART_SIZE_DEFAULT_SURROUND_REFLECTANCE) : record.surroundReflectance;\n if (typeof surround !== \"number\" || !Number.isFinite(surround) || surround < 0 || surround > 1) throw new InvalidConfigurationError(\"chartSize.surroundReflectance must be a reflectance in [0, 1].\");\n return { widthM, heightM, surroundReflectance: surround, defaulted };\n}\n\n/**\n * Public scene-preset provider. Places an engine chart (or a declared `material-layers` scene, #491, evaluated as\n * its `callerScene`; or a caller reflectance, radiance or material function) on\n * a plane `distanceM` in front of the camera and `framedWidthM` wide (frame units u = ±1 at its edges),\n * lit by `illuminant` at `illuminanceLux`. The returned `evaluateRadiance` and `evaluateApertureRadiance`\n * follow the native environment RAW provider contract. They answer requests for scene `sceneId` and\n * provider `providerProfileId`.\n */\nexport function createPlanarSceneRadianceProvider(input: {\n /** An `image-plane` scene (#581) is refused: it is taken by the facade's capture and display-view functions, which load its module. */\n scene: ChartScene | ChartMaterialLayerScene | CallerReflectanceScene | CallerRadianceScene | CallerMaterialScene | ImagePlaneScene;\n illuminant: CaptureIlluminant;\n illuminanceLux: number;\n distanceM: number;\n framedWidthM: number;\n /** Frame height / width. */\n aspect: number;\n sceneId: string;\n providerProfileId: string;\n /**\n * 2.3, opt-in: place the chart at this physical size, centred, instead of filling the frame; the chart preset\n * is resolved with aspect heightM / widthM and the rest of the plane is the surround.\n */\n chartSize?: ChartSizeOption;\n}): PlanarSceneRadianceProvider & { chart: ResolvedChartScene | null } {\n requireInputObject(input, \"createPlanarSceneRadianceProvider input\");\n const keys = [\"scene\", \"illuminant\", \"illuminanceLux\", \"distanceM\", \"framedWidthM\", \"aspect\", \"sceneId\", \"providerProfileId\", \"chartSize\"];\n for (const key of Object.keys(input)) if (!keys.includes(key)) throw new InvalidConfigurationError(\"createPlanarSceneRadianceProvider input has unknown field \\\"\" + key + \"\\\".\");\n for (const key of [\"illuminanceLux\", \"distanceM\", \"framedWidthM\", \"aspect\"] as const) {\n const value = input[key];\n if (typeof value !== \"number\" || !Number.isFinite(value) || value <= 0) throw new InvalidConfigurationError(key + \" must be a positive finite number.\");\n }\n for (const key of [\"sceneId\", \"providerProfileId\"] as const) if (typeof input[key] !== \"string\" || !/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/.test(input[key])) throw new InvalidConfigurationError(key + \" must be a public opaque ID.\");\n requireInputObject(input.scene, \"scene\");\n const size = input.chartSize === undefined ? undefined : resolveChartSizeOption(input.chartSize, input.aspect), chartAspect = size ? size.heightM / size.widthM : input.aspect;\n const declared = (input.scene as { kind?: unknown }).kind === \"material-layers\" ? resolveChartMaterialLayers({ scene: input.scene as ChartMaterialLayerScene, aspect: chartAspect }) : undefined;\n const caller = declared ? requireCallerScene(declared.callerScene) : \"kind\" in input.scene ? requireCallerScene(input.scene) : undefined;\n const chart = caller ? null : resolveChartScene({ scene: input.scene as ChartScene, aspect: chartAspect });\n const illuminant = resolveCaptureIlluminant(input.illuminant);\n const provider = buildPlanarSceneRadianceProvider({ scene: chart ?? caller!, sceneId: input.sceneId, providerProfileId: input.providerProfileId, illuminant,\n irradianceScale: calculateIlluminantIrradianceScale(illuminant.shape, input.illuminanceLux),\n geometry: { distanceM: input.distanceM, metresPerFrameUnit: input.framedWidthM / 2,\n ...(size ? { chart: { widthM: size.widthM, heightM: size.heightM, surroundReflectance: size.surroundReflectance } } : {}) },\n evidence: [{ sourceOrigin: \"photivra\", sourceReference: \"photivra:planar-scene-provider\", reuseStatus: \"photivra-owned\" }],\n limitations: [\"Planar Lambertian scene under uniform illumination; no shadows, inter-reflection, gloss or fluorescence.\"] });\n return { ...provider, chart };\n}\n\n/** Validates a caller scene record (a function scene as given; a material scene with its materials prepared). */\nexport function requireCallerScene(value: unknown): ResolvedCallerScene {\n requireInputObject(value, \"scene\");\n const record = value as Record<string, unknown>;\n if (record.kind === \"material-function\") {\n for (const key of Object.keys(record)) if (key !== \"kind\" && key !== \"sceneId\" && key !== \"materials\" && key !== \"materialAt\") throw new InvalidConfigurationError(\"Unknown scene field: \" + key + \".\");\n if (typeof record.materialAt !== \"function\" || typeof record.sceneId !== \"string\" || !/^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/.test(record.sceneId) ||\n !Array.isArray(record.materials) || record.materials.length < 1 || record.materials.length > CALLER_MATERIAL_SCENE_MAX_MATERIALS)\n throw new InvalidConfigurationError(\"A material scene needs a public sceneId, 1 to \" + CALLER_MATERIAL_SCENE_MAX_MATERIALS + \" materials and a materialAt function.\");\n const inputs = [...record.materials as unknown[]];\n return Object.freeze({ kind: \"material-function\" as const, sceneId: record.sceneId, materialAt: record.materialAt as ResolvedCallerMaterialScene[\"materialAt\"],\n materials: Object.freeze(inputs.map((m, index) => resolveChartMaterial(m, \"scene.materials[\" + index + \"]\"))),\n materialInputs: Object.freeze(inputs.map((m) => (typeof m === \"number\" ? undefined : m))) });\n }\n for (const key of Object.keys(record)) if (key !== \"kind\" && key !== \"sceneId\" && key !== \"evaluate\") throw new InvalidConfigurationError(\"Unknown scene field: \" + key + \".\");\n if ((record.kind !== \"reflectance-function\" && record.kind !== \"radiance-function\") || typeof record.evaluate !== \"function\" ||\n typeof record.sceneId !== \"string\" || !/^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/.test(record.sceneId)) throw new InvalidConfigurationError(\"A caller scene needs kind, a public sceneId and an evaluate function.\");\n return record as unknown as CallerReflectanceScene | CallerRadianceScene;\n}\n"]}