In today's quick tip, new author Ankash Kallyat will discuss optimizing textures in Unreal Development Kit and some of the key things to remember when importing textures into UDK. We'll look at a few ways to save memory by extracting Specular maps from Diffuse maps, as well as working with LOD settings to optimize game play.
Every few weeks, we revisit some of our reader's favorite posts from throughout the history of the site. This tutorial was first published in December of 2011.
Before we start, I would like to list out the formats supported by UDK. The following Texture formats are supported:
I mostly prefer TGA as it is now supported by most of the software packages, plus you can tweak the alpha. I often save textures in TGA format, but sometimes TGA files get saved in 32 bit and sometimes with a plain alpha, even though they actually don't contain any alpha information.
This is very bad because UDK imports TGA files and tries to compress them with it's built-in Compressor known as DXTC. However, the alpha is not completely compressed or sometimes not at all by Unreal Engine 3. So it's better to save the file without an alpha, if you really don't need any alpha information in the Unreal Engine. Also make sure the file is saved with 8 bits per channel RGB/RGBA format to avoid complications when importing.
Here I'll be starting off with a simple foliage texture (the Banana Palm leaf.)
Extracting a Specular map from a Diffuse map
We all tend to save files in three different formats i.e. Diffuse, Specular and Normal maps. Although you really don't always have to save a separate specular map, because we can extract it from the diffuse map.
As shown above in the the Unreal Material Editor, I extracted the Red and Green information from the Diffuse map, and then multiplied it. I again multiplied it with a constant value of 18 just to crank up the result.
You can adjust it according to your desires or you could import a 256 x 256 specular map instead of using the constant parameter.You will be able to see the second multiplied value starts to shine a little bit (which is exactly what we wanted,) after that just plug the result into the "Specular" node.
You can also plug the constant parameter value into the "Specular Power" node, if want a nice and shiny specular Result. That's it, we've just created a specular map from a diffuse map and have thus saved enough memory to load one more 1024 res map in engine.
Importing Tips n Tricks
Whenever we try to load or save a texture map we usually miss out and forget to check the resolution of the texture map. Always check the resolution of the map because UDK only imports textures with a resolution of 2 (x2.)
For example: 256 x 256, 512 x 512, 1024 x 1024, 2048 x 2048 and so on. Again make sure the file is saved in 8 Bits per Channel RGB/RGBA format, to avoid complications while importing. To check this out, open up the file in Photoshop and Go to Image-->Mode--> and there you should see 8 Bits/ Channel selected. If it's not, then just click on it. After you load the texture, make sure that you've set the LOD Bias.
LOD Bias Setting
As shown in the above texture properties, I have imported the banana leaf texture with a resolution of 1024 x 1024 but I've set the LOD bias to 1. What Happens here is the resolution decreases by 1 step (x2) which is 512 x 512, so you don't have to load photoshop for that.
The reason I've set the load bias to 1 is because our mesh is simple foliage and 1024 x 1024 is going to drain a lot of memory. Below is the difference between "With LOD Bias" and "Without LOD Bias".
In UDK go to View and then the Browser window and select Texture Stats to see the statistics of the textures loaded in your scene.
Without LOD BIAS Setting
As you can see in the above image, the textures are loaded in a 1024 x 1024 dimension with no LOD bias set. The Textures here are each using about 1366kb of memory.
With LOD BIAS Setting
In the above pic, the textures are loaded in 1024 x 1024 dimensions but with the LOD Bias set to 1. Each Texture is using about 342 kb of memory.
For objects where you need high detail you don't have to do the above process. But for simple static objects like foliage, grass, leaves and any other such static meshes, you can go for the above process. This will save a lot of memory thus optimizing the gameplay.
- A Comprehensive Beginners Guide to UDK
- UDK – Creating Events With Unreal Kismet
- Quick Tip: An Introduction to Light-Mapping in UDK
Envato Tuts+ tutorials are translated into other languages by our community members—you can be involved too!Translate this post