How to draw lines starting from a table of data in GLSL?

Hi everyone, I am facing a hard time in realizing this task that may feel simple.
I have two lists of coordinates of given points and I’d like to draw lines from them: one list is about the starting points of these lines and the other list gives the arrival point of them. I managed to recreate the geometry through SOPs, but the other issue is that I have tones of lines and as you know that would overload the CPU… that’s why I thought about GLSL, but I actually don’t know how to manage it, also after seeing some relatable material online.
Could anyone help me on this issue?
I thank you in advance :slight_smile:

While this is totally possible in GLSL, it might be worth looking at the ObjectCHOP Snippets section, there’s a good example of how to instance lines by computing bearing and distance values. Your positions are all calculated in CHOPs but because you’ll be using instancing it’ll utilise the GPU.

This post shows the origin of those snippets from Matthew Ragan: Object CHOP Techniques

agree with @jayyson, instanced lines are a good way to go. however here’s a primer for getting started with glsl lines generated with 0 geometry.

The technique, is called SDF rendering, and you can find tons and tons of examples of this on shader toy.

There’s one example in particular that I like called “Glorious Line Algorithm”

I’ve ported it to a tox in the past, here it is:
base_everythingLineFunction.tox (3.9 KB)

Here’s a toe showing how to use that shader toy example to generate a simple line(s) with table dat as a source:
glsl_lines.3.toe (7.6 KB)

2 Likes

Not sure how many is tons, but if you have XYZ start positions in one list, and XYZ end positions in another list, you just need to convert each list into a SOP with the start points forming one line, and another SOP with the end points forming a line. Then merge the 2 lines together, and send it to a Skin SOP to connect starts to ends, and send that to the renderer, using optimally the Line Material.

connectTheDots.tox (2.3 KB)

Hi @lucasm !
I checked on this two references you sent, and they’re awesome! I am not an expert of GLSL and I am trying how to figure out to adapt it to the system I need to create. I was wondering, this is just for 2D lines, am I right? Because the lines I have to build are 3D, so with a z coordinates list.
Let me know if you could tell me something more about how to configure such a system ! :slight_smile:
Thank you so much!!

Hi @greg !
Thank you for the tip and reference, but actually is something I already did and even though it works perfectly, when I talk about tons I mean thousands lines and when using this technique the systems goes heavy, losing fps and so on, even though my computer specs are very good.
Moreover I’d really need to work on GLSL in order to manipulate those lines :')

Hi @jayyson !
Thank you for these ObjectCHOP references, they are so good! I will work an alternate version with these, but my main objective is to draw these lines in GLSL so that I can manipulate them later.