Left 4 Dead 2

Left 4 Dead 2

Not enough ratings
Reduce *.vpk size by lowering *.vtf size
By Artillery Rain
So you browse workshop for some top tier mod. You found them but look at file size... It's huge. Nevermind, you have high end PC.
No? Then maybe i can help you. This guide is about reducing *.vtf size (which usually the largest file in *.vpk) while still maintain acceptable quality.
Note: This guide only talk about model addon (survivors, weapons, panels and signs, concert images... ). If you want to reduce *.wav size, simply reduce bitrate (not sample rate) and set loop point if possible.
   
Award
Favorite
Favorited
Unfavorite
Why you should reduce *.vpk size
- Longer download time.
- Everytime it has a update, you will download it again (if you subscribe).
- It takes huge space in your storage disk.
- Hard to backup them (in case it no longer available anywhere).
- Longer loading time upon loading a map (a map means a chapter in a campaign).
- fps drops / Unstable fps
- Large RAM usage that could crash game.
- The longer you play, the higher chance you will crash. Bigger mod means more frequency.
- Also higher chance to crash when you change addon then load into a map (without exiting game).

What about positive side:
- Better quality for wealthy high end PC only.
- Maintain original quality from former game.
What is *.vtf and *.vmt ?
*.vtf is image file that is used by many asset within game (texture for model, spray, HUD, loading background, ...). A *.vtf can be still or animated image, can be transparent, and have a format.

*.vmt is text file that tell game how to display *.vtf ingame. In here you can set many effects to apply along with texture, includes phong shading, self illuminating, rim light, reflection, add normal map and exponent map, add advanced proxy like CurrentTime, PlayerProximity, PlayerSpeed, Health, AnimatedTexture, BloodyHands, BurnLevel, ...

Normally you don't need to edit *.vmt , but in some extreme case, removing some effect will significantly increase fps (example: custom texture for common infected, it applies normal map, phong shading, envmap, ... you know how much fps you can lose).

Now let's focus on *.vtf . It's size is calculated base on it's resolution, number of frame, mipmaps, and format (and maybe more?). The same applies to *.vtf that act as normal map and exponent map. We need a tool to edit *.vtf and i will go in detail along the way. In this guide i will use VTFEdit , you can get it here : https://nemstools.github.io/pages/VTFLib-Download.html
VTFEdit and it's feature
"VTFEdit is a GUI frontend for the functions contained within VTFLib, an LGPL open source programming library. VTFEdit is a successor to VTFTool and is written by Neil "Jed" Jedrzejewski and Ryan "Nemesis" Gregg.

VTFEdit itself was written solely by Ryan and is a .NET-based GUI tool for the creation and conversion of VTF and VMT files. It is a powerful tool allowing files of various formats to be converted to/from VTF format in all of the Source texture formats.

VTFEdit produces MIP maps and DXTn compressed images using nVidia's nvDXTlib library, offering a wide range of formats and filters.

Other features include the ability to create normal maps from greyscale images, various sharpening filters for MIP Map generation, access to all VTF header flags, a simple tree-based VMT creation system with GCF access, a WAD conversion tool, a batch conversion tool, and a VMT creation wizard."
- https://developer.valvesoftware.com/wiki/VTFEdit
---------------------------------------------------------------------------------------------------

In short, you use VTFEdit to:
- View , toggle flags (or feature or option or whatever it means to you) and save *.vtf .
- Import / Export an image (or images) between *.vtf and many other image file extensions. Supported extensions are:
*.bmp
*.dds
*.gif
*.jpg ; *.jpeg
*.png
*.tga
When import, application will greet you with a setting window like this:


(Hover your pointer over each setting for more info.)
(You only need to work in "General" tab, don't pay attention to other two.)
Once you have explored them all, just close the window for now. Don't worry you will meet it again real soon.
Main article: Use VTFEdit to clamp *.vtf size
Summary:
- Export *.vtf to *.png
- Import *.png into VTFEdit again
- Set those option like in image above, except "resize" section where you can set it to your liking.
- Save the image as *.vtf
-----------------------------------------------------------

Detail:
Before exporting, if you gonna export many *.vtf in a folder, i recommend copying that folder to somewhere with shorter path (a folder on your desktop, or folder directly under your disk, ...).
( Otherwise you can just drag *.vtf into application then click Export. )

Now in VTFEdit, click in Tools menu, then Convert Folder. Yow will see this:


Set input and output folder path, tick "To ..." , set target output extension as *.png from dropbox.
( Note: the field next to it tell app what extension for input, *.* means all extension )
( Ignore Options button for now, it's for converting other extension to *.vtf )

Now click Convert and wait. The larger *.vtf the longer you wait.
When completed, in output folder there will be a bunch of image:


Now you will import them into VTFEdit. Before you ask, no, you don't need Paint or Photoshop or anything, unless you want to edit them.

Route 1:
If those image have same resolution (or if you want them to), you can once again convert them all back to *.vtf . Tools --> Convert Folder , but this time tick "To VTF" , and click Options button to check your setting which will apply to all input file. Finally click Convert.

Route 2:
You can drag and drop each *.png into VTFEdit one by one. Each time you do, the VTF Options window will show up with your latest setting. I will go through important setting, so let's take a look at them again:

.
"General" section:
Normal format usually is DXT1 or BGR888
Alpha format usually is DXT5 or BGRA888
DXT format require less size than BGR so i recommend DXT format. Difference between DXT and BGR shouldn't be too noticeable except close inspect and comparison.

Some effect written in *.vmt may use alpha channel (transparency) from image. If you know that there are no such effect, you can set Alpha format to DXT1 . This will make imported image fully opaque (no alpha channel), and greatly decrease file size.

See also: https://developer.valvesoftware.com/wiki/Valve_Texture_Format

"Resize" section:
You can leave 3 first dropbox as default, but you can explore Sharpen Filter option, it will significantly affect your image.
The other 2 dropbox is very important because it will be image's resolution after importing (if it's lower than current's). You can change them to whatever value you like, but i recommend you reduce them to half, too low value won't look good.

"Mipmaps" section:
You can see mipmaps as levels of detail (LOD) of an image.
See also: https://blog.imaginationtech.com/why-you-really-should-be-using-mipmapping-in-your-graphics-applications/
Disable mipmapping can decrease file size as those mipmaps are stored in *.vtf too.

"Normal Map" section:
Disable this because you're not creating normal map from texture. Even if you are optimizing a normal map, skip this section too because it is already one.

When you are good with your setting, click Ok to import. You will now see the image which will be displayed ingame. See Info tab for file size, resolution, format and more. Save image as *.vtf and you are done.
Breath step
Bring all modified *.vtf to where it was and replace them. Repack *.vpk and test it ingame to see if you're satisfied with optimized texture.
Obviously there is difference, but look at their file size, what would you choose?
.
.
.
.
Hope this guide is helpful to you.
Sorry for guide thumbnail, Steam doesn't allow me to change.
Check out the mod i used for this guide:
Insurgency Sandstorm Honey Badger by ☆麻辣香锅☆

Insurgency FAMAS F1 replace Rifle (M16)

.
Have a nice day.