Renderer · interface

GpuDrivenMaterial

What a material tints and emits.

Explained in Hello world.

interface GpuDrivenMaterial
import type { GpuDrivenMaterial } from '@driftengine/core';

Properties

NameTypeDescription
tintreadonlyreadonly [number, number, number]
emissivereadonlynumberAdded to the lit colour as albedo * emissive. Zero for an ordinary surface.
roughnessreadonlyoptionalnumber0 is a mirror and 1 is fully rough. Defaults to 1, which is the matte this pipeline had.
More

Below 0.1 the highlight gets dimmer as the surface gets smoother, which is the forward path's own lobe and is recorded in docs/IMPROVEMENTS.md rather than fixed here — the published scenes are calibrated against the shader that has it.

specularreadonlyoptionalnumberHow much of the light the surface returns as a highlight. Defaults to 0.
More

Zero is what keeps this from moving anything: a material that says nothing about shininess renders exactly the frame it rendered when the lit expression was four lines.

reflectivityreadonlyoptionalnumberHow much of the environment the surface returns, before angle and roughness. Defaults to 0.
More

With no probe bound this reflects the same two-colour gradient the ambient comes from, which is what the forward path reflects in the same situation — see gpudriven/ibl.ts for the two weights and why the selector between them is exactly 0 or exactly 1.

metalnessreadonlyoptionalnumber0 is a dielectric and 1 is a metal. Defaults to 0.
More

One number a material, where flat/main.ts reads one texel of an ORM map. That is the whole of the difference and it is a subset rather than a second opinion: every expression it enters is the forward path's with a constant standing in for a fetch. See gpudriven/lit.ts for the four of them.

A metal reflects whether or not reflectivity asked for it, because a metal is nothing but its reflection — and with no probe bound, what it reflects is the sky-and-ground gradient. A metal in a scene with neither is a smooth gradient rather than a picture, which is a statement about the scene rather than about the material.

texturesreadonlyoptionalGpuDrivenTexturesThe material's maps, as DriftTexture decode programs, decoded per shaded pixel on the device.
More

A material with none uploads exactly the entry it uploaded before textures existed, so the frame it draws is unchanged — the promise every term in this pipeline makes. See gpudriven/materialTable.ts for what each program feeds and decodeTables.ts for the limits.

alphaCutoffreadonlyoptionalnumberDiscard a fragment whose base-colour alpha is below this. Zero means no test.
More

The test happens in the raster rather than in the shading pass, because that is where a pixel learns which triangle owns it: a discard in shade would come after the visibility buffer already held the leaf, and what stood behind it was never written.

Zero is the default and it skips the fetch outright, so a material that says nothing about cutout draws exactly the frame it drew before — the promise every term in this pipeline has made since it was four lines. A cluster carries one material, so the branch is coherent across every fragment of a draw rather than divergent within one.

It needs a textures.baseColour program to mean anything. With no base-colour map there is no alpha to test, and the raster reads 1 — so a cutoff at or below 1 keeps every fragment and one above 1 discards the whole surface. Both are what the material asked for, stated here because an invisible mesh is a hard thing to attribute.

blendreadonlyoptionalbooleanDraw this material's clusters blended instead of into the visibility buffer. Defaults to false.
More

A visibility buffer stores one surface a pixel, so it cannot hold a blend at all — that is architecture rather than an omission. What a blended material asks for is that its clusters skip the opaque half entirely and be drawn again by a second raster that shades in its own fragment stage and writes the two weighted-transparency targets. The cut runs a second time to find them, and a scene with no blended material runs neither stage.

The opacity is tint's fourth component, not this; this only says which half of the frame the surface belongs to. See blendRaster.wgsl.ts for what the second half does with it, and orderIndependent.ts for the weight and what it approximates.

opacityreadonlyoptionalnumberHow much of a blended surface is its own colour rather than what is behind it. Defaults to 1.
More

Read only where blend is set. One is a solid pane, which is what a material that asked to blend and said nothing else gets — visible, and therefore findable.

glassreadonlyoptionalGlassOptionsGlass: how much light passes, how milky it is, and the colour it takes — GlassOptions, as the forward path's drawTranslucentMesh takes it. Absent, or letting nothing through, is not glass.
More

A glass material is drawn in the blended half whatever blend says, because a visibility buffer holds one surface a pixel and glass is the pane and what is behind it.