I first discovered strange attractors through YouTube and was immediately fascinated. These are mathematical differential equations that describe systems where a set of random points follow defined changes in x, y, and z positions. Over time, the points settle into a structured shape, even though their paths are chaotic.
To learn more, check out the Wikipedia page:
https://en.wikipedia.org/wiki/Thomas'_cyclically_symmetric_attractor
For a previous NuDeco show, I created a visual based on Thomas' cyclically symmetric attractor by following the set of differential equations from the Wikipedia page.
I applied these equations to a visual feedback loop inside TouchDesigner using a compute shader. The following code shows how I implemented the equations efficiently to control particle positions in real time.
// Compute Shader
uniform float b_val;
layout (local_size_x = 8, local_size_y = 8) in;
void main()
{
// input 1
vec4 color = texelFetch(sTD2DInputs[0], ivec2(gl_GlobalInvocationID.xy), 0);
vec3 pos = color.rgb;
float b = b_val;//0.32899;
vec4 final_color;
/* dx */final_color.r= sin(pos.y) - b * pos.x;
/* dy */final_color.g= sin(pos.z) - b * pos.y;
/* dz */final_color.b= sin(pos.x) - b * pos.z;
/* life */final_color.a=1.0;
vec4 imageOut = final_color;
imageStore(mTDComputeOutputs[0], ivec2(gl_GlobalInvocationID.xy), TDOutputSwizzle(imageOut));
}
I passed the b constant as a uniform and set up three different b values as presets on my MIDI keyboard, allowing me to switch between different attractor states live.
b=0.208186
b=0.32899
Besides controlling how fast the attractor formed, I could also manipulate the base shape. But the most interesting effect happened when I changed the order of operations. Instead of constantly following the differential equations in the expected way, I reversed them. This created a scattering and dissolving effect, but in an organized, structured manner.
No comments:
Post a Comment