Convert Rainbow gradient Shader to 3 colors gradient

by cyo   Last Updated October 10, 2019 17:13 PM

I am attempting to convert this rainbow shader into just using three colors. I thought I would be able to set the three colors in the shader file, but I can't understand how to link them through the shader helper file.

shader: https://hastebin.com/uworiduluc.cs Shader helper: https://hastebin.com/kifezufegi.cs

fixed4 frag(fragmentInput i) : SV_TARGET{
fixed2 lPos = i.localPosition / _Spread;
half time = _Time.y * _Speed / _Spread;
half timeWithOffset = time + _TimeOffset;
fixed sine = sin(timeWithOffset);
fixed cosine = cos(timeWithOffset);

fixed hue = (-lPos.y) / 2.0;
hue += time;
while (hue < 0.0) hue += 1.0;
while (hue > 1.0) hue -= 1.0;
fixed4 hsl = fixed4(hue, _Saturation, _Luminosity, 1.0);
return HSLtoRGB(hsl);
}

I added these properties at the top

_Color3 ("Top", Color) = (1,1,0,1)    
_Color2 ("Middle", Color) = (1,1,0,1)
_Color1 ("Bottom", Color) = (1,1,0,1)

But I am not sure where I can add them into the code to have them be the colors that are used.

Tags : unity shaders


Related Questions


Updated March 28, 2015 09:04 AM

Updated April 05, 2015 18:05 PM

Updated April 28, 2017 08:13 AM

Updated June 01, 2017 17:13 PM

Updated June 10, 2015 22:05 PM