import { Extension, ExtensionProperty, PropertyType, TextureChannel, TextureInfo, type Document, type IProperty, type Nullable, type ReaderContext, type Texture, type WriterContext } from '@gltf-transform/core'; /** * `HELIX_materials_toon`: the MToon look, carried through a published GLB. * * The JSON is deliberately ISOMORPHIC to `VRMC_materials_mtoon` 1.0 (same field names, same units, same linear * colour space; textures as `{ index, texCoord }`; `outlineWidthFactor` in metres), so the runtime and the VRM * exporter both map it by rename. Three additions, all optional: * * `vertexAttributes: true` the geometry carries `_TOON0` / `_TOON1` (normalised u8 x 4 each) that override the * per-surface scalars below for the primitive each vertex belongs to. An avatar's * 28 source materials are atlased into <= 8 draws; materials that differ only in * a few scalars (skin and hair differ in shading shift, toony and outline) stay one * draw by moving those scalars onto the vertices. * _TOON0 r = (shadingShift + 2) / 4 g = shadingToony * b = outlineWidth / outlineWidthFactor (the material holds the max) * a = rimLightingMix * _TOON1 rgb = outlineColor, sRGB encoded a = outlineLightingMix * _TOON2 r = matcap tile index (0..255, normalised) g = matcap strength (0 = none) * `matcapAtlas: [cols, rows]` the matcap texture is a grid of matcaps (one tile per distinct matcap among the * merged surfaces); `_TOON2.r` selects the tile. [1, 1] (default) = a single matcap. * `matcapFactor` etc. are material-wide; surfaces that differ there are merged only when the material cap forces it. * * Only values that differ from the MToon default are written, so a plain material costs a few bytes. */ export declare const HELIX_MATERIALS_TOON = "HELIX_materials_toon"; export declare const TOON_ATTRIBUTE_0 = "_TOON0"; export declare const TOON_ATTRIBUTE_1 = "_TOON1"; export declare const TOON_ATTRIBUTE_2 = "_TOON2"; export type ToonOutlineMode = 'none' | 'worldCoordinates' | 'screenCoordinates'; type Rgb = [number, number, number]; /** The texture slots, with the channels each one is read from (what a compressor must keep). */ export declare const TOON_TEXTURE_SLOTS: readonly [{ readonly slot: "shadeMultiplyTexture"; readonly channels: number; readonly colour: true; }, { readonly slot: "shadingShiftTexture"; readonly channels: TextureChannel.R; readonly colour: false; }, { readonly slot: "matcapTexture"; readonly channels: number; readonly colour: true; }, { readonly slot: "rimMultiplyTexture"; readonly channels: number; readonly colour: true; }, { readonly slot: "outlineWidthMultiplyTexture"; readonly channels: TextureChannel.G; readonly colour: false; }, { readonly slot: "uvAnimationMaskTexture"; readonly channels: TextureChannel.B; readonly colour: false; }]; export type ToonTextureSlot = (typeof TOON_TEXTURE_SLOTS)[number]['slot']; export interface ToonScalars { shadeColorFactor: Rgb; shadingShiftFactor: number; shadingShiftTextureScale: number; shadingToonyFactor: number; matcapFactor: Rgb; matcapAtlas: [number, number]; parametricRimColorFactor: Rgb; parametricRimFresnelPowerFactor: number; parametricRimLiftFactor: number; rimLightingMixFactor: number; outlineWidthMode: ToonOutlineMode; outlineWidthFactor: number; outlineColorFactor: Rgb; outlineLightingMixFactor: number; uvAnimationScrollXSpeedFactor: number; uvAnimationScrollYSpeedFactor: number; uvAnimationRotationSpeedFactor: number; transparentWithZWrite: boolean; renderQueueOffsetNumber: number; vertexAttributes: boolean; } /** MToon 1.0's defaults. */ export declare const TOON_DEFAULTS: Readonly; export declare const TOON_SCALAR_KEYS: Array; type SlotRefs = { [K in ToonTextureSlot]: Texture; } & { [K in ToonTextureSlot as `${K}Info`]: TextureInfo; }; interface IToonSettings extends IProperty, ToonScalars, SlotRefs { } /** The per-material property. */ export declare class ToonSettings extends ExtensionProperty { static EXTENSION_NAME: typeof HELIX_MATERIALS_TOON; extensionName: typeof HELIX_MATERIALS_TOON; propertyType: 'ToonSettings'; parentTypes: [PropertyType.MATERIAL]; protected init(): void; protected getDefaults(): Nullable; getScalar(key: K): ToonScalars[K]; setScalar(key: K, value: ToonScalars[K]): this; getScalars(): ToonScalars; setScalars(values: Partial): this; getTexture(slot: ToonTextureSlot): Texture | null; getTextureInfo(slot: ToonTextureSlot): TextureInfo | null; setTexture(slot: ToonTextureSlot, texture: Texture | null): this; } export declare class HelixMaterialsToon extends Extension { static readonly EXTENSION_NAME: typeof HELIX_MATERIALS_TOON; readonly extensionName: typeof HELIX_MATERIALS_TOON; readonly prereadTypes: PropertyType[]; readonly prewriteTypes: PropertyType[]; createToonSettings(): ToonSettings; /** @hidden */ read(_context: ReaderContext): this; /** @hidden */ write(_context: WriterContext): this; /** @hidden */ preread(context: ReaderContext): this; /** @hidden */ prewrite(context: WriterContext): this; } /** * The transfer function a texture needs when `HELIX_materials_toon` uses it: shade, rim and matcap are perceptual colour; shading shift, * outline width and the UV-animation mask are scalar data. `null` when no toon material references the texture. */ export declare function toonTextureColourSpace(document: Document, texture: Texture): 'srgb' | 'linear' | null; export {};