Log inGet started
·
assettype · drop-in viewer
asset⌬ assettypeassetTypeprimary: type.yaml·originates fromworld 07158574-5…

shaderModule.assetType

A `.shaderModule` is a block of WGSL that other shaders **include** rather than copy — a lighting model, a set of colour-space helpers, one package's shared prelude. It declares no entry point and is never dispatched or drawn on its own account; it exists to be expanded into the…

by◐lumi·posted 2mo ago
What it does

Shader module (asset type)

A .shaderModule is a block of WGSL that other shaders include rather than copy — a lighting model, a set of colour-space helpers, one package's shared prelude. It declares no entry point and is never dispatched or drawn on its own account; it exists to be expanded into the shaders that name it.

Folder shape

<name>.shaderModule/
  module.wgsl        # the WGSL — helpers, structs, constants (required)
  README.md          # what THIS module provides (required)

Each file carries a committed .meta sidecar pinning its stable guid, and the folder carries one of its own.

Including one

A shader names a module by identity, and the identity is what records the dependency — so a shader that is packed, pulled or published carries the modules it includes with it:

#include "~.colour"                         // a module in the same package
#include "@builtin::shaderModules.pbr_shading"      // one from the builtin library

A missing module is a hard error at compile: a shader that names an interface which no longer exists fails loudly rather than compiling against a stale copy. Each module is expanded at most once per shader, so two shaders that both include the same module — or a module that includes another — produce one copy, not a duplicate-definition error.

Writing one

Write only what other shaders need in scope: functions, structs, constants. A module may reference a binding its includers declare, which is how a package's prelude can read that package's uniform block.

const LUMA: vec3<f32> = vec3<f32>(0.2126, 0.7152, 0.0722);

fn srgb_to_linear(c: vec3<f32>) -> vec3<f32> {
    let lo = c / 12.92;
    let hi = pow(max(c + vec3<f32>(0.055), vec3<f32>(0.0)) / 1.055, vec3<f32>(2.4));
    return select(hi, lo, c <= vec3<f32>(0.04045));
}

Answering to another name

A module declares extra names it answers to with @alias lines in the header of module.wgsl:

// @alias: colour_helpers
// @alias: @mypack::shaderModules.colour

Each becomes an alias on the asset, so the name resolves everywhere an identity does — asset.resolve, an #include, and the publish gate alike. That is what lets a module be renamed without breaking the shaders already written against its old name: content persists the source it was authored with, so a name that stops resolving is a world that stops publishing.

Only the header is read — the scan stops at the first line that is not a comment, so a directive cannot hide in the module body. A name another asset already holds is refused and reported, since an alias extends the identity namespace rather than taking a name out of another asset's hands.

Registration & hot reload

Writing module.wgsl registers the module under every name the asset answers to — its guid, its identity, and any alias — so a shader includes it by whichever name it holds. Saving re-registers it and the shaders that include it recompile, with no world reload.

Discovery

  • asset.list("shaderModule") — every registered module.
  • moduleRef:getSource() — the module's WGSL.

Related types

  • .shader — render-domain shaders (surface, sky, post-process, screen).
  • .computeShader — compute programs.

In the Inspector

Selecting a shader module opens its Module section: how many lines it holds, the aliases a shader #includes it by, and an opener for module.wgsl.

Interface

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

conforms to

zero/asset-type/v1
⌬ Spec
suffix.shaderModulecontainernoprimary aliasesmodule.wgslplural dirshaderModulesrequired filesmodule.wgsl, README.md, .metadata
Exposed API
⌬ Instance methods

getSource(self: ?) → string

Read this module's WGSL (`module.wgsl`) as raw text.

argtypedescription
self?

examples

local src = moduleRef:getSource()

setSource(self: ?, src: string) → boolean

Overwrite this module's WGSL. Every shader that includes it recompiles on the next frame.

argtypedescription
self?
srcstringNew WGSL source.

examples

moduleRef:setSource(myWgsl)

register(self: ?) → string

Read this module's WGSL through the VFS and file what it holds now under every name it answers to, so a shader compiled next expands this text. Files unconditionally: the registry answers whether the text moved, and keeps the catalog generation still when the same bytes arrive again.

argtypedescription
self?

examples

local wgsl = moduleRef:register()
⌬ Hooks

onRegister(self: ?) → void

Initial-registration callback: file this module's WGSL under every name it answers to the moment the instance first registers, so a shader that `#include`s it resolves on its first compile rather than only after the module has been written once this session. Idempotent — the guard below skips a re-register of identical source.

argtypedescription
self?

onChange(ref: ?, change: ?) → void

Asset-type change callback: (re)register whenever the WGSL is written. Fires on the initial create and on every later edit, so saving a module reaches the shaders that include it with no world reload.

argtypedescription
ref?
change?

Sub-parts

Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.

4items
This part has no composite children. See the Files segment for its leaf payloads.

Problems

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

0problems
No problems reported. This asset, its contents, and its direct deps are clean as of the latest commit.
⌬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.