← Ziding Zhang

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


Open Optical Lens Bench →

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.

Split comparison of a rainy Tokyo alley: left half native deep-focus frame, right half rendered through the ray-traced Carl Zeiss Planar T* 50mm f/1.4 optical formula focused on the foreground umbrella at 2.9 meters.
Native deep focus on the left; ray-traced Carl Zeiss Planar T* 50mm f/1.4 focused at 2.90 m on the right. Open the bench to drag the focus reticle, swap lenses, or drop in your own photo.

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):

  1. Distance mapping (Equiv. Mag vs Real 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.
  2. 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.
  3. 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).

LensPatent embodimentVerified EFL / BFLCorner transmission (wide → f/4.0)Iris
Leica Summilux-M 35mm f/1.4 ASPHUS 5,161,060 Ex. 1 (9 elem / 5 grp, 2 asph)35.41 mm / 19.64 mm23% at f/1.4 → 69% at f/4.09-blade
Carl Zeiss Planar T* 50mm f/1.4US 3,874,771 Ex. 5 (Contax/Yashica & ZF, 7 elem / 6 grp)50.00 mm / 35.46 mm30% at f/1.4 → 90% at f/4.09-blade
Carl Zeiss Planar T* 85mm f/1.4US 3,948,584 Ex. 4 (6 elem / 5 grp)84.96 mm / 38.15 mm71% at f/1.4 → 95% at f/4.09-blade
Leica Noctilux-M 50mm f/1.0Leitz Wetzlar f/1.0 (7 elem / 6 grp)52.05 mm / 27.34 mm16% at f/1.0 → 78% at f/4.010-blade
2D Snell's-law ray-traced cross-section of the Carl Zeiss Planar T* 50mm f/1.4 showing seven curved glass elements, red aperture stop at 19.9 mm, and rays converging across 0%, 60%, and 100% field heights onto a 21.6 mm half-diagonal full-frame sensor.
Live 2D Snell's-law cross-section of the Carl Zeiss Planar T* 50mm f/1.4 at f/1.4 (EFL = 50.0 mm, BFL = 35.5 mm). Inside the bench, stepping the f-stop physically closes the red iris blades and narrows the marginal ray cones.
Polychromatic 7-wavelength ray-traced bokeh point-spread function matrix for Carl Zeiss Planar T* 50mm f/1.4 at f/1.4 and f/2.8 across five field heights from 0% center to 100% corner and five defocus distances from 0.85 meters to infinity.
7-wavelength ray-traced PSF matrix for Carl Zeiss Planar T* 50mm f/1.4 at f/1.4 (top five rows) and f/2.8 (bottom five rows). Note the bright-core front bokeh, rimmed back bokeh with longitudinal chromatic aberration, cat's-eye corner clipping wide open, and 9-blade polygonal apertures stopped down.

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 with apple/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.js reads FocalLengthIn35mmFilm and FNumber directly from the JPEG APP1 block in the browser, and a dedicated Web Worker (depth-worker.js) runs onnx-community/depth-anything-v2-small via Transformers.js (webgpu with automatic wasm fallback) 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:
    1. 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.
    2. Add an optional layered disocclusion inpainting pass behind steep depth edges, or test anamorphic / Petzval / Helios 44-2 Biotar .zmx prescriptions directly by dropping another patent file into the ray-tracer script.

Have an answer, a counterexample, or a story? See Talk to me for open questions and live trials.

Credits: Ziding Zhang with Gemini 4 Neon. Inspired by @1umsensor's Depth Pro 2 lens simulator. Built with Apple Depth Pro 2 (depthpro2-b), Beam42 patent Zemax prescriptions, Transformers.js (onnx-community/depth-anything-v2-small for local uploads), and open-licensed Wikimedia Commons photographs (Ximonic, Franck Michel, Wiki.cullin).