Need help. #iOS #metal
I collect a series of points into array-like objects called Strokes. I copy the points to the GPU and generate (2 * n) + 2 vertices. I call drawPrimitives with the triangleStrip type.
It connects my strips with these degenerate tris. Lost. Help, thx?
Good catch, @0x21376B00: I was reducing the vertexCount on the drawPrimitives call as a crude debugging test, to see if the artifacts were introduced by erroneous point/vertex generation, and that's in the snippet pasted here.
Sadly (thankfully?), that's not it.
Vertex generation shader:
OH.
OHHHHHH.
Line 73 in the shader assumes that each primitive is drawn starting at vertex ID 0, but that is only true for the *first* stroke. Each subsequent stroke starts at `vertexCount` (before updating that value). 🤦🏾♂️
So this was good to clean up, but the "fix" was to draw 2*n vertices instead of 2*n + 2. I don't understand why; have I misunderstood triangle strips for all these years, or is #metal just buggy and nobody really uses tri strips so nobody cares?
Either way, the prototype is advancing. Some really good perf numbers so far. Need to add more complexity to the fragment shading, and then migrate vertex generation to a compute kernel.
An inscrutable picture for anyone who slogged through this 😂
Share this Scrolly Tale with your friends.
A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.
