/** * Sigmoid interpolation between the components of a vector based on x ∈ [0; 1], * cycling through its components then wrapping back to the first one, * and repeating periodically when x ∈ ℝ \ [0; 1]. */ float smoothCycleMix(vec2 v, float x) { float t = mod(x, 1.) * 2.; float i = floor(t); return dot(mix(v, v.yx, smoothstep(0., 1., fract(t))), vec2( 1. - step(1., i), step(1., i) )); } float smoothCycleMix(vec3 v, float x) { float t = mod(x, 1.) * 3.; float i = floor(t); return dot(mix(v, v.yzx, smoothstep(0., 1., fract(t))), vec3( 1. - step(1., i), step(1., i) * (1. - step(2., i)), step(2., i) )); } float smoothCycleMix(vec4 v, float x) { float t = mod(x, 1.) * 4.; float i = floor(t); return dot(mix(v, v.yzwx, smoothstep(0., 1., fract(t))), vec4( 1. - step(1., i), step(1., i) * (1. - step(2., i)), step(2., i) * (1. - step(3., i)), step(3., i) )); }