You should see 100x speedup in loading images into Texture2Ds. Texture2D myTexture = TextureLoader.LoadTextureDXT(bytes, TextureFormat.DXT1)
#Dds plugin for gimp 2.8 code
Here's some simple code to do that:īyte bytes = System.IO.File.ReadAllBytes(ddsFilePath) So you just need to read the bytes from a DDS file and then pass them to this C# method. Texture2D texture = new Texture2D(width, height, textureFormat, false) Int width = ddsBytes * 256 + ddsBytes īyte dxtBytes = new byte īuffer.BlockCopy(ddsBytes, DDS_HEADER_SIZE, dxtBytes, 0, ddsBytes.Length - DDS_HEADER_SIZE) Unable to read") //this header byte should be 124 for DDS image files Throw new Exception("Invalid DDS DXTn texture. Only DXT1 and DXT5 formats are supported by this method.") Throw new Exception("Invalid TextureFormat. If (textureFormat != TextureFormat.DXT1 & textureFormat != TextureFormat.DXT5) Here's my code for loading a DDS file into a Texture2D within a class named TextureLoader: public static Texture2D LoadTextureDXT(byte ddsBytes, TextureFormat textureFormat) You need to exclude the header bytes, however, when you pass the bytes to the LoadRawTextureData method (which was added in Unity 4.3 but sadly has not yet been documented). To load your DDS file in Unity, you'll need to read the DDS header which is described in detail here: īasically, a DDS file has a 128 byte header which contains some useful information like the width and height of your image.
Choose DXT1 compression if your image doesn't have an alpha channel (e.g., JPG images) or DXT5 compression if your images do have alpha (e.g., PNG). Load your jpg/png image(s) into one of these tools, and then export it as a DDS file. To save your images into DDS format, you can use Photoshop with the Nvidia texture tools plugin ( ), or you can use a free tool like GIMP (with its DDS plugin- ). So how can you get your images into DDS format, and how can you load them in Unity? + Support for saving existing mipmap chain (2D images only). I found that the time required to load the DDS version of the same image (with DXT1 compression) is roughly 3 ms! Amazingly fast.
#Dds plugin for gimp 2.8 download
The makers of have a nice collection of plugins for Gimp 2.8 that you can download, and they.Go there and download either layerfx.scm which is the script-fu version or a newer better one for gimp 2.8 is layerfx.2.8.py but you do not need both.
DDS is a file format created by Microsoft for use in their Direct X SDK (Software Development Kit.) Direct X.
#Dds plugin for gimp 2.8 how to
It can be used as a simple paint program, an expert quality photo retouching program, an online batch processing system, a mass production image render, an image format converter etc. How to Install a DDS Plugin for GIMP (9 Steps).
On our project at NOAA, we are loading hundreds of 4000 x 2000 jpg images and the time required to load each texture and compress it was roughly 600 ms (milliseconds). Gimp Script-Fu example (functions, parameters). It is a free application for photo retouching, image composition and image authoring. I've found a lot of good help on the Unity forums, so it is my turn to provide an answer.ĭDS (DirectDraw Surface) files can be loaded in Unity at runtime using the Texture2D LoadRawTextureData() method.