utrecht3d · technical notes · pipeline order

Utrecht3d Algorithms

utrecht3d builds a textured 3D model of Utrecht from open geodata only: 3DBAG buildings, AHN elevation, PDOK aerial photos, BGT and OSM objects, and openly licensed street photos. This page walks through the main algorithms in the order the data flows, from raw downloads to the browser viewer and the Blender film. Every figure is a schematic; numbers in the tables come from the source code.

CRS RD New · EPSG:28992heights NAPtile 250 m from 135850, 454900viewer part 125 mtile i_j → x = 135850 + 250·i
A

Data & geometry

Downloads from 3DBAG, BAG, AHN, BGT and the municipal registers become clean building and tree geometry per 250 m tile.

A1

3DBAG ingest and the deduplicated store

src/utrecht3d/bag_store.py src/utrecht3d/sources.py src/utrecht3d/buildings.py src/utrecht3d/bag_fallback.py

3DBAG is fetched as one JSON list of CityJSON features per query box, and the boxes overlap. The same building was saved up to ten times: 2,430 files and 3.6 GB on disk for 83k unique features (0.65 GB).

  1. Fetch each window from the 3DBAG API (collections/pand/items) for a tile box.
  2. Serialise every feature and hash it with BLAKE2b (16-byte digest). Store it once, zlib-compressed, with INSERT OR IGNORE.
  3. For the window, store only the ordered list of hashes, the count and a SHA-256 of the full text.
  4. On read, join the feature texts back into [a, b, …]: the original file returns byte for byte, and verify checks that.
  5. Panden that 3DBAG does not have yet (new builds) become flat LoD1 blocks from the BAG footprint, with a height from the AHN DSM.
feature keyblake2b, 16 bytes
compressionzlib level 9
tablesfeature(h, pid, z) · window(ns, key, n, hs, sha)
journalSQLite WAL
fallback: skip if overlapping 3DBAG> 30 %
fallback heightAHN DSM p70, if > ground + 2.5 m
fallback: skip if on street/water (BGT)> 50 %
switch offUTRECHT3D_BAG_STORE=0

Open data: 3DBAG (CC BY 4.0), BAG via PDOK, AHN, BGT.

A1 · 3DBAG store
illustrativeFour overlapping windows reference the same buildings. Each feature enters the store once; a window keeps only its list of hashes.
A2

Werfkelder filter

src/utrecht3d/werfkelder_filter.py src/utrecht3d/bag_fallback.py

Along the canals, 3DBAG sometimes models a wharf cellar under the quay as a box standing on the street, or lets a pand run out over the quay as a strip. The filter finds those from three independent signals.

  1. Build the street-and-quay surface from BGT: road and water parts at level 0, quay and retaining walls, and bare ground within 15 m of water.
  2. Rule 1: more than half of the footprint lies on that surface.
  3. Rule 2: the AHN DSM there (p70) stays within 1.5 m of the street level, measured in a 3 m ring around it. Nothing actually stands there.
  4. Rule 3: the 3DBAG roof (p70) is more than 2 m above the DSM. 3DBAG claims a volume the laser did not see.
  5. For strips, take the street part of a pand (opened by 0.75 m, at least 5 m²) and cut it off, keeping the main body. Overlap with the municipal Werfkelders layer confirms a flag.
street share> 0.5
DSM above street≤ 1.5 m
3DBAG roof over DSM> 2 m
minimum roof area4 m²
strip opening / min area0.75 m / 5 m²
never flag built ≥2020 (may postdate AHN)
confirmation overlap≥ 25 %
appliedreport; cuts only for a confirmed list

Open data: BGT, AHN DSM/DTM 0.5 m, 3DBAG, Gemeente Utrecht Werfkelders WFS.

A2 · Werfkelder filter
illustrativeSection across a canal wharf. Where the laser surface stays at street level but 3DBAG shows a roof, the part is flagged and cut.
A3

Tree positions and crowns from AHN

src/utrecht3d/trees_registry.py src/utrecht3d/terrain.py

The municipal tree register gives trunk positions and species, but no height or crown. AHN measures the canopy from above, but rows of street trees merge into one blob.

  1. Canopy height model: DSM − DTM at 0.5 m, building footprints removed, a 3×3 grey closing to fill the gaps of the leaf-off flight.
  2. Height of a registered tree: the maximum canopy height within 2.5 m of its trunk.
  3. Split the canopy between trees: each cell goes to the tree with the smallest distance ÷ prior crown radius (a power diagram, up to 12 m).
  4. Crown ellipse from the 2nd–98th percentile extent of each segment; the crown base from the 10th percentile of its surface height.
  5. Canopy peaks more than 3 m from any registered tree are added as private garden trees (local maxima in a 9-cell window, at least 4 m tall, green in the aerial photo).
rasterAHN 0.5 m
canopy cellCHM > 2.0 m
height search radius2.5 m
crown assignment reach12 m
crown semi-axes0.8–12 m
extra peak: min height / window4 m / 9 cells
extra peak: green testExG = 2G − R − B > 0.04

Open data: Gemeente Utrecht Bomenkaart (CC BY 4.0), AHN DSM/DTM (CC0), PDOK aerial photo.

A3 · Tree crowns
illustrativeA row of three trunks over one merged canopy. Each cell goes to the trunk with the lowest distance divided by crown radius.
Nieuwegracht seen from about 30 m above the canal, looking north-west to the Domtoren; rows of street trees of different sizes line both wharves.
resultNieuwegracht from about 30 m above the water, looking north-west to the Domtoren. Every crown along the canal is a registered tree from the Bomenkaart. Its height and crown ellipse come from the AHN canopy split described above, so neighbouring trees in one row get their own size instead of one merged blob. Render: utrecht3d viewer, 2 Dec 2026 (3DBAG, BGT, AHN, PDOK aerial photo, Gemeente Utrecht Bomenkaart CC BY 4.0).
A4

Street front from the AHN DSM

src/utrecht3d/facades_batch_west.py · front_box data/cache/…/facade_batch_west/work/bw.py · front_dsm

On the Oudegracht, the 3DBAG wall facing the street is sometimes a stub, set back, or sits between narrow fins. The real house front is found in the DSM, and a box carries the photo.

  1. Take the long axis of the footprint and point it at the street.
  2. Sample the DSM along that axis from 2 m outside the footprint inwards, every 0.25 m, on 9 parallel lines across 20–80 % of the lot width. Combine them with a median.
  3. The front is the first point where 16 samples in a row (4 m) stand more than 5 m above the street.
  4. The wall top is the 60th percentile of the DSM just behind the line.
  5. Drop 3DBAG shell triangles more than 0.15 m in front of the line and add a box: front quad for the photo, two sides and a roof.
profile step0.25 m
profile lines9 (20–80 % of width)
height threshold5.0 m above street
run length16 samples = 4 m
wall topDSM p60 − 0.4 m
box depthmin(max(1.5, shift + 1), 14) m
shell drop tolerance0.15 m

Open data: AHN DSM/DTM, 3DBAG, BAG.

A4 · Street front
illustrativeMedian DSM profile along the lot. A single spike (a lamp, a tree) does not trigger: the profile must stay above 5 m for 4 m.
A5

Dormers from DSM residuals

src/utrecht3d/dormers.py

