Monday, August 6, 2012

Asset management–roll ‘em up

An “asset” is a relatively large chunk of data used by a game. Examples include sound effects, textures, meshes, music and movies. While it’s important to have a runtime resource management system to avoid duplicate assets residing in memory, it’s also important to have a way to track runtime assets during development. Games tend to have a lot of assets.

One way to ease asset tracking is to reduce the number of assets by rolling some up together. In a 3D game, it’s often necessary to keep individual texture assets separate as they are reused across different meshes. In a 3D game, textures often describe surface materials but rarely do they describe object contours (that’s left to mesh geometry).

In a 2D game, however, textures usually define both surface material *and* contour, and as such there’s less likelihood that textures will be reused across different meshes. One example is sprite sheets. Some characters are defined by sprite sheets that span multiple textures. There is never going to be a case where these sprite-sheet textures have meaning outside the shape/material they represent. As a result, our runtime asset representing the visual characteristics of a character is a single asset: an “animation” asset. While we can “nest” animations, the exposed assets (file-wise) never drop below “animation asset” level (for example, the runtime files visually representing a guy holding a sword are a “guy” and “sword” animation asset). Animation data, mesh data and sprite-sheet textures are generated/rolled into one asset on export from our animation tool.

Similarly, larger backgrounds may span multiple textures at runtime, and thus there is no reason for the runtime to need these textures to be floating around separately. Thus, just like character assets, a background asset accumulates multiple textures on background export and all reside in a single asset file.

Reducing the asset count by rolling up “atomic” asset groups is good practice, both for runtime and for tools.