Texel A field guide to 3D techniques

Visibility Bitmask Ambient Occlusion × Radiance Cascades

A thin-occluder cascade zero. Screen-space radiance cascades whose short-range interval is gathered with visibility bitmasks, so thin occluders and the gaps between them stop being treated as infinitely thick, while the coarse cascades carry distant light.

Open in StudioReproduced254× · 7.88 ms

Visibility Bitmask Ambient OcclusionVisibility · Real-timein: depth, normalsout: visibility-mask, radianceradianceRadiance CascadesLighting · Real-timein: sdf, gbuffer, radianceout: radiance

Verified proof

reproduced · 2026-12-01texel-lablicense MIT
Specimen render of Bitmask cascade zero (left: thick depth-marched RC0, right: finite-thickness visibility bitmask + coarse cascades)
Cross-proof specimen. Bitmask cascade zero (left: thick depth-marched RC0, right: finite-thickness visibility bitmask + coarse cascades). Verified WebGL2 proof · 2026-12-01

Split-screen WebGL2 proof comparing naive infinitely-thick depth-marched cascade 0 (left, blacking out distant light behind thin railing slats and floating bars) against finite-thickness visibility-bitmask near-field gathering whose unset-sector transmittance multiplies merged coarse radiance cascades (right).

Chromium Headless ANGLE/SwiftShader WebGL2 · 512x512 · eliminates false over-occlusion behind thin slats and preserves gap transmission into merged coarse cascades while retaining contact AO

Show GLSL proof (204 lines)
const float P_THICKNESS = 0.085; // P Occluder Thickness [0.02, 0.35, 0.005]
const float P_CASCADE_BLEND = 1.15; // P Coarse Cascade Gain [0.2, 2.5, 0.05]
const float P_BITMASK_RANGE = 0.26; // P Near-Field Radius [0.08, 0.45, 0.01]
const float P_LIGHT_SWING = 1.00; // P Emitter Sweep [0.0, 2.0, 0.05]

float sdBox(vec2 p, vec2 b) {
  vec2 q = abs(p) - b;
  return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0);
}

// Returns (depth, isThinOccluder) for an architectural bay with solid walls + thin louver slats and balustrade bars
vec2 evalSceneDepth(vec2 p) {
  // Back wall depth = 1.0, floor/ceiling alcoves closer
  float dWall = 0.92;
  // Solid architectural pillar on outer edge
  float pillar = sdBox(p - vec2(0.0, -0.34), vec2(0.46, 0.07));
  float roof = sdBox(p - vec2(0.0, 0.37), vec2(0.46, 0.06));
  float solid = min(pillar, roof);
  // Thin vertical balustrade railings / slats in foreground plane (depth = 0.34)
  float slats = 1e5;
  for (int i = -3; i <= 3; i++) {
    float sx = float(i) * 0.062;
    float bar = sdBox(p - vec2(sx, -0.04), vec2(0.010, 0.22));
    slats = min(slats, bar);
  }
  // Thin horizontal louver shelf bars
  float shelf1 = sdBox(p - vec2(0.0, 0.14), vec2(0.24, 0.009));
  float shelf2 = sdBox(p - vec2(0.0, -0.18), vec2(0.22, 0.009));
  float thin = min(slats, min(shelf1, shelf2));
  // Center floating ring prop
  float ring = abs(length(p - vec2(0.0, 0.02)) - 0.115) - 0.011;
  thin = min(thin, ring);
  // Back sculptural ribs at depth 0.72
  float backRib = sdBox(p - vec2(-0.18, 0.02), vec2(0.032, 0.25));
  float backRib2 = sdBox(p - vec2(0.18, 0.02), vec2(0.032, 0.25));
  float mid = min(backRib, backRib2);
  if (solid < 0.0) return vec2(0.20, 0.0);
  if (thin < 0.0) return vec2(0.36, 1.0);
  if (mid < 0.0) return vec2(0.68, 0.0);
  // Sloped alcove floor gradient
  float alcove = dWall - 0.14 * smoothstep(0.10, 0.36, abs(p.y));
  return vec2(alcove, 0.0);
}

vec3 evalEmissive(vec2 p, float t) {
  float swing = sin(t * 0.85) * 0.14 * P_LIGHT_SWING;
  float swing2 = cos(t * 0.65) * 0.12 * P_LIGHT_SWING;
  // Warm amber sky window moving behind the thin slats
  vec2 lWarm = vec2(-0.12 + swing, 0.08 + swing2 * 0.5);
  float dW = length(p - lWarm);
  vec3 warm = vec3(3.6, 1.55, 0.42) * exp(-dW * dW * 38.0);
  // Cool cyan architectural strip on the opposite side
  vec2 lCool = vec2(0.14 - swing * 0.8, -0.06 - swing2 * 0.6);
  float dC = length(p - lCool);
  vec3 cool = vec3(0.32, 2.05, 3.25) * exp(-dC * dC * 42.0);
  // Subtle magenta rim bounce along top cornice
  float dM = abs(p.y - 0.29) + max(abs(p.x) - 0.22, 0.0);
  vec3 mag = vec3(1.65, 0.32, 1.10) * exp(-dM * 26.0);
  return warm + cool + mag;
}

