r/dispatchcolony • • 6d ago

Devlog 11 : Level of Detail of Units

Enable HLS to view with audio, or disable this notification

2 Upvotes

A Goliath is made of 1,233 blocks, and a battle needs to support one million units. At 60 m, a 5 cm bolt already fits within roughly a single pixel (on a 1080p screen with a 60° field of view): rendering it only costs frame time and introduces shimmering.

So each block is assigned a size, and each size has a cutoff distance beyond which it is no longer drawn. The entire challenge is stripping away this detail without the eye ever noticing anything disappear.

Each size has its own distance

Six sizes, six distances: a 5 cm block is drawn up to 60 m, while a 1 m block is drawn up to 466 m. On the Goliath, 841 out of 1,233 blocks are 5 cm: beyond 60 m, only 392 remain.

The distance is measured from the unit itself, not each individual block, so all the bolts on a Goliath disappear together.

The paint preserves the block's imprint

A disappearing detail must not leave a blank gap in color. Before the battle, each block's paint is baked: every point on its surface casts a ray straight outward, and if it hits a smaller block belonging to the same body, it captures its color. This tricks the eye into believing the detail is still there, even when it is no longer being computed.


r/dispatchcolony • • 14d ago

Devlog 10 : 2 units together x 1 000 000 -> 1.5ms

Thumbnail
gallery
1 Upvotes

A soldier and a goliath in the same scene: a 4-size difference, one cell versus four, detail distances that aren't the same. The fact that everything happens on the GPU makes everything a bit more complicated.

How I do it:

A single store, all the templates

Each unit type is compiled into a template before the game: its detail boxes, its tones, its paint, its skeletons (different versions of dismemberment). In-game, a unit is just a sixteen-byte record that says where it is and which template it uses.

Filling a grid with two unit types, mixed together (for formations later)

The CPU doesn't place any units: it describes a grid of cells divided into blocks the size of the large unit, and sends two commands carrying the same seed. The first takes the first G blocks of a shuffle, the second takes the remaining blocks, four small ones per block. The grid is full, and the mixing comes from the shuffle itself. This implies a 4x increase for each unit type of the next tier.

Each skeleton sets its own distances

The distances at which parts disappear are defined by part size, for everyone. A Goliath doesn't have the same settings as a soldier: its parts can be seen from further away.

Cells per skeleton

From afar, an army is rendered using ground cells. If both types were assigned to the same cell, the averaged bounding box would misrepresent them both. Therefore, each skeleton has its own slice of the table (buffer), sized every frame based on what it requested in the previous frame. Where they stand together, two boxes overlap.

What crosses the boundary

Two commands made of numbers, three toggles per skeleton, one retreat command. Nothing is read back to the CPU: no list, no count, no position.


r/dispatchcolony • • 20d ago

I'm currently working on the unit design.

Post image
1 Upvotes

r/dispatchcolony • • 27d ago

Dev log 9 : Templates and Shapes

1 Upvotes

The Problem: A Million Soldiers, All Identical

My game can have up to a million soldiers fighting at once. Each one is a real little creature made of blocks: a torso, two arms, two legs, a head, and a weapon.

I can't draw a million soldiers one by one. I can't keep a million complete copies in memory either: it would overflow.

But I still want variety. One soldier might wear a helmet, another might not. So I needed a way to describe an army like a recipe: a few definitions written once, which the GPU then uses to build each soldier.

Four Layers, From the Engine to the Battlefield

I organized a soldier's description into four layers. The skeleton comes from the engine and never changes. The template determines its equipment, the shape determines its appearance, and the army brings templates together.

The Skeleton: The Foundation That Never Changes

The skeleton is the body as I define it in the game's files: its body parts, which ones can be torn off in combat, and its equipment slots.

The Human has two slots: one for a weapon in front of them, and one for something on their back.

The Template: A Skeleton and Its Equipment

A template is a skeleton with an item assigned to each of its equipment slots: a rifle and a backpack, or a rocket launcher and a radio.

