FIT CTU

Adam Vesecký

NI-APH
Lecture 3

Assets

Introduction to Assets

What are assets?

Everything that is specific to the game (and not to the engine).

Any piece of data which is in a format that can be used by the game engine.

All media elements that are presented to the player and protected by copyright.

What are assets

  • many games are very similar in their mechanics, yet the assets are different
Super Mario

Super Mario (1985)

Dangerous Dave

Dangerous Dave (1988)

World of Warcraft

World of Warcraft (2004)

Order and Chaos 2

Order and Chaos 2 (2015)

Assets

Binary assets

Binary data

Bytecode assets

Bytecode

Text assets

Text files

Hybrid assets

Hybrid files

Assets
Assets diagram

Medias

NES cartridge
NES cartridge
8kB - 1MB
Super Mario
GameBoy cartridge
Game Boy cartridge
256 kB - 8 MB
Pokémon Yellow
Floppy disk
Floppy Disk
1.44 MB
Duke Nukem 1
Compact Disk
CD
700 MB
Half-Life
DVD disk
DVD
4.7 GB - 8.5 GB
GTA San Andreas
Bluray disk
Blu-ray
25 GB - 50 GB
Witcher 3
HDD
HDD + DLC
Any size
Call of Duty: Warzone
Super Mario took less space than the actual screenshot of it!

Size of game assets

Assets size in games

Asset Types

Sounds

  • AIFF, WAV, MP3, OGG

Images / Textures

  • PNG, JPG, TGA, SVG, EXR

Video

  • MP4, MKV, AVI, MOV, MPG, WEBM

3D Models

  • FBX, BLEND, DAE, 3DS, X3D

Game Data

  • ZIP, XML, JSON, CFG, BIN,...

Levels, Maps

  • CAS, DAT, RPF, TIGER, WAD

Scripts

  • JS, LUA, PY, CS
HEX data

Resource Manager

Resource Manager

Provides access to all resources (~assets)

  • meshes, materials, shaders, animations, textures, clips, levels
  • Resource Cache - used for faster access

Manages lifetime of each resource

  • most managers maintain some kind of registry

Ensures that only one copy of each resource exists in memory

  • resource GUID - usually path to the file, guaranteed to be unique

Loads required resources and unloads those no longer needed

  • loading is simpler than unloading

Handles streaming

  • in case of open worlds

Resource Manager

Resource Manager

Example: Godot Engine Resource Loader

1 RES ResourceLoader::_load(const String &p_path, const String &p_original_path,
2 const String &p_type_hint, bool p_no_cache, Error *r_error, bool p_use_sub_threads,
3 float *r_progress) {
4 bool found = false;
5
6 // Try all loaders and pick the first match for the type hint
7 for (int i = 0; i < loader_count; i++) {
8 if (!loader[i]->recognize_path(p_path, p_type_hint)) {
9 continue;
10 }
11 found = true;
12 RES res = loader[i]->load(p_path, p_original_path != String() ?
13 p_original_path : p_path, r_error, p_use_sub_threads, r_progress, p_no_cache);
14 if (res.is_null()) {
15 continue;
16 }
17
18 return res;
19 }
20
21 ERR_FAIL_COND_V_MSG(found, RES(), vformat("Failed loading resource: %s.", p_path));
22 }

Data loading

Level loading

  • only one game chunk is loaded at a time
  • requires a loading screen or a pre-rendered cutscene
  • used in Tomb Raider, Doom, Quake,...

Air locks

  • air lock is a small scene (room, hall)
  • when the player enters the area from which can't see the previous one, the next scene is loaded
  • used in Half-Life, Portal (partially)

World streams

  • the engine unloads regions too far away and loads new regions the player is heading to
  • 2D uses lazy loading
  • 3D uses LOD system - chunks are loaded at a variable granularity
  • used in GTA, WoW, Arma, and many 2D scrollers

Example: Level Loading

Shadow of the Tomb Raider (2018)

Wolfenstein II: The New Colossus (2018), cutscene

Example: Air Lock

Portal (2007)

Hellblade: Senua's Sacrifice (2017)

Example: World Streaming

World of Warcraft (2004)

Jazz Jackrabbit 2 (1998)

