How to batch convert textures from bmp to dds

Share hints and tricks or your own modifications for MAIW Packages in Flight Simulator X and Prepar3D.
User avatar
Greg
MAIW Admin
MAIW Admin
Posts: 4437
Joined: 12 Aug 2006, 19:56
Version: P3D
Location: Belgium

How to batch convert textures from bmp to dds

Post by Greg » 10 Sep 2017, 18:55

As promised some time ago, here's a guide on how to batch convert your textures from bmp to dds.

Before we start, allow me to kick at an open door but don't say you weren't warned: BACK UP YOUR TEXTURES. And then back up your back up. This file is brutal and will delete all your hard work if you aren't careful. :!:

Now let's begin.
  1. Open notepad or another text editor
  2. Copy and paste the following code into the text file:

    Code: Select all

    @echo off
    echo.
    echo Converting all BMPs to DDS5..
    "D:\FSApps\Prepar3D v4 SDK 4.0.28.21686\ImageTool.exe" -e dds -DXT5 -dds -nogui -nodither -mip -r *.bmp
    echo Done
    echo Deleting all BMP files..
    DEL /S *.bmp > NUL
    echo Done
    echo.
    echo.
    pause
  3. Check the path to your ImageTool.exe file in the pasted code and make sure it's correct for your setup. This is superimportant! If the path isn't correct, the conversion step will fail but the next step will still continue and delete all your bmp's! So again, check the path every time before you run the batch file since it may change when you update your SDK.
  4. Save the file as dds_converson.bat. The location is up to you and depends on how you want to proceed. Just know that ALL bmp files that the batch file finds in the folder it sits in, including all subfolders, will be converted. You have two options here: either you save it in your main aircraft folder (e.g. SimObjects\Airplanes) if you want to convert all aircraft textures in one go or you save it in a specific aircraft folder to only convert the textures for that specific aircraft.
  5. Run the batch file and wait until it's done. If you have a lot of bmp textures this may take quite a while.
One other remark for more advanced simmers: this command will convert all textures to DXT5 with mipmaps whether they're aircraft, lightmap, prop or other textures. Many lightmap and prop textures could probably be converted to dds DXT1 which makes them a bit smaller but you'll need to make sure they only have a pure black and white alpha layer without gradients. If you know what you're doing then you can play with the code in the batch file to convert all *_l.bmp or *prop*.bmp files to DXT1 first and then the rest to DXT5.

If you have any questions or comments, don't hesitate.

User avatar
John Young
MAIW Developer
MAIW Developer
Posts: 2468
Joined: 12 Jul 2008, 15:15

Re: How to batch convert textures from bmp to dds

Post by John Young » 11 Sep 2017, 06:52

Does the batch file also flip the textures and alpha's vertically Greg?

John

User avatar
Greg
MAIW Admin
MAIW Admin
Posts: 4437
Joined: 12 Aug 2006, 19:56
Version: P3D
Location: Belgium

Re: How to batch convert textures from bmp to dds

Post by Greg » 11 Sep 2017, 08:57

Yes John, just like when saving a texture manually as dds with Imageool the textures and alphas are flipped automatically.

User avatar
mikewmac
Magic Mike
Magic Mike
Posts: 2344
Joined: 12 Aug 2006, 10:06
Version: P3D
Location: KBTV - Vermont

Re: How to batch convert textures from bmp to dds

Post by mikewmac » 11 Sep 2017, 09:09

Thanks Greg,

