Flocking boids 2D

flo

I made a flocking boids implementation. I just started learning Touchdesigner so any feedback or comment is very appreciated. The boids’ location and velocity data is calculated in a glsl top. Since the glsl top can only output four numbers (vec4) for each pixel, I had to use another glsl top to output the direction angle. I feel there’s got to be a better way to do this. I plan to do 3D next, which would require an output of at least 2 vec3 for each pixel. I’ll need to figure that out as well. Any suggestion?
flocking2d.toe (9.6 KB)

1 Like

Pretty sweet, well done!

You can write to multiple buffers in one shader and then select those different buffers with the Render Select TOP to use for instance data. The “Write a GLSL TOP” article in the wiki has all the documentation you need to refer to. There are also a number of other examples and such posted on the forum using multiple buffers in a pixel shader as well. Also the Particles GPU palette COMP has some great stuff, though it is using a compute shader so works a bit differently than a simpler pixel shader.

1 Like

Thank you! That’s exactly what I was looking for!