The .drft container · interface
DrftMaterial
One surface, stored once per mesh rather than once per vertex.
Explained in The .drft container.
interface DrftMaterialimport type { DrftMaterial } from '@driftengine/drft';In depth
Parallel to the MESH chunks by ordinal: material n describes mesh n. A parallel
array rather than a field inside MESH because a material is small and a mesh is
megabytes, and the loader wants every material before it uploads anything, so it can
create each texture once and share it between the meshes that name it.
Properties
| Name | Type | Description |
|---|---|---|
namereadonly | string | What the source called this surface. Diagnostic, and more than diagnostic.MoreA bought asset frequently carries no material data worth the name and yet names its
materials perfectly well: the one this format was built against stores every surface as
the same default grey with no transparency, while calling them |
colorreadonly | readonly [number, number, number] | |
specularreadonly | number | |
roughnessreadonly | number | |
emissivereadonly | number | |
emissiveColorreadonly | readonly [number, number, number] | |
opacityreadonly | number | 1 is opaque. Below 1 the surface blends, and the loader draws it after the solid ones. |
albedoreadonly | number | Index into the asset's textures for the colour map, or -1 for an untextured surface. |
normalMapreadonly | number | Index into the asset's textures for the surface-space normal map, or -1 for none.MoreWritten by any baker that can derive it, and bound by nothing yet. Normal maps ship in the
renderer; carrying one through the container is the plan after ORM's. The field is defined
here rather than appended later so that all four indices cost the format one minor version
instead of three — see |
ormMapreadonly | number | Occlusion in R, roughness in G, metallic in B, or -1 for none. glTF's packing. |
emissiveMapreadonly | number | Index into the asset's textures for the emissive map, or -1. Written, not yet bound. |
roughnessScalereadonly | number | glTF's roughnessFactor where an ormMap supplies the roughness, and 1 where it does not.MoreA factor that multiplies a texture is not a value, which is the mistake this pair exists
to stop repeating. |
metallicScalereadonly | number | glTF's metallicFactor where an ormMap supplies the metallic, and 1 where it does not. |
occlusionStrengthreadonly | number | glTF's occlusionTexture.strength, or 0 where nothing establishes that the ORM map's R
channel holds occlusion at all.MoreglTF assigns G and B of a |
reflectivityreadonly | number | How much of the environment this surface mirrors, 0 to 1.MoreDistinct from |
cutoutreadonly | number | Alpha below which a fragment is discarded, 0 for a surface that discards nothing.MoreA test, not an opacity, and the difference is the whole reason this field exists. A cutout
says which texels of a surface are there at all — the gaps in a grille, the space between
leaves, the holes in a fence — and leaves everything it keeps at full strength. An opacity
says how much of the light passes through the surface that is there. A format with only the
second has to spend it on the first, and glTF states it exactly — |
blendreadonlyoptional | boolean | Whether the surface blends: its texture's alpha is coverage, times opacity. 1.18.MoreA flag, because |
doubleSidedreadonlyoptional | boolean | Whether both faces of the surface are seen: bit 1 of the flags word, 1.18.MoreglTF's |
transmissionreadonlyoptional | number | Glass, 1.19: the share of light that passes, 0 opaque to 1 clear. Absent or 0 is not glass,
which is what every surface before it was. See the engine's glass.ts. |
frostreadonlyoptional | number | How milky the glass is, 0 see-through to 1 fully diffusing. 1.19. |
tintreadonlyoptional | readonly [number, number, number] | The colour light takes through the glass; white is clear. 1.19. |