← Writing/Rendering / Godot
When the Shadows Gave Away the Trick
Building a 3D miniature diorama with world-sized pixels in Godot—and discovering which parts of a renderer have to agree on what a pixel is.
Four seconds into a fight in Erebus’ Maw, a crossbow bolt punches clean through a raider’s front line and buries itself in a Chain Hauler. Before the dust settles, the Mortar Mason slams a stone pillar out of the ground, shoves a raider straight into it, and sends half a courtyard of jagged flagstones spinning past the camera. Freeze on the debris and it feels like someone took a hammer to a hand-painted tabletop set.

That’s the shot you put in a trailer. The shot that actually defined our renderer was much quieter: a close-up of a single flagstone beside a miniature’s boots.
By that stage in development, the miniature was built out of chunky painted squares. So was the stone floor. Yet slicing right across one of those squares was a crisp, razor-smooth diagonal shadow, cutting a single painted pixel neatly into a lit triangle and a dark triangle.
It looked like a smooth 3D shadow projected onto a pixel-art floor—which is exactly what it was. That tiny diagonal blew the entire illusion, and handed us the sharpest question of the project:
If you want a 3D world to read as pixel art, how many stages of the graphics pipeline have to share the same definition of a pixel?
Pixels belong to the world, not the monitor
The fastest way to make a 3D game look like pixel art is to render into a tiny framebuffer and scale it up with nearest-neighbor filtering. That works beautifully right up until you zoom the camera in. Because the screen owns the grid, zooming closer gives a miniature more pixels—its silhouette suddenly sharpens, and the chunky charm evaporates.
We wanted the opposite. Zoom in on a miniature in Erebus’ Maw and you shouldn’t discover finer resolution; you should see the exact same painted marks filling twice as much of your monitor, like holding a magnifying glass over a painted pewter figure.

Half our mid-project confusion came from calling four different units “pixels.” Separating them straightened out the entire pipeline:
| Unit | Size in Erebus’ Maw | What it governs |
|---|---|---|
| Deployment tile | 1.0 × 1.0 court units | Tactical grid and unit spacing |
| Floor paint cell | 0.08 × 0.08 court units | Flagstone pigment, normal, roughness, dither |
| Miniature & rubble mark | 0.05 court units | Painted silhouette of figures and flying stone |
| Display pixel | 1 framebuffer sample | Final rasterization, HUD text, lens blur |
Our camera is orthographic. At 720p with an orthographic size of 9, one court unit spans 80 monitor pixels, so a 0.05-unit miniature mark covers a crisp 4 × 4 block on screen. Zoom in to size 4.5, and that exact same mark grows to 8 × 8. The camera controls magnification; the world decides how many marks exist.
Slicing miniatures and smashing the tabletop
To build miniatures that hold together as you orbit around them, we adapted a horizontal slice workflow from an earlier project (Get It There). Rather than hand-authoring sprites from eight angles, we start with bold, low-detail 3D sculpts grouped into articulated rigid parts—base, torso, hammer arm, bow—so pieces can swing independently during combat.
Our offline baker converts each sculpt into painted geometry in four stages:
- Voxelize and keep holes hollow. Triangles are sampled into a 3D grid at 1/15 model units (oversampling thin blades and cords at 2.25× edge reach so they never vanish between slices). We then flood-fill empty cells inward from the outside air; only sealed interior pockets absorb pigment from neighbors, keeping gaps under arms and weapons open.
- Pre-bake local contrast. Smoothing occupancy with a
(1, 3, 4, 3, 1) / 12kernel yields soft surface gradients, and short-range occlusion probes at 3, 7, and 12 voxels add crevice shading. Each voxel snaps to a seven-step value ramp (0.48to1.18) so metal, bone, and cloth read before scene lights even turn on. - Pack into a slice atlas. Horizontal cross-sections lay out eight across into a nearest-filtered PNG.
- Extract the outer shell. Any voxel sealed on all six sides by its own part is culled; every exposed surface voxel becomes a camera-aligned square quad anchored in local space.

One subtle trap showed up on slanted surfaces like beveled plinths: if a projected voxel only claims its single nearest snapped cell on the camera grid, slanted angles can open tiny pinholes where an upside-down interior face peeks through. Expanding each sample’s coverage across its projected camera-space half-extent sealed those leaks completely—tested by lighting a pure-white plinth from straight overhead and verifying 0 dark interior probes out of 625 at both viewing angles.
Making destruction belong to the same world
Once the miniatures looked solid and painted, our first pass at destructible stone looked like it had wandered in from a different game. Smooth, crisp-edged low-poly slabs erupted out of a chunky painted floor.