3DBAG roofs show dormers as noisy facets. The DSM shows them as bumps above the roof slope. The bumps are found and replaced by clean dormer boxes.

  1. Group 3DBAG roof faces of 18–72° slope into main planes (normals within 4°, offsets within 0.25 m, at least 10 m² per plane).
  2. For every DSM cell on a plane, compute the residual: DSM height minus plane height.
  3. Threshold the residual at 0.55 m and again at 0.38 m, open with a 2×2 element, and label connected blobs.
  4. Keep blobs of 1–12 m wide, filled ≥ 0.55, with the slope continuing behind and beside them, not green in the aerial photo.
  5. Fit the blob top to classify the dormer roof as pitched, shed or flat, then cut the 3DBAG facets out and insert a box of about 20–30 triangles.
DSM cell0.5 m
slope range18–72°
residual thresholds0.55 m, 0.38 m
min blob6 cells = 1.5 m²
width1.0–12 m
fill ratio≥ 0.55
front-row median residual≥ 0.45 m
roughness (std)≤ 0.6 m
dormer height0.9–3.3 m
skip mostly flat roofs> 50 % flat and > 250 m²

Open data: 3DBAG LoD2.2, AHN DSM, PDOK aerial photo (8 cm).

A5 · Dormers
illustrativeResidual map over one roof plane. The threshold drops from 0.55 m to 0.38 m; small or speckled blobs fail the shape tests.
Oblique view of a roof in tile 4_4: before, a plain brick box on the roof; after, a dormer with white cornice, two windows and a lead roof.
resultTile 4_4, pand 053573, oblique view, before / after. Before, the dormer is a plain brick box on the slope; after, the same box carries a dormer front with two windows, a white cornice and a lead-grey top. Render: utrecht3d viewer (3DBAG, PDOK aerial photo).
A6

The Domtoren model and detail bake

src/utrecht3d/domtoren_model.py tools/blender_film/domtoren_layout.py tools/blender_film/domtoren_export.py

The Dom tower is too complex for 3DBAG and too tall for street photos. It is modelled from 19th-century measured drawings, then baked to a light web model whose colour carries all the depth.

  1. Read the outline of each stage from measured elevations (G. de Hoog 1899, 1:50; J. van Maurik, 1830s) into layers: stone, brick, niche, tracery, open.
  2. Build the tower procedurally in Blender, stage by stage, rotated 18.3° off the RD grid.
  3. Cull hidden faces: keep a triangle only if a ray from one of its sample points escapes (Fibonacci-sphere directions over the outer hemisphere).
  4. Bake albedo × ambient occlusion in Cycles. The tiles have no normal maps, so depth goes into the colour.
  5. Add a detail layer in numpy from baked position and normal: recess darkening, rain streaks below ledges, soot under overhangs, ashlar block jitter.
stage 10–38.6 m, 19.3 m wide
stage 2to 68.08 m, 16.34 m wide
lantern69.0–95.0 m
spire / crown106.75 m / 112.32 m above the base
groundNAP +5.5 m
cull rays80 directions, ~40 per hemisphere
bakeCycles, 48 samples, AO 0.62, 1.6 m
streaks1–6 m, 5 cm grid
atlases3072² ×2, 2048², 1024² ×3

Open data: Het Utrechts Archief measured drawings (public domain, via Wikimedia Commons), a CC0 Commons photo, Poly Haven texture (CC0).

A6 · Domtoren
Stage heights to scale. Rays from a sample point test whether a face is visible; recessed faces get darker in the bake.
B

Photos → façades

Openly licensed street photos are found, posed, cleaned and projected onto the wall planes. Where no photo exists, a rule-based style fills in.

B1

The open photo index and its links

src/utrecht3d/photo_index.py src/utrecht3d/commons.py src/utrecht3d/hua.py tools/title_address_worklist.py

Open photos come from five sources with very different metadata: some have a camera position and heading, some an object position, some only a title like “Oudegracht 113”. The index links every photo to the BAG panden it shows, with a score.

  1. Harvest metadata from Commons, Het Utrechts Archief, RCE, Panoramax and own photos. Flickr-origin files are flagged and never returned.
  2. Photos with a camera position: sample points on nearby footprint edges and keep those that face the camera, fall inside the field of view and have a clear 2D sight line.
  3. Score each sample by distance, incidence and centrality; a pand gets its best sample times a visibility factor.
  4. Photos with an object position link to the footprint that contains it or lies within 8 m. Rijksmonument templates link to the monument’s panden.
  5. Titles and categories are parsed for addresses (ranges, lists, old wijk letters). Every number must exist in BAG, and a camera more than 60 m from the named pand vetoes the link.
cone sample score1/(1+(d/20 m)²) · cos θ · (0.35 + 0.65·c)
pand scorebest · (0.5 + 0.5·visible share)
cone rangePanoramax 35 m · Commons 70 m · own 60 m
default field of view60°
object link0.55 inside · 0.40 within 8 m
title address link0.9 (range 0.75)
title veto distance60 m
“good” link≥ 0.35

Open data: Wikimedia Commons, Het Utrechts Archief, RCE beeldbank, Panoramax, PDOK BAG and Locatieserver, 3DBAG footprints.

B1 · Photo index
illustrativeA photo’s viewing cone over footprints. Samples hidden behind another building score nothing; the nearest frontal pand wins.
B2

Camera solver

src/utrecht3d/camsolve.py src/utrecht3d/facade_chain.py src/utrecht3d/facadekit.py tools/camsolve_bench.py

A Commons photo comes without a usable pose: GPS is off by metres and the focal length is often unknown. Before it can texture a wall, the solver must recover position, rotation and focal length against the 3D model.

  1. Collect priors from EXIF, the photo index and hints. Find line segments, the vertical vanishing point and up to three horizontal ones; orthogonal pairs give a focal estimate (f² = −pa·pb).
  2. Render matching: render up to 8 probe views of the textured model, match features (ALIKED + LightGlue), lift the render pixels to 3D with the render depth.
  3. Solve with RANSAC + SQPnP over a grid of focal lengths, then polish with the vanishing-point pitch and roll. Re-render from the result and accept if the matches barely move.
  4. Fallback: score a fan of candidate viewpoints by how well model edges land on image edges, then refine the best six with a robust (Cauchy) least-squares fit.
  5. With --points, 4–8 clicked corners go straight into SQPnP and a lens-model choice; it takes 1–7 s (see B2b).
PnPSQPnP, 2000 RANSAC iterations
inlier thresholdmax(4 px, 0.006 L)
focal grid17 steps, 0.55–2.6 L
accept (render path)≥ 60 inliers, ≥ 25 % inlier share
verify≥ 60 % of matches within 3 % of L
edge fan16 distances 4–70 m × −70…70° in 7.5°
benchmark, --points14/14 within 2.5 %, 9/14 within 1 %
Llong side of the photo in px

Open data: 3DBAG LoD2.2, AHN DTM, Commons EXIF.

B2 · Camera solver
illustrativeModel corners reprojected from a wrong first guess. Each iteration moves the pose; the RMS error falls until it is under 1 % of the photo’s long side.
B2b

Clicked points (manual camera solve)

src/utrecht3d/camsolve.py src/utrecht3d/facadekit.py src/utrecht3d/facade_chain.py tools/camsolve_bench.py data/cache/collections/camsolve/benchmark.md

