Terrain Sculpting in BufferGeometry: Laplacian Smoothing, LERP, and Thermal Erosion Simulation

Core Concept – Laplacian Smoothing in Terrain Systems


In a grid-based BufferGeometry system, terrain is represented as a dense mesh of vertices arranged in a structured grid. When sculpting operations are applied, these vertices often become uneven and noisy, creating unnatural spikes or sharp transitions. Laplacian smoothing addresses this by repositioning each vertex toward the average of its neighboring vertices, effectively reducing local variation and producing a more stable surface.


https://www.udemy.com/course/web-based-3d-terrain-industrial-printing-engine-mastery/


Understanding Vertex Relaxation

In a grid-based BufferGeometry, terrain is represented as a structured mesh of vertices. When sculpting is applied, these vertices become uneven, producing noise-like distortions.

Laplacian smoothing reduces this irregularity by moving each vertex toward the average height of its neighboring vertices.

In height-based terrain systems, this primarily affects the Y-axis (height values), producing more natural and organic landscapes.

This process mimics physical relaxation in real materials, where energy differences gradually stabilize over time.


Vertex Interpolation (LERP) for Smooth Transitions

Instead of instantly snapping vertices to their smoothed state, real-time systems use Linear Interpolation (LERP) to create gradual transitions.

Formula:

V_new = V_current + (V_target - V_current) × Strength

This approach ensures:

  • Smooth sculpting transitions
  • Continuous animation feel
  • No sudden geometric jumps
  • GPU-friendly incremental updates

LERP is what transforms a mathematical operation into an interactive sculpting experience.


Trainee Assignments – Core Implementation Exercises

Task 1 – Falloff Curve Experiment

The brush system uses a quadratic falloff function:

Math.pow(1 - dist / size, 2)

Your Task

  • Replace 2 with 0.5
  • Then replace 2 with 6

What You Should Observe

  • 0.5 → wide, soft dome influence, very gradual falloff
  • 6 → tight, sharp peak influence, extreme central concentration

Key Insight

Falloff defines influence distribution across space, not total deformation strength.


Task 2 – Implement Average-Based Smoothing

Current smoothing logic may rely on a fixed reference point (such as mouse intersection height).

Your Task

Modify the logic so that:

  • The target height is computed from vertex data itself
  • Specifically: average height of all vertices inside brush radius

Conceptual Steps

  • Collect nearby vertices
  • Sum their height values
  • Divide by count
  • Use result as smoothing target

Objective

This teaches local neighborhood averaging, the foundation of Laplacian smoothing in height-field systems.


Assessment Questions – Understanding the System

Question 1 – The Spike Problem

Why does smoothing fail on low-resolution terrain grids (e.g. 20×20)?

Low-resolution grids suffer from:

  • Large spacing between vertices
  • Poor gradient representation
  • Insufficient interpolation points

This results in blocky, unnatural terrain deformation instead of smooth hills.


Question 2 – Falloff vs Strength

Brush Strength controls how much a vertex moves per update.

Brush Falloff controls how far the brush influence extends spatially.

Interaction:

  • Falloff defines who is affected
  • Strength defines how strongly they are affected

Together they determine the final sculpting shape and intensity distribution.


Question 3 – Real-Time Performance Optimization

Why use Float32Array instead of directly updating geometry each frame?

Because it:

  • Avoids repeated object allocation
  • Reduces garbage collection pressure
  • Enables fast sequential memory writes
  • Allows batched GPU updates

The final step:

geometry.attributes.position.needsUpdate = true

sends a single optimized update signal instead of continuous micro-updates.


Advanced Challenge – Thermal Erosion System Design

Concept Overview

Standard smoothing modifies terrain shape but does not preserve total material volume.

Thermal erosion simulates physical sediment movement:

  • Material moves from steep slopes
  • Accumulates in valleys
  • Preserves total terrain volume

Volume Conservation Concept

To track volume:

  • Compute initial sum of all heights
  • Track all removed and deposited material during updates
  • Ensure final sum remains approximately constant

Key Idea:

Total terrain “mass” should remain stable:

  • Peaks lose material
  • Valleys gain material
  • System reaches equilibrium over time

Sediment Redistribution Strategy

For each vertex:

  • Measure slope difference with neighbors
  • If slope is too steep:
  • Remove height (sediment)
  • Distribute sediment to lower neighbors

This creates realistic geological behavior similar to natural erosion.


Practical Implementation Structure

Recommended buffers:

  • Height buffer (Float32Array)
  • Sediment buffer (temporary transfer storage)
  • Optional global volume tracker

This enables:

  • Local realism (per vertex updates)
  • Global consistency (volume conservation)
  • Stable long-running simulations

Final Insight

Laplacian smoothing is the foundation of terrain relaxation systems. When extended with interpolation (LERP) and sediment redistribution, it evolves into a full procedural geology simulation model capable of producing highly realistic landscapes in real time.