Making DDS textures

From Rigs of Rods Wiki

Jump to:navigation, search

Contents

Introduction

DDS (also known as DXT or S3TC, or S3 Texture Compression) is a compressed picture format (similarly to JPEG or PNG), but with a very special characteristic:

DDS textures are kept in compressed form inside video memory (VRAM) and are decompressed on the fly in real time by the hardware (the decompression time is negligible, in fact you can even gain speed because less memory is accessed).

When you use PNG or JPEG textures, none of this happens: the picture is decompressed by software, and the RAW, uncompressed result is stored into VRAM, no matter what compression format the picture was (except for DDS).

DDS is a lossy format (that means that the image quality is slightly degraded), with fixed compression ratio: 1/8 for DXT1 and 1/4 for DXT3 and DXT5 (More on this later). So with DDS you can save 3/4th to 7/8th of the video memory used by your textures!

Another advantage is that DDS files includes precomputed Mipmaps for texture filtering, so the game does not have to generate them when loading the file, hence faster load time.

Generating and Usage

Okay, so now you know that DDS is a good thing. How to generate them and how to use them?

To generate a DDS file you need a DXT converter. I recommend you use the free NVidia nvDXT tool downloadable here. It is a command line converter that converts any picture into a DDS picture.

But before converting, you need to know what variant of DXT is good for your texture:

  • For opaque texture (no alpha transparency), use DXT1, you will obtain 8x compression, no alpha.
  • For textures with sharp transparent cutouts (like vehicle body with cutout windows), use DXT3, you will obtain 4X compression with sharp alpha transitions, but only 16 distinct alpha levels.
  • For texture with smooth, subtle transparency variation (like smoke clouds), use DXT5, you will obtain 4X compression with interpolated alpha values (smooth but blurry).

To convert with nvDXT, use the following commands:

  • DXT1: nvdxt -file <input file> -quality_highest -rescale lo -dxt1c
  • DXT3: nvdxt -file <input file> -quality_highest -rescale lo -dxt3
  • DXT5: nvdxt -file <input file> -quality_highest -rescale lo -dxt5

After that, you can use the resulting DDS file in material files as you used to do with the original PNG or JPG, just don't forget to change the extension in the material file so it uses the .dds file. For example:

material mymaterial
{
	technique
	{
		pass
		{
			texture_unit
			{
				texture mytexture.dds
			}
		}
	}
}

Note that you don't need to distribute the original picture file anymore, the game will only use the dds file.

Plugin Converters

Paint.NET

Another method is to use Paint.NET for the creation of .dds files. To do this:

  1. Open the image in Paint.NET
  2. Navigate to File in upper left hand corner
  3. Click Save As
  4. Select .dds as file type
  5. Select DXT1, DXT3, or DXT5 as compression type

Adobe PhotoShop 7.0

Another method is using the special DDS plugin for Photoshop, you can get it here: DDS Plugin for Photoshop

  1. After installing, launch PhotoShop and load a image normally
  2. Make your skin or what you want
  3. Save normally (don't change parameters)

GIMP

  1. Make sure you have GIMP 2.4 or higher.
  2. Download this DDS plugin
    1. Install under Windows, compile with Linux (make sure you have the GIMP dev package)
  3. Save as you normally would, except choose file type as DDS.
  4. Use appropriate compression method