FuNK!
Registered
Hey there,
if you have ever tried to convert a track or mod with a massive amount of textures you will surely know that it takes a lot of time to edit the DDS textures one by one to suit the Albedo requirements by rFactor2.
Tutorial for ImageMagick and DirectXTex (by @FuNK!)
Note: Any of the commands below can just be copy-pasted. You don't need to re-type them!
Note: It was reported that on some systems you have to add "magick" before the "mogrify" command.
1. Install ImageMagick
Get the latest version here: ImageMagick for Windows
2. Download the DirectXTex tools
Get the latest version here: Microsoft DirectXTex releases on GitHub
You have to download »texconv.exe« and »texdiag.exe«.
3. (Optional) Download @Lazza's "rF2_TexFix" program
This tool replaces the manual sorting process as described in section 7, as well as the modification and conversion of the textures as described in section 8.
Simply place the rF2_TexFix.exe in your root directory (see section 5)
https://www.dropbox.com/s/qols3xqtnoqn4yd/rF2_TexFix.zip?dl=0
4. (Optional) Install the Cmder command-line tool
This step is optional because you can just use the Windows command shell (cmd). Cmder is for the power users (installation is manual, Cmder provides some more/better features).
Get the latest version here: Cmder releases on GitHub
Follow the installation instructions here.
5. Prepare folders and tools
Choose a directory where you want to do the texture conversions and edits. Create the following (sub-)directories there:
Now copy the DirectXTex tools »texconv.exe« and »texdiag.exe« into the root directory.
(Info) You may chose your own directory names, but then you have to modify the commands below to suit this.
6. Open a command shell in the root folder
Open a new Windows command shell (cmd) in the root folder by press and hold shift key and rightclick somewhere in a empty area. From the menu select »Open command window here«.
(Optional) If you use Cmder and have installed it properly, you can do a rightclick somewhere in the folder and select »Cmder here«.
7. Copy your source DDS files and sort them according to their format
(Info) You can skip this step, if you already know the DDS formats. Just move the files in the respective »dxt*« sub-directory of »dds-source«. Sorting is necessary because after conversion the source DDS to PNG files the DDS format information is lost and a conversion back to DDS will automatically convert the PNG to DXT5 DDS files.
(Info) Please exclude any cubemaps, bumpmaps or specmaps from the source files as the don't need to be modified.
Copy all your source DDS files in the »source« folder. Run the following command to gather the format information:
This command creates an »output.txt« file in the root directory which includes all basic information of the DDS files in the »source« directory. The »output.txt« will be directly opened with the Editor (it's the Windows default, of course you may use another program). You can avoid this by only using the first part of this command (until »&&«).
Screen the »output.txt« for BC1 (a.k.a. DXT1) and BC3 (a.k.a. DXT5). Move the files into the respective sub-directory in your source directory (DXT1 to »dxt1« and »DXT5 to »dxt5«).
(Info) Normally the files in DXT1 format are the minority, so moving these first might be the fastest way to sort the files.
8. Convert, modify and convert back with ImageMagick and texconv
(Info) ImageMagick gives the best lossless results for PNG conversion, so this is the preferred method. Texconv can do the conversion too, but the results are compressed too much which will result in even worse DDS later. Therefore I don't include the alternative commands here, but if you are interested have a look into the DirectXTex Wiki.
Run the following command:
This command will convert the DDS files to PNG based on their source folders (i.e. format) and modify the color levels at the same time. The last part of the command then converts the modified PNG back to DDS and save them in the »output« directory. During all steps the console output gets written into a log.txt file (that's much easier than scrolling the console)
Please note: In case you only have DXT1 or DXT5 textures the above command will fail. You need to use the following separated commands instead:
For DXT1:
For DXT5:
Now you are done and that just took (without the installation of the tools) just a couple of minutes instead of hours or days! Awesome, right?
Tutorial for Photoshop (by @KittX)
(Info) This tutorial uses the macro-capabilities of Photoshop. Follow these simple steps to configure your macro to batch-edit DDS files. You have to record one macro for DXT1 files and one for DXT5. You can follow the steps 4 to 6 from the tutorial above to sort your files.
1. Open one of the files to edit in Photoshop, go to Window-Actions, and you have actions tab near the history tab.
2. Press "Create new action" (sheet icon), name it appropriately
3. Press record. Now every action you make is recorded. But it can be then removed and re-recorded if needed.
4. Apply color levels , and save it in the needed dds format*. It will record the dds saving settings, so you can make 2 sets of actions - for dxt1 and dxt5 for example.
5. Once you've saved, press stop and your action is ready to use.
6. Go to File > Automate > Batch, choose your action, choose folder and it'll convert your files.
*But make sure you revert the changes to the file you've opened for recording actions, and save it before going batch process, or make sure it is in another folder. Otherwise it will open that file again, and will apply levels again.
========================
Please note: DDS is a compressed format. Open a DDS, edit it and save it again will unfortunately result in a loss of quality. Make sure to not do more than maybe one or too editing steps. Better solution is to go with original files (e.g. with skins or textures in their PSD format).
Let me know your comments and report any problems/difficulties. And maybe someone is willing to improve this to a full tool (batch file, etc.)!? All programs are open source, so even redistribution in your own program would be allowed
Credits:
Thanks @Marcel Offermans for (accidentally) reminding me of ImageMagick's great features and possibilities!
Thanks to @KittX to add how you could achieve batch-editing with Photoshop!
Thanks to @Lazza for providing the little program to translate the manual process into a automatic one!!
if you have ever tried to convert a track or mod with a massive amount of textures you will surely know that it takes a lot of time to edit the DDS textures one by one to suit the Albedo requirements by rFactor2.
Tutorial for ImageMagick and DirectXTex (by @FuNK!)
Note: Any of the commands below can just be copy-pasted. You don't need to re-type them!
Note: It was reported that on some systems you have to add "magick" before the "mogrify" command.
1. Install ImageMagick
Get the latest version here: ImageMagick for Windows
2. Download the DirectXTex tools
Get the latest version here: Microsoft DirectXTex releases on GitHub
You have to download »texconv.exe« and »texdiag.exe«.
3. (Optional) Download @Lazza's "rF2_TexFix" program
This tool replaces the manual sorting process as described in section 7, as well as the modification and conversion of the textures as described in section 8.
Simply place the rF2_TexFix.exe in your root directory (see section 5)
https://www.dropbox.com/s/qols3xqtnoqn4yd/rF2_TexFix.zip?dl=0
4. (Optional) Install the Cmder command-line tool
This step is optional because you can just use the Windows command shell (cmd). Cmder is for the power users (installation is manual, Cmder provides some more/better features).
Get the latest version here: Cmder releases on GitHub
Follow the installation instructions here.
5. Prepare folders and tools
Choose a directory where you want to do the texture conversions and edits. Create the following (sub-)directories there:
Code:
\dds-source
\dds-source\dxt1
\dds-source\dxt5
\png-dxt1
\png-dxt5
\output
(Info) You may chose your own directory names, but then you have to modify the commands below to suit this.
6. Open a command shell in the root folder
Open a new Windows command shell (cmd) in the root folder by press and hold shift key and rightclick somewhere in a empty area. From the menu select »Open command window here«.
(Optional) If you use Cmder and have installed it properly, you can do a rightclick somewhere in the folder and select »Cmder here«.
7. Copy your source DDS files and sort them according to their format
(Info) You can skip this step, if you already know the DDS formats. Just move the files in the respective »dxt*« sub-directory of »dds-source«. Sorting is necessary because after conversion the source DDS to PNG files the DDS format information is lost and a conversion back to DDS will automatically convert the PNG to DXT5 DDS files.
(Info) Please exclude any cubemaps, bumpmaps or specmaps from the source files as the don't need to be modified.
Copy all your source DDS files in the »source« folder. Run the following command to gather the format information:
Code:
texdiag info dds-source\*.dds > output.txt && START output.txt
Screen the »output.txt« for BC1 (a.k.a. DXT1) and BC3 (a.k.a. DXT5). Move the files into the respective sub-directory in your source directory (DXT1 to »dxt1« and »DXT5 to »dxt5«).
(Info) Normally the files in DXT1 format are the minority, so moving these first might be the fastest way to sort the files.
8. Convert, modify and convert back with ImageMagick and texconv
(Info) ImageMagick gives the best lossless results for PNG conversion, so this is the preferred method. Texconv can do the conversion too, but the results are compressed too much which will result in even worse DDS later. Therefore I don't include the alternative commands here, but if you are interested have a look into the DirectXTex Wiki.
Run the following command:
Code:
mogrify -format png -define png:compression-level=0 -define png:compression-filter=5 -define png:compression-strategy=2 -depth 8 -channel RGB +level 7.8%,78.4% -path png-dxt1\ dds-source\dxt1\*.dds >> log.txt && mogrify -format png -define png:compression-level=0 -define png:compression-filter=5 -define png:compression-strategy=2 -depth 8 -channel RGB +level 7.8%,78.4% -path png-dxt5\ dds-source\dxt5\*.dds >> log.txt && texconv -nologo -timing -y -f DXT1 -o output png-dxt1\*.png >> log.txt && texconv -timing -nologo -y -f DXT5 -o output png-dxt5\*.png >> log.txt
Please note: In case you only have DXT1 or DXT5 textures the above command will fail. You need to use the following separated commands instead:
For DXT1:
Code:
mogrify -format png -define png:compression-level=0 -define png:compression-filter=5 -define png:compression-strategy=2 -depth 8 -channel RGB +level 7.8%,86.3% -path png-dxt1\ dds-source\dxt1\*.dds >> %FileDateTime%_log.txt && texconv -nologo -timing -y -f DXT1 -o output png-dxt1\*.png >> %FileDateTime%_log.txt
For DXT5:
Code:
mogrify -format png -define png:compression-level=0 -define png:compression-filter=5 -define png:compression-strategy=2 -depth 8 -channel RGB +level 7.8%,86.3% -path png-dxt5\ dds-source\dxt5\*.dds >> %FileDateTime%_log.txt && texconv -nologo -timing -y -f DXT5 -o output png-dxt5\*.png >> %FileDateTime%_log.txt
Now you are done and that just took (without the installation of the tools) just a couple of minutes instead of hours or days! Awesome, right?
Tutorial for Photoshop (by @KittX)
(Info) This tutorial uses the macro-capabilities of Photoshop. Follow these simple steps to configure your macro to batch-edit DDS files. You have to record one macro for DXT1 files and one for DXT5. You can follow the steps 4 to 6 from the tutorial above to sort your files.
1. Open one of the files to edit in Photoshop, go to Window-Actions, and you have actions tab near the history tab.
2. Press "Create new action" (sheet icon), name it appropriately
3. Press record. Now every action you make is recorded. But it can be then removed and re-recorded if needed.
4. Apply color levels , and save it in the needed dds format*. It will record the dds saving settings, so you can make 2 sets of actions - for dxt1 and dxt5 for example.
5. Once you've saved, press stop and your action is ready to use.
6. Go to File > Automate > Batch, choose your action, choose folder and it'll convert your files.
*But make sure you revert the changes to the file you've opened for recording actions, and save it before going batch process, or make sure it is in another folder. Otherwise it will open that file again, and will apply levels again.
========================
Please note: DDS is a compressed format. Open a DDS, edit it and save it again will unfortunately result in a loss of quality. Make sure to not do more than maybe one or too editing steps. Better solution is to go with original files (e.g. with skins or textures in their PSD format).
Let me know your comments and report any problems/difficulties. And maybe someone is willing to improve this to a full tool (batch file, etc.)!? All programs are open source, so even redistribution in your own program would be allowed
Credits:
Thanks @Marcel Offermans for (accidentally) reminding me of ImageMagick's great features and possibilities!
Thanks to @KittX to add how you could achieve batch-editing with Photoshop!
Thanks to @Lazza for providing the little program to translate the manual process into a automatic one!!
Last edited: