Procedural Generation using Noise

The easiest way is to use a 1d texture lookup defining the gradient. The other way is to use the Distance node to create a mask for each color band that you want. Then each color band is a Lerp node where the A input includes all previous band lerps, and B is the current band color. You can easily use math to evenly space the bands or specify each band location with a scalar.

Or you could go hardcore and encode the colors manually like I did for this shader complexity preview material. You could make each color an input to the custom node:


float3 colors[10];

colors[0]=float3(0,1,0.127);
colors[1]=float3(0,1,0);
colors[2]=float3(0.046,0.52,0);
colors[3]=float3(0.215,0.215,0);
colors[4]=float3(0.52,0.046,0);
colors[5]=float3(0.7,0,0);
colors[6]=float3(1,0,0);
colors[7]=float3(1,0,0.5);
colors[8]=float3(1,0.9,0.9);
colors[9]=float3(1,1,1);

float cindex = floor((x)*9);
float cphase = frac((x)*9);

return lerp(colors[cindex],colors[cindex+1],cphase);

obviously you need to add an input named x as well and make sure to replace the constant 9 in there with your number of colors minus 1.