When the automatic solver has nothing to hold on to, a person clicks 4–8 building corners in the photo and names the 3D corner each one belongs to. uv run utrecht3d camsolve <photo> --pand <id> --points pts.json turns those pairs into a camera in 1–7 s on the CPU. In the benchmark it lands within 2.5 % of the hand-made camera on all 14 photos, and within 1 % on 9.

  1. Run camsolve once without --points. Besides its A/B/C guesses it writes _corners.jpg, a plan of the footprints with every wall corner numbered (the target pand green).
  2. Click 4–8 corners in the photo and write them to pts.json as [u, v, id]: 12g is the ground point of corner 12, 12t its top, and plain 12 means “somewhere on the vertical edge at corner 12”.
  3. Each id looks up a 3D point in the raw 3DBAG LoD2.2 walls around the pand. These points, the pixel coordinates and a focal length go into OpenCV’s SQPnP, once for each focal-length start.
  4. Every SQPnP start is refined by robust least squares in up to three lens models. The simplest model wins unless a richer one clearly fits better.
  5. If the click error is under 0.6 % of the long side, the camera is accepted. The same JSON and overlays as the automatic solver are written, and best.cam goes on to the projection step.

When to use it

  • Procedural façades. Render matching (B2) matches the photo against renders of the textured model. Where the model only has procedural textures, as in most of Leidsche Rijn, it finds nothing to match, and the edge fallback is unreliable there. Go straight to --points. On seven own phone photos of Het Zand, the automatic run accepted none.
  • A failed render match: the solve is not accepted, or _render.jpg (the photo next to the model rendered from the result) does not line up.
  • A confirm panel that doesn’t fit: none of the A/B/C overlays puts its red and yellow lines on the photo’s party walls and cornices.

What a pts.json looks like

Pixels are measured on the upright photo (after any EXIF rotation). A list or {"points": [...]} both work. The // notes are for this page only; real JSON has no comments.

[[ 412,  233, "1t"],   // top of corner 1 (eave)
 [ 409,  871, "1g"],   // ground point of corner 1
 [1530,  262, "2t"],
 [1534,  905, "2g"],
 [1902,  598, "3"],    // somewhere on the vertical edge at corner 3
 [ 760,  604, 136274.84, 455620.93],         // on a vertical edge at RD x, y
 [ 755,  905, 136274.84, 455620.93, 2.6]]    // a full RD x, y, NAP z

An id like 12t fixes all three coordinates. A plain 12 or an [u, v, x, y] fixes only x and y: the solver adds that point’s height as an extra unknown. So it gives one equation net, where a full corner gives two. A wall corner seen against the sky is fine to click even if the ground is hidden behind cars.

Where the 3D corners come from

corner_table reads the raw 3DBAG LoD2.2 wall polygons (facade_chain.Ctx: no module replacements, not our built tiles). It covers the target pand and every neighbour whose centroid lies within 22 m. Wall vertices are merged per footprint corner on a 15 cm grid. Each corner column taller than 1 m gets a number, with g = lowest and t = highest wall vertex. The target pand is numbered first, then the neighbours by distance. The numbers don’t depend on which façade is chosen, so a pts.json stays valid between runs. For corners that 3DBAG lacks, give explicit RD/NAP coordinates (for example a BAG footprint corner at street level).

Why at least 4, and why 6–8 is better

  • Counting. The camera has 7 unknowns: position x, y, z, yaw, pitch, roll and focal length. Each full corner gives 2 equations, so 4 corners (8 equations) is the minimum, and _pnp_init refuses fewer than 4 points.
  • Degenerate layouts. If every click lies on one straight line, the camera can turn about that line without moving any point. If they all lie on one flat wall seen almost head-on, stepping back and zooming in give nearly the same picture, so distance and focal length trade off. Spread the clicks over two walls of a corner, or over ground and eave, and both problems go away.
  • Robustness. With 8 equations for 7 unknowns, one misplaced click just bends the camera. With 6–8 clicks (12–16 equations), the soft-L1 loss (scale 10 px) can down-weight it.
  • Lens and focal length. Richer lens models are only considered when there are at least 2 equations per unknown parameter: 9 clicks for the shift-lens model, 11 for the free principal point. Without an EXIF focal length, the focal length is also a free unknown and needs the depth spread that only non-coplanar clicks give.

Lens models and the choice

  • centred: principal point at the image centre; 7 parameters.
  • shift: a level camera (pitch = roll = 0) with a free principal point. This is how architecture photographers kept verticals straight, as in the 1979 RCE scans. A weak term keeps the horizontal shift near the centre.
  • free_pp: free principal point and free tilt, for crops of larger photos.

The models are tried in that order. A richer model replaces the current one only if (1) there are ≥ 2·(7 + extra parameters) equations, (2) the current error is above 1.5 px, and (3) the richer one cuts the error by more than 40 % (to below 0.6×). Lens distortion k1 is fitted only with --fit-k1. On RCE 39db9cad, a 1979 shift-lens scan with 11 clicks, the errors are centred 3.56 px, shift 1.72 px and free_pp 1.29 px. Shift wins: it more than halves the centred error, while free_pp does not beat shift by 40 %.

SQPnP, refinement and acceptance

Starts. With an EXIF focal length (35 mm equivalent or focal length plus a sensor guess), SQPnP runs once with that focal length, and a weak prior lets it drift: a 15 % change costs as much as a 3 px error. Without one, SQPnP runs at 0.6, 0.9, 1.3 and 2.0 × the long side. For SQPnP, vertical-edge points are placed at the median height of the full corners. OpenCV’s SQPnP is a globally optimal PnP solver for a fixed, known focal length, so every focal start gives one candidate pose.

Refinement. From each start, scipy.optimize.least_squares (soft-L1, at most 400 evaluations) fits the pose, the focal length, the free heights of vertical-edge points and the lens model’s extra parameters. A soft prior keeps the camera near eye height, 1.6 m above the AHN ground (3 px per metre). Solutions with a point behind the camera are dropped, a model stops trying more starts once it is under 0.15 % of the long side, and the whole fit stops after 6 s.

Edge polish. This runs only for thin point sets (fewer than 18 equations, counting a vertical-edge point as one) when time is left. The camera is nudged onto the photo’s line segments with the clicks as anchors. The polish is kept only if the click error stays below max(1.5×, 0.3 % of the long side) and more model edges land on image lines. --polish forces it.

Acceptance. The camera is accepted when the click error (rms per image axis) is under 0.6 % of the long side; otherwise its status is confirm. Unlike render matching, the points path makes no automatic re-render check. Check _overlay.jpg by eye, and later the projected façade.

Benchmark (pts2, 2026-11-29)

The error is measured against hand-made cameras: a 6 × 6 grid on the target façade is projected with both cameras, and the rms gap is given in % of the long side. For 10 photos the clicks were synthetic: the first 6 numbered corners projected with the hand camera, plus 2 px Gaussian noise. The 4 Moreelsepark photos (highlighted) use an agent’s real 6–11 clicks.

caseclickserror %Δpos mΔyaw °f ratios
og19961.040.23−0.071.0023.7
og222a60.860.100.330.9971.2
og22661.450.570.440.9451.3
og226b60.080.050.000.9981.3
hs362.280.49−1.381.0251.5
hs160.210.01−0.070.9961.3
rce8660.501.22−0.290.9811.7
zadelstraat60.910.440.330.9874.2
het_zand61.730.75−0.461.0102.7
groenedijk60.472.29−0.650.9243.2
HUA 82422380.151.420.030.9735.6
Panoramax 51434ad570.740.660.020.9741.6
RCE 39db9cad110.180.350.490.9893.3
RCE f8f857a761.703.38−1.190.9192.1

