engineSetShaderGlobal
Client
Sets a shader global, a value every shader reads. A new name creates the global.
bool engineSetShaderGlobal(string name, any value [, int priority = 0])
Parameters
| Name | Type | Description |
|---|---|---|
| name | string | The global's name. Shaders read it in UPPER_SNAKE_CASE: nightShare becomes NIGHT_SHARE. |
| value | any | A number, a vector, a tocolor value for vec3 and vec4, or a texture's name or an image for a texture. A global that already exists only takes its own type. |
| priority | int | When several resources set the same global, the highest priority wins; between equals, the newest.default 0 |
Returns
true when the value was set.
Example
engineSetShaderGlobal("alarmPulse", 0)
local shader = engineCreateShader("shaders/alarm.shader")
addEventHandler("onClientPreRender", root, function()
engineSetShaderGlobal("alarmPulse", math.abs(math.sin(getTickCount() / 300)))
end)NoteA global a pack locked, or a value of another type, is an error. A shader that reads a script's global compiles only if the global exists when the shader is created.