There are several different subtypes of textures, differing by the element type stored, the dimensionality of the texture, and the format of the data. In the following descriptions, T can be any tuple type, and indicates the type stored in a texel and returned upon lookup.
In the future, we hope to support more general element types, such as composite C++ types containing a number of Sh tuple types. For now, however, textures can only store a single tuple channel, although you can always define your own classes to simplify the interface to multi-channel “textures”.
To specify a texture using byte-oriented types (for instance), you must use tuple types with that storage class: ShAttrib3ub , in the case of unsigned byte textures. In addition to taking less space, such textures may also require fewer shader resources to support interpolation and filtering. If a floating-point storage type is used, then a floating-point texture will be allocated, but this is often overkill.
In discussing the various data formats below, we will use the ShTexture name, although this really relates specifically to linearly interpolated and filtered textures. The same data formats are also available for ShArray s and ShTable s.
Cube maps are indexed by a 3D vector whose length is ignored. Instead the ray from the origin of the cube in the direction of the given vector is intersected with a cube and one of the six faces is referenced.
Cube maps are useful for environment maps and other functions defined over a sphere. The Sh cube-mapped texture class automatically sets up the correct border conditions and MIP-map levels for cube maps (whenever possible).
Note that on most hardware, rectangular textures are internally indexed by [0,w] � [0,h] coordinates, whereas other textures are indexed using [0,1]n coordinates. If you use the “[]” operator on non-rectangular textures, or the “()” operator on rectangular textures, be aware that Sh may have to insert additional scaling code, making the shader slightly slower. Whenever possible, to maximize performance you should use the native access mode for texture lookups.
Note: This manual is available as a bound book from AK Peters, including better formatting, in-depth examples, and about 200 pages not available on-line.