Graphics Reference
In-Depth Information
Outside of the standard render and depth targets, 2D textures are commonly used for
applying surface properties to geometry being rendered. For example, if a brick wall is be-
ing rendered, the color of the bricks is typically supplied in a 2D texture that is read during
the rendering process. The surface properties supplied don't necessarily need to be limited
to the color of the surface, either. It is very common in modern rendering systems for sur-
face normal vectors to be modified with what is called a normal map. This is a texture that
supplies a 3D vector to represent a surface normal, where the X, Y, and Z coordinates are
stored in the R, G, and B channels of the texture. Still other properties are encoded into
textures, such as surface glossiness, displacement, and emissivity. It is fairly common to
hear these types of textures referred to as maps. For example, the textures mentioned above
would be referred to as gloss maps, displacement maps, or emissivity maps.
In addition to the per-object uses described above, it is also becoming increasingly im-
portant to perform post-processing of a scene rendering to increase the quality of the output
presented to the user. In these situations, the output rendering is used as an input to various
algorithms that process the image further or combine the image with other information to en-
hance it in some way. The algorithms in Chapter 10 demonstrate how this can be performed.
Creating 2D textures. The creation of a 2D texture is quite similar to the ID texture case.
Along with the addition of the extra dimension specification, an extra structure parameter
is added to determine the multisample level to be used in the texture. The texture is cre-
ated with the ID3DDevice: :CreateTexture2D() method, which takes a pointer to the
D3D11_TEXTURE2D_DESC structure, as shown in Listing 2.28.
struct D3D11_TEXTURE2D_DESC {
UINT Width;
UINT Height ;
UINT MipLevels;
UINT ArraySize;
DXGI_FORMAT Format;
DXGI_SAMPLE_DESC SampleDesc;
D3D11_USAGE
Usage;
UINT
BindFlags;
UINT
CPUAccessFlags;
UINT
MiscFlags;
}
struct DXGI_SAMPLE_DESC {
UINT Count;
UINT Quality;
}
Listing 2.28. The contents of the D3D11_TEXTURE2D_DESC structure.
As mentioned above, this structure is quite similar to that which is used for 1D texture
creation. The size of the texture is specified with the Width and Height parameters, and the
Search WWH ::




Custom Search