A scene says what the actors of a Source engine game do and say over time: speech, expressions,
gestures and the curves of the flex controllers of their models.
It is written as a text .vcd file. Games ship the scenes compiled to a binary form and
gathered in one file, scenes.image. A speech sound carries its own words and phonemes as
sentence data.
Sources, all in ValveSoftware/source-sdk-2013 and read on 4 December 2026:
src/public/scenefilecache/SceneImageFile.h, src/game/shared/sceneimage.cpp,
choreoscene.cpp, choreoevent.cpp, choreoactor.cpp and
choreochannel.cpp of the same folder, src/public/interpolatortypes.h,
src/public/expressionsample.h, src/public/tier1/lzmaDecoder.h,
src/public/sentence.cpp, src/public/tier2/riff.h,
src/tier1/checksum_crc.cpp and the word reader of the scene compiler,
src/utils/common/scriplib.cpp. Sizes are the sums of the declared field types.
The scene image (scenes.image)
The file begins with a 20-byte header. Offsets are from the start of the file.
| Offset | Size | Type | Name | Meaning |
|---|---|---|---|---|
| 0 | 4 | char[4] | nId | VSIF |
| 4 | 4 | int32 | nVersion | 2 |
| 8 | 4 | int32 | nNumScenes | Number of scenes |
| 12 | 4 | int32 | nNumStrings | Number of strings in the pool |
| 16 | 4 | int32 | nSceneEntryOffset | Where the directory is |
After the header come nNumStrings 32-bit offsets, one for each string, then the string
pool: strings ended by a zero byte, each stored once without regard to case, the pool padded to a
multiple of four bytes. Scenes name everything by the number of a string. Then follow the directory,
the summaries in directory order and the scene data.
Directory entry
SceneImageEntry_t, 16 bytes. The entries are sorted by crcFilename, which
the game searches by halving; no number occurs twice.
| Offset | Size | Type | Name | Meaning |
|---|---|---|---|---|
| 0 | 4 | uint32 | crcFilename | CRC-32 of the scene’s file name |
| 4 | 4 | int32 | nDataOffset | Where the scene is, on a multiple of four |
| 8 | 4 | int32 | nDataLength | Its stored length |
| 12 | 4 | int32 | nSceneSummaryOffset | Where its summary is |
The names themselves are not stored. The number is made from the name in lower case, with
backslashes, starting at scenes\. The CRC is the common reflected CRC-32 (polynomial
0xEDB88320, start and final exclusive-or 0xFFFFFFFF).
Summary
SceneImageSummary_t: a uint32 msecs (the time at which the scene stops, in
milliseconds, rounded), an int32 numSounds, and that many int32 string numbers. The
sounds are the first parameter of each speech event and, for a master closed caption, the token
under which the caption is played.
Scene data
Each scene is a compiled scene, packed with LZMA where that makes it smaller. A packed one begins with a 17-byte header.
| Offset | Size | Type | Name | Meaning |
|---|---|---|---|---|
| 0 | 4 | char[4] | id | LZMA |
| 4 | 4 | uint32 | actualSize | Unpacked size, always little-endian |
| 8 | 4 | uint32 | lzmaSize | Packed size, always little-endian |
| 12 | 5 | uint8[5] | properties | The LZMA properties |
Xbox 360 form
An image compiled for the Xbox 360 stores its numbers high byte first: the file begins
FISV and each compiled scene dcvb. The two sizes of the LZMA header stay
little-endian.
The compiled scene
A string is an int16 number into the pool of the image; a number outside the pool means an empty string. A list below is a count followed by that many records.
The same bytes can stand alone in a file: the scene library writes a compiled scene to a file and
takes any buffer that begins with the tag as one, and a comment in choreoscene.cpp
calls such a file a binary .xcd file. The strings are still numbers into a pool kept
by whatever wrote it, which the file does not hold; for a scene taken from
scenes.image that is the pool of the image.
| Part | Contents, in order |
|---|---|
| Scene | bvcd; uint8 version, 4; uint32 CRC-32 of the .vcd text it was made from; uint8 number of events that belong to no actor; uint8 number of actors; those events; those actors; the scene ramp; uint8 ignore phonemes |
| Actor | string name; list (uint8) of channels; uint8 active, 1 for yes |
| Channel | string name; list (uint8) of events; uint8 active, 1 for yes |
| Ramp | list (uint8) of points: float time; uint8 value, in 255ths |
| Event | int8 type; string name; float start; float end; three strings, the parameters; ramp; uint8 flags; float distance to target; list (uint8) of relative tags; list (uint8) of flex timing tags (both: string name, uint8 position in 255ths); list (uint8) of absolute tags on playback time, then list (uint8) on shifted time (both: string name, uint16 position in 4096ths); for a gesture, float sequence duration, −1 for none; int8, and when it is 1, two strings: the tag and the sound the event is timed from; list (uint8) of flex tracks; for a loop, int8 loop count; for speech, the caption fields |
| Flex track | string flex controller; uint8 flags: 1 active, 2 combination; float minimum; float maximum; list (int16) of samples; for a combination, a second list (uint16) of samples |
| Sample | float time; uint8 value, in 255ths; uint16 curve type |
| Caption fields of speech | int8 caption type: 0 master, 1 slave, 2 disabled; string token; uint8 flags: 1 uses a combined file (set only when captions are not disabled), 2 the combined file differs by gender, 4 the caption is not faded with distance |
Event types
0 unspecified, 1 section, 2 expression, 3 look at, 4 move to, 5 speak, 6 gesture, 7 sequence, 8 face, 9 fire trigger, 10 flex animation, 11 subscene, 12 loop, 13 interrupt, 14 stop point, 15 permit responses, 16 generic.
Event flags
1 resume condition, 2 lock body facing, 4 fixed length, 8 active, 16 force short movement, 32 play over script.
Curve types
The low byte is the interpolation to the right of a sample, the next byte that to its left: 0 default, 1 Catmull-Rom with X normalised, 2 ease in, 3 ease out, 4 ease in and out, 5 B-spline, 6 linear, 7 Kochanek-Bartels, 8 Kochanek-Bartels early, 9 Kochanek-Bartels late, 10 simple cubic, 11 Catmull-Rom, 12 Catmull-Rom normalised, 13 Catmull-Rom tangent, 14 exponential decay, 15 hold.
The text scene (.vcd)
The text is a list of words with blocks in braces. Some scenes begin with a comment such as
// Choreo version 1. The scene compiler splits the text with the word reader of
Valve’s build tools:
- A character of value 32 or less is a blank. Bytes from 128 up count as blanks too, because the reader compares them as signed numbers; a byte order mark is therefore passed over.
- Where a word would begin,
;,#and//start a comment that runs to the end of the line, and/*one that runs to*/. - A word that begins with a quotation mark runs to the next one, over line ends if need be.
- Any other word ends only at a blank or
;. Braces and quotation marks inside it are part of it, so a brace must stand apart. - A word holds at most 1,023 characters.
- The reader has commands of its own, all beginning with
$.
The game reads a loose .vcd through a word reader of its own, whose source is not in
the SDK.
Commands of the word reader
The reader carries these out as it meets them and does not hand them on. The command names and macro names are matched without regard to case, and they count even between quotation marks. The words a command needs must be on its line.
| Command | Effect |
|---|---|
$include file | The words of the file follow, then the rest of this one. A relative name is put after a directory the tool has set, not one the scene states; when the result lies under one of the tool’s base paths, the same file name is tried under each of them. A name may be a pattern with * and ?; the files it finds are read last first. A file that cannot be opened stops the tool |
$definevariable name value | Defines a variable for the rest of the run |
$definemacro name parameters \\ | Defines a macro. The parameters are the words up to one that begins \\ or up to the end of the line. The body is what follows the last parameter up to the line end; a \\ there blanks the rest of its line and takes in the next. The first definition of a name holds |
$macro values | Reads the body of the macro, with one value on this line for each parameter. A $ word that is not a macro is an ordinary word |
$name$ | Inside a word that is not quoted: replaced, in a macro body by the value of the parameter of that name, elsewhere by the first variable whose name begins with name. The replacement is not scanned again. A name with no definition stops the tool |
At most 62 files and macros may be open inside one another (a macro takes two of the places), a
macro has at most 64 parameters, the values of one call fill at most 4,095 characters, and 256
macros can be defined. The source: scriplib.cpp and, for the paths,
cmdlib.cpp.
At the top level the words are event, actor, mapname,
fps, snap (on or off),
ignorePhonemes (on or off), scene_ramp and
scalesettings (pairs of an editor tool and a whole number; 0 or less means 100). Any
other word is an error, and reading stops there. An actor block, after the name, holds
channel blocks, faceposermodel and active. A
channel block holds event blocks and active.
Event block
event type name { … }. Inside:
| Word | Values |
|---|---|
time | start, and end (1 when left out) |
ramp | The old ramp: attack, and optionally sustain and decay (each 1 when left out) |
param, param2, param3 | The three parameters |
pitch, yaw, loopcount | A whole number |
resumecondition, fixedlength, lockbodyfacing, forceshortmovement, synctofollowinggesture, playoverscript | None: the word sets the flag |
distancetotarget, sequenceduration | A number |
active | 0 or 1 |
tags | Block of name and position |
absolutetags | playback_time or shifted_time, then a block of name and position |
flextimingtags | Block of name, position and locked (0 or 1) |
relativetag | Tag and sound |
flexanimations | Flex tracks |
event_ramp | Curve data |
cctype | cc_master, cc_slave or cc_disabled |
cctoken | The caption token |
cc_usingcombinedfile, cc_combinedusesgender, cc_noattenuate | None |
A word the game does not know inside an event is passed over. The old ramp counts only
when there is no ramp of points and one of its three numbers is not 1: it becomes three points, all
of the sustain value, at the times (1 − attack) × length, decay × length and the middle of the two,
in order of time.
Curve data
Optionally leftedge curve level and rightedge curve
level, then a block with one sample on a line: time, value and, optionally, the name of a
curve type.
Flex tracks
flexanimations is followed by the optional words samples_use_time
(without it sample times are fractions of the event’s length) and
defaultcurvetype=curve, then a block of tracks. A track is the name of a flex
controller, then optionally disabled, combo, range
minimum maximum and the two edges, then a block of samples (time, value, optional
curve), and for a combination a second block. A track that is switched off and has no samples in its
first block is dropped.
Sentence data
A speech sound carries its sentence in the VDAT chunk
(WAVE_VALVEDATA) of a WAVE file. The text form
begins VERSION 1.0; with any other version the game reads nothing of it. Sections
follow, each a name and a block:
| Section | Contents |
|---|---|
PLAINTEXT | The words of the sentence |
WORDS | Blocks WORD word start end { … }, each holding phonemes: code number, symbol, start, end, volume |
EMPHASIS | Pairs of time and value |
CLOSECAPTION | For each language a block of PHRASE char or unicode length, one character skipped, that many bytes taken as they are, one character skipped, start, end. The game steps over the section |
OPTIONS | Pairs of key and value |
A caption’s length is below 4096. The caption languages are english, french, german, italian, koreana, schinese, spanish, tchinese, japanese, russian, thai and portuguese.
Cached binary forms
The engine also keeps sentences in binary form. Version 1: uint8 version; uint16 count of phonemes, each uint16 code, float start, float end; int16 count of emphasis points, each float time and int16 value in 32767ths; uint8 voice duck. Version 4, the aligned form: uint8 version and three padding bytes; int32 count of phonemes, each int32 code, float start, float end; int32 count of emphasis points, each two floats; int32 voice duck. They are what the sentence’s cache methods write into a buffer; the SDK sources read describe no file that holds them.
Viewer
A scene image shows its header, string offsets, directory, summaries and scene blocks, with
tables of every scene and every string. One scene at a time is unpacked and shown in full: its
actors and channels, events, tags, flex tracks and curve points. An option at the top of the window
chooses it by number; another finds it by file name, and adds scenes\ to a name that
lacks it. Both byte orders are read. A text .vcd shows the same tables, its editor zoom
settings and the byte range of every actor, channel and event. It splits the words as the scene
compiler does and carries out the commands of the word reader; an option at
the top of the window sets them aside instead, since the game’s own reader for a loose file is not
published. The commands and the included files are listed. An included file is a separate file: its
name is shown, and it is read when the scene is opened from a folder and the file is found from the
scene’s folder or a folder above it, by the whole path or a shorter tail of it (a pattern by the
whole path). Words that come from an included file or a macro are shown in the tables with the line
of the scene that brought them in and where they came from; they have no byte range of their own.
Where the tool would stop with an error the viewer reports it and reads on, leaving out a missing
file and keeping an unknown $name$ as written. A .vcd file that is a
Value Change Dump is a different format and is not read here.
A compiled scene in a file of its own, in either byte order, shows its fields and the same tables
with the byte range of every event. Its strings are shown as numbers, because the pool they point
into is in the file that holds the strings: for a scene of a game,
scenes.image.
One compressed scene is unpacked up to 256 MB, and a text scene or a compiled scene file is read up to 256 MB. The words of a text scene, with its included files and macro bodies, are read up to 256 MB in all, however many calls and files that makes, and from a folder 256 MB of the scene and its included files are taken, however many they are. Commands may stand for the words of other commands 1,000,000 deep. Every problem of the commands is listed, one met again at the same place counted with it. The limits of 1,023 characters a word, 62 open files and macros, 64 parameters, 4,095 characters of values and 256 macros are the compiler’s own: past them it stops, and the viewer reports it. A longer word and longer values are still read, a variable whose replacement would make a word too long is kept as written, and a file, macro call, parameter or definition that has no place is left out. In an image whose string offsets lead to the same long text over and over, strings are read up to four times the file size in all.
The scenes are listed, not performed: they are not played on a model. The viewer does not read the cached binary forms of a sentence, and it does not show the sentence data of a sound file.
Links
Reference
- SceneImageFile.h – the SDK header of the scene image
- sceneimage.cpp – how the image is built from the text scenes
- choreoscene.cpp – how a scene is read and written, as text and as binary
- sentence.cpp – the sentence data of a speech sound
- scriplib.cpp – the word reader of the build tools and its commands
- cmdlib.cpp – how the build tools make a path of a file name