Result: 14/14 within 2.5 % (worst 2.28 %), 9/14 within 1 %, all accepted, median 2 s. On the correct ones the median camera offset is 0.44 m and 0.29°. For comparison, the automatic solver (render matching first, v6) got 8/14 within 1 % in a median of 66 s. A camera 1–3 m off can still put the façade within 0.5 % (groenedijk: 2.3 m, f ratio 0.92), because stepping along the viewing direction and changing the focal length nearly cancel out. The f8f857a7 scan is the weakest: its 6 clicks barely fix a camera even by hand.

Level the photo first

Since 2 Dec 2026 every photo is levelled before its camera is solved. A phone photo held a few degrees off gives a tilted texture: on Vogelvlinderweg 13/15 the brick courses and window heads ran 3–4° off level. The roll is measured from the vertical vanishing point of the photo’s own vertical edges (corners, downpipes, jambs; vertical_vp_roll), and the photo is rotated into a new _level file (the original is never overwritten). The clicks and the camera solve then run on that file. After projection, tilt_check rectifies the crop at 1 cm, finds line segments (OpenCV LSD) and measures the median deviation of near-vertical and near-horizontal segments; it warns above 1°, and a front is accepted only within 0.5°. Where four hand picks leave a small tilt, level_fit refits the homography to the picks and the photo’s own lines (verticals map to ds = 0, horizontals to dz = 0, soft-L1). Vogelvlinderweg 151118: roll −3.80°, rectified verticals / horizontals −1.76° / −3.29° before, 0.00° / 0.00° after (src/utrecht3d/rectify_check.py).

input4–8+ clicks: [u, v, id] · [u, v, x, y] · [u, v, x, y, z]
3D cornersraw 3DBAG LoD2.2 walls, target + neighbours ≤ 22 m
PnPcv2 SQPnP, one start per focal (no RANSAC)
focal startsEXIF f, or 0.6 · 0.9 · 1.3 · 2.0 L
refineleast squares, soft-L1, f_scale 10 px, ≤ 400 evaluations
priorseye height ground + 1.6 m (3 px/m) · EXIF f ±15 % ≈ 3 px
lens modelscentred → shift → free_pp
richer model if≥ 2·(7+k) eq., current > 1.5 px, new < 0.6 × current
early stop / time cap< 0.15 % L / 6 s
edge polish (auto)< 18 equations and time left
acceptedclick rms < 0.6 % of L
benchmark14/14 ≤ 2.5 %, 9/14 ≤ 1 %, median 2 s
Llong side of the photo in px

Open data: 3DBAG LoD2.2 walls (corner table), AHN DTM (eye height), BAG footprints (explicit corners), photo EXIF. Benchmark photos: Wikimedia Commons, Het Utrechts Archief, RCE beeldbank, Panoramax, own photos.

B2b · Clicked points
illustrativeSix clicks, each tied to a numbered 3DBAG corner (inset). SQPnP at a wrong focal start puts the wireframe off; least squares snaps it onto the clicks; then the three lens models are compared and the simplest that fits is kept. The numbers in this drawing are made up; real ones are below.
Photo of Moreelsepark 1 with eight numbered clicks on four vertical building edges and the 3DBAG LoD2.2 edges drawn from the solved camera, lining up with the façade.
Real example: HUA 824223, Moreelsepark 1 (BAG 0344100000010397), benchmark case mp_hua824223. 8 clicks on 4 vertical building edges, each with a ground point at 2.6 m NAP and a higher point with free height ([u, v, x, y]). Yellow: the pand’s 3DBAG LoD2.2 edges (back faces culled) seen from the solved camera. Click error 1.28 px rms per point (0.85 px per axis, 0.05 % of 2560 px). Lens models: centred 0.85 · shift 6.97 · free_pp 0.66 px. Centred is kept because 0.85 px is already under the 1.5 px threshold, and 8 clicks are too few for a richer model anyway. Against the hand camera: 0.15 % of the long side. Fit 1.1–1.3 s, whole run 5.6 s in the benchmark, on the CPU. A rerun on 2026-12-01 gave the same camera. Photo: Het Utrechts Archief, cat. 824223 (Het Utrechts Archief, fotograaf, 2014), CC BY 4.0; overlay and annotations by utrecht3d.
Vogelvlinderweg 13 and 15: own photo, the procedural model before, and the photo-textured model after, with white eaves, canopy and dormers.
resultVogelvlinderweg 13/15, Leidsche Rijn (tile −17_5): photo | before | after. A procedurally textured street, so the render matcher had nothing to hold on to; the camera came from clicked corners on the levelled photo. Before and after from the same viewer camera. Photo: own photo 2026-12-01 (151118), CC0 1.0.
The same photo as taken and after levelling, and the rectified front with a 0.5 m grid whose lines run along the brick courses and window edges.
resultLevelling, Vogelvlinderweg 151118. Left: as taken and levelled (roll −3.80°). Right: the rectified front of 13/15 with a 0.5 m grid; window heads, sills and the canopy now run along the grid lines. Photo: own, CC0 1.0.
Bibliotheek Neude front: RCE photo, the earlier smeared and ghosted model, and the clean new model.
resultBibliotheek Neude (Neude 11, tile 2_4): photo | before (v2) | after (v3). v2 mixed several photos and came out dark and ghosted. v3 uses one levelled photo only (camera rms 5.2 px on the levelled frame), rectified per plane (tilt ≤ 0.18°), with trees, bikes and lamp posts replaced by matching bays. Photo: RCE beeldbank e1904b95, Thea van den Heuvel / Rijksdienst voor het Cultureel Erfgoed, CC BY-SA 3.0; levelled and cropped by utrecht3d.
Arthur van Schendelstraat 600 office entrance: own photo, the procedural brick model before, and the granite photo façade after.
resultArthur van Schendelstraat 600 (BAG 035083, tile 2_−1): photo | before | after. Camera solved from clicked corners, vertical edges and parapet / storey lines; trees, poles and people inpainted. Photo: own photo 2026-12-01 (125743), people blurred, CC0 1.0.
Abstederdijk 124: Commons photo, a plain procedural front before, and the photo front after.
resultAbstederdijk 124 (BAG 0344100000014292, tile 6_1), Maliebaan / Abstederdijk batch: photo | before | after. Camera from the clicked front corners (camsolve.fit_points), front plane rendered from that camera. Photo: AcroniusZ, Wikimedia Commons, CC BY-SA 4.0.
B3

Projecting photos onto walls, with occlusion

src/utrecht3d/streetview.py src/utrecht3d/facadekit.py src/utrecht3d/facades_f04.py src/utrecht3d/facades_f20.py

