Page 1 of 1

Non Linear Gradient for Kinetics

Posted: Thu May 16, 2024 8:23 pm
by borisacket
Dear readers,

I am generating gradients to control kinetics. I was wondering if there is a way to generate non linear gradients in the madmapper gradient shader or to maybe alter the shader to generate them. I am looking for sinewaves instead of linear animations, the gradients generated by the gradient shader are linear.

Boris

Re: Non Linear Gradient for Kinetics

Posted: Tue May 21, 2024 12:58 am
by mad-matt
Hi, you can edit the shader (right click the Gradient and choose "Open in Editor", in editor tool bar, press the button with 3 dots and choose "New Material from Gradient Color".
In the code, replace the line:

vec4 col = mix(colors[stepId%mat_color_count],colors[(stepId+1)%mat_color_count],pow(pos/stepSize-stepId,pow(mat_curve,6)));

with

// pos/stepSize-stepId is a value in 0 & 1 range, at 0 we show one color, at 1 the next color
// Make it a sinusoid
float mixFactor = 0.5 + 0.5 * sin( -PI/2 + (pos/stepSize-stepId) * PI );
vec4 col = mix(colors[stepId%mat_color_count],colors[(stepId+1)%mat_color_count],mixFactor);