import { Light2D } from "./Light2D.js"; import { DataTexture } from "three"; import Node from "three/src/nodes/core/Node.js"; import UniformNode from "three/src/nodes/core/UniformNode.js"; //#region src/lights/LightStore.d.ts /** * Function that reads a light index from a tile buffer/texture. * Abstracts over WebGPU storage buffers and WebGL2 DataTextures. * * @param tileIndex - TSL node for the flat tile index * @param slotIndex - TSL node for the slot within the tile (0..MAX_LIGHTS_PER_TILE-1) * @returns TSL int node containing the 1-based light index (0 = empty) */ type TileLookupFn = (tileIndex: Node<'int'>, slotIndex: Node<'int'>) => Node<'int'>; /** * Thin DataTexture storage for 2D lights. * * Stores per-light data in a DataTexture (width=maxLights, height=4 rows, * RGBAFormat, FloatType). Supports up to `maxLights` (default 256, configurable). * * DataTexture layout: * | Row | R | G | B | A | * |-----|--------|-----------|---------------|----------------| * | 0 | posX | posY | colorR | colorG | * | 1 | colorB | intensity | distance | decay | * | 2 | dirX | dirY | angle | penumbra | * | 3 | type | enabled | castsShadow | categoryBucket | * * `categoryBucket` is 0..3 — the hashed bucket index derived from * `Light2D.category`. Used by the Forward+ tile pass to scope each * category's fill-light quota independently (per-bucket group max). * * The shader reads via `textureLoad(lightsTexture, ivec2(lightIndex, row))`. * * @example * ```typescript * const store = new LightStore({ maxLights: 64 }) * store.sync(flatland.lights) // CPU → DataTexture each frame * ``` * * @internal */ declare class LightStore { /** Maximum number of lights this store can handle */ readonly maxLights: number; private _lightsData; private _lightsTexture; private _lightsTextureNode; private _countNode; /** * @param options - Optional configuration. * @param options.maxLights - Maximum lights this store can hold. * Default `1024` (raised from the previous `256`). The Forward+ * tile-assignment path indexes the lights array directly, so any * light past this cap reads zeros in the shader and contributes * nothing — bump it for scenes with more concurrent lights than * the default. Memory cost is `maxLights × 64` bytes CPU + GPU. */ constructor(options?: { maxLights?: number; }); /** Get the lights DataTexture (for use by GPU systems that sample lights directly) */ get lightsTexture(): DataTexture; /** Get the TSL node for the lights DataTexture */ get lightsTextureNode(): Node<'vec4'>; /** Get the current light count uniform node */ get countNode(): UniformNode<'float', number>; /** * Sync Light2D array into DataTexture. * Call once per frame. Copies current Light2D properties into the * DataTexture backing array. No shader recompilation. */ sync(lights: readonly Light2D[]): void; /** * Read light data from the DataTexture in TSL. * Returns row0..row3 vec4 values for a given light index. */ readLightData(lightIndex: Node<'float'> | Node<'int'>): { row0: Node<'vec4'>; row1: Node<'vec4'>; row2: Node<'vec4'>; row3: Node<'vec4'>; }; /** Dispose of GPU resources. */ dispose(): void; } //#endregion export { LightStore, TileLookupFn }; //# sourceMappingURL=LightStore.d.ts.map