# Second Sun

Kochu Studio optical experiment EX04. A simulated shaped mirror reflects a parallel beam onto an offset screen, recalling the golden disc and dark arc in Iana Kochu’s [*Red Meridian*](../../assets/red-meridian.jpg). The disc is concentrated light. The dark arc is an area that receives less of it.

## Scene

A 2 × 2 ideal specular mirror lies in the XZ plane at nominal Y = 0. A directional area lamp at (−3.37254, 5, 0) sends parallel rays in direction (0.55919, −0.82904, 0), at 34° to the nominal mirror normal. A white Lambertian receiver faces downward at (3.37254, 5, 0). The source and screen sit on opposite sides of the mirror and are separated by 6.745 scene units along X. The receiver is 2.72 units square. Its camera looks straight at a centered 2.14 × 2.14 crop. The only difference between the flat and optimized scenes is the mirror’s Y relief. The solved mirror spans −0.025077 to +0.023083 scene units.

The grayscale target comes from two contours traced on the original photograph. It keeps the irregular disc and the tapered, widening arc. A dim halo surrounds the disc so the arc reads as a reduction in light. The renderer receives the mirror, lamp, uniform diffuse receiver and camera. The traced target enters the optimization objective.

## Method and fit

The design follows EPFL’s [Computational Caustics](https://www.epfl.ch/labs/gcm/research-projects/computational-caustics/) experiments with shaped reflectors. The implementation adapts the [Mitsuba caustics optimization notebook](https://mitsuba.readthedocs.io/en/latest/src/inverse_rendering/caustics_optimization.html) and the geometry export approach used in [A Painting Made of Light](../painting-made-of-light/README.md). Mitsuba 3.9.1 and Dr.Jit 1.5.0 ran on macOS arm64 using `metal_ad_mono`. The emitter-side particle tracer follows the lamp to the mirror and the reflected paths to the receiver. The mirror has a smooth ideal conductor BSDF. Its 81 × 81 vertex mesh has interpolated shading normals.

The solver used 360 Adam updates with a 0.00065 learning rate and a 112 × 112 film. The height field grew from 14² to 28² to 56² at updates 90 and 216. Training used 32 samples per pixel per forward and gradient pass, doubling to 64 for the final quarter. The target exposure in the loss was fixed at 95% of the flat crop’s mean radiance. This makes dimming the whole image costly in the loss. Final evaluation used 1,024 samples per pixel and a seed shared by the two mirror states and separate from the training seeds.

| Measurement | Flat | Optimized |
| --- | ---: | ---: |
| Pearson pixel correlation with target | 0.2256 | 0.9787 |
| Mean-normalized RMSE | 0.7242 | 0.1832 |
| Bright disc intersection over union | 0.00% | 97.17% |
| Dark arc irradiance as a share of the surrounding halo | 99.95% | 18.63% |
| Mean crop irradiance in scene units | 0.5793 | 0.4572 |

RMSE compares each receiver and the target after division by its own mean. Bright disc overlap compares the target above 0.75 with the receiver above the same threshold after mean normalization. Arc contrast compares the mean on the interior of the traced arc to the mean over the halo outside both traced shapes. The raw arrays include both masks. Mean irradiance is π times mean linear receiver radiance for the unit-reflectance Lambertian screen. The optimized crop receives 78.9% of the flat control’s mean irradiance.

Both grayscale receiver images use one exposure and sRGB encoding. The amber display applies one shared monotonic palette to those grayscale pixels. The grayscale target uses its own scale, with target value 1 shown as white. The 3D diagram uses sampled ray intersections from the Mitsuba scene. Dashed reflected probes show crossings of the receiver plane outside the receiver.

This is a geometric optics simulation with a perfectly specular coating, a collimated source, and no surface scattering or diffraction. The high-contrast details depend on the modeled illumination angle and alignment. The PLY surface is a simulation mesh with interpolated normals and has no manufacturing tolerances or mounting design.

## Reproduce

Run from this directory with `uv` and Python 3.13.

```sh
scratch=$(mktemp -d "${TMPDIR:-/tmp}/second-sun.XXXXXX")
uv venv --python 3.13 "$scratch/venv"
uv pip install --python "$scratch/venv/bin/python" mitsuba==3.9.1 drjit==1.5.0 numpy==2.5.4 pillow==13.0.0
"$scratch/venv/bin/python" solve.py --output "$scratch/run"
```

The Metal backend was verified. The CLI also accepts `--variant llvm_ad_mono` on machines with a compatible Dr.Jit LLVM library. Parallel floating-point reductions can give slightly different results on repeated Metal solves. An independent replay reached 0.9791 correlation, 0.1846 normalized RMSE, 97.74% disc overlap and 0.4566 mean irradiance. Serve the Kochu Studio prototype over HTTP and visit `/light-experiments/second-sun/`.

- [Target](target.png), [flat receiver](flat.png), [optimized receiver](optimized.png), and [mirror heightmap](heightmap.png).
- [Amber optimized receiver](cover.png) and [amber flat receiver](flat-amber.png).
- [Flat mesh](mirror-flat.ply) and [optimized mesh](mirror-optimized.ply).
- [Linear receiver arrays, target and masks](data.npz), [surface grid and traced rays](surface.json), and [full run metrics](results.json).
