Skip to content

[Renderer] Add virtual shadow maps with cached pages and scalable many-light shadows #132

Description

@proggeramlug

Parent: #126

Problem

Bloom's cascaded sun shadows and per-light approaches cannot scale to UE-class geometric detail and many shadowed lights without fixed-resolution waste, aliasing, cascade transitions, or a shadow-map-per-light explosion. #11 already identifies virtual shadow maps as a major visual gap.

Outcome

Page-cached virtual shadow maps (VSMs) for directional, spot, and point lights on capable tiers, with stable filtering, explicit invalidation, bounded memory, and a correct cascaded/conventional fallback.

Architecture contract

Address space and cache

  • Per-light virtual address space mapped through page tables to a shared physical page pool.
  • Directional light uses camera-centered clip levels with stable texel/page snapping.
  • Spot lights use a 2D projection; point lights use a documented cube/octahedral representation.
  • Page metadata tracks owner, virtual coordinate, last use, dirty state, and generation.
  • Fixed memory budget with deterministic allocation/eviction and coarse fallback coverage.

Page demand and rendering

  • Mark pages from the camera-visible receiver set; optionally use depth/visibility buffer to avoid requesting empty screen regions.
  • Compact requested/dirty pages on GPU.
  • Cull shadow casters against each page and issue GPU-driven page renders where supported.
  • Static pages persist. Dynamic caster/light/transform changes invalidate only affected pages, conservatively.
  • Missing pages sample a coarser resident level or conventional fallback—never unshadowed by accident.

Sampling and quality

  • Cross-page filtering must not reveal seams; include borders/gutters or neighbor-aware sampling.
  • Receiver-plane/depth bias and normal bias are scene-scale aware and exposed through quality presets, not arbitrary per-scene hacks.
  • Directional clip-level transitions blend without visible rings.
  • Alpha-tested casters preserve coverage. Translucent colored shadows are out of scope unless explicitly added later.

Capability fallback

  • High tier: VSM page marking/caching/GPU-driven render.
  • Middle/baseline tier: improved CSM/conventional per-light maps with cascade blending and caching.
  • Capability report states which path is active and why.

Milestones

  1. Directional-light address/page table with debug visualization.
  2. Receiver demand, physical cache, and coarse fallback.
  3. Static/dynamic invalidation and GPU-driven caster submission.
  4. Seam-safe filtering and clip-level blending.
  5. Spot and point light support plus shared budget arbitration.
  6. Quality-tier integration and fallback qualification.

Acceptance criteria

  • Fixed Sponza/Bistro camera paths show no page seams, clipmap rings, cascade pops, missing-page flashes, or persistent stale shadows.
  • A moving caster and moving light invalidate affected pages within one frame; unrelated static pages retain a high cache-hit rate.
  • A geometric-detail stress scene preserves contact detail demonstrably better than current CSM at an equal or measured memory budget.
  • At least 100 shadow-requesting local lights can be submitted; actual shaded/page cost is visibility/budget bounded and reported.
  • Page pool memory never exceeds the configured budget plus documented metadata/staging overhead.
  • Alpha-tested foliage coverage and skinned casters have automated cases.
  • Forced fallback path remains correct on web/mobile/constrained adapters.
  • Debug views expose virtual pages, physical occupancy, misses, invalidations, clip levels, and per-light cost.

Likely files

  • native/shared/src/shadows.rs
  • native/shared/src/renderer/graph.rs, scene_pass.rs, hiz.rs, shader modules
  • scene/light data in native/shared/src/
  • public quality/capability APIs in src/

Verification

Run the quality corpus with camera cuts, rapid movement, dynamic casters, alpha-tested assets, and a forced small page budget. Attach uncapped GPU timings, cache statistics, memory, and fallback captures.

Non-goals

  • Ray-traced shadows replacing VSMs everywhere.
  • Requiring VSMs on low tiers.
  • Colored translucent shadow transport.

Dependencies

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions