Photo scans on our cathedral, and the stone we kept
We retextured a whole cathedral with photo scans laid in random hexagons so their copies don't line up. That worked for the ground, the slate and the dressed stone. On the rough rubble walls the hexagons cut stones in half, so those walls went back to their old stone, now sharper and weathered while the game runs. What we tried, what we kept, and what it costs.
Most of our cathedral is photo-scanned now, from the slate roof and the dressed stone to the headstones, the ground and the whole interior. The scans are laid in random hexagons so their copies don’t line up. On the rough rubble walls that blend cut stones in half. So those walls went back to their old stone, now drawn at twice the resolution and weathered while the game runs.
Before this test, the cathedral was drawn like all our buildings. A handful of tiling textures, some from photo scans and some made by code, were each laid down as a plain repeat with the same tone everywhere. Up close that looked fine. Further out the evenness gave it away, and evenness is one of the things that makes a game look like a game. So before changing the art across the whole map, we tested a new approach on one building, the cathedral with its churchyard wall and its grounds.
Drag the line across each picture to compare. The pictures from now also have ambient occlusion (a soft shadow in corners and under ledges), terrain shaded by how much sky it sees, and stained glass. All three came into the game after the befores were made, so part of the change in light comes from them and not from the textures.
Before
AfterWhy photo scans
A photo scan is made from many photographs of a real surface. Software turns them into textures that record its color, its relief and how much it shines. Scans carry the small irregular detail that’s hard to invent, like mortar that has crumbled back from a joint, lichen in a hollow, or the polish on a step.
We use free scans from Quixel’s Megascans library, under the Fab Standard License, plus free scans from Poly Haven. We picked 85 Megascans listings for ground, rock, building materials, bark, plants and decals. The game uses them at 2048 pixels at most.
Our project rule is that Dead Drop must not look like any other specific game. One of us ruled that scans are allowed as long as the game as a whole looks and feels like its own. The shapes are still ours. The buildings, trees and rocks come from our own generators, and the scans only cover their surfaces.
The repeat problem
A scan covers a patch a couple of meters across. A churchyard wall is far longer than that, so the patch has to be laid down again and again. Then the eye finds the copies. Up close you notice the same oddly shaped stone. From 50 meters you see a grid of dark spots marching along the wall.
A bigger texture doesn’t solve it. It costs more video memory and still repeats, only less often. A shader is the small program the graphics card runs to color each pixel. So the scan shader breaks up the repeat while the game draws each frame. That costs no extra texture memory, but it does cost frame time, and the last section has the numbers.
How the scans are laid
Six techniques work together on the cathedral. Each one fixes a failure we could see in our own screenshots.
Hexagon cells
The game splits a surface into a lattice of hexagons. Each cell shows the scan at its own random position, turned by a small random angle. Each pixel reads the scan up to three times, once for each cell around it, and blends the reads. The blend follows the scan’s own height, so a raised stone wins over the mortar beside it. The joins then run along the stones’ outlines instead of a straight line. The copies are still there, but scattered and turned, so the eye no longer finds a grid of them.
On the cathedral the hexagons draw the slate roof, the dressed stone at the corners, windows and doors, the copes on the churchyard wall, the timber, and the plaster and the arcade’s piers inside. The churchyard ground and the terrain use them too. The method isn’t our invention. It is known as hex tiling or stochastic tiling.
Each cell’s position and angle come from a hash, a formula that turns the cell’s number into random-looking values. Our first version used a common shortcut built on a sine function. On a map 2 kilometers across, the numbers going into it are large. Any edit to the shader’s code then reshuffled about a third of the cells, and another graphics card or driver could have drawn another wall. The cells now use a hash of whole numbers. It comes out the same on every card, so every machine draws the same wall.
Laid in the world, not on the model
A building in the game is several meshes. There are its detail levels, the pieces it breaks into, and the cells its walls are cut into for destruction. The texture coordinates of these meshes, which say where each point reads the texture, are offset from each other. While the hexagons followed those coordinates, a cell border ran along every mesh edge. It showed as hard triangular seams at arm’s length. The hexagons are now laid out by position in the world, so every mesh of the building agrees on them.
A second scan
A second scan of a related surface is mixed in, following a slow, random-looking pattern across the face. On the churchyard wall’s sandstone copes, a scan of lichened rock comes and goes. Inside, an older, grayer plaster shows in patches through the limewash. Wherever the second scan takes over, the first one’s features stop lining up with their copies. The second scan is read once per pixel, not in hexagons, which would cost as much again as the main scan.
Drift you see from afar
From far away the eye stops seeing stones and starts seeing patches. So color, brightness and shine drift slowly across each surface over two sizes of patch, say a few meters and a dozen or so (these sizes are only illustrative).
The hexagons also stay on much farther out than the shader’s own default. Past that range a single plain read showed a 2-meter repeat along the wall’s copes. We also tried fading them out closer in to save time. The slate roof and the walls, which still had hexagons then, showed their repeat again. The saving was at most 0.04 ms, so they stay on.
Before
AfterEvery stone its own
Separate stones are handled another way. A headstone, a floor flag, a memorial slab or an arch stone each gets its own patch of the scan, at its own offset, rotation and tone. Headstones also get their own scale and are mirrored half the time. Before that, the same crack network in the sandstone scan turned up on headstone after headstone.
The church’s floor is 587 separate flags, each a piece that can sink, rise or break. Cut into that many pieces, the floor scan’s white lichen spots turned up on flag after flag. So the shader pulls the brightest specks toward the stone around them.
The memorial slabs taught the same lesson. Laid in a regular zigzag at one size and one tone, they read as a checker from the far end of the nave. They now lie where burials would have been wanted, at different sizes and tones.
The ground
The churchyard ground mixes five scans of grass, dry grass, wet soil, mossy gravel and moss. A painted map says which goes where. It is read through a warp, so no border between them runs straight. The terrain across the map works the same way, with 19 scanned layers, one per kind of ground. There the scans only add detail on top of the ground’s measured color. From far away you see that color, and up close the scan’s detail, in hexagon cells like the roof.
Where the hexagons failed
The cathedral’s walls, and the churchyard wall around it, are rubble. Rubble is rough stones of every size, each bedded in its own ring of mortar, with no courses to follow. On these walls the test laid a Megascans rubble in hexagon cells, mixed with a second scan. Looking at the finished walls, one of us noticed that the blend between cells cut through single stones and their joints. Half of one stone ran into half of another, and joints stopped in the middle of a face. The wall read as dark, muddled texture rather than as stones someone had laid.
A cell is much bigger than a stone, so each border runs past many of them. On the slate roof the courses stay level from cell to cell, so the border finds a clean edge to follow. Grass and soil have no edges to cut. Rubble stones are every shape and line up with nothing. So all along the border, the blend splices pieces of different stones together.
Before
AfterSo we tested a rubble scan laid as a plain repeat with no hexagons, on a farmhouse with the same kind of wall. It stood side by side with the hexagon version and with the farmhouse’s own old stone. After seeing the three, one of us chose the old stone and asked for the same on the cathedral.
The cathedral’s old stone is a photo scan too, a free one from Poly Haven called Castle Wall Variation. It is color-graded to the gray of whin, the hard dark stone of many Scottish rubble walls. Our buildings used to draw it at 1024 pixels per 2-meter tile, half the scan’s own resolution. Now it draws at 2048, the scan’s full resolution, so each meter of wall gets twice as many pixels across.
That choice brings back the problem this post started with. The old stone is laid as a plain 2-meter repeat, so a long wall seen straight on shows its copies again. The slow color drift still runs over it, and so does the weathering in the next section. They break up the evenness, but they don’t hide the repeat.
Before
AfterWear that follows the weather
Real walls weather in a pattern. Water rises into the foot of a wall and runs down from every ledge. Moss grows where it stays damp, on the north side, in the joints and on top of the wall. Corners at hand height get rubbed smooth.
So the wear isn’t painted on. The shader works it out from the shape of each surface. It looks at how high the surface is above the ground, which way it faces, whether it is an edge, and what is above it. The building’s baked shading map adds the broad dirt and growth underneath.
The edges come from the model itself. The baked map holds only about 5 pixels per meter, far too coarse for a worn edge a couple of centimeters wide. So every point of the mesh carries where it sits on its face and which of the face’s sides are outside corners.
When the walls first went back to the old stone, they lost all of this. The old stone was drawn by our plain building shader, which has no run-time wear. One of us asked whether the moss had only been possible because of the scans. It wasn’t. The wear needs one thing from a texture, a height map, so that moss and dirt settle into the joints first.
The old stone had no height map, so we rebuilt one from its surface-relief map, which stores the slope at every pixel. Adding those slopes up across the tile gives back the height of every stone. Now the old stone goes through the same shader as the scans. The moss on it is lighter and patchier than it was on the scans, and the same wear runs on every old-stone wall on the map.
The cathedral’s north wall comes out greener and damper than its south wall. That is because it faces north, not because someone painted it that way. Inside, soot gathers high up and dust settles along the walls and in the joints. The floor is worn smooth and pale along the paths down the aisle and between the doors.
Before
AfterPlaster has fallen off the inside walls in patches, mostly near the floor where damp gets in. A third scan, of rough rubble, shows through where the plaster is gone. The plaster’s broken edge is drawn pale, with its shadow on the stone. The arches inside are built from separate stones too.
Before
AfterA churchyard nobody mows
The first finished churchyard had a problem the scans couldn’t fix. It looked mown. Dead Drop is set in a Highland region nobody has lived in for years, so one of us ruled that nothing should look manicured.
The churchyard now grows the game’s own rough, uneven grass from a density map the cathedral carries. It grows thick over most of the yard and thinner on the flagged path. It keeps a little way off each headstone, so it grows up around it. The worn paths in the ground underneath have healed over into grass and moss.
This is the same grass as everywhere else in the game, and it is short. It reaches about the shin of a standing player. Up close, a prone player lying in it still shows their head and shoulders. So in the churchyard the headstones and the walls give the cover, not the grass. The grass is placed from the map itself, the same on every machine, and no setting turns it down.
Before
AfterWhat it costs
All the numbers in this section were measured on one dev’s machine with an RTX 4080, at 1920 by 1080, with the default lighting. It is not our reference machine for performance, so read them as comparisons, not targets. The scans are built into the cathedral’s model, so the game can’t switch them off while it runs. “Before” figures therefore come from builds made before the test.
Video memory
| Standing at the cathedral | Video memory |
|---|---|
| Before the test | about 1,700 MB |
| With the cathedral on scans | about 2,010 MB |
| Now, with the scanned terrain and other new art | 2,605 MB |
Textures are nearly all of it, 2,223 MB of today’s figure. The cathedral’s scans are 2048 pixels for color and for surface relief, and 1024 for roughness and shading. The churchyard’s ground layers are 1024, because at standing height that is already finer than a screen pixel.
The scanned terrain’s 19 layers are 2048 pixels each. Drawn with the old terrain textures instead, the same spot measures 2,400 MB. So the scanned terrain is 205 MB of today’s 2,605. The rest of the rise since the test came with other art added to the map in the same weeks, and we didn’t split it up by building. Putting the walls back on the old stone saved 28 MB at the west front, because the walls there no longer load the rubble scans.
Frame time now
The table shows how long the graphics card spends on each frame at each spot, with the walls on the old stone. Each figure is the median over 480 frames, and three repeat runs agreed within 0.03 ms. Ambient occlusion, the soft shadow in corners and under ledges, is on for every player with the same settings, and the table shows it on and off. Draw calls count the separate requests the game sends the graphics card to draw each frame.
| Spot | Occlusion on | Occlusion off | Draw calls |
|---|---|---|---|
| Standing in the nave | 1.75 ms | 1.63 ms | 478 |
| In the churchyard | 1.88 ms | 1.72 ms | 806 |
| Above the churchyard, to the south | 2.10 ms | 1.94 ms | 614 |
| At the west front | 1.59 ms | 1.47 ms | 477 |
| Inside the churchyard, along the south wall | 2.13 ms | 1.93 ms | 1,544 |
The terrain is part of the outdoor numbers. Drawing the same spots with the old terrain textures saves at most 0.08 ms, above the churchyard, where the ground fills most of the view. The old stone now goes through the scan shader so that it weathers. Against the old stone drawn plain, that measured no difference outside the noise.
The nave, from before the test to now
The nave has the longest record, so here it is in order. The figures are with ambient occlusion off unless they say otherwise, because the occlusion wasn’t on by default before the test.
Before the test the nave took about 1.0 ms.
The scan shader’s extra layers. Measured in the nave during the test, switching each layer off saved this much:
| Layer switched off | Saving |
|---|---|
| Hexagon cells | 0.18 ms |
| The fallen plaster’s rubble and its outline | 0.18 ms |
| The second scan | 0.11 ms |
| Wear (damp, grime, streaks, soot, dust, lichen) | 0.12 ms |
| All the extra layers at once | 0.44 ms |
The rows add up to more than the last one because they overlap. The plaster’s rubble, for one, is also laid in hexagons, so part of its cost shows in two rows. With every layer off, the nave still took about 0.3 ms longer than before the test. The cathedral is about 150,000 triangles at its nearest detail level, so more geometry is the likely reason. We didn’t split it up.
Trimmed without changing the look. By then the nave measured 1.61 ms. We cut the shader’s cost only where the picture didn’t visibly change, judged on before and after stills from the same spots with time frozen. Cell reads that can’t show are now skipped, as are the second scan and the plaster’s rubble wherever they can’t appear. Those changes alter no pixel at all. The plaster’s outline now reads its random pattern from a stored texture. That moves the patches of fallen plaster but keeps their size and share.
Together that took the nave from 1.61 to 1.55 ms, and from 2.50 to 2.26 ms with the occlusion on. At the end of the test it measured 1.54 ms. One saving we turned down. Switching off the filtering that keeps bump detail sharp at grazing angles would have saved another 0.12 ms with the occlusion on. But walls seen along their length went soft, so the filtering stays on.
The occlusion ran our shader twice. The occlusion needs to know which way each pixel faces, and the engine works that out in an extra pass before the main one. In Godot, the engine we build on, that pass runs each material’s full shader. Nearly everything our stone shader does changes which way a pixel faces. So with the occlusion on, the stone was shaded twice per pixel.
The fix is a small patch to our own build of Godot. It tells a shader when it is running in that extra pass. Our heavy shaders then skip their work there and keep only the mesh’s own direction. In the nave it cut the occlusion’s cost from 0.94 to 0.13 ms, and every figure in the table above is with the patch.
We compared stills with and without the patch. In the nave nothing changed. The largest difference, averaged over a whole picture, was two thirds of one brightness step out of 255, at the west front. Single pixels there moved by up to 16 steps, with no pattern you can see.
Grass nobody could see. After the test the nave got slower, from 1.54 to 1.69 ms. When the churchyard got its grass, about 425,000 grass triangles ended up behind the nave’s walls, all drawn and none on screen. Much of that grass reached the graphics card only for the shader to shrink it to nothing. The grass now leaves those clumps out, and before and after stills of six views are identical to the pixel.
That brought the nave down to 1.63 ms, where it is today, and 1.75 ms with the occlusion on. What is left of the gap since the end of the test is the churchyard grass behind the walls, which we kept.
Draw calls and the build
Each kind of surface is one material, and each material costs a draw call for every mesh it appears on. So we reused a surface wherever two things should look alike. The carved names on about 120 headstones come from one generated texture of worn inscriptions. That is one extra draw call, and it cost no frame time we could measure. Neither did the 1,004 decals on the floors and walls, the cracks, mud and leaves.
A full build of the cathedral’s model took 2,037 seconds on one dev’s machine, but changing how a surface looks doesn’t rebuild it. The looks live in a small file the game reads. So a new tint, or the lighter moss on the old stone, rebuilds only that file and the scan textures.
How it was built
Claude did the work as four agents running at once, one each for the churchyard wall, the grounds, the outside of the church and the inside. A dev directed it and judged the pictures. The four agents shared one material system, and partway through, the wall agent found a bug in it. A setting in the step that saves textures made the mortar in every scan nearly white, which showed as a pale sheen on the stone. The fix went into the shared code straight away, and the other three agents rechecked their work against it.
What’s next
The cathedral is done, and so is the ground. Most of our other buildings have since moved onto the same scans for their roofs, dressed stone, brick, concrete and timber. Every bare rubble wall among them kept its old stone, weathered the same way as the cathedral’s. One landmark is still to be converted. The chunks a blast knocks out of a rubble wall still use the scanned rubble, so they are a slightly different color from the wall they came from. The engine’s shadows also show a fine dither in places.