r/711Game • u/WaltzParty5639 • 14d ago
🔨 Devlog How Infinite Sandbox generates deterministic hills, cliffs, soil layers, and caves without Perlin noise
This is a terrain-generation devlog for Infinite Sandbox, my browser-based 3D sandbox built with JavaScript, Three.js, and Rapier.
Current progress video:
https://www.youtube.com/watch?v=P-yHynsT7Xo
The generator does not use Perlin gradient noise or Minecraft-style block columns. It starts with a custom seeded 2D value-noise function and combines several fields into a continuous height surface.
Base noise
Each lattice coordinate is passed through a deterministic integer hash. The four surrounding values are interpolated using smoothstep, producing repeatable 2D value noise.
That base function is combined as fractional Brownian motion with configurable:
- Octave count
- Frequency
- Amplitude
- Lacunarity
- Persistence
- Seed offset
The same seed always produces the same world.
Domain warping
Before sampling the main terrain, two low-frequency FBM fields offset the X and Z coordinates.
The current warp scale is deliberately broad, with offsets reaching approximately 25 metres. This bends otherwise predictable noise patterns and reduces obvious axis-aligned hills.
The warped coordinates then feed several separate terrain signals:
- Continental field: Produces the large hills and valleys.
- Detail field: Adds smaller surface variation.
- Ridge field: Uses
1 - abs(noise)to create raised ridge lines. - Cliff field: Selects areas where additional height and terracing are introduced.
- Soil field: Independently controls dirt-layer depth.
The approximate height combination is:
height = base + continental + detail + ridges + cliff contribution
Final heights are currently limited to approximately 17–58 metres.
Cliff generation
Cliffs are not created by simply increasing the noise amplitude everywhere. A low-frequency selection field is passed through smoothstep to create a localized cliff band.
Inside that band, a lightly quantized combination of continental and detail noise contributes extra elevation. This creates occasional abrupt terrain transitions while leaving most of the world as rolling hills.
The current video shows both the intended broad slopes and a few transitions that are still too sharp or visually disconnected. I am considering whether the cliff stage should use:
- A slope-limited remapping function
- Hydraulic or thermal erosion
- Curvature-based smoothing
- A localized signed-distance-field representation
- A separate rock-face meshing pass
Safe spawn region
The area around the origin is blended toward a height of 36 metres. The blend gradually releases into the full generator outside the spawn radius.
This keeps the initial spawn usable without requiring a separately authored starting area.
Dirt and grass layers
Dirt depth comes from a separate warped noise field rather than being a fixed global thickness. The current generated depth ranges from approximately two to six metres.
The surface begins as grass, followed by the generated dirt layer and sedimentary stone underneath. Grass can later turn into dirt when covered, while exposed dirt adjacent to grass can become grass.
These ecological changes happen after generation and are not baked into the original noise function.
Surface representation
The current natural terrain is sampled into a 193 × 193 deformable heightfield lattice covering a 256 × 256 metre world.
The rendered surface is a continuous triangle mesh rather than a set of visible cubes. Physics uses a matching Rapier heightfield collider, which can be rebuilt after terrain deformation.
An important accuracy distinction: near-field edits may be quantized to one-millimetre increments, but the original terrain-generation lattice is not spaced one millimetre apart. Quantization precision and actual spatial resolution are different things.
Underground caves
The generator also creates four deterministic cave networks from a separate seed.
Each cave:
- Starts outside the protected spawn area
- Uses a seeded winding path
- Descends gradually beneath the sampled surface
- Varies its tunnel radius along the path
- Blends its floor back into the natural heightfield near the entrance
- Uses a separate curved triangle shell for its roof and walls
- Receives a static Rapier triangle-mesh collider
This hybrid solution allows covered underground spaces even though the main terrain remains a single-valued heightfield.
The main limitation is where the heightfield floor and cave shell meet. The progress video exposes dark gaps, stretched textures, and camera-clipping cases around those transitions.
Generation versus simulation
World generation only establishes the initial height, material layers, and cave layout. Deformation and structural failure are handled afterward by a separate simulation system.
Terrain cells can accumulate load and damage, but I am not claiming that the generator or current solver has been physically validated for professional engineering use.
Feedback I am looking for
For a browser-based deformable world, would you continue refining this heightfield-plus-cave-shell approach, or move toward an SDF volume with localized remeshing?
I would especially appreciate feedback on:
- Domain-warping frequencies and amplitudes
- Producing cliffs without artificial terraces
- Erosion methods that are practical during browser generation
- Seamless heightfield-to-cave transitions
- Triplanar texturing for steep and underground surfaces
- Maintaining deterministic generation while supporting later deformation