DirectDraw Surface

From Tech Artists Wiki

Jump to: navigation, search

A DirectDraw Surface file (extension .dds') is a Microsoft file format for storing compressed and uncompressed textures. Compressed textures are run natively on the GPU, and not expanded in memory, making them the only format that can run compressed on hardware.

There are a number of image types available for the DDS format.

Contents

General Info

Some general info to better understand this article.

Bits Per Pixel (BPP)

Bits per pixel (BPP) are how many bits of information in a single image pixel. BPP is the total combination of all the bits stored in all the image channels. When an image uses standard 24bit RGB color, each pixel stores 24 BPP, 8 bits for each channel. When an image uses 24bit RGB color, and it also has an Alpha channel, then that's four channels of color information, so it is 32 BPP, 4 channels at 8 bits each.

Bits Per Channel (BPC)

Bits per channel (BPC) describes the BPP for each color channel. The color channels for a RGB image are Red, Green, Blue. Alpha is another possible channel. There are a number of color storage formats with different numbers and types of color channels, like CMYK which is used for print.

A typical RGB image has 8 BPC, storing 256 levels of color information per channel. Higher bit depths are usually used for high dynamic range (HDR) or for displacement mapping, where an image may need more precision than the 256 levels of gray offered by 8 BPC. A displacement map using 16 BPC can store 65536 levels of gray in its single channel. In Photoshop you can change the BPC via the Image menu, with options for 8 BPC, 16 BPC, and 32 BPC.

Targa/Uncompressed

Targa images without alpha are usually 8 bits per channel, so 24 bits per pixel.

Normal map compression

See: Normal map compression

Signed/Unsigned

Data - whether a pixel, float, or integer - can only have a certain range of accuracy. This range is x. A signed data value has a sign assigned to it- that is, positive or negative. This means the max range of an integer is -x/2 to x/2. By making the data unsigned, the range of an integer is 0 to x, since the sign is assumed to be positive.

See Data types for more info

A single channel of a pixel normally represents a value from 0 to 255. DDS textures can also be signed- that is, from -127 to 127. This is useful for normal maps, since they need to store a vector. Instead of storing the vector compressed between 0 and 1 (0 and 255) and uncompressing it in the shader, it can just be stored with negative values in the DDS. Signed textures are only useful, therefore, for data textures such as normal maps, and not textures that are used to depict color space.

When you reload a signed image back into Photoshop, it will appear lighter: the entire image will be in the range of 127 to 255.

DXT

DXT textures stay compressed in video memory, unlike other texture types which are uncompressed, or only compressed on disk (.jpg, for example, is uncompressed to the full size of a TGA file in video memory), and uncompress during rasterization. This makes them a popular choice for color textures. The more variation in the texture, the better the compression result, as a general rule- low contrast maps tend to exhibit banding.

DXT compression analyzes the image in 4x4 blocks (16 pixels each), then only stores two colors per block and interpolates all the other 14 pixel colors using just 2 intermediate colors.

DXT is called Block Compression in DirectX 10.

DXT1

RGB, 4 bpp, no alpha or 1 bit alpha

DXT1 is a fixed 8:1 compression ratio.

It has a 1-bit alpha (black or white), or no alpha.

DXT1 is now called BC1 in DirectX 10.

DXT3

ARGB, 8 bpp, explicit alpha

DXT3 is a fixed 4:1 compression ratio.

It has 8-bit alpha, but the way it is compressed does not give good interpolation results, which makes banding apparent. It is rarely used, use DXT5 instead.

DXT5

ARGB, 8 bpp, interpolated alpha

DXT5 is same 4:1 compression ratio as DXT3.

It's 8-bit alpha is interpolated, which yields much smoother results.

DXT5nm

XY, 8 bpp

DXT5 nm is specifically for normal mapping: see the full article, DXT5 normal map compression.

3Dc

XY, 8 bpp

3Dc is specifically for normal mapping: see the full article, 3Dc normal map compression.

Palette

Paletted DDS textures work just like GIF files. They essentially create a greyscale image, where each value corresponds to an entry in the palette. The palette can also be swapped, so the main image can be colored differently.

16 colors

RGB, 4 bpp

4 bpp is capable of achieving 16 values, which maps to 16 colors.

256 colors

RGB, 8 bpp

16 colors + alpha

ARGB, 4 bpp

256 colors + alpha

ARGB, 8 bpp


Bit Reduction

Bit-reduced textures will reduce the color information in a texture by reducing the bpp's. For example, an uncompressed RGB colorspace yields 16.7 million colors (24 bpp- 2^24). With a 5.5.5, for example, the maximum colorspace is reduced to 65k colors (16 bpp- 2^16). The color-space is reduced, but there are no compression artifacts. The effect is similar to paletting. The differences between listed schemes are mostly in how they treat alpha.

5.5.5

RGB, 16 bpp, unsigned

5.6.5

RGB, 16 bpp, unsigned

1.5.5.5

ARGB, 16 bpp, unsigned

4.4.4.4

RGB, 16 bpp, unsigned

Uncompressed

These textures use generally uncompressed channels, but may have limited channels. Other channels are ignored or discarded. Most schemes here have both a signed and unsigned version.

8A/8L

These types use a single 8-bit channel, stored either as the Alpha or the Luminance (a greyscale RGB, basically).

8.8

16 bpp

All 8.8 schemes use two uncompressed channels.

AL

alpha/luminance, unsigned

VU

signed

CxVU

signed

8.8.8

RGB, 24 bpp, unsigned

8.8.8 schemes are the DDS RGB uncompressed texture format.

8.8.8.8 (ARGB/QWVU)

32 bpp

The 8.8.8.8 schemes are the DDS 4-channel uncompressed texture format. ARGB is unsigned, QWVU is signed.

X.8.8.8

XRGB, 32 bpp, unsigned

16.16 (GB, VU)

32 bpp

The 16.16 format provides extra texture precision, but eliminates a channel. GB uses only the Green and Blue channels and is unsigned, while VU is signed.

Floating Point

Floating point images store actual floating point data. This makes them useful for a few purposes. First, they can be used with High Dynamic Range lighting, since they can store info of arbitrary values. The second is more generic- FP textures can store any sort of value, since they are essentially just pixels containing arbitrary floating point numbers. This makes them more convenient than storing and accessing arrays, etc.

A 32-bit FP texture is much more accurate than a 16-bit, but is also larger. The main problem with FP textures is, in fact, their size, which is significantly larger than an uncompressed image.

16f

16.16f

16.16.16.16f

32f

32.32.32.32f

It is important to note than this format is the only format supported by Vertex Texture Fetch.

See Also

Personal tools