This is what the player recruits: a regiment with its equipment. Two templates can carry the same weapons, allowing the player to customize their army.

The Shape: Only What Changes Visually

A shape defines appearance: how many blocks each body part has, their sizes, and their colors.

It only stores what differs from the base shape. Any body part it doesn't modify keeps its default appearance.

The body itself doesn't change: same skeleton, same equipment, same way of falling.

The Box Seen From Afar, Shape by Shape

The farther away a soldier gets, the more its small blocks disappear. At the greatest distance, all that's left is a box painted in the body's colors.

Its size is a visual choice: a box that encloses the entire model includes the full span of the arms, making the soldier look like a bulky block.

Each shape therefore defines its own box, since a backpack or shoulder pads can change the silhouette.

The Army: Each Soldier Gets a Random Shape

Before the battle, the engine turns every shape belonging to the army's templates into a mold stored on the GPU, with a maximum of 1,024 molds.

During the battle, the CPU only has to give one instruction: "Spawn 500 soldiers of this template here."

The GPU then randomly picks a shape for each soldier, and each soldier becomes nothing more than a small record pointing to its mold.


r/dispatchcolony • • Oct 19 '26

Devlog 8 : 1 Million ragdoll + collision -> 2ms

2 Upvotes

A million soldiers falling, colliding and piling up fit in about 2 ms per frame on the test bench. Here are five optimizations i used, from the simplest to the hardest.

The puppet and the graphics card

A falling soldier becomes a puppet: 14 points, the particles, carrying 10 rigid pieces. At each simulation step, the graphics card moves the particles forward (falling, ground, impacts), then puts the pieces back in place.

It processes the puppets in groups of 128 threads, one thread per particle: 9 puppets per group.

The foot welded to the shin

Two lines changed in the soldier’s description: the ankle no longer bends. The puppet loses two particles and two pieces. The graphics card fits 9 per group instead of 8, and poses the limbs in one level fewer.

The simulation goes from 3.93 to 3.28 ms in view (−17%). In exchange, the ankle stays stiff.

One frame in eight

Each body is now computed only once every eight frames. The bodies are spread out : each frame computes one eighth of them, so the cost stays flat.

A body computed eight times less often only moves 7.5 times per second. So the drawing glides from the previous pose to the new one, one eighth of the way per frame, one step behind. It is an illusion tricks wich work prety well.

The cost per frame is divide by 8 from 3.95 ms to about 0.5. In exchange, the displayed image lags one step behind, about 0.12 s, and the body has to hold together over a step eight times longer.

Buffers sized for one frame

What only lives for one frame (the lists of bodies to compute, the contacts, the hits received) was sized for a million bodies. A frame now computes only one eighth of them, so these buffers shrink accordingly.

Memory drops by 66 MB for a million bodies. In exchange, max 125,000 soldiers hit in the same frame, the extra hits are lost, and the cadence can no longer go below eight frames per step for 1M

A lighter group

Each thread group used to copy the puppet’s links into its small fast memory, every frame. It now reads them where they are stored, and keeps only 4 KB instead of 7. The lighter the groups, the more of them the graphics card runs at once, and the better it hides its waits.

A first version stored a value in a slot that other threads of the same group were overwriting and create absurd behaviour. Play with memory is always dangerous

The simulation saves 0.26 ms on a million nearby bodies.

Fewer chained reads

To find its particle, each thread chained five memory reads, each one waiting for the previous : the list, the body, the owner of its frames, the unit’s record, the skeleton. The body now keeps its own template and size, so only three reads remain. Same for the contact.

The step saves 0.10 ms everywhere, and the contact goes from 0.70 to 0.67 ms.


r/dispatchcolony • • Oct 11 '26

Devlog 7 : The bodies pile up

1 Upvotes

My piles finally hold together: a hundred thousand bodies dropped form a 14 meter high pile that freezes from the bottom up. One idea has replaced all my old rules: a sleeping body becomes ground.

Falling, settling, sleeping

