uniform sphere tesselation

I need to uniformly tesselate (i.e. sample) the sphere. Currently I do it by subdividing octahedron, but that gives me non-power-of-two number of samples, which is very slow if used as a texture. I could simply skip two samples, but that is visually noticeable and causes other problems (like ruining the triangulation). Is there a better (but still simple) way?

Huh? What’s the connection between sphere tesselation and non-power-of-two textures?

I use an icosahedron as base platonic for a sphere tesselation which subdivides perfectly regular.

Originally posted by Relic:
[b] Huh? What’s the connection between sphere tesselation and non-power-of-two textures?

I use an icosahedron as base platonic for a sphere tesselation which subdivides perfectly regular. [/b]
The tesselation is regular all right, but I store the generated samples in an array and use them later as a texture, accessible from within the shader. Since the number of vertices when subdividing the octahedron grows like 6, 18, 66, 258 etc., this gives me a non-power-of-two texture.

What keeps you from storing that in a power-of-two texture?
You can index every individual texel in a 1D (or 2D texture) if you know your vertex index “n” and the texture’s size: ((float) nth_texel + 0.5) / texture_size is the center of such a texel in a 1D texture.

Originally posted by Relic:
What keeps you from storing that in a power-of-two texture?
You can index every individual texel in a 1D (or 2D texture) if you know your vertex index “n” and the texture’s size: ((float) nth_texel + 0.5) / texture_size is the center of such a texel in a 1D texture.

You mean I would use 512 texture to store 258 texture elements? Well I guess I could live with that in 1D despite being somewhat wasteful.
Unfortunately I use the 258 samples to produce a 3D texture of equal size (i.e. 258258258). To use 512512512 for that purpose is not an option (or even using 128128128 instead of 666666). Thanks anyway.

Ok, I see, that leaves me puzzling about why you would store data like that in a 3D texture. :wink:
Sounds like you’d need to get a graphics board which supports NPOT 3D textures then (GF6 and up should) or explain the reasoning. Maybe there’s another solution.

Originally posted by Relic:
Ok, I see, that leaves me puzzling about why you would store data like that in a 3D texture. :wink:

I use the uniformly distributed samples to pre-calculate some 3D function f(p1,p2,p3), where any of the pi’s can be a sample on the sphere. That’s what I store in the 3D texture (and process it further in a shader) before visualizing it in the end. The processing of 3D texture involves calculating barycentric coords etc., so skipping some samples (even only two) to produce a POT texture really messes things up.

Originally posted by Relic:
Sounds like you’d need to get a graphics board which supports NPOT 3D textures then (GF6 and up should) or explain the reasoning. Maybe there’s another solution.

I must admit that the last 4 or 5 of my graphics cards were all ATI’s (I switched somewhere back in the era of unreliable Detonator drivers). But lately it seems to me that Nvidia offers more current GPU capabilities, so I’ll surely give it a try. My Radeon x800 is getting a bit old, anyway.
But it DOES support 1D and 2D NPOT textures quite well, while with 3D textures things slow down to a crawl (as someone suggested, it probably falls back to SW).