A posed photo must only paint the parts of a wall it really sees: not the tree in front, not the side of the neighbour. Each texel is projected into the camera and checked against a depth buffer.

  1. Lay a regular texel grid on each wall plane and project every texel through the camera (per-texel projection, not a 2D homography).
  2. Render a z-buffer of all buildings from the camera. A texel counts only if its distance is within a tolerance of the buffer depth and the wall faces the camera.
  3. Weight each visible texel by resolution and frontality: cos · f / z for single photos.
  4. Hand and auto façades: the best weight wins per texel. Panoramax tile walls: an MRF picks one view per texel with a seam cost where views disagree, then a 5-level Laplacian pyramid blends the seams.
  5. Unseen holes are filled smoothly; large ones get procedural detail in the photo’s colours.
depth test (facadekit)z ≤ z_buf · 1.01 + 0.25 m
facing testcos > 0.2
Panoramax max distance50 m
max incidence72°
Panoramax texel0.1 m (default)
auto front texel1.5 cm, rest 5 cm
MRF14 mean-field iterations, 5 blend levels

Open data: Panoramax (CC BY-SA 4.0), Wikimedia Commons, Het Utrechts Archief, 3DBAG as occluders.

B3 · Projection
illustrativePlan view. Rays to wall texels that hit something nearer in the z-buffer are rejected and left for another view or the fill.
B4

Masking and LaMa inpainting

src/utrecht3d/segment.py tools/auto_facades.py src/utrecht3d/facade_register.py

Street photos contain people, cars, bikes, poles and trees. Those must not end up baked into a façade. Small objects are inpainted; large ones are cut and filled procedurally.

  1. Segment the photo per pixel (SegFormer-B5 Cityscapes for the auto path; Mask2Former for Panoramax).
  2. Map labels to obstruction classes: person, vehicle, two-wheeler, pole, sign, vegetation, fence.
  3. Dilate the mask with a square kernel about 0.8 % of the long side.
  4. Split into connected components. Small ones go to LaMa; large ones are cut out and left to the procedural fill.
  5. Run big-LaMa at the photo’s own resolution (padded to a multiple of 8). Only hole pixels are replaced.
dilation kernelmax(3, 0.008·L), odd · ≈ 11 px at 1280
“small” component< 1.5 % of image and < 0.4·H tall
LaMa modelbig-lama TorchScript, CPU
auto photo size≤ 1280 px
hand polygonsOpenCV Telea, radius 6

Open data: The photos themselves (Commons, HUA, Panoramax). LaMa weights: Apache-2.0.

B4 · Masks + LaMa
illustrativeA cyclist in front of a brick front: segmented, dilated, then filled from the surrounding texture.
B5

Row matching

src/utrecht3d/facades_f20.py tools/auto_facades.py · _style data/cache/…/facade_batch_east/work/rows.py data/cache/…/facade_batch_west/work/snaprow.py

Neighbouring houses in one row are textured from different photos with different exposure. Without a correction the row shows colour jumps at every party wall.

  1. Measure each front’s wall colour: the median of mid-luminance façade pixels (25th–75th percentile).
  2. For a hand-listed row, take the per-channel median of those colours as the reference.
  3. Give every photo a gain = reference ÷ own colour, clamped to 0.8–1.25 per channel. Procedural neighbours take the reference colour.
  4. Snap front-box corners that lie within 1.6 m of each other to their mean, so the walls meet.
  5. Bands (string courses, plinths) are set by hand in metres above the street. There is no automatic band detection.
wall colourmedian of 25–75 % luminance pixels
gain clamp0.8–1.25 per channel
applyclip(c · gain, 0, 1)
corner snap≤ 1.6 m
rowshand-listed (e.g. Kromme Nieuwegracht 6/10/12)

Open data: The façade photos.

B5 · Row matching
illustrativeThree fronts from three photos. The row reference is the channel median; each gain is clamped, so a dark photo is lifted but not fully.
B6

Auto façade styles by era and type

src/utrecht3d/auto_styles.py src/utrecht3d/facade_styles.py src/utrecht3d/roof_classes.py src/utrecht3d/photo_colours.py

Most buildings have no usable photo. They still need a believable front: the right era, building type, storey height, window rhythm and colour, without loud colours next to monuments.

  1. Era from the BAG construction year; type from the BAG use share and 3DBAG size, height and flat-roof share.
  2. Material and colour from the material estimate; a linked photo colour (link score ≥ 0.45) replaces a guess.
  3. Without either, draw one colour from the era palette per row of touching panden with the same year.
  4. Map era, type and material to a style family with its own bay width and storey heights.
  5. Mute in historic context: where ≥ 30 % of buildings within 150 m are pre-1900, limit chroma and hue in CIELAB.
eras<1900 · <1945 · <1965 · <1985 · <2000 · <2015 · later
industry≥ 300 m², ≤ 12 m, flat ≥ 0.6
outbuilding< 40 m² or < 3.2 m
historic zone≥ 30 % pre-1900 within 150 m
muted brickhue 35–75°, C ≤ 18, L 28–62
muted plasterC ≤ 7
switchUTRECHT3D_AUTO_STYLES=0

Open data: BAG (construction year, use), 3DBAG, Utrecht aerial photo, linked open photos.

B6 · Auto styles
illustrativeA street of mixed eras. Each pand gets a family from its year; inside the historic zone the colour is clamped into a muted Lab range.
Two identical street views in tile 4_5: before, generic post-war fronts; after, the era style with horizontal strip windows, white bands and dark shop fronts.
resultTile 4_5, post-war gables, same camera before / after. The era/type layer swaps the generic façade for the post-war style: wide strip windows, light horizontal bands at each floor and dark glazed shop fronts. Neighbours of other eras keep their own style. Render: utrecht3d viewer (3DBAG, BAG building year, BGT).
B7

The unattended auto-façade gate

tools/auto_facades.py src/utrecht3d/facades_auto.py src/utrecht3d/camsolve.py

Most photos are processed with nobody watching. A wrong façade is worse than none, so a candidate must pass every check, and any check that cannot be computed counts as a fail.

  1. Candidates: open licence, 2005 or later, long side ≥ 1200 px, no panoramas, and a strong link (title ≥ 0.8, or a cone link ≥ 0.3 within 45 m and 55°).
  2. Content check on the segmentation: enough building, little sky, vegetation and people.
  3. Camera solve must be accepted on the render-matching path; the pose then passes geometry checks (eye height, roll, pitch, not inside a building).
  4. Re-render from the solved camera: the façade must line up within 0.8 % of the long side, and an image-shift test must peak at zero shift.
  5. Two photos of one pand must agree after rectification (gradient ZNCC ≥ 0.35). Bake from one photo; drop the site if too little wall ends up photo-textured.
PnP inliers≥ 70, share ≥ 0.30
verify: matches that stay≥ 65 %
eye height0.6–3.5 m above DTM
roll / pitch|roll| ≤ 8°, −15…40°
facingcos ≥ 0.26, 3–70 m
own re-render≥ 20 matches, median ≤ 0.008 L
consistencygradient ZNCC ≥ 0.35
contentbuilding ≥ 0.25, sky 0.01–0.55, veg ≤ 0.35

Open data: Wikimedia Commons, Het Utrechts Archief, RCE, own photos; 3DBAG, AHN.

B7 · Auto gate
illustrativeCandidates run through the checks in order. One fail, or one value that cannot be computed, rejects the photo.
B8

Window geometry: recessed glass panes

src/utrecht3d/window_geom.py src/utrecht3d/tile.py web/js/night.js tools/blender_film/build_shot.py

