Military AI Works • How to batch convert textures from bmp to dds
Page 1 of 2

How to batch convert textures from bmp to dds

Posted: 10 Sep 2017, 18:55
by Greg
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.

Re: How to batch convert textures from bmp to dds

Posted: 11 Sep 2017, 06:52
by John Young
Does the batch file also flip the textures and alpha's vertically Greg?

John

Re: How to batch convert textures from bmp to dds

Posted: 11 Sep 2017, 08:57
by Greg
Yes John, just like when saving a texture manually as dds with Imageool the textures and alphas are flipped automatically.

Re: How to batch convert textures from bmp to dds

Posted: 11 Sep 2017, 09:09
by mikewmac
Thanks Greg,

Just what I needed. :)

Re: How to batch convert textures from bmp to dds

Posted: 11 Sep 2017, 09:26
by Greg
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!

Re: How to batch convert textures from bmp to dds

Posted: 11 Sep 2017, 14:27
by Joecoastie
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 ?

Re: How to batch convert textures from bmp to dds

Posted: 11 Sep 2017, 17:37
by Greg
Joecoastie wrote: 11 Sep 2017, 14:27EDIT: 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.

Re: How to batch convert textures from bmp to dds

Posted: 15 Sep 2017, 08:20
by Joseph29
Is there a guide to do this one file at a time also?

Re: How to batch convert textures from bmp to dds

Posted: 15 Sep 2017, 08:26
by gavinc
ImageTool.exe -e dds -DXT5 -dds -nogui -nodither -mip yourfilename.bmp

Re: How to batch convert textures from bmp to dds

Posted: 15 Sep 2017, 11:03
by Joseph29
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.

Re: How to batch convert textures from bmp to dds

Posted: 16 Sep 2017, 05:38
by Joseph29
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.

Re: How to batch convert textures from bmp to dds

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

Re: How to batch convert textures from bmp to dds

Posted: 17 Sep 2017, 01:14
by Joseph29
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?

Re: How to batch convert textures from bmp to dds

Posted: 17 Sep 2017, 01:39
by Joseph29
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.

Re: How to batch convert textures from bmp to dds

Posted: 17 Sep 2017, 09:02
by Greg
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.

Re: How to batch convert textures from bmp to dds

Posted: 17 Sep 2017, 09:20
by Joseph29
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.

Re: How to batch convert textures from bmp to dds

Posted: 17 Sep 2017, 10:19
by Greg
Excellent. Glad to be of help. :smt023

Re: How to batch convert textures from bmp to dds

Posted: 18 Sep 2017, 04:17
by Woogey
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

Re: How to batch convert textures from bmp to dds

Posted: 18 Sep 2017, 07:55
by John Young
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

Re: How to batch convert textures from bmp to dds

Posted: 18 Sep 2017, 21:41
by Victory103
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!