Graphics The Last Boundary

Turning a Cube into a Sphere

So, I read a couple of interesting articles about how to do cube mapping. The most straight-forward way I found was about using a cube to generate a sphere. This makes sense because you don’t need to do any insane math to work out the S,R and T coordinates of your cube texture.

Vertex points of a cube
Vertex points of a cube

Well, that’s what I’ve gone ahead and done. However, these vertices aren’t in any particular order; so tomorrow night I’ll need to work out a way to index them so that triangles are drawn. This was pretty easy, I haven’t looked at the code below to optimize it in any way; it just seemed like the logical way to produce the vertices.


Then from the help of this I was able to turn them vertices into a sphere very easily.

Now it's a Sphere
Now it’s a Sphere


Leave a Reply

Your email address will not be published. Required fields are marked *