Painted windows look flat: they cannot reflect the sky, show no depth at a grazing angle and light up at night only where a shader guesses which texels are glass. Real openings with glass, kept cheap enough for 125 m streaming parts.

  1. Procedural façades: the layout atlas of each style is redrawn with every glass area in a sentinel green (same random stream, so the same drawing). The green components are the lights; lights closer than 16 cm are one window.
  2. Per wall the storey/bay plan places those windows; a window must lie 4 cm inside the wall polygon. The wall piece of each band is united, the openings are cut out and the rest is re-triangulated (constrained Delaunay: no new vertices on band edges, so no cracks).
  3. Each opening gets 4 reveal faces (wall texels) back to a glass quad 12 cm behind the wall plane; the glazing bars move back with it, 1.5 cm in front of the glass, keeping their own texels. Frames and sills stay in the texture on the wall plane.
  4. Photo façades: each vertical plane of a façade module is resampled into a rectified 4 cm crop. A window must be dark on all four sides, nearly rectangular, of plausible size, clear of the ground and repeated in its storey row or column; anything else stays texture.
  5. All panes of a tile are one mesh on one material window_glass: opaque, roughness about 0.05, a little metalness, reflecting the sky light probe (environment × 3.2 in the viewer), a dark interior tint per window in the vertex colour. Its UV carries (lit, hash): a fixed ~30 % of the windows glow at night in the viewer and in Blender.
  6. Level 0 only: the plain walls stay as walls_k__far for lod1/lod2 (unchanged bytes), the holed walls are walls_k__near. The stability test checks that the far walls and every other mesh are identical.
pane recess12 cm (photo lights 8 cm)
bars1.5 cm in front of the glass
per opening2 glass + 8 reveal triangles
lights → windowgap ≤ 16 cm
photo: darkL < min(0.62·median, median − 0.10)
photo: shapefill ≥ 0.85, glass ≥ 55 %, contrast ≥ 0.08 each side
lit share30 % per window (md5 hash)
switchUTRECHT3D_WINDOW_GEOM / rollout list

Open data: The procedural façade styles; photo façade atlases from Commons, Het Utrechts Archief, RCE and Panoramax photos; 3DBAG wall planes.

B8 · Window geometry
illustrativePainted windows become holes with reveals and a recessed pane. The panes mirror the sky as it moves; at night a fixed third of them light up.
Before and after pairs of tile 4_4: a close street view of a brick block whose painted windows become recessed panes with glazing bars, and Blender renders of the same block by day and at night.
Pilot: tile 4_4 (old centre east: Kromme Nieuwegracht, Pieterskerkhof, Nobelstraat), 2 Dec 2026. Top: viewer, same camera, before / after. Bottom: Blender test still (EEVEE, photo pass) by day and at night, before / after. 4,229 procedural panes on 1,138 walls plus 239 panes detected in 25 of the 48 photo-façade module items (65 of 463 wall planes; 925 candidates rejected). Level 0: 92,850 → 207,122 triangles (holed walls 23,258 → 122,921, glass 8,936), 74.9 → 76.8 MB; largest 125 m part 23.6 → 23.8 MB (budget 36 MB). lod1 / lod2 unchanged (28.87 / 28.88 MB). Stability test: every other pand and mesh unchanged. Frame time (RTX 3060, 1400×900, high quality, median of 8 s): 36.5–44.8 ms without, 30.1–33.3 ms with window geometry, i.e. no measurable cost; the spread comes from other jobs on the shared GPU. A Leidsche Rijn tile (−11_4, Vinex) in a test build: 4,624 panes, 87k → 164k triangles, 19.8 → 21.1 MB.
C

Tiles & viewer

Built tiles are frozen against drift, compressed, split into 125 m streaming parts and drawn in the browser with physically based lighting.

C1

Material stability

src/utrecht3d/materials.py tools/test_material_stability.py

Materials are estimated from photos across the whole area. Rebuilding one tile with a new photo must not quietly change the brick colour of buildings nobody touched.

  1. The previous materials.json is the baseline. A photo-measured pand keeps its material unless a new estimate is clearly more confident.
  2. Inferred, propagated and prior entries are carried over unchanged; panden that left the build keep their entry.
  3. A new pand without a photo picks a donor among photo panden within 250 m, weighted by distance, year difference and monument status.
  4. The donor is chosen with a rendezvous hash, so the same inputs always give the same donor, and adding a far donor does not reshuffle near ones.
  5. Tests inject drift (remove donors, re-measure a tile) and demand that untouched panden stay exactly equal; built tiles are compared per pand, and lod0 textures by PSNR.
photo switch marginnew conf > old + 0.25
donor radius250 m
donor weighte^(−d/60) · e^(−Δyear/25) · (1 or 0.4) · (conf + 0.05)
donor drawargmin −ln(md5(pand, donor)) / w
glb test tolerance|Δ tint| ≤ 0.04
lod0 re-encode acceptedPSNR ≥ 40 dB, max error ≤ 48

Open data: Photo façade atlases, OSM building:material tags, RCE monument register, BAG year.

C1 · Material stability
illustrativePanden coloured by their donor photo pand. When one donor is removed, only the panden that used it draw again; every other pand keeps its colour.
C2

KTX2 encoding and the compressed-domain crop

src/utrecht3d/optimize.py src/utrecht3d/lod.py src/utrecht3d/quadtiles.py

JPEG textures sit uncompressed in GPU memory: a 4096² aerial takes about 89 MB. KTX2 (UASTC or ETC1S) stays block-compressed on the GPU. The 125 m streaming parts then need pieces of those textures without a slow and lossy re-encode.

  1. Resize to a multiple of 4 px and encode with ktx create, mipmaps included. Results are cached by a hash of pixels, arguments and encoder version.
  2. lod0 uses UASTC, lod1 UASTC with stronger rate–distortion, lod2 ETC1S.
  3. For each 125 m part, find the UV rectangle its triangles use. Crop it, shelf-pack the UV islands when that saves enough, or keep the whole texture.
  4. Crop in the compressed domain: unpack each mip level from zstd, view it as a grid of 16-byte 4×4 UASTC blocks, slice the blocks, recompress.
  5. Align rectangles so every kept mip stays on the block grid. Texels are bit-identical to lod0. ETC1S cannot be cut this way and is copied whole.
UASTCquality 2, RDO λ 1.0, zstd 12
ETC1Sclevel 2, qlevel 255
GPU cost1 B/texel × 4/3 for mips
kept mip levels5
alignment64 texels (f), 128 (h)
keep whole if crop >80 % of image
pack if≤ 0.75 × crop area
UV margin6 texels

Open data: PDOK aerial photo (8 cm), façade atlases built from the open photos.

C2 · KTX2 + crop
illustrativeA UASTC atlas as a grid of 4×4 blocks. The used UV area is snapped outward to the alignment grid and its blocks are copied unchanged, level by level.
C3

The tile budget per 125 m part

src/utrecht3d/lod.py src/utrecht3d/quadtiles.py tools/tile_budget.py

The viewer streams 125 m quadrants, never a whole lod0 tile, and textures are 96–97 % of a tile’s bytes. So the size limit is set per quadrant, and only the quadrant that is too big should lose quality.

  1. After a build, estimate each quadrant’s bytes: a texture counts with the share of its UV box inside the quadrant, geometry by triangle share.
  2. If a quadrant exceeds 36 MB or the tile exceeds 100 MB, list atlases that may be demoted (never the aerial or photo façades).
  3. Order them: rest, roof, tunnel and interior atlases first, then by size. Skip atlases that do not touch an over-budget quadrant.
  4. Re-encode picked atlases as ETC1S until the budget holds; the log reports each demotion.
  5. Unused atlas texels are flattened to 64 px cells of their mean colour first, which saves 5–15 % per atlas.
