PVG
8. Asset Management — Program Video Games

8. Asset Management

Every character played, every scene explored, every piece of music heard in a game, is made by taking an asset from disk and using it in the engine.

The Fractal Code Cycle Applied to Asset System

Recall our fundamental pattern:

Input → Processing → Output

For our event system:

  • Input: Asset data from the disk
  • Processing: Depends on asset type
  • Output: For graphics, create some GPU resource and upload the data to VRAM. For sound, simply load the data into RAM.

As explained below, all assets will be loaded up-front until the scene system is fully fleshed out and working.

What Are Asset Systems Good For?

There are many types of assets, so let's go over the major ones here:

  • Model: A collection of meshes, textures, and materials.
  • Mesh: 3D Geometry made from triangles, used to represent physical objects.
  • Texture: An image, usually overlaid onto meshes in 3D. These give the geometry texture. Usually large in file size.
  • Material: A set of textures and rendering properties. Materials can be applied to meshes to give them wildly different looks.
  • Sound Effects: Audio files, usually small in file size.
  • Music: Audio files, usually very large in file size.

Asset System in the System Stack

The Asset System sits in the base layer as everything that requires a visual or audio component must draw from it.

Design Considerations

Depending on the type of game being made and the target platform specifications, asset systems may vary wildly.

For example, a large open-world game such as Oblivion may want to have an asset streaming system, where as the player moves around the open world, assets are loaded and unloaded dynamically.

For an RPG like this one, there will be distinct scenes. That means any assets not required for the current scene can be unloaded, and vice versa.

For now, though, getting asset loading working in a simple way will do just fine.

The Big Idea

The asset system must be able to provide assets at the time they are required with little latency.

To that end, a simple Map interface with preloaded assets is used per each asset type - see the reference implementation for more details.