Log inGet started

shader

The shader namespace — the engine's Luau API reference for shader.

The shader namespace — 3 functions.

globals/shader/compile

shader.compile(keys: string | { string }, opts: { [string]: any }) -> boolean

Compile a zero-scaffolding SURFACE shader: the author wrote only vertex() / fragment() and declared its material properties, and the engine generates the group(1) material interface plus every render-mode entry point. Compiles once and registers the result under every key.

Parameters

  • keys string | { string } — One registration key, or the array of keys (guid, identity, aliases) the one compiled program answers to.
  • opts { [string]: any }{ source, domain?, properties? } — the author's WGSL, its @domain, and the declared property schema.

Returns boolean — True when the compile was queued.

shader.compile({ ref.guid, ref.identity }, { source = wgsl, properties = props })

globals/shader/registerModule

shader.registerModule(keys: string | { string }, source: string) -> boolean

Register a block of WGSL other shaders include. Every key names the same source, so a shader includes it by whichever name it holds — its guid, its identity, or an alias. Registering again replaces it, and the shaders that include it recompile.

Parameters

  • keys string | { string } — One key, or the array of keys this module answers to.
  • source string — The module's WGSL.

Returns boolean — True when the registration was queued.

shader.registerModule({ ref.guid, ref.identity }, wgsl)

globals/shader/status

shader.status(name: string) -> (string, string?)

A shader's latest compile outcome, without reading the engine log: "compiled", "failed" (with the compiler error second), or "pending". Compilation is async, so a "pending" straight after a write means ask again next frame.

Parameters

  • name string — Shader identity or guid — the key it compiled under.

Returns (string, string?) — Status, and the compiler error when it failed.

local status, err = shader.status(ref.guid)
  • api
  • reference