engineSetMaterialValue
Client
Sets a material's value: a shader parameter, a static switch or the render target of a TARGET_n output.
bool engineSetMaterialValue(material material, string name, any value)
Parameters
| Name | Type | Description |
|---|---|---|
| material | material | The material. |
| name | string | The parameter's, switch's or output's name. |
| value | any | A number for float and uint; a vector for vec2, vec3 and vec4, or a tocolor value for vec3 and vec4 (turned from sRGB into linear); a texture's name or an image (texture, render target, screen source, dui or post image) for a texture; a boolean for a switch; a render target for TARGET_n. |
Returns
true when the value was set.
Example
local screen = dxCreateRenderTarget(512, 256)
local material = engineCreateMaterial("surface")
engineSetMaterialValue(material, "emissionMap", screen)
engineSetMaterialValue(material, "roughnessFactor", 0.1)
engineSetModelMaterial("kmb_atm1", 1, material)NoteA name the shader does not declare is an error, and so is a value of the wrong type. While the shader is still compiling, the type is taken from the Lua value.