Maps Converter
Overview
At Studio 397 we are looking to move towards an asset pipeline long term. What does that mean? Well it means we will provide tooling to help deploy assets to game, and the functions can range from ensuring textures are saved in the correct format, to baking lighting for cockpit interiors or tree lighting or more. This tool is the first step in that move and it is something that we are making use of daily to help improve our artists workflow.
The base premise of this tool is to convert TGA texture files to the correct and optimal DDS encoding for their purpose whilst doing some basic date checking to make sure it only converts updated textures. In order for all this to work you will have to name your textures to our naming standards though.
This tool is a command line app which calls Microsoft's freely available Texconv.exe to do the actual texture conversion.
Why use this?
- Removes the need to use Photoshop to export textures (any texturing software should be fine now).
- To prevent artists resaving of already compressed textures.
- To allow the use of newer DDS file formats which are not supported by 3ds Max (i.e BC5 & BC7).
- To allow representative textures to be visible in 3ds Max when opening scene files (specify the TGA files in your materials).
- To ensure files are automatically saved in the correct format (Linear v SRGB, number of mip maps etc).
- To do all of the above with minimal increase in artist work overhead.
Installation
The recommended usage of the tool at this time is to create a batch file in the folder above your maps folder to run the application. It will then automatically convert all TGA files in "MapsSource" newer than their DDS equivalent in "Maps" folder.
Firstly we need to locate where everything is on your PC. The exact location of the rFactor2 install depends on where you setup your steam installs, but by default it would be C:\Program Files (x86)\Steam\steamapps\common\rFactor 2\Support\MapConverter.
Custom Steam Apps Folder
For example, you have the following setup:
- "D:\MyTestTrack\Assets\MapsSource" - MapsSource folder (for TGA files)
- "D:\MyTestTrack\Assets\Maps" - Maps folder (for game ready DDS files)
Then all we need to do is have the batch file in D:\MyTestTrack\Assets\ with the following:
"C:\Program Files (x86)\Steam\steamapps\common\rFactor 2\Support\Tools\MapConverter\MapConverter.exe"
After running the batch file, an output log is generated in the same folder named "MapConverter.log". This tells you, for each texture it finds, what action it takes and why and if it has any issues.
Beneath we will detail other options you can specify in order to run it, such as specifying custom directories, and forcing the conversion of all textures regardless of time stamps.
If you want to change the folders it converts from and/or to. Assuming both those folders are in the same directory as your MapConvert.bat file, then you need to edit the bat file as follows.
"C:\Program Files (x86)\Steam\steamapps\common\rFactor 2\Support\Tools\MapConverter\MapConverter.exe" -s MySourceFolder -d MyDestinationFolder
Process
- Ensure all textures follow the set out naming conventions.
- Save uncompressed TGA files in either 32 bit (with alpha) or 24 bit (no alpha) into your source folder.
- Run your batch file to convert. This will convert any TGA files newer than the DDS equivalent in maps.
- Load the track or pack the track, or see textures hot reload in the Scene Viewer or Mod Dev.
Arguments
The application can be run with some optional arguments.
- -s <path>: This overwrites the default source path of "MapsSource"
- -d <path>: This overwrites the default destination path of "Maps"
- -f: This forces the conversion of all TGA files in the source path.
Required Texture Naming
Textures must be named following a standard as follows.
- All parts of the texture name must be separated with an underscore "_".
- The final part of the file name may be an underscore followed by two digits for texture animation. This is optional.
- Then working from the end of the filename, the next part of the file name must be the type of map. At present the following types are accepted:
- BC7 (RGBA) SRGB: alb, alba, albr, dc, dca
- BC7 (RGBA) Linear: ov, ova, mu, mua, spec, rdt, em, ema, spl
- BC5 (RG): nm, mr, aos, pt, mx, gr, mdm, bwm, bl
- The next part of the filename is optional. This allows the setting of how many mipmaps this texture should have.
- m<MipsNumber>.
- The filename maybe prefixed by as many parts as you like.
Below are some valid examples:
- BuildingA_Alba.tga
- Flag_Nm_00.tga
- Foliage_TreesA_m6_alba.tga
Below are some invalid examples:
- BuildingB_diff.tga
- BuildingCalba.tga
- Flag_Nm00.tga
- Foliage_TreesB_alba_m6.tga
Force a Texture to be Converted
If for some reason a texture is not being converted, you can force it in two ways.
- Force all textures to be converted by running the application with the -f argument
- Delete the appropriate DDS file in the maps folder and run the application as normal and it will be reconverted.