@photivra/engine 2.16.0 → 2.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -1
- package/CITATION.cff +1 -1
- package/README.md +6 -6
- package/SECURITY.md +1 -1
- package/THIRD_PARTY.md +24 -0
- package/dist/camera/lens-projection.d.ts +5 -0
- package/dist/camera/lens-projection.js +10 -0
- package/dist/camera/lens-projection.js.map +1 -1
- package/dist/core/version.d.ts +1 -1
- package/dist/core/version.js +1 -1
- package/dist/core/version.js.map +1 -1
- package/dist/equipment/generic-lens-catalogue.d.ts +227 -0
- package/dist/equipment/generic-lens-catalogue.js +243 -0
- package/dist/equipment/generic-lens-catalogue.js.map +1 -0
- package/dist/facade/defocus-bokeh-zones.d.ts +33 -0
- package/dist/facade/defocus-bokeh-zones.js +53 -0
- package/dist/facade/defocus-bokeh-zones.js.map +1 -0
- package/dist/facade/defocus-image-space-provider.d.ts +9 -0
- package/dist/facade/defocus-image-space-provider.js +96 -7
- package/dist/facade/defocus-image-space-provider.js.map +1 -1
- package/dist/facade/diffraction-provider.d.ts +29 -0
- package/dist/facade/diffraction-provider.js +117 -11
- package/dist/facade/diffraction-provider.js.map +1 -1
- package/dist/facade/display-view-gpu-session.js +4 -0
- package/dist/facade/display-view-gpu-session.js.map +1 -1
- package/dist/facade/display-view-gpu.d.ts +10 -0
- package/dist/facade/display-view-gpu.js.map +1 -1
- package/dist/facade/display-view-lens-signal.d.ts +30 -0
- package/dist/facade/display-view-lens-signal.js +427 -0
- package/dist/facade/display-view-lens-signal.js.map +1 -0
- package/dist/facade/expected-signal-setup.d.ts +7 -0
- package/dist/facade/expected-signal-setup.js +12 -2
- package/dist/facade/expected-signal-setup.js.map +1 -1
- package/dist/facade/expected-signal.d.ts +8 -0
- package/dist/facade/expected-signal.js +150 -0
- package/dist/facade/expected-signal.js.map +1 -1
- package/dist/facade/generic-lens-capture.d.ts +6 -0
- package/dist/facade/generic-lens-capture.js +8 -0
- package/dist/facade/generic-lens-capture.js.map +1 -0
- package/dist/facade/large-defocus-lattice.d.ts +39 -0
- package/dist/facade/large-defocus-lattice.js +64 -0
- package/dist/facade/large-defocus-lattice.js.map +1 -0
- package/dist/facade/scene-radiance.d.ts +5 -0
- package/dist/facade/scene-radiance.js +5 -2
- package/dist/facade/scene-radiance.js.map +1 -1
- package/dist/facade/simulate-capture.d.ts +38 -5
- package/dist/facade/simulate-capture.js +306 -49
- package/dist/facade/simulate-capture.js.map +1 -1
- package/dist/facade/simulate-display-view.js +22 -16
- package/dist/facade/simulate-display-view.js.map +1 -1
- package/dist/gpu/display-view-quality-gpu.d.ts +0 -9
- package/dist/gpu/display-view-quality-gpu.js +6 -0
- package/dist/gpu/display-view-quality-gpu.js.map +1 -1
- package/dist/gpu/display-view-speed-gpu.js +2 -0
- package/dist/gpu/display-view-speed-gpu.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/optics/defocus-bokeh-kernel.d.ts +207 -0
- package/dist/optics/defocus-bokeh-kernel.js +380 -0
- package/dist/optics/defocus-bokeh-kernel.js.map +1 -0
- package/dist/optics/defocus-disc-kernel.d.ts +41 -19
- package/dist/optics/defocus-disc-kernel.js +44 -23
- package/dist/optics/defocus-disc-kernel.js.map +1 -1
- package/dist/optics/generic-lens-psf.d.ts +68 -0
- package/dist/optics/generic-lens-psf.js +337 -0
- package/dist/optics/generic-lens-psf.js.map +1 -0
- package/dist/optics/illumination-vignetting.d.ts +6 -0
- package/dist/optics/illumination-vignetting.js +24 -7
- package/dist/optics/illumination-vignetting.js.map +1 -1
- package/dist/optics/sensor-environment-query.d.ts +6 -0
- package/dist/optics/sensor-environment-query.js +13 -6
- package/dist/optics/sensor-environment-query.js.map +1 -1
- package/dist/optics/site-kernel-runs.d.ts +77 -0
- package/dist/optics/site-kernel-runs.js +200 -0
- package/dist/optics/site-kernel-runs.js.map +1 -0
- package/dist/output/generic-lens-corrections.d.ts +24 -0
- package/dist/output/generic-lens-corrections.js +51 -0
- package/dist/output/generic-lens-corrections.js.map +1 -0
- package/docs/AGENT_GUIDE.md +1 -0
- package/docs/API_REFERENCE.md +49 -1
- package/docs/QUICK_START.md +257 -17
- package/docs/USAGE.md +57 -5
- package/docs/api/core-version.md +1 -1
- package/docs/api/equipment-generic-lens-catalogue.md +281 -0
- package/docs/api/exports.json +137 -2
- package/docs/api/facade-simulate-capture.md +23 -2
- package/docs/api/optics-defocus-bokeh-kernel.md +145 -0
- package/docs/api/optics-defocus-disc-kernel.md +22 -15
- package/docs/api/optics-sensor-environment-query.md +6 -0
- package/docs/api/output-generic-lens-corrections.md +39 -0
- package/llms.txt +1 -0
- package/package.json +1 -1
|
@@ -75,9 +75,12 @@ import { calculateCaptureExposureWindows } from "../sensor/exposure-window.js";
|
|
|
75
75
|
import { calculateSensorSpectralQuadrature } from "../sensor/spectral-quadrature.js";
|
|
76
76
|
import { createDiffractionLimitedPsfProfile } from "../optics/diffraction-psf-profile.js";
|
|
77
77
|
import { registerDiffractionPsfKey, siteDiffractionKernel } from "../optics/site-diffraction-kernel.js";
|
|
78
|
-
import { convolveSiteKernels, createDefocusDiscSiteKernel, requireDefocusDiscKernelRadius, resolveDefocusDisc } from "../optics/defocus-disc-kernel.js";
|
|
78
|
+
import { convolveSiteKernels, createDefocusDiscSiteKernel, defocusDiscKernelRadius, defocusDiscLimitMessage, requireDefocusDiscKernelRadius, resolveDefocusDisc } from "../optics/defocus-disc-kernel.js";
|
|
79
79
|
import { calculateDefocusFieldVariation, createDefocusImageSpaceProvider, prepareDefocusImageSpaceGeometry } from "./defocus-image-space-provider.js";
|
|
80
80
|
import { createDiffractedPlanarProvider } from "./diffraction-provider.js";
|
|
81
|
+
import { DEFOCUS_DIRECT_KERNEL_MAXIMUM_RADIUS_SITES, siteKernelRuns } from "../optics/site-kernel-runs.js";
|
|
82
|
+
import { createDefocusBokehSiteKernel, resolveDefocusBokehOptions } from "../optics/defocus-bokeh-kernel.js";
|
|
83
|
+
import { planDefocusBokehZones } from "./defocus-bokeh-zones.js";
|
|
81
84
|
import { resolveGenericPrimeLens } from "../equipment/generic-prime-lenses.js";
|
|
82
85
|
import { calculateChannelElectronsPerRadiance } from "./channel-response.js";
|
|
83
86
|
import { calculateSiteEffectiveSaturationCode } from "../capture/raw-white-level.js";
|
|
@@ -101,7 +104,7 @@ export const SIMULATE_CAPTURE_BOX_APERTURE_DEFAULT_SAMPLES = 4;
|
|
|
101
104
|
* a capture does. `motion.rotation` is a non-zero angular velocity; `sensor.temporalSampleCount` a count above 1.
|
|
102
105
|
*/
|
|
103
106
|
export const SIMULATE_CAPTURE_COST_OPTIONS = /* @__PURE__ */ Object.freeze(["lens.pupilSampling", "lens.projection", "lens.distortion", "lens.vignetting", "lens.psf",
|
|
104
|
-
"lens.diffraction", "lens.defocus", "sensor.antiAliasing", "sensor.pixelAperture.box", "sensor.temporalSampleCount", "motion.rotation", "motion.shutter.rolling", "output.borderHandling.mirror", "output.region",
|
|
107
|
+
"lens.diffraction", "lens.defocus", "lens.catalogue", "sensor.antiAliasing", "sensor.pixelAperture.box", "sensor.temporalSampleCount", "motion.rotation", "motion.shutter.rolling", "output.borderHandling.mirror", "output.region",
|
|
105
108
|
"output.whiteBalance.auto", "output.demosaic.ahd", "output.highlightMode.reconstruct", "output.colorEncoding.wide-gamut", "output.gamutMapping.perceptual",
|
|
106
109
|
"output.diffractionCorrection", "output.sharpening", "output.format.jpeg", "output.format.png", "output.format.dng"]);
|
|
107
110
|
/**
|
|
@@ -834,20 +837,38 @@ export function parseDisplayViewOption(value, frameWidth, frameHeight) {
|
|
|
834
837
|
function resolveDefocusOption(input) {
|
|
835
838
|
const { run, assume, focalLengthMm, fNumber, focusDistanceM, subjectDistanceM, pitch } = input;
|
|
836
839
|
const disc = resolveDefocusDisc({ focalLengthMm, aperture: fNumber, focusDistanceM, subjectDistanceM, pitchMicrometers: pitch });
|
|
837
|
-
const size = disc.diameterMicrometers + " µm (" + disc.diameterSites + " sites of " + pitch + " µm)";
|
|
838
840
|
let radius;
|
|
839
841
|
try {
|
|
840
842
|
radius = requireDefocusDiscKernelRadius(disc.diameterSites);
|
|
841
843
|
}
|
|
842
|
-
catch
|
|
843
|
-
fail("lens.defocus:
|
|
844
|
+
catch {
|
|
845
|
+
fail("lens.defocus: " + defocusDiscLimitMessage(disc.diameterSites, disc.diameterMicrometers));
|
|
844
846
|
}
|
|
845
|
-
|
|
847
|
+
let value = { model: "geometric-disc", scientificStatus: "approximation", diameterMicrometers: disc.diameterMicrometers, diameterSites: disc.diameterSites,
|
|
846
848
|
kernelRadiusSites: disc.diameterSites === 0 ? null : radius, fNumber, focusDistanceM, subjectDistanceM, samplePitchMicrometers: pitch,
|
|
847
849
|
defocusCircleModel: { id: "thin-lens-defocus-circle", version: "1.1.0" } };
|
|
848
|
-
|
|
850
|
+
let model = "Geometric defocus of the flat scene plane (an approximation): the thin-lens blur circle of an ideal uniform circular pupil, " +
|
|
849
851
|
"c = f²·|s − d| / (N·d·(s − f)) (calculateDefocusCircle 1.1.0), as a uniform disc sampled on the site lattice (exact disc area in each site's cell). " +
|
|
850
852
|
"No diffraction of the defocused wave, aberrations or pupil vignetting. ";
|
|
853
|
+
// #553: the bokeh options. Out of focus, where a kernel is applied, the shaped kernel replaces the disc and its record joins the value.
|
|
854
|
+
let kernelRadius = radius;
|
|
855
|
+
if (input.bokehOptions) {
|
|
856
|
+
value = { ...value, bokeh: { options: input.bokehOptions } };
|
|
857
|
+
if (disc.diameterSites > 0 && run !== "ideal-reference" && input.bokeh) {
|
|
858
|
+
const shaped = input.bokeh(disc);
|
|
859
|
+
value = { ...value, bokeh: shaped.value };
|
|
860
|
+
model += shaped.explanation;
|
|
861
|
+
kernelRadius = shaped.value.kernelRadiusSites;
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
// #564: above the direct radius the kernel (the disc, or the shaped kernel of #553) is convolved by runs; the field is absent below it,
|
|
865
|
+
// so those records are unchanged.
|
|
866
|
+
if (kernelRadius > DEFOCUS_DIRECT_KERNEL_MAXIMUM_RADIUS_SITES) {
|
|
867
|
+
value = { ...value, convolution: "runs" };
|
|
868
|
+
model += "The kernel radius is above 64 sites, so the kernel is convolved by runs (#564): each kernel row's run of equal weights is a difference of two prefix sums, " +
|
|
869
|
+
"the other cells (the edge) are read one by one, and with lens.diffraction each node's diffraction kernel is applied after the defocus kernel. " +
|
|
870
|
+
"That is the same sum as the direct convolution, regrouped (exact up to rounding, not an approximation). ";
|
|
871
|
+
}
|
|
851
872
|
if (disc.diameterSites === 0) {
|
|
852
873
|
assume("lens.defocus", "model", value, model + "In focus (lens.focusDistanceM equals subjectDistanceM): the disc has zero diameter, so no defocus kernel is applied.");
|
|
853
874
|
return undefined;
|
|
@@ -856,8 +877,9 @@ function resolveDefocusOption(input) {
|
|
|
856
877
|
assume("lens.defocus", "model", value, model + "Resolved but not applied: the ideal reference has no camera effects.");
|
|
857
878
|
return undefined;
|
|
858
879
|
}
|
|
859
|
-
// The display view (#492, step 2b): a site kernel in its expected-signal tables (simulate-display-view.ts)
|
|
860
|
-
|
|
880
|
+
// The display view (#492, step 2b): a site kernel in its expected-signal tables (simulate-display-view.ts); with a lens field mapping,
|
|
881
|
+
// vignetting or rotation (#563) applied in image space as in the capture, so it records the capture's assumption below.
|
|
882
|
+
if (run === "display-view" && !input.imageSpace) {
|
|
861
883
|
assume("lens.defocus", "model", { ...value, execution: "expected-signal-site-kernel", combinedWithDiffraction: input.diffraction }, model +
|
|
862
884
|
"Applied in the display view's expected-signal tables as a site kernel on the lattice" + (input.diffraction ? " (with lens.diffraction, each spectral node's " +
|
|
863
885
|
"diffraction kernel convolved with the disc, a further approximation)" : "") + "; see the view.defocus assumption.");
|
|
@@ -936,7 +958,8 @@ export async function runCapture(options, run, viewOption, renderView) {
|
|
|
936
958
|
preset = parseCallerCameraPreset(cameraOption);
|
|
937
959
|
const body = preset.body, lens = preset.lens;
|
|
938
960
|
// Lens
|
|
939
|
-
const lensOptions = allowKeys(top.lens, "lens", ["focalLengthMm", "fNumber", "focusDistanceM", "pupilSampling", "projection", "distortion", "vignetting", "psf", "diffraction", "prime", "defocus"
|
|
961
|
+
const lensOptions = allowKeys(top.lens, "lens", ["focalLengthMm", "fNumber", "focusDistanceM", "pupilSampling", "projection", "distortion", "vignetting", "psf", "diffraction", "prime", "defocus",
|
|
962
|
+
"catalogue", "focusScatter"]);
|
|
940
963
|
// Generic prime (2.3): resolved on the simulated frame's size, which the output and sensor sections validate again below.
|
|
941
964
|
let prime;
|
|
942
965
|
if (lensOptions.prime !== undefined) {
|
|
@@ -951,22 +974,49 @@ export async function runCapture(options, run, viewOption, renderView) {
|
|
|
951
974
|
widestFNumber: prime.widestFNumber, narrowestFNumber: prime.narrowestFNumber, minimumFocusDistanceM: prime.minimumFocusDistanceM }, "Generic prime (not a real product): focal length = equivalent ÷ the simulated frame's diagonal crop factor, f/" + prime.widestFNumber + "–f/" + prime.narrowestFNumber +
|
|
952
975
|
", minimum focus max(0.10 m, f·(1 + 1/0.15)) (thin-lens approximation). It replaces the tier lens's focal length and f-number range; the tier lens's transmission is kept.");
|
|
953
976
|
}
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
977
|
+
// Generic lens catalogue (#549): resolved on the simulated frame like the prime; its character is built once the f-number is known.
|
|
978
|
+
let catalogue, catalogueFrame;
|
|
979
|
+
let lensKit;
|
|
980
|
+
if (lensOptions.catalogue !== undefined) {
|
|
981
|
+
for (const key of ["prime", "focalLengthMm", "projection", "distortion", "vignetting", "psf", "diffraction", "pupilSampling"])
|
|
982
|
+
if (lensOptions[key] !== undefined)
|
|
983
|
+
fail("lens.catalogue cannot be combined with lens." + key + ": the catalogue lens sets its own focal length, projection, distortion, vignetting and PSF (with diffraction).");
|
|
984
|
+
if (displayView)
|
|
985
|
+
fail("simulateDisplayView does not support lens.catalogue: the catalogue lens's field-dependent PSF, distortion and vignetting run through the capture's environment quadrature.");
|
|
986
|
+
const o = (typeof top.output === "object" && top.output !== null ? top.output : {}), sn = (typeof top.sensor === "object" && top.sensor !== null ? top.sensor : {});
|
|
987
|
+
const frameW = positive(o.width ?? DEFAULTS.width, "output.width"), frameH = positive(o.height ?? DEFAULTS.height, "output.height"), framePitch = positive(sn.pixelPitchMicrometers ?? DEFAULTS.pixelPitchMicrometers, "sensor.pixelPitchMicrometers");
|
|
988
|
+
catalogueFrame = { widthMm: frameW * framePitch / 1000, heightMm: frameH * framePitch / 1000 };
|
|
989
|
+
lensKit = await import("./generic-lens-capture.js");
|
|
990
|
+
catalogue = lensKit.resolveGenericLens({ lensId: lensOptions.catalogue, activeImagingArea: catalogueFrame });
|
|
991
|
+
assume("lens.catalogue", "model", { lensId: catalogue.lensId, name: catalogue.name, set: catalogue.set, kind: catalogue.kind, equivalentFocalLengthMm: catalogue.equivalentFocalLengthMm,
|
|
992
|
+
focalLengthMm: catalogue.focalLengthMm, cropFactor35Mm: catalogue.cropFactor35Mm, widestFNumber: catalogue.widestFNumber, narrowestFNumber: catalogue.narrowestFNumber,
|
|
993
|
+
minimumFocusDistanceM: catalogue.minimumFocusDistanceM, maximumMagnification: catalogue.maximumMagnification, projection: catalogue.projection, fisheyeImage: catalogue.fisheyeImage }, "Generic catalogue lens " + catalogue.name + " (#549; Photivra's own design, not a real product): focal length = equivalent ÷ the simulated frame's diagonal crop factor, f/" +
|
|
994
|
+
catalogue.widestFNumber + "–f/" + catalogue.narrowestFNumber + ", minimum focus max(0.10 m, f·(1 + 1/" + catalogue.maximumMagnification + ")) (thin lens). Its character is a labelled " +
|
|
995
|
+
"approximation (the lens.catalogue.character assumption). It replaces the tier lens's focal length and f-number range; the tier lens's transmission is kept.");
|
|
996
|
+
}
|
|
997
|
+
else if (lensOptions.focusScatter !== undefined)
|
|
998
|
+
fail("lens.focusScatter needs lens.catalogue: the focus scatter is a catalogue lens's own.");
|
|
999
|
+
const lensRange = prime ? { id: prime.lensId, focalLengthMm: prime.focalLengthMm, widestFNumber: prime.widestFNumber, narrowestFNumber: prime.narrowestFNumber } :
|
|
1000
|
+
catalogue ? { id: catalogue.lensId, focalLengthMm: catalogue.focalLengthMm, widestFNumber: catalogue.widestFNumber, narrowestFNumber: catalogue.narrowestFNumber } : undefined;
|
|
1001
|
+
const lensExposure = lensRange ? { ...lens.exposure, profileId: "photivra-" + lensRange.id + ":exposure",
|
|
1002
|
+
focalLengthMmRange: { ...lens.exposure.focalLengthMmRange, value: { minimum: lensRange.focalLengthMm, maximum: lensRange.focalLengthMm } },
|
|
1003
|
+
aperture: { ...lens.exposure.aperture, widestAvailableFNumber: { kind: "constant", fNumber: { value: lensRange.widestFNumber, evidence: FACADE_EVIDENCE } },
|
|
1004
|
+
narrowestAvailableFNumber: { value: lensRange.narrowestFNumber, evidence: FACADE_EVIDENCE } } } : lens.exposure;
|
|
958
1005
|
const focalDefault = lensExposure.focalLengthMmRange.value.minimum;
|
|
959
|
-
const focalLengthMm =
|
|
1006
|
+
const focalLengthMm = lensRange ? lensRange.focalLengthMm :
|
|
960
1007
|
positive(pick(lensOptions, "focalLengthMm", "lens.focalLengthMm", focalDefault, "The preset lens's focal length (the generic primes are 50 mm)."), "lens.focalLengthMm");
|
|
961
1008
|
const capabilities = resolveGenericEquipmentExposureCapabilities({ bodyProfile: body.exposure, lensProfile: lensExposure, selectedFocalLengthMm: focalLengthMm });
|
|
962
1009
|
const subjectDistanceM = positive(pick(top, "subjectDistanceM", "subjectDistanceM", DEFAULTS.subjectDistanceM, "Scene plane 5 m in front of the camera (the generic tiers' reference focus distance)."), "subjectDistanceM");
|
|
963
1010
|
if (subjectDistanceM * 1000 <= focalLengthMm * 2)
|
|
964
1011
|
fail("subjectDistanceM must exceed twice the focal length.");
|
|
965
|
-
|
|
1012
|
+
let focusDistanceM = positive(pick(lensOptions, "focusDistanceM", "lens.focusDistanceM", subjectDistanceM, "Focused on the scene plane."), "lens.focusDistanceM");
|
|
966
1013
|
if (focusDistanceM * 1000 <= focalLengthMm)
|
|
967
1014
|
fail("lens.focusDistanceM must exceed the focal length.");
|
|
968
1015
|
if (prime && (subjectDistanceM < prime.minimumFocusDistanceM || focusDistanceM < prime.minimumFocusDistanceM))
|
|
969
1016
|
fail("The " + prime.lensId + " focuses no closer than " + prime.minimumFocusDistanceM + " m (max(0.10 m, f·(1 + 1/0.15))); subjectDistanceM and lens.focusDistanceM must be at least that.");
|
|
1017
|
+
if (catalogue && (subjectDistanceM < catalogue.minimumFocusDistanceM || focusDistanceM < catalogue.minimumFocusDistanceM))
|
|
1018
|
+
fail("The " + catalogue.name + " focuses no closer than " + catalogue.minimumFocusDistanceM + " m (max(0.10 m, f·(1 + 1/" + catalogue.maximumMagnification +
|
|
1019
|
+
"))); subjectDistanceM and lens.focusDistanceM must be at least that.");
|
|
970
1020
|
let pupil;
|
|
971
1021
|
if (lensOptions.pupilSampling === undefined)
|
|
972
1022
|
assume("lens.pupilSampling", "default", null, lensOptions.defocus === undefined ?
|
|
@@ -980,7 +1030,8 @@ export async function runCapture(options, run, viewOption, renderView) {
|
|
|
980
1030
|
fail("lens.pupilSampling needs at most 256 rays (radialSamples × angularSamples).");
|
|
981
1031
|
}
|
|
982
1032
|
// 2.0 optics hooks: only what the environment site contract accepts.
|
|
983
|
-
const projection = lensOptions.projection === undefined ?
|
|
1033
|
+
const projection = lensOptions.projection === undefined ? (catalogue && catalogue.projection !== "rectilinear" ? catalogue.projection : undefined) :
|
|
1034
|
+
parseLensProjectionModel(lensOptions.projection);
|
|
984
1035
|
let distortion;
|
|
985
1036
|
if (lensOptions.distortion !== undefined) {
|
|
986
1037
|
const d = allowKeys(lensOptions.distortion, "lens.distortion", ["kind", "profile"]);
|
|
@@ -988,7 +1039,11 @@ export async function runCapture(options, run, viewOption, renderView) {
|
|
|
988
1039
|
fail("lens.distortion.kind must be radial or brown-conrady.");
|
|
989
1040
|
distortion = d;
|
|
990
1041
|
}
|
|
991
|
-
|
|
1042
|
+
// #549: a catalogue lens's distortion (and the fisheyes' projection) is set once its field reach is known (below); the mapping
|
|
1043
|
+
// stands in for it in the combination checks until then.
|
|
1044
|
+
if (catalogue)
|
|
1045
|
+
distortion = { kind: "radial", profile: lensKit.genericLensDistortionProfile(catalogue.character.distortion.corner, catalogue.halfDiagonalMm) };
|
|
1046
|
+
let lensFieldMapping = projection === undefined && distortion === undefined ? undefined :
|
|
992
1047
|
{ projectionModel: projection ?? "rectilinear", distortion: distortion ?? { kind: "none" }, radiometricAreaCorrection: "inverse-distortion-jacobian" };
|
|
993
1048
|
if (lensFieldMapping) {
|
|
994
1049
|
if (pupil)
|
|
@@ -1038,16 +1093,36 @@ export async function runCapture(options, run, viewOption, renderView) {
|
|
|
1038
1093
|
fail("lens.diffraction cannot be combined with lens.pupilSampling: the environment contract does not mix a sampled PSF with pupil rays.");
|
|
1039
1094
|
}
|
|
1040
1095
|
// Defocus (#492): validated here, resolved once the f-number is.
|
|
1041
|
-
let defocusModel;
|
|
1096
|
+
let defocusModel, defocusBokeh;
|
|
1042
1097
|
if (lensOptions.defocus !== undefined) {
|
|
1043
|
-
const record = allowKeys(lensOptions.defocus, "lens.defocus", ["model"]);
|
|
1098
|
+
const record = allowKeys(lensOptions.defocus, "lens.defocus", ["model", "blades", "sphericalAberration", "catsEye"]);
|
|
1044
1099
|
if (record.model !== "geometric-disc")
|
|
1045
1100
|
fail("lens.defocus.model must be \"geometric-disc\".");
|
|
1101
|
+
// #553: the bokeh options; none given keeps the disc of #492 (byte-identical requests).
|
|
1102
|
+
if (record.blades !== undefined || record.sphericalAberration !== undefined || record.catsEye !== undefined) {
|
|
1103
|
+
const bokeh = { ...record };
|
|
1104
|
+
delete bokeh.model;
|
|
1105
|
+
try {
|
|
1106
|
+
defocusBokeh = resolveDefocusBokehOptions(bokeh, "lens.defocus");
|
|
1107
|
+
}
|
|
1108
|
+
catch (error) {
|
|
1109
|
+
fail(error.message);
|
|
1110
|
+
}
|
|
1111
|
+
if (defocusBokeh.catsEye && diffractionRadiusOption !== undefined)
|
|
1112
|
+
fail("lens.defocus.catsEye cannot be combined with lens.diffraction: the cat's eye varies over the field, " +
|
|
1113
|
+
"so each field zone would need its own diffraction kernel convolved with its clipped pupil at every spectral node. Omit one of the options.");
|
|
1114
|
+
}
|
|
1046
1115
|
if (pupil)
|
|
1047
1116
|
fail("lens.defocus cannot be combined with lens.pupilSampling: the pupil rays already render defocus, so it would be counted twice.");
|
|
1048
1117
|
if (lensPsf)
|
|
1049
1118
|
fail("lens.defocus cannot be combined with lens.psf: a caller PSF declares its own defocus, so it could be counted twice.");
|
|
1050
|
-
|
|
1119
|
+
// #549: with a catalogue lens the disc is convolved into the lens's PSF (below), not applied by the lens.defocus paths. The bokeh
|
|
1120
|
+
// options (#553) shape the lens.defocus kernel only, so they are refused rather than dropped (a follow-up for a later release).
|
|
1121
|
+
if (catalogue && defocusBokeh)
|
|
1122
|
+
fail("lens.defocus.blades, sphericalAberration and catsEye cannot be combined with lens.catalogue: the catalogue lens " +
|
|
1123
|
+
"folds a plain disc into its own PSF. Omit the bokeh options, or use lens.focalLengthMm instead of the catalogue lens.");
|
|
1124
|
+
if (!catalogue)
|
|
1125
|
+
defocusModel = "geometric-disc";
|
|
1051
1126
|
}
|
|
1052
1127
|
// Motion (2.0): constant camera rotation and the shutter type.
|
|
1053
1128
|
const motionOptions = allowKeys(top.motion, "motion", ["angularVelocityRadPerSec", "shutter", "rollingShutterSkewSeconds"]);
|
|
@@ -1180,14 +1255,12 @@ export async function runCapture(options, run, viewOption, renderView) {
|
|
|
1180
1255
|
const unsupported = (option, reason) => fail("simulateDisplayView does not support " + option + ": " + reason);
|
|
1181
1256
|
if (pupil)
|
|
1182
1257
|
unsupported("lens.pupilSampling", "pupil rays move each query off the site lattice the expected-signal tables use; lens.defocus renders the defocus of the scene plane on the lattice.");
|
|
1183
|
-
if (lensFieldMapping)
|
|
1184
|
-
unsupported("lens.projection or lens.distortion", "the expected signal assumes the ideal rectilinear, distortion-free mapping of the site lattice.");
|
|
1185
|
-
if (vignetting)
|
|
1186
|
-
unsupported("lens.vignetting", "the expected signal assumes the same radiance-to-irradiance factor at every site.");
|
|
1187
1258
|
if (lensPsf)
|
|
1188
1259
|
unsupported("lens.psf", "only the engine-built diffraction kernels (lens.diffraction) are tabulated.");
|
|
1189
|
-
|
|
1190
|
-
|
|
1260
|
+
// #563: projection, distortion, vignetting and rotation are supported (display-view-lens-signal.ts), except rotation under a rolling shutter.
|
|
1261
|
+
if (rotating && shutterKind === "rolling")
|
|
1262
|
+
unsupported("camera rotation with motion.shutter \"rolling\"", "every row has its own instants, so the view's " +
|
|
1263
|
+
"scene points of one instant would mix rows exposed at other times; use motion.shutter \"global\" for the view.");
|
|
1191
1264
|
if (outputOptions.region !== undefined)
|
|
1192
1265
|
unsupported("output.region", "pass the rectangle as view.region, in display pixels.");
|
|
1193
1266
|
if (outputOptions.whiteBalance === "auto")
|
|
@@ -1198,6 +1271,9 @@ export async function runCapture(options, run, viewOption, renderView) {
|
|
|
1198
1271
|
unsupported("output.highlightMode \"reconstruct\"", "the view supports the per-channel highlight clip.");
|
|
1199
1272
|
if (outputOptions.diffractionCorrection !== undefined || outputOptions.sharpening !== undefined)
|
|
1200
1273
|
unsupported("output.diffractionCorrection or output.sharpening", "the development detail stages filter the whole developed capture image.");
|
|
1274
|
+
if (defocusBokeh?.catsEye)
|
|
1275
|
+
unsupported("lens.defocus.catsEye", "the expected-signal tables hold one kernel per spectral node, and the cat's eye varies over the field; " +
|
|
1276
|
+
"simulateCapture renders it. lens.defocus.blades and lens.defocus.sphericalAberration are supported.");
|
|
1201
1277
|
}
|
|
1202
1278
|
const colorSamplingProfile = { schemaVersion: "0.1.0", profileId: IDS.cfa, evidence: FACADE_EVIDENCE, coordinateSystem: "native-sensor-color-sampling-site-index",
|
|
1203
1279
|
layout: { kind: "periodic-mosaic", repeatWidthSites: 2, repeatHeightSites: 2, siteChannelIds: ["red", "green", "green", "blue"], anchor: "native-sensor-top-left-site" } };
|
|
@@ -1404,7 +1480,8 @@ export async function runCapture(options, run, viewOption, renderView) {
|
|
|
1404
1480
|
const buildProvider = (sceneIlluminant, scale) => buildPlanarSceneRadianceProvider({ scene: chart ?? callerScene,
|
|
1405
1481
|
sceneId: IDS.scene, providerProfileId: IDS.provider, illuminant: sceneIlluminant, irradianceScale: scale, geometry: { distanceM: subjectDistanceM, metresPerFrameUnit,
|
|
1406
1482
|
...(chartSize ? { chart: { widthM: chartSize.widthM, heightM: chartSize.heightM, surroundReflectance: chartSize.surroundReflectance } } : {}) }, evidence: FACADE_EVIDENCE,
|
|
1407
|
-
limitations: Object.freeze(["Planar Lambertian scene under uniform illumination; no shadows, inter-reflection, gloss or fluorescence."])
|
|
1483
|
+
limitations: Object.freeze(["Planar Lambertian scene under uniform illumination; no shadows, inter-reflection, gloss or fluorescence."]),
|
|
1484
|
+
...(catalogue?.kind === "fisheye" ? { zeroBeyondHorizon: true } : {}) });
|
|
1408
1485
|
const provider = buildProvider(illuminant, irradianceScale);
|
|
1409
1486
|
// 2.6: a chart preset's evaluator is engine-built end to end (its results: the schema's exact keys, constant fields,
|
|
1410
1487
|
// the request's identifiers, deep-frozen FACADE_EVIDENCE, UNCERTAINTY and limitations, and an engine-computed
|
|
@@ -1478,6 +1555,8 @@ export async function runCapture(options, run, viewOption, renderView) {
|
|
|
1478
1555
|
fNumber = positive(pick(lensOptions, "fNumber", "lens.fNumber", DEFAULTS.fNumber, "f/8."), "lens.fNumber");
|
|
1479
1556
|
if (prime && (fNumber < prime.widestFNumber || fNumber > prime.narrowestFNumber))
|
|
1480
1557
|
fail("lens.fNumber " + fNumber + " is outside the " + prime.lensId + " range f/" + prime.widestFNumber + "–f/" + prime.narrowestFNumber + ".");
|
|
1558
|
+
if (catalogue && (fNumber < catalogue.widestFNumber || fNumber > catalogue.narrowestFNumber))
|
|
1559
|
+
fail("lens.fNumber " + fNumber + " is outside the " + catalogue.name + " range f/" + catalogue.widestFNumber + "–f/" + catalogue.narrowestFNumber + ".");
|
|
1481
1560
|
}
|
|
1482
1561
|
else {
|
|
1483
1562
|
if (lensOptions.fNumber !== undefined)
|
|
@@ -1590,15 +1669,154 @@ export async function runCapture(options, run, viewOption, renderView) {
|
|
|
1590
1669
|
const exposureDeviationStops = standardExposureDeviationStops(fNumber, shutterSeconds, resolvedIso, meteredLuminance);
|
|
1591
1670
|
const exposureIlluminanceLux = standardExposureIlluminanceLux(fNumber, shutterSeconds, resolvedIso, meteredLuminance, illuminanceLux, callerScene?.kind !== "radiance-function");
|
|
1592
1671
|
const exposureGreyCardDeviationStops = callerScene?.kind === "radiance-function" ? null : greyCardDeviationStops(fNumber, shutterSeconds, resolvedIso, illuminanceLux);
|
|
1672
|
+
// #549: the catalogue lens's character at the resolved f-number and focus: focus scatter, the defocus disc folded into its PSF, then
|
|
1673
|
+
// its distortion and vignetting profiles over the field the PSF and the queries reach, and its PSF profile.
|
|
1674
|
+
let catalogueTaps, catalogueDefocusApplied = false;
|
|
1675
|
+
if (catalogue && lensKit) {
|
|
1676
|
+
const { GENERIC_LENS_EVIDENCE, genericLensDistortionProfile, genericLensVignettingProfile, resolveGenericLens, simulateGenericLensFocusError, createGenericLensPsfProfile, genericLensPsfKernelRadius, GENERIC_LENS_PSF_MAXIMUM_COMBINED_RADIUS_SITES } = lensKit;
|
|
1677
|
+
if (fNumber < catalogue.widestFNumber || fNumber > catalogue.narrowestFNumber)
|
|
1678
|
+
fail("lens.fNumber " + fNumber + " is outside the " + catalogue.name + " range f/" + catalogue.widestFNumber + "–f/" + catalogue.narrowestFNumber + ".");
|
|
1679
|
+
if (lensOptions.focusScatter !== undefined) {
|
|
1680
|
+
const scatterOptions = allowKeys(lensOptions.focusScatter, "lens.focusScatter", ["seed", "shotIndex"]);
|
|
1681
|
+
const sample = simulateGenericLensFocusError({ lensId: catalogue.lensId, activeImagingArea: catalogueFrame, fNumber, focusDistanceM, seed: scatterOptions.seed,
|
|
1682
|
+
...(scatterOptions.shotIndex === undefined ? {} : { shotIndex: scatterOptions.shotIndex }) });
|
|
1683
|
+
assume("lens.focusScatter", "model", { ...sample }, "Seeded autofocus error (an approximation of focus consistency): image-side error z·σ·2Nc with z a standard normal draw from the seed and shot index, σ = " + sample.depthOfFocusFraction +
|
|
1684
|
+
" of the depth of focus 2·N·c (c = the frame diagonal / 1500), read back through the thin lens. The focus distance " + sample.intendedFocusDistanceM + " m becomes " + sample.focusDistanceM + " m" +
|
|
1685
|
+
(lensOptions.defocus === undefined ? "; without lens.defocus the capture renders no defocus, so the image does not change." : "."));
|
|
1686
|
+
focusDistanceM = sample.focusDistanceM;
|
|
1687
|
+
}
|
|
1688
|
+
const character = resolveGenericLens({ lensId: catalogue.lensId, activeImagingArea: catalogueFrame, fNumber, focusDistanceM });
|
|
1689
|
+
let extraKernel;
|
|
1690
|
+
if (lensOptions.defocus !== undefined) {
|
|
1691
|
+
const disc = resolveDefocusDisc({ focalLengthMm, aperture: fNumber, focusDistanceM, subjectDistanceM, pitchMicrometers: pitch });
|
|
1692
|
+
let discRadius;
|
|
1693
|
+
try {
|
|
1694
|
+
discRadius = requireDefocusDiscKernelRadius(disc.diameterSites);
|
|
1695
|
+
}
|
|
1696
|
+
catch {
|
|
1697
|
+
fail("lens.defocus: " + defocusDiscLimitMessage(disc.diameterSites, disc.diameterMicrometers));
|
|
1698
|
+
}
|
|
1699
|
+
const kernel = run === "ideal-reference" ? null : createDefocusDiscSiteKernel(disc.diameterSites);
|
|
1700
|
+
if (kernel) {
|
|
1701
|
+
extraKernel = { weights: kernel.weights, radius: kernel.radius };
|
|
1702
|
+
catalogueDefocusApplied = true;
|
|
1703
|
+
}
|
|
1704
|
+
assume("lens.defocus", "model", { model: "geometric-disc", scientificStatus: "approximation", diameterMicrometers: disc.diameterMicrometers, diameterSites: disc.diameterSites,
|
|
1705
|
+
kernelRadiusSites: disc.diameterSites === 0 ? null : discRadius, fNumber, focusDistanceM, subjectDistanceM, samplePitchMicrometers: pitch,
|
|
1706
|
+
defocusCircleModel: { id: "thin-lens-defocus-circle", version: "1.1.0" }, execution: "catalogue-lens-psf" }, "Geometric defocus of the flat scene plane (an approximation): the thin-lens blur circle c = f²·|s − d| / (N·d·(s − f)) (calculateDefocusCircle 1.1.0) as a uniform disc sampled on the site lattice. " +
|
|
1707
|
+
(disc.diameterSites === 0 ? "In focus: no disc is applied." : run === "ideal-reference" ? "Resolved but not applied: the ideal reference has no camera effects." :
|
|
1708
|
+
"With the catalogue lens the disc is convolved into every node of the lens's PSF (a further approximation: the defocused aberrated wave PSF is not exactly the in-focus PSF convolved with the disc) and applied through the environment PSF quadrature."));
|
|
1709
|
+
}
|
|
1710
|
+
// An upper bound of the PSF's radius (the built window may be narrower): the field reach below uses it.
|
|
1711
|
+
const kernelRadius = genericLensPsfKernelRadius({ lens: character, focusDistanceM, sitePitchMicrometers: pitch }) + (extraKernel ? extraKernel.radius : 0);
|
|
1712
|
+
// The field the PSF taps and the site queries reach: the native raster plus the kernel radius and the query offsets.
|
|
1713
|
+
const queryReach = Math.max(0, ...queryOffsetsSites.map((q) => Math.max(Math.abs(q.x), Math.abs(q.y))));
|
|
1714
|
+
const reachMm = (kernelRadius + queryReach + 1) * pitch / 1000;
|
|
1715
|
+
const frameHalfMm = { x: nativeWidth * pitch / 2000, y: nativeHeight * pitch / 2000 }, extentMm = { x: frameHalfMm.x + reachMm, y: frameHalfMm.y + reachMm };
|
|
1716
|
+
const reachRadius = Math.hypot(extentMm.x, extentMm.y) / catalogue.halfDiagonalMm;
|
|
1717
|
+
const b = 1 - 2 ** (-character.character.vignetting.cornerStops / 2);
|
|
1718
|
+
if (!(b * reachRadius * reachRadius < 0.98))
|
|
1719
|
+
fail("lens.catalogue: the " + catalogue.name + "'s vignetting E(ρ) = (1 − bρ²)² is defined inside ρ < " + (1 / Math.sqrt(b)).toFixed(3) + " of the frame's half-diagonal, and this frame's PSF reach goes to ρ = " +
|
|
1720
|
+
reachRadius.toFixed(3) + ". Use a larger output (or smaller pixels' fewer sites of reach): the reach is " + (kernelRadius + queryReach + 1) + " sites beyond the frame.");
|
|
1721
|
+
vignetting = genericLensVignettingProfile(character.character.vignetting.cornerStops, catalogue.halfDiagonalMm, reachRadius);
|
|
1722
|
+
const corner = character.character.distortion.corner;
|
|
1723
|
+
distortion = { kind: "radial", profile: genericLensDistortionProfile(corner, catalogue.halfDiagonalMm, corner < 0 ? reachRadius / (1 + corner * reachRadius * reachRadius) * 1.01 : reachRadius) };
|
|
1724
|
+
lensFieldMapping = { projectionModel: projection ?? "rectilinear", distortion, radiometricAreaCorrection: "inverse-distortion-jacobian",
|
|
1725
|
+
...(catalogue.kind === "fisheye" ? { outsideImageCircle: "backward-ray" } : {}) };
|
|
1726
|
+
try {
|
|
1727
|
+
prepareEnvironmentLensFieldMapping(lensFieldMapping);
|
|
1728
|
+
}
|
|
1729
|
+
catch (error) {
|
|
1730
|
+
fail("lens.catalogue: the " + catalogue.name + "'s distortion over this frame's reach: " + error.message);
|
|
1731
|
+
}
|
|
1732
|
+
const c = character.character;
|
|
1733
|
+
let psfReport = null;
|
|
1734
|
+
if (run !== "ideal-reference") {
|
|
1735
|
+
const built = createGenericLensPsfProfile({ lens: character, focusDistanceM, sitePitchMicrometers: pitch, fieldHalfExtentMm: extentMm, frameHalfMm, evidence: GENERIC_LENS_EVIDENCE,
|
|
1736
|
+
...(extraKernel ? { extraKernel } : {}) });
|
|
1737
|
+
lensPsf = { kind: "sampled-local", configuration: { psf: { profile: built.profile, focalLengthMm, focus: { kind: "finite", distanceM: focusDistanceM }, apertureFNumber: fNumber,
|
|
1738
|
+
signedDefocusImagePlaneMicrometers: 0 }, psfWavelengthBasis: { value: "vacuum", evidence: GENERIC_LENS_EVIDENCE },
|
|
1739
|
+
spatialModel: { kind: "destination-local-shift-invariant-approximation", evidence: GENERIC_LENS_EVIDENCE,
|
|
1740
|
+
limitation: "Catalogue lens PSF: a 5 × 5 field grid × 5 wavelengths, interpolated with centroid alignment; each site's PSF is that of its own field point." } } };
|
|
1741
|
+
if (built.kernelRadiusSites > GENERIC_LENS_PSF_MAXIMUM_COMBINED_RADIUS_SITES)
|
|
1742
|
+
fail("lens.catalogue with lens.defocus needs a PSF of radius " + built.kernelRadiusSites + " sites (the lens's " + built.aberrationKernelRadiusSites + " plus the disc's " +
|
|
1743
|
+
(built.kernelRadiusSites - built.aberrationKernelRadiusSites) + "), over the limit of " + GENERIC_LENS_PSF_MAXIMUM_COMBINED_RADIUS_SITES + " (" + (2 * built.kernelRadiusSites + 1) ** 2 +
|
|
1744
|
+
" scene queries per site and spectral node through the environment quadrature). Bring the focus closer to the subject, stop down, or use larger pixels.");
|
|
1745
|
+
catalogueTaps = (2 * built.kernelRadiusSites + 1) ** 2;
|
|
1746
|
+
psfReport = { aberrationKernelRadiusSites: built.aberrationKernelRadiusSites, kernelRadiusSites: built.kernelRadiusSites, maximumTruncatedEnergyFraction: built.maximumTruncatedEnergyFraction,
|
|
1747
|
+
fieldNodesMm: { x: built.fieldXmm, y: built.fieldYmm }, wavelengthNodesNm: built.wavelengthsNm, transformSize: built.transformSize, maximumPhaseStepWaves: built.maximumPhaseStepWaves };
|
|
1748
|
+
}
|
|
1749
|
+
assume("lens.catalogue.character", "model", { lensId: catalogue.lensId, fNumber, focusDistanceM, magnification: c.magnification, closeFocusGain: c.closeFocusGain, pupilScale: c.pupilScale,
|
|
1750
|
+
aberrationsWaves550: { ...c.aberrations }, lateralColor: { ...c.lateralColor }, distortionCorner: c.distortion.corner, vignettingCornerStops: c.vignetting.cornerStops,
|
|
1751
|
+
notRendered: { strayLight: { ...c.strayLight }, breathing: { ...c.breathing }, focusScatterDepthOfFocusFraction: c.focusScatterDepthOfFocusFraction, bokeh: "disc (#553)" },
|
|
1752
|
+
psf: psfReport, profiles: { vignetting, distortion: distortion.profile, maximumNormalizedRadius: reachRadius } }, "The catalogue lens's character, a labelled approximation of a generic lens (docs/LENS_CATALOGUE.md): Seidel wave aberrations at the frame corner (spherical, balanced by defocus; coma; astigmatism; field curvature), " +
|
|
1753
|
+
"scaled from the widest aperture by the pupil ratio a = N0/N (a⁴, a³, a², a²) and by the close-focus factor; axial colour as a defocus and lateral colour as a radial shift, both with the normalised Cauchy dispersion. " +
|
|
1754
|
+
(run === "ideal-reference" ? "Not applied: the ideal reference has no camera effects. " :
|
|
1755
|
+
"Rendered as a sampled PSF (scalar Fraunhofer diffraction of the aberrated circular pupil, integrated over each site cell, on a 5 × 5 field grid × 5 wavelengths with centroid-aligned interpolation) " +
|
|
1756
|
+
"through the environment PSF quadrature (one scene query per kernel tap), with the lens's radial distortion (r_d = r·(1 + k1ρ²)) and relative illumination (E = (1 − bρ²)²) as lens field mapping and field throughput" +
|
|
1757
|
+
(catalogue.kind === "fisheye" ? ", and the equisolid projection; directions at or beyond 90° see no scene (zero radiance), so a circular fisheye's image ends at its 180° circle" : "") + ". ") +
|
|
1758
|
+
"Flare, focus breathing and bokeh shape are reported, not rendered; ρ is normalised to the frame's half-diagonal, so the lens is scaled to the simulated frame like lens.prime.");
|
|
1759
|
+
}
|
|
1593
1760
|
// #492: the capture applies the disc as an object-space convolution, which needs every disc point a site sees to be another site's scene point.
|
|
1594
1761
|
// #548: a lens field mapping, vignetting or camera rotation breaks that, so the capture then applies the disc in image space, on the sensor's
|
|
1595
|
-
// site lattice (defocus-image-space-provider.ts).
|
|
1762
|
+
// site lattice (defocus-image-space-provider.ts). #563: the display view reads the same geometry in any focus (display-view-lens-signal.ts).
|
|
1596
1763
|
const imageSpaceOptions = [...(lensFieldMapping ? [lensOptions.distortion !== undefined ? (lensOptions.projection !== undefined ? "lens.projection, lens.distortion" : "lens.distortion") : "lens.projection"] : []),
|
|
1597
1764
|
...(vignetting ? ["lens.vignetting"] : []), ...(rotating ? ["camera rotation"] : [])];
|
|
1598
|
-
const
|
|
1765
|
+
const lensGeometry = (defocusModel !== undefined || displayView) && imageSpaceOptions.length > 0 ? prepareDefocusImageSpaceGeometry({ focalLengthMm, focusDistanceM,
|
|
1599
1766
|
angularVelocityRadPerSec: angular, ...(lensFieldMapping ? { lensMapping: prepareEnvironmentLensFieldMapping(lensFieldMapping) } : {}), ...(vignetting ? { vignetting } : {}) }) : undefined;
|
|
1767
|
+
const defocusGeometry = defocusModel !== undefined ? lensGeometry : undefined;
|
|
1768
|
+
// #553: the shaped kernel (on axis) and, with a cat's eye, its field zones; built when the disc is resolved out of focus.
|
|
1769
|
+
let bokehAxisKernel, bokehZones;
|
|
1770
|
+
const bokehSummary = defocusBokeh === undefined ? undefined : (disc) => {
|
|
1771
|
+
const options = defocusBokeh, side = subjectDistanceM > focusDistanceM ? 1 : -1;
|
|
1772
|
+
const build = (field) => {
|
|
1773
|
+
try {
|
|
1774
|
+
return createDefocusBokehSiteKernel({ diameterSites: disc.diameterSites, side, fNumber, focalLengthMm, pitchMicrometers: pitch, options, ...(field ? { field } : {}) });
|
|
1775
|
+
}
|
|
1776
|
+
catch (error) {
|
|
1777
|
+
const message = error.message;
|
|
1778
|
+
fail(message.startsWith("lens.defocus") ? message : "lens.defocus: " + message);
|
|
1779
|
+
}
|
|
1780
|
+
};
|
|
1781
|
+
const axis = build();
|
|
1782
|
+
bokehAxisKernel = axis;
|
|
1783
|
+
// The run convolution above 64 sites (#564) takes one kernel for the whole frame; the cat's eye needs one per field zone.
|
|
1784
|
+
if (options.catsEye && !displayView && axis.radius > DEFOCUS_DIRECT_KERNEL_MAXIMUM_RADIUS_SITES)
|
|
1785
|
+
fail("lens.defocus.catsEye: the blur needs a kernel radius of " + axis.radius + " sites; with a cat's eye the limit is " + DEFOCUS_DIRECT_KERNEL_MAXIMUM_RADIUS_SITES +
|
|
1786
|
+
" sites (129 across). Reduce the defocus or omit catsEye.");
|
|
1787
|
+
if (options.catsEye && !displayView) {
|
|
1788
|
+
// The field tangent of a native point (sites from the top-left corner), in output-image axes (+Y up): through the lens
|
|
1789
|
+
// mapping in image space (#548; at the exposure start, so camera rotation does not move the field), else the planar lattice's.
|
|
1790
|
+
const g = 2 / width, mmPerSite = pitch / 1000;
|
|
1791
|
+
const fieldOf = defocusGeometry ? (x, y) => {
|
|
1792
|
+
const look = defocusGeometry.lookOf((x - nativeWidth / 2) * mmPerSite, (y - nativeHeight / 2) * mmPerSite, 0);
|
|
1793
|
+
return { x: look.x / look.z, y: look.y / look.z };
|
|
1794
|
+
} : (x, y) => ({ x: (x - nativeWidth / 2) * g * metresPerFrameUnit / subjectDistanceM, y: -(y - nativeHeight / 2) * g * metresPerFrameUnit / subjectDistanceM });
|
|
1795
|
+
bokehZones = planDefocusBokehZones({ options, nativeWidth, nativeHeight, radius: axis.radius, fNumber, focalLengthMm, fieldOf, kernelAt: build });
|
|
1796
|
+
if (!(bokehZones.minimumOpenAreaRatio > 0))
|
|
1797
|
+
fail("lens.defocus.catsEye: the clipping apertures close the pupil in part of the frame; reduce shiftPerTanFieldMm or enlarge radiusMm.");
|
|
1798
|
+
}
|
|
1799
|
+
const zones = bokehZones;
|
|
1800
|
+
return { value: { options, side: side === 1 ? "behind-focus" : "in-front-of-focus", kernelRadiusSites: axis.radius, method: axis.method, raySamples: axis.raySamples,
|
|
1801
|
+
sphericalAberrationSites: axis.sphericalAberrationSites, axisOpenAreaRatio: axis.openAreaRatio,
|
|
1802
|
+
...(zones ? { catsEye: { execution: "piecewise-constant-field-zones", zoneSizeSites: zones.zones.size, columns: zones.zones.columns, rows: zones.zones.rows,
|
|
1803
|
+
minimumOpenAreaRatio: zones.minimumOpenAreaRatio, largestAdjacentOpenAreaRatioChange: zones.largestAdjacentOpenAreaRatioChange, lightLossApplied: false } } : {}) },
|
|
1804
|
+
explanation: "The kernel is shaped by the lens instead (#553, bokeh character; calculateDefocusBokehKernel): the projected open pupil " +
|
|
1805
|
+
(options.blades ? "(" + options.blades.count + " blades" + (options.blades.curvature > 0 ? ", curvature " + options.blades.curvature : "") +
|
|
1806
|
+
(options.blades.circularAtOrBelowFNumber !== null ? ", circular at or below f/" + options.blades.circularAtOrBelowFNumber : "") + ", scaled to the disc's area) " : "(a circle) ") +
|
|
1807
|
+
"of a point " + (side === 1 ? "behind" : "in front of") + " the focus plane" + (side === 1 ? "" : " (the pupil turned through 180°: the rays have not crossed yet)") +
|
|
1808
|
+
(options.sphericalAberration ? ", with primary spherical aberration W040 " + options.sphericalAberration.w040Micrometers + " µm at f/" + options.sphericalAberration.atFNumber +
|
|
1809
|
+
" (" + axis.sphericalAberrationSites + " sites at the marginal ray here; ray map (σc/2 + bρ²)·P, rays binned per site cell)" : " (exact polygon area in each site's cell)") +
|
|
1810
|
+
(zones ? ". Cat's eye: the pupil is clipped by " + options.catsEye.apertures.length + " aperture(s) shifted by field position (calculateMechanicalVignetting's model), applied as " +
|
|
1811
|
+
zones.zones.columns + " × " + zones.zones.rows + " field zones of " + zones.zones.size + " sites, each with its centre's kernel (a piecewise-constant approximation; " +
|
|
1812
|
+
"the open-area ratio falls to " + formatBound(zones.minimumOpenAreaRatio) + " and changes by at most " + formatBound(zones.largestAdjacentOpenAreaRatioChange) +
|
|
1813
|
+
" between neighbouring zones). The kernel has unit sum: the light the clip removes is not applied; declare it with lens.vignetting" : "") +
|
|
1814
|
+
". A geometric approximation: no diffraction, onion rings, higher-order or field-dependent aberrations; the same kernel at every wavelength. "
|
|
1815
|
+
};
|
|
1816
|
+
};
|
|
1600
1817
|
const defocusDisc = defocusModel === undefined ? undefined :
|
|
1601
1818
|
resolveDefocusOption({ run, assume, focalLengthMm, fNumber, focusDistanceM, subjectDistanceM, pitch, diffraction: diffractionRadiusOption !== undefined,
|
|
1819
|
+
...(defocusBokeh ? { bokehOptions: defocusBokeh, bokeh: bokehSummary } : {}),
|
|
1602
1820
|
...(defocusGeometry ? { imageSpace: (disc) => {
|
|
1603
1821
|
// Rotation with a rolling shutter: each row's instants differ, so one instant's image on the lattice would mix rows exposed at other times.
|
|
1604
1822
|
if (rotating && shutterKind === "rolling")
|
|
@@ -1612,9 +1830,10 @@ export async function runCapture(options, run, viewOption, renderView) {
|
|
|
1612
1830
|
} } : {}) });
|
|
1613
1831
|
const defocusImageSpace = defocusDisc !== undefined && defocusGeometry !== undefined;
|
|
1614
1832
|
// #492: the disc on the site lattice (radius 0 for a disc inside one cell: the identity, still applied).
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1833
|
+
// #553: the shaped kernel replaces the disc (with a cat's eye, the axis kernel; the zones replace it in the gather).
|
|
1834
|
+
const defocusKernel = defocusDisc && !displayView ? bokehAxisKernel ?? createDefocusDiscSiteKernel(defocusDisc.diameterSites) ?? undefined : undefined;
|
|
1835
|
+
// The display view's disc (#492, step 2b): its expected-signal tables apply it (simulate-display-view.ts); #553: or the shaped kernel.
|
|
1836
|
+
const displayViewDefocus = displayView ? (defocusDisc && bokehAxisKernel ? { ...defocusDisc, siteKernel: bokehAxisKernel } : defocusDisc) : undefined;
|
|
1618
1837
|
// Sensor readout for the ISO setting. Standard output sensitivity S = 10/H (CIPA DC-004 §3.2) is defined at the
|
|
1619
1838
|
// output, independent of pixel size, while the collected charge is proportional to the sensitive-aperture area
|
|
1620
1839
|
// (EMVA 1288 Release 4.0, Eq. 3). The tier's signal chain is anchored to the 6 µm aperture; at another area the
|
|
@@ -1688,7 +1907,10 @@ export async function runCapture(options, run, viewOption, renderView) {
|
|
|
1688
1907
|
assume("sensor.shutter", "model", "global-electronic", "Global electronic shutter: every site integrates the same exposure window.");
|
|
1689
1908
|
if (rotating)
|
|
1690
1909
|
assume("motion.angularVelocityRadPerSec", "model", { ...angular }, "Constant camera angular velocity applied to every scene ray at each temporal midpoint of each site's exposure window (engine rotation convention, docs/SENSOR_ENVIRONMENT_QUERY.md); motion blur is the midpoint quadrature over sensor.temporalSampleCount samples.");
|
|
1691
|
-
if (
|
|
1910
|
+
if (catalogue)
|
|
1911
|
+
assume("lens.psf", "model", lensPsf ? { kind: "sampled-local", source: "lens.catalogue" } : "not-applied", lensPsf ?
|
|
1912
|
+
"The catalogue lens's engine-built sampled PSF (see lens.catalogue.character) redistributes irradiance through the environment PSF quadrature." : "No lens PSF: the ideal reference has no camera effects.");
|
|
1913
|
+
else if (lensPsf)
|
|
1692
1914
|
assume("lens.psf", "model", { kind: "sampled-local" }, "Caller-supplied sampled lens PSF redistributes irradiance through the environment PSF quadrature; its evidence and limits are the caller's.");
|
|
1693
1915
|
// With lens.diffraction the PSF is recorded as lens.diffraction once its kernels are built.
|
|
1694
1916
|
else if (diffractionRadiusOption === undefined)
|
|
@@ -1698,11 +1920,11 @@ export async function runCapture(options, run, viewOption, renderView) {
|
|
|
1698
1920
|
assume("lens.fieldThroughput", "model", "unity", "No vignetting, distortion, lateral colour or stray light.");
|
|
1699
1921
|
else {
|
|
1700
1922
|
if (vignetting)
|
|
1701
|
-
assume("lens.vignetting", "model", { kind: "radial-illumination-vignetting", profile: vignetting }, "Caller-declared radial relative illumination 1 + r2·ρ² + r4·ρ⁴ + r6·ρ⁶, applied once as environment field throughput at the physical sensor point before any PSF.");
|
|
1923
|
+
assume("lens.vignetting", "model", { kind: "radial-illumination-vignetting", profile: vignetting }, (catalogue ? "The catalogue lens's" : "Caller-declared") + " radial relative illumination 1 + r2·ρ² + r4·ρ⁴ + r6·ρ⁶, applied once as environment field throughput at the physical sensor point before any PSF.");
|
|
1702
1924
|
else
|
|
1703
1925
|
assume("lens.fieldThroughput", "model", "unity", "No vignetting, lateral colour or stray light.");
|
|
1704
1926
|
if (distortion)
|
|
1705
|
-
assume("lens.distortion", "model", distortion, "Caller-declared " + distortion.kind + " distortion: each sensor point is inverse-distorted before the scene-ray query and irradiance is multiplied exactly once by the area factor 1/det(J).");
|
|
1927
|
+
assume("lens.distortion", "model", distortion, (catalogue ? "The catalogue lens's " : "Caller-declared ") + distortion.kind + " distortion: each sensor point is inverse-distorted before the scene-ray query and irradiance is multiplied exactly once by the area factor 1/det(J).");
|
|
1706
1928
|
}
|
|
1707
1929
|
if (projection === undefined)
|
|
1708
1930
|
assume("lens.projection", "default", "rectilinear", "Ideal rectilinear (pinhole) projection.");
|
|
@@ -1896,7 +2118,25 @@ export async function runCapture(options, run, viewOption, renderView) {
|
|
|
1896
2118
|
// #492: each spectral node's kernel for lens.defocus out of focus: the disc, or with lens.diffraction the node's diffraction kernel convolved
|
|
1897
2119
|
// with the disc, radius R_diffraction + R_defocus (built on first use, kept for the request). Object space, or image space (#548).
|
|
1898
2120
|
let defocusSiteKernels;
|
|
1899
|
-
if (defocusKernel) {
|
|
2121
|
+
if (defocusKernel && defocusKernel.radius > DEFOCUS_DIRECT_KERNEL_MAXIMUM_RADIUS_SITES) {
|
|
2122
|
+
// #564: above the direct radius the disc is convolved by runs (site-kernel-runs.ts) and each node's diffraction kernel applied
|
|
2123
|
+
// after it, instead of one combined kernel per node: the same sums regrouped. `at` is never read on this path.
|
|
2124
|
+
const runs = siteKernelRuns(defocusKernel.weights, defocusKernel.radius), diffractionRadius = diffraction ? diffraction.kernelRadiusSamples : 0;
|
|
2125
|
+
const psfConfiguration = diffraction ? diffractionPsf.configuration.psf : undefined, profileWavelengths = diffraction ? diffraction.profile.axes.wavelengthNm : quadratureWavelengths();
|
|
2126
|
+
const diffractionKernels = new Map();
|
|
2127
|
+
defocusSiteKernels = { radius: diffractionRadius + defocusKernel.radius, wavelengthsNm: profileWavelengths, at: () => fail("simulateCapture: the large defocus kernel has no combined kernels."),
|
|
2128
|
+
large: { runs, ...(diffraction ? { diffraction: { radius: diffractionRadius, kernelAt(wavelengthNm) {
|
|
2129
|
+
let kernel = diffractionKernels.get(wavelengthNm);
|
|
2130
|
+
if (!kernel) {
|
|
2131
|
+
if (!profileWavelengths.includes(wavelengthNm))
|
|
2132
|
+
fail("simulateCapture: a spectral node has no diffraction kernel.");
|
|
2133
|
+
kernel = siteDiffractionKernel(psfConfiguration, wavelengthNm, pitch, diffractionRadius, "simulateCapture: diffraction kernels must sample the site pitch exactly.");
|
|
2134
|
+
diffractionKernels.set(wavelengthNm, kernel);
|
|
2135
|
+
}
|
|
2136
|
+
return kernel;
|
|
2137
|
+
} } } : {}) } };
|
|
2138
|
+
}
|
|
2139
|
+
else if (defocusKernel) {
|
|
1900
2140
|
if (diffraction) {
|
|
1901
2141
|
const diffractionRadius = diffraction.kernelRadiusSamples, combined = new Map(), profileWavelengths = diffraction.profile.axes.wavelengthNm;
|
|
1902
2142
|
const radius = diffractionRadius + defocusKernel.radius;
|
|
@@ -1976,17 +2216,19 @@ export async function runCapture(options, run, viewOption, renderView) {
|
|
|
1976
2216
|
}
|
|
1977
2217
|
const readTile = async (request) => ({ ...request, sites: Array.from({ length: request.width }, (_, j) => siteInput(request.y * nativeWidth + request.x + j)) });
|
|
1978
2218
|
const yieldControl = createHostYield().yieldControl;
|
|
1979
|
-
const perSite = queriesPerSite * (diffraction && psf === diffractionPsf ? (2 * diffraction.kernelRadiusSamples + 1) ** 2 : 1);
|
|
2219
|
+
const perSite = queriesPerSite * (diffraction && psf === diffractionPsf ? (2 * diffraction.kernelRadiusSamples + 1) ** 2 : catalogueTaps ?? 1);
|
|
1980
2220
|
let diffractionMs = 0, defocusMs = 0, demosaicMs, encodeMs;
|
|
1981
2221
|
const diffractedProvider = (window) =>
|
|
1982
2222
|
// #548: the disc (or diffraction ⊛ disc) in image space, on the sensor's site lattice, through the mapping, field throughput and rotation.
|
|
1983
2223
|
defocusSiteKernels && defocusGeometry && defocusImageSpace ? createDefocusImageSpaceProvider({ base: provider, geometry: defocusGeometry, siteKernels: defocusSiteKernels.at,
|
|
2224
|
+
...(defocusSiteKernels.large ? { largeKernel: defocusSiteKernels.large } : {}),
|
|
1984
2225
|
wavelengthsNm: defocusSiteKernels.wavelengthsNm, kernelRadius: defocusSiteKernels.radius, nativeWidth, nativeHeight, sitePitchMicrometers: pitch, distanceM: subjectDistanceM,
|
|
1985
|
-
metresPerFrameUnit, queryOffsetsSites, timesPerBand: temporalSampleCount, onConvolution: (ms) => { defocusMs += ms; }, ...(window ? { window } : {})
|
|
1986
|
-
|
|
2226
|
+
metresPerFrameUnit, queryOffsetsSites, timesPerBand: temporalSampleCount, onConvolution: (ms) => { defocusMs += ms; }, ...(window ? { window } : {}),
|
|
2227
|
+
...(bokehZones ? { fieldZones: bokehZones.zones } : {}) }) :
|
|
2228
|
+
defocusSiteKernels ? createDiffractedPlanarProvider({ base: provider, siteKernels: defocusSiteKernels.at, ...(defocusSiteKernels.large ? { largeKernel: defocusSiteKernels.large } : {}),
|
|
1987
2229
|
wavelengthsNm: defocusSiteKernels.wavelengthsNm, kernelRadius: defocusSiteKernels.radius, nativeWidth, nativeHeight, outputWidth: width,
|
|
1988
2230
|
sitePitchMicrometers: pitch, distanceM: subjectDistanceM, metresPerFrameUnit, onConvolution: (ms) => { defocusMs += ms; },
|
|
1989
|
-
...(window ? { window } : {}),
|
|
2231
|
+
...(window ? { window } : {}), ...(bokehZones ? { fieldZones: bokehZones.zones } : {}),
|
|
1990
2232
|
...(antiAliasing || boxSamples > 1 ? { queryOffsetsSites: apertureNodeOffsets(boxSamples).flatMap((node) => (antiAliasing ? antiAliasing.components : [{ offsetMicrometers: { x: 0, y: 0 } }]).map((c) => ({ x: node.x - c.offsetMicrometers.x / pitch, y: node.y - c.offsetMicrometers.y / pitch }))) } : {}) }) :
|
|
1991
2233
|
diffraction && diffractionObjectSpace ? createDiffractedPlanarProvider({ base: provider, psf: diffractionPsf.configuration.psf,
|
|
1992
2234
|
wavelengthsNm: diffraction.profile.axes.wavelengthNm, kernelRadius: diffraction.kernelRadiusSamples, nativeWidth, nativeHeight, outputWidth: width,
|
|
@@ -2068,8 +2310,14 @@ export async function runCapture(options, run, viewOption, renderView) {
|
|
|
2068
2310
|
}
|
|
2069
2311
|
// Display view: the renderer that simulate-display-view.ts passes in reads this request's resolved state, so a bundle
|
|
2070
2312
|
// that only captures does not contain the display view.
|
|
2313
|
+
// #563: the view's expected signal through the lens, from the capture's own geometry (#548), checked to cover its farthest source point: the outer
|
|
2314
|
+
// site centre plus the kernel radius and the largest query offset.
|
|
2315
|
+
const lensSignal = displayView && lensGeometry ? (await import("./display-view-lens-signal.js")).prepareDisplayViewLensSignal({ geometry: lensGeometry,
|
|
2316
|
+
times: rotating ? Array.from({ length: temporalSampleCount }, (_, i) => (i + 0.5) * (shutterSeconds / temporalSampleCount)) : [0], distanceM: subjectDistanceM, metresPerFrameUnit,
|
|
2317
|
+
pitch, imagingArea, boxSamples, spots: antiAliasing ? antiAliasing.components : [{ offsetMicrometers: { x: 0, y: 0 } }] }, nativeWidth, nativeHeight, (diffraction ? diffraction.kernelRadiusSamples : 0) + (displayViewDefocus ? (bokehAxisKernel?.radius ?? defocusDiscKernelRadius(displayViewDefocus.diameterSites)) : 0) +
|
|
2318
|
+
Math.max(0, ...queryOffsetsSites.map((o) => Math.max(Math.abs(o.x), Math.abs(o.y)))) - 0.5, imageSpaceOptions.join(", ")) : undefined;
|
|
2071
2319
|
if (displayView)
|
|
2072
|
-
return await renderView({ ahd, fastReport, antiAliasing, aspect, assume, assumptions, axisChannelResponse, boxSamples, buildProvider, callerScene, chart, materialLayers, chartReport, chartSize, diffraction, defocus: displayViewDefocus, diffractionPsf, fNumber, focalLengthMm, focusDistanceM, height, highlightMode, exposureGain, illuminanceLux, illuminant, illuminantOption, imagingArea, intentOf, metresPerFrameUnit, noiseSeed, outputOptions, parsedView, pitch, preset, provider, regimeByChannel, resolvedIso, isoReport, standardExposureDeviationStops: exposureDeviationStops, standardExposureIlluminanceLux: exposureIlluminanceLux, greyCardDeviationStops: exposureGreyCardDeviationStops, metering, sceneOption, scenePreset, shutterSeconds, started, subjectDistanceM, toneCurve, whiteBalanceOption, whiteBalanceState, width, checkAbort, margin, mode, nativeHeight, nativeWidth, sourceSha256, yieldControl, kelvinWhiteBalanceInput });
|
|
2320
|
+
return await renderView({ lens: lensSignal, ahd, fastReport, antiAliasing, aspect, assume, assumptions, axisChannelResponse, boxSamples, buildProvider, callerScene, chart, materialLayers, chartReport, chartSize, diffraction, defocus: displayViewDefocus, diffractionPsf, fNumber, focalLengthMm, focusDistanceM, height, highlightMode, exposureGain, illuminanceLux, illuminant, illuminantOption, imagingArea, intentOf, metresPerFrameUnit, noiseSeed, outputOptions, parsedView, pitch, preset, provider, regimeByChannel, resolvedIso, isoReport, standardExposureDeviationStops: exposureDeviationStops, standardExposureIlluminanceLux: exposureIlluminanceLux, greyCardDeviationStops: exposureGreyCardDeviationStops, metering, sceneOption, scenePreset, shutterSeconds, started, subjectDistanceM, toneCurve, whiteBalanceOption, whiteBalanceState, width, checkAbort, margin, mode, nativeHeight, nativeWidth, sourceSha256, yieldControl, kelvinWhiteBalanceInput });
|
|
2073
2321
|
// Ideal reference (2.3): the scene without camera effects, at the capture's own exposure, white balance and encoding.
|
|
2074
2322
|
if (idealReference) {
|
|
2075
2323
|
const referenceStarted = clockMs();
|
|
@@ -2191,20 +2439,28 @@ export async function runCapture(options, run, viewOption, renderView) {
|
|
|
2191
2439
|
fail("serializeSimulatedCaptureDngFromParts writes the whole frame: the options take no output.region.");
|
|
2192
2440
|
const dngParts = run === "dng-from-parts" ? viewOption : undefined;
|
|
2193
2441
|
let tabulated;
|
|
2194
|
-
|
|
2442
|
+
// #553: a cat's eye varies the kernel over the field, which the expected-signal tables (one kernel per node) do not take.
|
|
2443
|
+
if (dngParts === undefined && tabulatedScene && !pupil && !lensFieldMapping && !vignetting && !lensPsf && !rotating && !bokehZones && (!diffraction || diffractionObjectSpace) && provider.chartMaterialAt && provider.materialRadiance) {
|
|
2195
2444
|
const { electronsPerRadiance, wavelengths } = axisChannelResponse("simulateCapture");
|
|
2196
2445
|
const perNode = CHANNELS.map((c) => Float64Array.from(wavelengths, (nm) => electronsPerRadiance[c].get(nm) ?? 0));
|
|
2197
2446
|
const sceneMaterials = chart ? chart.materials : callerScene.materials, materialRadiance = provider.materialRadiance;
|
|
2447
|
+
const tabulatedMaterials = { materialAt: provider.chartMaterialAt, whiteRadiance: (nm) => irradianceScale * illuminant.shape.evaluate(nm) / Math.PI,
|
|
2448
|
+
list: [...sceneMaterials.map((m, index) => (m.kind === "neutral" ? { neutral: m.reflectance } : { radiance: (nm) => materialRadiance(index, nm) })),
|
|
2449
|
+
...(chartSize ? [{ neutral: chartSize.surroundReflectance }] : [])] };
|
|
2198
2450
|
const { signalInput: builtSignalInput } = buildExpectedSignalInput({ nativeWidth, nativeHeight, width, wavelengths, perNode, apertureNodes: apertureNodeOffsets(boxSamples), boxSamples, antiAliasing, pitch,
|
|
2199
2451
|
diffraction: diffraction && !defocusSiteKernels ? { radius: diffraction.kernelRadiusSamples, psf: diffractionPsf.configuration.psf, profileWavelengths: diffraction.profile.axes.wavelengthNm } : undefined,
|
|
2200
|
-
materials:
|
|
2201
|
-
list: [...sceneMaterials.map((m, index) => (m.kind === "neutral" ? { neutral: m.reflectance } : { radiance: (nm) => materialRadiance(index, nm) })),
|
|
2202
|
-
...(chartSize ? [{ neutral: chartSize.surroundReflectance }] : [])] },
|
|
2203
|
-
radianceAt: provider.radianceAt, imagingArea, focalLengthMm, focusDistanceM, subjectDistanceM, metresPerFrameUnit, caller: "simulateCapture" });
|
|
2452
|
+
materials: tabulatedMaterials, radianceAt: provider.radianceAt, imagingArea, focalLengthMm, focusDistanceM, subjectDistanceM, metresPerFrameUnit, caller: "simulateCapture" });
|
|
2204
2453
|
// #492: with lens.defocus the table convolves the lattice radiance with each node's defocus (or combined) kernel, on the
|
|
2205
2454
|
// lattice formula, exactly as the object-space provider does.
|
|
2206
2455
|
let signalInput = builtSignalInput;
|
|
2207
|
-
if (defocusSiteKernels) {
|
|
2456
|
+
if (defocusSiteKernels?.large) {
|
|
2457
|
+
// #564: the in-focus signal on the lattice formula (diffraction kernels, or a unit tap per node), then the disc by runs.
|
|
2458
|
+
signalInput = buildExpectedSignalInput({ nativeWidth, nativeHeight, width, wavelengths, perNode, apertureNodes: apertureNodeOffsets(boxSamples), boxSamples, antiAliasing, pitch,
|
|
2459
|
+
diffraction: diffraction ? { radius: diffraction.kernelRadiusSamples, psf: diffractionPsf.configuration.psf, profileWavelengths: diffraction.profile.axes.wavelengthNm } : undefined,
|
|
2460
|
+
largeDefocus: defocusSiteKernels.large.runs, materials: tabulatedMaterials,
|
|
2461
|
+
radianceAt: provider.radianceAt, imagingArea, focalLengthMm, focusDistanceM, subjectDistanceM, metresPerFrameUnit, caller: "simulateCapture" }).signalInput;
|
|
2462
|
+
}
|
|
2463
|
+
else if (defocusSiteKernels) {
|
|
2208
2464
|
const lattice = { ...builtSignalInput };
|
|
2209
2465
|
delete lattice.queryPoint;
|
|
2210
2466
|
signalInput = { ...lattice, kernels: { radius: defocusSiteKernels.radius, perNode: wavelengths.map((nm) => defocusSiteKernels.at(nm)) } };
|
|
@@ -2470,7 +2726,8 @@ export async function runCapture(options, run, viewOption, renderView) {
|
|
|
2470
2726
|
}
|
|
2471
2727
|
const ranOptions = new Set([...(pupil ? ["lens.pupilSampling"] : []), ...(projection !== undefined ? ["lens.projection"] : []),
|
|
2472
2728
|
...(distortion ? ["lens.distortion"] : []), ...(vignetting ? ["lens.vignetting"] : []), ...(lensPsf ? ["lens.psf"] : []),
|
|
2473
|
-
...(
|
|
2729
|
+
...(catalogue ? ["lens.catalogue"] : []),
|
|
2730
|
+
...(diffraction ? ["lens.diffraction"] : []), ...(defocusSiteKernels || catalogueDefocusApplied ? ["lens.defocus"] : []), ...(antiAliasing ? ["sensor.antiAliasing"] : []), ...(boxAperture ? ["sensor.pixelAperture.box"] : []),
|
|
2474
2731
|
...(temporalSampleCount > 1 ? ["sensor.temporalSampleCount"] : []), ...(rotating ? ["motion.rotation"] : []),
|
|
2475
2732
|
...(rollingSchedule ? ["motion.shutter.rolling"] : []), ...(mirrorBorder ? ["output.borderHandling.mirror"] : []), ...(region ? ["output.region"] : []),
|
|
2476
2733
|
...(needsAuto ? ["output.whiteBalance.auto"] : []), ...(ahd ? ["output.demosaic.ahd"] : []),
|