/** * @fileoverview Differentiable 2D Gaussian rasterizer — the autodiff CORE of the * sovereign HoloScript 3DGS trainer (no Python gsplat, no remote cloud). * * This is the CPU REFERENCE for the forward+backward alpha-blend math. It is the * parity spec the eventual WGSL trainer kernels are checked against (same role as * `splat-shared-sort.parity.ts` plays for the sort). The hard part of a 3DGS trainer * is the gradient of the front-to-back over-blend w.r.t. every gaussian parameter; * that math lives here and is verified by `GaussianTrainer2D.test.ts` against * finite differences (max rel err ~1e-5). * * Pipeline owned: capture → reconstruct → TRAIN (this) → render → twin. This closes * the one native gap — training was previously Python (`train_refine.py`) or a remote * call to `api.rendernetwork.com` in `GaussianSplatBakingPipeline`. * * Stage 1 (here): 2D gaussians, fixed index order. Stage 2 adds the 3D→2D projection * chain (∂cov2d/∂{scale,quat}, ∂mean2d/∂mean3d) so it optimizes real 3D gaussians from * posed views. Stage 3 ports the hot path to WGSL on the sovereign GaussianSplatSorter. */ /** SoA buffers for N 2D gaussians. `a,b,c` are the 2D conic (inverse covariance). */ export interface Gaussian2D { N: number; posx: Float64Array; posy: Float64Array; a: Float64Array; b: Float64Array; c: Float64Array; r: Float64Array; gr: Float64Array; bl: Float64Array; op: Float64Array; } /** Per-parameter gradient buffers (same shape as Gaussian2D minus N). */ export interface Gaussian2DGrad { posx: Float64Array; posy: Float64Array; a: Float64Array; b: Float64Array; c: Float64Array; r: Float64Array; gr: Float64Array; bl: Float64Array; op: Float64Array; } export interface RasterOpts { /** Apply the production cutoffs (alpha<1/255 skip, 0.999 clamp). false => smooth (for grad checks). */ clip?: boolean; } export interface ForwardResult { img: Float64Array; tFinal: Float64Array; } /** * Forward: per pixel, front-to-back over-blend of the N gaussians (index order). * alpha_i = op_i * exp(-(0.5*(a*dx^2 + c*dy^2) + b*dx*dy)) * C += T * alpha_i * color_i ; T *= (1 - alpha_i) */ export declare function forward2D(g: Gaussian2D, W: number, H: number, bg?: readonly [number, number, number], opts?: RasterOpts): ForwardResult; /** * Backward: given dL/dimg, accumulate dL/d{params}. Replays the per-pixel blend, then * walks gaussians back-to-front accumulating the suffix S_i = Σ_{j>i} c_j α_j T_j + T_f·bg. * dC/dcolor_i = T_i·α_i * dC/dα_i = T_i·color_i − S_i/(1−α_i) * chain α→σ→{conic, mean2d}: dα/dσ = −α, σ = 0.5(a dx²+c dy²)+b dx dy */ export declare function backward2D(g: Gaussian2D, W: number, H: number, dLimg: Float64Array, bg?: readonly [number, number, number], opts?: RasterOpts): Gaussian2DGrad; //# sourceMappingURL=GaussianTrainer2D.d.ts.map