Left 4 Dead 2

Left 4 Dead 2

79 ratings
How To Optimize Your Mods
By Shao
A very simple and straight forward way to stop your game from crashing via excessive use of memory, because the average mod here tends to be completely at uncompressed and absurd texture resolutions that are beyond useful with no mipmap support causing your eyes to bleed with oversharpness.

L4D2 is a 32-bit game, meaning that going beyond 3.5GB you'll crash regardless of anything period. Let's get to it.

At the end of this guide I am willing to answer questions, but my knowledge is limited so don't expect miracles!

   
Award
Favorite
Favorited
Unfavorite
Programs You'll Need
Have at reach any type of image editing program, I use GIMP[www.gimp.org]. Ignore this if you prefer using VTFEdit resizing or aren't going to edit alpha channels.

Have L4D2 Authoring Tools to recompile into VPK's
Have GCFScape
Have VTFEdit
Optional; Irfanview[www.irfanview.com] if you have to handle image bulks for RNG mods and such. (THIS PROGRAM DOES NOT HANDLE ALPHA CHANNELS WELL.)

You can download tools from here https://valvedev.info/

People that use Crowbar can probably do the same things as this guide will tell, however you probably wouldn't have to be told any of this if you work with Goldsrc or Source Engine and know the limitation of those engines.
How To Do It
  • Get your file from the workshop folder in "steamapps\common\Left 4 Dead 2\left4dead2\addons\workshop" which can be identified by it's ID from the link you subscribe to or the picture previews themselves.



  • After you've installed GCFScape and VTFEdit, should the proper file types be associated and make workflow a lot easier by simply double clicking .vpk / .vmt / .vtf to open them.

  • Finding your mod, you will extract it's content with GCFScape somewhere you are comfortable with then find the textures in their respective files.



  • Now having found your texture somewhere in the extracted file, open it up with VTFedit. You have to be careful and make sure to check in the view menu if the texture has an alpha channel, if yes then export as .TGA, unless you find a texture with an useless alpha channel (Completely white channel), then BMP is recommended, you can usually tell right away if one could have an alpha channel if the texture format is DXT5 or BGRA8888. Once exported you will resize it's resolution if the texture is absurdly big to something more reasonable, depending on the software support you may or may not be able to which is where GIMP steps in or you re-import with VTFedit Resize feature although it's important that we go over what Alpha Channels are used for first.

    Alpha Channels are used for two things; first to control transparency on textures such as blood to not look like it was splat on a sheet of paper then placed on the wall, second they serve as a way to store greyscale images for reflections details by default for $bumpmap (There is no settings called $normalmapalphaphongmask, it just works by default), alternatively instead of using the normals alpha you can also use $basemapalphaphongmask in .vmt which will use the alpha's of the diffuse instead, but still not save on the original bumpmaps which uses memory.

    $basemapalphaphongmask does not require a normal map but if you need a placeholder, using something like "dev/dev_normal" can be a good way to save on memory since the file is a small simple existing asset while relying on the more detailed alpha of the diffuse. Remember, if you still use an original detailed sizeable bumpmap, it will not save on memory because the every channels are still loaded no matter and therefor $basemapalphaphongmask is not ideal and you should let the default behavior bumpmap do it's thing with a proper alpha in the normal while the $basetexture should simply be DXT1 with no alpha.

    $basealphaenvmapmask / $normalmapalphaenvmask should also be used to give finer details to the specular maps of env_Map rather than having looking like it got dipped into oil, this however requires the greyscale image to be detailed such as the weapon texture itself. Again preferably the normal map alpha should be used while the $basetexture remain as DXT1 with no alpha to save on memory.

    $basealphaenvmapmask / $basemapalphaphongmask in most cases are only practical if you rely on simple bumpmaps such as "dev/dev_normal" or have to play around with settings that conflicts the latter of normals. Note that $basealphaenvmapmask works in reverse and therefor blacks/transparent area's are going to be reflective while the whites/opaque are not.



  • With your image editing software start evaluating sizes, 2048x2048 for a small object is not ideal and should be 1024x1024, even 512x512 can work in most situations, per say bigger objects at best should be 2048x2048, 4096x4096 is an absolute memory sink that will do no good to your in-game experience unless the object is really really large and only uses a singular texture, it is VERY rare that one object benefits from such thing because in most situations large objects share multiple textures instead. Perspective is also essential and if you're working with the texture of a weapon, large helps keeping details in but it's important to judge how size eventually doesn't matter, especially if your weapon has multiple textures shared to it.

    Be warned, resolutions can vary and should always be multiplied by accordingly, if ratio is not respected things will go wrong.

    Once the texture adjusted, you will re-import it through VTFedit and choose either DXT1 if there's no alpha channel or DXT5 if there's one. (It's important that the VTF version that you compile the file with is 7.4, 7.5 is not supported by L4D2, this setting can be found in the advanced tab when importing.)



  • Uncompressed files should only be used for objects (often big) that require lot of details with normal maps, compression tends to create artifacts in gradients which in turn can make the reflection ugly, BGRA8888 if there is an alpha and BGR888 if there is none, remember that this is mostly ideal for normal maps or fine gradients in basetextures.

    As a reminder if your object doesn't need much detail the small "dev/dev_normal" is general the way to go, much of the other phong details can be achieved via $basemapalphaphongmask so that you don't need an absurdly large uncompressed normal for say a rock or vehicle, you can rely on the $basetexture alpha which safes greatly on filesize.

    If DXT5 compression introduces artifacts to your normal map reflection details, reduce the bumpmap size by half, for example 2048x2048 to 1024x1024, if 1024x1024 then 512x512 and so on until around 256x256 since size will eventually have diminishing returns and details will be impossible at a certain smaller size.

    Then with the said smaller bumpmap use BGRA8888, this will result in having convincing details while avoiding compression artifacts at the same relative size of the bigger DXT5 file. Compression is usually much harder to notice on basetextures so DXT1 should remain as the better choice for filesize unless you really need the alpha in the basemap, this tactic can still work with BGR888 but that should only be done if artifacting is really noticeable on your texture after vtf compression.



  • Following the Format is Mipmaps, this is what allows the game to downscale and prevent oversharpness. Box and Sharpen Soft are ideal for just about anything. This does increase the file size slightly but allow for better visual quality in return.



  • Proceeding to generate and that everything went well, tick the appropriate flags (Trilinear, Anisotropic and Normal Map if it's a Normal Map.) then save the newly made .vtf where the original was by overwriting it then rinse and repeat if necessary for other textures.



  • Having to repack the root folder, all you'll need to do is drag and drop into the vpk.exe of L4D2 Authoring Tools location in "steamapps\common\Left 4 Dead 2\bin". Ideally you'd want a shortcut on your desktop so that the file it'll spew be there too.


And that's it, you've optimized your mods so that you can use more without having to deal with random or instant crashes because some custom map was taking so much memory among all your others mods. Drop the new .vpk into your "steamapps\common\Left 4 Dead 2\left4dead2\addons" and unsub from the workshop mod you've modified because you don't want to have it twice.
Pro Tips
  • You can select multiple files while importing for the RNG mods which will integrate the textures in order frame by frame, this is required to adjust those.

  • You can extract all frames of a texture by selecting "Export All", you'd want to ideal use that for RNG mods, will be labelled properly as well for easier bulk management.

  • VTFedit has multiple channel options as well as mask and tile modes to inspect and know what the texture is all about.

  • Only need a specific texture in a channel? You can copy right from the image preview itself with right click.

  • Renaming the root folder will automatically rename the VPK on it's compile.

  • Have a phong that's too bright? $phongboost is a float therefor you can fine tune it with decimals such as 0.5 for sweet spots.

  • .TGA should always be preferred when handling alpha channels. Using .BMP will remove them while .PNG will not properly import/export and .JPG has quality loss therefor is the worst possible option.

    My recommendation would be that something matte should not have any boost, while slightly metallic should get 1 then finally 2 for extremely reflective objects. Phongboost is a really sensitive setting, going higher than those numbers will hardly do anything more even if you can use them.

    Reflections can have more colorful details based on the diffuse but it requires $phongalbedotint to be enabled which requires a phongexponenttexture to use the green channel from.

    https://developer.valvesoftware.com/wiki/$phong for more info.

  • Have a specular reflection that's too obvious? $envmaptint is an RGB matrix and therefor also can take on decimals for fine tuning, such as "$envmaptint [0.005 0.005 0.005]". This one is a personal hot take for me since vanilla weapons have an absurd setting that makes them look very ugly, $env_map is used relatively without much thought and can really ruin fine details in the phong when not balanced.

    As a general rule of thumb, things that shouldn't reflect much at all can do with "$envmaptint [0.001 0.001 0.001]".

    If your object is about as reflective as chrome or lens "$envmaptint [0.01 0.01 0.01]" will be noticeable enough without being too distracting when the env_map changes.

    Finally beyond that, "$envmaptint [0.1 0.1 0.1]" or higher should be used for static objects in a certain setting because you'll end up with objects that glow in the dark and very noticeable env_map changes.

    https://developer.valvesoftware.com/wiki/$envmap for more info.
22 Comments
Tac_L1bra 29 Oct, 2023 @ 9:22pm 
Ohh ok, noted, thanks mate
Shao  [author] 29 Oct, 2023 @ 9:15pm 
Not that I have noticed it ever being ticked, I checked a few and never saw it ticked. Might be the last person who used it did that.
Tac_L1bra 29 Oct, 2023 @ 2:12am 
Is the "Auto Create VMT File" always ticked by default? I had like about 3 of them from the same file names after I reduced the resolution of the image
Shao  [author] 2 Sep, 2023 @ 3:58pm 
You can get away with smaller normal and exponent if you make them uncompressed. Compression will introduce very noticeable compression artifact in the highlights so not recommended for large objects. If your object is rather small, compression won't be that bad.
rixzuuPH 30 Aug, 2023 @ 9:42pm 
is it also necessary to resize the normals and exponent vtf files? they're also absurdly huge like in 2048 or 4096
⎛⎝goodusername12345⎠⎞ 24 Apr, 2023 @ 7:25pm 
Mipmaps will work fine (I remember them working during my testing) and so should frames as the tool to create ATI2 (and maybe also ATI1) VTF files will most likely just be a modified version of either Vtex or VTFEdit.
Shao  [author] 24 Apr, 2023 @ 1:03pm 
If it can replicate most of VTF features like Mipmaps and frames while reducing file size. I can see it being useful.
⎛⎝goodusername12345⎠⎞ 23 Apr, 2023 @ 12:32pm 
If I ever get around to it I would love to get a functioning tool out in the public capable of creating ATI2 compressed textures for the Source engine.
⎛⎝goodusername12345⎠⎞ 23 Apr, 2023 @ 12:30pm 
It might actually be possible to use ATI2 (also known as BC5) compression for normal maps the only downside is ATI2 cannot hold a alpha channel, oh and there is also the downside that there are 0 public tools that can create them for Source. I actually in the past almost finished fully confirming whether or not Source can actually use ATI2 properly or not but then I got very very sidetracked and haven't gone back to it since although a friend who was helping me with testing said they are confident that ATI2 works in Source based on what they witnessed during testing.
Supreme Leader 4 Aug, 2022 @ 9:13pm 
Sorry if I'm come out confusing, I was only recompress some mods for my personal use and still haven't fully tell which 'map' is which.

So there's like 3 or 4 'map' type of file (yellow, blue, black&white) in those mod, I was asking you that if I'm resizing one of them without doing the same to others, does it make the mod broken?