Luxar Viewer API Documentation - v2026.9.22
    Preparing search index...

    Function energyCompensation

    • Brightness-compensation factor for a streaming blendable LOD leaf (mechanism 2 in the module doc; additive / luminous / volumetric).

      As a leaf's additive ladder streams in, its committed prefix carries only e (∈ (0, 1]) of the leaf's full self-energy E, so it renders at e·E and brightens toward E as chunks arrive — a pop. Because opacity linearly scales summed energy in additive/luminous compositing (and per-ray optical depth τ in volumetric), multiplying opacity by 1/e holds the partial prefix near the full E at every step. This is a heuristic, not an exact compensation: e(k) is a squared-amplitude (self-energy) fraction while additive brightness is linear in amplitude, so a 2:1 disjoint pair at k = 1 renders at mass 2.5 of 3. The factor converges to 1 as e → 1, so the final frame is exact.

      floor caps the boost at 1/floor so a tiny early prefix can't over-brighten its (energy-descending, hence core-heavy) splats into tone-map clipping.

      Returns 1 (no compensation, so the leaf is left byte-identical) whenever there is nothing to compensate: e absent (unstamped dataset), already complete (e >= 1; a non-progressive leaf stamps 1), or degenerate (e <= 0 before any chunk commits, or NaN).

      Parameters

      • e: number | undefined
      • floor: number

      Returns number