GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
shader_ugroup(3) Arcan Lua API shader_ugroup(3)

shader_ugroup - Allocate a uniform group inside a shader

out_shid or nil
shader_ugroup( shid )

All shaders have a default group of shaders that the shader_uniform function applies to. In many cases, however, one might want to have multiple objects that uses the same shader but with a slightly different set of uniforms. shader_ugroup can be used to create a derivative shader that uses most of the same underlying resources but switches to a different set of uniforms when activated. The returned shader is valid for all shader related calls but has its lifecycle to the shader it was derived from. Any forced uniform at the time of group creation will be copied from the group associated with the specified shid. There's a finite amount of uniform group slots available to each shader, and if the provided shid is invalid or there are not enough free group slots left in the shader, the out_shid will be nil.

1
Though it is bad form to ever rely in the specific value of a shid, shaders that are derived typically have a value > 65535.

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

build_shader(3) delete_shader(3)

June 2022 vidsys

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.