https://github.com/sidp/physical-camera
https://github.com/sidp/physical-camera
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/sidp/physical-camera
- Owner: sidp
- Created: 2026-02-18T10:52:36.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2026-02-26T16:21:29.000Z (4 months ago)
- Last Synced: 2026-02-26T20:31:44.949Z (4 months ago)
- Language: Python
- Size: 1 MB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Physical Camera
A Blender extension that replaces Blender's built-in camera with a physically-based lens simulation. Rays are traced through real lens prescriptions to produce realistic depth of field, bokeh shapes, chromatic aberration, and vignetting.
## Features
- Sequential ray tracing through multi-element lens designs
- Spherical, aspheric, and cylindrical surface types
- Anamorphic lens support with dual-axis ABCD optics and elliptical bokeh
- Fresnel transmission loss with single/multi coating models and natural vignetting
- Spectral chromatic aberration (400-700nm continuous sampling)
- Variable element spacing for internal focusing (when patent data is available)
- Polygonal aperture blades with adjustable rotation
- Focus distance driven by Blender's camera settings
- Debug visualization modes for diagnosing ray behavior
## Requirements
- Blender 4.5 or later
- Cycles render engine with OSL enabled
- CPU or OptiX rendering (OSL cameras are not supported on CUDA, HIP, or Metal)
## Installation
1. Download or clone this repository
2. In Blender, go to Edit > Preferences > Add-ons > Install from Disk
3. Select the `addon` directory
## Usage
1. Select a camera in your scene
2. Open the Camera Properties panel
3. In the "Physical Lens" panel, click "Enable Physical Lens"
4. Choose a lens and adjust settings:
- **Lens** — select from available lens prescriptions
- **f-stop** — aperture size (clamped to the lens's maximum)
- **Aperture Blades** — 0 for circular, 3+ for polygonal bokeh
- **Blade Rotation** — rotate the aperture shape
- **Chromatic Aberration** — toggle spectral dispersion
- **Debug Mode** — Normal, Pinhole, Diagnostic (failure visualization), or Exit Direction
Focus distance is controlled through Blender's standard camera Depth of Field settings.
## Included Lenses
- Canon RF 85mm f/1.2L USM (aspheric, internal focusing)
- Cooke Triplet 50mm f/4.5
- Double Gauss 50mm f/2
- Double Gauss 100mm f/1.7
- Mamiya 55mm f/2.8 N (medium format)
- Mamiya 150mm f/4 Soft (medium format, soft focus)
- Navarro Anamorphic 2x Cinema (anamorphic, aspheric)
- Neil Front Anamorphic 2x Cinema (anamorphic, internal focusing)
- Nikkor AI AF Fisheye 16mm f/2.8D (internal focusing)
- Petzval 85mm f/2.4
- Sonnar 50mm f/1.5
- Tessar 50mm f/2.8
- Zeiss Distagon 35mm f/4
- Zeiss Planar 80mm f/2.8 (medium format)
- Zuiko 18mm f/3.5 (internal focusing)
## Adding a Lens
Create a `.toml` file in `addon/lenses/` with the following format:
```toml
[lens]
name = "Lens Name"
focal_length = 50.0
max_fstop = 2.0
coating = "multi" # "none", "single", or "multi"
[[surface]]
radius = 29.475
thickness = 3.76
ior = 1.67
aperture = 25.2
abbe_v = 57.0
[[surface]]
type = "stop"
radius = 0
thickness = 2.5
ior = 1.0
aperture = 20.0
abbe_v = 0.0
# ... more surfaces
```
Surfaces are listed front-to-back (scene-side to sensor-side). All dimensions are in millimeters. The aperture stop must have `type = "stop"` with `radius = 0` and `ior = 1.0`. Aspheric surfaces use `type = "aspheric"` with `conic` and `aspheric_coeffs` fields. Cylindrical surfaces for anamorphic lenses use `type = "cylindrical_x"` or `type = "cylindrical_y"`.
After adding a lens, regenerate diagram previews: `uv run scripts/build_diagrams.py`
See `CLAUDE.md` for details on variable element spacing, aspheric coefficients, and cylindrical surface conventions.
## License
GPL-3.0-or-later