Sphere generation

Started by
18 comments, last by wasd 20 years, 4 months ago
With an icosahedron, the distortion at the points is pretty minimal, assuming you''re mapping an equilateral triangle texture to each of the 20 sides of the icosahedron... After tesselation the angle between the triangle sides at a point is ~72 degrees. That''s reasonably close to the 60 degree angles of an equilateral triangle (an octahedron will have ~90 degree angles at the points) and doesn''t have any of the pinching artifacts you get if you use a rectangular texture and spherical mapping.

Now that I''m thinking about it, you could probably get an almost completely undistorted mapping if you "inflate" the triangle of UV coordinates a little so that the corners are 72 degrees. I like having the vertices evenly spaced though. Another technique that''ll work on any mesh is to use a cube map, which might be the easiest on hardware that supports it (you don''t even have to make UV coordinates, just use the vertices themselves).

ApochPiQ: I use recursive subdivision because it also functions as a handy tree structure for collision detection and other uses. I tried a more equal-length method of subdivision but the improvement wasn''t dramatic enough to justify a less efficient tree.
Advertisement
well, seeing is believing.

Take 3 spheres, your regular sphere, iso, and octa, and texture map them using the same
mapping equation, and compare them.

I say the regular sphere looks the best, since it can have many polys at the poles.

It looks like it doesn''t matter how many subdivisions you apply, an iso always has
6 polys at the poles, octa will always have 8 polys at the poles. I''m saying the texture
mapping looks horrible for these two, because you have to stretch just 6 or 8 faces
around 360 degrees.

Take you regular sphere, since it has so many polys at the pole, I think this will
help spread out this distortion.
oops, I mean 4 polys at the poles for octahedron, not 8.
I don't think you understand what we're talking about. You do *NOT* use spherical mapping with an octahedron or icosahedron, you texture each of the original facets. The texturing at the poles has roughly the same texel density as on the equator, with approx. 25% lateral stretching for an icosahedron. If the textures match properly the point isn't visible without looking at the wireframe. (edit: and even then it isn't blatantly obvious)

Here's an example of icosahedral mapping (click on the thumbnail to see a larger image). Imagine this globe "inflated" to a round shape; each of the 12 points will have the same slight distortion but not nearly as dramatic as the "infinite" pinching you get with spherical mapping at the poles.

[edited by - Fingers_ on December 1, 2003 4:01:14 PM]
yeah, that''s what I''m doing, spherical mapping on all 3 types of spheres.

What Kyle N posted.
quote:
Hmmm, I think you''re both wrong. A regular sphere works best,
as it has the most polys at the poles.

An octa and iso sphere look like crap at the poles. There''s only at most 4 or 8 faces, so the texture is stretched horribly among them.

hmm i think you dont know what youre talking about.

spheres created with polar coordinates need much more polys to look smooth at the equator. besides the lightning looks messed up.

in general it just sucks ass.

if you subdivide a 20-faced primitive, youll have none of that shit, and if as previously suggested texture each face seperatly there is no issue with the textures. and since youll be using procedural textures for this sort of thing most of the time anyway, this is no problem.
well, I don''t know exactly what the original poster f8k8 wanted. I got the impression
he like everyone else is putting his spheres in a game, so no, he''s not doing procedural,
he''s using texture maps.

And everyone uses spherical mapping because well, it''s easy and that''s what''s
everyone uses.

Post some code for your iso mapping sh*t.
Er.. I don''t see why anybody would use spherical mapping in a game, because of the problems we''ve talked about. Generally if you can see the poles of a planet you don''t want to use spherical mapping.

My screenshot in the 4th post uses icosahedral mapping and has at least three "poles" visible to the camera. You can only notice them because the detail texture alignment causes a bit of a seam between each facet. The easiest one to see is in the lower right corner near the terminator because it''s on the ocean.. on land the seams are all but invisible even with the detail texture.

As for code, it''s trivial. Each facet is mapped to an equilateral triangle in the UV''s (or approximated as <0.5,0> <1,1> <0,1> for a square texture). That''s all there is to it. The only non-trivial part is generating triangular textures that tile seamlessly, which takes either a good artist, a lot of time or specialized tools (or a scanner and one of those paper globes ).
that''s doesn''t sound very good for gaming. If you''re texture mapping a sphere for a game, you
don''t want a texture for each face, you want one texture for your entire sphere, and that''s what
spherical mapping will give you. And there''s only one seam to deal with, so that''s another plus.
That''s why I use it for its simplicity and easiness to use.

And that''s what they use for planetary globes, cartography, etc..., although the texture is spherical
distorted to compensate for texture distortion.

http://astronomy.swin.edu.au/~pbourke/projection/spherical/
http://astronomy.swin.edu.au/~pbourke/texture/polargrid/
http://astronomy.swin.edu.au/~pbourke/texture/spheremap/
http://astronomy.swin.edu.au/~pbourke/texture/texturemapping/
I guess it''s a matter of taste. Myself, I''m perfectly comfortable with having a simple and easy way to make an infinite number of nearly distortion-free globes for MY future games. Your links only convince me further

Here''s another shot, directly above the south pole of planet #52 (the pole is just inland from the lower shore of the big island/continent).

Of course, if you want to put all of those triangles in one texture it''s not particularly hard to do. It might look somewhat like that flattened paper globe (though there are more efficient ways to pack it). I use actual separate textures because that allows more texture detail with reasonable VRAM usage. Only the textures that are currently in view need to be in VRAM, so the other side of the planet doesn''t use any. Games like BF1942 do this with square blocks of terrain...

This topic is closed to new replies.

Advertisement