Just what I needed. :)
    Mike M.

    User avatar
    Greg
    MAIW Admin
    MAIW Admin
    Posts: 4437
    Joined: 12 Aug 2006, 19:56
    Version: P3D
    Location: Belgium

    Re: How to batch convert textures from bmp to dds

    Post by Greg » 11 Sep 2017, 09:26

    You're very welcome Mike.

    By the way, you can also use this on your scenery folders if you have old scenery with bmp textures. But again, back up first!

    User avatar
    Joecoastie
    Lieutenant Colonel
    Lieutenant Colonel
    Posts: 815
    Joined: 30 Jan 2007, 17:46
    Version: P3D
    Location: 8.2mi/077 radial of GVE

    Re: How to batch convert textures from bmp to dds

    Post by Joecoastie » 11 Sep 2017, 14:27

    Greg,

    If one wanted only to convert one aircraft's textures would you change the end of line 4 from ' *.bmp' to the full path to the aircraft folder ? e.g D:\--- \SimObjects\Aircraft\MGAI_F-35\*.bmp

    Joe

    EDIT: I just read the instructions again . It is dependent on where you run (folder) the batch file. Correct ?
    Service to my Country 9/61 - 2/03
    US Navy - HS-3, VX-1, HS-7
    Va National Guard - 229th Cbt Avn Co
    US Coast Guard - E City CGAS, CGC Morro Bay, RTC Yorktown
    NOAA - Co-op Observer 1983 - present

    User avatar
    Greg
    MAIW Admin
    MAIW Admin
    Posts: 4437
    Joined: 12 Aug 2006, 19:56
    Version: P3D
    Location: Belgium

    Re: How to batch convert textures from bmp to dds

    Post by Greg » 11 Sep 2017, 17:37

    Joecoastie wrote:
    11 Sep 2017, 14:27
    EDIT: I just read the instructions again . It is dependent on where you run (folder) the batch file. Correct ?
    Indeed. The bat file will only convert all textures of the folder it is in and all subfolders (-r), so just move it to the aircraft folder you want to convert.

    Joseph29
    Colonel
    Colonel
    Posts: 2035
    Joined: 20 Sep 2006, 20:35
    Version: P3D
    Location: Long Island New York

    Re: How to batch convert textures from bmp to dds

    Post by Joseph29 » 15 Sep 2017, 08:20

    Is there a guide to do this one file at a time also?

    User avatar
    gavinc
    MAIW Conversion Team
    MAIW Conversion Team
    Posts: 318
    Joined: 25 Aug 2013, 09:26
    Version: FSX

    Re: How to batch convert textures from bmp to dds

    Post by gavinc » 15 Sep 2017, 08:26

    ImageTool.exe -e dds -DXT5 -dds -nogui -nodither -mip yourfilename.bmp

    Joseph29
    Colonel
    Colonel
    Posts: 2035
    Joined: 20 Sep 2006, 20:35
    Version: P3D
    Location: Long Island New York

    Re: How to batch convert textures from bmp to dds

    Post by Joseph29 » 15 Sep 2017, 11:03

    gavinc wrote:
    15 Sep 2017, 08:26
    ImageTool.exe -e dds -DXT5 -dds -nogui -nodither -mip yourfilename.bmp
    Thanks. I will try it tonight or tomorrow.

    Joseph29
    Colonel
    Colonel
    Posts: 2035
    Joined: 20 Sep 2006, 20:35
    Version: P3D
    Location: Long Island New York

    Re: How to batch convert textures from bmp to dds

    Post by Joseph29 » 16 Sep 2017, 05:38

    Can someone post a link to where I can find ImageTool? Is DXTbmp a good tool to use? I have that tool but can't find ImageTool.

    User avatar
    Greg
    MAIW Admin
    MAIW Admin
    Posts: 4437
    Joined: 12 Aug 2006, 19:56
    Version: P3D
    Location: Belgium

    Re: How to batch convert textures from bmp to dds

    Post by Greg » 16 Sep 2017, 13:18

    It's part of the P3D SDK as you can see in the path in my code.

    Joseph29
    Colonel
    Colonel
    Posts: 2035
    Joined: 20 Sep 2006, 20:35
    Version: P3D
    Location: Long Island New York

    Re: How to batch convert textures from bmp to dds

    Post by Joseph29 » 17 Sep 2017, 01:14

    Greg wrote:
    16 Sep 2017, 13:18
    It's part of the P3D SDK as you can see in the path in my code.
    Thanks Greg.


    Ok I think I converted my first paint to DDS, but I think I am having a problem with the mips. When I click on Add MipMaps it says Mip image too large for original. What does that mean? And how do I properly add mips to a paint?

    Joseph29
    Colonel
    Colonel
    Posts: 2035
    Joined: 20 Sep 2006, 20:35
    Version: P3D
    Location: Long Island New York

    Re: How to batch convert textures from bmp to dds

    Post by Joseph29 » 17 Sep 2017, 01:39

    I think I need a step by step instruction on how to do this. The one I did is 1024x1024 and is 1.00MB in size. But the other ones are 4096x4096 and are 21.3MB in size. I don't think I did it right.

    User avatar
    Greg
    MAIW Admin
    MAIW Admin
    Posts: 4437
    Joined: 12 Aug 2006, 19:56
    Version: P3D
    Location: Belgium

    Re: How to batch convert textures from bmp to dds

    Post by Greg » 17 Sep 2017, 09:02

    This doesn't have anything to do with the batch convert instructions, but alright here's how to convert the texture manually with Imagetool:
    1. Open the bmp texture with Imagetool (if it doesn't open with that by default right-click on the bmp file and select "Open With" -> "Imagetool". You may need to select "Choose another app" first if it doesn't show up in the list immediately.)
    2. On the right hand side you'll see the details about your texture. If it's an FS9 texture you"ll probably see DXT3 or DXT1 as the format. It will also tell you if the texture has mulitple mipmaps which it should. If it isn't, it will say "# Mip Levels: 1". In that case go to "Image" in the menu -> "Create MipMaps". FS9 textures that were normally 1024x1024 pixels will now show 9 Mip Levels (1+8).
    3. Now convert the texture to DXT5 format. Select "Image" -> "Format" -> "DXT5".
    4. And finally save the image as a dds file. Select "File" -> "Save As" -> keep the file name but change the extension to .dds. Unlike DXTBmp, Imagetool will automatically flip the image and alpha channel for you.
    5. Delete the bmp file.
    That's it. You see it's quite a long process if you want to do it for every texture, hence why a batch file is so much easier. It does all these things automatically for you.

    Joseph29
    Colonel
    Colonel
    Posts: 2035
    Joined: 20 Sep 2006, 20:35
    Version: P3D
    Location: Long Island New York

    Re: How to batch convert textures from bmp to dds

    Post by Joseph29 » 17 Sep 2017, 09:20

    Thank you Greg!

    I only had one file to convert from BMP to DDS, so that is why I asked about converting only 1 file. But I did just download a few other textures that needed to be converted and I tried out your batch file. It worked good. Now I know how to convert 1 file to DDS and a bunch of files to DDS.

    User avatar
    Greg
    MAIW Admin
    MAIW Admin
    Posts: 4437
    Joined: 12 Aug 2006, 19:56
    Version: P3D
    Location: Belgium

    Re: How to batch convert textures from bmp to dds

    Post by Greg » 17 Sep 2017, 10:19

    Excellent. Glad to be of help. :smt023

    User avatar
    Woogey
    First Lieutenant
    First Lieutenant
    Posts: 158
    Joined: 04 Jul 2012, 18:23
    Version: P3D

    Re: How to batch convert textures from bmp to dds

    Post by Woogey » 18 Sep 2017, 04:17

    Ok this may be off subject slightly, but here goes: What causes texture "Flashing?" I thought for sure if I converted all the Nellis Textures to .dds, that the Flashing and Glitching would go away. Unfortunately not the case. It mostly happens with windows and Logos on buildings.

    -Woog

    User avatar
    John Young
    MAIW Developer
    MAIW Developer
    Posts: 2468
    Joined: 12 Jul 2008, 15:15

    Re: How to batch convert textures from bmp to dds

    Post by John Young » 18 Sep 2017, 07:55

    Texture flashing, or technically "co-planar flickering" is caused when two planes of the model share exactly the same position and the sim can't make up its mind what to display. Windows and signage on walls are quite classic problem areas and ground polygons can be another. There are ways to overcome that when designing, but the type of texture won't make any difference unfortunately, the fault is in the construction of the model or library object.

    John

    User avatar
    Victory103
    Colonel
    Colonel
    Posts: 3521
    Joined: 13 Aug 2007, 03:35
    Version: P3D
    Location: KPHX

    Re: How to batch convert textures from bmp to dds

    Post by Victory103 » 18 Sep 2017, 21:41

    Thanks for the review on the "manual" way to convert Greg. I've been staying with that until I felt comfortable with the batch file. I shouldn't need to worry as the 1st step is to backup everything!
    DUSTOFF
    ARMY PROPS

    -Chris

    Post Reply