Texel A field guide to 3D techniques

Real-time snow and terrain deformation × Surfel-Based Global Illumination (GIBS)

Dynamic surfel GI inside carved snow trenches and footprints. Deep footprints, vehicle tracks, and plowed snow berms dynamically shift real-time bounce lighting — casting cool blue sky-filled shadows inside fresh trenches and warm sunlight bounce off steep compressed snow walls.

Open in StudioReproduced91.8× · 2.84 ms

Real-time snow and terrain deformationSimulation · Real-timein: heightfield, depthout: heightfield, normalscompositeSurfel-Based Global Illumination (GIBS)Lighting · Real-timein: gbuffer, depth, meshout: radiance, irradiance-probes

Verified proof

reproduced · 2026-12-01texel-lablicense MIT
Specimen render of Deformed snow + dynamic surfel GI (left: static ambient snow trench, right: dynamic surfel sky/warm bounce)
Cross-proof specimen. Deformed snow + dynamic surfel GI (left: static ambient snow trench, right: dynamic surfel sky/warm bounce). Verified WebGL2 proof · 2026-12-01

Split-screen WebGL2 proof comparing carved snow trenches with static flat ambient lighting (left) against dynamically updated surfel GI disks that re-orient onto freshly stamped snow walls to inject cool blue sky-cavity bounce and warm golden sunlight inter-reflection (right).

Chromium Headless ANGLE/SwiftShader WebGL2 · 512x512 · updates terrain-anchored GI surfels dynamically on carved snow trenches for vivid blue cavity shading and warm sunlight sidewall bounce

Show GLSL proof (182 lines)
const float P_TRENCH_DEPTH = 0.34; // P Trench Depth [0.1, 0.55, 0.02]
const float P_SURFEL_BOUNCE = 1.25; // P Surfel GI Gain [0.2, 2.2, 0.05]
const float P_SURFEL_VIS = 0.22; // P Surfel Disk Overlay [0.0, 1.0, 0.05]
const float P_SUN_ANGLE = 0.38; // P Low Sun Angle [0.15, 0.85, 0.03]

float hash21(vec2 p) {
  p = fract(p * vec2(127.1, 311.7));
  p += dot(p, p + 34.5);
  return fract(p.x * p.y);
}

float vnoise(vec2 p) {
  vec2 i = floor(p);
  vec2 f = fract(p);
  vec2 u = f * f * (3.0 - 2.0 * f);
  return mix(
    mix(hash21(i), hash21(i + vec2(1.0, 0.0)), u.x),
    mix(hash21(i + vec2(0.0, 1.0)), hash21(i + vec2(1.0, 1.0)), u.x),
    u.y
  );
}

// Deformed snow heightfield with curving carved sled/boot trench + raised rim berms
float snowHeight(vec2 p, float t, out float trenchMask) {
  float drift = 0.14 * sin(p.x * 0.8 + 0.5) * cos(p.y * 0.7) + 0.05 * vnoise(p * 2.4);
  // Curving path centerline
  float curveX = 0.55 * sin(p.y * 0.75 + t * 0.25);
  float distCurve = abs(p.x - curveX);
  // Individual stepping footprint indentations along path
  float stepWave = 0.78 + 0.22 * sin(p.y * 5.2 - t * 1.4);
  float carve = exp(-pow(distCurve / 0.34, 2.6)) * P_TRENCH_DEPTH * stepWave;
  // Displaced snow berms pushed up along both edges of the trench
  float berm = exp(-pow((distCurve - 0.44) / 0.18, 2.0)) * (P_TRENCH_DEPTH * 0.42) * stepWave;
  trenchMask = clamp(carve / max(P_TRENCH_DEPTH, 1e-4), 0.0, 1.0);
  return drift - carve + berm;
}

vec3 snowNormal(vec2 p, float t) {
  float e = 0.022;
  float m;
  float hx = snowHeight(p + vec2(e, 0.0), t, m) - snowHeight(p - vec2(e, 0.0), t, m);
  float hz = snowHeight(p + vec2(0.0, e), t, m) - snowHeight(p - vec2(0.0, e), t, m);
  return normalize(vec3(-hx, 2.0 * e, -hz));
}