Rebuilding the flying debris out of painted 0.05-unit surface samples transformed the feel of combat. Two details made the illusion stick:
- Socket-anchored pigment. When a rock breaks out of tile
(4, 0)and flips end over end, it carries its original tile coordinates in per-instance data. Its top surface keeps sampling flagstone pigment from its home socket—so stains and cracks stay glued to the tumbling stone—while its newly exposed cut walls and underside sample broken interior grain. - Real 3D occlusion. Because the shards live in full 3D space rather than a 2D particle overlay, a chunk thrown across the arena genuinely passes behind one miniature and in front of another. (In an isolated 16 × 16 crop over the Fungal Brute’s torso, a passing slab changes 0 pixels behind him and all 256 pixels in front.)
Staging the miniature set
A tabletop only feels tiny if the lighting and camera treat it like a physical object. Instead of washing the court in flat ambient light (0.31 cool fill), we stage identifiable light sources: a cool directional moon (0.68, casting shadows), an overhead vault spotlight (6.0), a pair of warm flickering braziers (6.2 north with shadows, 4.3 south, modulated with subtle dual-sine flicker so flames breathe without strobing), and tiny wicks tucked along the perimeter.

Three camera details glue the action together:
- Tilt-shift focus. A post-process pass reconstructs view-space depth and projects it onto a tilted plane
(0.10, 0.18, -1.0), keeping both active combatants sharp inside a dynamic focus band while softly blurring the table’s distant edges with a 36-tap golden-angle spiral (reducing far-edge contrast to 0.70×). World-anchored damage numerals draw on the canvas after the lens at a matching 0.047-unit texel scale so hits stay razor-sharp. - Physical combat timing. Moves earn their impact from board geometry: the Mason’s Knock Test actually validates a clear 1.12-unit pillar site and 1.55-unit shove corridor before firing its 1.72-second sequence. Camera recoil kicks opposite the blow direction (8.5 Hz main sway plus a 14 Hz orthogonal rattle), while knockout finisher orbits drop live action to
0.065×speed after giving flying rubble a crisp 0.16-second full-speed burst.
Everything on the tabletop now spoke the same visual language—except the shadows.
Tracing the smooth diagonal into Godot’s renderer
Our first attempt to quantize lighting was the obvious one: snap the shading coordinate to the center of each painted cell inside the fragment shader using Godot’s LIGHT_VERTEX built-in (an idea popularized in Godot by David Holland’s 3D Pixel Art Rendering).
Around a warm brazier’s falloff, it looked promising. Across a hard cast shadow, the smooth diagonal was still right there, slicing straight through painted stone cells.
Opening Godot 4.6’s Compatibility renderer source (drivers/gles3/shaders/scene.glsl, lines 676–731 and 2382–2421) explained why in thirty seconds:
- The directional light renders its shadow depth map from the scene’s casters.
- When drawing the floor, the vertex shader takes each vertex’s position and normal, applies normal bias, and computes the directional shadow lookup coordinate before rasterization.
- The GPU smoothly interpolates that shadow coordinate across every triangle.
- By the time your fragment shader runs and overrides
LIGHT_VERTEX, local light attenuation and specular highlights listen to your snapped position—but the directional shadow lookup has already interpolated across the triangle’s original corners.
To make Godot’s native shadow map snap to our paint grid without rewriting the entire shadow pipeline, we had to separate three jobs that standard meshes lump into one VERTEX attribute:

