Jump to content
Sign in to follow this  
toby23

Guide to mipmapping and optimising textures

Recommended Posts

Guide to mipmapping textures for flight simulation


By Toby Rayfield 27/06/2015

 

 

Updated 02/07/2015

- Flipping Section added for BMP to DDS conversion

 

 

CONTENTS

I. Texture Compression

II. Texture Formats

III. Tools you will need

IV. Why would I want mipmaps anyway?

V. How to check if a texture needs converting

VI. How to add mipmaps using Imagetool

VII. Resizing and converting textures using Photoshop

VIII. Texture Dimensions and File Size

IX. Saving a DDS in Photoshop

X. Filesizes as an indicator of optimisation

XI. Which textures can I convert?

XII. Naming Conventions

XIII. Saving a Bitmap as DDS in Imagetool

XIV. Batch Commands

 

 

Texture compression

There are two types of texture compression that should be used, which will allow you to balance file size with function.

 

DXT1 textures are for textures with no alpha channel, or a pure black or white alpha channel.

DXT5 textures are for textures with greyscale Alpha layers

 

DXT3 textures should not be used as they show compression artifacts in the final image.

 

Texture Formats

Textures come in various formats, the two most common found in flight simulator add-ons  are BMP and DDS format. Both formats can use DXT1 or DXT5 compression.

 