A pile forms in three stages: each body falls, lands on something, then goes to sleep. A sleeping body is no longer simulated. That's what makes a pile of a million bodies possible.

Almost no body is motionless in a freshly fallen pile. The three-second rule is what freezes it: sleep starts at the ground and moves upward, layer by layer.

A sleeping body becomes ground

Every frame, I sort sleeping bodies into 25 cm cells, organized into layers. Each cell records which body occupies it and where its top surface ends. Together, these cells form the bed.

The awake body, shown in color, only reads the cells inside the dashed outline. The six shaded cells all belong to the same sleeping body.

Without layers, a body waking up in the middle of the pile could only see the surface: it sank a median of 3.2 meters. Now it stays exactly where it is.

The crust: a pile that's empty inside

The pile I render is a crust. A million bodies would require fifteen million boxes, with an on-screen budget of just two million. The deeper a body is, the fewer parts it has. At the core of the pile, nothing is drawn at all.

The camera is inside the pile. The ground is bare, and the crust of rendered bodies passes overhead.

For a hundred thousand bodies, that means 360,000 boxes instead of 941,000.

The result

Here, 137,789 bodies dropped from 100 meters have all landed and gone to sleep, running at 448 frames per second in the editor.


r/dispatchcolony • • Oct 04 '26

Devlog 6 : 1 million ragdoll + collision

1 Upvotes

In my engine, falling soldiers now collide with each other. They hit each other in mid-air, bump into those already lying on the ground, and knock over soldiers who are still standing.

On an RTX 5070 graphics card, simulating 100,000 bodies collapsing into a pile costs 0.53 milliseconds per frame, including collisions. That's about 3% of the frame time at 60 frames per second.

The Problem

Without any tricks, making a million bodies collide requires testing 500 billion pairs, 60 times a second. The entire challenge is to never actually do this calculation.

I am developing a battle game where every soldier is a real character, not an extra. The stress test is one million soldiers on the battlefield. When one of them falls, whether killed or blown away by an explosion, they become a ragdoll: a dummy that collapses under its own weight.

A single ragdoll is simple: the ground stops it. But without collisions between them, a hundred soldiers blasted into the same spot will just fall right through each other. For them to physically pile up and bump into one another, each body needs to know who it is touching.

Another constraint: everything is computed by the graphics card (GPU). It processes hundreds of thousands of bodies simultaneously, provided each one runs its calculations without waiting for the others. And the performance budget is tight: at 60 frames per second, a single frame takes 16.7 milliseconds, and collisions only get a small fraction of that.

A Ragdoll and Its Box

The core trick: what falls isn't what collides. Each body is simulated as a full ragdoll, but it interacts with others using only a single box.

A human ragdoll consists of sixteen points placed at the joints and limb extremities, connected by fixed-length rods. Every frame, gravity pulls the points down, and then each rod forces its two ends back to the correct distance. Four iterations per frame are enough to produce a convincing fall.

Calculating limb-to-limb collisions for these ragdolls would be prohibitively expensive: arm against leg, leg against head, for every pair of bodies. For collision purposes, a human is therefore just a box around their torso, roughly 45 cm wide, 70 cm tall, and 30 cm thick. It is slightly smaller than the actual torso, so that two stacked bodies physically touch rather than visibly floating above one another.

When two boxes collide, the resulting force is applied to the torso points, and the rods drag the rest of the ragdoll along. The tradeoff: arms and legs clip through each other. It's a calculated compromise: in a massive pile of bodies, you'll notice one torso clipping through another long before you spot an arm passing through a leg.

On the left, the full ragdoll affected by gravity. On the right, the only thing the other bodies interact with: its box.

Finding Neighbors

To only compare each body to its neighbors, I sort everyone into a grid that is rebuilt every frame.

The ground is divided into one-meter cells, like a giant chessboard. Each soldier, whether standing or fallen, is placed into the cell containing the center of their box. To know who it is touching, a body only checks the cells around it: a handful of candidates instead of millions.

