Graphics Reference
In-Depth Information
Figure 2.27. Implementing a color scale with a ID texture.
populated with color values, where each color represents a scalar data value range. For
example, when the value is in a normal range, it can be colored blue and progress to "hot-
ter" colors as the input value approaches a more critical range. To implement such a color
scale within a shader program, the particular scalar property value that is being visualized
is mapped to the [0,1] range and is then used to sample the appropriate color in the 1D
texture. This process is depicted in Figure 2.27.
A ID texture resource can also be used in a computational context within the compute
shader. With the general purpose computation capabilities of the compute shader, any 1D data
array can be stored in a texture. If the data can be stored as a texture—that is, if it doesn't
require a structure to represent its basic element it can take advantage of the sampling abili-
ties of the GPU, as described above, with little or no additional computational cost.
Creating 1D textures. The process of creating a 1D texture follows the same process as all
of the resources in Direct3D 11. The ID3DllDevice: :CreateTexturelD() method takes
a D3D11_TEXTURE1D_DESC description structure pointer, which specifies all of the desired
texture properties of the resource. The structure and its members are provided in Listing 2.19.
Struct D3D11_TEXTURE1D_DESC {
UINT Width;
UINT MipLevels;
UINT ArraySize;
DXGI_FORMAT Format;
D3D11_USAGE Usage;
UINT
BindFlags;
UINT
CPUAccessFlags;
UINT
MiscFlags;
}
Listing 2.19. The D3D11_TEXTURE1D_DESC structure and its members.
Search WWH ::




Custom Search