// Evaluate dynamic terrain-anchored surfel GI by gathering 6 oriented neighbor surfels around wp
vec3 evalSurfelGI(vec3 wp, vec3 N, vec3 sunDir, vec3 lanternPos, float t) {
  vec3 accum = vec3(0.0);
  float wSum = 1e-4;
  vec2 offs[6];
  offs[0] = vec2(0.32, 0.0);
  offs[1] = vec2(-0.32, 0.0);
  offs[2] = vec2(0.16, 0.28);
  offs[3] = vec2(-0.16, -0.28);
  offs[4] = vec2(-0.16, 0.28);
  offs[5] = vec2(0.16, -0.28);

  for (int i = 0; i < 6; i++) {
    vec2 sXZ = wp.xz + offs[i];
    float tm;
    float sY = snowHeight(sXZ, t, tm);
    vec3 sPos = vec3(sXZ.x, sY, sXZ.y);
    vec3 sN = snowNormal(sXZ, t);
    vec3 toSurfel = sPos - wp;
    float dist2 = max(dot(toSurfel, toSurfel), 0.04);
    vec3 dir = toSurfel / sqrt(dist2);
    // Form factor between receiver normal and oriented deformed surfel disk
    float ff = max(dot(N, dir), 0.0) * max(dot(sN, -dir), 0.0) / (dist2 + 0.14);
    // Direct illumination held in the surfel: golden low sun + warm camp lantern
    float sSun = max(dot(sN, sunDir), 0.0);
    vec3 toLantern = lanternPos - sPos;
    float lDist2 = max(dot(toLantern, toLantern), 0.12);
    float sLant = max(dot(sN, toLantern / sqrt(lDist2)), 0.0) / lDist2;
    vec3 surfelRad = vec3(1.15, 0.82, 0.52) * sSun * 1.45 + vec3(1.6, 0.58, 0.18) * sLant * 0.85;
    accum += surfelRad * ff;
    wSum += ff;
  }
  return accum * P_SURFEL_BOUNCE;
}

