Advertisement

Creating Sphere with GL_TRIANGLE_STRIP

Started by May 11, 2019 09:16 AM
13 comments, last by Gnollrunner 5 years, 8 months ago

Afaik vertex- and an index buffers for opengl and d3d are built identically. Valid until correction ?

Suggesting to OP to tessellate an icosphere instead of slices. Triangles are almost equally distributed, no singularities, only the "terminator line" where textures meet needs some attention.

 

6 hours ago, Gnollrunner said:

Finally a third option is to sub-divide an icosahedron.  This is my goto sphere! It gives you far more even triangulation but it's trickier to generate algorithmically.

I submit that an icosphere is not particularly tricky to generate algorithmically. Once you have hardcoded the indexing of the base icosohedron, subdivision is fairly straightforward.

To put my money where my mouth is, here's a straightforward implementation ripped from a current project (feel free to use/adapt if you like).

I'd also say to the OP, that triangle strips aren't really a worthwhile optimisation here. It's quite tricky to generate a sliced sphere in a single triangle strip (typically requiring the introduction of degenerate triangles), so at best you'll save a (very small) amount of memory, and at worst you end up rendering using multiple strips which means multiple draw calls... and that's more expensive than just using a triangle list instead.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Advertisement
8 hours ago, Gnollrunner said:

I would think you would have repeat each strip twice, except for the top and bottom, because you have to do a zig-zag between them.

I'm guessing you meant rows of vertices and not strips?

🙂🙂🙂🙂🙂<←The tone posse, ready for action.

9 hours ago, swiftcoder said:

I submit that an icosphere is not particularly tricky to generate algorithmically. Once you have hardcoded the indexing of the base icosohedron, subdivision is fairly straightforward.

To put my money where my mouth is, here's a straightforward implementation ripped from a current project (feel free to use/adapt if you like).

I'd also say to the OP, that triangle strips aren't really a worthwhile optimisation here. It's quite tricky to generate a sliced sphere in a single triangle strip (typically requiring the introduction of degenerate triangles), so at best you'll save a (very small) amount of memory, and at worst you end up rendering using multiple strips which means multiple draw calls... and that's more expensive than just using a triangle list instead.

Ha, ha, Rust looks like Greek to me :D but I think I got the gist of it. Kind of a breath first traversal type thing, although it's not really a tree per se.  I actually build a tree, and it has actual edges, but then I'm not using it strictly for graphics and it has to change at run time so I can't afford to search for edges.

This topic is closed to new replies.

Advertisement