Closed mattrdowney closed 6 years ago
This is extremely useful for #30 (almost required), and lays the groundwork for #41
Conveniently, in UV-space, each level-of-detail of an octahedron sphere has vertices along a grid, so the only difficulty is dealing with switching between octahedral faces during a left-to-right, top-to-bottom generation.
Rescale needn't be factor of two:
The grid that generates a octahedron level-of-detail is:
Triangles: 2*n^2 Vertices: (n+1)^2
where construction is easier when n is even (i.e. n = 2,4,6...).
The level-of-detail = 0 case is 2 2 2 (eight faces of an octahedron) and (2+1)^2 or nine corners (forward,back, left, right, up, down*4)
The largest such grid for 2-byte indexing is: 2 180 180 < 65536
which is pretty amusing (181 works too, but construction is harder).
level of detail actually goes to 255 (not 180), because the mesh is limited by vertices, not triangles.
Thus, the level of detail should probably be constrained from [1,127] (which maps to [3,255]).
Solved as of a1b60688c886a3aacd0a240c7ad9d481c08310c3
Using a subdivided octahedron sphere.
I could swear I read this post before Invertigo was a VR game: https://www.binpress.com/tutorial/creating-an-octahedron-sphere/162
Regardless, the methodology won't be directly mirrored for a few reasons:
1) UVs work differently. 2) Tangents and even normal vectors are unnecessary (they wouldn't be used for lighting anyway). 3) Recursion and the Mesh.Optimize is possible (not ultra likely). 4) Spawning the points clockwise from north pole to south pole and filling in the UVs might be the best option (since I specifically made a point to OctahedralUVCoordinates conversion; the only trouble is the boundary condition).