This is a tutorial on how to mass resize the textures of multiple vehicles at once.
It’s split into 6 steps.
Notes: This tutorial shouldn’t be used for very small .ytd
as they already have compact textures and any further downsizing will most likely result in them looking washed out. However it’s going to work fine for any *light*
and *emissive*
textures as they are going to be strategically skipped so they don’t cause issues. Also it will skip *carbon*
, *Carbon*
and *script_rt*
textures for similar reasons.
This method will not work if you have repeating texture files (e.g. you have texture.ytd
in car1
and texture.ytd
in car2
).
Make sure you’ve closed all programs which have opened any programs that look inside the working folders or their subfolders before executing any of the code snippets.
As a side effect it would turn the textures that are below 4x4 in resolution to 4x4. Not aware of any bugs that result of this, as textures are intended to be at least 4x4.
0. Dependencies (and Downloads):
- .NET 6 Runtime x64
- OpenIV
- Folder2YTD
- ImageMagick
- Other dependencies needed to install the apps
0.5 Backup
Backup whatever cars you’re going to modify.
1. Create an appropriate file structure
This step depends on the way that cars are ordered in your server. This step will cover the 2 most common ways.
First, make a folder in c:
called vehicles
and move the car resource into c:\vehicles\
And put your cars in it.
The 2 possibilities are:
1.1 The cars are in a single carpack resource
This means that the file structure you’re dealing with should look something like this
vehicles
└───cars
├───carcols.meta
├───carvariations.meta
├───fxmanifest.lua
├───handling.meta
├───vehiclelayouts.meta
├───vehicles.meta
│
└───stream
├─────car1.ydd
├─────car1.yft
├─────car1.ytd
├─────car2.ydd
├─────car2.yft
├─────car2.ytd
├─────car3.ydd
├─────car3.yft
└─────car3.ytd
1.2 The cars are in different resources
This means that the resource structure you’re dealing with should look something like this
vehicles
└───car1
├───carcols.meta
├───carvariations.meta
├───fxmanifest.lua
├───handling.meta
├───vehiclelayouts.meta
├───vehicles.meta
├───vehicle_names.lua
│
├───stream
│ ├────car1.ydd
│ ├────car1.yft
│ └────car1.ytd
car2
├───carcols.meta
├───carvariations.meta
├───fxmanifest.lua
├───handling.meta
├───vehiclelayouts.meta
├───vehicles.meta
├───vehicle_names.lua
│
├──stream
│ ├────car2.ydd
│ ├────car2.yft
│ └────car2.ytd
car3
├───carcols.meta
├───carvariations.meta
├───fxmanifest.lua
├───handling.meta
├───vehiclelayouts.meta
├───vehicles.meta
├───vehicle_names.lua
│
└───stream
├────car3.ydd
├────car3.yft
└────car3.ytd
The solution is the same - open cmd
as admin execute the following in the c:
cd c:\vehicles\
mkdir work
cd c:\vehicles\work
mkdir unedited
cd c:\
mkdir temp
move c:\vehicles\work c:\temp\work
for /r "c:\vehicles\" %i in (*.ytd) do copy /y "%i" "c:\temp\work\unedited\%~nxi"
move c:\temp\work c:\vehicles\work
rmdir c:\temp
cd c:\vehicles\work
mkdir edited
cd c:\vehicles\
cd c:\vehicles\work
and press enter whenever it reaches the final command
In all cases this should result in the work
folder being something similar to this:
work
├──unedited
│ ├────────car1.ytd
│ ├────────car2.ytd
│ └────────car3.ytd
└──edited
Now it’s the time to remove all very little sized .ytd
’s (my rule of thumb is below 2MB) and the ones you won’t want to optimize from the work
folder.
and keep the cmd
session open, we’ll need it later.
All steps from now on until 5. including are now independant of structure of car resource.
2. Create the appropriate folders for editing
Now since our image software of choice can’t work with raw .ytd files we need to export the textures, but first, let’s make the folders where we’ll do it.
in the cmd session execute
cd c:\vehicles\work\unedited\
for %i in (*.ytd) do md "c:\vehicles\work\unedited\%~ni"
for %i in (*.ytd) do md "c:\vehicles\work\edited\%~ni"
and press enter whenever it reaches the final command
This should create a car1
, car2
and car3
folder in the folders unedited
and edited
.
3. Export the textures
Open OpenIV>Grand Theft Auto V>Windows
, go to file>edit mode
and click yes, now go to File>Open folder...
and paste this in the address bar
c:\vehicles\work\unedited
and click select folder.
There should be folders and .ytd
files, if it errors or the .ytd
files don’t show up close OpenIV and repeat the step.
In this case we’re going to export for car1, but you can use this method for your own .ytd
.
Click on car1.ytd>export all textures>DirectDraw Surface (*.dds)
and paste in the address bar c:\vehicles\work\unedited
then select car1
and close the OpenIV texture visualiser.
Repeat for the other .ytd
In your case you should do it for every .ytd
. By the end you should have lots of .dds
files in all of the folders in unedited
.
Finally, close OpenIV
Here comes the fun part.
4. Convert the textures
In the cmd
session execute:
cd c:\vehicles\work\unedited
for /D %i in (*) do (cd c:\vehicles\work\unedited\%~ni & magick mogrify -resize 50% -verbose -quality 100 -path c:\vehicles\work\edited\%~ni *.dds & replace c:\vehicles\work\unedited\%~ni\*emissive*.dds c:\vehicles\work\edited\%~ni\ /s & replace c:\vehicles\work\unedited\%~ni\*light*.dds c:\vehicles\work\edited\%~ni\ /s & replace c:\vehicles\work\unedited\%~ni\*carbon*.dds c:\vehicles\work\edited\%~ni\ /s & replace c:\vehicles\work\unedited\%~ni\*script_rt*.dds c:\vehicles\work\edited\%~ni\ /s & replace c:\vehicles\work\unedited\%~ni\*Carbon*.dds c:\vehicles\work\edited\%~ni\ /s)
cd c:\vehicles\work\edited
for /D %i in (*) do (cd c:\vehicles\work\edited\%~ni & magick mogrify -resize 4x4^< -verbose -quality 100 -path c:\vehicles\work\edited\%~ni *.dds)
cd c:\vehicles\work\
and press enter whenever it reaches the final command
Commands ARE seperated by “&”, I tried to line break via ^
, but it doesn’t work.
command 1 changes directory to the unedited
folder
command 2 traverses over the folders which directly cointain the .dds
files in the unedited
folder.
command 3 converts the images as needed and outputs them in their respective folders in the edited
folder.
command 4 through 8 replace the textures which sometimes get screwed up when optimized.
command 9 just moves your working directory back to work
command 10 changes directory to the edited
folder
command 11 traverses over the folders in the edited
folder
command 12 Resizes all images below 4x4 to 4x4, as textures that were previously 4x4 get bugged once below that
5. Import the textures
run Folder2YTD.exe
Select Quality>Best Quality
Select Detect Transparency>By pixels
Select Format Output>GTA V (.YTD)
Slide the Power of Two threshold
to 0
Generate mipmaps
should be on, as we’re already compressing the textures 4x times.
Select Show result upon converting
Click on
Paste C:\vehicles\work\edited
in the address bar.
Select all of the folders and click Convert
.
When it’s done (you’ll get a message box pop up with a summary) - close Folder2YTD.exe
Almost done
6. Move the textures to their respective folders
For carpacks this is easy.
Move all the .ytd
files from work/edited
to cars/stream/
. And click yes for all
when it prompts you for replacement of files.
Either that or use the solution for the individual resources:
move c:\vehicles\work c:\work
cd c:\vehicles
for /R %i in (*.ytd) do replace c:\work\edited\%~nxi c:\vehicles\ /s
move c:\work c:\vehicles\work
and press enter whenever it reaches the final command
Try out the cars, if they have no issues - remove the work
folder and use your car resource.
Enjoy
Edit: Changed lights to light and fixed emissive typo in snippet
Edit 2: Added *script_rt*
, *carbon*
and *Carbon*
to Step 4
Edit 3: Changed threshold in Folder2YTD instructions
Edit 4: Fixed the issue with color texture resizing and fixed step 4 so it doesn’t crash by restructuring the folders. All of the steps were changed to fit. Changed step 1 to not create directories on C: directly
TO DO:
Automate Step 2 so it doesn’t require human input
Eventually turn this into a .bat
script once step 2 and 5 can be done via CLI.
Make it so textures below a certain size (e.g. below 128x128) don’t get compressed, should be possible via MediaInfo.