API contracts for material authoring and compilation boundary.
Entrypoints
defineMaterial(input)
Validates and freezes material definitions. Use this for all user-facing material creation.
Input: FragMaterialInput
Output: FragMaterial
Immutable, validated object with frozen top-level maps:
fragmentuniformstexturesdefinesincludesstorageBuffers
signature and preprocessed WGSL are internal runtime outputs, not public fields of FragMaterial.
resolveMaterial(material)
Framework-agnostic core helper that turns a validated FragMaterial into runtime-ready payload:
- preprocessed WGSL source
- uniform layout metadata
- texture metadata (including storage +
fragmentVisibleconfig) - storage buffer keys and definitions
- storage texture keys
- deterministic material signature
Use this in adapter implementations or low-level tooling.
Hard contracts
Define value types
MaterialDefines accepts booleans, untyped numbers (f32), typed scalar values (bool, f32, i32, u32), and typed float vectors (vec2f, vec3f, vec4f). Vector define values must be finite numeric tuples with the matching component count.