- Where the triangle covers the screen (
POSITION): use the real mesh corners so geometry stays watertight. - Where an object blocks light (
IN_SHADOW_PASS): use the real mesh corners so casters write accurate silhouettes into the shadow map. - Where a painted cell receives light (camera-pass
VERTEX): feed every corner of that cell the exact same paint-cell center (CUSTOM0.xyz).
In shader form, the entire trick is four lines:
vec3 raster = VERTEX;
vec3 receiver = CUSTOM0.xyz;
POSITION = PROJECTION_MATRIX * (MODELVIEW_MATRIX * vec4(raster, 1.0));
VERTEX = IN_SHADOW_PASS ? raster : receiver;Because every corner of a painted cell hands the engine the identical receiver coordinate (and flat geometric normal), Godot computes the exact same shadow-map lookup at all corners of that cell. Interpolating an identical value across a triangle yields a constant—so every screen pixel inside that stone mark receives the exact same shadow visibility, straight out of Godot’s native shadow pipeline.
The catch? Geometry. For a cell to hand its own flat receiver coordinate to the vertex shader, the mesh has to be clipped along the 0.08-unit paint grid so every cell owns its own vertices. Remember that geometric precondition; it’s about to come back and bite us.
Turning smooth light into painted bands
Once cast shadows snapped cleanly to paint cells, smooth lighting gradients across the floor still felt slightly too soft—closer to 3D Gouraud shading than an illustrated dungeon. We built a live toggle (D) to compare three finishes side by side on the exact same frozen view:

Posterization alone carved stark contour rings around every lamp. Adding a 4×4 ordered Bayer dither broke those rings into crisp checkerboard transitions right where warm firelight meets cool dungeon shadow—while keeping the bright core under the brazier clean and solid.
Early on, we tried quantizing each lamp individually inside the material’s light() function. That backfired immediately: two lamps rounded separately can sum to an arbitrary in-between brightness that doesn’t exist on your value ramp. You have to let all lights, shadows, and reflections combine first, and quantize the combined scene color in post-processing.
That left a puzzle: the post-process shader only sees the final RGB framebuffer and depth buffer. It has no idea which world-space Bayer cell a pixel belongs to.
Our workaround is a clean piece of log-space arithmetic. Every painted surface already knows its world-space cell address (anchored to rest coordinates so dither stays glued to tumbling stone). From that cell modulo 4, we look up its rank r in Bryce Bayer’s classic 1973 4×4 threshold matrix and compute a centered threshold t = (r + 0.5) / 16.
Before Godot runs lighting, the material multiplies its pigment by a tiny exponential exposure bias:
const float BAND_STEP = 0.32;
float threshold = (rank + 0.5) / 16.0;
float gain = pow(2.0, (0.5 - threshold) * 0.80 * BAND_STEP);At the extremes, gain barely nudges the color—between 0.920× and 1.087×. Why make it a power of two? Because multiplication in linear space becomes addition in log space.
After every lamp and shadow finishes contributing to the framebuffer, the post-process shader takes a luminance proxy v = dot(rgb, vec3(0.2126, 0.7152, 0.0722)), rounds log2(v) to the nearest 0.32-stop band (roughly a 1.248× brightness jump per step), and scales the whole RGB triplet uniformly:
float k = floor(log2(v) / 0.32 + 0.5);
float band = exp2(0.32 * k);
vec3 out_rgb = rgb * (band / v);Scaling all three channels together keeps warm firelight golden and moonlight blue instead of shifting hues like per-channel posterization. And because each cell arrived pre-biased in log2 space, neighboring cells cross the rounding threshold at staggered brightness levels—producing a world-locked Bayer pattern across the entire scene without spending a single extra G-buffer channel.

Designing a test the wrong shader can’t pass—and the plot twist it uncovered
Pretty screenshots are terrible witnesses. Busy flagstone textures, mortar shadows, and tilt-shift blur can easily hide whether a shader is actually keeping shadows locked to paint cells.
To settle the question cold, we built a ruthless diagnostic rig in native Godot 4.6.1 (Compatibility, Apple M1 Max, 1280×720): hide the fighters and lamps, flatten the floor to a clean uniform tone, park an orthographic camera straight overhead, and suspend an invisible 0.40 × 0.15 × 2.50 rotated box above the court casting a long, razor-sharp diagonal directional shadow.
Across a 14 × 14 patch (196 paint cells), the harness samples five points inside every cell—the center plus four interior corners inset safely away from cell borders—at 1× zoom, 2× zoom, and after sliding the caster 0.24 units sideways. If any interior probe disagrees with its cell’s center by more than 0.012 in luminance, that cell is flagged as split.
Here are the three render paths side by side under that exact same caster:

