---
id: "cloth-simulation-filter"
title: "Cloth Simulation Filter (CSF) for LiDAR Ground Filtering"
aliases: [CSF]
domain: "capture"
stage: "capture"
realtime: "offline"
platforms: [cpu, python]
year_introduced: 2016
inputs: [point-cloud]
outputs: [point-cloud, heightfield]
style: "photoreal"
dynamic: "static"
cost: "offline"
authority: "Zhang et al., 2016"
url: "https://texelatlas.vercel.app/t/cloth-simulation-filter/"
sources_verified_at: "2026-11-29"
---
# Cloth Simulation Filter (CSF) for LiDAR Ground Filtering (Zhang et al., 2016)

> Separates ground from non-ground points in an airborne LiDAR cloud by inverting the cloud and draping a simulated cloth over it; points near the cloth are ground.

## Reach for it when

- separate ground points from trees and buildings in lidar
- need a terrain model from an airborne point cloud
- remove objects to get bare earth from scan data
- classify ground versus non-ground in photogrammetry points
- ground extraction with few parameters to tune

## How it works

The point cloud is flipped upside down, and a regular grid of cloth particles, connected by springs, is dropped onto it. Each particle moves under gravity until it would touch a LiDAR point beneath it, at which point it stops. Neighbouring particles are pulled toward each other by internal forces that depend on the cloth rigidness, which stops the cloth from falling into small gaps or following buildings and trees. After a fixed number of iterations the cloth approximates the terrain surface. Original points are classified as ground when their distance to the cloth is below a threshold. Only a few parameters are needed: grid resolution, rigidness, time step and the distance threshold.

## When to use it

Choose it when you need a ground/non-ground split of airborne or terrestrial LiDAR or photogrammetric point clouds, for DTM extraction or object removal. Prefer progressive morphological or TIN-densification filters for dense, steep, urban terrain with hand-tuned parameters, and learned segmenters when labels exist.

## Cost

offline — Roughly linear in number of points and grid cells; runs on CPU in seconds to minutes for tiles.
Measured GPU Weight: 10.16× baseline (moderate) — 0.3344 ms median / 0.3355 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 8.32× baseline (moderate) — 0.1323 ms median (2.53× faster on L4).
Ampere A100 scaling: 7.57× baseline (moderate) — 0.2179 ms median (1.53× faster on A100).

## Failure modes

- Steep slopes and terraces get classified as non-ground if rigidness is too high
- Low vegetation and cars are retained as ground when the distance threshold is too loose
- Large flat roofs may be partly absorbed as ground with a soft cloth
- Grid resolution too coarse smooths away small terrain features like ditches

## Dataflow

- Inputs: point-cloud
- Outputs: point-cloud, heightfield
- Platforms: cpu, python

## Presets

### CSF default parameters (json-params; parameter preset)

```json
{
  "cloth_resolution": 0.5,
  "rigidness": 3,
  "time_step": 0.65,
  "class_threshold": 0.5,
  "iterations": 500,
  "slope_smooth": true
}
```

Attribution: Parameter names follow jianboqi/CSF (Apache-2.0); values are the library's commonly used defaults, written for this index.

### Cloth Simulation Filter (CSF) — inverted LiDAR cloth drape (left) vs classified ground & objects (right) (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_RIGIDNESS": 0.72,
  "P_CLASS_THRESH": 0.07,
  "P_SWEEP": 0.45,
  "P_SPLIT": 0.48
}
```

```glsl
const float P_RIGIDNESS = 0.72; // P Cloth Rigidness [0.1, 1.0, 0.02]
const float P_CLASS_THRESH = 0.07; // P Ground Threshold [0.02, 0.16, 0.005]
const float P_SWEEP = 0.45; // P Scan Pan [0.0, 2.0, 0.05]
const float P_SPLIT = 0.48; // P Inverted CSF / Class [0.0, 1.0, 0.02]

float hash11(float x) {
  x = fract(x * 0.1031);
  x *= x + 33.33;
  x *= x + x;
  return fract(x);
}

// True rolling ground elevation y_ground(x)
float groundY(float x) {
  return -0.18 + 0.09 * sin(x * 3.2) + 0.045 * cos(x * 6.5 + 0.7);
}

// Airborne LiDAR surface height including buildings & tree crowns above the ground
float lidarTopY(float x) {
  float g = groundY(x);
  // Building 1
  if (abs(x + 0.42) < 0.13) return g + 0.28;
  // Building 2 (stepped roof)
  if (abs(x - 0.36) < 0.15) return g + 0.24 + 0.06 * step(0.32, x);
  // Tree canopy 1
  float t1 = abs(x + 0.08);
  if (t1 < 0.11) return g + 0.22 * sqrt(max(1.0 - (t1 / 0.11) * (t1 / 0.11), 0.0)) + 0.05 * sin(x * 80.0);
  // Tree canopy 2
  float t2 = abs(x - 0.66);
  if (t2 < 0.09) return g + 0.19 * sqrt(max(1.0 - (t2 / 0.09) * (t2 / 0.09), 0.0));
  return g;
}

// Simulated draped cloth height over inverted LiDAR (stiff cloth bridges over inverted buildings/trees!)
float clothY(float x, float rigid) {
  float g = groundY(x);
  // Low rigidness lets cloth sag slightly into building/tree pits; high rigidness stays tightly bridged on ground
  float sag = (1.0 - rigid) * 0.12;
  float b1 = smoothstep(0.14, 0.0, abs(x + 0.42)) * sag;
  float b2 = smoothstep(0.16, 0.0, abs(x - 0.36)) * sag;
  float tr = smoothstep(0.12, 0.0, abs(x + 0.08)) * sag * 0.8;
  return g + (b1 + b2 + tr);
}

