Shaders and materials
· 2 min read
A shader language with imports, and materials that relink the moment the shader is saved.
What landed
- Shaders. WESL — WGSL plus imports,
@ifvariants and dead-code elimination — linked to WGSL at run time. A 2D shader importspackage::sprite; a 3D one importspackage::meshand callsshade(in)for the scene's lights. - Materials. A
materialasset names a shader and its[params], read off the linked shader rather than declared twice.sprite,shape2d,shape3dandmeshtake one; a node without one draws with the built-in material. - Relink on save. Save the shader and every material naming it relinks and every node drawing with it is rebuilt. One that will not link is reported with the line the author wrote, and the node keeps the built-in material meanwhile.
- Channels.
render::set_channel("uv")draws the scene's UVs instead of its colour;normals,depthandalbedoare the others.
# materials/glow.toml
type = "material"
shader = "shaders/glow.wesl"
[params]
speed = 2.0
rings = 5.0
tint = "#ffb347"
Rendering observes the simulation and feeds nothing back, so a shader is
outside the digest and time() is render time, not the tick. A function
marked @const still runs on the CPU in headless tests.
examples/shaders is a glow material on a sprite beside a plain one, and
it runs in the browser.
Shaders and materials in the manual.