Multimedia assets

Music Formats

AIFF

  • Audio Interchange File Format
  • uncompressed pulse-code modulation
  • may contain loops and samples

WAV

  • linear pulse-code modulation
  • used when time involved in compressing is a concern (short sounds)

MP3

  • MPEG-1 Audio Layer III
  • lossy data-compression

OGG

  • more advanced and a bit smaller in size than MP3
  • open-source (in sharp contrast with MP3)
Music assets

Image Formats

JPEG

  • Joint Photographic Experts Group
  • used for digital photography
  • doesn't support alpha channel
  • don't use it for pixel-art

PNG

  • Portable Network Graphics
  • good results for simple images (not real pictures)

TGA

  • Truevision TGA
  • favorite format for textures

SVG

  • Scalable Vector Graphics
  • format for vector images
JPG image
PNG image
SVG image

Videos and Cutscenes

  • one of the most progressive properties of a game
  • a) fully progressive - video, in-game cutscene
  • b) partially progressive - i.e. custom skin of the avatar in the scene
  • c) partially emergent - the player can walk around but can't control the scene
  • d) fully emergent - generated cutscene
  • 1980's - in-game cutscenes
  • 1990's - pre-rendered video cutscenes
  • 2000's - in-game cutscenes
  • 2010's - pre-rendered video cutscenes
  • 2020's - in-game cutscenes
Warcraft cutsceneHellblade cutscene

Videos and Cutscenes

Another World cutscene

Another World, in-game

Wolfenstein New Collosus cutscene

Wolfenstein 2: New Colossus, video

Warcraft cutscene

Warcraft 3, in-game

Warcraft reforged cutscene

Warcraft 3 Reforged, video

meme ifonly

Textures

  • pieces of bitmaps that are applied to an object
  • textures are ultimately converted to formats that are specific to platform and graphic API

Types

  • diffuse texture
  • displacement texture
  • normal texture
  • volumetric texture
  • tileable texture
  • sprite atlas

Formats

  • Desktop: BC6H, BC7, DXT1, DXT5
  • iOS: ATSC, PVRTC
  • Android: ASTC
Color texture

Diffuse

Displacement texture

Displacement

Normal texture

Normal

Volumetric texture

Volumetric

Tileable texture

Tileable

Sprite animation

Sprite atlas

Sprites

Sprite

  • a single graphic image that is incorporated into a scene
  • allows to create large scenes as you can manipulate each sprite separately

Spritesheet

  • a set of corresponding sprites

Sprite atlas

  • a single texture image containing a list of spritesheets
Prince of Persia sprites

3D Objects

3D objects

Mesh

Materials

Textures

3D File Formats

  • encode 3D geometry, material, textures, animations,...
  • geometry encoding - approximate mesh, precise mesh and constructive solid geometry (CSG)
  • BLEND - internal blender file, supported by many engines
  • COLLADA - .DAE, sharing models across CAD software
  • X3D - popular format for WEB
Appr. meshPrec. meshCSGColorMaterialTextureCameraLights
STL
OBJ
FBX
DAE
3DS
STEP
X3D
BLEND

Generic Assets

ZIP

  • many games use their own proprietary format derived from ZIP

ZIP

  • lossless archive format
  • compressions: shrink, DEFLATE, bzip2, none
  • directory-like structure

zlib

  • open-source library
  • implements DEFLATE compression

Game Data

Serialized data

  • XML, JSON, CSV, CFG,...
  • it's good to use XML for tree-like structures and JSON for flat entities
  • some languages (such as C++) don't provide a standardized serialization facility
  • JSON is a good fit for JavaScript as it is it's natural object notation

Database

  • web environment: Web storage (small data), IndexedDB (large data)
  • desktop/mobile: SQLite

Save data

  • dump of all the parts of the game engine required to restore the full state
  • size varies, for most games it's usually a few MBs

Web Storage

Local Storage

  • for data of smaller size (config, game state)
  • up to 10MBs, no expiration time
  • keys and values are strings
1 let myStorage = window.localStorage;
2
3 myStorage.setItem('player_state', player.stateId);
4 myStorage.removeItem('player_state');
5 myStorage.clear();

