/** * Data layout of `.csgs` GPU playback (`dynamic/csgs-curve-modifier.ts`): one * section packed for a modifier that evaluates the curves in the * gather/vertex stage, so the page uploads a section once instead of every * frame. * * Kept free of TSL and three.js so the clip worker can build it, and not * exported from `formats/csgs/index.ts`: the layout is an implementation * detail of `@voluma/vlam/dynamic`. Per section: * - **knots**: an RGBA16F texture (half floats, 8 B per texel). Each splat * owns a contiguous block, groups in coding order (`P` xyz, `R` wxyz, * `S` xyz, `O`, `D` xyz): one texel per knot, except the scalar opacity, * whose knots pack four to a texel (knot `j` in component `j & 3` of * texel `j >> 2`). Half precision is ~0.05 % of a value. Position knots * are stored **relative to the splat's first position knot** (which the * pool center holds in float32), so their precision follows how far a * splat moves within a section, not how far it stands from the clip's * origin: absolute half floats step by ~8 mm at 8 to 16 m. * - **headers**: per splat, the block's first texel, the five knot counts * packed into one integer, and the birth and death frames packed into * another, all exact in float32 (the per-splat channels are float32). * Birth and death are **section-relative** (`frame − g0`, clamped to * `[0, nframes]`), so the 4096 radix limits a section, not the clip, to * 4095 frames. * - **base**: the pool's copy of the splats. Centers sit on the first * position knot, the covariance is the identity (the modifier's linear * output `M = R(t)·S(t)` then yields `M·Mᵀ`), the color is neutral * (the modifier adds the DC term), and the SH is the section's. * - **bounds**: the box of every absolute position knot. The hat curves * interpolate between knots, so every pose stays inside it; the player * declares it as the mesh's `displacementBounds`, which the depth sort * quantizes against. */ import type { CsgsPlaybackSection } from './csgs-frame'; import type { SplatData } from '../../core/splat-data'; /** Floats per group knot, in coding order: P, R, S, O, D. */ export declare const CSGS_GROUP_DIMS: readonly [3, 4, 3, 1, 3]; /** Pool texture rows (and the knot texture) are this many texels wide. */ export declare const CSGS_KNOT_TEXTURE_WIDTH = 2048; /** Multiplier between packed knot counts (each count is 1 to {@link CSGS_GPU_MAX_KNOTS}). */ export declare const CSGS_K_RADIX = 8; /** Most knots per curve the packed counts hold; a section with more stays on the frame path. */ export declare const CSGS_GPU_MAX_KNOTS: number; /** Multiplier between the packed (section-relative) birth and death frames. */ export declare const CSGS_LIFE_RADIX = 4096; /** Pool byte color of the neutral base, which the modifier replaces. */ export declare const CSGS_NEUTRAL_BYTE = 128; /** Upper bound on a log-scale before `exp`, as the CPU evaluator clamps it. */ export declare const CSGS_MAX_LOG_SCALE = 20; /** One section packed for GPU playback. */ export interface CsgsGpuSection { readonly g0: number; readonly nframes: number; /** Splats of the section (the active slots). */ readonly count: number; /** Texels of `knots` in use. */ readonly texels: number; /** RGBA half-float knot texels (bits), `texels * 4` used. Positions are deltas. */ readonly knots: Uint16Array; /** Per splat: first knot texel. */ readonly base: Float32Array; /** Per splat: `kP + 8·kR + 64·kS + 512·kO + 4096·kD`. */ readonly k: Float32Array; /** Per splat: `(birth − g0) + 4096·(death − g0)`, each clamped to `[0, nframes]`. */ readonly life: Float32Array; /** The section's `count` pool splats, one per slot. */ readonly pool: SplatData; /** Box of every absolute position knot (see {@link csgsSectionBounds}). */ readonly bounds: CsgsBounds; } /** An axis-aligned box as plain tuples, so it crosses a worker boundary. */ export interface CsgsBounds { readonly min: readonly [number, number, number]; readonly max: readonly [number, number, number]; } /** * Box of every absolute position knot of a section. The hat curves * interpolate linearly between knots, so every pose of every splat stays * inside it. An empty section gives an empty box (`min` above `max`). */ export declare function csgsSectionBounds(section: CsgsPlaybackSection): CsgsBounds; /** Largest finite half float: knots beyond it cannot be stored. */ export declare const CSGS_HALF_MAX = 65504; /** * Whether every stored knot of a section fits a half float (the GPU path's * contract), positions taken as deltas from each splat's first knot, as * they are packed. Captures are metres across; Faltwerk's synthetic stress * streams are not, and stay on the float32 worker path. Sections longer than * 4095 frames do not fit the packed life either, nor curves of more than * {@link CSGS_GPU_MAX_KNOTS} knots the packed counts (the container allows any). */ export declare function csgsGpuHalfSafe(section: CsgsPlaybackSection): boolean; /** Texels a section needs (see the module comment). */ export declare function csgsGpuTexels(section: CsgsPlaybackSection): number; /** Packs one section for GPU playback (see the module comment). */ export declare function packCsgsGpuSection(section: CsgsPlaybackSection): CsgsGpuSection; /** Whether splat `i` of a packed section is alive at section-local integer frame `local`. */ export declare function csgsGpuAlive(life: Float32Array, i: number, local: number): boolean; /** The values the GPU modifier derives for one splat at frame time `t`. */ export interface CsgsGpuSample { readonly alive: boolean; readonly position: readonly [number, number, number]; /** Normalized quaternion, wxyz. */ readonly rotation: readonly [number, number, number, number]; readonly scale: readonly [number, number, number]; readonly opacity: number; /** DC color, `0.5 + C0·D`, unclamped. */ readonly color: readonly [number, number, number]; } /** * Evaluates splat `i` of a packed section exactly as the GPU modifier does, * from the packed (half-float) data alone, at absolute frame time `t`. The * reference the layout is tested against. */ export declare function sampleCsgsGpuSection(packed: CsgsGpuSection, i: number, t: number): CsgsGpuSample;