A game about forced loneliness, made by TACStudios
1# Gradient Node 2 3## Description 4 5Defines a constant **Gradient** for use in [Shader Graph](index.md), although internally to the shader this is defined as a **struct**. To sample the **Gradient** it should be used in conjunction with a [Sample Gradient Node](Sample-Gradient-Node.md). When using a separate **Gradient Node**, you can sample a **Gradient** multiple times with different Time parameters. 6 7## Ports 8 9| Name | Direction | Type | Description | 10|:------------ |:-------------|:-----|:---| 11| Out | Output | Gradient | Output value | 12 13## Controls 14 15| Name | Type | Options | Description | 16|:------------ |:-------------|:-----|:---| 17| | Gradient Field | | Defines the gradient. | 18 19## Generated Code Example 20 21The following example code represents one possible outcome of this node. 22 23``` 24Gradient Unity_Gradient_float() 25{ 26 Gradient g; 27 g.type = 1; 28 g.colorsLength = 4; 29 g.alphasLength = 4; 30 g.colors[0] = 0.1; 31 g.colors[1] = 0.2; 32 g.colors[2] = 0.3; 33 g.colors[3] = 0.4; 34 g.colors[4] = 0; 35 g.colors[5] = 0; 36 g.colors[6] = 0; 37 g.colors[7] = 0; 38 g.alphas[0] = 0.1; 39 g.alphas[1] = 0.2; 40 g.alphas[2] = 0.3; 41 g.alphas[3] = 0.4; 42 g.alphas[4] = 0; 43 g.alphas[5] = 0; 44 g.alphas[6] = 0; 45 g.alphas[7] = 0; 46 return g; 47} 48 49Gradient _Gradient = Unity_Gradient_float(); 50```