/** * additional import for TypeScript * @import {TextureAtlas} from "./../../texture/atlas.js"; */ /** * Lit-aware variant of `QuadBatcher` for the SpriteIlluminator workflow. * * Adds a 5th vertex attribute (`aNormalTextureId`) so each quad knows * which slot its normal map occupies, and owns the per-frame * `Light2dBlock` uniform buffer that the lit fragment shader iterates. * * Colors and normal maps share ONE slot pool the same size as `QuadBatcher`'s * (#1585) — a normal map is allocated a unit like any other texture, and * `aNormalTextureId` records which one. The `WebGLRenderer` only * dispatches sprites here when the scene actually needs lighting (active * `Light2d` AND the sprite has a `normalMap`); unlit sprites stay on * `QuadBatcher` and pay nothing. * @category Rendering */ export default class LitQuadBatcher extends QuadBatcher { normalStore: WebGLTextureStore | undefined; lightBlock: UniformBlock | undefined; /** * Release the cached GL texture uploaded for the given normal-map source * and clear any slot bookkeeping referencing it. Safe to call for images * that were never bound. * @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap} image - normal-map source */ evictNormalMap(image: HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap): void; /** * Upload the per-frame Light2d data used by the lit fragment path. * Called once per camera per frame (before the world tree walk). * Lights past `MAX_LIGHTS` are silently ignored. * * Coordinates must be supplied in the same space as the renderer's * pre-projection vertex coords (i.e. camera-local / FBO-local), * matching `Stage.drawLighting`'s convention. * * The data goes into the `Light2dBlock` uniform buffer, which is * independent of which program is current — so unlike the uniform arrays * this replaced, calling it does not disturb the active shader. The * upload is skipped outright when the packed bytes are unchanged, so a * scene whose lights are static still costs nothing per frame. * @param {object} uniforms * @param {Float32Array} uniforms.positions - flat array of `[x, y, radius, intensity]` per light, length = 4 * count * @param {Float32Array} uniforms.colors - flat array of `[r, g, b]` per light, length = 3 * count * @param {Float32Array} [uniforms.heights] - flat array of per-light height, length >= count * @param {number} uniforms.count - number of lights to render (clamped to MAX_LIGHTS) * @param {number[]} [uniforms.ambient] - `[r, g, b]` ambient floor (0..1 each) */ setLightUniforms(uniforms: { positions: Float32Array; colors: Float32Array; heights?: Float32Array | undefined; count: number; ambient?: number[] | undefined; }): void; /** * Bind a normal-map image to the given GL texture unit. Uploads on * first use (via `uploadNormalMap`) and rebinds the cached * `WebGLTexture` on subsequent calls. Mirrors the * `bindTexture2D` / `createTexture2D` split used by `MaterialBatcher`, * but for normal-map textures which live outside the color * `TextureCache` (cached per-image in `normalMapTextures`). * @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap} image - normal-map source * @param {number} unit - GL texture unit the normal map is resolved to */ bindNormalMap(image: HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap, unit: number): void; /** * Add a textured quad with optional paired normal map. * @param {TextureAtlas} texture - Source texture atlas * @param {number} x - Destination x-coordinate * @param {number} y - Destination y-coordinate * @param {number} w - Destination width * @param {number} h - Destination height * @param {number} u0 - Texture UV (u0) value * @param {number} v0 - Texture UV (v0) value * @param {number} u1 - Texture UV (u1) value * @param {number} v1 - Texture UV (v1) value * @param {number} tint - tint color (UINT32 argb) * @param {boolean} [reupload=false] - Force the texture to be reuploaded * @param {HTMLImageElement|HTMLCanvasElement|null} [normalMap=null] - paired normal-map (SpriteIlluminator workflow) */ addQuad(texture: TextureAtlas, x: number, y: number, w: number, h: number, u0: number, v0: number, u1: number, v1: number, tint: number, reupload?: boolean, normalMap?: HTMLImageElement | HTMLCanvasElement | null): void; } import QuadBatcher from "./quad_batcher.js"; import { WebGLTextureStore } from "../texture/store.js"; import UniformBlock from "../buffer/uniformblock.js"; import type { TextureAtlas } from "./../../texture/atlas.js"; //# sourceMappingURL=lit_quad_batcher.d.ts.map