Editing Arcane University:DDS Data Format

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
 
Almost all textures used by Skyrim are DDS (Direct Draw Surface) files. This article contains information and advice on the different types of DDS files, and how to use them.
 
Almost all textures used by Skyrim are DDS (Direct Draw Surface) files. This article contains information and advice on the different types of DDS files, and how to use them.
  
== Texture Types and the DXT/BC format ==
+
== Texture Types and the DXT format ==
  
 
===What is the DDS file format?===
 
===What is the DDS file format?===
*Block Compression (BC), formerly known as DXT, is a set of compression algorithms or codecs applied to raster/bitmap images. The set is also known as S3 Texture Compression (S3TC). They all convert 4×4 blocks of pixels to either 64-bits or 128-bits depending on the codec. All are lossy algorithms. The original codecs were created by S3 Graphics, but many non-encumbered alternatives exist now. There are many different codecs: BC1, BC2, BC3, etc. I’ll talk more about them in a moment. DDS (Direct Draw Surface) is an image file format, rather like a container for storing image data compressed using one of the DXT codecs. It was developed by Microsoft and introduced with DirectX 7. Together, a DDS file containing data organized using Block Compression creates an image file that can be used in most graphical applications, at least those that support DDS natively or via a plug-in. DDS files are very common in the game industry, where advantages in loading speed and video memory savings outweigh disadvantages.  
+
*DXT is a set of compression algorithms or codecs applied to raster/bitmap images. The set is also known as S3 Texture Compression (S3TC). They all convert 4×4 blocks of pixels to either 64-bits or 128-bits depending on the codec. All are lossy algorithms. The original codecs were created by S3 Graphics, but many non-encumbered alternatives exist now. There are many different codecs: DXT1, DXT3, DXT5, etc. I’ll talk more about them in a moment. DDS (Direct Draw Surface) is an image file format, rather like a container for storing image data compressed using one of the DXT codecs. It was developed by Microsoft and introduced with DirectX 7. Together, a DDS file containing data organized using a DXT code creates an image file that can be used in most graphical applications, at least those that support DDS natively or via a plug-in. DDS files are very common in the game industry, where advantages in loading speed and video memory savings outweigh disadvantages.  
  
 
===How does it work?===
 
===How does it work?===
*Block Compression sees images as collections of 4×4 blocks of pixels called "texels". For every texel, the codec selects two colors from the texel, each determining one end of a color range of 4 colors. The middle two colors are interpolated. The sixteen pixels of the texel are then assigned a 2-bit index (0-3) that maps them to the color range. The two representative colors are stored as 16-bit RGB values (5:6:5). So each texel requires 2×16 bits for the colors, plus 16×2 bits for the indices, giving a total of 64 bits for each texel, which equates to 4 bits per pixel. So for any set of images having the same dimensions, compressed size will always be the same.  
+
*DXT sees images as collections of 4×4 blocks of pixels called "texels". For every texel, DXT selects two colors from the texel, each determining one end of a color range of 4 colors. The middle two colors are interpolated. The sixteen pixels of the texel are then assigned a 2-bit index (0-3) that maps them to the color range. The two representative colors are stored as 16-bit RGB values (5:6:5). So each texel requires 2×16 bits for the colors, plus 16×2 bits for the indices, giving a total of 64 bits for each texel, which equates to 4 bits per pixel. So for any set of images having the same dimensions, compressed size will always be the same.  
  
 
===What if the image has an alpha channel?===
 