IndexedDB

  • JS-based object-oriented DB
  • low-level API for structured data
1 await db.players.add({
2 name: 'Warrior',
3 avatar: await getBlob('sprite_warrior.png'),
4 key_mapping: 'default'
5 });
1 {
2 "player": {
3 "difficulty": "hard",
4 "scene": "mountains_02",
5 "posX" : 12,
6 "posY" : 56,
7 "inventory" : ["flashlight, lighter, candle"],
8 "stamina": 45,
9 "agility": 12
10 }
11 }

Example: OpenTTD Save format

OpenTTD save format
  • 3 data layers
  • very complex
Transport Tycoon Deluxe

Example: DOOM Save format

  • DSG files
  • the game loads the level and restores the state by going through its aspects
  • virtually nullifies the feasibility of manual hacking except the player data
  • Aspects:
    • doors, switches, elevators, stairs, lights
    • items picked/available
    • projectiles, teleport, respawn
    • animation, damage
    • linedefs seen on automap
    • items/kills gained counter
1 // p_saveg.c::P_UnArchiveThinkers
2 while (1) {
3 tclass = *save_p++;
4 switch (tclass) {
5 case tc_mobj:
6 PADSAVEP();
7 mobj = Z_Malloc (sizeof(*mobj), PU_LEVEL, NULL);
8 memcpy (mobj, save_p, sizeof(*mobj));
9 save_p += sizeof(*mobj);
10 mobj->state = &states[(int)mobj->state];
11 mobj->target = NULL;
12 if (mobj->player) {
13 mobj->player = &players[(int)mobj->player-1];
14 mobj->player->mo = mobj;
15 }
16 P_SetThingPosition (mobj);
17 mobj->info = &mobjinfo[mobj->type];
18 P_AddThinker (&mobj->thinker);

Levels, Maps, Dialogues

  • mostly proprietary formats of particular libraries/frameworks
  • TMX Maps
    • XML format used by Tiled application for 2D games
    • layers, properties, objects, animations, terrains, wangsets
  • Popular tools for Unity
    • Chat Mapper - tool for writing nonlinear dialogue
      • branching trees
      • barks and alerts
      • QTE
      • localization
      • optional scripting
    • Fungus - storyline library
    • Quest Machine - extensible quest system
Tileset

Tilemaps

  • several layers - 1st-layer tiles, sprites, 2nd-layer tiles, background (for parallax scrolling)
  • Tile - the smallest element on a map
  • Wang - a set of tiles that make a unified whole (e.g. a building)
Zelda tilemap

Zelda (2004)

The Messenger screenshot

The Messenger (2018)

The Messenger tiles

Example: TMX file

1 <map version="1.0" orientation="orthogonal" renderorder="right-down" width="120" height="18" tilewidth="128"
2 tileheight="128" nextobjectid="1">
3 <tileset firstgid="1" name="gameart2d-desert" tilewidth="128" tileheight="128" tilecount="40" columns="5">
4 <image source="gameart2d-desert.png" width="640" height="1024"/>
5 <tile id="2">
6 <properties>
7 <property name="type" type="int" value="1"/>
8 </properties>
9 </tile>
10 <tile id="7">
11 <properties>
12 <property name="type" type="int" value="1"/>
13 </properties>
14 </tile>
15 </tileset>
16 <layer name="background" width="120" height="18">
17 <data encoding="csv">
18 0,23,25,25,36,37,36,23,23,37,25,23,25,......

Example: DOOM WAD file

  • "Where's All the Data"
  • Binary format of package files for Doom
    • Levels (walls, floors, monsters)
    • Sound effects, music
    • Color palettes, images
  • Designed by John D. Carmack
Doom Map
Doom WAD format

Lecture Summary

  • I know what game assets are
  • I know the purpose of a Resource manager
  • I know how games can handle loading
  • I know the difference between the use-cases of WAV and MP3/OGG formats
  • I know the difference between PNG and JPEG formats
  • I know what a cutscene is
  • I know what a sprite is
  • I know the types of textures
  • I know what a tilemap is

Goodbye Quote

Where other men are limited by morality or law, remember, everything is permitted. We work in the dark to serve the light.Assassin's Creed series