import { type Ktx2Header } from './ktx2'; /** * Re-texture a split Scene package without moving a single cell. * * `helix scene split` shares each distinct texture once, but "distinct" means distinct SOURCE BYTES. A shell * exported from a DCC tool routinely carries one image many times with different encoder noise (Hyperspace's * metal/rough map appears five times, 253 KB each, to within 0.1/255 mean difference), and every UASTC data map is * written without rate-distortion optimisation. Both are paid in full on the first-playable path. * * This step reads a finished split bundle (the folder `helix scene split` writes: scene document, cells/, textures/, * assets/) and changes ONLY texture bytes: * * 1. merges textures that decode to the same picture (same codec, colour space, size and role; high PSNR) onto one * representative, by renaming the image uri inside each GLB that referenced the others; * 2. re-encodes a UASTC data/normal map with RDO when that is smaller and still above a PSNR floor. Data and * normal maps stay UASTC: scene perf rule P03 refuses ETC1S there, and its blocks facet a normal map. * * Nodes, transforms, stream groups, cell bounds, spawn, budgets and every GLB's geometry are copied through * untouched, so what loads when (and what stands where) cannot change. Only the resource rows of the files that did * change (GLB integrity/bytes/name, texture rows) are rewritten, then the document is resealed and validated. */ export interface RetextureOptions { /** Merge two textures when their level-0 PSNR (RGB) is at least this many dB. Default 44. */ mergePsnrDb?: number; /** Also require the largest single-texel difference to stay below this (0-255). Default 24. */ mergeMaxDelta?: number; /** * UASTC RDO quality scalars to try for data and normal maps, highest first (basis `-uastc_rdo_l`: higher is smaller and * lossier). The first that stays above `reencodePsnrDb` and saves `minSavingFraction` wins; empty disables. Default [2, 1]. */ uastcRdo?: number[]; /** Keep an RDO re-encode only when it is at least this much smaller. Default 0.08 (8 percent). */ minSavingFraction?: number; /** Floor for a re-encode against the decoded original, in dB, on the channels the maps use. Default 40. */ reencodePsnrDb?: number; } type TextureKind = 'colour' | 'normal' | 'data'; export interface RetextureTexture { name: string; codec: Ktx2Header['codec']; kind: TextureKind; width: number; height: number; bytesBefore: number; bytesAfter: number; action: 'kept' | 'merged' | 'rdo' | 'dropped-unreferenced'; into?: string; psnrDb?: number; rdo?: number; } export interface RetextureReport { schemaVersion: 'helix.scene-retexture-report/1'; options: Required; input: { scene: string; revision: string; integritySha256: string; }; output: { scene: string; revision: string; integritySha256: string; }; textures: { before: { files: number; bytes: number; }; after: { files: number; bytes: number; }; }; glbs: { rewritten: number; unchanged: number; bytesBefore: number; bytesAfter: number; }; totals: { bytesBefore: number; bytesAfter: number; }; detail: RetextureTexture[]; warnings: string[]; } /** * Point the images of a GLB that name a texture in `rename` at its replacement (uri and, when it carried the old file * name, the image name). Returns the new GLB, or undefined when it references none of them. Nothing else changes: the * binary chunk is copied through byte for byte. */ export declare function renameGlbImages(bytes: Uint8Array, rename: ReadonlyMap): Uint8Array | undefined; export declare function retextureBundle(args: { input: string; output: string; options?: RetextureOptions; dryRun?: boolean; }): Promise; export declare function formatRetextureReport(report: RetextureReport): string; export {};