Non Linear Gradient for Kinetics
  • borisacket
    junior Member
    Posts: 9
    Joined: Sun Oct 09, 2022 4:43 pm

    Non Linear Gradient for Kinetics

    by borisacket » Thu May 16, 2024 8:23 pm

    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
  • mad-matt
    garageCube team
    Posts: 1579
    Joined: Mon Sep 09, 2013 5:50 pm

    Re: Non Linear Gradient for Kinetics

    by mad-matt » Tue May 21, 2024 12:58 am

    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);

Who is online

Users browsing this forum: No registered users and 35 guests