Skip to main content

The "vngen_set_shader_float" Function

Syntax#

vngen_set_shader_float(id, type, [name], uniform, value);
ArgumentTypeDescription
idreal/stringThe ID of the specific entity to modify
typeinteger/macroSets which type of entity to modify
[name]stringOptional: Sets the character name to check, if entity is an attachment
uniformstringSets the shader uniform to modify, as a string
valuerealSets the value to assign to the shader uniform

Description#

When writing a shader, it can be useful to pass information from GML to the shader. Normally, shader variables are completely separate from GML and can't be modified externally, however it is possible to pass in variables called uniforms which are then referenced in shaders, allowing GML and shaders to communicate.

VNgen uses its own implementation of shaders on a per-entity basis. With this script, it is possible to assign a floating-point (real) value to a shader uniform defined within the shader itself.

Note that VNgen automatically passes in 5 default input values for handling fade transitions, global time, mouse and view coordinates, and the parent entity dimensions. These values are read-only and cannot be modified, but are very useful for designing shaders themselves.

They are:

uniform float in_Amount; //Transition percentage (0-1)
uniform float in_Time; //Seconds active
uniform vec2 in_Mouse; //X/Y
uniform vec2 in_Offset; //View X/Y
uniform vec2 in_Resolution; //Width/Height

Note the names and functions of these uniform values when supplying uniform names to be modified.

Example#

vngen_set_shader_float("bg", vngen_type_scene, "my_uniform", 0.0);