“Flexible”? How?

Why

Developers might want the assets in their game to not be available and readable like a file that you hop on the game’s directory and yank, so game engines commonly pack assets into larger, commonly encoded, files. There are more reasons for this, however. For instance, what do you think is faster:

  • Loading 10,000 tiny loose files or
  • Loading one big file with the same total size as the tiny loose ones?

Loading the larger, packed file is faster. This is because most of the time spent on loading files comes from reading file metadata, and seeking the requested file. (Your system knows where its files are, but it still has to go get them!)

Think of it this way, would you rather travel to the fridge twice with a cup to fill a bowl, or travel many more times because you wanted to use a spoon to fill the bowl instead? Same result, a lot slower process.

With this in mind, it’s definitely a good and valid decision to support packed asset files in the engine, such as .pak, .pck, .asset, etc. The developer wants to package the assets into some proprietary or encrypted format of their own? That’s okay, they will just have to implement the I/O for it themselves! The VFS (Virtual Filesystem) will handle the rest.

Now comes the “Flexible” part. Let’s say that I, the game developer using the engine, want to ship the game’s assets as one big data.pak, what will the modders do now? Will they have to patch the data.pak with their modifications?

Doesn’t sound too efficient though, does it?

This is where the VFS saves the day: The VFS allows modders to use “loose files” as needed for easier development and/or sharing.

How does it do that?

How

We finally get to the How. The VFS can treat a file exactly like a folder. Think about it, the packed file is just a different flavored container for all the game’s assets, just like a folder. The VFS reads and parses the file, and then indexes all its contents as if it were a folder.

Now let’s go back to the modding a packed game scenario: Do the modders have to patch the data.pak? Nope! As long as you know the structure of the assets, you shouldn’t need to go down the packed route. Be a happy folder-using modder, thanks to VFS.

Goodbye

One more thing that is worth remembering: it’s typical for loose files to be mounted with higher priority (so before) than packed files. The same way that the game’s assets are always last in the PS (Priority Stack), packed files will be checked after loose files by default.

Longer post eh? Stay safe!