// Coarse cascades 1+2: distant radiance field (smooth low-frequency directional radiance)
vec3 evalCoarseCascade(vec2 p, vec2 dir, float t) {
  vec3 acc = vec3(0.03, 0.04, 0.065);
  for (int c = 1; c <= 2; c++) {
    float rStart = P_BITMASK_RANGE * (c == 1 ? 0.95 : 2.1);
    float stepLen = c == 1 ? 0.055 : 0.11;
    float w = c == 1 ? 0.62 : 0.48;
    for (int s = 0; s < 5; s++) {
      float dist = rStart + (float(s) + 0.5) * stepLen;
      vec2 q = p + dir * dist;
      if (abs(q.x) > 0.48 || abs(q.y) > 0.46) break;
      vec3 em = evalEmissive(q, t);
      acc += em * w / (1.0 + 4.8 * dist * dist);
    }
  }
  return acc * P_CASCADE_BLEND;
}

// Pure float visibility bitmask (16 angular elevation sectors encoded across 4 vec4s) vs infinite-thickness depth march
void traceCascadeZero(vec2 p, float z0, vec2 dir, float t, bool useBitmask, out vec3 nearRad, out float transmittance) {
  nearRad = vec3(0.0);
  vec4 maskA = vec4(0.0);
  vec4 maskB = vec4(0.0);
  vec4 maskC = vec4(0.0);
  vec4 maskD = vec4(0.0);
  float maxElev = -1.0;
  const int STEPS = 10;
  float dt = P_BITMASK_RANGE / float(STEPS);
  for (int i = 1; i <= STEPS; i++) {
    float r = float(i) * dt;
    vec2 q = p + dir * r;
    if (abs(q.x) > 0.48 || abs(q.y) > 0.46) break;
    vec2 sc = evalSceneDepth(q);
    float dzFront = z0 - sc.x;
    if (dzFront > 0.002) {
      float hFront = atan(dzFront, r) / 1.5707963;
      if (!useBitmask) {
        // Left: plain depth-marched cascade 0 treats any closer depth sample as infinitely thick
        if (hFront > maxElev) {
          float deltaVis = clamp(hFront - max(maxElev, 0.0), 0.0, 1.0);
          nearRad += (evalEmissive(q, t) * 0.42 + vec3(0.03, 0.035, 0.045)) * deltaVis;
          maxElev = hFront;
        }
      } else {
        // Right: finite thickness slab projects an angular interval [hBack, hFront] into 16 visibility sectors
        float effThick = sc.y > 0.5 ? P_THICKNESS * 0.55 : P_THICKNESS * 2.8;
        float dzBack = dzFront - effThick;
        float hBack = atan(dzBack, r) / 1.5707963;
        float a0 = clamp(hBack, 0.0, 1.0) * 16.0;
        float a1 = clamp(hFront, 0.0, 1.0) * 16.0;
        if (a1 > a0 + 0.01) {
          float newlyLit = 0.0;
          for (int b = 0; b < 16; b++) {
            float fb = float(b) + 0.5;
            float hit = smoothstep(a0 - 0.35, a0 + 0.35, fb) * (1.0 - smoothstep(a1 - 0.35, a1 + 0.35, fb));
            if (hit > 0.01) {
              float prev = 0.0;
              if (b < 4) prev = maskA[b];
              else if (b < 8) prev = maskB[b - 4];
              else if (b < 12) prev = maskC[b - 8];
              else prev = maskD[b - 12];
              float addBit = clamp(hit * (1.0 - prev), 0.0, 1.0);
              newlyLit += addBit;
              float nv = clamp(prev + hit, 0.0, 1.0);
              if (b < 4) maskA[b] = nv;
              else if (b < 8) maskB[b - 4] = nv;
              else if (b < 12) maskC[b - 8] = nv;
              else maskD[b - 12] = nv;
            }
          }
          // Gather near-field bounce radiance through newly set bits only
          vec3 surfBounce = evalEmissive(q, t) * 0.65 + vec3(0.045, 0.055, 0.075);
          nearRad += surfBounce * (newlyLit / 16.0);
        }
      }
    }
  }
  if (!useBitmask) {
    // Infinite thickness blocks everything below maxElev
    transmittance = clamp(1.0 - max(maxElev, 0.0) * 1.18, 0.0, 1.0);
  } else {
    float occBits = dot(maskA, vec4(1.0)) + dot(maskB, vec4(1.0)) + dot(maskC, vec4(1.0)) + dot(maskD, vec4(1.0));
    transmittance = clamp(1.0 - occBits / 16.0, 0.0, 1.0);
  }
}

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 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
  bool useBitmask = uv.x > 0.0;
  // Mirror both halves onto identical architectural bay coordinates so left vs right compare 1:1
  vec2 p = vec2(useBitmask ? (uv.x - 0.25) : (uv.x + 0.25), uv.y);
  p.x *= 1.85;
  vec2 sc = evalSceneDepth(p);
  float z0 = sc.x;
  vec3 albedo = vec3(0.72, 0.70, 0.67);
  if (z0 < 0.25) albedo = vec3(0.24, 0.25, 0.29);
  else if (sc.y > 0.5) albedo = vec3(0.42, 0.45, 0.50);
  else if (z0 < 0.72) albedo = vec3(0.56, 0.53, 0.50);
  // Subtle architectural masonry grid on back wall
  float grid = smoothstep(0.94, 0.99, max(abs(sin(p.x * 38.0)), abs(sin(p.y * 38.0))));
  albedo *= (1.0 - 0.12 * grid);

  const int DIRS = 12;
  vec3 gi = vec3(0.0);
  float visSum = 0.0;
  for (int i = 0; i < DIRS; i++) {
    float ang = (float(i) + 0.5) * 6.2831853 / float(DIRS) + 0.13;
    vec2 dir = vec2(cos(ang), sin(ang));
    vec3 nearRad;
    float trans;
    traceCascadeZero(p, z0, dir, iTime, useBitmask, nearRad, trans);
    vec3 coarseRad = evalCoarseCascade(p, dir, iTime);
    // Merge cascade 0 (near bitmask) + transmittance * coarser cascades
    gi += nearRad + trans * coarseRad;
    visSum += trans;
  }
  gi /= float(DIRS);
  float ao = visSum / float(DIRS);

  // Direct emitters visible on back wall plane
  vec3 em = evalEmissive(p, iTime);
  vec3 col = albedo * gi * 1.45;
  if (z0 > 0.74) {
    col += em * 0.42;
  } else if (sc.y > 0.5) {
    // Crisp rim highlight on thin railings from merged cascades
    col += gi * vec3(0.55, 0.58, 0.65) * 0.48 + vec3(0.05, 0.06, 0.08) * ao;
  }
  // Subtle inset bar at bottom showing raw cascade-0 transmittance (AO)
  if (uv.y < -0.405) {
    col = vec3(ao * ao * 1.15);
    if (useBitmask) col = mix(vec3(0.06, 0.12, 0.22), vec3(0.96, 0.84, 0.58), ao);
    else col = mix(vec3(0.05, 0.05, 0.07), vec3(0.76, 0.78, 0.82), ao);
  }
  col = acesTone(col);
  if (abs(uv.y + 0.405) < 0.0025) col = vec3(0.85, 0.84, 0.80);
  if (abs(uv.x) < 0.003) col = vec3(0.96, 0.94, 0.88);
  fragColor = vec4(pow(clamp(col, 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}

Why they connect

Visibility Bitmask Ambient Occlusion marches the depth buffer and marks occupied angular sectors as bits, outputting a visibility-mask and near-field radiance gathered through the unset bits. Radiance Cascades takes radiance as an input: the bitmask result replaces cascade 0's interval trace, and its unoccluded fraction decides how much of the merged coarser cascade continues through. Cascades 1 and up trace and merge as normal. The merged result is per-pixel radiance with near-field contact detail from the bitmask and far-field light from the cascades.

How to build it

WebGPU or desktop compute, all in screen space. Run the bitmask slices with directions chosen to line up with cascade 0's angular bins, using a tuned thickness. For each cascade-0 probe direction, output the radiance gathered within the interval and a transmittance from the bitmask. Merge from coarse to fine as usual, multiplying each coarser contribution by that transmittance. Test leaking against a plain depth-marched cascade 0 on a scene with chair legs, railings and foliage, and check that temporal stability does not get worse.

Field marks

  1. Bitmask slices and cascade directions use different angular layouts; resampling between them causes ringing.
  2. The thickness heuristic still needs tuning per scene.
  3. Both halves are screen-space and miss off-screen light.
  4. Noise from few slices propagates into the merged cascades.

Prior art

No prior art found on 2026-11-29.

Searches run (4)
  • arXiv: all:"radiance cascades" AND all:"screen space" → 0 results
  • GitHub repos: "radiance cascades" "screen space" → 3 results
  • arXiv: all:"visibility bitmask" AND all:"indirect lighting" → 1 result
  • GitHub repos: "visibility bitmask" "indirect lighting" → 0 results