Shader

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 | vector3 | color | image | rendertarget | displayvalueValue to assign - must match the uniform's declared type
Image, rendertarget and display instances are bound as sampler textures

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)
Set a color uniform on a shader
local entity = core.shader.create("assets/shaders/tint.glsl", core.shader.shader_mode.SPATIAL)

entity:set_param("tint_color", {1, 0.5, 0, 1})
Bind a rendertarget as a texture uniform
local entity = core.shader.create("assets/shaders/portal.glsl", core.shader.shader_mode.SPATIAL)
local rt = core.rendertarget.create({512, 512})

entity:set_param("portal_texture", rt)

On this page