5 Samples a **Gradient** given the input of **Time**. Returns a **Vector 4** color value for use in the shader.
9 | Name | Direction | Type | Binding | Description |
10 |:------------ |:-------------|:-----|:---|:---|
11 | Gradient | Input | Gradient | None | Gradient to sample |
12 | Time | Input | Vector 1 | None | Point at which to sample gradient |
13 | Out | Output | Vector 4 | None | Output value as Vector4 |
15 ## Generated Code Example
17 The following example code represents one possible outcome of this node.
20 void Unity_SampleGradient_float(float4 Gradient, float Time, out float4 Out)
22 float3 color = Gradient.colors[0].rgb;
24 for (int c = 1; c < 8; c++)
26 float colorPos = saturate((Time - Gradient.colors[c-1].w) / (Gradient.colors[c].w - Gradient.colors[c-1].w)) * step(c, Gradient.colorsLength-1);
27 color = lerp(color, Gradient.colors[c].rgb, lerp(colorPos, step(0.01, colorPos), Gradient.type));
29 #ifndef UNITY_COLORSPACE_GAMMA
30 color = SRGBToLinear(color);
32 float alpha = Gradient.alphas[0].x;
34 for (int a = 1; a < 8; a++)
36 float alphaPos = saturate((Time - Gradient.alphas[a-1].y) / (Gradient.alphas[a].y - Gradient.alphas[a-1].y)) * step(a, Gradient.alphasLength-1);
37 alpha = lerp(alpha, Gradient.alphas[a].x, lerp(alphaPos, step(0.01, alphaPos), Gradient.type));
39 Out = float4(color, alpha);