I learned the math for computing the vertices of an icosahedron but I couldn't think of a way to easily generate the mesh, so I wrapped tape around a d20 I had from back when I played mtg, labeled all the vertices, and used that as reference to build the 20 triangles in the mesh.
been difficult to focus on anything but in an attempt to get my brain to zone out on something that isn't real life I was able to figure out how to fix the UVs around the poles of the sphere. much better now. adds 12 new vertices to the final mesh.
turns out lots of people go down this road and run into the same problem. the solution seems to be to detect the problem by examining the uvs of entire triangles and generating new, fixed vertices. I'll see if I can do that without making my code disgusting.
I found a solution that wasn't too gross, but not too great either. added about 27 lines of new code. maybe I can improve upon it, but not now. onto the next and hopefully final problem: bad texture coordinates at the poles.
I believe the issue here is that the vertices along this seam need to be duplicated but with different u coordinates, one where u=0 and another where u=1. same position and normals, though. it's tricky to solve because my algorithm has no knowledge of where this seam even is.
the sphere now has texture coordinates, but there is a very obvious issue. I used the formula here https://en.wikipedia.org/wiki/UV_mapping#Finding_UV_on_a_sphere but it creates a seam where u coordinate does a hard jump from 0 to 1 and creates that gross looking result. I don't know if I'm just missing something. trying to tweak the formula has just introduced new distortions so far.
now it's spherical. the trick is that once you subdivide the triangles of the icosahedron, you take the normal of each vertex and scale it by the sphere's radius to get the final position. this sphere is made of 1280 triangles and looks pretty good at this scale.
you can say this is a really low resolution sphere. for my next trick, I will subdivide each of the 20 triangles several times and transform each vertex so that it is the same distance from the origin. this will create a nice approximation of a sphere.