A compiled shader returned by datumhue.shader.new or bytes:shader, applicable to draw canvases, UI panels, or scene materials. A 3D mesh shows its color unlit; a custom shader as a standard material's shader is lit.
Update a preset shader's parameters. Changes propagate to every primitive using this shader. Custom shaders raise — their state changes through set / set_channel.
Example
-- Presets only: a custom shader changes through set and set_channel.local glow = datumhue.shader.new({
type = "animated_glow",
color1 = datumhue.color("#2d353b"),
color2 = datumhue.color("#dbbc7f"),
})
datumhue.ui.root:panel({ width = 120, height = 80 }):set_material(glow)
-- param1 is the glow's strength, param2 its pulse speed.
glow:update({ param1 = 2, param2 = 0.5 })
Bind or clear a custom shader's channel texture. index is 1-based and maps down by one to the 0-based uniform: set_channel(1) writes dh_channel0, set_channel(2) writes dh_channel1, up to set_channel(4) for dh_channel3. source is a pixel canvas, draw canvas, or scene handle, or nil to restore white.
Recompile a custom shader from new source, keeping its declared uniforms, current values, and channels. On a compile error the previous program keeps rendering and the error raises with the failing source line.
Example
-- New source; the uniforms, their values and the channels stay.
shader:reload(datumhue.bytes([[fn dh_fragment(uv: vec2<f32>) -> vec4<f32> { return u.tint * (1.0 - uv.y);}]]))
Remove the shader. A custom shader's slot under the per-app limit is freed; anything the shader is applied to keeps its current look. Afterwards state reads failed, calling remove again does nothing, and every other method and property of the handle raises.
Wait until this asset is fully loaded, then return it for chaining. An in-memory asset returns at once; one still loading (a file read or remote fetch) yields the coroutine until it lands. A load failure raises; format errors on playable assets still surface at use time.