Simulating classic camera lenses from one photograph
Apple Depth Pro 2 gives every pixel a physical distance in meters. Tracing seven wavelengths through patent glass formulas turns flat deep-focus photographs into interactive full-frame lens renders in the browser.
December 1, 2026 · Project · What is not yet established
A smartphone photograph looks like a smartphone photograph because a tiny sensor keeps nearly every plane in focus at once—and software portrait filters replace that missing optics with a uniform blur over a cutout mask.
When I tried relighting a single museum photograph, scale was the missing number: one image could not separate a small bust nearby from a large one far away. Apple Depth Pro 2 predicts both camera focal length and per-pixel metric depth in meters—even across umbrella shafts, overhead power lines, and backlit wildflower stems. On the four test scenes here, its blind focal-length estimates landed within roughly 5–10% of the cameras’ recorded EXIF.
Once every pixel has a real distance, believable full-frame rendering depends on three physical effects that Gaussian portrait blur misses, modelled here from real glass geometry rather than hand-tuned sliders (the same physical-refraction instinct behind lighting a wine glass with one lamp):
- Distance mapping (
Equiv. MagvsReal Dist). A 50 mm or 85 mm full-frame lens applied at a 23 mm phone shot’s literal meters produces macro-thin blur; scaling scene depth by the focal ratio matches the framing magnification you would get stepping back with the real lens. - Asymmetric spherical aberration and chromatic dispersion. Tracing seven visible wavelengths (430–670 nm) through each lens’s published glass radii, refractive indices, and Abbe numbers yields creamy bright-core front bokeh and crisply rimmed back bokeh with subtle green-magenta longitudinal fringing.
- Mechanical barrel vignetting. Oblique corner ray bundles clip against the front and rear glass diameters before reaching the 36 × 24 mm sensor, trimming corner bokeh discs into tangential cat’s-eye ellipses and dropping wide-open corner light—to 30% on the Planar 50 at f/1.4, recovering to 90% by f/4.0.
Built after seeing F.E.N.I.’s Depth Pro 2 lens simulator. Inside the bench, switch between Leica Summilux-M 35mm ASPH, Carl Zeiss Planar T* 50mm, Planar T* 85mm, and Leica Noctilux-M 50mm f/1.0, inspect the live ray-traced cross-section and 7-wavelength PSF gallery beneath the photo, or upload your own shot (processed locally in the browser).
Agent context: sources, method and working notes
Verified optical prescriptions and ray-traced measurements
Four patent Zemax prescriptions from the open Beam42 optical archive were traced in 3D skew-ray Snell’s law (with Newton-Raphson EVENASPH surface intersection for the two aspheric surfaces in Leica’s Summilux 35) across seven CIE 1931 D65-weighted wavelengths (430, 470, 510, 550, 590, 630, 670 nm), using Schott/Cauchy dispersion from each glass element’s nd and Vd values and exact mechanical clear-aperture diameters (DIAM).
| Lens | Patent embodiment | Verified EFL / BFL | Corner transmission (wide → f/4.0) | Iris |
|---|---|---|---|---|
| Leica Summilux-M 35mm f/1.4 ASPH | US 5,161,060 Ex. 1 (9 elem / 5 grp, 2 asph) | 35.41 mm / 19.64 mm | 23% at f/1.4 → 69% at f/4.0 | 9-blade |
| Carl Zeiss Planar T* 50mm f/1.4 | US 3,874,771 Ex. 5 (Contax/Yashica & ZF, 7 elem / 6 grp) | 50.00 mm / 35.46 mm | 30% at f/1.4 → 90% at f/4.0 | 9-blade |
| Carl Zeiss Planar T* 85mm f/1.4 | US 3,948,584 Ex. 4 (6 elem / 5 grp) | 84.96 mm / 38.15 mm | 71% at f/1.4 → 95% at f/4.0 | 9-blade |
| Leica Noctilux-M 50mm f/1.0 | Leitz Wetzlar f/1.0 (7 elem / 6 grp) | 52.05 mm / 27.34 mm | 16% at f/1.0 → 78% at f/4.0 | 10-blade |
Depth pipeline and rendering architecture
- Built-in metric scenes (Apple Depth Pro 2): Four open-licensed deep-focus scenes (
Nakano Rain Alley,Shinjuku Lanterns,Ramen & Cast Iron,Wildflowers & Spire) were inferred withapple/DepthPro2-B(depthpro2-b, 1280px width) and packed into lossless 12-bit RG-encoded inverse-depth PNGs (4,096 discrete metric depth levels per scene) alongside the exact inverse-depth bounds and predicted focal lengths.Nakano Rain Alley(EXIF 35 mm f/5.0, Depth Pro 2 est. 35.8 mm, 2.66–42.2 m): Ximonic, Wikimedia Commons (CC BY-SA 4.0).Shinjuku Lanterns(EXIF 70 mm f/4.0, Depth Pro 2 est. 79.3 mm, 8.22–73.5 m): Franck Michel, Wikimedia Commons (CC BY 2.0).Ramen & Cast Iron(iPhone 4S EXIF 35 mm f/2.4, Depth Pro 2 est. 36.6 mm, 0.57–1.40 m): Wiki.cullin, Wikimedia Commons (CC0).Wildflowers & Spire(Galaxy A55 5G EXIF 23 mm f/1.8, Depth Pro 2 est. 25.5 mm, 1.10–250 m): Wikimedia Commons (CC BY-SA 4.0).
- Client-side uploads: When a reader drops or uploads a local photo,
exif.jsreadsFocalLengthIn35mmFilmandFNumberdirectly from the JPEG APP1 block in the browser, and a dedicated Web Worker (depth-worker.js) runsonnx-community/depth-anything-v2-smallvia Transformers.js (webgpuwith automaticwasmfallback) so images never leave the device. - Real-time WebGL 2 renderer (
lens-engine.js): Four GPU passes linearize sRGB with reversible specular highlight headroom, compute the signed full-frame metric Circle of Confusion, dilate foreground near-field reach so out-of-focus foreground edges halo cleanly over sharper backgrounds without background bleed onto sharp foregrounds, and convolve 144 golden-angle Vogel disk taps (with Interleaved Gradient Noise phase rotation and depth-preserving bilateral polish) weighted directly by each lens’s rotated spatially-varying 7-λ PSF atlas and ray-traced mechanical vignetting curve.
Critique or advance this
- Weakest premise: Single-view depth-aware PSF convolution cannot reconstruct scene texture hidden behind an out-of-focus foreground silhouette, and our in-browser upload fallback uses relative Depth Anything V2 rather than true metric Depth Pro 2.
- Concrete extensions:
- Export an ONNX quantized build of
apple/DepthPro2-S(24M parameters, ~97 MB fp32 / ~25 MB q8) for WebGPU so uploaded photos also receive true metric depth and automatic focal-length estimation in the browser. - Add an optional layered disocclusion inpainting pass behind steep depth edges, or test anamorphic / Petzval / Helios 44-2 Biotar
.zmxprescriptions directly by dropping another patent file into the ray-tracer script.
- Export an ONNX quantized build of