UNPKG

@playcanvas/splat-transform

Version:

Library and CLI tool for 3D Gaussian splat format conversion and transformation

60 lines (59 loc) 2.62 kB
import { GraphicsDevice } from 'playcanvas'; /** * Appearance columns per storage chunk. The kernel exposes three appearance * bindings (appA/appB/appC), so the layout holds up to 3·APP_CHUNK columns; at * 16 the widest chunk reaches the ~2 GB per-binding limit around ~33.5M splats. * The CPU-side packing in `data-table/decimate.ts` imports this same constant, * so the kernel strides and the host packing can't drift. */ export declare const APP_CHUNK = 16; /** * Per-splat cache for the edge cost kernel. Packed layouts to stay within the * WebGPU per-stage storage-buffer count limit (8) and the per-binding size * limit (~2 GB) — appearance is split into 16-column chunks for the latter. */ interface EdgeCostCache { /** Per-splat geometry interleaved 8-wide: (x, y, z, mass, logdet, vx, vy, vz). */ posScalars: Float32Array; /** Row-major 3×3 rotation per splat (length 9N). */ rotR: Float32Array; /** * Appearance in up to three chunks of ≤16 columns. Chunk c has stride * width_c (= its live column count): appChunks[c][s * width_c + k]. */ appChunks: Float32Array[]; /** Number of appearance columns C. */ numAppCols: number; /** Number of splats. */ numSplats: number; } /** * GPU edge-cost evaluator. * * Each compute thread evaluates the KL-style cost for one edge (i, j) by * reading the per-splat cache for both endpoints, computing the merged * Gaussian's covariance/determinant, running a single Monte-Carlo sample * through both component PDFs, and adding an L2 distance over the * appearance (SH) coefficients. Output is `costs[e] = cost for edge e`. * * Mirrors the CPU `computeEdgeCost` in `data-table/decimate.ts`. */ declare class GpuEdgeCost { /** * @param cache - Per-splat cache (uploaded once). * @param edgeI - Edge u indices (length E). * @param edgeJ - Edge v indices (length E). * @param z - Single Monte-Carlo sample (3 floats from N(0,1)). * @param outCosts - Destination for per-edge costs (length E). */ execute: (cache: EdgeCostCache, edgeI: Uint32Array, edgeJ: Uint32Array, z: Float32Array, outCosts: Float32Array) => Promise<void>; destroy: () => void; /** * @param device - PlayCanvas GraphicsDevice (WebGPU). * @param maxN - Maximum number of splats. * @param maxE - Maximum number of edges in a single dispatch. * @param maxAppCols - Maximum appearance column count (over all bands). */ constructor(device: GraphicsDevice, maxN: number, maxE: number, maxAppCols: number); } export { GpuEdgeCost, type EdgeCostCache };