A procedural way to define color palettes. Rainbow takes samples from a slice out of the HSL color wheel, modest min/max combines two random colors using the minimum and maximum functions, HSL wheel arcs samples colors from a wheel using arcs and symmetries.
Along with a seed value these procedures should provide harmonic color combinations in Houdini setups.
float s = chf('scale');
float r = chf('rotate');
float a = chf('angle');
float b = chf('brightness');
function vector color(vector pos; float b){
float hue = atan(pos.x, pos.y);
hue = fit(hue, -PI, PI, 0.0, 1.0);
float sat = length(pos);
float val = b;
vector clr = hsvtorgb(hue, sat, val);
return clr;
}
function vector arc(float u, sc, rot, angle){
vector2 dir = sample_circle_edge_uniform(rot);
vector2 uv = set(u, sc);
vector2 pos = sample_circle_slice(dir, angle*PI_2, uv);
vector p = vector(pos);
return p;
}
float u = i@primnum/(i@numprim - 1.0);
v@Cd = color(arc(u, s, r, a), b);
function vector recolor(vector clr){
vector c = rgbtohsv(clr);
c[1] = min(c[1], 0.75);
c[2] = clamp(c[2], 0.05, 0.8);
c = hsvtorgb(c);
return c;
}
int seed = chi('seed');
vector a = rand(0, seed);
vector b = rand(1, seed);
a = recolor(a);
b = recolor(b);
int class = i@primnum % 3;
if(class == 1) b = a;
if(class == 2) a = b;
v@Cd = min(a, b) / pow(max(a, b), 0.25);
float fall = chf('falloff');
vector p = v@P * sqrt(1.5);
float wheel = atan2(p.y, p.x);
float hue = fit(wheel, -PI, PI, 0.0, 1.0);
float radius = length(p);
v@Cd = hsvtorgb(hue, 1.0 - pow(radius / 2.0, fall), radius);