shader_ugroup(3)
β¨ shader_ugroup β¨
okay bestie, we're in the Arcan Lua API and this one is a shader_ugroup(3) situation β it's all about allocating a uniform group inside a shader π
πΈ SYNOPSIS πΈ
out_shid or nil
shader_ugroup( shid )
π DESCRIPTION π
so literally every shader comes with a default group of shaders that shader_uniform applies to. that's the baseline, the main character energy of uniform groups π«Ά
but highkey, a lot of the time you want multiple objects that use the same shader, just with a slightly different set of uniforms. and that's exactly where shader_ugroup comes in, bestie β it creates a derivative shader that uses most of the same underlying resources but switches to a different set of uniforms when it gets activated. slay.
the returned shader is valid for all shader related calls, but its lifecycle belongs to the shader it was derived from (no cap, it's a whole dependent situation).
any forced uniform at the time of group creation gets copied from the group associated with the specified shid. also important: there's a finite amount of uniform group slots available to each shader. so if the provided shid is invalid, or there aren't enough free group slots left in the shader, then out_shid will be nil π
π¦ NOTES π¦
- ngl, it's bad form to ever rely on the specific value of a shid β but for the record, shaders that are derived typically have a value
> 65535π
π EXAMPLE π
function shader_ugroup0()
local frag = [[
uniform float r;
uniform float g;
uniform float b;
void shader_ugroup0(){
gl_FragColor = vec4(r, g, b, 1.0);
}
]];
local shid = build_shader(nil, frag, "csh");
a = fill_surface(64, 64, 0, 0, 0);
b = fill_surface(64, 64, 0, 0, 0);
show_image({a, b});
move_image(b, 64, 0);
image_shader(a, shid);
shader_uniform(shid, "r", "f", 1.0);
shader_uniform(shid, "b", "f", 0.0);
-- r and b values will be inherited, g is undefined
local shid2 = shader_ugroup(shid);
image_shader(b, shid2);
-- g is now defined in shid1, undefined in shid2
shader_uniform(shid, "g", "f", 1.0);
shader_uniform(shid2, "g", "f", 0.0);
end
π SEE ALSO π
π§ and that's the whole vibe check, bestie β go forth and group those uniforms π
so yeah, that was shader_ugroup from the vidsys source, version October 2026 edition β iconic, honestly πβ¨π
π¦ where this page comes from
- nixos 26.05: arcan 0.7.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms