I am procedurally generating meshes. Suppose I was generating a triangle stripe, but instead of defining them in order, I had them jumbled, say I define triangle 1, 3, 5, 7, 9, then 2, 4, 6, 8, 10 (my problem isn’t really about triangle stripes but the idea is the same).
It still seems to render fine. Is there a performance hit? Is it worth worrying about?
The order of the vertex array is irrelevant; the order of the triangle array determines how triangles are rendered. For example, if [1, 2, 3] refers to vertices in a clockwise order, then [1, 3, 2] is counter-clockwise and the surface normal is reversed.
–Eric
Hi Eric,
thanks for replying. I need to be more specific.
I’m wondering if the order of the actual triangles (as defined in the triangle array) matters. Can I haphazzardly construct triangles that result in a closed mesh, or should I (say, for rendering performance reasons) construct triangles such that the edge of the next triangle is connected to an edge of a previous triangle. Assume that every triangle that is created is correctly defined with clockwise winding.
I don’t know how much it matters these days but, in the past, optimizing “mesh topography” was considered important. Calculations on vertices are/were cached, and if a vertex was used multiple times it was best to re-use it before it was removed from the cache, so the order in which verts were processed was important. Whether that’s still a consideration these days I don’t know.
1 Like
Cheers.
Vertices are generally reused immediately, but not always. For now I’ll try to keep in mind caching but I won’t go out of my way complicating my algorithm to guarantee it.
1 Like
It’s worth researching more to see if it’s still an issue. I believe the above was true back when lighting was done per-vertex. Now that it’s done per-pixel it might not even be a thing.
1 Like
My boats are procedurally generated:
R. Lindsay, I don’t think it really matters unless you’re maybe using OpenGL and telling it to render them as actual triangle strips. With my boats, vertices are generated in vertical cross sections starting from the back of the boat and moving toward to the tip. I’m using Unity’s rendering there (not OpenGL except for force vectors and so forth, which is irrelavent to your point). I didn’t pay any attention to trying to order the triangles in any particular way. I did need to make sure the individual triangle vertices were ordered to get the normal direction right.
So in other words, I generate the triangles as strips, but they’re just stored in a Unity mesh class in whatever way was convenient. Each boat is multiple meshes pieced together this way, so they aren’t true triangle strips I think. Basically, I wouldn’t worry about it too much and just build a big list of triangles in whatever way is easy. 
2 Likes
Correct, but there’s nothing bad about that. My understanding is that triangle strips were a way to reduce CPU->GPU bandwidth usage by around 50% by re-using common vertices between adjacent triangles in the strip, back when the CPU submitted vertex draw data for every frame. These days the whole mesh is sent prior to drawing, so it’s not an issue any more.
2 Likes
Good to know. Thanks, that makes sense.