Cube maps
Posted: 28.08.2006, 07:21
Tonight I had some interesting ideas about ways to use cube maps in Celestia. A cube map is a set of six square textures, each the face of a cube. All modern graphics hardware supports them. A normal texture is indexed by two coordinates (u,v); but with a cube map, the lookup uses a 3-vector (x, y, z) The cube map is sampled at the point where the vector intersects the cube. Despite the extra complexities, it's just as fast as regular texture mapping.
So what is it good for? It's most often used for a technique called reflection mapping. More generally, a cube map is used as a lookup table for functions of direction. Here's an article with some samples:
http://developer.nvidia.com/object/cube ... orial.html
They're incredibly useful when dealing with spheres . . . In Celestia, a cube map could be used to store a planet texture. The equivalent of a 16k x 8k texture could be stored in a cube map with 6 4k x 4k faces. That's 25% less memory, because there's less memory used for the polar regions of a planet which are oversampled relative to the equatorial areas when using rectangular maps (simple cylindrical projections.)
There's also no singularity around the poles with cube maps. However, when producing a cube map, the source is probably going to be a simple cylindrical projection. You could do some high quality filtering when generating the cube map to limit the artifacts near the pole. Or better yet, you could start with images that weren't cylindrical projects and go directly to a cube map.
Another use of cube maps would be to overcome the size limitations of cloud maps. GeForce cards have a maximum texture size of 4k x 4k; a cube map with 4 4k x 4k faces gives you a cube map that is effectively 16k x 8k. And rotation and cloud shadows would work with such a texture. In fact, cloud shadows would work much better with cube maps because you could skip the very expensive spherical to cartesian coordinate conversion that's required when you have a regular cloud map.
A big down side is that there isn't any way to split cube maps or do virtual texturing with them. But, there are enough benefits that I'll probably add support for them to Celestia some time in the future--sooner rather than later if I can convince a skilled texture creator to produce a cube map texture without an intermediate simple cylindrical projection.
--Chris
So what is it good for? It's most often used for a technique called reflection mapping. More generally, a cube map is used as a lookup table for functions of direction. Here's an article with some samples:
http://developer.nvidia.com/object/cube ... orial.html
They're incredibly useful when dealing with spheres . . . In Celestia, a cube map could be used to store a planet texture. The equivalent of a 16k x 8k texture could be stored in a cube map with 6 4k x 4k faces. That's 25% less memory, because there's less memory used for the polar regions of a planet which are oversampled relative to the equatorial areas when using rectangular maps (simple cylindrical projections.)
There's also no singularity around the poles with cube maps. However, when producing a cube map, the source is probably going to be a simple cylindrical projection. You could do some high quality filtering when generating the cube map to limit the artifacts near the pole. Or better yet, you could start with images that weren't cylindrical projects and go directly to a cube map.
Another use of cube maps would be to overcome the size limitations of cloud maps. GeForce cards have a maximum texture size of 4k x 4k; a cube map with 4 4k x 4k faces gives you a cube map that is effectively 16k x 8k. And rotation and cloud shadows would work with such a texture. In fact, cloud shadows would work much better with cube maps because you could skip the very expensive spherical to cartesian coordinate conversion that's required when you have a regular cloud map.
A big down side is that there isn't any way to split cube maps or do virtual texturing with them. But, there are enough benefits that I'll probably add support for them to Celestia some time in the future--sooner rather than later if I can convince a skilled texture creator to produce a cube map texture without an intermediate simple cylindrical projection.
--Chris