Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/facett

facett-map3d/src/shadow.wgsl

// ── Cascaded shadow-map DEPTH pass (T3.3) ────────────────────────────────────
// A depth-only render of the mesh from the sun, ONE draw per cascade. Decoupled
// from the big scene `Uniforms` so each cascade can bind its own light-space
// view-projection (a tiny 64-byte uniform) without threading a cascade index
// through the main uniform. The main pass (`map3d.wgsl`) samples the resulting
// depth array with PCSS + a Poisson disk for contact-hardening soft shadows.

struct ShadowU {
    // World → this cascade's light clip (column-major). The cascade's ortho frustum
    // is fitted around the scene centre with a per-cascade radius (tight→wide).
    light_vp: mat4x4<f32>,
};

@group(0) @binding(0) var<uniform> SU: ShadowU;

struct VsIn {
    @location(0) pos: vec3<f32>,
    @location(1) nrm: vec3<f32>,
    @location(2) col: vec4<f32>,
};

@vertex
fn shadow_vs(in: VsIn) -> @builtin(position) vec4<f32> {
    return SU.light_vp * vec4<f32>(in.pos, 1.0);
}