Files

40 lines
1.4 KiB
Markdown
Raw Permalink Normal View History

2026-10-21 20:45:23 +01:00
# Rectangle Node
## Description
Generates a rectangle shape based on input **UV** at the size specified by inputs **Width** and **Height**. The generated shape can be offset or tiled by connecting a [Tiling And Offset Node](Tiling-And-Offset-Node.md). Note that in order to preserve the ability to offset the shape within the UV space the shape will not automatically repeat if tiled. To achieve a repeating rectangle effect first connect your input through a [Fraction Node](Fraction-Node.md).
NOTE: This [Node](Node.md) can only be used in the **Fragment** [Shader Stage](Shader-Stage.md).
## Ports
2026-11-30 19:13:17 +00:00
| Name | Direction | Type | Binding | Description |
|:--- |:---|:---|:---|:---|
| UV | Input | Vector 2 | UV | Input UV value |
| Width | Input | Float | None | Rectangle width |
| Height | Input | Float | None | Rectangle height |
| Out | Output | Float | None | Output value |
2026-10-21 20:45:23 +01:00
## Controls
2026-11-30 19:13:17 +00:00
| Control | Description |
|:---|:---|
| (Dropdown) | Select the robustness of computation. The options are:<ul><li>**Fastest**</li><li>**Nicest**</li></ul> |
2026-10-21 20:45:23 +01:00
## Generated Code Example
The following example code represents one possible outcome of this node.
```
void Unity_Rectangle_float(float2 UV, float Width, float Height, out float Out)
{
float2 d = abs(UV * 2 - 1) - float2(Width, Height);
d = 1 - d / fwidth(d);
Out = saturate(min(d.x, d.y));
}
```
2026-11-30 19:13:17 +00:00
## Additional resources
[!include[nodes-example-samples](./snippets/nodes-example-samples.md)]