Rebuilding DLC TFC
This guide will show you how to recook the TFC for your DLC mod. This will compact your TFC file by effectively removing old, outdated, or superceded textures that used to be referenced by no longer are. This will let you ship an optimized TFC file which will reduce mod size, allowing your users to spend less time downloading the mod. You can also use this guide to batch update texture references from a singleplayer DLC TFC to new multiplayer DLC TFC, or vice versa. You would do this because SP and MP DLC cannot load in each other, respectively.
For my Redemption DLC, I had to port textures from the Leviathan Lev004 (Shipwreck) map. There are many textures for this map - hundreds - that only exist in that DLC's TFC. By using MEMNoGui, I was able to batch dump textures with their hashes, and then rebuild the TFC for my mod by doing a same-texture replace (not actually modifying, but simply repointing textures to my TFC). Doing it manually would have taken tens of hours of long, boring labor.
These are the tools you will need to follow this guide.
Table of Contents
- TFCs in Mass Effect 2 and 3
- The process
- Setting up the recooking environment
- Dumping referenced textures
- Recooking the TFC
Make sure you have complete backups of your data as this process is not irreversable.
TFCs in Mass Effect 2 and 3
TFC files are used in Mass Effect 2 and 3. They are used to store shared textures, which make up almost all of the textures in the game. Things such as GUI textures are typically not shared and are baked directly into game package files. The rest are inserted into TFC files, and are referenced from package files via offsets. This is why you cannot replace files after texture mods have been installed, as the offsets will no longer be valid.
Mass Effect does not use TFC files, instead baking textures in a more complicated fashion, that I won't be covering here.
As you develop your mod you may choose to change a texture. Due to how the current modding tools are made, new textures are simply appended and the TFC is not rebuilt. This means that data that was once pointed to no longer is and will take up extra space for something that does nothing. This is not desirable as it means your end users take up more space for installing, and you spend more time uploading your mod.
During game compilation in Unreal Engine 3, this is all precalculated in a process known as cooking. Some users in the scene also call this baking. During the initial compilation of Mass Effect 2 and 3, all package files were generated, and in a subsequent pass all pointers to textures were updated to point to a specific position in a TFC file for the same texture reference. This is also how texture mods are installed, and why a texture map (also known as a tree) must be built before texture modding - all texture references must be known, so when a texture is updated, all pointers to the texture being replaced can be updated.
This is why texture data is simply appended and repointed to, rather than recompacting the TFC file - updating hundreds or thousands of files takes a long time and uses a large amount of system resources, which is not desirable for most modders. However, doing this before shipping your mod will make sure your end users only have the data they need and not extra garbage data.
Before we delve into this guide, here is how the process will look:
- Set up the recooking environment
- Dump referenced textures for recooking
- Recook TFC
Setting up the recooking environment
To simplify and make things easier, we will need to clone an installation of Mass Effect 2 or 3. We are not going to boot this installation. To start, we need to copy an entire vanilla installation of Mass Effect 2/3 to a new directory. After this is complete, we start to hollow it out by deleting all top level folders except for Binaries and BIOGame. The GDFBinary can be left, it doesn't matter.
Next we will go into the Cooked directory and delete everything except the TFC files. This path is BioGame/CookedPC (ME2) or BIOGame/CookedPCConsole (ME3).
Then we need to hollow out the DLC directory. In the below picture, I have my mod, MPMapPack (Redemption). This is a example of recooking the TFC, while at the same time porting textures between SP/MP DLC. If you have files that are based on DLC even in the same game mode (and that DLC is not required) you will want to do this as well as those referenced textures will be packed into your DLC so users won't require that DLC for the textures.
In all DLC folders except your mod folder(s), you should delete everything except the .tfc files. This will ensure we aren't adding data that is not relevant to our mod to our TFC.
Finally, to finish setting up our environment, we need to point MEM to use this hollow installation and build a texture map for it. Opening MEM (GUI), go to your game (in this example, ME3), and go to Change Game Path, and choose your executable for the hollowed out installation.
You should also remove any existing texture map you have, if you've installed textures through ALOT Installer, MEUITM, or MEM before. You will need to do this every time you want to rebuild the TFC as a new texture map will need to be created. Since our game is hollowed out this will be quick for rebuilding.
We then need to open Texture Manager.
This will cause a texture scan to take place.
You may get an error here (WARNING: Some errors have occured!), it is safe to ignore - it is because some files it expects are not present, but it won't harm anything. You might also get a text editor popup with text showing scan issues - you will want to make sure you avoid broken textures at all costs, as they are not really possible to recover from without significant time investment. As such, keep checkpoints of your work, as losing a non-broken textures copy then advancing work on a broken texture will be significantly more difficult to fix. Broken textures are textures that point to invalid data in a TFC, and will be fully black.
Once the scan is complete, you should see a list of packages on the left. At this point we have set up our environment for recooking a TFC.
Dumping referenced textures
Assuming you don't already have all the textures neatly organized in a folder, you will need to dump referenced textures in your TFC. This should not incur a loss of quality. We will need to use MEMNoGui for this, so fire up your command prompt and navigate to the directory where you have MassEffectModderNoGui.exe.
I know some users are not very comfortable with command line, so I'll try to be a bit more verbose in this section. You can open a command prompt from any location in windows by right clicking an empty space in a folder with nothing selected (this is important!) while holding shift. Depending on the version of Windows you have, you will get Open Command Prompt window here or Open Powershell window here. Select this.
For ease of use, if you get the Powershell option, the first command I issue is cmd, which puts me into cmd and not Powershell. Since I am not using any powershell features, I do not want to have to deal with some of its changes to the way the shell works. Powershell is great for scripting things and administrative tasks, but we aren't doing that here.
You can use Tab to autocomplete items in cmd. In this empty folder (except for MassEffectModderNoGui), I can simply press tab until the selected item is shown (MassEffectModderNoGui.exe). Learning how and when to use autocomplete will make your life in cmd suck a lot less.
Issuing just MassEffectModderNoGui.exe with no parameters will have it output syntax usage. The syntax for different commands changes over time as new features are implemented - your output might look different than this one.
For dumping textures, we will use a specific one of these: -extract-all-dds.
We will need to specify the command, the game id, the output directory, and optionally a texture file cache reference filter - this last parameter is important, as we do not want to add basegame textures into our TFC. The only ones we want are the ones currently in our TFC, so we can compact it. Our TFC should only contain textures that are not shared outside of our DLC. If you are porting content between MP/SP, you will run this command multiple times, each time changing the filter so it dumps textures from other DLC for references that use this name. The filter is the texture file cache name, like Textures_DLC_CON_MPMapPack. It always follows Textures_[DLC folder name]. It does not include the .tfc on the end.
The output directory MUST be quoted if it contains spaces. When using autocomplete, you can add a \ on the end to let it start autocompleting the next subdirectory, even if its after a ".
This command may take some time to complete. There is no output on screen while this is running, so just wait for it to finish. You can see it doing stuff if you go into the output directory you specified.
Ensure these are unique textures in this folder, and not common ones like the texture for ammoboxes (note that some ammobox textures are unique to the DLC - Leviathan DLC, for example, has a few unique ones).
Once this is done, we are almost ready to rebuild our TFC. At this point MAKE SURE YOU HAVE A BACKUP OF YOUR MOD, because if you don't and anything goes wrong, your files may not be recoverable.
Recooking the TFC
To recook the TFC, we will be directly applying the dds files from the folder to the game. This bypasses MEM's vanilla game database as you may totally new textures, so we will not be creating a MEM file for installation. Using a special command in the command line version of MEM, we can set the updated textures to reference a texture file cache name of our choosing. MEM will automatically add the name for you if it isn't already present.
The command we need to use to install and rebuild the TFC is eloquently named -dlc-mod-for-mgamerz.
This command takes the game ID (2 or 3), the path to extracted folder we made (in this example, dumpedtextures), and the exact TFC name string. Optionally it can accept a 16 byte (as hex) GUID if you want to use your own, otherwise a random one is created. It can also take the -verify parameter, which detects installed textures to make sure they match what we just installed, so I recommend using this.
Before your run this command you must delete your existing TFC file - otherwise it will attempt to append to it instead. The file will be recreated.
Running this command will build a new TFC file for you. It may take some time as cooking is a pretty laborious process.
It will be placed in the folder specified after the Textures_ name. You can follow this guide again to rebuild your TFC as necessary.
Was this guide helpful?
If you found compacting TFCs this way helpful, please give a star to Aquadran's MEM repositories on GitHub to show that you appreciate the work he does on MEM. If the guide helped you through the process, feel free to share it with others to help them do the same.