Metric Panda Games

One pixel at a time.

More Game Asset Preprocessing

Rival Fortress Update #3

Last week I talked about the asset preprocessing pipeline that I’m working on for Rival Fortress: essentially all game and engine assets are preprocessed and packed into a single giant file that is optimized for faster loading during runtime.

This week, while tackling font rendering, I’ve refined the asset packer and added a few more features.

Hot reloading assets

The most useful feature is the ability to re-pack and reload assets while the game is running. The code responsible for this is the same that I talked about in the post about hot-swappable modules. This makes for faster iteration times, especially when working on shaders.

The engine can also detect new asset .PAK files while running and pull them in automatically. I intend to leverage this functionality in the future when I start working on the modding API.

Streamlined asset manifest

I also streamlined the JSON manifest that specifies how game assets should be pre-processed, and it now looks like so:

{
  "fonts":
  [
    {
      "name": "Large",
      "filename": "fonts/test.ttf",
      "size": 32,
      "range_start": 32,
      "range_end": 126
    }
  ],
  "materials":
  [
    {
      "name": "Stone",
      "shaders":
      [
        "shaders/stone.frag",
        "shaders/stone.vert"
      ]
    },
    {
      "name": "HUD",
      "shaders":
      [
        "shaders/hud.frag",
        "shaders/hud.vert"
      ]
    }
  ],
  "meshes":
  [
    "meshes/plane.obj",
    "meshes/cube.obj",
  ],
  "images":
  [
    "images/test.jpg",
    "images/test2.jpg",
  ]
}

I’ve also added Materials and Fonts as asset types, but I’m still weighing pro and cons of different font rendering approaches.

Command line interface

While merging the asset packer (that was previously a separate tool) with the main executable I also added command line argument parsing. Now the game executable can start in different modes depending on the command line arguments. For example if I want to run the asset packer as part of the build chain, I can pass the -t packer argument and the game will behave like a command line tool and won’t initialize all game related sub-systems.