Microsoft DirectX 8.1 (C++)

CubeMap Sample

Description

The CubeMap sample demonstrates an environment mapping technique called cube mapping. Environment mapping is a technique in which the environment surrounding a 3-D object, such as the lights, is put into a texture map, so that the object can have complex lighting effects without expensive lighting calculations.

Not all cards support all features for environment mapping techniques, such as cube mapping and projected textures. For more information on environment mapping, cube mapping, and projected textures, refer to the Microsoft® DirectX® SDK documentation.

Path

Source: (SDK root)\Samples\Multimedia\Direct3D\EnvMapping\CubeMap

Executable: (SDK root)\Samples\Multimedia\Direct3D\Bin

User's Guide

The following table lists the keys that are implemented. You can use menu commands for the same controls.

Key Action
ENTER Starts and stops the scene.
SPACEBAR Advances the scene by a small increment.
F2 Prompts the user to select a new rendering device or display mode.
ALT+ENTER Toggles between full-screen and windowed modes.
ESC Exits the application.

Programming Notes

Cube mapping is a technique that employs a six-sided texture. To visualize the effects of this technique, imagine a wall-papered room in which the wallpaper has been shrink-wrapped around an object. Cube mapping is superior to sphere-mapping because the latter is inherently view-dependent; sphere maps are constructed for one particular viewpoint in mind. Cube maps also have no geometry distortions, so they can be generated on the fly using IDirect3DDevice8::SetRenderTarget for all six cube map faces.

Cube mapping works with Microsoft Direct3D® texture coordinate generation. By setting D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR, Direct3D generates cube map texture coordinates from the reflection vector for a vertex, thereby making this technique easy for environment mapping effects where the environment is reflected in the object.

This sample uses common DirectX code that consists programming elements such as helper functions. This code is shared with other samples in the DirectX SDK. You can find the common headers and source code in (SDK root)\Samples\Multimedia\Common.