Look at the first two columns:
- Left (fragment
LIGHT_VERTEXonly): 30 split cells in plain lighting (29 with dither)—amber boxes marching cleanly down both diagonal shadow edges. - Middle (shared native vertex receiver): 0 split cells across all three finishes, both zoom levels, and after moving the caster—while still flipping 77 cell centers from lit to dark when the box moves. Real dynamic shadows, zero split pixels.
Now look at the third column.
| Receiver path | Finish | Split 1× | Split 2× | Moved | Δ 2× | Δ Move |
|---|---|---|---|---|---|---|
| Fragment LIGHT_VERTEX only | Pixel lighting | 30 | 30 | 26 | 0 | 77 |
| Fragment LIGHT_VERTEX only | Posterized + dither | 29 | 29 | 26 | 0 | 77 |
| Shared vertex receiver (dense) | Pixel lighting | 0 | 0 | 0 | 0 | 77 |
| Shared vertex receiver (dense) | Posterized + dither | 0 | 0 | 0 | 0 | 77 |
| Current 18-tri compact court | Pixel lighting | 30 | 30 | 26 | 0 | 77 |
| Current 18-tri compact court | Posterized + dither | 28 | 28 | 24 | 0 | 77 |
The smooth diagonal came back.
The cost of a pixel
Between building the dense shared-receiver floor and shipping our latest build, we ran a massive optimization pass. Pre-clipping 245 fractured stone tiles to a 0.08-unit paint grid—plus 4,409-sample surfel miniatures (the Mortar Mason’s round plinth alone burned 4,140 triangles)—had pushed our early opening scene to 6.01 million combined camera and shadow submissions.
We tore that budget apart (documented in full in the companion floor article):
- The intact 245-tile floor collapsed into 9 rectangles (18 top triangles, 272 including walls and bed), using a 6-step fragment raymarch over a corner-depth texture to fake the mortar grooves, and swapping to instanced tiles only when a stone actually lifts. That cut isolated floor camera submissions from 694,542 down to 272 and shaved over 2 ms off steady frame times.
- Dense surfel miniatures and props became fitted low-poly painted hulls sampling tiled 3D pigment volumes (with a 2-voxel nearest-fill margin and optional orthographic square-edge expansion + shared depth so joints don’t split marks). Combined opening submissions plunged from 6.01 million down to 58,098, cutting paced 60 FPS Apple GPU energy by 19.0% in placement (
128.1 → 103.8 mJ/frame) and 21.6% under repeated craters (134.0 → 105.0 mJ/frame).

And right inside that triumph hid our ironic trade-off. Remember the geometric precondition of the shared vertex receiver? Eighteen triangles across an entire courtyard cannot carry a unique flat vertex receiver for every 0.08-unit stone cell.
Our compact floor shader fell back to assigning LIGHT_VERTEX in the fragment shader—the exact path from column one. Seated crowns inside opened tiles and flying rubble still keep their explicit vertex receivers, but on the intact 18-triangle sheet, Godot’s vertex-interpolated directional shadows can once again cross the middle of a painted cell.
Why didn’t our original automated test catch the regression? Look at the last two columns of the audit table. Our old test only sampled one point at the center of each cell to verify that shadows stayed put across zoom (0 changed) and moved with the caster (77 changed). By that metric, all three columns looked 100% identical! Only probing five interior points per cell unmasked what the optimization had quietly traded away.
That leaves a clean, concrete problem for the next rendering pass: keeping the 18-triangle floor mesh intact while sampling shadow visibility at the snapped cell center via a separate lookup or pass—getting back to 0 split cells without paying 694,000 triangles to rent them.
When people watch Erebus’ Maw in motion, the thing that catches their eye is a stone pillar exploding into pixel-painted rubble across a lit miniature arena. Nobody consciously notices a shadow settling onto a flagstone. They only notice the moment it cuts a painted pixel in half—and quietly breaks the spell.
Notes, references & credits
Fresh shadow audits were captured on November 25, 2026 in Godot 4.6.1 (Compatibility renderer) on an Apple M1 Max at 1280×720. The opening close-up and timeline frames come from the dense-floor era; the third column of the shadow audit reflects the compact court.
- Flagstone material adapted from ambientCG Tiles 130 (CC0 1.0).
- David Holland, 3D Pixel Art Rendering and Godot PR #91136 for
LIGHT_VERTEXbackground. - Godot 4.6 Compatibility renderer source: vertex shadow setup and directional shadow lookup.
- Bryce E. Bayer, An Optimum Method for Two-Level Rendition of Continuous-Tone Pictures (1973), bibliographic record.
- Companion post: How to Shatter an 18-Triangle Floor.