self:set_param

Client

Sets a uniform parameter on the shader by name


Syntax

local status = self:set_param(
    name,
    value
)

Parameters

TypeNameDescription
stringnameName of the uniform parameter as declared in the GLSL source
bool | number | vector2 | vector3valueValue to assign - must match the uniform's declared type

Returns

TypeNameDescription
boolstatustrue on successful execution, false otherwise

Examples

Set a float uniform on a shader
local entity = core.shader.create("assets/shaders/dissolve.glsl", core.shader.shader_mode.SPATIAL)

entity:set_param("dissolve_amount", 0.75)
Set a vector2 uniform on a shader
local entity = core.shader.create("assets/shaders/ripple.glsl", core.shader.shader_mode.CANVAS_ITEM)

entity:set_param("wave_direction", {1.0, 0.5})
Set a bool uniform on a shader
local entity = core.shader.create("assets/shaders/outline.glsl", core.shader.shader_mode.SPATIAL)

entity:set_param("show_outline", true)

On this page