per quadrant (f part)36 MB
whole lod0100 MB
serve lod0 whole only if≤ 72 MB
demotion profileETC1S, clevel 4
saving estimate0.8 × texture bytes
fill margin / cell16 px / 64 px
estimate accuracy≈ ±5 MB

Open data: None directly; it acts on built tiles.

C3 · Tile budget
illustrativeA 250 m tile split into four 125 m parts. One part crosses 36 MB; its roof atlas is demoted to ETC1S until it fits. Sizes are illustrative.
C4

Viewer lighting

web/js/lighting.js web/js/viewer.js

A city model lit by a flat ambient light looks like a plastic toy. The viewer lights it with a sky, darkens corners, compresses the bright range like a camera and adds haze with distance.

  1. Sky model from sun elevation: air mass (Kasten–Young) reddens and dims the sun; zenith and horizon colours shift for a low sun.
  2. Render the sky dome into a PMREM environment map for image-based lighting; re-bake only when the sky changes.
  3. GTAO at half resolution, with normals rebuilt from depth, fading out between 250 m and 1200 m.
  4. Aerial fog in linear light before tone mapping: factor 1 − e^−(ρd)², coloured with the sky in the view direction plus a sun glow.
  5. Tone map with Neutral (default), AgX or ACES, each with its own base exposure.
sun (default)elevation 38°, azimuth 215°
fog density ρ0.0003 /m (≈ 9 % at 1 km, 55 % at 3 km)
GTAOradius 4, 8 samples, intensity 0.85
AO fade250 → 1200 m
exposureNeutral 1.15 · AgX 0.93 · ACES 0.88
hemisphere fill0.55
bloomstrength 0.16, threshold 1.6

Open data: None; the sky is analytic.

C4 · Lighting
Left: scene radiance from shadow to sky (0–16, log scale) through the three tone curves. Right: the fog factor over distance with ρ = 0.0003.
C5

Tree impostors

web/js/tree_impostors.js tools/tree_impostors/atlas.py tools/tree_impostors/tree_gen.py web/js/tree_species.js

Utrecht has tens of thousands of street trees. Full meshes are far too heavy, flat billboards look wrong from above. Each far tree is one quad that shows a pre-rendered view from the nearest viewing direction.

  1. Bake each tree in Cycles from 8 × 8 directions laid out on a hemi-octahedral grid over the upper hemisphere; the border row is the horizon.
  2. Store albedo with alpha and a normal per view, as KTX2 array textures, one layer per tree.
  3. In the vertex shader, turn the view direction into grid coordinates and take the 4 nearest views (one 2×2 cell).
  4. Blend them with sharpened bilinear weights, alpha-test at 0.5 and light with the baked normal.
  5. Close to the camera, cross-fade to a low-poly mesh with a screen-door dither, the two using complementary thresholds.
views8 × 8 hemi-octahedral
view size160 px (atlas 1280 px)
normal atlas¼ size, UASTC
trees8 species × 2 variants
weight sharpeningsmoothstep(0.22, 0.78, f)
near mesh fade20–23 m (12–14 m low-memory)
near mesh≈ 4–5k triangles

Open data: Gemeente Utrecht Bomenkaart for position, genus and size.

C5 · Tree impostors
The camera direction mapped onto the 8×8 hemi-octahedral grid. The four surrounding views are blended by their bilinear weights.
Aerial view over the Catharijnesingel towards the Domtoren, with long rows of trees along the canal and in the Lucasbolwerk park.Two identical street views at the Catharijnesingel: left all trees as impostor quads, right the nearby trees as full branch meshes.
resultTop: Catharijnesingel and Lucasbolwerk from about 110 m. Hundreds of trees, each one impostor quad showing the pre-rendered view closest to the viewing direction, so they keep their volume from above. Bottom: the same street at eye height, left with impostors only (?treemesh=0), right the default, where trees within 20 m of the camera fade over to their full mesh. Render: utrecht3d viewer, 2 Dec 2026 (3DBAG, BGT, AHN, PDOK aerial photo, Gemeente Utrecht Bomenkaart CC BY 4.0).
C6

Procedural trees by space colonisation

tools/tree_impostors/tree_gen.py tools/tree_impostors/leaf_textures.py

The impostors need tree models, and the project uses no downloaded assets. Branches are grown towards a cloud of points that fills a species-specific crown shape.

  1. Build the crown envelope: an ellipsoid with random lobes (lime, plane, maple…), a vase for elm, a cone for conifers.
  2. Scatter 4200–6000 attraction points inside it.
  3. Each point pulls the nearest branch node within the influence radius; each pulled node grows one step towards the mean pull, plus a bit of upward bias, droop and wiggle.
  4. Points closer than the kill radius to a node are removed. Repeat until no points are left or 400 iterations.
  5. Set radii with the pipe model, r = (Σ r_child^2.4)^(1/2.4), then place leaf cards on the thin twigs.
attraction points4200–6000
influence radius2.0–2.8 m
kill radius0.45–0.65 m
step0.30–0.40 m
max iterations400
pipe exponent2.4
leaf cards10 000–28 000

Open data: None (fully procedural; species from the tree register).

C6 · Tree growth
illustrativeTwo-dimensional sketch of the growth loop. Points (dots) attract the nearest node; they disappear once a node comes within the kill radius.
Two seed variants of a plane tree: Blender renders of the grown branch mesh under sun and sky next to the impostor atlas view baked from it.Close street-level view of two grown trees in the viewer, with branching trunks and leaf clusters against the sky.
resultTop: Platanus × hispanica, two seeds. For each seed: the grown mesh rendered in Blender Cycles (sun, then sky light) and the horizon view of the impostor atlas baked from it. Bottom: the same model as a near mesh in the viewer (Catharijnesingel, eye height): the forked trunk and the branch skeleton grown towards the attractor cloud show through the leaf cards. Renders by utrecht3d; no downloaded tree assets.
C7

The lightmap prototype

tools/lightmap/lm_prep.py tools/lightmap/lm_bake.py tools/lightmap/lm_write.py web/js/lightmap.js

Real-time sky light cannot know that a narrow canal street gets little sky. This experiment (?lightmap=1) bakes sky light and sun bounce per 125 m part and uses it instead of the diffuse environment light.

  1. Unwrap a second UV set with xatlas for each part; include the neighbouring tiles at lod1 and tree crowns as occluders.
  2. Bake A: the viewer’s own sky formula as the only light, direct and indirect. This captures sky occlusion.
  3. Bake B: the sun, bounce light only. The direct sun stays real-time with its shadow map.
  4. Combine blur(A) + blur(B), store as 8-bit KTX2 and attach it to the material.
  5. In the shader, the baked irradiance replaces the diffuse sky light; the hemisphere fill is scaled by the baked sky visibility; GTAO is halved.
texel0.12 m
max resolution2048 px
bakeCycles, 64 samples
tree occluders35 % transparent
blurσ 1 texel (A), 1.5 (B)
bake sun32° / 150° (must match ?sun)
statusexperiment, off by default