===What if the image has an alpha channel?===
* This depends on the codec used. In BC3, the alpha channel is encoded using a second set of 64 bits for each texel. BC3 stores alpha information in a way that is almost the same as color information. Two alpha values are selected and used as the extremes for a range of transparency values. The alpha values are represented by 8 bits each, and the range indices by 3 bits each, allowing for gradients of up to 8 shades. BC2 handles the alpha channel a little differently. Each pixel gets 4 bits to represent its alpha, for a total of 16 unique values of transparency. This allows the alpha channel to be represented more accurately than BC3, but with less subtle transitions. So, for an image with no alpha using DXT1, compression results in an image using 4 bpp (bits per pixel). For an image using BC2 or BC3 incorporating an alpha channel, the requirements will be 8 bpp. Note that the actual image size will likely be larger, as it will frequently include mipmap data.
+
* How DXT handles this depends on the codec used. In DXT5, the alpha channel is encoded using a second set of 64 bits for each texel. DXT5 stores alpha information in a way that is almost the same as color information. Two alpha values are selected and used as the extremes for a range of transparency values. The alpha values are represented by 8 bits each, and the range indices by 3 bits each, allowing for gradients of up to 8 shades. DXT3 handles the alpha channel a little differently. Each pixel gets 4 bits to represent its alpha, for a total of 16 unique values of transparency. This allows the alpha channel to be represented more accurately than DXT5, but with less subtle transitions. So, for an image with no alpha using DXT1, compression results in an image using 4 bpp (bits per pixel). For an image using DXT3 or DXT5 incorporating an alpha channel, the requirements will be 8 bpp. Note that the actual image size will likely be larger, as it will frequently include mipmap data.
  
===What are the advantages of DDS files and Block Compression?===
+
===What are the advantages of DDS files and DXT compression?===
*Fast load times. DDS files are ready to be used by the graphics system and can be read straight into graphics memory with little overhead. In situations where many files are being constantly swapped in/out of the graphics unit, this can be a substantial savings and can reduce "lag", especially with big texture files. Mipmaps can be pre-generated and included in the DDS files. This is another savings in load times and gives the graphic designer control over mipmap construction. More on mipmaps in a moment. Data remains compressed in video memory. All image formats except DDS are loaded into graphics memory in flat, uncompressed state. (And uncompressing them takes time and resources.) DDS files remain in their compressed state in video RAM, using special algorithms on the video card to retrieve data on demand. Compression ratio is 6:1 if no alpha channel is used, or 4:1 if an alpha channel is used. This can result in huge video memory savings.
+
*Fast load times. DDS files are ready to be used by the graphics system and can be read straight into graphics memory with little overhead. In situations where many files are being constantly swapped in/out of the graphics unit, this can be a substantial savings and can reduce "lag", especially with big texture files. Mipmaps can be pre-generated and included in the DDS files. This is another savings in load times and gives the graphic designer control over mipmap construction. More on mipmaps in a moment. Data remains compressed in video memory. All image formats except DDS/DXT are loaded into graphics memory in flat, uncompressed state. (And uncompressing them takes time and resources.) DDS/DXT files remain in their compressed state in video RAM, using special algorithms on the video card to retrieve data on demand. Compression ratio is 6:1 if no alpha channel is used, or 4:1 if an alpha channel is used. This can result in huge video memory savings.
  
 
===What are the disadvantages?===
 
