The "vngen_set_shader_sampler" Function
#
SyntaxArgument | Type | Description |
---|---|---|
id | real/string | The ID of the specific entity to modify |
type | integer/macro | Sets which type of entity to modify |
[name] | string | Optional: Sets the character name to check, if entity is an attachment |
uniform | string | Sets the shader uniform to modify, as a string |
source | sprite/string | Sets the sprite or surface to assign to the shader uniform (string required for surface) |
#
DescriptionWhen 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 sprite or surface to a shader uniform defined within the shader itself. While it might seem strange, surfaces must be input as a string, not the associated variable itself, as this is the only way to differentiate between whether the intended source is a sprite or not.
important
Surfaces passed into shaders as samplers must be created and drawn to before vngen_object_draw
is run.
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:
Note the names and functions of these uniform values when supplying uniform names to be modified.