vec3 acesTone(vec3 x) {
  return clamp((x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14), 0.0, 1.0);
}

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
  vec2 res = max(iResolution.xy, vec2(1.0));
  vec2 uvN = fragCoord / res;
  float splitX = iMouse.z > 0.0 ? clamp(iMouse.x / res.x, 0.05, 0.95) : 0.5;
  bool useSurfelGI = uvN.x > splitX;

  vec2 p = (fragCoord - 0.5 * res) / res.y;
  float t = iTime;
  vec3 ro = vec3(0.15, 1.65, -2.65);
  vec3 ta = vec3(0.0, -0.08, 0.65);
  vec3 fw = normalize(ta - ro);
  vec3 ri = normalize(cross(vec3(0.0, 1.0, 0.0), fw));
  vec3 up = cross(fw, ri);
  vec3 rd = normalize(fw * 1.55 + ri * p.x + up * p.y);

  vec3 sunDir = normalize(vec3(0.82, P_SUN_ANGLE, 0.36));
  vec3 lanternPos = vec3(-0.78, 0.38, 0.45);
  vec3 sky = mix(vec3(0.55, 0.66, 0.82), vec3(0.16, 0.28, 0.52), clamp(rd.y * 2.0 + 0.2, 0.0, 1.0));
  vec3 col = sky;

  float dist = 0.2;
  bool hit = false;
  float hitTrench = 0.0;
  for (int i = 0; i < 68; i++) {
    vec3 q = ro + rd * dist;
    float tm;
    float h = snowHeight(q.xz, t, tm);
    float d = q.y - h;
    if (d < 0.005) {
      hit = true;
      hitTrench = tm;
      break;
    }
    dist += max(d * 0.55, 0.02);
    if (dist > 18.0) break;
  }

  // Also ray-test glowing warm amber beacon sphere beside the trench
  vec3 oc = ro - lanternPos;
  float lb = dot(oc, rd);
  float lh = lb * lb - (dot(oc, oc) - 0.12 * 0.12);
  float tLantern = lh > 0.0 ? (-lb - sqrt(lh)) : -1.0;

  if (tLantern > 0.0 && (!hit || tLantern < dist)) {
    col = vec3(2.8, 1.25, 0.45);
  } else if (hit) {
    vec3 wp = ro + rd * dist;
    vec3 N = snowNormal(wp.xz, t);
    vec3 V = -rd;

    // Self-shadow test along low sun ray against raised snow berms
    float shadow = 1.0;
    for (int s = 1; s <= 6; s++) {
      float sd = float(s) * 0.14;
      vec3 sp = wp + sunDir * sd;
      float sm;
      float sh = snowHeight(sp.xz, t, sm);
      if (sh > sp.y + 0.01) shadow = min(shadow, 0.18);
    }

    float ndl = max(dot(N, sunDir), 0.0) * shadow;
    // Crisp snow micro-sparkle glints
    float sparkle = pow(hash21(floor(wp.xz * 42.0)), 18.0) * ndl * 1.4;
    // Compressed trench snow has slightly denser ice-blue subsurface tint
    vec3 snowAlb = mix(vec3(0.92, 0.94, 0.98), vec3(0.76, 0.86, 0.96), hitTrench * 0.65);

    vec3 toL = lanternPos - wp;
    float lD2 = max(dot(toL, toL), 0.1);
    float lDirect = max(dot(N, toL / sqrt(lD2)), 0.0) / lD2;

    if (!useSurfelGI) {
      // Left baseline: flat static ambient light misses trench cavity sky-blue & sidewall bounce
      vec3 direct = vec3(1.18, 0.92, 0.68) * ndl + vec3(1.3, 0.55, 0.20) * lDirect * 0.45;
      col = snowAlb * (vec3(0.24, 0.26, 0.30) + direct) + vec3(sparkle);
    } else {
      // Right: dynamic surfel GI adds cool sky cavity fill + warm sunlit berm & lantern bounce
      float skyVis = clamp(0.5 + 0.5 * N.y - hitTrench * 0.38, 0.15, 1.0);
      vec3 skyFill = mix(vec3(0.11, 0.24, 0.54), vec3(0.26, 0.42, 0.68), skyVis) * (0.55 + 0.45 * hitTrench);
      vec3 bounce = evalSurfelGI(wp, N, sunDir, lanternPos, t);
      vec3 direct = vec3(1.22, 0.90, 0.62) * ndl + vec3(1.5, 0.60, 0.20) * lDirect * 0.55;
      col = snowAlb * (skyFill + direct + bounce) + vec3(sparkle);

      // Optional surfel disk placement debug overlay
      if (P_SURFEL_VIS > 0.01) {
        vec2 sCell = fract(wp.xz * 3.2) - 0.5;
        float disk = smoothstep(0.38, 0.31, length(sCell));
        float ring = smoothstep(0.05, 0.01, abs(length(sCell) - 0.34));
        col = mix(col, mix(vec3(0.25, 0.78, 0.95), vec3(1.0, 0.72, 0.32), ndl), (ring * 0.65 + disk * 0.12) * P_SURFEL_VIS);
      }
    }
    float fog = 1.0 - exp(-dist * 0.055);
    col = mix(col, sky, clamp(fog, 0.0, 1.0));
  }

  col = acesTone(col * 1.06);
  if (abs(fragCoord.x - splitX * res.x) < 1.0) col = vec3(0.95, 0.93, 0.89);
  fragColor = vec4(pow(clamp(col, 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}

Why they connect

Real-time snow and terrain deformation outputs a continuously updated snow heightfield and reconstructed terrain normals stamped by moving actors. The hop to Surfel-Based Global Illumination (GIBS) is composite: whenever a heightfield tile is stamped, update the world-space positions, normals, and compressed-snow albedos of surfels residing in that spatial hash cell (and spawn fresh surfels along steep newly exposed trench walls). Surfel-Based Global Illumination (GIBS) traces short hemisphere rays per surfel against the displaced heightfield and nearby scene geometry, exponentially blending irradiance so indirect blue bounce and colored torchlight respond immediately to freshly carved snow.

How to build it

Maintain a 2D ping-pong snow heightfield texture updated by orthographic depth stamps of moving feet or wheels, adding raised rim displacement around compressed basins. Tessellate or ray-march the snow terrain into the primary G-buffer with normals derived via central differences. Partition world space into a uniform surfel hash grid anchored to the terrain: mark tiles touched by the deformation brush as dirty, lift or depress surfels onto the new heightfield elevation, and reorient their disk normals. Trace 8-16 stochastic rays per active surfel against the heightfield mip hierarchy and dynamic lights, then gather weighted surfel irradiance during deferred snow shading.

Field marks

  1. Surfels parked on flat snow before a deep trench is carved can end up floating above or buried below the surface if dirty-tile updates lag by even a frame.
  2. High-albedo snow (>0.85 reflectance) amplifies multi-bounce feedback instability unless surfel energy conservation and temporal clamping are enforced.
  3. Sharp footprint sidewalls smaller than the surfel radius suffer light leaking across thin ridges.
  4. Camera-centered clipmap recentering of the snow heightfield must preserve surfel world coordinates without wiping accumulated GI history.

Prior art

No prior art found on 2026-12-01.

Searches run (2)
  • arXiv: all:"snow deformation" AND all:"surfel"
  • GitHub repos: "snow deformation" "surfel gi"