/** * Unified material model. * * FBX materials come in many vendor flavours: the classic FbxSurfaceLambert / FbxSurfacePhong, Autodesk Standard * Surface (OSL), Arnold aiStandardSurface, 3ds Max Physical Material, 3ds Max PBR (metal/rough and spec/gloss), * the 3ds Max glTF material, OpenPBR, and Maya's Stingray PBS ShaderFX graph. Each stores its parameters under * different property names, sometimes behind a shader binding table. * * This module resolves any of them into two parameter sets, mirroring how the FBX SDK / ufbx expose materials: * `fbx` (the classic Lambert/Phong parameters) and `pbr` (a physically based parameter set), plus feature flags. */ import { type FBXPropertyValue } from "../types/fbxTypes.js"; export type FBXShaderType = "unknown" | "fbxLambert" | "fbxPhong" | "oslStandardSurface" | "arnoldStandardSurface" | "3dsMaxPhysicalMaterial" | "3dsMaxPbrMetalRough" | "3dsMaxPbrSpecGloss" | "gltfMaterial" | "openPbrMaterial" | "shaderFxGraph"; /** One resolved material parameter: a constant value and/or a texture. */ export interface FBXMaterialMap { /** Constant value (r,g,b,a for colours, x for scalars) */ value?: number[]; /** Number of meaningful components in `value` (1 for scalars, 3 or 4 for colours) */ valueComponents: number; /** Texture bound to the parameter */ texture?: TTexture; /** Whether the texture is enabled (some vendors carry an explicit toggle) */ textureEnabled: boolean; } export type FBXFbxMapName = "diffuseFactor" | "diffuseColor" | "specularFactor" | "specularColor" | "specularExponent" | "reflectionFactor" | "reflectionColor" | "transparencyFactor" | "transparencyColor" | "emissionFactor" | "emissionColor" | "ambientFactor" | "ambientColor" | "normalMap" | "bump" | "bumpFactor" | "displacement" | "displacementFactor" | "vectorDisplacement" | "vectorDisplacementFactor"; export type FBXPbrMapName = "baseFactor" | "baseColor" | "roughness" | "metalness" | "diffuseRoughness" | "specularFactor" | "specularColor" | "specularIor" | "specularAnisotropy" | "specularRotation" | "transmissionFactor" | "transmissionColor" | "transmissionDepth" | "transmissionScatter" | "transmissionScatterAnisotropy" | "transmissionDispersion" | "transmissionRoughness" | "transmissionExtraRoughness" | "transmissionPriority" | "transmissionEnableInAov" | "subsurfaceFactor" | "subsurfaceColor" | "subsurfaceRadius" | "subsurfaceScale" | "subsurfaceAnisotropy" | "subsurfaceTintColor" | "subsurfaceType" | "sheenFactor" | "sheenColor" | "sheenRoughness" | "coatFactor" | "coatColor" | "coatRoughness" | "coatIor" | "coatAnisotropy" | "coatRotation" | "coatNormal" | "coatAffectBaseColor" | "coatAffectBaseRoughness" | "thinFilmFactor" | "thinFilmThickness" | "thinFilmIor" | "emissionFactor" | "emissionColor" | "opacity" | "indirectDiffuse" | "indirectSpecular" | "normalMap" | "tangentMap" | "displacementMap" | "matteFactor" | "matteColor" | "ambientOcclusion" | "glossiness" | "coatGlossiness" | "transmissionGlossiness"; export type FBXMaterialFeatureName = "pbr" | "metalness" | "diffuse" | "specular" | "emission" | "transmission" | "coat" | "sheen" | "opacity" | "ambientOcclusion" | "matte" | "unlit" | "ior" | "diffuseRoughness" | "transmissionRoughness" | "thinWalled" | "caustics" | "exitToBackground" | "internalReflections" | "doubleSided" | "roughnessAsGlossiness" | "coatRoughnessAsGlossiness" | "transmissionRoughnessAsGlossiness"; export interface FBXMaterialModel { shaderType: FBXShaderType; /** Prefix material property names carry for this shader (e.g. "3dsMax|Parameters|") */ shaderPropPrefix: string; fbx: Partial>>; pbr: Partial>>; features: Partial>; } /** Inputs needed to resolve a material, independent of the parse representation. */ export interface FBXMaterialSource { /** "lambert", "phong", "unknown", ... as written in the file */ shadingModelName: string; /** Property values by full property name (e.g. "DiffuseColor", "Maya|baseColor", "3dsMax|Parameters|roughness") */ props: Map; /** Textures connected to the material by property name (OP connection property) */ texturesByProp: Map; /** Connected shader implementation, when any */ shader?: { renderApi: string; /** shader semantic name -> material property names */ bindings: Map; }; } /** Shader types whose parameters are physically based; the loader emits PBR materials for them by default. */ export declare function isPbrShaderType(type: FBXShaderType): boolean; /** Detects the shader flavour of a material from its shading model name, connected shader and 3ds Max class ids. */ export declare function detectShaderType(source: FBXMaterialSource): { shaderType: FBXShaderType; shaderPropPrefix: string; }; /** * Resolves the unified material model from raw material data. */ export declare function resolveMaterialModel(source: FBXMaterialSource): FBXMaterialModel; /** Colour (first three components) of a map, or undefined. */ export declare function mapColor(map: FBXMaterialMap | undefined): [number, number, number] | undefined; /** Scalar (first component) of a map, or undefined. */ export declare function mapScalar(map: FBXMaterialMap | undefined): number | undefined;