Bagikan melalui


What Is a Depth Texture?

A depth texture, also known as a shadow map, is a texture that contains the data from the depth buffer for a particular scene.

Each pixel value contains the depth of the geometry in that pixel. Use a depth texture to render accurate shadows using a technique called shadow mapping. There are two common ways to encode the depth information into a texture. The first is to use a standard RGBA surface format for your texture, and copy all four color (32-bits of data) into the buffer (a depth format is usually assigned to 24 or 32 bits). The second is to use a floating-point texture format and a floating-point depth buffer (depth buffers are normally fixed-point). When using the floating-point approach, it is more accurate to subtract the depth from 1.0 before storing it because of the way floating-point numbers are encoded.

Although depth textures are useful for efficient shadow mapping, they are not universally supported by hardware. These techniques require a custom vertex and pixel shader that is not available on Windows Phone. For an example, see Creating a Depth Texture.

See Also

Concepts

What Is a Depth Buffer?