×
Menu

DDS_Using Source Cube Maps (EN)

В МВ это не работает, добавлено для "общего развития" и на случай, если завезут в ОпМВ!

Выдержка из оригинальной справки. (NDL Gamebryo 1.1)
 
Cube Mapping
The DX8 renderer supports both rendered and source cube mapping on all platforms that support them. As a result, the DIFFUSE_CUBE_MAP and SPECULAR_CUBE_MAP texture coordinate generation modes are supported. Cube Maps may be used in any type of dynamic multitexture effect. Note that not all hardware can support Cube Maps. If the hardware cannot support Cube Maps, then Ni*CubeMap::Create will return NULL.
 
Although less common in practice, NiSourceCubeMap objects are very useful for creating static lighting effects using cube maps. Source cube map objects are very much like NiSourceTexture objects, but have six files or NiPixelData objects associated with them, one for each face. They also have the notion of a "current" face, which is the face for which data can be retrieved or changed on-the-fly at a given time. See the reference documentation for NiSourceCubeMap for details of which functions are affected by the current face switch.
Creation of an NiSourceCubeMap requires six image filenames or six NiPixelData objects. These may not be mixed — a source cube map must be created from six objects of the same type. The other requirements are as follows:
· All six input images (pixel data or filenames) must be square
· All six input images must be the same size
· All six input images must be the same incoming format
· The size of each image must be a power of two
The NiSourceCubeMap object requires a renderer with which it will be associated. If the given renderer cannot support cube mapping, the creation function will return NULL.
In terms of artwork for source cube maps, the artist must generate six image files that represent the cube map, one file for each face. Creation of these cube maps can be tricky, as the matching edges of the six images must match pixel-for-pixel, or else seams will be apparent in the cube map. Perhaps the best way for an artist to visualize the cube is as the unfolded cross-shape in the figure above. In fact, the artist can create the cube map as a single image in an image creation program, and simply cut the image into the six faces before exporting. An example of such a cube map is shown below.
 
Using Source Cube Maps
Although less common in practice, NiSourceCubeMap objects are very useful for creating static lighting effects using cube maps. Source cube map objects are very much like NiSourceTexture objects, but have six files or NiPixelData objects associated with them, one for each face. They also have the notion of a "current" face, which is the face for which data can be retrieved or changed on-the-fly at a given time. See the reference documentation for NiSourceCubeMap for details of which functions are affected by the current face switch.
Creation of an NiSourceCubeMap requires six image filenames or six NiPixelData objects. These may not be mixed — a source cube map must be created from six objects of the same type. The other requirements are as follows:
· All six input images (pixel data or filenames) must be square
· All six input images must be the same size
· All six input images must be the same incoming format
· The size of each image must be a power of two
The NiSourceCubeMap object requires a renderer with which it will be associated. If the given renderer cannot support cube mapping, the creation function will return NULL.
In terms of artwork for source cube maps, the artist must generate six image files that represent the cube map, one file for each face. Creation of these cube maps can be tricky, as the matching edges of the six images must match pixel-for-pixel, or else seams will be apparent in the cube map. Perhaps the best way for an artist to visualize the cube is as the unfolded cross-shape in the figure above. In fact, the artist can create the cube map as a single image in an image creation program, and simply cut the image into the six faces before exporting. An example of such a cube map is shown below.
 
Using Cube Maps as Dynamic Multitextures
A cube map may be used as the texture image for any dynamic multitexture (NiTextureEffect). However, if a cube map is used for a dynamic multitexture, that NiTextureEffect must use one of the two cube-mapping texture coordinate generation modes (DIFFUSE_CUBE_MAP or SPECULAR_CUBE_MAP), as a cube map always expects 3D texture coordinates.
 
The most common uses of cube maps are as follows:
1. Specular environment maps (similar to the sphere maps above):
a. Use a dark base texture on the object receiving the map (as the cube map will be added to the base)
b. Set the cube map as the texture for an environment map (generally uses a rendered cube map for live effects)
c. Use the SPECULAR_CUBE_MAP coordinate generation mode
 
2. Diffuse omni-directional light maps
a. Use a bright (fully-lit) base texture (as the cube map will darken the base map)
b. Set the cube map as the texture for an environment map (generally uses a source cube map with the lighting painted into it)
c. Use the DIFFUSE_CUBE_MAP coordinate generation mode
 
Cube maps are form of texture map that maps 3D unit vectors into colors. They avoid many of the problems that occur with sphere maps — discontinuities, inability to render to them, etc. However, they are only supported on some platforms and hardware and are by no means universal.
 
The basic concept of a cube map is a unit cube with six sides, centered at the origin. Each face of the cube can be thought of as a 2x2 unit square, lying in each of the following planes: X=1, X=–1, Y=1, Y=–1, Z=1, Z=–1. Each cube face is a square texture that represents a 90-degree field-of-view image shot from the origin, facing out in the given direction. Put together, these six images form a one-to-one mapping of directions to texels. The figure below shows how the cube faces may be visualized:
 
Because each of the faces is square, flat and represents a 90-degree field of view, it is very easy to render to these textures in such a way that the cube map can represent an entire scene as viewed from a given point at a given time. Because they can be rendered on the fly, Cube Maps can create incredibly realistic reflections, including live rendered reflections of dynamic objects in the scene.
Although Cube Maps are commonly used as environment maps, this is not a fixed limitation. Any dynamic texture may be a cube map, including projected lights. By creating a cube map that represents all of the static lighting in a scene, applications can apply a cube map as a projected light and generate complex lighting situations with lights coming from all directions with a single map.
To use Cube Mapping, applications must make two changes to an existing projected effect: The effect texture must be an NiRenderedCubeMap or NiSourceCubeMap, and the texture coordinate generation mode must be either DIFFUSE_CUBE_MAP or SPECULAR_CUBE_MAP. The sections below describe how to create and use Cube Maps.