Texture2D GradientTextureTriple(Color startColor, Color middleColor, Color endColor, int textureWidth, float mixPosition)
{
Texture2D texture = new Texture2D(textureWidth, 1);
Color[] gradientColors = new Color[textureWidth];
for (int i = 0; i < textureWidth; i++)
{
float t = Mathf.InverseLerp(0, textureWidth - 1, i);
gradientColors[i] = Color.Lerp(
Color.Lerp(startColor, middleColor, t),
Color.Lerp(middleColor, endColor, t),
Mathf.Lerp(0, 1, Mathf.Clamp01(t - mixPosition)));
}
texture.SetPixels(gradientColors);
texture.Apply();
return texture;
}