API contracts for material authoring and compilation boundary.
Entrypoints
| Entrypoint | Exports |
|---|---|
@motion-core/motion-gpu/svelte | defineMaterial |
@motion-core/motion-gpu | defineMaterialresolveMaterial |
defineMaterial(input)
defineMaterial(input)Validates and freezes material definitions. Use this for all user-facing material creation.
Input: FragMaterialInput
FragMaterialInput| Field | Type | Required |
|---|---|---|
fragment | string | Yes |
uniforms | UniformMap | No |
textures | TextureDefinitionMap | No |
defines | MaterialDefines | No |
includes | MaterialIncludes | No |
Output: FragMaterial
FragMaterialImmutable, validated object with frozen top-level maps:
fragmentuniformstexturesdefinesincludes
signatureFragMaterialresolveMaterial(material)
resolveMaterial(material)Framework-agnostic core helper that turns a validated
FragMaterial- preprocessed WGSL source
- uniform layout metadata
- texture binding metadata
- deterministic material signature
Use this in adapter implementations or low-level tooling.
Hard contracts
| Contract | Behavior |
|---|---|
Fragment entrypoint must be fn frag(uv: vec2f) -> vec4f | Throws during validation |
| Uniform/texture/define/include keys must be WGSL-safe identifiers | Throws during validation |
Matrix uniforms should use typed form { type: 'mat4x4f', value: [...] } | Ensures stable layout and packing |