Open data: Built tiles only.

C7 · Lightmap
Section through a canal street. A point at the bottom sees only part of the sky dome; the bake stores that share (plus bounce).
C8

Paving and grass detail shader

web/js/streetscape.js src/utrecht3d/streetscape.py

Up close, the 8 cm aerial photo turns to mush. A procedural pattern for each paving type, driven by BGT, is drawn into the ground material near the camera.

  1. At build time, rasterise BGT road parts into a 0.25 m grid with two bytes per cell: paving class and laying angle.
  2. In the fragment shader, look up the class with a small noise jitter so class edges do not stair-step; only on flat ground.
  3. Draw the class pattern: herringbone or stretcher bond klinkers, setts, cobbles, asphalt grain, with noise for wear and moss.
  4. Fade fine detail by screen footprint (fwidth) and blend from aerial × pattern far away to the pattern colour up close.
  5. Grass multiplies the aerial with a 512 px blade texture, tiled stochastically to hide repeats.
raster0.25 m, class + 36 angle steps
paving fade15 / 60 / 160 m (low: 10 / 35 / 60 m)
grass fade8 → 30 m
klinker6.8 cm + 0.6 cm joint
setts / tiles13 cm / 30 cm
grass period0.8 m

Open data: BGT wegdeel and grass (PDOK, CC0), PDOK aerial photo.

C8 · Paving shader
illustrativeGround from the camera outward (log distance). The pattern colour replaces the aerial within 15 m, hands back to aerial × pattern by 60 m, and all detail ends at 160 m.
C9

Rippled canal water

web/js/water.js web/js/night.js

The BGT water surfaces are flat polygons. Drawn as plain blue they look like a floor; a real reflection pass would cost a second render of the city. The water needs ripples, a sky reflection and sun or lamp glints for almost nothing.

  1. The existing glTF material water is patched in place (onBeforeCompile): no extra pass, draw call or texture fetch.
  2. Ripples: the normal is tilted by the analytic gradient of two scrolling octaves of value noise in world x/z (0.45 and 1.6 per metre, the second rotated). The tilt is full within 40 m and fades out by 300 m, so the water does not shimmer from the air.
  3. Fresnel (Schlick, F0 = 0.02): looking straight down the water is dark, silty olive and slightly see-through; at grazing angles it mirrors the sky. Low reflected rays in a narrow canal hit the quays and houses, so they get a dark warm wall colour; only steeper rays see the sky.
  4. The sky colours are the sky dome’s own uniforms, so the night sky darkens the reflection by itself. A low roughness (0.07) lets the sun’s specular sparkle on the ripples; at night the nearest street lamps (a pool of 5–16 point lights) leave the same glints.
  5. Animation runs at about 12 fps only while water within 300 m is in view and not hidden behind buildings (an occlusion query); on low quality the water is static.
noise octaves2 · 0.45 and 1.6 /m
ripple rangefull ≤ 40 m, none ≥ 300 m
Fresnel0.02 + 0.98 (1 − cos θ)5
roughness0.07
animation~12 fps, medium / high quality
night lights16 / 10 / 5 point lights (high / medium / low)

Open data: BGT waterdeel (PDOK, CC0) for the water surfaces; furniture lamp posts for the night lights.

Nieuwegracht from just above the water, looking south between brick quays and trees; the water shows small ripples with bright sun glints.The same view at night: dark water with warm reflections of the street lamps broken up by the ripples.
resultNieuwegracht from about 2.5 m above the water, same camera by day and at night. By day (sun set low ahead with ?sun=25,190) the ripples catch the sun as glints and the far water turns to sky colour at the grazing angle. At night the lamp posts on the wharves leave broken warm streaks on the ripples. Render: utrecht3d viewer, 2 Dec 2026 (BGT, 3DBAG, AHN, Gemeente Utrecht Bomenkaart CC BY 4.0).
D

Film

The same tiles feed an offline Blender flyover on a 6 GB GPU, finished with an image-space sky grade.

D1

Film tile plan and texture budget

tools/blender_film/flyover_route.py tools/blender_film/flyover_plan.py tools/blender_film/convert_tiles.py tools/blender_film/build_shot.py tools/blender_film/scene_cache.py

The flyover is rendered in Blender EEVEE on a 6 GB GPU, and frames slow down 10–30× once textures pass about 2.5 GB. Only tiles near the camera can carry full-resolution textures, and the choice is made per render part, not per frame.

  1. Cut the camera path (the web flyover, 30 fps) into parts of at most 120 frames; a tail under 60 frames joins the previous part.
  2. For every 250 m tile, take the smallest 3D distance from every third camera position in the part to the tile box. Height above 15 m NAP counts, so a high shot does not pull in full detail.
  3. Tiles outside the view cone for the whole part score d · 2.5 + 200 m. Map the score to a level: lod0f, lod0, lod1, lod2 or nothing.
  4. Cost each texture as RGBA8 with mips (w · h · 4 · 1.33). While a part exceeds the budget, demote the farthest full-detail tile one level.
  5. Each level is a pre-converted GLB (KTX2 transcoded to JPEG/PNG with fixed maximum sizes). An optional scene cache stores built parts as .blend files keyed on everything that affects them.
lod0f< 110 m · atlas 2048, aerial 4096 px
lod0< 320 m · atlas 1024, aerial 2048 px
lod1 / lod2< 1000 m / < 3000 m
texture budget2300 MB (U3D_TEX_BUDGET)
part length≤ 120 frames
3D treeswithin 150 m
renderEEVEE, 1920×1080, 32 samples, AgX
scene cacheLRU 3 GB, opt-in

Open data: The built tiles (3DBAG, PDOK aerial, open photos), tree register, Poly Haven assets (CC0).

D1 · Film tile plan
illustrativeTiles coloured by level for the current part (bold path). Per-level texture costs are illustrative; the thresholds and the 2300 MB budget are real.
D2

Sky post-grade

tools/blender_film/sky_grade.py tools/blender_film/flyover_compose.py

The rendered sky comes out pale and nearly white. The grade makes it bluer towards the top in image space, without re-rendering and without halos around towers or flicker between frames.

  1. Find sky pixels from colour alone: bright, unsaturated, not redder than blue, flat (low variance in a 7 px window), and connected to the top of the frame.
  2. Clean the mask (close, erode) and blur it (σ 1.5) for a soft edge.
  3. Take one horizon row per frame: the 90th percentile of the lowest sky pixel per column, so towers poking up are ignored.
  4. Blend a gradient from deep blue at the top to pale blue at the horizon (t^0.7), scaled to keep each pixel’s brightness, at 45 % strength.
  5. For the film, smooth horizon and sky share over ±15 frames, average the mask over time, and fade the grade at night, at street level and when there is little sky.
sky testL > 0.55, sat < 0.25, B ≥ R − 0.02
flatnessvariance < 0.0006 (7 px)
horizonp90 of lowest sky row
deep / horizon colour(0.30, 0.52, 0.82) / (0.80, 0.86, 0.93)
gradientt^0.7
strength0.45
temporal smoothingmedian ±15 frames, mask EMA 0.5

Open data: None; it works on rendered frames.

D2 · Sky grade
illustrativeA schematic frame. The mask stops at the roofs; the horizon row ignores the tower; the gradient keeps each pixel’s brightness.