===What are the disadvantages?===
*Block Compression codecs are lossy. What is stored as compressed data is not the same as the original image, and on a fine level it may not even be close. Images with high contrast regions such as print or cartoon-like colors and borders will likely generate visible artifacts, particularly with smaller resolutions. For this reason DDS can be problematic when used with normal maps, though there are work-arounds. I’ll come back to this issue. Never use DDS files for editing and archiving. The compression degrades the original colors. It is not a good format where retention of the true color is critical, particularly in those situations where fine differences may have a large impact. Block Compression generates images using a 16 bit color depth. Where formats like JPG or PNG use 8 bits per channel per pixel (RGB 8:8:8) for a 24-bit color depth (32 bits with PNGs having an alpha channel), Block Compression reduces the spectrum down to 5:6:5 bits using an interpolation algorithm to arrive at the new color values. In short, you lose much of the original color range. But many graphic applications in games and sims don't require tight control over the colors, and a good choice of the color palette can eliminate any visible results of this effect. File size on disk can be large for DDS. For example, a 1024×1024 image with an alpha channel and mipmaps will result in a 1.37MB file. But file size is a relatively small consideration these days. Game/simulation performance matters far more.
+
*DXT codecs are lossy. What is stored as compressed data is not the same as the original image, and on a fine level it may not even be close. Images with high contrast regions such as print or cartoon-like colors and borders will likely generate visible artifacts, particularly with smaller resolutions. For this reason DXT can be problematic when used with normal maps, though there are work-arounds. I’ll come back to this issue. Never use DDS files for editing and archiving. The compression degrades the original colors. It is not a good format where retention of the true color is critical, particularly in those situations where fine differences may have a large impact. DXT generates images using a 16 bit color depth. Where formats like JPG or PNG use 8 bits per channel per pixel (RGB 8:8:8) for a 24-bit color depth (32 bits with PNGs having an alpha channel), DXT reduces the spectrum down to 5:6:5 bits using an interpolation algorithm to arrive at the new color values. In short, you lose much of the original color range. But many graphic applications in games and sims don't require tight control over the colors, and a good choice of the color palette can eliminate any visible results of this DXT effect. File size on disk can be large for DDS. For example, a 1024×1024 image with an alpha channel and mipmaps will result in a 1.37MB file. But file size is a relatively small consideration these days. Game/simulation performance matters far more.
  
 
===Are there any image dimension limitations?===
 
===Are there any image dimension limitations?===
*DDS images can be of any dimension expressed in powers of two up to the limits of your application or hardware, but no dimension can be less than 4. So 1024×512 is fine, but 2048×2 is not. Since Block Compression works with texels and each texel is a 4×4 block of pixels, it follows that it can’t work with an image with a dimension smaller than 4.
+
*DDS/DXT images can be of any dimension expressed in powers of two up to the limits of your application or hardware, but no dimension can be less than 4. So 1024×512 is fine, but 2048×2 is not. Since DXT compression works with texels and each texel is a 4×4 block of pixels, it follows that DXT can’t work with an image with a dimension smaller than 4.
  
 
==Mipmaps==
 
==Mipmaps==
Line 26: Line 26:
 
A texture without mipmaps will not crash the game, but may cause significant drops in framerate, and will look "grainy" at a distance. All Skyrim textures should have mipmaps, except for facegen textures and UI art.
 
A texture without mipmaps will not crash the game, but may cause significant drops in framerate, and will look "grainy" at a distance. All Skyrim textures should have mipmaps, except for facegen textures and UI art.
  