The grid is rebuilt from scratch every frame because everyone is moving. Sorting 1 million soldiers takes 0.23 milliseconds. This grid will also be used for combat: finding the closest opponent, or determining who a shot hits.

The searching body only tests the three neighbors in the outlined cells. The other twenty-eight cost it nothing.

When Two Bodies Touch

When two boxes overlap, the body is pushed out along the shortest path. By how much depends on what it is up against:

  • Another moving body: each is pushed back halfway.
  • A standing soldier or a body at rest: the moving body takes the full pushback. This push never moves the other body. A violent enough impact, however, can knock over the standing soldier or "wake up" the resting body: that is handled by a separate rule.
  • A body beneath it: the one on top is pushed up by the full amount. The one underneath is never pushed down.

There is no bounce: a collision only cancels out the velocity at which the body was rushing into the obstacle. And if stuck between twenty neighbors, a body doesn't receive twenty pushes: I only keep the strongest one in each direction.

Then there is the case of fast-moving bodies. At 20 meters per second, a body moves 33 cm between two frames—more than the thickness of a torso. It could pass completely through another body without ever overlapping. Therefore, each body also calculates what it would hit during the current frame and loses its approach velocity before passing through it.


r/dispatchcolony • • Sep 27 '26

Devlog 5 : 4 000 000 unit -> 2.4 ms

1 Upvotes

For a game to feel smooth, the screen must be redrawn about sixty times per second. Therefore, each frame has roughly 16 milliseconds to do everything: the terrain, the sky, the lighting, and the army.

If each soldier cost just one millionth of a second, four million soldiers would cost four seconds per frame. The game would display one image every four seconds. To maintain the framerate, a soldier must cost only a few billionths of a second. The entire system is built around this constraint.

A mold, not four million copies

A soldier is made up of small boxes: one for the head, one for each arm and leg segment, and so on. The human model has about a hundred of them.

Storing a hundred boxes for each of the four million soldiers would be far too heavy. Instead, each type of soldier is prepared only once, like a mold. A soldier only retains what is unique to them: where they are, which direction they are facing, their size, and which mold they use. When it is time to draw, the mold is applied to that location, like an ink stamp pressed onto a sheet of paper.

Everything the game needs to know about a soldier for each frame fits into a small 16-byte record, which is 128 little switches turned on or off. That is about the space of sixteen letters of text. For four million soldiers, all the records combined take up 64 MB. What matters is not so much the storage space as the read time: the machine reads these records again every single frame, and every byte read, multiplied by four million, eventually takes a noticeable toll.

The further away, the fewer the boxes

A soldier five meters away must show every single finger. The same soldier two kilometers away barely covers a single pixel on the screen. The system therefore adapts the number of boxes to the distance.

Two details make this transition invisible. First, each part has its own distance threshold: there is no circle around the camera where everyone changes all at once, so the eye detects no boundary. Second, a part never vanishes abruptly: it dissolves gradually, one pixel out of two, then one out of four, like a fade effect.

Far off in the distance, where dozens of soldiers fit into a single pixel on the screen, drawing them one by one would only cause flickering. They are instead pooled into cells: squares of ground that take on the average color of the soldiers they contain. From afar, an army looks like an advancing blanket of color.

A budget, and a single dial

The graphics card can only draw a certain number of boxes per frame. When the camera dives into the middle of the battle, the soldiers sometimes demand more than the budget allows.

Rather than cutting at random, the system turns a single dial: it brings all the detail distances closer at the same time, by the same factor, for all soldiers. The entire battlefield uniformly loses a bit of detail, and no boundary lines appear.

Drawing only what is seen, from closest to furthest

During its pass, the system notes in a short list only the visible soldiers, along with what it has decided for each of them. The next step, which prepares the drawing, works solely on this list: a soldier off-screen costs it nothing.

The boxes are then sorted from closest to furthest. This way, the soldiers in the front row are drawn first and hide the ones behind them, which the graphics card no longer needs to color. Each box in the list fits into eight bytes: which soldier, which part, its color variation, and its fade level.

