shader_ugroup(3)

πŸ“¦
version 0.7.1 Β· 2 versions
, in nixos 26.05

✨ 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 πŸ¦‹

  1. 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