# engineSetMaterialValue (Client)

> Sets a material's value: a shader parameter, a static switch or the render target of a `TARGET_n` output.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Client
- **Category**: Materials and shaders
- **URL**: https://wiki.mymp.gg/en/engineSetMaterialValue

## Syntax

```lua
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

```lua
local screen = dxCreateRenderTarget(512, 256)
local material = engineCreateMaterial("surface")
engineSetMaterialValue(material, "emissionMap", screen)
engineSetMaterialValue(material, "roughnessFactor", 0.1)
engineSetModelMaterial("kmb_atm1", 1, material)
```

### Note

A 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.

## See also

- [engineGetMaterialValue (Client)](https://wiki.mymp.gg/en/engineGetMaterialValue.md): Reads a value the material sets: a parameter, a static switch or a TARGET_n output.
- [engineResetMaterialValue (Client)](https://wiki.mymp.gg/en/engineResetMaterialValue.md): Drops a value the material set, or all of them, going back to what its base gives.
- [engineGetMaterialParameters (Client)](https://wiki.mymp.gg/en/engineGetMaterialParameters.md): Lists the parameters of the shader a material uses.
- [dxCreateRenderTarget (Client)](https://wiki.mymp.gg/en/dxCreateRenderTarget.md): Creates a render target: an image the dx functions can draw into and that can be used like any other image.