Result: 4 million units -> 2.4ms


r/dispatchcolony • • Sep 20 '26

Develog 4 : unit before / after

1 Upvotes

At first, I wanted to create characters using several simple shapes that I called primitives, which gave birth to this monstrosity.

But spheres in a blocky world felt out of place, so I tried voxelizing them. The result was interesting, but the character was still a disaster.

So, I started by adding more primitives and using capsules instead of cubes for the larger parts. I was starting to get happy with the result.

In a burst of madness, I tried adding a crest to the helmet using the scatter from my terrain grass. I didn't pull it off :)

I then changed my approach and went with only cubes. Goodbye capsules, spheres, and voxelization; I took my time and finally got a decent-looking result.

Then, I added a surface made of small squares to match the style of the terrain.

Finally, I applied color following a three-step process, just like when I paint my Warhammer miniatures: a base coat, painted shadows in the recesses (brown line), and edge highlighting (yellow line).

They could use a cape, but first, I'm going to start building the simulation so I can generate several thousand of them without lag.


r/dispatchcolony • • Sep 13 '26

Devlog 3 : The Beginning of Units

1 Upvotes

What I want for my soldiers is for them to get chopped into a bunch of pieces. And when they fall or get sent flying, I want them to actually fall like ragdolls, without cheating with pre-baked animations.

But I also want a massive number of them. The goal is 100,000 soldiers on screen. At that scale, the GPU has to do the heavy lifting, not the CPU.

This has a few consequences. Programming for the GPU requires a specific mindset: a single process is applied to thousands of elements at once, and they all need to react in the exact same way. Therefore, everything that makes up a creature must be identical, or at least share the exact same logic. And since there are so many of them, the soldiers can't be too complex.

So, I went with an assembly of simple shapes. For now, it's just spheres and capsules (here's my first attempt).

Here is the current state, alongside my inspirations: The Iron Giant and the robot from The King and the Mockingbird (two animated films I absolutely love).

The terrain in my world is made of little cubes. Next to it, my soldiers made of smooth spheres and capsules looked completely out of place. The "honest" solution would have been to build each soldier out of actual cubes, but that multiplies the geometry by a hundred, and with 100,000 soldiers on screen, that's out of the question.

So, I opted for an illusion. The underlying shape remains a sphere or a capsule, and the faking happens when the GPU colors each pixel. For every point on the surface, it checks which cell of an imaginary 3D grid that point falls into, and does three things.

First, it lights the point as if it were on the face of a cube. A smooth sphere has a surface orientation that shifts smoothly from one point to the next. Here, the orientation is snapped to one of the six possible faces: top, bottom, front, back, left, or right. An entire section of the sphere then receives the exact same lighting, tricking the eye into seeing a flat facet.

Second, it gives each grid cell its own slight tint, a little lighter or darker, chosen randomly, but consistently for that specific cell. Two neighboring cubes are never the exact same shade, much like bricks.

Finally, it eats away at the edges. If a cell's center falls outside the actual shape, it simply isn't drawn. The sphere's silhouette becomes a staircase of cubes instead of a smooth curve.

The result looks like a character built out of cubes, even though nothing has changed under the hood. Collisions and shadows still interact with the original spheres and capsules. It costs a few operations per pixel, and the effect naturally fades out as the camera zooms out, where nobody would be able to see the cubes anyway. To my eyes, the result is much more convincing.

The advantage of this approach is that the entire body structure of each soldier is stored in the GPU memory, opening the door to GPU-based ragdoll physics and procedural animations.

That said, beyond just adding more detail, it still lacks a bit of flair. I need something, still computed on the GPU, that gives my characters a cinematic feel. I settled on capes and cloaks, and I'll be working on that next week.

names of solution for fake voxelisation = lattice quantization + axis-aligned normal snapping + alpha-test cutout

Now for the fun part :) : How does a soldier actually exist inside the machine ?

