import type { Vector3 } from '@holoscript/core'; /** * GlobalIllumination.ts * * Global Illumination system: * - Spherical Harmonic (SH, L2 9-coefficient) light probe encoding/decoding * - SH irradiance grid (3D probe array) * - Irradiance probe sampling and trilinear interpolation * - DDGI-style probe validity tracking * - Lightmap UV unwrapping placeholder (atlas packing) * - Bounce count / GI mode configuration * * CPU-side — does not depend on WebGPU. Probe lighting values are * expected to come from an offline bake or iterative runtime update. * * @module rendering */ /** L2 spherical harmonics — 9 coefficients per RGB channel */ export interface SH9 { r: Float32Array; g: Float32Array; b: Float32Array; } export type GIMode = 'lightmaps' | 'probes' | 'ddgi' | 'ssgi' | 'none'; export interface GIConfig { mode: GIMode; /** World-space distance between adjacent probes */ probeSpacing: number; /** Number of indirect light bounces to simulate */ bounceCount: number; /** Grid dimensions [x, y, z] */ gridSize: [number, number, number]; /** World-space origin of the probe grid */ gridOrigin: Vector3; } /** Create an empty SH9 (all zeroes) */ export declare function createSH9(): SH9; /** * Add a directional radiance sample to an SH9 accumulator. * dir must be a unit vector (azimuth encoded across hemisphere). */ export declare function addSHSample(sh: SH9, dir: Vector3, radiance: [number, number, number], weight?: number): void; /** * Evaluate SH9 irradiance at a surface normal (Ravi Ramamoorthi, 2001). * Returns RGB irradiance. */ export declare function evalSH9Irradiance(sh: SH9, normal: Vector3): [number, number, number]; /** Scale all SH coefficients by a scalar (e.g. to normalise after sample accumulation) */ export declare function scaleSH9(sh: SH9, s: number): void; /** Linearly interpolate between two SH9 probes (for trilinear grid lookup) */ export declare function lerpSH9(a: SH9, b: SH9, t: number): SH9; export interface ProbeInfo { index: number; worldPos: Vector3; sh: SH9; /** 0 = invalid (occlusion issue), 1 = valid */ validity: number; /** Number of times this probe has been updated */ updateCount: number; } export declare class GIProbeGrid { private probes; private config; constructor(config?: Partial); private buildGrid; getProbeCount(): number; getConfig(): Readonly; getProbe(x: number, y: number, z: number): ProbeInfo | undefined; getProbeAt(index: number): ProbeInfo | undefined; updateProbe(x: number, y: number, z: number, sh: SH9): void; setValidity(x: number, y: number, z: number, valid: number): void; invalidateAll(): void; /** Number of valid probes (validity > 0) */ getValidProbeCount(): number; /** * Sample irradiance at a world-space position + surface normal. * Performs trilinear interpolation across the 8 surrounding probes. */ sampleIrradiance(worldPos: Vector3, normal: Vector3): [number, number, number]; /** * Return lightmap UV (atlas page + offset) for a given probe index. * Probes are packed in a square atlas, 16 per row. */ getLightmapUV(probeIndex: number): { page: number; u: number; v: number; }; } //# sourceMappingURL=GlobalIllumination.d.ts.map