The3DG

Nature · Test cube 15

Stone wall

Big rounded stones of every shape, with deep gaps between them.

Presented by FloNothing in nature repeats exactly. Neither do these. Relax into it.
× 1.00
1.4 mm
135°
  • Prints well with a 0.4 mm nozzle.

25 mm, with your size and depth. Prints upright, no supports. About 4 MB.

Good for

Castles, garden pieces, tabletop terrain.

Print notes

  • Depth 0.4 to 1.5 mm for a 0.4 mm nozzle (as written: 1.4 mm).
  • Best on walls, printed upright. On a flat top, use thin layers (0.12 mm or less).
  • Fade it out over the bottom 3 mm so the first layers are flat and stick to the plate.
  • Not printed yet: these notes come from the geometry. The test cube will tell us more.

The formula

The real code this page runs: give it a point (U mm across, V mm up) and it returns the height there, in mm. Push the surface out by that much and the texture is real geometry.

function stoneWall(U: number, V: number, amp = 1.4) {
  const { d1, d2 } = cells(U, V, 11.0, 5);
  const g = clamp((d2 - d1) / 0.18, 0, 1);
  return amp * g ** 0.5 * (0.75 + 0.25 * dome(clamp(d1 / 0.8, 0, 1) ** 2));
}
The helpers it uses (clamp, dome, cells, rnd)
function clamp(x: number, lo: number, hi: number) {
  return Math.min(Math.max(x, lo), hi);
}
/** A round bump: 1 in the middle (r2 = 0), 0 at the edge (r2 = 1). */
function dome(r2: number) {
  return Math.sqrt(clamp(1 - r2, 0, 1));
}
/** Jittered cells: distance to the nearest and second-nearest cell center (in cells), and the nearest cell's id. */
function cells(U: number, V: number, p: number, k = 1) {
  const x = U / p;
  const y = V / p;
  const xi = Math.floor(x);
  const yi = Math.floor(y);
  let d1 = 9;
  let d2 = 9;
  let id = 0;
  for (const dx of [-1, 0, 1])
    for (const dy of [-1, 0, 1]) {
      const ci = xi + dx;
      const cj = yi + dy;
      const cx = ci + 0.15 + 0.7 * rnd(ci, cj, k);
      const cy = cj + 0.15 + 0.7 * rnd(ci, cj, k + 1);
      const d = Math.hypot(x - cx, y - cy);
      if (d < d1) {
        d2 = d1;
        id = rnd(ci, cj, k + 2);
      } else d2 = Math.min(d2, d);
      d1 = Math.min(d1, d);
    }
  return { d1, d2, id };
}
/** A repeatable random number 0..1 for a cell (no Math.random: the same texture every time). */
function rnd(a: number, b: number, k = 0) {
  const x = Math.sin(a * 127.1 + b * 311.7 + k * 74.7) * 43758.5453;
  return x - Math.floor(x);
}

Printed

Test cube 15 is waiting for the printer. Its photo goes here.