==There are tons of compression codecs! Which should I use?==
+
==There are tons of DXT codecs! Which should I use?==
Block Compression (BC) comes in a lot of flavors. Fortunately most are specialty applications. For common situations you’ll probably need to consider only two: BC1 and BC3 (for Skyrim LE), or BC1 and BC7 (for SSE).
+
*DXT comes in a lot of flavors. Fortunately most are specialty applications. For common situations you’ll probably need to consider only two: DXT1 and DXT5 (if intended for Skyrim LE), or DXT1 and DXT10 (for SSE). Let's briefly overview each one to get an idea when they might be used.
===BC1===
+
** '''DXT1 (BC1)'''
Formerly known as DXT1, BC1 provides the smallest file size, at the cost of havinga 1-bit alpha channel. This can be useful for diffuse textures with no transparency, or that use alpha testing but no blending (this is sometimes called "cutout alpha").
+
*** RGB, 4 bits per pixel, no alpha or 1 bit (black or white) alpha
* RGB, 4 bits per pixel, no alpha or 1 bit (black or white) alpha
+
*** DXT1 is a fixed 8:1 compression ratio
* BC1 is a fixed 8:1 compression ratio
+
**:If your image does not require an alpha channel, use the no-alpha DXT1. It uses the same compression algorithm as DXT3/5 for color data, and will get you half the file size. It can also be used if the alpha channel is 1-bit: in other words, if parts of the texture either transparent or not, with no partially transparent pixels. This can be useful for diffuse textures that use alpha testing but no blending.
===BC3===
+
** '''DXT3 (BC2)'''
Formerly known as DXT5, BC3 was the go-to codec for most images that include an alpha channel in Skyrim LE (diffuse with transparency, and normal maps with specular). The cost is double the file size of a BC1 image. If compressing textures for Skyrim SE, use BC7 instead.
+
*** ARGB, 8 bits per pixel, explicit alpha
* ARGB, 8 bits per pixel, interpolated alpha
+
*** DXT3 is a fixed 4:1 compression ratio
* BC3 is a fixed 4:1 compression ratio
+
**:DXT3's method for storing alpha is better for files that have clearly delineated defined alpha regions and values. It may result in banding artefacts if used on images with smooth blended alpha regions– use DXT5 or DXT10 for these cases.
===BC4===
+
** '''DXT5 (BC3)'''
BC4 is a single-channel compression codec. It is ideal for textures like environment masks that contain only one color channel. Does not work in Skyrim LE.
+
*** ARGB, 8 bits per pixel, interpolated alpha
* grayscale, 8 bits per pixel, no alpha
+
*** DXT5 is same 4:1 compression ratio as DXT3
* BC4 is a fixed 2:1 compression ratio
+
**:DXT5 was the go-to codec for most images that include an alpha channel in Skyrim LE. The cost is double the file size of a DXT1 image. If you do not need an alpha channel, or only require 1 bit of alpha, use DXT1. If compressing textures for Skyrim SE, use DXT10/BC7 where you would otherwise use DXT5.
===BC7===
+
** '''DXT10 (BC7)'''
BC7 is a more recent compression algorithm that is supported by Skyrim SE, but not LE. BC7 is preferred over BC3 in nearly all cases, because it is the same size but at a higher quality. BC1 is still preferred for textures without alpha channels, or 1-bit ("cutout") alpha, since it is much smaller. When exporting as BC7, always use the slowest compression algorithm for the highest quality.
+
*** RGB or RGBA, 8 bits per pixel, interpolated alpha
* RGB or RGBA, 8 bits per pixel, interpolated alpha
+
*** BC7 is same 4:1 compression ratio as BC3 and BC5
* BC7 is same 4:1 compression ratio as BC3 and BC5
+
**:BC7 is a more recent compression algorithm that is supported by Skyrim SE, but not LE. Its compression rate is equal to BC3 and BC5, but at higher quality. This does come at the cost of somewhat longer time to compress. Always use the slowest compression method when given the option, for highest quality. BC7 is preferred over BC5 in nearly all cases. DXT1/BC1 is still preferred for textures without alpha channels, or 1-bit alpha, since it is much smaller. When exporting as BC7, always use the slowest compression algorithm for the highest quality.
  
 
{{note|Images that are already compressed in .dds format cannot be increased in quality by reformatting them, unless you use the original ''uncompressed'' texture as a base.}}
 
{{note|Images that are already compressed in .dds format cannot be increased in quality by reformatting them, unless you use the original ''uncompressed'' texture as a base.}}
Line 73: Line 73:
  
 
Your normal map is a bit different than the diffuse, as we will place the specular map in the alpha channel.
 
Your normal map is a bit different than the diffuse, as we will place the specular map in the alpha channel.
 
 
'''Photoshop Instructions'''
 
 
*Step 1: Open normal map
 
*Step 1: Open normal map
 
*Step 2: Import specular map or inverted roughness map
 
*Step 2: Import specular map or inverted roughness map
Line 83: Line 80:
 
*Step 6: Delete specular map layer and enable all channels
 
*Step 6: Delete specular map layer and enable all channels
  
