hi all - a general and specific GLSL question -
i have a data visualisation i’ve been building - using the replicator and SOPS mainly - its some text mapped to some lines and then bezier curves - the static performnce is good and i can interact with it all with quasi 60 fps -
now i want to start building some movement in and obviously the whole thing grinds to a halt - so i was wanting to try an transpose the whole thing to GLSL - its all procedural so i have the data there ready and i was thinking i could:
-pass in the start point which is the category then iterate through the data drawing a bezier curve to each of the destination points -
seems simple enough but in 6+ years of using TD I hit a wall every time I try and dig into GLSL - so I have three main quesitons:
-
would i get a performance gain from doing this - concerned that using a geometry shader i’m basically going to be creating loads of primitives anyway so would i get much improved performance if i’m having to redraw 700+ beziers every frame ?
-
is the work flow for this to pass in the data straight to the geo shader or should i create the points and pass them into the geo comp first … then draw the curve in the geo shader -
-
does anyone have a good simple set of resources or even a simple example to hand for just drawing primitives in 3d space from data - i’ve gone through all the examples i can find and they are all a little too specific for their example case and i can’t quite parse them in my mind …
any help much appreciated -
Hi there,
I think using GLSL definitely will gain better performance for this problem. What I would do is instance a set of lineSOPs with for example 100 vertices each. Then inside a vertex shader you can displace the vertices using a bezier curve. You don’t have to use a geometry shader for this.
What you would need is the start and end position per line, then using TDInstanceID() you could fetch the right positions and then using gl_VertexID interpolate the bezier curve. The more vertices you have
the more smooth the curve is going to be.
Let me know if this makes sense, if not I can make an little example.
Cheers,
tim
Couldn’t help myself and made a little example 
Hope it helps!
cheers,
tim
CubicBezier.tox (1.7 KB)
2 Likes
tim! you are a star - im pretty sure you’ve given me a hand here before on something!
that’s a really great way to approach my problem - as ever with TD so many ways to skin a cat - and a much cleaner way of thinking about it
- i 100% follow the logic and theory of it all - would need to work out the vertextID and interpolation but the theory is great -
just downloaded the example - a bit late here (UK) but will fire it up and check it out first thing
thanks again!
b
1 Like
ok - couldn’t resist had a peek at the example - that is very nice!
thanks again - will implement to morrow and let you know!
best
Ben
1 Like
works like an absolute charm - 722 lines - threw some noise through them and it didn’t even break a sweat! thanks again - fully getting my head into and around GLSL has been on to do list for longer than i can remember but i keep hitting a wall with it every time i try - this has been a huge help both project wise and also understanding glsl and methodologies
B
Nice!! Happy I could help 
Btw, if you want to animate/have control over the line colors, you can pass down the uv coordinates in the vertex shader to the pixel shader. Since a line is just 1 dimensional, you only need the uv.x which would be 0 at the start point and 1 at the end. See attached tox as an example if you’re interested 
Cheers,
tim
CubicBezier-animated-colors.tox (1.8 KB)
4 Likes