/** * Refuse a character GLB whose `normalTexture` is not a tangent-space normal map. * * ── THE DEFECT (live, found by the 2026-10-02 whole-catalogue visual-QA sweep) ─────────────────────── * Two different importers shipped normal maps that are not normal maps, and nothing read a pixel of them: * * MISSING-Z Cyberpunk 2077 `*_n01` maps are two-channel (BC5, red/green only). The extraction wrote them out as * RGB with blue = 0 and nobody rebuilt Z, so every texel decodes to a vector with no "up" component: * mean RGB (127,128,0). Lit, the surface goes black along every panel edge and glassy elsewhere — * "jagged torn black streaks" on the Cyberpunk Jumpsuit, "blotchy z-fighting" on the Baseball Cap, * "crumpled faceted" Sneakers. Nine live Cyberpunk items carry it. * NOT-NORMAL Sims 4 imports bound a different DST/RLE texture as the normal map (mean RGB like 0,154,0 or * 5,2,0) or baked garbage from it (`helix_baked_normal`, mean 92,109,88). Lit, that is faceted noise: * "torn jagged panels" on shoes, dresses and caps that are geometrically fine. * * ── WHY EVERY EXISTING GATE PASSED IT ────────────────────────────────────────────────────────────── * Same story as `baseColorGuard.ts`: the structural and budget checks never read a pixel of a normal map. * * ── THE TESTS ──────────────────────────────────────────────────────────────────────────────────────── * A real tangent-space normal map clusters around (128,128,255): most of a surface faces its own normal, so the * mean blue is high (>= ~170 even for heavily detailed maps). Both defects have a mean blue far below that. * MISSING-Z mean B < 24 and mean R,G within 24 of 128 -> repairable: Z = sqrt(1 - x^2 - y^2) * (`repairMissingNormalZ`), so the detail the artist authored is kept. * NOT-NORMAL mean B < 100 otherwise -> not recoverable; drop the normalTexture. * A texture that cannot be decoded is reported UNCHECKED and does not refuse. * * Escape hatch: `HELIX_ALLOW_BROKEN_NORMAL_MAP=1`. */ import type { Document } from '@gltf-transform/core'; export declare const NORMAL_MAP_MISSING_Z_MAX_BLUE_MEAN = 24; export declare const NORMAL_MAP_MISSING_Z_RG_TOLERANCE = 24; export declare const NORMAL_MAP_MIN_BLUE_MEAN_FOR_NORMAL = 100; export interface NormalMapFinding { material: string; texture: string; reason: 'missing-z' | 'not-normal'; detail: string; mean: [number, number, number]; } export interface NormalMapReport { findings: NormalMapFinding[]; /** Materials whose normal image could not be decoded, so no verdict was possible. */ unchecked: string[]; } export declare function inspectNormalMaps(document: Document): Promise; /** * Rebuild Z in every two-channel (missing-Z) normal map, in place, as PNG (the caller's KTX2 stage re-encodes). * Returns the number of textures rebuilt. Maps that are not missing-Z are untouched. */ export declare function repairMissingNormalZ(document: Document): Promise; export declare function describeNormalMapFindings(findings: readonly NormalMapFinding[]): string; /** Throws with an itemized report when any material's normalTexture is not a tangent-space normal map. */ export declare function assertNormalMapsAreNormals(document: Document, name?: string): Promise; export declare function assertGlbNormalMapsAreNormals(glb: Uint8Array, name?: string): Promise; /** Shared by publish, publish --dry-run and publish-version, so the gate before the fee is the gate at it. */ export declare function assertPublishNormalMaps(opts: { kind: string; mesh?: string; }, meshBytes: Uint8Array | null | undefined): Promise;