Log inGet started
▣
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·part ofmodule renderer.module·originates fromworld 07158574-5…

material

`renderer.material`: the material records (a shader key, property overrides and texture-slot references) the renderer builds a bind group from, and what each one draws with.

by◐lumi·posted 5d ago
What it does

renderer.material

renderer.material: the material records (a shader key, property overrides and texture-slot references) the renderer builds a bind group from, and what each one draws with.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

module renderer.material global renderer renderer.material: the material records the renderer builds a bind group from.

assetNameAt(path: string, category: string) → string

argtypedescription
pathstring
categorystring

assetNamedByKey(key: string, category: string) → string

argtypedescription
keystring
categorystring

materialAssetNamed(key: string) → string

argtypedescription
keystring

shaderShownAs(shader: any) → string

A material's shader as a report names it: the asset a `guid@checksum` key is a version of, else the shader as written.

argtypedescription
shaderany

vocabularyOf(def: any) → MaterialVocabulary

argtypedescription
defany

wrapMaterialHandle(guid: string, name: string) → MaterialHandle

argtypedescription
guidstring
namestring

resolveTextureRef(ref: any, materialName: string, slot: string, what: string, site: string?) → any

The GPU key a texture slot binds by. The renderer looks a slot's texture up by EXACT cache key — the guid an upload landed under — so an identity, a name, a `.texture` path, or the image path a texture was imported from names a real texture the cache has never heard of, and the slot renders the shader's declared fallback instead. Resolving here materialises the texture and returns that key, so every form an author can hold binds the texture they named. A reference that answers to nothing is passed through (the renderer picks up a texture that lands later) and reported, so the fallback is never silent. `site` is the source the API call was written in (`__asset.callerSite()`, read at the call's entry): a `~.tail` reference expands against the root enclosing it and a reference its reference table recorded reaches the texture recorded there, as an `asset.tryResolve` on the caller's own line reads them.

argtypedescription
refany
materialNamestring
slotstring
whatstring
sitestring?

create(content: MaterialContent, key: string) → MaterialHandle

argtypedescription
contentMaterialContent
keystring

registeredMaterialContent(key: string) → void

The guid of the schedule texture standing for one animation's timing, kept per source texture so a second material over the same animation binds the texture the first one wrote rather than uploading the same texels again. Internal: the content a runtime material under `key` was registered with, as an argument `renderer.material.create` takes again: its definition and what it adopts. Every table is the caller's own copy.

argtypedescription
keystring

copy(t: any) → any

argtypedescription
tany

frameScheduleTexture(guid: string, ends: { number }) → string

A texture carrying `ends` — the millisecond each layer stops being shown — one texel per layer, the millisecond as a 24-bit integer with its high byte in R. Read with `textureLoad`, so the shader gets the integer back exactly rather than a filtered neighbourhood of it. Returns the guid a material slot binds it by.

argtypedescription
guidstring
ends{ number }

list( ) →

Every runtime material currently registered, ordered by registry key. Each entry carries the key, where it came from, the shader it binds, and for a key a `.material` asset filed (`guid@checksum`) the asset it is. `renderer.references("material", key)` says what is still holding a row, and `renderer.collect()` releases the rows nothing holds.

examples

for _, m in ipairs(renderer.material.list()) do print(m.asset or m.guid, m.shader) end

releaseMaterial(key: string, by: string) → boolean

Drop the material filed under `key`: its definition, its registry row, its handles (stamped with `by`, the verb that released it) and its GPU record.

argtypedescription
keystring
bystring

destroy(key: string | { [string]: any } | AssetRef) → boolean

Drop a runtime material registered via `renderer.material.create`: clears its recoverable definition, unregisters its runtime-resource stamp so it is no longer swept into the material freeze/save flow, and frees the GPU record. Use for transient materials (e.g. a preview swatch) that must not outlive their use. The on-disk asset, if any, is untouched, and the next `handle()` of a material asset files its record again. Each texture the record's slots named is released with it once nothing else names it, the one the device's cache loaded for an asset included. The reach is the registry: after this, `describe` and `list` stop answering for the key. A surface already wearing the handle goes on drawing what it was given — `Model:restoreSessionMaterial` is what puts a Model back on its authored material. `MaterialHandle` `create` returned, or an `AssetRef` from `asset.resolve`.

argtypedescription
keystring | { [string]: any } | AssetRefThe material's registry key (the one passed to `create`), the

examples

renderer.material.destroy("__preview_swatch_" .. texGuid)

visibilitySurface( ) → any

currentObservation(frames: number?) → any

The renderer records a frame's per-renderable resolutions only while something is reading them, so a read arms recording and the frame after it publishes. This waits that frame out, so every call built on it answers with live data, and arms `frames` recording frames (one when none is given): a call made once pays for the frame that answers it, and a caller asking every frame keeps every frame recording. A wait that finds the frame it armed unpublished arms the next one. Counted in the frames the RENDERER draws, since a frame it declined published nothing to read — a budget of engine frames can run out having never met one that did.

argtypedescription
framesnumber?

publishedMaterial(key: string) → any

What the renderer holds for one material, out of the document it publishes every frame. Reading it neither arms per-draw recording nor waits for a frame, so a caller asking about a material pays what a table lookup costs.

argtypedescription
keystring

shaderStanding(shader: any) → void

Where the shader a material names stands, for a material the renderer has not prepared: `"absent"` when no shader asset answers to it (a name that resolves to no asset, or a `guid@checksum` key no asset holds), else the compile status of the version it names (`"pending"`, `"failed"`, `"compiled"`). Returned with the sentence `describe` states as `reason`.

argtypedescription
shaderany

describe(key: string | { [string]: any } | AssetRef) → any

The recoverable definition (`{ shader, properties, textures, name, render, features, bindings }`) this module registered under `key` via `renderer.material.create`, or nil for keys registered elsewhere (e.g. material assets resolved by the assetType). `properties` and `textures` carry the material's current values: each `setProperty` / `setTexture` write lands on this record, a texture slot under the GPU key the slot binds by — these are the WRITES, held here whether or not the renderer took them up. `renderer` beside them is what the renderer holds for the same key: the program its prepared bind group was built against, the texture each slot of its row names (`renderer.textures`, the writes the renderer took up), the render state its draws are looked up under, whether a pipeline exists for that key, and the draws, instances and binds the last published frame counted for it. A frame counts those only while something observes the renderer (`renderer.materialCost()`, `renderer.observe()` and `renderer.drawDiagnostics()` each record the frame that answers them, and `describe` records none), so `renderer.observed` states whether they were counted: `true` with the counts, `false` with `draws`, `instances`, `placeholderDraws`, `binds` and `bindsElided` all nil. `renderer` is nil when the renderer holds no material under this key at all, and `resident` states the same fact as a boolean. Writes reach the screen through both halves: `resident = false` says the renderer holds nothing to put them in, and `renderer.draws = 0` on a resident material says it holds them and no renderable is drawing with it. For a material that is resident AND drawn and still looks wrong, `renderer.drawDiagnostics()` names the renderable and the cause. A material that is not resident carries `shaderStatus` and `reason`, where its shader stands: `"absent"` when the shader it names resolves to no shader asset (nothing will compile it, so it stays unprepared until one arrives), `"pending"` while that shader has not compiled, `"failed"` with the compiler's message, or `"compiled"` when the shader is ready and the material has not been prepared yet. A resident material carries neither. `renderer.material.create`, or an `AssetRef` from `asset.resolve`. `shaderStatus: string?`, `reason: string?` and, for a key a `.material` asset filed, `asset` (the asset it is) fields

argtypedescription
keystring | { [string]: any } | AssetRefThe material's registry key, the `MaterialHandle` from

renderState(key: string | { [string]: any } | AssetRef) → MaterialObservation

What the renderer holds for a material, which is a different document from the values written to it. `index` is the material index its row in the material table is filed under, which an edit rewrites in place, and `textures` the texture each slot of that row names, by slot name, under the key the texture is resident as; a slot drawing its shader's declared default is absent, so a `setTexture` the renderer has taken up reads here as the key it bound. `shader` is the program its prepared bind group was built against, `renderState` the blend / cull / topology / queue / depth key its draws are looked up under, `keyBuilt` whether a pipeline exists for that key, and `draws` / `instances` / `placeholderDraws` / `binds` / `bindsElided` what it cost in the frame the renderer last published. A frame counts those only while something observes the renderer, which `renderer.materialCost()` and `renderer.drawDiagnostics()` start, so `observed` states whether they were counted: `true` with the five counts, `false` with all five nil. `nil` means the renderer holds no material under this key at all — the writes landed on a record nothing is drawing with. `renderer.material.create`, or an `AssetRef` from `asset.resolve`.

argtypedescription
keystring | { [string]: any } | AssetRefThe material's registry key, the `MaterialHandle` from

examples

local r = renderer.material.renderState("water"); print(r.renderState.blend, r.keyBuilt)

vocabulary(key: string | { [string]: any } | AssetRef) → MaterialVocabulary

A material's property names under `props` and its shader-declared and assigned texture slots under `textureSlots`, each a `{ [name] = true }` set — with `byRole` beside them, the index a key spelled in another engine's convention resolves to a declared name through. This is what a write's key is routed against on the record, in the shape `MaterialSchema.route` takes. It is read off the definition this module holds and touches nothing the renderer holds, so a call costs a table lookup and belongs on a per-frame write path; `describe` is the read that carries the renderer's own state. One frozen table per record, shared by every key that reaches it, rebuilt on the first read after a write puts a new name on the record. `renderer.material.create`, or an `AssetRef` from `asset.resolve`. record carrying no property, assigned texture, or declared texture slot.

argtypedescription
keystring | { [string]: any } | AssetRefThe material's registry key, the `MaterialHandle` from

examples

local MaterialSchema = require("@builtin::modules.material_schema")
local route, name = MaterialSchema.route(assert(renderer.material.vocabulary(handle)), "color", { 1, 0, 0, 1 })

sessionKeyFor(entityId: string) → string

The canonical registry key for an entity's SESSION material — the runtime material a system (e.g. GI baking) shows on an entity in place of its authored material for the lifetime of the engine session. One session material per entity: create it under this key, hand the handle to `Model:applySessionMaterial`, and the component re-adopts it across VM reloads by probing this key with `describe`. The key names the entity for as long as the entity stands: once it is gone the session store lets the handle go, and a collection releases the material and whatever its bindings were the last to hold.

argtypedescription
entityIdstringThe entity carrying the material.

examples

local key = renderer.material.sessionKeyFor(entityId)

setProperty(key: string | { [string]: any } | AssetRef, name: string, value: any) → void

Push one changed uniform property to a registered material's GPU record (frame-fast incremental update; no re-register). Keyed by the material's registry key. The value written becomes the material's current one: it is what `describe` reports, and — for a property the material's shader declares, which is what the uniform buffer is packed by — what a material `AssetRef` reads back through `getProperty` / `getProperties` and what the surface is drawn with. A write under any other name reaches the record `describe` reports, which is where it reads back. Each call is one write to one material. A value many materials follow every frame (a wind strength, a time of day, a global tint) is a named value instead: each material binds the property with `values` in `renderer.material.create` (`values = { tint = { value = "tint" } }`), and one `values.set(root, "tint", v)` on an ancestor of the entities drawing them reaches all of them on the draw, with no write per material. `renderer.material.create`, or an `AssetRef` from `asset.resolve`.

argtypedescription
keystring | { [string]: any } | AssetRefThe material's registry key, the `MaterialHandle` from
namestringProperty name.
valueanyNew value.

examples

renderer.material.setProperty(asset.resolve("wall", "material"), "roughness", 0.2)

setClock(key: string | { [string]: any } | AssetRef, seconds: number?, rate: number?) → void

Drive a material's surfaces from a clock of its own: the `time` its shader's `vertex()`, `vertex_clip()` and `fragment()` read. The clock reads `seconds` now and runs on by itself, `rate` of its seconds for every second of the world's gameplay time, so it is stated again only when that changes — a pause is a rate of 0, a seek is a new `seconds`, slow motion is a rate below 1. Every surface drawing the material follows it, motion vectors included. `seconds = nil` hands the material back to the world's time. A procedural graph's Generator drives the materials it realizes from its playhead this way, so an effect's shaders pause, slow and scrub with it. `renderer.material.create`, or an `AssetRef` from `asset.resolve`.

argtypedescription
keystring | { [string]: any } | AssetRefThe material's registry key, the `MaterialHandle` from
secondsnumber?The time the material's surfaces read now, or nil to release it.
ratenumber?Seconds of the clock per second of gameplay time (default 1).

examples

renderer.material.setClock(asset.resolve("frost_ice", "material"), 12.5, 0)

setTexture(key: string | { [string]: any } | AssetRef, slot: string, ref: string | { [string]: any } | AssetRef) → boolean

Push one changed texture slot to a registered material's GPU record. Keyed by the material's registry key. The slot is one the material's shader declares as a texture: a slot it does not declare is refused with a warning naming the texture slots it does declare, and the material is left as it was. While the shader's vocabulary has not been read (a custom shader that has not loaded) every slot is taken. `renderer.material.create`, or an `AssetRef` from `asset.resolve`. image path it was imported from, a `color:` / `default:` form, a live GPU handle, or a texture `AssetRef` carrying one. An asset reference is materialised (Disk→CPU→GPU) and bound by the key the upload lands under. texture slot under that name.

argtypedescription
keystring | { [string]: any } | AssetRefThe material's registry key, the `MaterialHandle` from
slotstringTexture slot name (`"base_color_texture"`, …).
refstring | { [string]: any } | AssetRefTexture reference — a `.texture` guid / identity / name / path, the

examples

renderer.material.setTexture("sky", "sky_texture", "panorama.texture")

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported on this asset or on the parts this page shows. Parts it leaves out are not counted here.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.