Metadata-Version: 2.4
Name: foton-daylight
Version: 0.3.1
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Rust
Classifier: Topic :: Scientific/Engineering
Requires-Dist: numpy>=1.23
Requires-Dist: honeybee-core>=1.64,<2 ; extra == 'honeybee'
Requires-Dist: honeybee-radiance>=1.66,<2 ; extra == 'honeybee'
Requires-Dist: honeybee-radiance-postprocess>=0.5,<1 ; extra == 'honeybee'
Requires-Dist: ladybug-core>=0.44,<1 ; extra == 'honeybee'
Requires-Dist: platformdirs>=4.3,<5 ; extra == 'honeybee'
Requires-Dist: pytest>=8,<10 ; extra == 'test'
Requires-Dist: fastapi>=0.115,<1 ; extra == 'viewer'
Requires-Dist: ladybug-core>=0.44,<1 ; extra == 'viewer'
Requires-Dist: platformdirs>=4.3,<5 ; extra == 'viewer'
Requires-Dist: python-multipart>=0.0.18,<1 ; extra == 'viewer'
Requires-Dist: uvicorn>=0.32,<1 ; extra == 'viewer'
Requires-Dist: websockets>=14,<16 ; extra == 'viewer'
Provides-Extra: honeybee
Provides-Extra: test
Provides-Extra: viewer
License-File: LICENSE
Summary: Hardware-accelerated daylight coefficients and annual metrics with Metal, Vulkan, and deterministic CPU backends
Keywords: daylight,radiance,honeybee,metal,vulkan,ray-tracing
Requires-Python: >=3.10
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Documentation, https://github.com/snjsomnath/foton/tree/main/docs
Project-URL: Issues, https://github.com/snjsomnath/foton/issues
Project-URL: Repository, https://github.com/snjsomnath/foton

# Foton

This project is basically an exercise in using LLMs to create reimplementations within a tight scope against a deterministic target. In this case, we wanted to have fast GPU based daylighting calculations for teaching purposes, so we built it! (or asked an LLM to).
Everything after this point here is generated by an LLM.

**GPU-accelerated daylight transport for architectural analysis.**

