W3: Chunked terrain mesh, collision and LOD
TerrainView draws the island as 16 x 16 chunks of 64 m, each at one of four detail levels (2, 4, 8 and 16 m spacing) chosen by distance to the camera. TerrainChunkBuilder builds chunk geometry on WorkerThreadPool threads; the main thread only uploads finished meshes, within a 2 ms per-frame budget, nearest chunks first. - Seams: every chunk hangs skirts deeper than twice the most any level strays from the full-resolution edge, so neighbours at any two levels meet without a crack. Normals come from the full-resolution heightfield at every level, and back faces light like the ground above them. - Splat material: a procedural shader blends sand, marsh, grass and rock with weights from the island's bands, averaged over 4 m so borders blend. Steep ground turns to rock and summits weather pale. - Collision stays SimGround's heightfield, with no renderer involved. - Capture scenarios terrain, terrain_lod (tinted by level) and terrain_cracks (magenta sky). tools/crack_check.gd counts sky pixels seen through the ground; make terrain-capture requires cracks in a skirtless control and none in the real terrain. Tests: chunk vertices sit on the heightfield; skirts cover every pairing of levels on sampled shared edges; detail falls with distance; flying across the island at 30 m/s for 2,037 frames streams 661 chunk rebuilds with the worst main-thread frame at 0.8 to 1.4 ms (headless, CPU only); 24 players over 900 ticks on two generated islands never sink into the ground, and a player sprints up towards a summit unharmed. make terrain-capture: control 437 crack pixels, terrain 0. Closes #10 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -120,11 +120,26 @@ sent on a reliable ordered event stream, since a dropped wall is a gameplay lie.
|
||||
| `src/audio/` | Sound playback, music | `src/sim/` (read only) |
|
||||
| `src/app/` | Startup and mode selection | Everything |
|
||||
|
||||
## Terrain
|
||||
|
||||
The island's heightfield (`Island`, in `src/sim/`) is the only terrain collision, on
|
||||
the server and in client prediction. Nothing in the renderer is ever used for collision.
|
||||
|
||||
The client draws it with `TerrainView` (`src/client/terrain/`): 64 m chunks at four
|
||||
levels of detail chosen by distance to the camera. `TerrainChunkBuilder` builds chunk
|
||||
geometry on `WorkerThreadPool` threads, and the main thread only uploads finished meshes,
|
||||
within a per-frame budget. Each chunk hangs skirts from its edges deeper than any two
|
||||
levels can disagree, so a level boundary never opens a crack. Normals come from the
|
||||
full-resolution heightfield at every level, so lighting doesn't change across a boundary.
|
||||
The terrain shader blends procedural sand, marsh, grass and rock layers using splat
|
||||
weights from the island's elevation bands, with rock on steep ground.
|
||||
|
||||
## Performance budgets
|
||||
|
||||
| Budget | Target |
|
||||
|---|---|
|
||||
| Server tick | Under **12 ms** with 24 players |
|
||||
| Client | **60 fps** on a GTX 1060-class GPU at medium settings |
|
||||
| Terrain streaming | Under **8 ms** of main-thread work in any frame (measured headless; GPU upload unmeasured) |
|
||||
|
||||
Software rendering in CI can't verify the client budget. It needs a real GPU playtest.
|
||||
|
||||
Reference in New Issue
Block a user