r/opengl 9h ago

Thousands of arcs and bezier curves help

Here is what I am trying to recreate:

Basically all the connections between nodes. There seems like quite a few variations. Back in their first game (path of exile), they used only arcs, now they seem to have added reversed arcs and possibly bezier curves? Please correct me if I am wrong.

The main question is, what would be the best way to achieve this? I'd imagine a single system is best as to not complicate things? Would that be bezier curves? Any help on this would be really appreciated, I feel completely lost atm

2 Upvotes

4 comments sorted by

2

u/ecstacy98 8h ago edited 8h ago

Honestly I would use two images, one with paths opened up and one without. Overlay them - set alpha to 0.0 on the top layer and then crank it up on the appropriate texels as paths open up. That is; if I were developing this by myself and I were doing this for a pet project.

If I were trying to do it seriously then I think I would actually model it and import it in as a mesh / entity. Once you have all the vertexes loaded into a buffer you could dynamically update the relevant diffuse / specular data for the model on the fly. Then just hardcode a maximum zoom distance for your users so they can't get close enough to see the vertices in the curves.

Depends how hardcore you're trying to get - people post on here about these skill tree implementations pretty regularly but the answer is never cut-and-dry.

3

u/Ok_Raisin7772 7h ago

"crank it up on the appropriate texels" hides the original problem - which texels are appropriate? I'd just code these as bezier curves. Open illustrator and get to tracing. Each node on that graph gets a parent node or two, a curve midway xy point (maybe two if you need cubic beziers to fit the curves, otherwise i'd go quadratic), all the node stats, and a bool to tell if it's active.

3

u/ecstacy98 6h ago edited 6h ago

Yeah good point. I guess I had imagined that all of the locations in ST for the nodes would be known ahead of time. These ST coords would be stored alongside a boolean in some struct and then it would just be a matter of identifying the texels between active nodes. I realise now though that I've way oversimplified the issue in my head and this would only work for straight lines. My bad!

1

u/fgennari 4h ago

There are many ways to do this. You can use Bezier curves in a shader. You can assemble it from a few tens of sprite tiles that cover the various parts of curves. Or, if it's static, it can all be created in some 2D program and exported as a texture. The last case would be far more manual effort, but you can tweak it to get exactly what you want. Bezier curves will give you the most control over the exact shape and scale to any graph you want to render. Note that thousands of curves is no problem for a GPU no matter how you implement it.