vec3 aces(vec3 x) {
  x = max(x, 0.0);
  return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);
}

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
  float screenX = fragCoord.x / max(iResolution.x, 1.0);
  float split = clamp(P_SPLIT, 0.0, 1.0);
  bool isInverted = screenX < split;
  float rigid = clamp(P_RIGIDNESS, 0.05, 1.0);
  float thresh = clamp(P_CLASS_THRESH, 0.015, 0.20);
  float pan = sin(iTime * 0.45 * max(P_SWEEP, 0.0)) * 0.16;

  // Blueprint engineering grid backdrop
  vec3 col = mix(vec3(0.024, 0.034, 0.056), vec3(0.054, 0.072, 0.112), smoothstep(-0.5, 0.5, uv.y));
  vec2 g1 = abs(fract(uv * 10.0 - 0.5) - 0.5);
  col += vec3(0.018, 0.028, 0.044) * smoothstep(0.035, 0.008, min(g1.x, g1.y));

  // Left half shows the INVERTED LiDAR cloud (y -> -y) with gravity cloth draping down from above!
  // Right half shows the UPRIGHT classified point cloud (cyan = ground, amber/green = non-ground)
  float xWorld = uv.x + pan;
  float yEval = isInverted ? -uv.y : uv.y;

  float cY = clothY(xWorld, rigid);
  float dCloth = abs(yEval - cY);

  // Draw threshold tolerance band around the simulated cloth surface
  float inBand = smoothstep(thresh + 0.004, thresh - 0.004, abs(yEval - cY));
  col = mix(col, vec3(0.12, 0.52, 0.68), inBand * 0.22);

  // Draw the cloth curve + cloth particle nodes
  float clothLine = smoothstep(0.008, 0.002, dCloth);
  float nodeX = fract(xWorld * 18.0 + 0.5) - 0.5;
  float dNode = length(vec2(nodeX / 18.0, yEval - cY));
  float clothNode = smoothstep(0.012, 0.005, dNode);
  vec3 clothCol = isInverted ? vec3(0.98, 0.78, 0.24) : vec3(0.24, 0.88, 0.96);
  col = mix(col, clothCol, max(clothLine * 0.9, clothNode));

  // Render discrete airborne LiDAR return points sampled along x
  float stepX = 0.022;
  float ix = floor(xWorld / stepX);
  for (int k = -1; k <= 1; k++) {
    float cx = (ix + float(k) + 0.5) * stepX;
    float topY = lidarTopY(cx);
    float gY = groundY(cx);
    float clY = clothY(cx, rigid);

    // Primary LiDAR top return point
    float jit = (hash11(ix + float(k) * 1.7) - 0.5) * 0.012;
    float py = topY + jit;
    float distPt = length(vec2(xWorld - cx, yEval - py));
    float ptMask = smoothstep(0.012, 0.004, distPt);
    bool isGroundPt = abs(py - clY) < thresh;
    vec3 ptCol = isGroundPt
      ? vec3(0.18, 0.90, 0.86) // Ground point
      : (py - gY > 0.23 ? vec3(0.98, 0.44, 0.22) : vec3(0.42, 0.92, 0.34)); // Building vs tree
    col = mix(col, ptCol * 1.15, ptMask);

    // Vertical wall / trunk returns for buildings & canopies
    if (topY - gY > 0.08) {
      for (int r = 1; r <= 3; r++) {
        float ry = mix(gY + 0.03, topY - 0.02, float(r) / 4.0) + (hash11(cx * 31.0 + float(r)) - 0.5) * 0.015;
        float dR = length(vec2(xWorld - cx, yEval - ry));
        float mR = smoothstep(0.009, 0.003, dR);
        bool rGrd = abs(ry - clY) < thresh;
        vec3 rCol = rGrd ? vec3(0.18, 0.90, 0.86) : vec3(0.95, 0.58, 0.22);
        col = mix(col, rCol, mR * 0.85);
      }
    }
  }

  // Gravity arrow indicator on left inverted side
  if (isInverted) {
    vec2 aP = uv - vec2(-0.34, 0.30);
    float shaft = smoothstep(0.005, 0.001, abs(aP.x)) * smoothstep(0.07, 0.06, abs(aP.y));
    float head = smoothstep(0.006, 0.001, abs(abs(aP.x) - (aP.y + 0.075) * 0.65)) * step(aP.y, -0.02) * step(-0.08, aP.y);
    col += vec3(0.98, 0.78, 0.24) * max(shaft, head) * 0.85;
  }

  float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));
  col = mix(col, vec3(0.95, 0.97, 1.0), sep);

  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}
```

Attribution: MIT — written for this index.

## Combines with

- [Multi-View Stereo (PatchMatch, COLMAP)](https://texelatlas.vercel.app/t/multi-view-stereo-patchmatch.md): Dense photogrammetric point clouds are filtered by CSF to extract a terrain model.

## Combination ideas

- [Regrow a photographed site](https://texelatlas.vercel.app/ideas/captured-site-revegetation/)

## Sources

1. [primary] Wuming Zhang, Jianbo Qi, Peng Wan, Hongtao Wang, Donghui Xie, Xiaoyan Wang, Guangjian Yan (2016) An Easy-to-Use Airborne LiDAR Data Filtering Method Based on Cloth Simulation. Remote Sensing. https://doi.org/10.3390/rs8060501 (verified via crossref on 2026-11-29)
2. [implementation] jianboqi (2016) jianboqi/CSF. https://github.com/jianboqi/CSF License: Apache-2.0. (verified via github on 2026-11-29)

## Cite this entry

Texel. "Cloth Simulation Filter (CSF) for LiDAR Ground Filtering." https://texelatlas.vercel.app/t/cloth-simulation-filter/ (accessed 2026-12-01).
