shader_uniform

declaration:

::lua
function shader_uniform(shaderid, symbol, formatstr, persistfl, ...) => nil

Sets the value of a specific uniform referenced by symbolname (string) in the successfully built shader referenced by shaderid. The type of the uniform is regulated by formatstr and the persistflag defines if the engine should keep track of the uniform or if the script will update it again.

possible format string patterns:

The types in this list are clearly not complete with respect to the ones used in GLSL, but the need for additional ones have not yet surfaced.

pattern arguments
b boolean
i int
f float
ff vec2
fff vec3
ffff vec4
f x 16 matr4x4

caveats:

This function is expensive and should only be used when absolutely necessary (as with all shaders), if the persistfl is set to NOPERSIST, the values need to be updated when / if the OpenGL context gets removed or modified, if set to PERSIST, the cost of updating the uniforms in the shader active will be slightly higher.


Related

Wiki: Shader Functions
Wiki: image_shader

MongoDB Logo MongoDB