import type { GBufferPasses } from './gbuffer'; import type { ItemModel } from './model'; import { TextureCache } from './textures'; /** * Where a card (the `gbuffer/1` octahedral impostor) tells the truth, and where it cannot. * * A card stores one albedo, normal, roughness and metalness per 3.6 cm-ish texel and the scene lights it. Three kinds of item * have no truthful card, whatever the engine does with it: * * - see-through glass or water (alpha BLEND, or transmission, which the reader turns into BLEND): a card is a cutout, so a pane is * either solid or stippled, never see-through; * - a mirror (an opaque material that is metallic and smooth: `MI_Glass_Opaque_01F` of the Black Frame Glass Wall is metallic 0.949, * roughness 0): it looks like the sky it reflects, and a card re-lights a few degrees of normal error into a flat grey panel; * - thin emissive parts (a neon tube 1.5 cm wide in a texel 3.6 cm wide): the card holds a coverage of 0.2 to 0.4 and never a solid * line, so the glowing area is a third too small and dim. * * For those items the far representation is a mesh. `compileItemLods({ cardTruth: true })` leaves the impostor out (`impostor: null`) * with the reason in `warnings`, but only when a mesh is guaranteed (see `meshGuarantee` in artifact.ts): the document format does * not change, so every engine that reads an item-lod document already draws a document with no impostor. * * The census is by SURFACE AREA: the sum of triangle areas of the material over the sum of every triangle (double-sided counts once). * It is sampled, never exhaustive: at most `MAX_SAMPLES_PER_MATERIAL` triangles per material, spread evenly, each standing for the * triangles around it. Texture-driven values (alpha, metallic-roughness, emissive) are read from the triangle's centroid UV. * * The thresholds come from the census of the 1,091 distinct models behind the 1,167 public item-lod versions on helix3 (2026-10-13, * `scripts/item-lod-card-census.mjs`, `item-lod-thin-emissive.mjs`): each sits in a gap of the real distribution, not on a guess. * - glass: 15 items at 0.21 to 1.00 of area; the next is 0.12 (a Lamborghini and a McLaren, whose windows are not what makes their card wrong), then 0.09. * - mirror: 3 items at 0.33 to 0.88 (a chrome coffee machine, the glass wall, a chrome statue); the next are 0.25 and 0.21, glossy car paint and chrome trim on cars. * - thin emissive: 3 items at 0.78 to 0.98 of their glowing texels thin (the neon figure sign and two glass lamps); the next is 0.32, a table lamp. */ export declare const CARD_TRUTH: { /** A BLEND or transmission material that is really translucent (0.03 < alpha < 0.9) covering at least this share of the area. */ readonly glassShare: 0.15; /** An opaque material that is a mirror covering at least this share of the area. */ readonly mirrorShare: 0.3; readonly mirrorMetallic: 0.9; readonly mirrorRoughness: 0.1; /** An alpha under this is invisible (not glass), at or over `glassAlphaMax` it is a solid with a BLEND flag (not glass either). */ readonly glassAlphaMin: 0.03; readonly glassAlphaMax: 0.9; /** * Thin emissive (read from the capture, so it needs a capture): of the covered texels that glow, the ones with a coverage under * `thinCoverage` outnumber the ones at or over it, AND the glowing texels are at least `emissiveShare` of every covered texel * (a lamp post with one glowing lens is not a neon sign). */ readonly thinCoverage: 0.5; readonly emissiveShare: 0.01; }; export interface CardCensus { /** Total surface area in square metres. */ area: number; /** Share of the area that is translucent BLEND / transmission material, 0..1. */ glass: number; /** Share of the area that is a mirror, 0..1. */ mirror: number; /** Share of the area whose material glows (reported for the census; the thin-emissive rule itself reads the capture). */ emissive: number; /** The materials that carry the glass and mirror shares, largest first, for the warning text. */ glassMaterials: string[]; mirrorMaterials: string[]; } /** The area-weighted material census of a model (see the file comment). Deterministic: no randomness, fixed stride. */ export declare function cardCensus(model: ItemModel, cache?: TextureCache): Promise; export interface ThinEmissive { /** Covered texels (coverage > 0) over every view. */ covered: number; /** Covered texels that glow. */ glowing: number; /** Glowing texels whose coverage is under `thinCoverage`: a tube narrower than a texel. */ thin: number; } /** * Thin emissive parts from the capture. A texel glows when its emissive radiance reaches the same floor the emissive map uses (6 of 765); * the capture's alpha is the texel's coverage (the supersampled share the item fills), so a 1.5 cm tube in a 3.6 cm texel reads 0.2 to 0.4. */ export declare function thinEmissiveTexels(passes: GBufferPasses): ThinEmissive; export interface CardVerdict { /** True when the item should have no card. */ suppress: boolean; /** One entry per rule that fired, in warning wording ("mirror 0.71 of area (MI_Glass_Opaque_01F)"). */ reasons: string[]; glass: number; mirror: number; thinEmissive: { covered: number; glowing: number; thin: number; } | null; } /** The geometry-and-material half of the verdict: glass and mirror. No capture needed. */ export declare function materialVerdict(census: CardCensus): CardVerdict; /** Adds the thin-emissive rule once a capture exists. */ export declare function withThinEmissive(verdict: CardVerdict, thin: ThinEmissive): CardVerdict;