More information about these formats is available here (http://www.prepar3d.com/SDKv2/LearningCenter/modeling/texturing_aircraft_%20models.html). 

 

BMP's were used in older versions of Microsoft Flight Simulator but with the introduction of FSX, Microsoft changed to the more efficient DDS format. BMP files still work in Prepar3d but are not recommended.

Quote P3D SDK: The DDS format allows images to be compressed with greater efficiency and flexibility than formats such as BMPs

 

If you are interested to learn more about how textures work, I highly recommend the SDK link above as a starting point.

 

Tools you will need

1. ACES Imagetool - included with the FSX/P3D SDK, more information about this essential tool here


2. Adobe Photoshop

3. Nvidia Texture Tools for Adobe Photoshop (https://developer.nvidia.com/nvidia-texture-tools-adobe-photoshop)

 

While there are many other tools out there, these are the ones I will discuss and recommend.

 

 

 

Why would I want mipmaps anyway?

In the image below, you can see unmipped and uncompressed gauge textures. Do you see how the lines appear unclear? In motion, it is much worse as the lines appear to vibrate and distract from the flight. This is because there are no mipmaps, so the computer displays the original raw and uncompressed image. As I am not sitting at exactly the correct distance from this texture, it cannot display the texture correctly, hence the unclear image.

 

 no-mip.jpg

 

In this second image, the gauge textures have been mipmapped. While they appear blurry in this cropped image, in the sim, they are clear and easily readable. If I had to choose between the two, I would choose the mipmapped version. As the texture now has mipmaps, the computer can choose which version is the optimal one for my distance from the texture.

 

mip.jpg

 

!! Before you start editing textures, always create a backup of the textures that you want to edit !!

 

How to check if a texture needs converting

1. Open Imagetool

2. Open the folder containing the textures you would like to optimise

3. Drag the texture onto the open window of Imagetool

One of the following things will happen:

 

imagetoolerror.png

 

imagetoolsuccess.png

 

If the image won't open in the official texture tool, imagine the problems that this could cause for your simulator. While the textures might display without crashing the sim, who knows what this might cause to happen behind the scenes.

 

All of my textures open in Imagetool. So I see no reason why anyone should provide textures that don't.

 

Textures can be saved, compressed and converted in a way that they appear correctly in the sim and do not open in Imagetool but if a texture opens in Imagetool, then it is correctly formatted and adheres to the official SDK format guidelines, which is what we're aiming for.

 

6. In the second image above, you can see on the right, under the information tab, that the image is 4096x4096 pixels large, has DXT5 compression, it is unknown if the image has an alpha channel and the image contains no mipmaps (1 Mip Level is the texture).

 

7. If I now open this texture in Photoshop, using the options selected below for opening DDS files, I can see that it does have an alpha channel, so I know that DXT5 is the correct format for this texture.

 

NVIDIAtoolopendialogue.png    alphachannel.png

 

8. As this image is already in the correct DDS format, I now have two options, I can resize and save this file using Photoshop or I can convert it and add mipmaps using Imagetool. I will explain both methods below. It depends on personal preference, normally it is easier to batch convert multiple files with Imagetool but if you need to resize as well, then you will need to use Photoshop. Note that batch methods can be used in both programs effectively. I find it easier to create batch tools in Photoshop to automatically process large amounts of textures.

 

!! Before you start editing textures, always create a backup of the textures that you want to edit !!

 

How to add mipmaps using Imagetool

- Open the image in Imagetool

- Select 'Image > Create Mipmaps' from the menu bar

 

imagetool-create.jpg

 

Congratulations, you have now added mipmaps to the texture

 

imagetoolmippeddda45.png

 

Close Imagetool and save the image when prompted.

 

The ideal size for textures in the FSX/P3D engine is 1024x1024 pixels. As this image is 4096x4096, it has not been fully optimised. As shown in the image below, the mipped version is 5mb larger than the non-mipped version, so we still need to resize this texture to fully optimise it.

 

mippedbutnotresized.png

 

Resizing and converting textures using Photoshop

1. Open the original .dds image that you want to optimise in Photoshop, using the options as shown in the image below, when asked.

 

NVIDIAtoolopendialogue.png

 

2. Select 'Image > Image Size' in the Photoshop menu bar.

 

 resize.png

 

3. Enter your preferred size in the entry field, choose between 1024 or 2048, and select a resample method.

I use 'smooth gradients' as 'sharpen' adds halos around lines, as shown in the zoomed in images below.

 

smoother.png

 

sharper.png

 

Texture Dimensions and File Size

Textures should be 1024x1024 pixels. As the examples above show an external aircraft texture and I am prepared to spend a bit more VAS having nicer looking textures on my aircraft, I chose 2048x2048 pixels. 4096x4096 is uneccesarily large for these kind of external livery files and it will also take a long time to save the DDS file.

 

Normally an aircraft will not contain more than 2 main texture sheets, which is why I can justify using 2048x2048 for these two textures. An airport is a different matter as that has many textures, maybe as many as 50 and if half of them are 4096x4096, you shouldn't be surprised when you run out of VAS and the sim crashes.

 

2048x2048 should always be enough for your favourite textures, use 1024x1024 for everything else, unless the original file is smaller, then leave it as it is.

 

Saving a DDS in Photoshop

Now, all we need to do is save this texture as a DXT5 DDS file.

 

1. Choose 'File > Save As' from the Photoshop Menu Bar

2. Select the format D3D/DDS (*.DDS;*.DDS), check that Alpha Channels is checked and click Save.

 

savemenu.png

 

Next, another window will open, from the NVIDIA plug-in. Set up the options as below and click 'Save'. Do not change any of the other options.

 

savedxt5dds.png

 

Congratulations, you now have an optimised texture.

 

If you were saving a texture without a greyscale Alpha Channel, then you would select DXT1 format from the drop down menu.

 

In the image below, you can see the results of various resizing and compression on file size and, hopefully, can understand why I chose the 2048x2048 DXT5 DDS option for this external texture.

 

optmisedsizes.png

 

Filesizes as an indicator of optimisation

You can use Windows Explorer to filter a folder of textures by size to quickly see if your newly purchased add on uses mipmapped textures or not. The following file sizes will normally indicate correctly mipmapped files.

 

43 kb

86 kb

171 kb

342 kb

683 kb

1366 kb

2731 kb

5462 kb

 

Anything else is either incorrectly optimised or a special texture, which we will come to in a minute.

 

The following image shows correctly optimised texture file sizes.

 

correctlymippedfolder.png

 

The next image shows incorrectly optimised texture file sizes. You will get the idea quickly enough but basically anything that you see with a filesize of 1025 kb, 4097 kb or 16,385 kb is incorrect and needs optimising. 

 

incorrectlymippedfolder.png

 

Which textures can I convert?

As mentioned previously, certain kinds of textures should not be converted or optimised. Environment maps (reflections), fresnel_ramps, bump maps, specular layers and prop textures should be left alone. While these textures can be optimised, it is beyond the scope of this document, to teach the techniques involved.

 

If you want to try converting bump maps, which are often delivered in 4096x4096 and therefore VAS consumers, you need to convert the file to 32 bit, if not already, then resave as DXT5 DDS. To avoid any artifacts or loss of quality, you would normally create a new bump map from the optimised texture that you have created instead. Read more about bump maps in the P3D SDK Documentation in the link at the very top of this document.

 

Naming Conventions

The SDK recommends  the following naming convention for textures:

ModelName_TextureNumber_Suffix.Extension

 

The Suffix _T is normally used to indicate an external texture.

Most developers use a version of the following suffixes but many don't. It is up to you to check each texture before you convert it.

 

The suffixes for each type of texture are as follows:

Diffuse Map: '_T'

Specular Map: '_T_Specular'

Bump Map: '_T_Bump'

Emmisive Map: '_T_LM'

 

A diffuse map is a regular texture, for example, the outside livery of an aircraft.

A Specular map is used to define how and where a model reflects light, e.g. the shininess of metal.

A Bump Map defines the 3d elements of a texture, for example, rivets and panel lines.

An Emmisive Map displays flat textured lighting effects, as seen on the tail of an aircraft at night.

 

Below is an image showing these types of files and how they might be named.

 

donttouch.png

 

Saving a Bitmap as DDS in Imagetool

Bitmaps in DXT1, DXT3 or DXT5 format have already been compressed. If you convert them to DDS format, you will compress them more and create visual artifacts, which can be seen as pixelated blocks in the textures. In this case, you only need to select the 'Create MipMaps' option and save the file.

 

If the Bitmaps are uncompressed and in 32 bit format, then you can convert them to DDS format without worrying about losing quality.

 

You will see a wide variety of incorrectly formatted textures. In the screenshot below, you can see a 32 bit BMP with 3 mip layers and an alpha layer open in Imagetool.

 

imagetooluncompressedbmp.png

 

If I select 'View > Alpha Channel' from the menu, I see this. An alpha channel with black, white and shades of grey. The correct format for this texture is DDS and it should be compressed using the DXT5 method.

 

imagetool-alpha.jpg

 



BMP textures need to be manually flipped by the CPU before they can be displayed in the simulator. DDS textures are already flipped, which reduces the work that your CPU needs to do before it can display the texture.


 

If we save a BMP in DDS format, the image will be flipped and will appear upside down in the simulator, as the developer mapped the texture to the model the other way round. To compensate for this, we need to flip the texture, before optimising it, so that it will display correctly.

 

!! Before you start editing textures, always create a backup of the textures that you want to edit !!

 

As Imagetool does not have a menu option for flipping textures, we will use the freeware DXTBMP tool from Martin Wright.

 

Flipping Images in DXTBMP

Open DXTBMP and drag the BMP that you want to convert to DDS onto the open DXTBMP window, as in the image below.

 


dxtbmp1.png

 

From the menu bar, select 'Image > Flip Image and Alpha', as shown in the image below.

 

dxtbmp2.jpg

 

From the menu bar, select 'File > Save' and, in the window that pops up, check that Save as Type is 'Extended 32 bit 888-8' as in the screenshot below, add the appendix '_flipped' to the filename and click Save.

 

dxtbmp3.png

 

Close DXTBmp, we have now finished using this tool.

 

You should now have two files, the original and the flipped version, as below.

 

dxtbmp4.png

 

Open Imagetool and drag the _flipped.bmp file onto the open window, as shown below.

 

dxtbmpimagetool5.png

 

In Imagetool, select 'Image > Format > DXT 5and then 'Image > Create MipMaps'.

 

imagetool-dxt5.jpg

 

Which gives the following result..

 

dxtbmpimagetool6e80cd.png

 

Now Save this new texture with the extension .dds and close Imagetool. This texture is now optimised.

 

Do not forget to remove the _flipped suffix before copying this file back to the specific texture folder.

 

The simulator looks first for DDS files, then for BMP files, so there shouldn't be any problems with conflicting files but as we want to do this correctly, you should remove the original BMP file from the specific texture folder as well.

 

If I compare the filesizes of these textures in Windows Explorer, I see this..

 

dxtbmpimagetool7.png

 

This texture was for a windsock. A relatively small part of an airport but one of 300 textures provided in a 'general texture' folder for an airport. If we work out how much VAS these textures would consume if loaded into memory...

 

The original uncompressed textures require 300 x 5.3mb = 1.6 Gigabytes of VAS to display

The optimised compressed textures require 300 x 1.3mb = 409 Megabytes of VAS to display

 

I know which ones I want to use.

 

Batch Commands

You can automate the conversion process by using so-called batch files in either Photoshop or Imagetool.

This next section will explain how to create and use batch files.

 

Imagetool

1. Create a new folder on your desktop called MIP IN

2. Create a copy of Imagetool.exe in this folder

3. Open Notepad++ and paste the following text into a new document:

ImageTool -nobeep -brief -DXT5 -mip -e BMP *.bmp

4. Save this file in your new MIP IN folder and call it 'mip BMP as DXT5.bat'

5. Copy the BMP texture that you want to convert to DXT5 to the MIP IN folder and double click on the .bat file.

6. The window below will briefly pop up, indicating that the process was successful

7. Congratulations, you have optimised a texture with a batch file

8. Check the file size for confirmation that the file has been optimised.

 

imagetool_batch.jpg

 

9. In the future, all you need to do is copy all of the BMP textures, with Alpha channels, that you want to convert to DXT5 format to the MIP IN folder and double click the .bat file.

 

Below is another example that can be used to create mipped DXT1 BMP files.

 

I. mip BMP as DXT1 No Alpha.bat

ImageTool -nobeep -brief -DXT1 -mip -e BMP *.bmp

 

I do not recommend trying to use Imagetool to convert .dds or .psd files as the files are not viewable in Imagetool afterwards. Imagetool can generate DDS files from 8 bit .psd files but why would you do this if you have Photoshop. 

 

Photoshop

1. Open Photoshop and in the 'Actions' tab, click on the drop down menu and select 'New Set...'

2. Name this Set 'Texture Conversion'

3. With this Set highlighted, click on the drop down menu and select 'New Action'

4. Name this Action 'Resave DDS as DXT5 mipped'

5. Press the record button on the bottom of the Actions tab

6. In the menu bar, select 'File > Open' and select the .dds file that you want to convert in Photoshop using the options shown below.

 

NVIDIAtoolopendialogue.png

 

7. In the menu bar, select 'File > Save As' and choose D3D/DDS format, as shown previously in the section Saving a DDS in Photoshop.

8. Close the image and press the Stop button on the bottom of the Actions tab

9. To test this batch file, or Action, create a new folder on your desktop called 'MIP IN PSD' and copy a couple of unoptimised DDS files to this folder.

10. Create a new folder called 'MIP OUT PSD' on your desktop.

11. In Photoshop, in the menu bar, select 'File > Automate > Batch' and set up the folders and options as below. Click the Choose button and set your 'MIP IN PSD' folder in the top part and select you 'MIP OUT PSD' folder in the bottom part.

 

batchpsd.png

 

12. When you click OK, the batch will run and automatically Open and Convert any files that it finds in your 'MIP IN PSD' folder. We created a 'MIP IN PSD' folder to avoid any conflicts with BMP files in your MIP IN folder.

 

Using these very powerful tools, you should find it easy to create your own Actions to carry out the following automated processes for you. Just apply a logical step by step process and learn from your mistakes and experiments.

 

Actions.png

 

The biggest tip I can give you is to backup your texture folders before you start any kind of optimisation.

Good Luck and happy mipping..

 

Toby

 

This document is dedicated to all of you..

 

  • Upvote 4

Ryzen 5800X3D, 64GB RAM, RTX 4090, Windows 10, Varjo Aero, DOF H3

Share this post


Link to post
Share on other sites

Thank you very much Toby. I was really fascinated by you conversation on mipmapping and how to setup a batch to do the image conversions. I've done some DirectX engine development and some livery creation for FSX, and I ended up doing it all by hand. Now that you posted the hot-to on setting up a batch, I'm in heaven. That will be a god-send for texture creation that I do in the future.

Share this post


Link to post
Share on other sites

Excellent post Toby, I really appreciate the time and effort you have put into explaining the how-to.

 

Well done!


\Robert Hamlich/

 

Share this post


Link to post
Share on other sites

Nice reading! Will definitly try this out for myself when I get home from vaccation.

 

I'm curious, have you tried this with heavy addons such as PMDG T7, NGX etc or mega-airports? It should drastically reduce VAS consumption but I don't know the scope and amount of textures that need to be mipmapped in order to achieve such.


38.jpg

Brynjar Mauseth 

Share this post


Link to post
Share on other sites

Toby, I was looking at optimizing LatinVFR KSNA. Opening the texture folder there are several bmp files, but they all are either DXT1 or DXT5.  Can I use the the following batch command to mip all of the bmp files?

 

ImageTool -nobeep -brief -mip -e BMP *.bmp

 

It's essentially the same batch command you use minus the -DXT5 portion.

Share this post


Link to post
Share on other sites

Correction to my previous post - I signed up for photoshop cloud subscription.  Got 1 month free.  This again is excellent howto.  You do get award of the year on AVSIM


Active Pattern: MSFS2020 | In Long term Storage: Prepar3d  

How I Evaluate Third Party Sim Addon Developers

Refined P3Dv5.0 HF2 Settings Part1 (has MaddogX) and older thread Part 2 (has PMDG 747)

Share this post


Link to post
Share on other sites

Toby, I was looking at optimizing LatinVFR KSNA. Opening the texture folder there are several bmp files, but they all are either DXT1 or DXT5. Can I use the the following batch command to mip all of the bmp files?

 

ImageTool -nobeep -brief -mip -e BMP *.BMP

 

It's essentially the same batch command you use minus the -DXT5 portion.

Make a backup of your textures and give it a go! It's the best way to learn how this command line works, you won't break anything..

Ryzen 5800X3D, 64GB RAM, RTX 4090, Windows 10, Varjo Aero, DOF H3

Share this post


Link to post
Share on other sites

toby23 - is the key to save VAS also related to MipMaps.  For example if files can't open in ImageTool, and then I add MipMaps via Photoshop and save the DDS.  For example DX1 to DX1 Mipmap DDS and DX5 dds to dx5 Mipmap

 

And

 

I should not try to convert Dxt 1 textures to Dxt 5

 

Thanks


Active Pattern: MSFS2020 | In Long term Storage: Prepar3d  

How I Evaluate Third Party Sim Addon Developers

Refined P3Dv5.0 HF2 Settings Part1 (has MaddogX) and older thread Part 2 (has PMDG 747)

Share this post


Link to post
Share on other sites

The key to saving VAS is using optimised textures and settings in the sim and all of your add-ons.

Adding mipmaps increases the filesize but compressing then reduces the size.

Mipmaps are required for optimal display of a texture in a graphics engine.

 

If you read the beginning section of my guide again, you will see that DXT1 and DXT5 are used for different kinds of textures, those with and without alpha layers, but read the guide and it should help answer your questions. There is no need to convert DXT1 textures to DXT5.


Ryzen 5800X3D, 64GB RAM, RTX 4090, Windows 10, Varjo Aero, DOF H3

Share this post


Link to post
Share on other sites

Make a backup of your textures and give it a go! It's the best way to learn how this command line works, you won't break anything..

 

Maybe I missed it in your guide, but how do I determine if a texture file is mipped or not before looking at it in the sim?

Share this post


Link to post
Share on other sites

Open it in imagetool, see section V. How to check if a texture needs converting above.


Ryzen 5800X3D, 64GB RAM, RTX 4090, Windows 10, Varjo Aero, DOF H3

Share this post


Link to post
Share on other sites

Great guide. How about BMP files that are in 24-bit uncompressed format (A2A for example), when I send them to DXTBmp I don't see and option to save in 24-bit. Should I saved them as the guide mentions and then in Imagetool format them to 24-bit DXT5 or leave it as 32-bit?

 

Also, can this be done in GIMP?

Share this post


Link to post
Share on other sites

If you have a 24bit BMP and want to flip it before converting it to DDS format, then open it in DXTBmp and save it as an Extended 32 bit 888-8 .bmp file, before adding mipmaps and compressing it in Imagetool. If you save it as a 24 bit BMP image in DXTBmp, it most likely won't open in Imagetool. I can't comment on GIMP as I've never used it.


Ryzen 5800X3D, 64GB RAM, RTX 4090, Windows 10, Varjo Aero, DOF H3

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...