# dxDrawRectLight (Client)

> Lights from a rectangle for a single frame, without creating an element.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Client
- **Category**: Lights
- **URL**: https://wiki.mymp.gg/en/dxDrawRectLight

## Syntax

```lua
bool dxDrawRectLight(float x, y, z, float normalX, normalY, normalZ, float width, float height, float radius, color color [, float intensity = 1, float falloff = 4, float barnDoorAngle = 88, float barnDoorLength = 0.2, bool castShadow = false, float tangentX, tangentY, tangentZ = nil])
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `x, y, z` | `float` | The light's position in the world, three numbers or a vec3. |
| `normalX, normalY, normalZ` | `float` | Where the rectangle's face points. Three numbers or a vec3, finite and non-zero; it is normalised. The light shines only in front. |
| `width` | `float` | Width of the rectangle in metres, from 0.01 to 100. |
| `height` | `float` | Height of the rectangle in metres, from 0.01 to 100. |
| `radius` | `float` | Range in metres, above 0 and up to 1000. |
| `color` | `color` | Three numbers `r, g, b` (integers from 0 to 255) or a `tocolor` value. Alpha is ignored. |
| `intensity` | `float` | Brightness multiplier, from 0 to 1000. At 1, a white light shines with an HDR radiance of 12. *(default: `1`)* |
| `falloff` | `float` | Exponent of the fade toward the radius, from 0.1 to 32. Higher values keep the light strong closer to its edge. *(default: `4`)* |
| `barnDoorAngle` | `float` | Angle of the barn doors from the normal, from 0 to 90 degrees. From 88 up they block nothing. *(default: `88`)* |
| `barnDoorLength` | `float` | Length of the barn doors in metres, 0 or more. *(default: `0.2`)* |
| `castShadow` | `bool` | Whether the light casts shadows. *(default: `false`)* |
| `tangentX, tangentY, tangentZ` | `float` | Direction of the rectangle's width, three numbers or a vec3. Left out, it is made from the normal and the world's up axis. A zero vector or one along the normal logs a warning. *(default: `nil`)* |

## Returns

`true` if the light was queued for the frame. `false` when 256 lights are already queued, or with a wrong argument.

The light lasts one frame. A call made before the world is drawn (for example in `onClientPreRender` or `onClientRender`) lights that frame; one made after it lights the next. Calls made while no frame runs are dropped. Going over 256 lights in a frame logs a warning once, until a frame leaves room in the queue.

## Example

```lua
addEventHandler("onClientPreRender", root, function()
    dxDrawRectLight(1481.0, -1771.0, 22.0, 0, -1, 0, 4, 0.5, 12, 255, 60, 200, 3)
end)
```

### Coming from MTA

MTA has no dynamic lights.

## See also

- [createRectLight (Client)](https://wiki.mymp.gg/en/createRectLight.md): Creates a light that comes from a rectangle, like a panel or a lit window. The light exists on this client only.
- [dxDrawPointLight (Client)](https://wiki.mymp.gg/en/dxDrawPointLight.md): Lights a point in every direction for a single frame, without creating an element.
- [dxDrawSpotLight (Client)](https://wiki.mymp.gg/en/dxDrawSpotLight.md): Lights a cone for a single frame, without creating an element.
- [onClientPreRender (Client)](https://wiki.mymp.gg/en/onClientPreRender.md): Fired every frame, after the world is simulated and before the world is drawn.