[![PyPI](https://img.shields.io/pypi/v/foton-daylight?style=flat-square)](https://pypi.org/project/foton-daylight/)
[![Radiance benchmark](https://img.shields.io/badge/Radiance-benchmarked-blue?style=flat-square)](https://www.radiance-online.org/)
[![Honeybee](https://img.shields.io/badge/Honeybee-1.x-orange?style=flat-square)](https://www.ladybug.tools/honeybee/)
[![License](https://img.shields.io/badge/license-MIT-green?style=flat-square)](LICENSE)

Foton is an experimental GPU-based daylight transport engine for architectural
analysis.

It is not a replacement for Radiance or Honeybee. Instead, it explores whether
the expensive ray-traced transport step in a Radiance-style daylight workflow
can be moved to the GPU and made fast enough for interactive use.

![Daylight autonomy of a shaded shoebox computed by Foton in Grasshopper and drawn by Ladybug's spatial heatmap](docs/images/grasshopper-heatmap-viewport.png)

*The shipped Grasshopper example: Foton computes the annual metrics on the GPU in about a second; Honeybee's own metrics component and Ladybug's heatmap read the result folder as if Radiance had written it ([quickstart](docs/grasshopper-quickstart.md)).*

## Where Foton fits

A simplified Radiance matrix workflow looks like:

    Sky
     |
     v
    rfluxmtx / rcontrib
     |
     v
    Sky -> sensor transport
     |
     v
    Illuminance / annual metrics

Foton focuses on the transport step:

    Sky
     |
     v
    +-----------+
    |   Foton   |  GPU ray tracing
    +-----------+
     |
     v
    Sky -> sensor transport
     |
     v
    Illuminance / annual metrics

Foton uses Honeybee-generated models and Radiance as a reference for
benchmarking.

## What it does

- GPU ray-traced direct visibility
- Diffuse multi-bounce transport
- Thin-glass transport
- Tregenza (146) and Reinhart MF:2 (578) sky subdivisions
- Daylight transport coefficients
- Illuminance and annual daylight calculations
- DA and sDA
- Metal and Vulkan GPU backends
- Deterministic CPU reference backend
- Python API and Honeybee integration

The current implementation is aimed primarily at conventional architectural
daylighting: diffuse surfaces, ordinary glazing, shading devices, and
building-scale sensor grids.

## What it does not do

Foton does not currently reproduce the full Radiance material and transport
model.

In particular, it should not yet be assumed equivalent to Radiance for:

- a separate direct-sun pass: Foton is a two-phase method, so the sun is
  carried inside its sky patch (as `rfluxmtx` does), not traced as a disc.
  DF and sky-coefficient parity are exact. Against Honeybee's annual recipe
  with its traced sun, run at converged ambient settings, this cost about
  1 pp of DA and 1 % of energy on south-facing teaching rooms in Phoenix,
  Seattle and Gothenburg ([measured](validation/results/2026-11-02-teaching-sun-vs-stock/README.md));
  the recipe's default two-bounce ambient setting is a far larger difference,
  reading about 15 % below both Foton and converged Radiance
- complex BSDF materials
- advanced daylight-redirecting systems
- highly specular environments
- arbitrary Radiance material types
- certification or compliance calculations

Radiance remains the reference for those applications.

## How does it compare with Radiance?

The repository contains automated comparisons against Radiance on 106
Honeybee-generated scenes, each at two sky densities, with converged
`rfluxmtx` references (up to twelve replicates at 80,000 ambient divisions and
12 bounces). The archived campaign of 2 November 2026 on the shipped `final`
preset gave, on the 204 of 212 cases inside the gates:

- Full diffuse + thin-glass sky coefficients: energy bias within 5 %, RMS
  error within 10 % of the coefficient scale, typically 1–3 %
- Annual illuminance: bias within 5 % and hourly CV(RMSE) within 10 %,
  typically 1–3 % on directly lit rooms
- DA, cDA, UDI and sDA: mean absolute error within 2 percentage points on
  every grid
- Against Honeybee's own annual recipe with a traced sun, run at converged
  ambient settings: about 1 pp of DA and 1 % of energy in Phoenix, Seattle and
  Gothenburg

The eight cases outside the gates, the gate definitions and the open questions
are in [purpose and plan](docs/purpose-and-plan.md) and the campaign READMEs
under `validation/results/`. These results are for static diffuse materials
and thin glass; they are not a claim that Foton matches Radiance to a fixed
accuracy for arbitrary models.

## Performance

On the current benchmark machine (Apple M4 Pro), the 216-sensor / 146-patch
full transport calculation took:

    Foton:      5.79 ms
    rcontrib:   3574 ms

This is a single benchmark configuration, not a general speedup claim.

The purpose of the comparison is to show the potential of GPU transport for
interactive daylight analysis. The Vulkan backend has so far run on one other
GPU, an NVIDIA Tesla T4 on Linux, where a cold annual run of a corpus scene
takes a median 1.5 s against 0.25 s on the M4 Pro
([evidence](validation/results/2026-11-03-architectural-v4-vulkan-t4/README.md)).

## Installation

    pip install foton-daylight

For Honeybee support:

    pip install "foton-daylight[honeybee]"

## Status

Foton is experimental and under active development.

The goal is not to replace Radiance. The goal is to make a focused part of
Radiance-style daylight transport fast enough to use interactively in
architectural design and research.

**Accuracy against Radiance is established on the teaching scenes and on the
corpus, with two named exceptions, on both GPU backends.** The archived
campaigns of 2 and 3 November 2026 (106 scenes at two sky densities against
converged Radiance 5.4a references, on the `final` preset as shipped) passed
204 of 212 cases on Metal (Apple M4 Pro) and the same 204 on Vulkan (NVIDIA
Tesla T4, Linux), the two backends agreeing within 0.008 percentage points of
energy bias; all 32 teaching cases and every room-form, shading, context and
opening case pass, and DA, cDA, UDI and sDA agreed within 2 percentage points
on every grid. The eight
cases outside the gates are rooms lit only through internal glazing, where
hourly illuminance scatters 15 to 35 percent and one room reads 5 percent
high, and one bright 12 m room where Radiance itself moves 3.6 percent between
8 and 12 bounces. Details, the diagnosis and what is still open are in
[purpose and plan](docs/purpose-and-plan.md). Static diffuse materials and
thin glass are supported; nothing here claims compliance, ASE, glare, dynamic
shading or BSDF support.

Further reading: [Grasshopper quickstart](docs/grasshopper-quickstart.md),
[installation](docs/installation.md), [Python API](docs/python-api.md),
[benchmarking](docs/benchmarking.md), [validation corpus](validation/architectural-scenes.md).

### Cinematic teaching demo

Run `cd viewer && npm run dev:demo` and open `http://127.0.0.1:5173/demo.html`
for a roughly one-minute architectural teaser with automated cameras, room
changes and live GPU analysis. Gothenburg weather is prepared from the
repository EPW. See the [demo guide](viewer/src/demo/README.md).

