Connecting points with lines in Geometry Shader

As the title says, i’m trying to connect a series of points with other nearby points using GLSL. I’m calculating the current point position in the vertex shader, and then looping through every other point position in the buffer using texelFetch() and a samplerBuffer until I find a nearby point. I’m then passing both of those positions to the geometry shader to connect them with a line_strip.

For some reason all of my nearby point positions seem to be in weird places and I can’t figure out why? Any help would be appreciated!

Point Cloud Connect.15.toe (6.8 KB)

Hi, Does this help: Plexus in Touchdesigner - YouTube plexus by paketa12

or plexus from alphamoonbase on olib: TD OLIB

1 Like

There’s a bit of confusion regarding transforms in your file.
Since you’re using instancing, P/pos in the vertex shader is vec3(0), TDDeform() has the instance transform.
So you actually want to compare the positions in the noise texture to TDDeform(pos).

See quick fix
Point Cloud Connect.16.toe (6.7 KB)

As a side note you should avoid the topto (any copy from gpu mem to cpu mem is slow or 1 frame late) and send that as a samplerbuffer and instead directly read the position for the texture with texelfetch() (same as texture() but you pass pixel coordinates and there’s no filtering).

Hope it helps!
See Greg’s post for other solutions

3 Likes

Perfect, thanks guys!

1 Like