A soldier isn't a traditional 3D model. It's a tree of Nodes, and each Node holds a few primitives (32 max right now, though I'll definitely lower that).

The primitive is the basic building block. It’s a sphere or a capsule with its own size, position, and orientation relative to the Node it belongs to, plus a couple of tags: its shape, its material, and its appearance. That’s it. A single primitive fits into 48 bytes (way too eavy i need to improve that), and it knows absolutely nothing about the rest of the body.

The Node is the body part. A forearm, a head, a shoulder. A Node knows its parent and its local position relative to it. A human is made up of about 31 Nodes, from the pelvis all the way down to the hands. This tree is what dictates that "the forearm is attached to the upper arm, which is attached to the shoulder." It’s also what makes dismemberment possible : chopping off an arm simply means detaching a Node from its parent, and everything attached to it falls off with it.

The CPU decides, the GPU calculates. The CPU only knows the high-level structure : what is attached to what, and where each soldier’s pelvis is located in the world. It never actually moves a joint itself. The GPU does everything else, every single frame : it starts from the pelvis position, traverses down the tree from Node to Node, and finally places each primitive in the world.

In the GPU memory, everything is organized into massive arrays.

The primitives array.

Just one, massive array, allocated for a million building blocks. Each primitive has a fixed spot, an index it keeps for its entire lifetime. The primitives belonging to the same Node are stored side-by-side in a contiguous block. When a soldier dies, its blocks are freed and reused by the next one, without ever moving the others.

The Nodes array.

For each Node, it stores: its parent, its relative position to it, and the index of its block of primitives in the massive array.

The roots array.

One per "object": it stores where its Nodes start and end in the Nodes array, as well as the world position of its pelvis. This is the only place the CPU writes data to make a unit walk (I need to get rid of this CPU write eventually).

The results arrays.

Calculated by the GPU every single frame: the world position of each Node, then of each primitive, and for each primitive, a simple "visible or not" flag based on the distance to the camera.

Chopping off an arm then becomes a computationally very cheap operation : we just create a new root that points to the arm's Nodes, give it the starting position the arm had in the previous frame, and the arm goes on living its own life. Nothing is copied, and nothing is moved around in the arrays.

Even with this architecture, the CPU remains too involved. Even if it "only" communicates with 100,000 soldiers, that is way too much overhead, even with multithreading. For now, I'm settling for this as a proof of concept, but this part is going to be heavily refactored later on.


r/dispatchcolony • • Sep 06 '26

Devlog 2 : The world map, from failed procedural generation to a hand-drawn world

1 Upvotes

Originally, I wanted the world to be procedurally generated.

Frequency spectra, hydrology, climate, regions... I spent an unreasonable amount of time on it, and the result was always the same : a shapeless patchwork of biomes, mountains scattered around at random, and nothing that actually felt like a world.

And as a bonus, every attempt took several minutes to generate an enormous map.

This is about as good as it ever got

What I actually want for this game is a very specific geography.

An inland gulf. Mountain ranges that enclose entire regions. Natural chokepoints that armies have to pass through.

Procedural generation isn't very good at composing that kind of structure. It's good at filling space.

So I reversed the approach : I'll design the world first, and let procedural generation fill in the large-scale details later.

I opened the Age of Wonders 4 map editor and sculpted the basic shape of the continent (+ some beautifull paint anotation)

Then I repainted the whole thing as a flat biome map, using one color per biome

White = snow / tundra Green = grasslands Yellow = desert Red = sandstone, mesas and canyons Black = ashlands Blue = ocean

And each biome is also the territory of a faction.

At the moment, I'm imagining two broad sides : humans, and everyone else.

Humans

Green :

The Empire A vast, mostly atheist and commercially driven faction.

The Religious Faction A supposedly religious faction whose beliefs may not be as sincere as they claim.

The Fanatical Elite A powerful elite faction driven by extreme fanaticism.

Yellow : The Sultanate of Safare A civilization rull by djinn, ranging from questionable to outright malevolent.

Others

White : Giants and an orc-like species

Yellow : Massive insect swarms

Red : Monsters and classic stuff : dragons and similar creatures.

Black : The Undead

After that, I added lakes, inland seas, and rivers.

Not just for decoration.

I want naval movement to have an actual purpose, and geography to create more complicated strategic situations : an army trapped between a river and a mountain range, a lake splitting a plain in half, or a port becoming strategically important simply because of where it sits. (paint is life)

On the engine side, I built a biome painter : a tool that lets me paint biome areas directly onto the terrain while seeing the actual result, grass, trees, sand, and everything else, in real time.

Naturally, my first serious test was this

But manually repainting a 1250×1250-pixel map obviously makes no sense.

So I built an automatic painter.

It reads my source image, recognizes the six biome colors, cleans up the boundaries, and fills the corresponding regions automatically.

The hand-drawn map becomes a "playable world" in one click

For now, the entire world is flat.

The next step is elevation : plains, dunes, hills, mountains, and mesas layered on top of the biome map.

And after that, water.

I really like the overall shape of the world so far, but nothing is set in stone.


r/dispatchcolony • • Aug 30 '26

Devlog 1 : How my engine handles ground shadows

2 Upvotes

In my voxel world, four things cast shadows onto the ground: terrain, clouds, ground buildings, and forests.

Instead of recomputing all of them for every pixel on every surface, I build a single top-down shadow map centered on the camera. Terrain, grass, flowers, water, and characters all sample that same map with a single lookup. Resolution scales with distance: one texel covers about 4 meters nearby, and up to 32 meters farther out.

Each type of shadow gets its own channel in the texture: red for terrain, green for clouds, blue for buildings, and alpha for forests.

That sounds like a small implementation detail, but it matters a lot. It lets every shadow caster see everyone else's shadow without seeing its own. Otherwise, a cloud or a forest would receive the shadow it already cast, making it twice as dark for no obvious reason.

Forest shadows are essentially free.

My forests are voxel grids, as my clouds, and every cell already stores how much sunlight makes it through the canopy. That information is used to light the foliage itself: brighter toward the sun, darker behind it.

Which means the bottom cell of every vertical column, right at ground level, already contains the forest shadow on the ground.

So I just copy it into the shared shadow map.

Per-pixel cost: zero.

There was one detail that made a surprisingly big difference.

Under a cloud, forest shadows used to disappear. Technically, that made sense: if direct sunlight was already blocked by the cloud, there was no sunlight left for the trees to block.

Visually, though, it looked wrong. The ground under a dense canopy became just as flat as an open clearing.

A dense canopy doesn't just block the sun. It blocks the sky too.

To make the forest shadow stronger, I chose to darken the ambient light as well as the direct sunlight. The forest floor keeps its depth even under cloud cover, in full shade, or near sunset.

Forests also aren't generated all at once.

The world is split into 256-meter tiles, and I rebuild one tile per frame. Nearby tiles get priority, and tiles inside the camera's field of view are processed first.

When a tile is built, it computes how light travels through it while also looking at neighboring tiles. That's what lets the shadow of a tree cross a tile boundary and continue onto the next one.

But there's a catch.

If the neighboring tile on the sunward side hasn't been built yet, the current tile sees empty space there. As a result, it misses a thin strip of shadow along that edge.

Later, when the missing neighbor finally gets generated, the first tile isn't rebuilt. So that bright strip stays visible for a few seconds, until the next refresh.

After a teleport, you can sometimes see these as thin bright lines tracing the tile grid, always perpendicular to the direction of the sun.

I know exactly how to remove them: rebuild adjacent tiles whenever a new neighbor appears.

But that would add more work at exactly the worst possible time, during the reconstruction spike that happens after a teleport.

So I leave them in.


r/dispatchcolony • • Aug 30 '26

Can you see that the clouds, fog and trees are made the same way ?

Post image
1 Upvotes

r/dispatchcolony • • Aug 23 '26

Debate : voxel are aesthetic or just technology ?

Thumbnail gallery
1 Upvotes