I'm trying to make a quad sphere based on an article, which shows results like this:
I can generate a cube correctly:
But when I convert all the points according to this formula (from the page linked above):
x = x * sqrtf(1.0 - (y*y/2.0) - (z*z/2.0) + (y*y*z*z/3.0));
y = y * sqrtf(1.0 - (z*z/2.0) - (x*x/2.0) + (z*z*x*x/3.0));
z = z * sqrtf(1.0 - (x*x/2.0) - (y*y/2.0) + (x*x*y*y/3.0));
My sphere looks like this:
As you can see, the edges of the cube still poke out too far. The cube ranges from -1
to +1
on all axes, like the article says.
Any ideas what is wrong?