Confused? [https://wiki.beyondskyrim.org/w/images/e/ed/Specular_to_Normal_Alpha_Channel.gif Watch this video].
+
Confused about the specular and normal map? [https://wiki.beyondskyrim.org/w/images/e/ed/Specular_to_Normal_Alpha_Channel.gif Watch this video]!
 
+
 
+
'''GIMP Instructions'''
+
 
+
Visit our [https://wiki.beyondskyrim.org/wiki/Arcane_University:Gimp_for_Skyrim GIMP for Skyrim] wiki page for instructions.
+
  
 
===Converting PNG to DDS===
 
===Converting PNG to DDS===
Line 94: Line 86:
  
  
<center>'''Simply open the PNG/TGA of your diffuse, normal map, environment, and/or glow map in the software, and File > Save/Export As > DDS.'''</center>
+
<center>'''Simply open the PNG/TGA of your diffuse, normal map, environment, and/or glow map in the software, and File > Save As > DDS.'''</center>
  
 
<center>{{note|'''Always generate mipmaps.'''}}</center>
 
<center>{{note|'''Always generate mipmaps.'''}}</center>
Line 104: Line 96:
  
 
{| class="wikitable"
 
{| class="wikitable"
|+ <span id="Comparison of DDS Exporters"></span>Comparison of DDS Exporters
+
|+ Comparison of DDS Exporters
 
|-
 
|-
| 1. [https://developer.nvidia.com/nvidia-texture-tools-exporter '''Nvidia Texture Tools (NVTT) (Standalone and/or Photoshop Plugin)''']
+
| 1. [https://developer.nvidia.com/nvidia-texture-tools-exporter '''Nvidia Texture Tools (NVTT)''']
 
| These first two are tied in terms of quality. NVTT does require an Nvidia graphics card, but it has a nice GUI and outputs excellent quality. It comes as either a standalone application, which supports command-line use and batch scripts, or a Photoshop plugin.
 
| These first two are tied in terms of quality. NVTT does require an Nvidia graphics card, but it has a nice GUI and outputs excellent quality. It comes as either a standalone application, which supports command-line use and batch scripts, or a Photoshop plugin.
 
|-
 
|-
Line 121: Line 113:
 
| Has support for all DDS formats, but suffers from discoloration and blocky gradients.
 
| Has support for all DDS formats, but suffers from discoloration and blocky gradients.
 
|-
 
|-
| 5. [https://www.gimp.org '''GIMP''']
+
| 5. [https://code.google.com/archive/p/gimp-dds/ '''GIMP DDS Plugin''']
 
| Free, does not require special graphics cards or proprietary software, but has inferior results and lacks support for BC7 entirely.
 
| Free, does not require special graphics cards or proprietary software, but has inferior results and lacks support for BC7 entirely.
 
|}
 
|}
  
For more detailed information, see [https://w3dhub.com/forum/topic/417101-dds-files-and-dxt-compression/?tab=comments#comment-671198 this post].
+
For more detailed information, see [https://w3dhub.com/forum/topic/417101-dds-files-and-dxt-compression/ this post].
  
 
=== DXT and Normal Maps ===
 
=== DXT and Normal Maps ===
Line 135: Line 127:
 
== See Also ==
 
== See Also ==
 
*[https://www.reedbeta.com/blog/understanding-bcn-texture-compression-formats Understanding BCn Texture Compression Formats] by Nathan Reed
 
*[https://www.reedbeta.com/blog/understanding-bcn-texture-compression-formats Understanding BCn Texture Compression Formats] by Nathan Reed
*[https://w3dhub.com/forum/topic/417101-dds-files-and-dxt-compression/?tab=comments#comment-671198 Comparison of different DDS compressors]
+
*[https://w3dhub.com/forum/topic/417101-dds-files-and-dxt-compression/ Comparison of different DDS compressors]
 
*[[wikipedia:DirectDraw Surface|DirectDraw Surface]] on Wikipedia
 
*[[wikipedia:DirectDraw Surface|DirectDraw Surface]] on Wikipedia
 
*[[wikipedia:S3 Texture Compression|S3 Texture Compression]] on Wikipedia
 
*[[wikipedia:S3 Texture Compression|S3 Texture Compression]] on Wikipedia

Please note that all contributions to Beyond Skyrim are considered to be released under the Creative Commons Attribution-ShareAlike (see Beyond Skyrim Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel | Editing help (opens in new window)

Template used on this page: