Internal documentation
Technical reference for Book Atlas / Skyrim Source Exporter, one concept per page. Read Architecture first if you’re new to the codebase.
The sidebar has a general part, then one part per .NET project:
- General: Architecture, the JSON contracts between the exporter and the generator (book export, map export), and every place the code departs from a format’s reference (Spec deviations).
- CreationEngineFormats: the binary file formats, with no Skyrim-specific knowledge.
- BookAtlas.Exporter: the CLI built on that library: load order, localization, the
export:*commands and thedebug:*inspection tools. - BookAtlas.Generator: the static site built from the exporter’s JSON.
Each command prints its options and examples with <command> --help. The pages explain what a
command does and why, not how to type it.
Architecture
Three .NET 10 projects, each with its own part in this book. This page covers what crosses project boundaries: the folder split of each project and where new code goes.
CreationEngineFormats <- BookAtlas.Exporter --JSON--> BookAtlas.Generator
(file formats) (CLI: export, debug) (static site)
BookAtlas.Generator references neither of the other two: it reads only the
book export JSON format.
A namespace is the project name followed by the folder path, one segment per folder: the type in
BookAtlas.Exporter/Pipelines/Maps/Layers/PlacedObjects/ObjectsLayer.cs is
BookAtlas.Exporter.Pipelines.Maps.Layers.PlacedObjects.ObjectsLayer. Test projects follow the same rule.
CreationEngineFormats
The file formats, with no dependency on a CLI, a load order or vanilla Skyrim data. Parsers throw
InvalidDataException on malformed input and never log.
| Folder | Content |
|---|---|
Binary/ | SpanReader (little-endian reads) and SpanCursor (sequential, bounds-checked reads) |
Plugin/ | Plugin format: record and group headers, PluginFile, PluginWalker, FormIds |
Plugin/Query/ | Plugin queries: what a command reads from a plugin, in one walk |
Plugin/Records/ | One model per record type |
Plugin/Reader/ | One reader per record type, SubrecordCursor, Tags, VmadReader |
ArchiveFile/ | BSA archives and string tables |
Text/ | GameTextDecoder: primary then secondary encoding, for string tables and inline text |
Nif/ | NIF and Havok: header, scene graph, BSTriShape geometry, collision shapes, textures |
Lod/ | LOD settings: the terrain LOD grid of a worldspace |
Swf/ | SWF container, DefineFont3, TrueType writer |
Dds/ | DDS textures: header, mip levels, decoding to RGBA with Pfim |
BookAtlas.Exporter
The CLI reads game data in four layers. A layer calls only the layers below it.
Commands/ parse the options, build a GameSource, run a pipeline (or format a dataset for a dump)
|
Pipelines/ one feature: ask for its datasets, chain its steps, write its output
|
Datasets/ one model merged over the load order: its clauses, its merge, its report
|
Game/ access to the game: the source, the session, archives, the plugin pass, assets, vanilla facts
Imaging/ IO/ Diagnostics/ used by every layer
| Layer | Does | Calls | Why the boundary |
|---|---|---|---|
Commands/ | Options, help, examples, --clean | Pipelines, Datasets (dumps), Game | A command stays an adapter to the command line |
Pipelines/ | The steps of one output, then its files | Datasets, Game | A new output is a new pipeline: it never opens a plugin or an archive |
Datasets/ | Clauses on the plugin query, the load-order merge, what the merge dropped | Game, other datasets | Two pipelines in one session share what is already read and merged |
Game/ | Where the data is, the session, archives, the plugin pass, assets | CreationEngineFormats | The only code that touches game files |
Inside a layer, folders follow the domain: Datasets/Books/, Pipelines/Maps/,
Pipelines/Interiors/. Pipelines/Debug/ holds the debug:* commands that chain more than
one step. A dump that only reads a dataset and prints it has no pipeline: the command formats it.
A session
A command builds a GameSource: one plugin file, one archive file, or a load order found in a
Data directory. It opens a GameSession on it for its whole run.
- The pipeline asks for every dataset it needs in one
LoadAsync. - The session builds one
PluginQueryper plugin and lets each dataset attach its clauses to it. Each plugin is walked once, all plugins in parallel, see Plugin queries. - Each dataset merges its per-plugin parts in load order. The parts are released after the merge, unless the model keeps them on purpose.
GetAsyncreturns the model. The first call also logs what the merge dropped, once per session, see Logging.- When a large model is no longer needed, the pipeline releases it, so the next steps run without it.
- Disposing the session closes the archives.
The archives open on first use, once per session. A pipeline that needs them reads
session.Archives before LoadAsync, so the listings are read, and the loose files of Data
indexed, while the plugins are walked.
Datasets
| Kind | Contract | Cached | Examples |
|---|---|---|---|
| Plugin | Attach declares clauses on a plugin’s query, Merge folds the parts | Yes, by value | BookRecords, LocationRecords, WorldspaceMaps(reads) |
| Derived | BuildAsync combines other datasets of the session | Yes, by value | BookPlacements, WorldspaceCells, WorldspaceTerrain |
| Lookup | FormIds known after a first merge, then a targeted read of the top groups | No, served once | BaseObjects(wanted), NamedRecords(wanted) |
A dataset is a record. Its parameters are its cache key: two equal requests share one model, and
WorldspaceMaps with and without heights are two models. Merge and BuildAsync are pure: they
put what they dropped in the model, and the dataset’s Report logs it. The merge rules are in
Load order and merging.
Where new code goes
| You’re adding… | Goes in |
|---|---|
| A binary format detail (a record type, a subrecord, an archive field) | CreationEngineFormats |
| A new output | A pipeline in Pipelines/<Feature>/, a thin command in Commands/, registered in ExporterCli.cs |
| Data a pipeline needs from the plugins | A dataset in Datasets/<Domain>/, its clauses in the domain’s query class |
| A model built from existing datasets | A derived dataset |
| Records found by FormId after a merge | A lookup in Datasets/Lookups/ |
| Reading a file from the archives | Game/Assets/ |
| A fact specific to vanilla Special Edition | Game/Vanilla/ |
| Decoding a game texture | CreationEngineFormats/Dds/, see DDS textures |
| An image operation or PNG encoding | Imaging/, PNG in Imaging/Png/ |
| A way to interpolate between the samples of a grid | Imaging/Interpolation/Kernels/, see Interpolation |
| A debug dump | Commands/Debug/, with a pipeline in Pipelines/Debug/ if it chains several steps |
Game/Vanilla/ holds the facts of vanilla Special Edition (archive list, string encodings,
fontconfig files), Game/LoadOrders/ the se, ae and custom load orders. GameSource is where
another data source would plug in. No abstraction is built for it yet.
No dependency injection container
The dependencies are data (datasets), not services to wire. There is one lifetime, the session, and few pipelines, all known. A container would add a package, start-up time and an indirection that hides the flow. Constructors take the session and the options. A container becomes useful only if pipelines turn into extensions registered at run time.
The production commands are export:books and
export:worldspace-maps:*. The debug:* commands are
inspection tools.
BookAtlas.Generator
The static site generator. See its overview for why it’s a separate project.
| Folder | Content |
|---|---|
Commands/ | generate:site, generate:pdf |
Import/ | JSON import models and readers (books, maps), independent of the exporter’s types; language discovery; the map catalog |
Diagnostics/ | A copy of the exporter’s logger |
IO/ | A copy of the exporter’s OutputDirectoryCleaner, behind --clean |
Templates/, Assets/ | Embedded Scriban templates, the pages’ scripts, the site stylesheet and the PDF one |
Rendering/ | Book naming, titles and their sort order, the concurrent book loop |
Rendering/Markup/ | Book markup to safe HTML |
Rendering/SiteAssets/ | Texture and font resolution, stylesheet |
Rendering/Templating/ | The Scriban wrapper and template functions |
Rendering/Pages/ | Page shell, index pages and the map pages; BookPage/ for one book’s page |
Rendering/Maps/ | The map page’s menu, data and libraries, links from book pages; copying the tiles into the site |
Rendering/Pdf/ | Headless Firefox, the WebDriver BiDi client, printing books to PDF |
LanguageSiteGenerator.cs writes one language’s subsite, LanguagePdfGenerator.cs one language’s PDFs.
Tests
Each project has a test project with the same folder layout: CreationEngineFormats.Tests,
BookAtlas.Exporter.Tests, BookAtlas.Generator.Tests. Fixtures are built in code
(Support/: plugin, subrecord, BSA and NIF byte builders); no test reads game files.
Book export JSON format
export:books writes, per language discovered in the strings archive:
- One JSON file per book, under
<output-directory>/localized/<language>/, named<owningPlugin>_<localId>_<editorId>.json(e.g.skyrim.esm_0F3AC2_Book0EditorId.json); seeBookFileExporter.GetFileName. - One
index.jsonin that same directory, listing every book exported for that language; seeBookIndexWriter.
Once per export, it also writes <output-directory>/export.json, the export manifest:
what describes the whole export rather than one language, such as its load order.
All are written with System.Text.Json source generation (Pipelines/Books/BookExportJsonContext.cs),
camelCase property names, indented. Source generation (not reflection-based
JsonSerializer.Serialize<T>) is required here because the project publishes with
PublishAot=true.
The authoritative C# shapes are Pipelines/Books/BookExportModel.cs (BookExportModel, BookTeachesModel,
BookKeywordModel, BookLocationModel), Pipelines/Books/BookIndexWriter.cs (BookIndexEntryModel), Pipelines/Books/ExportManifestWriter.cs
(ExportManifestModel), Pipelines/Books/LoadOrderModel.cs and Pipelines/Books/ExportMetaModel.cs. The
TypeScript below mirrors them for consumers outside this repo (the static site); keep both in sync
by hand, there is no generation step tying them together.
Per-book file
Every FormId is a GlobalFormId string, "owningPlugin:localId", such as "skyrim.esm:0F3AC2".
A *Source field names the plugin that last set the matching field, or null when none did.
interface BookExport {
formId: string;
/** Lowercased file name of the plugin that defines the book, e.g. "skyrim.esm". */
owningPlugin: string;
/** Hex id local to owningPlugin, e.g. "0F3AC2". */
localId: string;
editorId: string | null;
title: string | null;
/** DESC text. When DESC is blank once markup is stripped and menuArtFormId is set, a generated
* placeholder naming the menu art record instead, see contentIsPlaceholder. */
content: string | null;
/** True when content is the generated placeholder. Always false when menuArtFormId is null. */
contentIsPlaceholder: boolean;
/** ICON: inventory icon path, relative to the game's Textures folder. */
inventoryImage: string | null;
/** DATA gold value: the base price, not a vendor's price, see export heuristics. */
value: number | null;
/** DATA type: "book" (0) or "note" (255). null without DATA or outside the spec. */
type: "book" | "note" | null;
/** DATA flag 0x02. null without DATA. */
cannotBeTaken: boolean | null;
/** DATA weight. null without DATA. */
weight: number | null;
/** What reading the book teaches. null when it teaches nothing. */
teaches: BookTeaches | null;
/** CNAM: the short inventory text, localized. null when absent or string id 0. */
description: string | null;
/** KWDA, in record order. [] when the book has none. */
keywords: BookKeyword[];
/** INAM: the record (a STAT in vanilla) whose model shows the book's art. */
menuArtFormId: string | null;
/** The menu art record's EditorId and MODL path, when the load order has it. */
menuArtEditorId: string | null;
menuArtModelPath: string | null;
/** Every texture of the menu art model, converted to PNG. [] when there is none or nothing
* resolves. */
menuArtImages: MenuArtImage[];
editorIdSource: string | null;
titleSource: string | null;
/** Who set DESC, even when content shows the placeholder. */
contentSource: string | null;
inventoryImageSource: string | null;
valueSource: string | null;
menuArtFormIdSource: string | null;
/** DATA: type, cannotBeTaken, weight and teaches, replaced together. */
dataSource: string | null;
descriptionSource: string | null;
keywordsSource: string | null;
/** Every place the book is placed or reachable from. */
locations: BookLocation[];
/** Every leveled list that can produce the book, see below. */
leveledLists: BookLeveledList[];
/** The scripts of the book's VMAD. [] without VMAD. */
scripts: BookScript[];
scriptsSource: string | null;
}
interface MenuArtImage {
/** Relative to the export's textures/ folder, e.g. "menuart/fishmapeastmarch01.png". */
path: string;
/** The texture's file name matches the model's: the object's own artwork, not shared paper.
* At most one per array. Prefer it when showing one image. */
isNameMatch: boolean;
/** The texture's file name without folder or extension, e.g. "LargeNote01". */
name: string;
}
interface BookTeaches {
/** "skill": DATA flag 0x01. "spell": flag 0x04, which wins when both are set. */
kind: "skill" | "spell";
/** The SPEL, or the skill's AVIF in Skyrim.esm. */
formId: string;
/** null when the load order doesn't have the record. */
editorId: string | null;
/** Localized FULL, e.g. "Smithing". null when the record or its string is missing. */
name: string | null;
/** The skill's actor value name, the same in every language, e.g. "Marksman" for Archery.
* null for a spell. */
actorValue: string | null;
}
interface BookKeyword {
formId: string;
/** null when the load order doesn't have the KYWD. Keywords have no localized name. */
editorId: string | null;
}
interface BookLocation {
/** "direct": a REFR of the book itself.
* "container": reachable from a placed CONT's items, nested leveled lists included.
* "npc": reachable from a placed NPC's inventory, the NPC in no vendor faction.
* "vendor": sold by a placed NPC of a vendor faction, from its inventory or its faction's chest,
* or found in a placed vendor chest.
* Only "direct" is a guarantee, see export heuristics. */
source: "direct" | "container" | "npc" | "vendor";
/** The container's or NPC's EditorId. null for "direct". */
sourceEditorId: string | null;
/** The placed reference itself (book, container or NPC), not its base record. */
refFormId: string;
/** null for an interior cell. */
worldspaceEditorId: string | null;
cellEditorId: string | null;
isInterior: boolean;
/** Exterior cell grid. null for an interior cell. */
gridX: number | null;
gridY: number | null;
/** Position in game units, cell-local for an interior. */
x: number;
y: number;
z: number;
/** The reference's Persistent flag: often quest-related, not always. */
isPersistent: boolean;
/** The reference carries a VMAD. Its contents aren't read. */
hasScript: boolean;
}
interface BookLeveledList {
formId: string;
editorId: string | null;
/** The book's LVLO entry in this list, only when the book is a direct entry; the first one
* when it is listed several times. null when reached through a nested list. */
level: number | null;
count: number | null;
}
leveledLists is every LVLI that can produce the book, through nested lists included, whether or
not anything placed uses the list. locations only follows lists reachable from a placed CONT or
NPC_, so a book can have leveled lists and no location, or the other way round.
interface BookScript {
/** The script's name, without extension. */
name: string;
/** VMAD script status byte, raw, from VMAD version 4. null on older data. */
status: number | null;
properties: BookScriptProperty[];
}
interface BookScriptProperty {
name: string;
/** Which value field is set; the nine others are null. */
type: "object" | "string" | "int32" | "float" | "bool" |
"objectArray" | "stringArray" | "int32Array" | "floatArray" | "boolArray";
/** VMAD property status byte, raw, from VMAD version 4. */
status: number | null;
stringValue: string | null;
int32Value: number | null;
floatValue: number | null;
boolValue: boolean | null;
objectValue: BookScriptObjectValue | null;
stringArrayValue: string[] | null;
int32ArrayValue: number[] | null;
floatArrayValue: number[] | null;
boolArrayValue: boolean[] | null;
objectArrayValue: BookScriptObjectValue[] | null;
}
interface BookScriptObjectValue {
/** null when the FormId doesn't resolve, see data problems: the property is kept. */
formId: string | null;
/** Only when formId is null: the file-local FormId in hex, e.g. "000C583E". */
rawFormId: string | null;
/** The quest alias the reference is bound to. null for a plain reference (VMAD's 0xFFFF). */
aliasId: number | null;
}
Per-language index: index.json
interface LanguageIndex {
books: BookIndexEntry[];
fonts: FontIndexEntry[];
}
interface BookIndexEntry {
formId: string;
editorId: string | null;
title: string | null;
/** File name only (same directory as index.json), e.g. "skyrim.esm_0F3AC2_Book0EditorId.json". */
fileName: string;
/** Total entries in that book's `locations` array, all sources combined. */
locationCount: number;
/** True if at least one of that book's locations has source "direct". */
hasDirectLocation: boolean;
}
interface FontIndexEntry {
/** The font's DefineFontName, e.g. "Daedric". */
name: string;
/** The markup faces whose fontconfig map name is this font's name, e.g. ["$DaedricFont"].
* [] when none matches, see font-export.md. A face should appear under one font at most; this
* isn't enforced. */
styles: string[];
/** TTF file path, relative to index.json's own directory, e.g. "fonts/Daedric.ttf". */
path: string;
}
fonts is one entry per font converted from that language’s fontlib SWFs. See
Font export for why every embedded font is exported.
Export manifest: export.json
What describes the whole export rather than one language. Written once per export, at the root
of the output directory, next to localized/ and textures/; see Pipelines/Books/ExportManifestWriter.cs.
interface ExportManifest {
loadOrder: LoadOrder;
/** What the export ran with. Optional: an older export has none. */
meta?: ExportMeta;
}
interface LoadOrder {
/** The --load-order value the export ran with: "se", "ae" or "custom". */
name: string;
/** Plugin file names read, in load order. A plugin of the load order missing from Data is left out. */
plugins: string[];
/** BSA file names opened, in load order. An archive missing from Data is left out. */
archives: string[];
}
loadOrder lists the files the export actually read, not the files the load order asked for. See
Load order and merging for how the lists are built.
Export meta
meta records the command and the options an export ran with. export.json carries it, and so
does each map manifest of the map export format, never maps.json.
interface ExportMeta {
/** The exporter command, e.g. "export:books". */
command: string;
/** Option name as typed on the command line, to its value as text, in the command's order. */
options: { [name: string]: string };
}
| Rule | Behavior |
|---|---|
| Options listed | Every option with a value, given or defaulted. A flag not given is "false" |
| Left out | The arguments and the path options (--output-directory): they name folders of your machine |
| Changing no output file | Left out: --clean, and --stats of export:books |
| Not listed | --verbose and --help, which belong to the whole CLI |
| Repeated option | Its values joined with , , e.g. "Tamriel, Sovngarde" |
A consumer shows the values as they are and doesn’t parse them. Commands/ExportMeta.cs builds it.
Map export format
A map directory describes worldspace maps for a consumer such as the generated site. It holds an
index, maps.json, and one manifest per map. A manifest describes its map completely, load order
included, so an index can list maps of several runs and several load orders.
export:worldspace-maps:lod and export:worldspace-maps:raster-records write this format with
--format grid and --format pmtiles. --format plain-png writes no manifest and no index. You
can also write an index by hand, see Writing an index by hand.
The authoritative C# shapes are in Pipelines/Maps/Output/MapManifest.cs (MapIndex,
MapManifest and its parts) and Pipelines/Maps/Output/MapGridManifest.cs (MapGridMarkerGroup,
MapGridMarker). The TypeScript below mirrors them for consumers outside the exporter; keep
both in sync by hand. Both files are written with System.Text.Json source generation
(MapContractJsonContext), camelCase, indented, accented names unescaped.
Files
<map-directory>/
maps.json the index
<manifest path> one per map, any name, any subfolder
<tiles path> a grid folder <z>/<x>/<y>.png, or a .pmtiles archive
<level tiles path> one per level past level 0, of the same type
| Rule | Detail |
|---|---|
| Paths are relative | To the file that holds them: an index entry’s manifest to maps.json, a manifest’s tiles.path and each level’s to the manifest |
| Separator | / only. A path holding \ breaks the rule |
| Inside the directory | No .. segment, no empty segment, not rooted (/abs, C:/abs) |
| Null, not left out | An optional field is written as null, so a hand-written manifest and a generated one read the same way |
The grid’s tiles.json and the PMTiles metadata are not part of the format: they are the tile
viewers’ own manifests, see Grid output. They
leave a null field out.
Index: maps.json
/** Which maps exist. Nothing else. */
interface MapIndex {
maps: MapIndexEntry[];
}
interface MapIndexEntry {
/** The worldspace's EditorID. Unique in the index, case-insensitive: the site's URLs use it. */
editorId: string;
/** Path of the map's manifest (a MapManifest), relative to maps.json. */
manifest: string;
}
Manifest
/** One map, described completely. */
interface MapManifest {
/** Must equal the index entry's editorId. */
editorId: string;
/** "owningPlugin:localId", e.g. "skyrim.esm:00003C". */
formId: string;
/** WRLD FULL in `language`; null without one or when its string id is missing. */
name: string | null;
/** WRLD WNAM's EditorID; null without a parent or when it doesn't resolve. */
parentEditorId: string | null;
/** WRLD DATA flags. */
flags: { smallWorld: boolean; cantFastTravel: boolean };
/** The image's size in cells, and the LAND cells drawn. */
cells: { width: number; height: number; land: number };
tiles: MapTiles;
/** The full-size image: tile pixels at maxZoom. */
image: {
width: number;
height: number;
pixelsPerCell: number;
/** The image's edges in game units, X east, Y north. */
worldBounds: { west: number; north: number; east: number; south: number };
};
/** How the image was made, for display only: labels chosen by the producer. */
render: { background: string; layers: string[] };
/** The language of `name` and of the markers' names, e.g. "english". */
language: string;
/** The files the map was made from. Same shape as export.json's loadOrder. */
loadOrder: LoadOrder;
/** The plugins carrying the worldspace's WRLD or one of its CELL records, in load order. */
plugins: MapPlugin[];
/** What `--markers` lists, one group per kind. Null when the map was made without it. */
markerGroups: MarkerGroup[] | null;
/** The levels drawn over level 0 (`tiles`), in slider order. Null for a map of one level. */
levels: MapLevel[] | null;
/** The command and options the map was made with, see the book export format's ExportMeta.
* Optional: an older manifest or one written by hand has none. */
meta?: ExportMeta;
}
interface MapTiles {
type: "grid" | "pmtiles";
/** A grid folder holding <z>/<x>/<y>.png, or a .pmtiles file; relative to the manifest. */
path: string;
tileSize: number;
minZoom: number;
maxZoom: number;
}
interface MapLevel {
/** 1, 2, ... from the top level down. Level 0 is the manifest's `tiles`. */
index: number;
/** The level's stop in game units; null for a level that is not an altitude. */
altitude: number | null;
/** For display, e.g. "z 272". */
label: string;
/** Only the tiles that differ from level 0's. Same type, tileSize, minZoom and maxZoom as `tiles`. */
tiles: MapTiles;
}
interface LoadOrder {
name: string;
plugins: string[];
archives: string[];
}
interface MapPlugin {
/** File name, as in loadOrder.plugins. */
plugin: string;
/** "defines": owns the WRLD FormId. "overrides": carries a later version. null: no WRLD. */
worldspace: "defines" | "overrides" | null;
/** CELL records of the worldspace whose FormId the plugin owns. */
newCells: number;
/** CELL records of the worldspace whose FormId another plugin owns. */
overriddenCells: number;
}
interface MarkerGroup {
/** The kind, as `--markers` names it: unique in the map. */
id: string;
/** The label of the group's layer. */
name: string;
/** CSS "#rrggbb". */
color: string;
/** Whether a viewer shows the layer when the map opens. */
defaultVisible: boolean;
markers: Marker[];
}
interface Marker {
/** The record the marker stands for. */
formId: string;
name: string | null;
/** The game starts without it: a viewer draws it fainter. */
disabled: boolean;
worldspace: string | null;
x: number; y: number; z: number;
/** Pixels from the image's top-left corner at full size. */
pixelX: number; pixelY: number;
/** The first and last level showing the marker's floor; null for a map of one level. */
levels: { from: number; to: number } | null;
/** Display label and text pairs, listed as they are. The keys depend on the group. */
data: Record<string, string>;
}
A pixel at full size spans (east - west) / width game units. With Leaflet, use CRS.Simple and
maxNativeZoom set to maxZoom.
Marker groups
What the exporter reads to fill these groups is described in Markers.
A viewer needs no knowledge of what a group holds: it makes one layer per group from its name
and color, shows it when defaultVisible is true, and draws each marker at its pixel. A
disabled marker is drawn fainter. The popup lists formId, the pairs of data in their order
and the game position.
| Marker property | Meaning |
|---|---|
formId | The record the marker stands for: the REFR of a location marker, the BOOK of a books marker |
name | FULL; null without one, or when its string id is missing from the tables |
disabled | The REFR’s “Initially Disabled” header flag |
worldspace | The EditorID of the marker’s worldspace |
x, y, z | Game units in the marker’s worldspace, from DATA, to the hundredth |
pixelX, pixelY | Pixels from the image’s top-left corner, at full size, to the hundredth |
levels | The levels whose floor under the marker is the floor nearest its z |
data | Text pairs; the keys are display labels |
The groups the exporter writes:
Group id | name | color | defaultVisible | data keys |
|---|---|---|---|---|
location | location | #f5c542 | true | Type (the spec’s name, or the number past the enum), then Visible and Can travel to, always set to yes or no |
books | Books | #b07cf0 | false | none: data is {} |
A book is listed once per REFR, so a book lying in several places appears several times. Its
content, image and page are not part of the list.
markerGroups: [] is a map made with --markers and no group; a group with markers: [] means
none of its kind falls on the image; null means the map was made without --markers.
A marker’s levels is null when the map’s levels is.
Map levels
A map with levels is a stack: level 0 is tiles, and each level is a layer of tiles drawn over
it. A level holds only the tiles whose pixels differ from level 0’s at the same z/x/y, at every
zoom. Where a level has no tile, level 0 shows through and is right there. What the levels show is
described in Levels.
| Level property | Meaning |
|---|---|
index | 1 for the top level under level 0, then down. In levels in index order |
altitude | The level’s stop, in game units: level k shows, under each point, the highest floor less than 64 units above it, else the lowest. A whole number |
label | z <altitude>, without decimals |
tiles | As the map’s tiles, with its own path |
A marker’s levels gives the levels whose floor under the marker is the floor nearest its z,
first and last: a marker on an upper floor shows on the levels that keep that floor, one on the
floor under it on the levels that show it. Where the levels don’t cut the map, or for a marker of
a descendant worldspace that its ONAM moves or scales, levels spans every level, from 0 to the
last index.
Consumer rules
| Situation | Consumer does |
|---|---|
maps.json missing or not a MapIndex | Fails |
Index entry without editorId or manifest | Skips the entry |
Duplicate editorId in the index (case-insensitive) | Keeps the first |
Manifest missing, unreadable, or editorId differs from the entry | Skips the map |
Manifest without tiles, or without image.worldBounds | Skips the map |
Path with .., absolute, or a \ | Skips the map |
tiles.type unknown, or tiles.path missing on disk | Skips the map |
tiles.type and the file disagree: a grid path that isn’t a folder holding at least one file, a pmtiles path that isn’t a file | Skips the map |
parentEditorId not in the index | Shows the map as a root |
A level whose tiles.type, tileSize, minZoom or maxZoom differs from tiles | Drops the level |
A level whose tiles.path breaks a path rule or is missing on disk | Drops the level, keeps the map |
A level without label or tiles, or whose index is under 1 | Drops the level |
Two levels with the same index | Keeps the first one it can use |
levels out of index order | Reads them in index order |
levels: [], or every level dropped | Reads it as null |
What the exporter writes
Each tile map gets <EditorID>.json next to its tiles: the grid’s Tamriel/ gets
Tamriel.json, Tamriel.pmtiles gets Tamriel.json. At the end of the run, maps.json lists the
maps this run wrote, replacing any earlier one. A run that writes no map writes no index. These
names are the exporter’s defaults, not rules of the format.
| Manifest field | Source |
|---|---|
editorId, formId, parentEditorId, flags | The merged WRLD |
name | WRLD FULL, resolved in --language against the string tables of the plugin that wrote the last FULL, even without --markers |
cells | width, height: the image divided by pixelsPerCell. land: the LAND cells drawn |
tiles, image | The numbers of tiles.json |
render.background | lod or raster-records |
render.layers | Display labels of what was drawn: the background’s options (terrain colormap, hillshade, grass), then the layers in their drawing order (objects (texture), water, roads, light tint, lights, cell-grid), then the id of each kind of --markers (location, books) |
language, markerGroups | --language; the groups as in tiles.json with --markers, null without |
levels | With --levels, the level files the run wrote, <EditorID>.level-<k> or <EditorID>.level-<k>.pmtiles; null without --levels or for a map without stops |
loadOrder | The plugins read and the archives opened, as export.json of export:books |
plugins | Each plugin of the load order carrying the worldspace’s WRLD or one of its CELL records, the persistent cell included, see the assumption |
meta | The command and its options, see Export meta. The same in every manifest of a run |
A mod that places objects in a worldspace carries the cells it places them in, so it shows in
plugins even when it doesn’t touch the WRLD. With --parent-lod, plugins lists the
worldspace’s own plugins, not its parent’s.
Writing an index by hand
To show maps of several runs together, put each run in its own subfolder and write a maps.json
at the top that points at their manifests:
{
"maps": [
{ "editorId": "Tamriel", "manifest": "vanilla/Tamriel.json" },
{ "editorId": "Sovngarde", "manifest": "modded/Sovngarde.json" }
]
}
Each manifest keeps its own load order, and its tiles.path stays relative to the manifest.
Spec deviations and ambiguities
Every place where the code departs from a format’s reference, fills a gap the reference leaves open, or reports a problem it finds in the data. The references themselves are listed in References.
Pages
Each entry sits on one page, by kind:
| Page | Holds | Example |
|---|---|---|
| Deviations | The code contradicts what the reference states | WRLD NAM0 read as floats, not int32 |
| Assumptions | The reference is silent, incomplete or unclear, so the code picks an answer | Localized string id 0 |
| Not implemented | Documented data the code deliberately skips | VMAD fragments |
| Reported data problems | Data the code can’t use as is: what it does and why it warns | A FormId whose master is missing |
| Export heuristics | Exported values that approximate runtime game state | A book’s value, a disabled reference on a map |
How an entry is settled
Every row carries a Basis column: how the answer was established.
| Basis | Meaning |
|---|---|
| Vanilla data | Checked by running the exporter on the five vanilla masters and their archives; it holds on every case |
| Tooling | Follows xEdit or niftools, not checked independently |
| Article | Stated by a secondary source from References |
| Design | A choice the data can’t confirm or refute; the row says why it was made |
| Unverified | A best guess; the row says what to try if it proves wrong |
The order of work for a new entry:
- Read the reference page for the field (UESP,
nif.xml, SWF19). - Look for the same field in xEdit or niftools.
- Run the exporter on the game
Datafolder and check the result on every vanilla case. - Pick the page by kind, add the row with its basis, and name the tests that cover it.
When the basis is Unverified, say what you would observe if the guess is wrong.
Deviations
The code does something other than what the reference states. Basis values are defined in Spec deviations.
WRLD NAM0 and NAM9 bounds
Reference: UESP WRLD.
| Reference | Code | Why | Basis |
|---|---|---|---|
NAM0/NAM9 are int32[2], “assumed from Oblivion” | Read as float32[2] | Tamriel gives (-233472, -176128) to (253952, 208896), whole cells | Vanilla data |
The spec itself flags the type as a guess carried over from Oblivion.
Tests: WorldspaceReaderTests.
CELL XCLW no water
Reference: UESP CELL.
| Reference | Code | Why | Basis |
|---|---|---|---|
XCLW 0x7F7FFFFF and 0x4F7FFFC9 mean no water, 0xCF000000 may | Those three, NaN, and any height of 1e9 or more in magnitude mean no water | Blackreach also stores 0x4F7FFFFC (4.29e9, cell 0, 1) and 0xFF7FFFFF (-float.MaxValue); read as heights, the first floods a whole cell | Vanilla data |
No vanilla terrain or water plane comes near 1e9 units, so the threshold only catches these markers.
Tests: CellReaderTests.
Grass water mode
Reference: UESP GRAS.
| Reference | Code | Why | Basis |
|---|---|---|---|
DATA “How water distance is applied” numbered 1 to 8, from “Above - At Least” to “Either - At Most Below” | The same list numbered 0 to 7 (GrassWaterMode) | Every dry-land vanilla GRAS stores 0 with a distance of 0, which only reads as “Above - At Least” (above the water). The kelp, coral and underwater rocks store 2 with 105 to 390 units: “Below - At Least” under 0 to 7, “Above - At Most” under 1 to 8 | Vanilla data, and xEdit’s wbDefinitionsTES5.pas, whose enum starts at 0 |
The reference gives no unit for “Distance from water”. The code reads it in world units, see assumptions.
Tests: GrassReaderTests, GrassCoverTests.
Rule of One merge
Reference: How Skyrim Loads Forms. Design in Load order and merging.
| Article | Code | Why | Basis |
|---|---|---|---|
| An override clears the whole form, then reloads it | Fields merge one by one: a missing field keeps the earlier value | No exemption list exists for the records read here; readers already tolerate partial records | Design |
| Papyrus data is cleared on every override | HasScript is latest-wins | Follows the article | Article |
The engine clears a form and reloads it from each override, so a field the override doesn’t carry
becomes empty unless Bethesda’s code exempts it. The code can’t reproduce those exemptions
without a list of them, so it keeps earlier values instead. The one field the article doesn’t
cover is in XTEL across overrides.
Keying a REFR by its own FormId, independent of its cell, is not a deviation: the article lists
CELL/REFR as independently overridden parent and child. LocationMerger.MergeRecords is the
one merge every command uses, interiors included.
Tests: LocationMergerRuleOfOneTests, BookMergerFieldOverwriteTests,
InteriorCellFinderRuleOfOneTests.
VMAD string encoding
Reference: UESP File Format Conventions, xEdit What’s New, 4.0.0.
| Reference | Code | Why | Basis |
|---|---|---|---|
| Every string is Windows-1252 | VMAD script names, property names and string values are UTF-8, invalid bytes become U+FFFD | The game expects UTF-8 there | Tooling |
xEdit states that VMAD strings are “always explicitly stored as UTF8” and that “any other
codepage would result in errors” in every supported game. It gives no override, so the code has no
fallback encoding either.
Tests: VmadReaderTests.
Assumptions
The reference is silent, incomplete or unclear, so the code picks an answer. Basis values are defined in Spec deviations.
Group type 10
Reference: UESP Mod File Format. Layout in Plugin file format.
| Reference | Code | Why | Basis |
|---|---|---|---|
| The group type table stops at 9 | Type 10 (cell visible distant children) is walked like types 8 and 9 | Records under it would otherwise be missed | Tooling (xEdit) |
Tests: PluginWalkerTests.
Record types in cell children
Reference: UESP Mod File Format, record type table. The CELL page only says a cell’s children group holds its “references”.
| Question | Code | Why | Basis |
|---|---|---|---|
| Which record types can a cell’s children group (types 8, 9 and 10) hold? | REFR, ACHR, LAND, NAVM, PGRE, PHZD, the types the table places in cell subgroups. PluginWalker enters cell children only when a query asks for one of them | Skipping cell children saves most of a worldspace walk | Vanilla data: the five vanilla masters and the two Creation Club masters of the Special Edition hold no other type there |
If a plugin carries another type in cell children, add it to RecordTypeSet’s cell child list.
Tests: PluginWalkerTests.
WRLD unnamed flags
Reference: UESP WRLD.
| Reference | Code | Why | Basis |
|---|---|---|---|
DATA flag 0x04 unnamed | Kept as WorldspaceFlags.Unknown04 | Printed rather than dropped | Design |
PNAM flag 0x10 unknown | Kept as WorldspaceParentUseFlags.Unknown10 | Same | Design |
Tests: WorldspaceReaderTests.
XTEL across overrides
Reference: How Skyrim Loads Forms. The rest of the merge rules are in Rule of One merge.
| Question | Code | Why | Basis |
|---|---|---|---|
Does an override without XTEL clear the teleport? | HasTeleport is or-ed across overrides | The article doesn’t cover XTEL, so an earlier plugin’s value is kept | Unverified |
If a door loses its teleport in game after an override, switch HasTeleport to latest-wins.
Tests: LocationMergerRuleOfOneTests.
String table encoding
Reference: UESP String Table File Format. Pipeline in Localization.
| Question | Code | Why | Basis |
|---|---|---|---|
| Polish and Czech secondary encoding is “Custom” | No secondary encoding | Undocumented | Vanilla data |
| Japanese and Chinese aren’t in the table | No secondary encoding | Nothing to implement against | Vanilla data |
| Behavior when both encodings fail | Lenient UTF-8 decode, counted | Keeps the text, flags the problem | Design |
Every string table of the five vanilla masters, in all nine languages, decodes as pure UTF-8 with no fallback, so the missing secondary encodings don’t affect vanilla data. How the fallback is reported is in Reported data problems.
Tests: SkyrimStringTableTests.
Inline string encoding
Reference: UESP File Format Conventions, UESP String Table File Format, xEdit What’s New, 4.0.0. Pipeline in Localization.
The two UESP pages disagree. File Format Conventions says every string is Windows-1252. String Table File Format says the game tries UTF-8 first, then the language’s secondary encoding.
| Strings | Code | Why | Basis |
|---|---|---|---|
General: EDID, paths, TES4 author, description and masters | Windows-1252 | Follows File Format Conventions; the player never sees them | Tooling (xEdit) |
An lstring of a non-localized plugin (FULL, DESC, CNAM) | Kept as raw bytes, decoded per export language with the string table rule | The player sees them; Vominheim.esm stores them as UTF-8 | Design |
xEdit splits plugin strings the same way: “general strings” in Windows-1252, “translatable
strings” in the language’s code page. For translatable strings, xEdit uses one code page per
language (Windows-1252 for English, UTF-8 for most other languages in Special Edition). The code
tries UTF-8 first for every language instead, as String Table File Format describes. The title of
Vominheim.esm’s BOOK 63774C stores ô as the UTF-8 bytes C3 B4: read as Windows-1252,
it becomes “Blanchecôte”.
Windows-1252 text with accents is almost never valid UTF-8, so a plugin written in Windows-1252
still decodes through the fallback. A language with no secondary encoding decodes invalid bytes
leniently, see Reported data problems. The vanilla masters are
localized, so they don’t exercise this path. If the guess is wrong, Windows-1252 text that
happens to be valid UTF-8, such as é, shows as é.
Tests: BufferDecodeTests, GameTextDecoderTests, LStringResolverTests,
BookLocalizationResolverTests.
Localized string id 0
The reference doesn’t say what id 0 means.
| Question | Code | Why | Basis |
|---|---|---|---|
A BOOK FULL or DESC with id 0 | Left unresolved, not counted as missing, no warning | Id 0 is in no vanilla table; it reads as “no string” | Vanilla data |
Vanilla has 7 such fields in Skyrim.esm and 1 in Dragonborn.esm. Any other missing id is a
real problem, see Reported data problems.
Tests: BookLocalizationResolverTests.
BOOK CNAM table
The reference says .dlstrings holds “Journal/Book entries” and .strings the “general strings”,
but doesn’t list fields. See Localization.
| Question | Code | Why | Basis |
|---|---|---|---|
Which table holds a BOOK CNAM id | .dlstrings | Every non-zero vanilla id resolves there; 71 miss in .strings | Vanilla data |
Tests: BookLocalizationResolverTests.
Book teaches
Reference: UESP BOOK, DATA, and
UESP Actor Value Indices.
| Question | Code | Why | Basis |
|---|---|---|---|
Flags 0x01 and 0x04 both set | Read as a spell | No vanilla book sets both; a spell FormId is the more specific reading | Unverified |
Where the skill’s AVIF lives | Skyrim.esm, FormId from the reference’s table | Plugin data has no index to AVIF mapping | Vanilla data |
Teaches without either flag | Ignored | The reference only defines it under those flags | Design |
Vanilla has 90 skill books (18 skills, 5 each) and 116 spell tomes. Each skill book’s AVIF has the
expected EditorId (AVSmithing, and AVMysticism for Illusion). If a book with both flags
teaches its skill in game, swap the order in BookMerger.ResolveTeaches.
Tests: BookMergerBookDataTests, ActorValuesTests.
Keyword count
Reference: UESP BOOK, KSIZ and
KWDA.
| Question | Code | Why | Basis |
|---|---|---|---|
KSIZ disagrees with KWDA’s length | KWDA’s length wins; KSIZ isn’t read | The array is what’s actually there | Tooling (xEdit) |
KWDA length not a multiple of 4 | Trailing bytes ignored | A partial FormId can’t be resolved | Design |
Tests: BookReaderTests.
BSA duplicate paths
Nothing documents how several archives resolve a shared path. See BSA archive format.
| Question | Code | Why | Basis |
|---|---|---|---|
| A path in several archives | The last archive in the order wins | Mirrors the plugin load order | Design |
Vanilla archives overlap in a few places. The paths in both Skyrim - Animations.bsa and
Skyrim - Meshes0.bsa resolve to Meshes0, and those in both Textures3 and Textures8 resolve
to Textures8, the later archive each time. Each installed voices archive holds the same paths, so the last installed
one wins; the exporter reads no voice file. The book export and terrain LOD
output don’t depend on which copy wins, so vanilla data can’t confirm the rule.
Tests: ArchiveFileSystemTests, LocalizationSourceTests, FontSourceTests.
Loose files
UESP’s archive page doesn’t say how loose files and archives combine. Mod manager communities state that a loose file always wins, see the STEP forum thread on BSA extraction.
| Question | Code | Why | Basis |
|---|---|---|---|
| A path both loose and in an archive | The loose file wins, whatever the archive order | The engine checks loose files first | Article |
| Case of a loose path | Ignored | Windows file systems ignore it | Article |
| Two loose files differing only by case (Linux) | The first in ordinal order wins, the other is reported | The game on Windows sees one file | Design |
A file at the root of Data | Not a resource | Resource paths always start with a folder | Design |
With a Special Edition Data and a red Textures\Landscape\TundraRocks01.DDS, the
raster-records map of Tamriel shows the Whiterun tundra in red, and a broken loose copy of a
book’s menu art NIF is reported unreadable by export:books.
Tests: ArchiveFileSystemTests, LocalizationSourceTests, GameSessionTests.
File name block padding
The spec gives totalFileNameLength as the total length of all file names, with their \0.
Vanilla MarketplaceTextures.bsa counts 9 more \0 bytes after its last name.
| Question | Code | Why | Basis |
|---|---|---|---|
\0 bytes after the last name, inside totalFileNameLength | Skipped as padding | A Bethesda archive has them, and the folder record offsets count them | Vanilla data |
| Any other byte there, or fewer names than files | The archive is rejected | The names and the file records no longer line up | Design |
The block is read in one call of totalFileNameLength bytes, so this length has to be right.
Tests: BsaListingReaderTests.
Plugin archives
The engine loads the archives named after each plugin along with it. The name rule is stated by forum posts, not by UESP: see the Steam discussion and Auto BSA.
| Question | Code | Why | Basis |
|---|---|---|---|
| Which archives a plugin loads | <plugin>.bsa and <plugin> - Textures.bsa | Both names are in SkyrimSE.exe | Article |
| Their order | <plugin>.bsa first | No source states it | Unverified |
| Their place among archives | After the vanilla archives, in plugin order | The ini archives load first | Article |
| Vanilla masters | No plugin archive | They ship in the shared Skyrim - *.bsa archives | Vanilla data |
If a mod ships a file in both archives and the wrong copy shows up, swap the order in
Game/Vanilla/Archives.PluginArchiveFileNames.
Tests: LoadOrderTests, CustomLoadOrderTests, GameSourceTests.
Book markup conventions
Book markup and fontconfig*.txt have no published spec. The parsers follow what vanilla data
contains. See Book markup assets and
Font export.
| Question | Code | Why | Basis |
|---|---|---|---|
fontconfig*.txt syntax | Parsed as the vanilla files write it | No published format | Vanilla data |
| A texture spelled with different casing | The file uses the archive entry’s casing | Keeps names independent of processing order | Design |
Unit of <font size> and <img width height> | Flash stage pixels of the book text field | book.swf’s page field writes its 22 px font height as size="22"; a 296×278 image fills its 296 px text width | Vanilla data |
Size of an <img> without width and height | A 64 × 64 px box, aspect ratio ignored | Two unsized QA book images of different sizes both measure about 64 × 62 in-game | Unverified: measured on one 1080p screenshot. If wrong, unsized drop caps look larger or smaller than in-game |
Both are applied by the generator, see Book page geometry. Faces and assets the data points at but doesn’t ship are in Reported data problems.
Tests: FontConfigParserTests, MenuArtTextureConverterTests, BookContentSanitizerTests.
Terrain LOD tiles
The lodsettings\<worldspace>.lod layout follows its
UESP page, see
LOD settings. The
<worldspace>.<level>.<x>.<y>.dds names under textures\terrain\<worldspace>\ are an archive
path convention, not record data: no UESP page covers them, and the code follows the
DynDOLOD terrain LOD page and xEdit. See
debug:*:archive:terrain-lod.
| Question | Code | Why | Basis |
|---|---|---|---|
| Tile naming | Level, then the tile’s south-west cell X and Y | Stated by DynDOLOD; matches every tile in the vanilla texture archives | Vanilla data |
| Grid origin | The lodsettings left/bottom cell, not zero | xEdit’s BlockForCell aligns on it; Blackreach (-23, -9) and Sovngarde (-24, -32) tiles only line up this way | Vanilla data |
| Cell to tile | Tiles step by the level from the origin | Same formula as xEdit’s BlockForCell; every expected tile of the 12 worldspaces with LOD exists at every level they generate | Vanilla data |
.lod stride_pow2 | The grid side in cells, itself a power of two, not an exponent | The spec gives only the field name; xEdit reads it as a stride; the 12 vanilla files hold 16 to 256, all powers of two | Vanilla data |
.lod file size | Exactly 16 bytes, anything else rejected | The spec’s struct is the whole file; xEdit rejects any other size; every vanilla file is 16 bytes | Vanilla data |
| Tile orientation | Grid Y grows north, a DDS’s first row is its north edge | Stitched Tamriel is seamless and north-up | Vanilla data |
| X8R8G8B8 tiles | The fourth byte is padding, drawn opaque | Solstheim tiles have DDPF_RGB without DDPF_ALPHAPIXELS and a zero padding byte | Vanilla data |
_n.dds normal encoding | World space: red east, green up, blue north, each byte mapped to -1..1 | See below | Vanilla data |
Cells without LAND | Not part of the worldspace, cleared by --crop-to-playable | Vanilla tiles are black there (MarkarthWorld) | Vanilla data |
| Playable area | Overlap of the NAVM cell bounds and the non-persistent REFR/ACHR cell bounds, plus one cell | Either box alone keeps filler or scenery, see below | Design |
| Persistent references | Not counted toward a cell | Vanilla stores them in the worldspace’s persistent cell, a CELL with flag 0x400 and XCLC 0, 0 (Tamriel, MarkarthWorld, Blackreach, Sovngarde) | Vanilla data |
| Water surface | A cell with DATA “Has Water” has water at its XCLW, or at the WRLD DNAM default water height when XCLW is absent or means no water | The spec defines each field, not how they combine; the result draws Tamriel’s sea, rivers and lakes and Solstheim’s sea where they are in game | Vanilla data |
| Child worldspace cell coordinates | A child worldspace’s cells sit at the same grid coordinates as its WNAM parent’s, so --parent-lod draws them with the parent’s tiles (lod) or fills their holes with its LAND (raster-records) | The spec only says PNAM “Use LOD Data” inherits the parent’s LOD; in game, that LOD is what shows in the holes. ONAM places a child’s map markers on its parent’s map; the five vanilla worldspaces drawn with --parent-lod set it to scale 1 and offsets 0, and line up with their place on Tamriel’s map | Vanilla data |
| Water across cells | Each cell’s water is a flat plane at its own height | Matches the data; neighbouring cells with different XCLW show a straight edge (Blackreach) | Vanilla data |
LAND without VHGT | Flat at the worldspace’s DNAM default land height (its parent’s with “Use Land Data”); left out of the water when no DNAM applies | The spec doesn’t say how such a cell is drawn. In 12 of the 14 vanilla worldspaces with one, and in the Vominheim mod (945 of 2096 cells), every neighbouring vertex sits at that height | Vanilla data, two exceptions below |
Two vanilla worldspaces don’t fit the LAND without VHGT rule. MarkarthWorld’s cell (-46, -2) has
neighbours near 11000 and a default of -27000: drawn flat, it is a deep pit under the sea’s water
height, outside the playable crop. FallowstoneCaveWorldStart’s cells (-1, -3) and (-2, -3) have
neighbours at 2000 and a default of 100, above their water at 0, so they show no water either way.
Rounding each cell down to a multiple of the level only matches worldspaces whose origin is itself a multiple of 32 (Tamriel, Solstheim), and finds none of Blackreach’s tiles.
No published source documents the terrain LOD normal maps. The flat areas of the vanilla tiles (sea, cells
without LAND) are (128, 255, 128), so green is up. Two checks on the level-32 tiles of Tamriel and Solstheim fix
the other axes:
- A slope field has no curl only with the right axes. Reading red as east and blue as north (or both negated) gives the lowest total curl; swapping the channels or negating one of them gives 1.6 to 2.6 times more.
- Integrating the slopes of Solstheim from the sea inward gives land above sea level with red east and blue north, and below it with both negated. That holds along rows and along columns.
No field marks the playable part of a worldspace. WRLD MNAM only exists on Tamriel and
Solstheim, and NAM0/NAM9 span every LAND cell. Two signals were compared on the 12 vanilla
worldspaces with LOD:
- The bounds of the cells with a navmesh match the walkable area of Tamriel (
-48..52,-34..45against-57..61,-43..46forLAND) and Solstheim. Sovngarde has single-cell columns of navmesh across its filler terrain, which stretch the bounds over it. - The bounds of the cells with placed references match Sovngarde’s valley (
0..30,0..31), but include Tamriel’s border mountains and a few isolated cells (Blackreach-18).
Their overlap keeps the valley of Sovngarde and the walkable area of Tamriel. A worldspace built
mostly from objects comes out small: MarkarthWorld’s navmeshes cover 2x3 of its 140 LAND cells.
Tests: TerrainLodGridTests, WorldspaceCellsTests, LodSettingsReaderTests, TerrainLodSettingsLoaderTests,
LodRasterTests, DdsDecoderTests, TerrainLodNormalsTests,
MapCropTests, TerrainLodTileSourceTests, WorldspaceTerrainTests, WaterLayerTests,
LodTileTests, MapProjectionTests, WorldspaceLodSourceTests, MapPlannerTests.
LAND texture layers
Reference: UESP LAND,
UESP LTEX,
UESP TXST. The Skyrim LAND page lists
VTXT as “a variable length list of 8 byte records” without a layout; the
Oblivion LAND page gives one. Layout
in Plugin file format.
| Question | Code | Why | Basis |
|---|---|---|---|
VTXT layout | uint16 position, 2 unknown bytes, float32 opacity | The Oblivion page’s layout; the Skyrim page gives the same 8-byte size | Vanilla data: every position is 0 to 288 and every opacity 0 to 1 |
VTXT position | Row by row from the quadrant’s south-west point, 17 points per row | Stated by the Oblivion page | Vanilla data: textures line up with the rivers the water layer draws from VHGT |
| Quadrant points on the cell grid | A quadrant’s 17x17 points are vertices of the 33x33 VHGT grid; neighbouring quadrants share their middle row or column | 17 + 16 = 33: the only way two quadrants fill the cell’s vertices | Vanilla data: blended this way, two cells agree on their shared edge 10 times better than with the grid transposed, flipped or its quadrants swapped (Tamriel, and the Vominheim mod) |
| Shared vertex | Each layer is blended in layer order over every quadrant; the base texture of the later quadrant wins on a shared row or column | The pages don’t say which quadrant owns it | Design |
VCLR grid | Rows south to north, columns west to east, like VHGT | The Skyrim page says only “the same as Oblivion”; the Oblivion page gives no order | Vanilla data: on Tamriel, neighbouring cells agree on their shared edge colors (mean difference 0.05 per vertex out of 765), against 35 to 71 with the grid flipped or transposed |
TX00 path | Relative to textures\ | The TXST page gives no root; vanilla paths start with Landscape\ | Vanilla data: 90 of 91 LTEX color maps found this way, the last has no TNAM |
| Default texture | textures\landscape\dirt02.dds | The BTXT row names only dirt02.dds | Vanilla data: the file exists there |
Quadrant without BTXT | The default texture, as for a zero LTEX | The page gives the default only for a zero formid | Design |
Several VTXT after one ATXT | Their points are appended to that layer | The pages describe one VTXT per ATXT | Design |
Tests: LandscapeReaderTests, WorldspaceLandscapesTests, LandscapeRasterizerTests,
LandscapePaletteTests.
LAND texture tiling
Reference: UESP LAND, UESP LTEX, UESP TXST. None of them says how often a landscape texture repeats: the scale is an engine setting, not a field.
| Question | Code | Why | Basis |
|---|---|---|---|
| Repeats per cell | 24, 12 per quadrant | fLandTextureTilingMult defaults to 3, applied as 3 / 4 per vertex step: 32 x 3 / 4 | Mudcrab PR 91, from a static inspection of SkyrimSE.exe |
| Origin | Repeats line up with cell edges, no mirroring | 24 is whole, so every cell starts a repeat | Same source |
| Orientation | The color map’s first row is the north edge of a repeat | Not stated | Design: the pattern is too small on a map to tell |
An .ini that changes fLandTextureTilingMult changes the game, not the map.
Tests: LandscapeRasterizerTests.
Landscape normal maps
Reference: UESP TXST. TX01 is a
“normal map (tangent- or model-space)” and DNAM 0x04 marks a model-space one. The page doesn’t say
how a tangent-space map lies on the ground.
| Question | Code | Why | Basis |
|---|---|---|---|
| Tangent frame on a landscape texture | Red along the color map’s columns, east; green down its rows, south (the DirectX convention) | A tangent-space normal map is the gradient of a surface: read in the right frame, its curl is close to 0 | Article: Beyond Skyrim, Baking, “Skyrim uses DirectX”. Vanilla data: on 10 textures\landscape\*_n.dds, the curl read this way is 1.2 to 4.9 times smaller than with green toward the north, on every one |
| Up component | Blue, or rebuilt from red and green where that is higher | DXT5 compression leaves vectors off unit length: red and green alone would lay a tilted texel flat. A BC5 map stores no blue | Vanilla data: the 50 textures\landscape\*_n.dds are DXT5; on 4 of them, 0.1 to 3.5% of texels have red and green squared summing over 1, with blue still 0.24 to 0.48 up |
| Scale and placement | Those of the color map, see LAND texture tiling | One TXST maps both on the same coordinates | Design |
Model-space map (DNAM 0x04) | Not read | Its normals are in the model’s frame, not the texture’s | Vanilla data: none of the 90 landscape TXST with a TX01 sets it |
Tests: LandscapeBackgroundTests, LandscapeTextureReaderTests.
Object normal maps
References: nif.xml BSShaderTextureSet names slot 1 ‘Normal/Gloss’ and BSVertexDataSSE stores a
tangent and a bitangent per vertex, without saying how a texel lies along them. Community Shaders’
Lighting.hlsl builds the frame its pixel shader multiplies the texel by from the bitangent (its
first row), the tangent, then the normal.
| Question | Code | Why | Basis |
|---|---|---|---|
| Tangent frame of a texel | Red along the vertex bitangent, green along the tangent, blue along the normal, each axis blended over the face and brought to unit length first | The shader does so: its frame’s rows are the bitangent read from the position’s W, the normal’s and the tangent’s fourth bytes, then the tangent, then the normal | Tooling: Community Shaders Lighting.hlsl. Vanilla data: on every shape of Tamriel’s placed models with a normal map, weighted by area and placements, the bitangent runs along +u and the tangent along +v (down the texture’s rows); the green therefore runs down the rows, the DirectX convention of Landscape normal maps. The curl test there, on the 200 most placed object normal maps, is lower read so on 190 of them (median ratio 1.45); the others are atlases whose islands are turned or mirrored, which the vertex frame follows |
| Texel to direction | 2 b / 255 - 1 on red, green and blue, then the sum brought to unit length | The shader reads the texel as 0 to 1 and computes 2 c - 1, without rebuilding blue | Tooling: Community Shaders Lighting.hlsl TransformNormal |
| Strength | Half the texel’s tilt, a style choice of Map shading | The shader takes the whole tilt, under its own light | Design |
Model-space map (Model_Space_Normals) | Not laid, see not implemented | Its normals are in the model’s frame, not the vertices’ | Vanilla data: none of the 8,981 shapes with a normal map placed on Tamriel sets it |
Tests: NifSceneReaderTests.LightingShader_GivesSlotOneAsItsNormalMap,
ObjectRasterizerTests.NormalMapTexel_TiltsTheSurface, ObjectsLayerTests.NormalMapInTheArchives_BendsTheTexturedSquare.
Emissive shapes
References: nif.xml gives Emissive Color, Emissive Multiple and slot 2 of the texture set, not what the
engine does with them. Community Shaders’s Lighting.hlsl gives the pixel shader. Nothing
here was compared with a capture in game.
| Reference | Code | Why | Basis |
|---|---|---|---|
diffuseColor += emitColor, then diffuseColor times the base color, then the vertex colors | The emission is a term on the pixel’s color, added once the map’s light is applied (FaceShader.Emitted) | The map’s light is no sum of lights: a term added after it reads the same | Lighting.hlsl |
emitColor takes the glow map on the Glowmap technique alone | Slot 2 weighs the emission on shader type 2 (Glow) only | Vanilla Default shapes, candles and plants, hold a texture in slot 2 and still emit whole: on Tamriel, the Glow type and the Glow_Map flag go together on every shape | Lighting.hlsl, vanilla scan |
Without Linear Lighting, LinearToSrgb(SrgbToLinear(emit) × SrgbToLinear(glow)) | A plain product emit × glow of the bytes | A power law is multiplicative: both agree but for sRGB’s linear toe, on near-black texels | Lighting.hlsl |
Own_Emit (flag 1 bit 22) “provides its own emittance color” | Not read | Set on every placed lighting shape of Tamriel: it tells nothing apart | Vanilla scan |
A Glow shape without a slot 2 | Emits nothing | What the engine binds there isn’t known; one placed reference of Tamriel, and lighting it whole risks a bright shape | Design |
| A glow map missing from the archives | Emits nothing, logged | As above | Design |
Tests: EmissiveLayerTests, NifSceneReaderTests.LightingShader_GivesItsEmission.
Projected materials
References: UESP STAT and
MATO give the fields, not what the engine does
with them. xEdit gives their layout by form version. Community Shaders’s Lighting.hlsl
gives the pixel shader. How a record’s fields reach the shader’s constants comes from third-party plugins that
hook the engine, cited below. Nothing here was compared with a capture in game.
The pixel’s weight and how much of the material it shows:
threshold = cos(Max Angle) + (1 - cos(Max Angle)) × (Falloff Bias + Falloff Scale × noise)
weight = dot(normal, up) × vertex alpha - threshold
mix = smoothstep(0, 1, 5 × (0.1 + weight))
| Question | Code | Why | Basis |
|---|---|---|---|
MATO DATA size | 28, 32, 48 or 52 bytes tell the fields present; under 28 is dropped | UESP lists 48 bytes and “a small number of 32/28”. xEdit adds Is Snow, form 43 in SSE | Vanilla data: 28, 32, 48 and 52 occur; xEdit |
STAT DNAM size | 8 or 12 bytes, Considered Snow read from the ninth | UESP gives 8 bytes, xEdit adds Considered Snow and 3 unused in SSE | Vanilla data: 11 914 of 8 bytes, 384 of 12 |
Which MATO the map draws | Those with Single Pass set | The other path builds a second geometry from the record’s DNAM properties | Tooling: XPMF MaterialMatcher.hpp |
| Which records take one | STAT only | The engine applies it from the static’s data when it clones its model | Tooling: XPMF, CommonLibSSE TESObjectSTAT |
| Field to constant | (1 - cos) × Falloff Scale scales the noise, (1 - cos) × Falloff Bias + cos is the threshold, 1 / Noise UV Scale tiles the noise, the color is Single Pass Color | The shader names only ProjectedUVParams; PapyrusExtender and Seasons of Skyrim write (scale, bias, 1 / noise, cos(angle)), XPMF describes what the engine makes of it | Tooling: Lighting.hlsl, PapyrusExtenderSSE ApplyMaterialShader, XPMF |
| Direction | Straight up in the world. Projection Vector isn’t read | The single pass path doesn’t read it (XPMF). Read as a direction, 13 459 of Tamriel’s rocks, at (0, 0, -1), would hold their snow underneath, beside SnowMaterialMountain1P at (0, 0, 1) | Tooling: XPMF. Vanilla data, as a check |
| The record’s model | Not read: four textures under textures\effects\ | The engine loads them from fixed paths; ShaderTests\ShaderBox.nif, the model of most MATO, isn’t in the archives | Tooling: XPMF, strings of SkyrimSE.exe. Vanilla data: the four are in Skyrim - Textures5.bsa |
| Vertex alpha | The vertex color’s alpha, whatever Vertex_Alpha says | The shader reads the vertex’s color. Of 2 667 shapes on Tamriel’s single pass models, 566 set the flag and 433 paint an alpha under 250 | Tooling: Lighting.hlsl. Vanilla data, for how often it matters |
| A blended shape’s vertex alpha | Vertex_Alpha only, as its opacity reads it | One value per vertex carries both | Design |
| Color | ProjectedDiffuse × Single Pass Color, toned as a texture | The shader multiplies them. Toned, SnowMaterialObject1P gives (140, 147, 155), LSnow01 of the ground (134, 142, 151) | Tooling: Lighting.hlsl. Vanilla data, for the match |
| Texture coordinates | World east and north over the tile, a plane seen from above | Community Shaders samples three planes by the normal; vanilla computes them from TextureProj, not documented. Seen straight down, a plane never stretches | Design |
| Tiling | Noise Noise UV Scale units per tile, diffuse and normal 5 times that, detail normal 1.25 times | fProjectedUVDiffuseNormalTilingScale 0.2 and fProjectedUVNormalDetailTilingScale 0.8 of a generated SkyrimPrefs.ini; the Creation Kit’s are 0.5 and 1.2 | Vanilla data, for the INI |
| Normal | Normal and detail normal combined as the shader does, in a frame built on the unbent vertex normal, then blended by mix, at half tilt | The shader blends in the shape’s tangent space, so a slope stays a slope. A noise has no direction a frame’s turn could show. The strength is the object normal maps’ style | Tooling: Lighting.hlsl |
| Mip level | From the map’s scale | The noise tiles finer than a pixel at a low scale, where its mean is what shows | Design |
Considered Snow, Is Snow | Read, not used | Neither enters the color or the weight of a map’s pixel | Tooling: Lighting.hlsl |
Tests: ProjectedMaterialTests, DirectionalMaterialReaderTests, ModeledObjectReaderTests,
DirectionalMaterialsTests, ObjectsLayerTests.ProjectedMaterials_CoverTheStatic.
Grass density and slope
Reference: UESP GRAS,
UESP LTEX. The GRAS page gives DATA
Density, Min Slope and Max Slope as uint8 without a unit or a range; the LTEX page says only “Possible
Grass” for GNAM.
| Question | Code | Why | Basis |
|---|---|---|---|
| Density | A percentage, 0 to 100 | No vanilla value goes past 100 | Vanilla data: the 31 GRAS after Update.esm range from 10 to 90. Unverified as a scale: if the engine reads it otherwise, the map’s coverage is off by that factor |
| Min Slope and Max Slope | Degrees from horizontal, both inclusive | A slope in degrees fits a uint8 | Vanilla data: Min Slope is 0 on every GRAS, Max Slope 10 to 90, most 33 to 50, which matches grass leaving cliffs. Unverified as a unit: if wrong, grass would show on cliffs or miss gentle slopes |
Several GNAM | Every one grows, in any order | The page doesn’t say whether GNAM repeats or in which order | Design |
The same GRAS in two GNAM | Counts once | A second entry adds no new grass | Design |
Tests: GrassReaderTests, GrassCoverTests.
Grass water distance
Reference: UESP GRAS. The page gives
DATA “Distance from water” as a uint16 and the modes that apply it, without a unit or a meaning for
each mode. The numbering of the modes is a deviation.
| Question | Code | Why | Basis |
|---|---|---|---|
| Distance from water | World units between the ground and its cell’s water height | The ground height and the water height are in world units | Vanilla data: kelp 274 units tall needs 390 under water, coral 155, underwater rocks 105. Unverified |
| Above, Below | The ground stands over, or under, the water height | The names | Design |
| At Least, At Most | The ground is that far from the water or farther, or that close or closer, both inclusive | The names | Design |
| Either - At Most Above, Either - At Most Below | Any ground on the other side of the water, or ground on that side at most that far | The names | Design |
A cell without water (XCLW absent or a no-water value, no worldspace DNAM) | All its ground is above the water, infinitely far | Nothing to stand under | Design |
| A mode past 7 | No water rule | No mode to apply | Design: no vanilla GRAS has one |
Water from placed objects (WATR references) | Not counted | The cell’s water height is the only one the background reads | Design: a grass may grow in a placed pond |
Tests: GrassCoverTests, GrassTuftsTests.
Navmesh triangle flags
Reference: UESP NVNM. The page calls the triangle’s third uint16 field “Cover marker?”, “usually 0x0008 or 0x0408”, and names none of its bits. Layout in Plugin file format.
| Question | Code | Why | Basis |
|---|---|---|---|
| Which bit marks a road or a trail | 0x0040, “Preferred” (NavmeshTriangleFlags.Preferred) | xEdit’s name for the bit | Tooling, and vanilla data: Tamriel’s 52,367 such triangles draw its road network, and the STAT road pieces fall on them |
An NVNM with a bad count or vertex index | The whole navmesh is dropped, with a warning | A partial read could draw triangles from shifted bytes | Design: no vanilla NAVM has one |
| What a vertex’s X, Y and Z are | World units, Z the height, in the frame of the worldspace or interior cell | The page names the three floats without a unit or frame | Vanilla data: the road triangles fall on the STAT road pieces placed in world units, and a cut 160 units above the navmesh heights shows the floors of Blackreach and of the vanilla interiors |
| Where an actor can walk | On every triangle of a NAVM, whatever its flags: the map levels take each one, with its heights, as walkable floor (WorldspaceMapReads.Navmeshes) | The navmesh is what the AI walks on; the spec names no flag that marks a triangle as not walkable | Design |
On a mod, the bit can cover only part of the roads: Vominheim marks 3,776 triangles. The roads layer also draws the road pieces, see export heuristics.
Tests: NavmeshReaderTests, WorldspacePathsTests, WorldspaceNavmeshesTests.
Reference header flags
Reference: UESP Mod File Format, record
flags, and UESP REFR. The format page
gives a REFR two “Hidden from local map” bits, 0x40 (“Needs Confirmation”) and 0x200, and
also calls 0x200 “MotionBlurCastsShadows”. The REFR page lists only 0x200.
| Question | Code | Why | Basis |
|---|---|---|---|
| Which bit hides a reference from the local map | 0x200 when the base is an ACTI, STAT or TREE, 0x40 when it is a DOOR, none for other bases (ReferenceFlags.IsHiddenFromLocalMap) | xEdit names a REFR’s flags by its base’s type: 0x200 is “Cast Shadows” on a LIGH, “Motion Blur” on an MSTT | Tooling, and vanilla data |
What the maps keep of a REFR’s flags | All of them, as read (Placement.HeaderFlags) | The base’s type is known only after the merge | Design |
On the five vanilla masters and two mods, 619 enabled exterior references carry 0x200: 534 STAT,
80 TREE, 1 ACTI, 3 LIGH and 1 MSTT. Most are cave ceiling rocks and ship beams and decks in
underground worldspaces (MossMotherCavernWorld, KatariahWorld), which would hide the floor seen from
above. Of the 39 that carry 0x40, 3 are doors; the others are bases where xEdit gives the bit no
meaning.
Tests: ReferenceFlagsTests, WorldspaceMapQueryPathsAndPlacementsTests.
Reference footprint
Reference: UESP REFR (DATA: position,
then rotation in radians; XSCL: “setScale”) and
UESP OBND. The pages don’t say
how the rotation applies to the bounds or the model.
| Question | Code | Why | Basis |
|---|---|---|---|
| Direction of the Z rotation | Clockwise seen from above (PlacementRotation.TurnZ) | The pages give no direction | Vanilla data: the road pieces’ boxes fall on the preferred navmesh triangles of Tamriel |
X and Y rotations of a model (--objects) | Clockwise seen from the positive end of their axis, like Z; Z turns the point first, then Y, then X (RotationConvention.Default) | The pages give no direction nor order | Vanilla data: the convention that lays the road pieces on the terrain, see below |
X and Y rotations of a box (--roads) | Ignored: the box is drawn flat, turned by Z only | Road pieces lie almost flat, a small tilt barely moves their footprint | Design |
XSCL absent | Scale 1 | The page gives no default | Vanilla data: road pieces without XSCL fall on the preferred triangles at scale 1 |
OBND origin | The reference’s position, before scaling | The bounds are in the object’s own space | Vanilla data: same check as the rotation |
If the Z direction were wrong, turned road pieces would cross the navmesh roads at an angle instead of following them.
Road pieces follow the slope they are laid on: of the 5,500 on Tamriel, 4,910 have an X or Y
rotation. Each vertex of their models was moved into the world under each candidate convention and
compared with the LAND height under it, bilinear between the vertices:
| Convention | Median distance to the terrain |
|---|---|
| Clockwise X and Y, Z first (kept) | 12.6 units |
| The six other directions and orders | 25.6 to 48.1 units |
| X and Y ignored | 28.6 units |
| Rz·Ry·Rx, counterclockwise | 34.6 units |
Tests: PlacementRotationTests, RoadsLayerTests, ReferenceReaderTests, ModeledObjectReaderTests.
Light radius
Reference: UESP REFR gives XRDS as a
float, “~1.25. Controls the radii on objects like lights”;
UESP LIGH gives DATA Radius as a
uint32. The page doesn’t say how XRDS combines with the base’s radius.
| Question | Code | Why | Basis |
|---|---|---|---|
What a light’s XRDS holds | An offset added to its LIGH radius (LightsLayer) | The “~1.25” reads as a scale, but the vanilla values don’t fit one: negative values are common, and none brings the radius to 0 or below once added | Vanilla data: 1,489 of the 1,680 lights placed in worldspaces carry one, from -665 to 6,919 (one outlier at 456,444, see data problems); 298 are negative; radius plus XRDS is never 0 or less. Unverified as semantics: if it scaled the radius, the map’s glows would be far larger than the game’s lights |
A radius plus XRDS of 0 or less | No glow | A light with no reach lights nothing | Design: no vanilla light has one |
Tests: ReferenceReaderTests, LightsLayerTests.
Armor ground model
Reference: UESP ARMO. The page lists
MODL twice: once as a model, near the top, and once as the FormID of an ARMA armature, repeated.
MOD2 is the male model and MOD4 the female one.
| Question | Code | Why | Basis |
|---|---|---|---|
Which MODL an ARMO holds | Every MODL of an ARMO is an ARMA FormID, never read as a path | Read as a path, the FormID gives 3 bytes of noise | Vanilla data: the 137 ARMO bases placed in a worldspace have only 4-byte MODL |
The model of an ARMO placed in the world | MOD2, else MOD4 (ModeledObjectReader) | A placed armor lies on the ground with its male model | Vanilla data: all 137 have a MOD2 found in the archives |
If the armature MODL were ever a path, a placed armor would be missing from --objects, and its
MOD2 would show instead.
Tests: ModeledObjectReaderTests.
NIF and Havok shapes
Reference: niftools’ nif.xml. Layout in
NIF / Havok format.
| Question | Code | Why | Basis |
|---|---|---|---|
Which column of bhkConvexTransformShape’s matrix holds the translation | The last column | No source states it | Unverified |
hkPackedNiTriStripsData vertices “may not be standard half-precision” | IEEE 754 half floats | What other tooling uses | Tooling |
bhkCompressedMeshShapeData chunk vertex composition order | Chunk translation, then the chunk transform | Most chunks use an identity transform | Unverified |
| Havok scale and Euler order | 69.9915 and Rz·Ry·Rx | Tooling conventions, not derived here | Tooling |
NiAVObject rotation: nif.xml calls Matrix33 column-major but doesn’t say how a point is multiplied | The nine floats read as rows, applied to column vectors | Visual meshes then line up with their collision, see below | Vanilla data |
BSVertexDesc offset unit, which nif.xml doesn’t state | 4 bytes, like the vertex size | Every UV offset is then 16 bytes, right after the position and its fourth float; the color offsets read gray to white colors on rocks and blue-green ones on waterfall bodies | Vanilla data |
| Editor-only geometry, which nif.xml doesn’t mark | A node or BSTriShape named EditorMarker is left out with its subtree | The name is a convention of the Creation Kit and NIF tooling | Tooling |
NiAVObject Flags bits, which nif.xml doesn’t define for BS version 100: only NiBillboardNode’s description names bit 0 “hidden” | Bit 0 hides the block and its subtree | Every vanilla shape that sets it is a helper the game doesn’t show: particle emitter meshes, forge markers, spare weapon parts | Vanilla data: 4,444 placed shapes on vanilla worldspaces |
The order of BSLightingShaderProperty UV Scale and UV Offset, which nif.xml doesn’t state | uv × UV Scale + UV Offset | NifSkope’s Skyrim shaders do the same | Tooling |
The direction of v in a HalfTexCoord | v = 0 is the texture’s first row, v grows down the rows | Direct3D’s convention, which the game renders with | Design |
| How a skinned vertex is posed, which nif.xml doesn’t state | The sum of its weighted bones, each bone’s skin transform then its node’s transform to the model’s space; the overall skin transform and the shape’s own transform left out | NifSkope poses a BS version 100 shape so. Bones not saved in their bind pose give a different shape than the raw positions: the OBND of TreePineForest04 matches the raw positions, 1,100 units of its trunk under the ground, and the posed trunk stands on it | Tooling, NifSceneReaderTests.SkinnedShape_TakesItsGeometryFromItsPartitionPosedByItsBones |
The order of NiSkinData rotations, which nif.xml calls Matrix33 like NiAVObject’s | Read as NiAVObject’s | With it, 766 of the 916 skinned models outside armor and clothes pose as their raw positions; transposed, every vertex of TreePineForest04, TreeAspen01 and TreeAspen02 moves, by up to 1,400 to 2,900 units | Vanilla data |
| Whose bones a vertex’s Bone Indices point at, which nif.xml doesn’t state | The skin instance’s bones | In the vanilla trees, every weighted influence of a partition, through its own bone list, names the same instance bone as the vertex data: 85,733 influences | Vanilla data |
Which triangles of a SkinPartition to read | Triangles Copy, the SSE field, which indexes the shared vertex data | Triangles holds the same values in all 6,585 partitions of the vanilla skinned models | Vanilla data |
| A skinned vertex whose weights add up to 0 | Placed by the shape’s own transform | Blended by no bone it would fall to the origin | Design, NifSceneReaderTests.SkinnedVertexWithoutWeight_KeepsTheShapePlacement |
How a normbyte maps to -1 to 1: nif.xml says only “[0, 255] to [-1, 1]” | byte × 2 / 255 − 1, linear | Community Shaders’ Lighting.hlsl vertex shader computes -1 + 2 × value from the bytes read as 0 to 1. Decoded so, vertex normals lie a median 0.3° to 4° from their faces’ | Tooling and vanilla data: rocks, trees, Windhelm, Riften and imperial dungeons, NifSceneReaderTests.Shape_ReadsNormalsTangentsAndBitangents |
| How a skinned vertex’s normal is posed, which nif.xml doesn’t state | Each weighted bone’s rotation, blended by the weights, back to unit length; the shape’s own rotation for a vertex without weight | As its position; the scale of a bone doesn’t turn a direction. Posed so, the normals of the vanilla trees lie a median 3.4° from their posed faces | Vanilla data, NifSceneReaderTests.SkinnedShape_TurnsItsNormalsByItsBones |
Which child of a NiSwitchNode to draw: nif.xml says one “active child” is drawn, and the game can change it at run time | The child at its stored Index; none when Index is past its children | A map shows the state the model is saved in, without knowing what each child means. Harvestable plants store their unharvested state at index 0 | Vanilla data: the 80 meshes\plants\ models with a switch node all have two children and index 0, covered by NifSceneReaderTests.SwitchNode_DrawsOnlyItsActiveChild |
| The opacity a blended shape outputs, which nif.xml describes only as the lighting shader’s Alpha being “the material opacity” | Texel alpha × vertex alpha (with Vertex_Alpha) × material Alpha, clamped to 0 to 1 | An Alpha above 1 then keeps a face opaque longer as its vertex alpha falls, as nif.xml says | Unverified: if wrong, Markarth’s waterfall bodies (Alpha 0.9, vertex alpha about 120) show the rock under them more or less than in game, ObjectRasterizerTests.Draw_BlendedShape_MixesWithWhatLiesUnder |
The blend equation, which nif.xml names only by its AlphaFunction factors | color × source factor + pixel × destination factor, clamped to 0 to 1 after each face; the destination alpha counts as 1 | The Direct3D blend the game renders with; the map is opaque | Design, ObjectRasterizerTests.Draw_BlendedShape_MixesWithWhatLiesUnder |
An AlphaFunction value past 10, which nif.xml doesn’t define | Counts as ONE | No vanilla shape uses one: they use 6/7, 6/0 and 1/2 | Vanilla data |
| The order the game draws blended shapes in | Over each pixel, from the lowest face up; at one height, in the order of the references, then of the triangles | The game sorts them back to front from the camera, here straight above | Design, ObjectRasterizerTests.Draw_BlendedShapes_MixFromTheLowestUp |
| How an effect shader computes its color and alpha, which nif.xml doesn’t state | As NifSkope’s sk_effectshader.frag: texture × vertex colors × base color × scale, or a palette lookup; alpha × falloff × base alpha squared | The only renderer of these fields at hand | Tooling, ObjectRasterizerTests.Draw_EffectShape_* |
| Equal falloff start and stop angles, where GLSL’s smoothstep is undefined | A step: the stop opacity below the angle, the start opacity from it | NifSkope notes the case without settling it | Design |
| Whether the map’s light shades an effect shape | Not shaded | NifSkope’s effect shader reads no light; the effects glow or show their own colors | Tooling, ObjectRasterizerTests.Draw_EffectShape_IsNotShadedByTheMapLight |
| The texture coordinate a palette lookup reads | The texture’s green as the DDS stores it, the map’s tone left out | The tone would move it along the palette | Design, ObjectsLayerTests.Texture_EffectLooksItsColorUpInItsPaletteByTheUntonedGreen |
If wrong, the footprints HavokShapeReader returns are off:
- Shapes behind a
bhkConvexTransformShapelook offset: try the last row. - Rotated compressed mesh chunks look displaced: apply the transform before the translation.
The NiAVObject convention was checked on every NIF of the Anniversary Edition archives and two
mods. For the 241 models with an identity root, a rotated node or shape below it and a root
collision, the bounding box of the visual mesh was compared with the collision’s under both
readings. 148 fit better as read, 21 transposed (animated and effect meshes, whose collision
doesn’t follow the visual mesh), 72 tie. With the wrong reading, rotated parts of a model would turn
the wrong way on the map.
hkPackedNiTriStripsData is almost absent from vanilla interiors, so the half-float reading has
little effect either way. Shapes the code doesn’t read are in
Not implemented.
Tests: HavokShapeReaderTests, NifReaderTests, NifBlockReaderTests, NifSceneReaderTests,
ObjectRasterizerTests.
Face winding
Reference: nif.xml, StencilDrawMode: DRAW_CCW draws “only
the triangles whose vertices are ordered CCW with respect to the viewer”, the standard behavior. The
NIF pages say nothing of the winding of a shape without an NiStencilProperty, the case of every
Skyrim shape with a BSLightingShaderProperty.
| Question | Code | Why | Basis |
|---|---|---|---|
| Which side of a face is its front | The side its vertices wind counterclockwise from; seen from above, a face whose vertices wind counterclockwise faces up (ObjectHeightSampler) | The standard draw mode culls the other side | Tooling, and vanilla data: Blackreach, DLC1DarkfallPassageWorld, LabyrinthianWorld03 and BlindCliffCaveWorld cut every cell, SolitudeWorld and MarkarthWorld none, see map levels. The other winding would cut the roofs and leave the caves |
A shape flagged Double_Sided | Counted by its winding, like the others | The flag isn’t read, see map levels | Design: a double-sided vault ceiling counts as a roof, so its cell isn’t cut |
Tests: ObjectHeightSamplerTests, VaultMapTests.
Effect shader soft falloff
Reference: nif.xml names Soft_Effect (flag 1 bit 30) and
Soft Falloff Depth without describing them; NifSkope leaves the depth unused.
Community Shaders’ Effect.hlsl fades the opacity by
saturate(scene distance / k - face distance / k), with k a material constant.
| Question | Code | Why | Basis |
|---|---|---|---|
| The fade | Opacity × clamp(gap / Soft Falloff Depth, 0, 1) (EffectShading.Soft) | k read as the soft falloff depth | Article; k inferred from the field’s name |
| The gap, seen from above | Height above the highest opaque surface under the pixel, terrain or object | A vertical view’s distance is a height | Design |
| Water | Not counted: the gap reaches the ground under it | The shader doesn’t show it | Unverified: if wrong, effects over water are fainter in game |
| A shape without alpha blending | Not faded | Only blending reads the opacity | Design |
| A depth of 0 or less, or NaN | No fade | No vanilla shader has one | Design |
Most vanilla effects fade over 64 units or less; see also map objects for the depths a map leaves out.
Tests: NifSceneReaderTests.EffectShader_GivesItsSoftFalloffDepthWhenSoftEffectIsSet,
ObjectRasterizerTests.Draw_SoftEffectShape_FadesNearWhatLiesUnderIt.
Map markers
Reference: UESP REFR lists FULL
(lstring), FNAM (uint8 marker flags) and TNAM (uint16 marker type, an enum from 1) without the
subrecord that starts them.
| Question | Code | Why | Basis |
|---|---|---|---|
| What marks a reference as a map marker | XMRK, an empty subrecord; FNAM, FULL and TNAM count only after it | Every vanilla marker reads XMRK (0 bytes), FNAM (1), FULL (4), TNAM (2), and no other reference carries those three | Vanilla data: the 472 markers of the five masters |
TNAM 0, not in the enum | Kept, typeName left out | Vanilla gives it only to interior markers, on no worldspace map | Vanilla data: 35 markers of Skyrim.esm |
| The enum’s numbering | As listed, 1 is City | Riverwood is 2 (Town), the caves 4 (Cave), the cities their castle or capitol | Vanilla data |
Tests: ReferenceReaderTests, WorldspaceMarkersTests.
Child worldspace map offset
Reference: UESP WRLD gives ONAM
as float[4], World Map Scale (-1 hides the map markers) and Cell X, Y, Z offsets, “where map
markers will appear in relation to the parent”. It doesn’t say how they combine. See
Child worldspaces.
| Question | Code | Why | Basis |
|---|---|---|---|
| How scale and offset combine | child * scale + offset, in game units | AlftandWorld (scale 0.001, offset 79872, 77824) lands on Tamriel’s Alftand marker (78347, 77408); a KarthspireRedoubtWorld door plus its offset lands within 1,000 units of the Tamriel door it leads to. Dividing would throw Alftand off the map | Vanilla data |
| Negative scale | Hidden, like -1 | The spec names -1 only; Sovngarde is the only negative one | Design |
| Scale 0 | Every marker on the offset point | Follows the formula; DLC01SoulCairn is the only one | Design |
No ONAM | The child isn’t placed | xEdit marks ONAM required; every vanilla WRLD has one | Tooling |
| A grandchild | Each offset applied on the way up | Follows from the field’s meaning; vanilla has no grandchild: every parent is Tamriel or DLC2SolstheimWorld, neither of which has a parent | Design |
The formula fits the worldspaces built in place or moved as a block. Blackreach (scale 2.5) isn’t
built to scale: its three lifts to Tamriel are in a different order than their Tamriel doors, so
no scale and offset map one onto the other. FallowstoneCaveWorldEnd is built in Tamriel’s own
coordinates, yet its ONAM (scale 0.0001, offset 22528, -8192) gathers it near Whiterun, far from
Fallowstone Cave. The code follows ONAM in both cases. If the game shows Giant’s Grove near
Fallowstone Cave on its world map, ONAM isn’t what places a child’s markers there.
Tests: WorldspaceReaderTests, MapMarkerCatalogTests.
A worldspace’s CELL records
Reference: UESP WRLD puts a single
CELL directly in the World Children group, then the exterior cell blocks. UESP
Mod File Format, Form IDs, gives a FormId’s
owner by its master index. Neither says which plugins “make” a worldspace. The map’s plugin chain
lists every plugin carrying the worldspace’s WRLD or one of its CELL records.
| Question | Code | Why | Basis |
|---|---|---|---|
| Is the persistent cell one of the worldspace’s cells? | Yes, counted like a block cell | A mod placing a persistent reference in the worldspace carries only that cell | Design |
A plugin carries the same CELL twice | Counted once for that plugin | The chain counts cells, not records | Design |
| New or changed cell | New when the resolved FormId’s owner is the plugin itself, changed otherwise | Follows the FormId’s master index | Design |
A CELL or WRLD whose FormId doesn’t resolve | Left out of the chain | The worldspace datasets already drop and report it | Design |
Tests: WorldspaceCellsTests, WorldspaceMapQueryTests.
Texture paths
A texture path in a NIF texture set or in book markup is relative to the Data folder, under
textures\. Neither nif.xml nor UESP says how the engine reads a path that doesn’t fit.
| Question | Code | Why | Basis |
|---|---|---|---|
A path without the textures\ prefix | Read under textures\ | Book markup and some NIFs omit the prefix | Vanilla data |
A path holding a data\textures\ folder, such as skyrimhd\build\pc\data\textures\plants\thistle01.dds | Everything before textures\ is dropped | The front is the author’s build tree; the rest names an archive entry | Vanilla data: 45 of the 1,408 diffuse paths of placed models, all found once cut |
Tests: TextureColorsTests, MenuArtTextureConverterTests.
SWF DefineFont3
Reference: SWF19. Detail in SWF font parsing.
| Question | Code | Why | Basis |
|---|---|---|---|
DefineFont3 EM square | 20480 units, not DefineFont2’s 1024 | Ascent, descent and advances only fit 20480 | Vanilla data |
Glyph Y direction versus TrueType glyf | Flipped: SWF points down | A glyph’s path extent matches [-ascent, +descent] | Vanilla data |
FontBoundsTable | Ignored; bounds come from the contour points | Always [0,0]×[0,0] in real fonts | Vanilla data |
All three were checked on the vanilla interface SWFs.
Not implemented
Data the reference documents that the code deliberately skips. Each row says what you lose.
Plugin records
Reference: UESP Mod File Format and its record pages.
| Reference | Code | Why | Effect |
|---|---|---|---|
VMAD “Fragments” block of QUST, PERK, SCEN, INFO, PACK | Not decoded | None of the record types read here has it | None |
FACT VENV vendor hours | Not read; only VENC is | Nothing models time of day | A vendor is listed whatever the hour |
CELL DATA interior flag | Read, not used | The enclosing top group already says it | None |
WRLD MNAM camera floats (28-byte form) | Not read | Unused here; the spec doesn’t know their purpose | None |
BOOK DATA flag 0x08 (read) | Read, not exported | It tracks whether the player read the book; no vanilla book sets it | None |
BOOK MICO, DEST, YNAM, ZNAM | Not read | Message icon, destruction and sounds aren’t shown | No cover image for a book; the map draws its MODL model, the book export shows none |
LAND VNML and DATA | Not read | The hillshade of raster-records derives the slope from VHGT | None on the maps |
LTEX MNAM, HNAM, SNAM; TXST TX02 to TX07, DODT | Not read | A map reads each landscape texture’s color map, normal map and grass | No specular, glow or material detail on a map |
Multipass MATO (Single Pass unset), its DNAM properties and its model | Not read: the static stays bare | It draws a second geometry with its own textures and Projection Vector. 5.8 % of Tamriel’s references to a MATO, mostly glacier slabs | Glaciers and ice keep their base texture |
MATO Material UV Scale, Normal Dampener, Projection Vector | Read, not used | The single pass path doesn’t read them | None |
TXST DNAM flags 0x01 and 0x02 | Read, not used | Only 0x04, a model-space normal map, changes how the map reads TX01 | None |
Model-space TX01 (DNAM 0x04) on a landscape texture | Not read | See assumptions | Its texture shows no relief; no vanilla landscape texture has one |
GRAS OBND, MODT; DATA position, height and color range, wave period, flags | Not read | --grass reads density, slope and water distance only, see Grass | Tufts stand upright and vary by a fixed scale range, not by Fit to Slope or the height range |
WRLD NAM2/NAM3, CELL XCWT water types | Not read | The water overlay uses one fixed palette | Every water body has the same color |
WRLD NAM4 LOD water height | Not read; DNAM is used | They match on Tamriel (-14000) | A worldspace where they differ would show its near water height |
NVNM edge links, door and cover triangles, grid; NAVM ONAM, PNAM, NNAM | Not read | The roads layer needs only the triangles and their flags | None on the maps |
REFR XESP enable parent | Not read | See disabled references | A reference enabled through its parent follows its own flag |
Base object MODS alternate textures, MO2S, MO4S | Not read | --objects takes each shape’s texture from its NIF | A base that swaps a texture is drawn with the NIF’s own color |
LIGH DATA Time, Falloff Exponent, FOV, Near Clip, flicker period and amplitudes, Value, Weight; FNAM Fade; the flicker, pulse and shadow flags; MODL; REFR XLIG | Not read | --lights reads a light’s color, radius and Off by default flag only, see Lights | A spotlight glows all around: 14 of the 1,623 lights placed in vanilla worldspaces are spotlights. A faint light glows as much as a bright one of the same radius |
Tests: VmadReaderTests, WorldspaceReaderTests, BookReaderTests, LandscapeReaderTests, NavmeshReaderTests, GrassReaderTests, LandscapeTextureReaderTests, LightReaderTests.
String tables
Reference: UESP String Table File Format.
| Reference | Code | Why | Effect |
|---|---|---|---|
| Alias substitution in strings | Not done | Happens at runtime, after decoding | <Alias=...> tags stay in the text |
| Font coverage caveats | Not handled | Happens at render time | None on decoding |
Missing secondary encodings are in Assumptions.
NIF and Havok shapes
Reference: niftools’ nif.xml.
| Reference | Code | Why | Effect |
|---|---|---|---|
bhkRigidBodyT translation and rotation | Not applied | Not verified to matter | A shape under it could be offset |
bhkNiTriStripsShape | Not supported | About 0.002% of placed objects | Drawn as a position marker |
| Concave footprints | Reduced to the convex hull | Simple, far better than a marker | Concave rooms look filled in |
NiTriShape, NiTriStrips, BSLODTriShape, BSDynamicTriShape | Skipped, reported in SkippedBlockTypes | Rare in placed SSE models | Their geometry is missing |
NiBillboardNode, BSBlastNode, BSDamageStage | Not descended, reported in SkippedBlockTypes | A damage node draws one child, a billboard turns to the camera: drawing every child would be wrong | Their subtree is missing |
Localmap_Hide_Secret (flag 1 bit 20) and Hide_On_Local_Map (flag 2 bit 18) of a shader | Not read | No placed shape sets them, in vanilla or with Moon and Star and Vominheim; nif.xml leaves the second one’s meaning open | A mod’s shape the game hides from its local map is drawn |
Vertex alpha and material Alpha in the alpha test | Not applied: the test reads the texel’s alpha | Blending reads them, see assumptions; vanilla rock piles set Vertex_Alpha with a mean vertex alpha of 0 to 54 and no blending, and show in game | A face the game discards by its vertex alpha shows |
BSEffectShaderProperty Lighting Influence, Env Map Min LOD, Refraction and Weapon_Blood flags | Not read | A map seen from above has no scene light, nothing to refract and no blood | An effect shape keeps its own colors under any light |
BSEffectShaderPropertyFloatController and other UV controllers | Not read | A map shows one moment | Foam and falling water are frozen at their stored UVs |
Texture set slot 2 outside a Glow shader, slots 3 to 8 (parallax, environment, …) | Not read | A map lights a face by its diffuse and its normal map only | No glow, parallax or reflection on an object |
Model_Space_Normals (flag 1 bit 12) normal map | Read as set, not laid: the shape keeps its vertex normals | No placed shape of Tamriel sets it, see assumptions | A mod’s model-space map adds no relief |
External_Emittance (flag 1 bit 29), REFR XEMI | Not read: the shape emits at its own color, at every hour | The game scales such a shape by the LIGH or REGN its reference names. 9,326 references of the masters have an XEMI | A window emits by day as by night, and the windows of a dark building too |
| Emission of a blended shape | Not drawn | A fragment is mixed before the night’s tint, and about 160 placed shapes of Tamriel are such: an alchemy table, a shrine | They emit nothing on the map |
| Normal map alpha, the gloss | Not read | A map has no specular light | None |
NiParticleSystem, BSStripParticleSystem | Skipped, reported in SkippedBlockTypes | A NIF stores how emitters make particles, not the particles. Simulated and frozen at one moment, seen from above, a waterfall’s spray only adds a faint mist, and smoke draws opaque discs over towns | Spray, mist, smoke, steam and blowing snow are missing |
Tests: HavokShapeReaderTests, NifSceneReaderTests.
DDS textures
Reference: Microsoft’s DDS programming guide.
DdsMipLevel cuts one small mip level out of a texture so the decoder skips the larger ones.
| Reference | Code | Why | Effect |
|---|---|---|---|
| Cube maps, volume textures, texture arrays | Not cut, the texture counts as undecodable | Diffuse textures of placed models are 2D: every vanilla one is DXT1 or DXT5 with a full mip chain | Such a texture is drawn gray |
| Formats other than DXT1 to DXT5, BC1 to BC7, ATI1/ATI2 and whole-byte uncompressed pixels | Not cut | The level size needs the format’s block or pixel size | Same |
Tests: DdsMipLevelTests.
Map marker icons
Reference: SWF19.
| Reference | Code | Why | Effect |
|---|---|---|---|
Map marker icons of interface\map.swf | Not exported | The engine only passes each marker’s TNAM to the movie’s ActionScript, which picks the icon. Interface mods do it differently (SkyUI shows a frame of a sprite imported from another movie), so only running the ActionScript would hold for every load order | tiles.json gives type and typeName: a viewer draws its own symbol per type |
Reported data problems
Data the code can’t use as is. Each row says what the code does instead and why it reports it. Log levels follow Logging: a recovered problem is a warning, a known limitation is debug output.
Unresolvable FormIds
Reference: UESP Mod File Format, FormIds. Resolution in FormIds and GlobalFormIds.
| Problem | Code | Why |
|---|---|---|
| A record’s FormId has a master index past the plugin itself | The record is dropped and reported | No safe fallback for the record’s own identity |
Same case for a VMAD Object value on a BOOK | Kept, with formId: null and the raw local id | Dropping a property would hide the rest of the script data |
Same case for a BOOK DATA spell or a KWDA keyword | Left out, one warning with the count | The rest of the book stays usable |
A BOOK DATA skill index that isn’t a skill, or a type outside 0 and 255 | Left out, same warning | No spec meaning to export |
| A spell, skill or keyword record the load order doesn’t have | Exported by FormId only, one warning | The reference itself is still valid |
On a clean vanilla load order, none of these happens. When one does, the plugin is corrupt or one of its masters is missing from the load order.
Tests: PluginMastersTests, LocationMergerUnresolvedFormIdTests, VmadReaderTests,
BookMergerBookDataTests, BookFileExporterTests.
Localization
Reference: UESP String Table File Format.
| Problem | Code | Why |
|---|---|---|
| A string id missing from its table (not id 0) | Left unresolved, one warning per plugin and language | Points at a broken or mismatched table |
| Both encodings fail on a string | Lenient UTF-8 decode, counted in FallbackCount and logged | Keeps the text, flags the problem |
An inline lstring isn’t valid UTF-8 and the language has no secondary encoding | Lenient UTF-8 decode, one warning per plugin and language | Keeps the text, flags the problem |
Id 0 isn’t a problem, see Assumptions. No vanilla table needs the fallback decode.
Tests: BookLocalizationResolverTests, SkyrimStringTableTests, LStringResolverTests.
Book markup assets
See Book markup assets and Font export.
| Problem | Code | Why |
|---|---|---|
| A face mapped to a name no embedded font has | The face stays unresolved; the font is still exported | No fuzzy matching |
A face with no map entry | Rendered as (unmapped) | The face tag is wrong in the source text |
| A texture or font nothing ships | Warning, export continues | The book stays usable without it |
Vanilla has each case:
$CClub_Fontmaps to “Eurostile LT Cyr Std”, which no embedded font is named.- Vanilla text has a typo’d face tag.
- Two assets don’t ship: a font renderer atlas and one illuminated letter.
Tests: FontConfigParserTests, MenuArtTextureConverterTests.
Terrain LOD tiles
See debug:*:archive:terrain-lod and
export:worldspace-maps:lod.
| Problem | Code | Why |
|---|---|---|
| An expected tile no archive has | Reported, not an error; transparent in a map | The rest of the grid is still usable |
| A tile Pfim decodes to an unmapped pixel format | Same as a missing tile | Same |
--hillshade: a normal map missing or undecodable | Reported; the tile is drawn unshaded | The diffuse tile is still usable |
A malformed lodsettings file | Worldspace treated as having no LOD, reason at --verbose | Other worldspaces are still usable |
| A worldspace without the requested LOD | One [WARN] for the run, each reason at --verbose | Expected for most vanilla worldspaces, but a map was asked for all |
| A placeholder tile, much smaller than the others of its level | Redrawn from the next finer level, see placeholder tiles | Scaled up, it draws flat blocks |
--water: a LAND without VHGT | Flat at the worldspace’s DNAM default land height, count at --verbose; left out when no DNAM applies | See assumptions; 183 vanilla LAND records have none |
Missing tiles and malformed settings files are not seen in vanilla data. Tamriel has one
placeholder, tamriel.32.-64.-64.dds. 38 of 49 vanilla worldspaces have no level-32 LOD.
Tests: TerrainLodGridTests, WorldspaceCellsTests, TerrainLodSettingsLoaderTests, LodRasterTests,
TerrainLodNormalsTests, TerrainLodTileSourceTests, WorldspaceTerrainTests.
Landscape textures
See export:worldspace-maps:raster-records.
| Problem | Code | Why |
|---|---|---|
A LAND BTXT or ATXT whose LTEX FormId doesn’t resolve | Drawn with the default texture, one [WARN] for the run, each at --verbose | The rest of the cell is still usable |
An LTEX TNAM that doesn’t resolve | The LTEX has no color map, one [WARN] for the run | Same as an LTEX without TNAM |
A used LTEX without a readable color map (no TNAM, no TX00, texture missing or undecodable, or no plugin holds it) | Drawn gray, one [WARN] per map with the count, each at --verbose | Gray reads as neither ground nor snow |
The default dirt02.dds missing or undecodable | Same, for the quadrants without a base texture | Same |
An LTEX TX01 normal map missing or undecodable, with --hillshade where the pattern is drawn | Its texture shows no relief, one [WARN] for the run with the count, each at --verbose | The color map still draws it |
In vanilla data, 90 of the 91 LTEX have a color map: LScrub01 has no TNAM, and no LAND
uses it. CWTestHold, a test worldspace, uses LTEX skyrim.esm:000844, which no plugin holds:
its map warns once.
Tests: WorldspaceLandscapesTests, LandscapeTexturesTests, LandscapePaletteTests, LandscapeBackgroundTests.
Grass models
See Grass, with --grass.
| Problem | Code | Why |
|---|---|---|
A GRAS without MODL, whose model is missing or unreadable, or whose shapes have no readable diffuse texture | No color: the textures that list it grow nothing from it. One [WARN] for the run with the count, each at --verbose | The other grasses of the texture still grow |
A GRAS without a DATA long enough for the slopes | Grows nothing | Without density or slope range, nothing says where it grows |
An LTEX GNAM that doesn’t resolve | Left out of the texture’s grasses, one [WARN] for the run | Same as a GRAS no plugin holds |
In vanilla data, GRAS dragonborn.esm:01771E names Landscape\Grass\DLC02VolcanicAshRocks01.nif,
which no archive holds: the run warns once.
Tests: GrassPaletteTests, GrassCoverTests, LandscapeTexturesTests.
Navmeshes and references
See Worldspace maps.
| Problem | Code | Why |
|---|---|---|
A NAVM whose last version has no NVNM, counts past its end or a triangle naming a missing vertex | No paths drawn from it and, with --levels, no floors read from it; one [WARN] for the run for each of the two, each at --verbose | The rest of the worldspace’s navmeshes are still usable |
A REFR whose last version has no NAME or no DATA | Left off the maps, one [WARN] for the run, each at --verbose | Nothing says what or where it is |
A NAVM or REFR whose FormId, worldspace or base doesn’t resolve | Dropped, see Unresolvable FormIds | Same as any record |
No vanilla NAVM or exterior REFR has one of these problems.
Tests: WorldspacePathsTests, WorldspaceNavmeshesTests, WorldspacePlacementsTests, NavmeshReaderTests.
Object models and textures
See Objects.
| Problem | Code | Why |
|---|---|---|
| A model path not in the archives, or a NIF that fails to parse | The references placing it aren’t drawn, one [WARN] per map with the count of models, each at --verbose | The other objects are still usable |
| A diffuse texture not in the archives, or a DDS that fails to decode | Its shapes are drawn gray, one [WARN] per map with the count, each at --verbose | Gray reads as neither stone nor wood |
Each map reports what its own references place, and the textures of the models on its ground: a
child drawn with --parent-lod doesn’t repeat its parent’s problems.
In vanilla data, every model placed in a worldspace is found and parses. Three diffuse paths of
placed models resolve to nothing: one NIF names its texture ERR (Tamriel), and two Windhelm
decals, textures\architecture\windhelm\WHicedecal01.dds and WHarenawallstains.dds, aren’t in
the archives (WindhelmWorld, WindhelmPitWorldspace).
Tests: ObjectsLayerTests, TextureColorsTests.
Lights
See Lights, with --lights.
| Problem | Code | Why |
|---|---|---|
A light whose LIGH radius plus XRDS is over 100,000 units | No glow, one [WARN] per map with the count, each at --verbose with its base and position (LightsLayer.MaxRadius) | Its glow would whiten the whole map |
In vanilla data, one light has one: REFR skyrim.esm:0F7CBE in BlindCliffCaveWorld, base
BlindCliffSpotlight01, with an XRDS of 456,444 for a radius of 456,956. Of the other 1,622 lights
placed in worldspaces, the largest reaches 7,175 units. The same base placed elsewhere
(skyrim.esm:02CF02) has an XRDS of 4,510. Nothing in the reference marks the outlier: its header
flags, its XLIG (End Distance Cap 0) and its sub-records match the other’s. In game, disabling it
from the console changes no lighting in the cave.
Tests: LightsLayerTests.
Export heuristics
Exported values whose true value depends on runtime game state or on what a record means to a player. The export gives the static value or an approximation.
Book export
Shape in Book export JSON format.
| Field | Code | Why |
|---|---|---|
value | The static base price | The sale price depends on Speech, perks and factions at runtime |
content when DESC is blank and menuArtFormId is set | A generated placeholder, contentIsPlaceholder: true | The book’s content is the art |
BookLocation.source container, npc, vendor | Reachability, not a guarantee | Leveled lists are rolled at runtime |
isPersistent | The record’s Persistent flag, read as “possibly quest-related” | The flag is also set on other always-loaded references |
hasScript | Set when a VMAD is present | A heuristic: a script doesn’t say what it does to the book |
level, count on a leveled list entry | Only for a direct LVLO entry, else null | A nested chain has no single level or count |
How hasScript merges across overrides is in Rule of One merge.
Tests: BookReachabilityTests, LocationMergerLeveledListTests.
Worldspace maps
What the map layers draw, see Worldspace maps.
Map shading
With --hillshade, every lit pixel of a map, ground, terrain LOD tile, object face or grass
tuft, is multiplied by one factor (MapShading.Factor), in one pass, the
lighting layer:
factor = clamp(1 + k (N·L - Lz) + cartographic, 0.55, 1.35)
N is the unit normal of what the pixel shows, L the direction toward the light and Lz its
height, so flat ground keeps its color under every light. cartographic holds the terms that
don’t come from the normal: on the raster-records ground and on what stands on it, the broad
relief and curvature of the surface (see Hillshade);
everywhere, the contact occlusion. The bounds apply to the sum.
| Value | Code | Why | Basis |
|---|---|---|---|
k = 0.8, the same for every surface | MapShading.Contrast | A slope reads the same on the ground, on a LOD tile and on an object: a road piece laid on a slope blends into it | Design |
| Factor between 0.55 and 1.35 | MapShading.MinShade, MapShading.MaxShade | A slope facing away keeps its color readable; under a low sun a whole mountain side reaches the upper bound instead of turning white | Design |
Without --hillshade, nothing is shaded | MapOptions.Lighting null | The option is the map’s light: without it, the map shows the colors alone | Design |
| An object’s normal map keeps half its tilt: red and green times 0.5, blue as it is | MapShading.NormalMapStrength | Under this formula, a vertical view shows the whole tilt on pieces that repeat across the map: at full strength Road01_n and Dirt02_N (mean tilt 25 to 30 degrees) turn cobbles and dirt lumpy and hide the stones their diffuses already paint. A slope cap doesn’t help: under 3% of their texels pass 60 degrees | Design, checked on Riverwood’s street and on the road zones |
An object’s N facing down, a face’s or a vertex normal blended over it, is turned up | FaceLighting.ShadeOf, FaceLighting.UpNormal, FaceShader | Seen from above, a ceiling or a face wound the other way shows its upper side; lit from below it would sit at the lower bound | Design |
A grass tuft takes the ground’s N and cartographic, its color times 0.8, and leaves the surface at the ground’s height | GrassTufts.SelfShadow, ObjectDrawOptions.GroundCover | A tuft is a cover of the ground: lit by its blades’ own normals, a meadow would read as noise over the relief; standing on the surface, each tuft would darken the ground around it by contact | Design |
| An effect face and a wireframe edge aren’t lit | FaceShader, ObjectTarget.Paint | An effect shader isn’t lit in the game; an edge is a drawn line, not a surface | Design |
A blended face is lit as it is drawn, without cartographic | FaceShader | It mixes over what lies under it and can’t leave a normal for the pass | Design |
On an object, N is the vertex normals blended over the face, as the game lights a model; a shape
without normals takes its face’s.
The game lights a surface by N·L plus its ambient and does not keep flat ground at its diffuse
color: the formula is a map convention, not the engine’s.
Tests: ObjectRasterizerTests.TiltedFace_IsShadedLikeALodTileOfTheSameSlope,
ObjectRasterizerTests.VertexNormalFacingDown_IsLitAsItsUpperSide,
ObjectsLayerTests.WithoutHillshade_FacesAreUnshaded, ObjectsLayerTests.OpaqueEffectFace_IsNotLit,
ObjectRasterizerTests.NormalMapTexel_TiltsTheSurface,
LandscapeBackgroundTests.OpenAsync_TuftsWithoutHillshade_AreUnshaded,
GrassTuftsTests.Draw_KeepsTheGroundsSurfaceAndNormals,
MapRegionRendererTests.ObjectLyingOnASlope_IsLitLikeTheSlope.
Contact occlusion
Seen from above, a wall or a cliff has almost no pixels: without a shade at its foot, only its top’s
color tells it from the ground. The game gets that shade from ambient occlusion. The lighting layer
measures, for each lit pixel, the sky its surface doesn’t see within a small radius
(ContactOcclusion), on the region’s surface:
- In 8 directions, at 4 distances up to the radius, rounded to the nearest pixel, it reads how high the surface rises above the pixel’s tangent plane, the plane through the pixel with its normal.
- The highest angle of each direction gives its sine; the term is the weight times their mean,
negative, added to
cartographic.
Above the tangent plane, a plane, a slope or a ridge hides no sky and keeps its light; a hollow, a wall’s foot or the gap between two rocks darkens. A sample past the map’s edge or without a surface hides nothing.
| Value | Code | Why | Basis |
|---|---|---|---|
| Radius 64 units, 4 distances, 8 directions | ContactOcclusion.RadiusUnits, Steps, Directions | A shade at a wall’s foot, not across the street: a few pixels from 256 pixels per cell up. Below 64 pixels per cell the radius is under a pixel and the term vanishes | Design |
| Weight 0.35 | ContactOcclusion.Weight | A pixel at the foot of a tall wall, three directions of eight hidden, darkens by about 0.13: a shade that reads without hiding the ground | Design |
| Measured above the tangent plane | ContactOcclusion.Term | Measured above the horizontal, every slope would darken by the ground uphill | Design |
| A sample without a surface or past the map’s edge hides nothing | ContactOcclusion.Term | Counted at the pixel’s height, a slope at the map’s edge would darken or lighten by a band of the radius | Design |
The radius is in world units, so the map is the same however it is cut: a region is drawn that many
pixels wider (ContactOcclusion.MarginPixels). The faces of a decal, a layer laid over a rock or a
mountain, raise the surface like any face, unless they lie on what the pixel shows, see Decals.
Tests: ContactOcclusionTests.Term_DarkensOnlyWhereTheSurfaceRisesAboveTheTangentPlane,
MapRegionRendererTests.WallFoot_IsDarkenedByContact, MapRegionRendererTests.LitMap_IsTheSameHoweverItIsCut.
Surface relief
Mountains, cliffs and large rocks are meshes over the LAND: measured on the LAND alone, the broad
relief and the curvature (see Hillshade)
ignore them, and an object takes the relief of the ground hidden under it. With --objects on the
raster-records background, the objects layer measures both terms on the surface instead
(SurfaceRelief) and writes them over the background’s, interpolated as the ground’s are.
| Value | Code | Why | Basis |
|---|---|---|---|
At each VHGT vertex, every 128 units, aligned on the cells | SurfaceRelief, WorldSampleGrid with phase 0 | The terms keep the vertex grid they are tuned on; where no object stands, the relief is the ground’s, to the bit | Design |
The LAND raised to the highest face that faces up over the vertex | ObjectHeightSampler.SampleTopFront | The underside of an overhang or a ceiling faces down: it is no ground, see Face winding | Design |
What the faces add over the LAND is averaged over the 5 by 5 vertices around each vertex (640 units) | SurfaceRelief.SmoothRadius | Unsmoothed, a plant, a rock or a roof covering one or two vertices is a bump that the curvature lights up and rings with dark ground: a mottle at 128 units. Averaged, a small object barely raises the surface and a mountain keeps its shape | Design |
| No fade above the ground | SurfaceRelief | A mesh mountain stands far above its LAND; a fade by height would leave it out | Design |
The LAND alone in the cells the levels cut | SurfaceRelief.For | Each level shows other faces there, and every level shares one relief | Design |
| Not over the terrain LOD | ObjectsRun | The lod background has no relief of its own to join | Design |
Not in wireframe | ObjectsRun.ReliefOf | Edges are no surface: they would raise the relief where the map shows only lines | Design |
The terms are measured once per map, so the map is the same however it is cut. The grid reads the objects past the map’s edge as far as the broad relief reads. The average spreads a mesh’s edge over 256 units on each side: the ground at a cliff’s foot takes some of its height, and a building still brightens its block a little.
Tests: MapRegionRendererTests.MeshMountain_EntersTheBroadRelief,
MapRegionRendererTests.MeshPlateau_GivesTheGroundTheReliefOfTheSameLand,
MapRegionRendererTests.DownFacingFace_AddsNoRelief, MapRegionRendererTests.ReliefWithoutObjectsAbove_IsTheGroundRelief,
MapRegionRendererTests.CutLevel_LightsTheGroundUnderTheRoof,
ObjectHeightSamplerTests.SampleTopFront_OnVertices_SamplesAtTheMultiplesOfTheUnits.
Cast shadows
The shadows of --hillshade are no reading of the game’s shadow maps: the map has one light and no camera, and rays
from every pixel would need a margin as long as a mountain’s shadow around every region. The shadow
is measured once per map on the heights at the VHGT vertices (CastShadows), which depend on nothing
but the map, then interpolated with the relief.
| Value | Code | Why | Basis |
|---|---|---|---|
| Vertices swept line by line from the light’s side, along the axis nearest it | CastShadows.Sweep | Each vertex costs one step, whatever the height of the mountains, and the map needs no margin | Design |
| A vertex’s top is its height or the top of the vertex toward the light, less the ray’s fall | CastShadows.Sweep | A step between two vertices of the line reads both, so a light off the axes softens with distance, a penumbra | Design |
| Fully in shadow 256 units under the ray, from 0 at the ray | CastShadows.Softness | Two vertices: a smooth edge at the lattice’s scale | Design |
| Weight 0.3, a term added to the cartographic ones | CastShadows.Weight | Clearly read on flat ground at any hour, 0.7 of its light, without reaching the map’s lower bound on a slope away from the light | Design |
| Not scaled by the pixel’s normal | LandscapeHillshade.ReadVertex | The term joins the broad relief’s channel: no new plane or channel. A slope already turned from the light darkens twice, up to the bound | Design |
| No shadow from outside the map’s cells | CastShadows.Over | The map reads no height past them | Design |
Tests: CastShadowsTests, MapRegionRendererTests.Relief_CastsAShadowAwayFromTheLight,
MapRegionRendererTests.LitMap_IsTheSameHoweverItIsCut.
Decals
The game draws a decal shape with a depth bias over what it lies on. The map keeps the highest face at each pixel, with no such bias: drawn as any face, a layer a little over a rock would raise the surface, and a layer a hair under it or level with it wouldn’t show.
| Value | Code | Why | Basis |
|---|---|---|---|
| Drawn after the opaque faces of the band | DecalPass | What it lies on must be there, whichever object comes first | Design |
| It lies on what the pixel shows up to 16 units over it | ObjectTarget.DecalLift | Half the ground tolerance, a layer’s thickness on a rock. Farther over, it is any face | Design |
| It shows up to 1 unit under what the pixel shows | ObjectTarget.DecalBias | The game’s bias is a hair. At 16 units, as over it, the layers buried under a fort’s paving come through it | Vanilla |
| Lying, it paints its color and its own normal, and raises no surface | ObjectTarget.PaintOver | The game’s shader lights a decal by its own normal map: a paved floor is a decal, and keeps its relief. It leaves no step for the contact occlusion | Lighting.hlsl, vanilla |
| The surface relief still counts its faces | SurfaceRelief | 16 units over 640 of averaging changes nothing that shows | Design |
| A blended decal stays with the blended shapes | ShapeMaterials | It already neither raises the surface nor writes a normal | Design |
Tests: ObjectRasterizerTests.FlatDecal_ShowsOverWhatItLiesOnWhicheverIsFirst,
MapRegionRendererTests.FlatDecal_RaisesNoSurfaceAndKeepsItsOwnLight.
Map objects
The roads pick their pieces by record type and model folder (MapObjectClassifier). Paths are
compared without case, with either slash and with or without a leading meshes\. The objects layer
draws every placed model but what the rules below leave out (ObjectInstances.Exclusion,
ObjectModel.From).
| Rule | Code | Why | Basis |
|---|---|---|---|
Road piece: a STAT whose model is under landscape\roads\ | MapObjectClassifier.IsRoad | The navmesh “Preferred” bit covers only part of a mod’s roads | Vanilla data: 5,498 such references on Tamriel; on Vominheim 468 references to vanilla road pieces fill the gaps of its 3,776 preferred triangles |
| A reference whose base has the Is Marker header flag isn’t drawn | ObjectExclusion.Marker | Editor markers aren’t seen in game | Vanilla data: 14,527 references on Tamriel |
A reference with XPRM isn’t drawn | ObjectExclusion.Primitive | A primitive is a trigger, a room bound or a collision plane, never seen | Vanilla data: 1,495 references on Tamriel |
| A reference hidden from the local map isn’t drawn | ObjectExclusion.HiddenFromLocalMap | The game leaves it out of its own map seen from above: cave ceilings, ship decks | Vanilla data, see reference header flags |
| A shape without a shader property isn’t drawn | ObjectModel.From | Every one placed is a helper the game doesn’t render: water current planes, collision copies, particle emitter meshes, animation bones | Vanilla data: 4,876 placed shapes on vanilla worldspaces besides the hidden ones, see below |
| An effect shape whose Soft Falloff Depth is 1,024 or more isn’t drawn | ObjectModel.SoftFalloffDepthLimit | It fades over a quarter of a cell or more: built to be seen from afar, it hides the ground from above | Vanilla data: placed, only the clouds (sky\*cloud*, 2,048) and an effect of the Ideal Masters’ crystal; every other effect is at 512 or less |
A shape whose shader is a BSWaterShaderProperty isn’t painted: the water layer tints what lies under it | WaterWriter, WaterLayer | It is a water surface, and the shader holds no color: tinted as a cell’s water, it reads as the water around it | Vanilla data: 302 placed shapes, water planes, troughs, streams and puddles |
| An object shows only above the terrain, less 32 units | ObjectRasterizer.GroundTolerance | Road pieces and floors follow the LAND only roughly; a buried rock shows only what rises above the ground | Vanilla data: 5.3 % of the vertices of Tamriel’s 5,500 road pieces lie more than 32 units under the bilinear terrain, see Surface |
In texture mode, a face reads the mip level of its least stretched pixel axis, or of its most stretched one over 16 | MipSelection.MaxAnisotropy | A GPU with 16x anisotropic filtering, the most Direct3D 11 allows, does so; picked from the most stretched axis alone, a steep alpha-tested card reads a level where its alpha has averaged out and vanishes | Design: on WhiterunWorld at 256 pixels per cell, the Gildergreen keeps more of its leaves |
In texture mode, a texture is read at the side its shapes’ average repeats per unit ask | TextureSides.SideFor | The densest triangle of an atlas would read most textures whole | Design: a part mapped finer than the average is drawn blurred |
| A blended shape is mixed over the image after the water layer, and doesn’t raise the surface | BlendedObjectsLayer, BlendedWriter | Mixed before, a waterfall body over a deep pool would take the deep water’s tint; the water still tints the ground seen through it | Design: Markarth’s waterfalls, MapLayersTests.From_BlendedObjectsMixOverTheWater |
| A shape’s vertex colors multiply its toned color, before the map’s light shades it | FaceShader | The tone matches the objects to the terrain’s colors; the vertex colors then darken them as the game’s diffuse | Design: White River falls, Tamriel |
A road piece without OBND is not drawn: nothing says how large it is.
Tests: RoadsLayerTests, ObjectSceneTests, ObjectsLayerTests, ObjectRasterizerTests, MapLayersTests.
Road pieces
A road piece’s OBND box holds the road and its shoulders, and a curve fills only part of its box.
Painted whole, the boxes draw a wide road with steps where two pieces meet at an angle.
RoadPieceStroke draws each piece as a stroke instead:
| Part | Rule | Why | Basis |
|---|---|---|---|
| Axis | The box’s local Y axis, through the middle of its X extent | The road runs along Y in the road meshes | Vanilla data: the strokes follow the preferred navmesh triangles of Tamriel |
| Width | Half the box’s X extent | The shoulders blend into the terrain | Design: chosen by eye on Tamriel |
| Ends | A half disc on each Y edge of the box, of the stroke’s half width | The next piece starts at that edge: two turned pieces meet without a notch | Design |
A curve is drawn as the straight stroke through its box, so a sharp curve cuts its corner. The road mesh would give the exact shape; the exporter does not read NIF road meshes.
Tests: RoadsLayerTests.
Disabled references
The maps show the world as the game starts.
| Reference | Code | Why | Basis |
|---|---|---|---|
“Initially Disabled” flag (0x800) set on the last version | Left off | It appears only through a script or a quest; a mod also “removes” a vanilla reference by disabling it | Design |
“Initially Disabled” on a map marker’s last version, with --markers | Listed, disabled set | A quest enables it later, such as the Dark Brotherhood Sanctuary: a viewer can still show it, and the flag says so | Design |
“Initially Disabled” on a book’s last version, with --markers=books | Listed, disabled set | Like a map marker: a script can enable it, and a viewer shows it fainter | Design |
XESP enable parent | Not read: the reference’s own flag decides | Following the parent would need its record and the “opposite” flag | Unverified: a reference whose state at the start comes from its parent would be missing or extra |
| Deleted last version | Left off | The record is removed | Design |
A persistent reference sits in its worldspace’s persistent cell, not in the cell under it: the maps
place it by its DATA position, like any other.
Tests: WorldspacePlacementsTests, WorldspaceMapQueryPathsAndPlacementsTests, WorldspaceMarkersTests, WorldspaceBooksTests.
Grass
--grass tints the ground of raster-records with the grass its textures grow, see
Grass. From 512 pixels per cell, it scatters the
grass models’ tufts instead, see Grass tufts.
The engine’s placement of grass is not documented: the tufts follow the same data, placed the map’s own
way, not where the game puts them.
| Value | Code | Why | Basis |
|---|---|---|---|
| A grass’s color: the alpha-weighted mean of its model’s diffuse textures, the shapes weighted by triangle count | GrassPalette | The tufts’ look from above; the alpha leaves out the transparent part of a blade card | Vanilla data: 30 of the 31 GRAS get a color |
| Coverage: the sum of the densities of the grasses that grow at the slope, over 100, at most 1 | GrassCover.At | Several grasses on one texture cover more ground than one | Design: the engine’s placement is not documented |
| Grass color of a texture: its grasses’ colors weighted by density | GrassCover.At | A denser grass covers more of the ground | Design |
The texture’s color moves toward its grass color by coverage x 0.6 | GrassCover.Strength | Full grass still lets the ground through between the tufts | Design: a style choice, to tune from side-by-side maps |
| Slope at a vertex: from the vertex on each side, on both axes | LandscapeHeightField.SlopeDegrees | The same slope the hillshade’s fine term reads | Design |
A worldspace with WRLD DATA No Grass: no grass on its map, its parent’s cells under --parent-lod included | LandscapeBackground.OpenAsync | The map shows the child as it looks in game | Vanilla data: 4 of the 45 maps, among them WhiterunWorld |
| From 512 pixels per cell, tufts instead of the tint | LandscapeOptions.TuftPixelsPerCell | A tuft is about 8 pixels wide there; smaller, it reads as noise | Design: a style choice, from side-by-side maps |
| A tuft may grow every 32 units on both axes, moved within its square by a hash | GrassTufts.Spacing | Dense enough to cover a meadow, and no grid shows | Design: the engine’s spacing is an INI setting, not plugin data |
| A place holds a grass with the chance of the texture weights there times the grass’s density over 100, where its slope range holds the slope, bilinear between vertices | GrassTufts.In | The tint’s coverage, place by place; the bilinear chance softens the slope gate | Design |
Each tuft turns at random about its vertical axis and scales by 0.8 to 1.2; it stands upright on the bilinear VHGT height | GrassTufts.MinScale, MaxScale | Breaks the repetition of one model | Design: DATA height range and Fit to Slope aren’t read |
A tuft’s place, turn and scale come from a hash of its place and its GRAS FormId | GrassTufts.SeedOf | Every region and run draws the same tufts; a grass added by a mod leaves the others’ tufts where they were | Design |
| The ground under the tufts keeps its own color, without the tint | LandscapeBackground.OpenAsync | The tufts show the grass; tinting under them would count it twice | Design |
A tuft’s pixels take the ground’s normal and VHGT relief, and a factor of 0.8 | GrassTufts.SelfShadow | The relief stays readable under a meadow; the factor stands for the blades’ shade on one another | Design: a style choice |
Tests: GrassCoverTests, GrassPaletteTests, GrassTuftsTests, LandscapeRasterizerTests, LandscapeBackgroundTests,
ObjectRasterizerTests.
Lights
--lights draws a glow around each placed LIGH, see
Lights. The game lights the surfaces around a light;
the map paints the light’s reach seen from above.
| Value | Code | Why | Basis |
|---|---|---|---|
Strength: (1 - d)², d the distance over the radius, 1 at the light | LightsLayer.Paint | Most of a light’s effect is near it; Falloff Exponent isn’t read | Design: a style choice, to tune from side-by-side maps |
Blending: screen, 1 - (1 - map) x (1 - color x strength) | LightsLayer.Screen | It only lightens, so the same layer barely shows by day and stands out at night | Design |
| A light shows only where the surface stays within 32 units above it, at its pixel and at each pixel of its glow | LightCover | The map has one height per pixel: what rises above a light covers it, a roof or a ceiling hides it | Design: an overhang hides the light under it, see Lights |
A blended face above a light dims it by its destination factor, 1 - alpha when it blends over; the least of the light’s pixel and the glow’s pixel counts | LightCover, BlendedSurfaces.Through | A translucent shape lets through what it keeps of what lies under it, as it does for the colors | Design |
| Placed after the night tint | MapLayers.From | The night darkens the world, not its lights | Design |
Tests: LightsLayerTests, MapLayersTests, MapRegionRendererTests.
Map levels
The levels of a map show the floors one above another. The exporter reads the walkable floors from
the navmesh, see navmesh triangle flags, and lists them
per square of the ground (FloorField).
| Rule | Code | Why | Basis |
|---|---|---|---|
| A sample is a 32-unit square aligned on multiples of 32 in world units; it reads the navmesh at its center, edges included | FloorField.SampleUnits | A pixel’s floor comes from world coordinates, so every region and run reads the same floor | Design: one sample is one pixel at 128 pixels per cell |
| A sample’s heights, highest first, start a new floor where the next lies more than 128 units lower; a floor stands at its highest | FloorField.FloorGap | An actor is about 128 units tall: closer floors can’t both hold one, so they are a slope or a step of one floor | Design |
| A sample keeps at most 6 floors, the highest | FloorField.MaxFloors | Bounds the memory per sample | Vanilla data: the interiors and worldspaces measured hold at most 3 |
| A sample without navmesh takes the ground height at its center as its only floor | FloorField.Build | Outside the navmesh, a worldspace’s floor is its LAND | Design |
| A sample with neither navmesh nor ground takes the floors of its nearest sample that has some, breadth-first, neighbours west, east, north, south | FloorField.Build | Objects there still need a floor to be cut against; the fixed order gives the same floors on every run | Design: the nearest floor is a guess where nothing walks |
In a worldspace, the levels apply only to the cells whose floor lies under a vault (VaultMap): a
cave ceiling seen from inside is the back of its faces. The vault map reads the scene and the
navmesh on its own 128-unit grid, once per map.
| Rule | Code | Why | Basis |
|---|---|---|---|
| A navmesh sample is under a vault when a face rises more than 512 units over its top floor and no face up does, see face winding | VaultMap.Clearance | A bridge or a roof shows its top face from above; a cave shows only the back of its ceiling | Vanilla data: Blackreach’s floor lies 86 % under a vault, Tamriel’s 0.2 % |
| A cell is cut when 5 % of its navmesh samples are under a vault, and it has at least 32 such samples | VaultMap.CellShare, MinCellSamples | A stray overhang in an open cell doesn’t cut it | Vanilla data: Solitude and Markarth cut no cell; DLC1AncestorsGladeWorld keeps its open glade and cuts 4 of its 9 cells. Tamriel cuts 5 of its 5,644 cells, where navmesh runs under rock: their 5.7 % to 10.7 % overlap the cave cells cut at 7.1 % to 10.7 %, so no share leaves them out. DLC2SolstheimWorld cuts 8 of 918 cells, 9 % to 45 % under a dome over open ground, see Levels |
| Every cell is cut when 25 % of the worldspace’s navmesh samples are under a vault | VaultMap.WorldspaceShare | An underground worldspace has cells whose vault the per-cell rule misses | Vanilla data: at 50 %, one of BlindCliffCaveWorld’s three cells (38 % under a vault) stayed uncut |
| Vault samples are 128-unit squares aligned on multiples of 128 | VaultMap.SampleUnits | The decision is per cell: a coarser grid is enough, and a cell holds a whole number of samples | Design |
A level shows, per sample, one of its floors, and the cut follows that floor. Level 0 shows the top
floor. Each later level stands at an altitude, a stop of the slider: a sample shows its highest floor
less than 64 units above that altitude, its lowest when every floor is higher (LevelStops). The
exporter picks the stops where the slider reveals floor, walking down from the top.
| Rule | Code | Why | Basis |
|---|---|---|---|
A sample moves from floor j to the next one below floor j - 64 | LevelStops.Tolerance | A level standing just under a floor still shows it, as long as it lies within half an actor of it | Design |
| Candidate altitudes are grouped in 16-unit bins; a stop stands at its bin’s lower edge | LevelStops.AltitudeBin | A sloped floor moves sample by sample: one candidate per bin, not per sample. The lower edge shows every floor change of its bin | Design |
| A candidate becomes a stop when it shows 256 x 256 square units of floor that no higher level showed, counting only samples with navmesh of their own | LevelStops.MinRevealedArea | A landing or a step reveals too little to earn a level | Vanilla data: 4 to 30 levels on Bleak Falls Barrow, Wolfskull Cave, Frostflow Lighthouse, the Hall of Attainment and Blackreach, where a share of changed pixels gives 1 level for a cave and 14 for a spiral stair |
| A stop less than 128 units under the previous one replaces it | LevelStops.MergeWithin | Two stops closer than an actor’s height show nearly the same floors | Vanilla data: Blackreach keeps 9 levels of 30, Dragonsreach one for its balconies at z 400 and 384. Equal to FloorField.FloorGap |
| Only samples where the levels apply give stops | LevelStops.Pick | Outside the cut, every level shows the top floor | Design |
| Where the levels apply, a face more than 160 units above the floor a level shows at a pixel is left out there, with its edges and its water | LevelCut.CutHeight | Keeps what stands on the floor, drops the ceiling | Vanilla data: 128 to 192 keep the furniture and drop the ceilings of the interiors measured; 256 already fails on Breezehome |
A marker shows on the levels whose floor at its sample is the floor nearest its DATA height | MapLevelSet.LevelsAt | A marker stands on a floor; nothing in the record says which | Design: a map marker stands a few units over its floor |
A marker of a descendant worldspace that ONAM moves or scales shows on every level | MapMarkerCatalog | Its height is in its own worldspace’s frame; the ONAM Z offset is not read | Design |
Tests: FloorFieldTests, ObjectHeightSamplerTests, VaultMapTests, LevelStopsTests, ObjectRasterizerTests, ObjectsLayerTests, MapMarkerCatalogTests.
References
The external sources the parsers and design follow. When a source and the code disagree, the entry is in Spec deviations.
UESP
The UESP Skyrim mod pages are the reference
specification. All the pages below are under Skyrim_Mod: on en.uesp.net.
| Page | Covers |
|---|---|
| Mod File Format | Records, groups, subrecords, record flags, FormIds, compression |
| File Format Conventions | Field types: zstring, wstring, lstring, formid |
| Archive File Format | BSA versions 104 and 105 |
| String Table File Format | .strings, .dlstrings, .ilstrings, encodings |
| LOD Settings File Format | lodsettings\<worldspace>.lod |
| Actor Value Indices | Actor value index to AVIF FormId |
Each record and shared field has its own sub-page of Mod File Format:
- Records: ARMO, BOOK, CELL, CONT, FACT, GRAS, LAND, LCTN, LIGH, LTEX, LVLI, NAVM, NPC_, REFR, STAT, TES4, TXST, WRLD.
- Fields: NVNM (navmesh geometry), OBND (object bounds), VMAD (attached Papyrus scripts).
The Skyrim LAND page doesn’t describe the VTXT layout; the
Oblivion LAND page fills the gap.
xEdit
xEdit (TES5Edit) is the reference implementation of the
plugin format. It settles what UESP leaves open: group type 10, record layouts, the .lod size
and terrain LOD block alignment (Core/wbLOD.pas). Its
What’s New for 4.0.0 lists the plugin string
classes and their code pages.
Other game sources
| Source | Covers |
|---|---|
| niftools nif.xml | NIF header, nodes, Havok shapes |
NifSkope sk_effectshader.frag | How an effect shader computes its color, alpha and falloff |
Community Shaders Effect.hlsl | Skyrim SE’s effect shader in HLSL: the soft fade |
Community Shaders Lighting.hlsl | Skyrim SE’s lighting shader in HLSL: normal maps, projected materials |
XPMF MaterialMatcher.hpp | What the engine does with a MATO: single and multipass paths, the shader’s constants, its four textures |
| PapyrusExtenderSSE, Seasons of Skyrim | How plugins fill SetProjectedUVData from a MATO and a Max Angle |
| CommonLibSSE-NG | Names of the engine’s fields: DIRECTIONAL_DATA, materialThresholdAngle |
| DynDOLOD: Terrain LOD and Water LOD | Terrain LOD tile paths: <worldspace>.<level>.<x>.<y>.dds |
| STEP forum: BSA extraction | Loose files override every archive |
| How Skyrim Loads Forms (David J. Cobb) | What the engine does on an override, see Load order and merging |
| Beyond Skyrim Arcane University: Baking | Normal maps: DirectX convention, green flipped against OpenGL |
Other formats
| Source | Covers |
|---|---|
| SWF File Format Specification v19 (Adobe) | SWF container, DefineFont3, SHAPE |
| OpenType specification (Microsoft) | sfnt container, TrueType tables |
| LZ4 frame format | BSA 105 file compression |
| RFC 1950 (zlib) | Record and BSA 104 compression, PNG image data |
| DDS header and programming guide (Microsoft) | Texture container, mip level layout |
| PNG specification (W3C) | Image output |
| PMTiles v3 (Protomaps) | Tile archive: header, TileId, directories |
Book markup (<font>, <img>, [pagebreak]) and fontconfig*.txt have no published
specification; their handling is derived from vanilla data, see
Book markup handling and
Book markup assets.
Benchmarks
A <Project>.Benchmarks project measures the hot paths of <Project> with
BenchmarkDotNet, on inputs built in code. It needs no game data,
so you can compare two versions of a function without rerunning a whole command.
| Project | Measures |
|---|---|
BookAtlas.Exporter.Benchmarks | BookAtlas.Exporter |
Running
nix develop --command dotnet run -c Release --project <Project>.Benchmarks -- --filter '*' --job short
| Option | Effect |
|---|---|
--filter '<pattern>' | Runs the benchmarks whose full name matches, for example '*Landscape*' |
--job dry | One iteration of each benchmark, to check that they run |
--job short | 3 warmups and 3 iterations: enough to compare two versions |
no --job | The default job: longer, tighter error margins |
no --filter | Asks which benchmarks to run |
BenchmarkDotNet refuses a Debug build: always pass -c Release. Results go to
BenchmarkDotNet.Artifacts/, which git ignores.
Run on an idle machine. Another process on the cores, a running command for example, makes the Error
column larger than the difference you look for. A benchmark that runs in parallel suffers most.
Reading the results
| Column | Meaning |
|---|---|
Mean | Time per operation |
Error | Half of the 99.9% confidence interval: the true mean lies within Mean ± Error |
StdDev | Spread between iterations |
Allocated | Managed memory allocated per operation |
A difference between two versions is real when it is well above their Error. Allocations don’t
vary between runs: a change in Allocated is real even when the time is too noisy to tell.
To compare a change, run the same filter before and after it, on the same machine.
In CI
The Benchmarks workflow (.forgejo/workflows/benchmarks.yaml) runs on every pull request that
changes C# code. It runs every *.Benchmarks project of the pull request’s base and of its head in
5 rounds on the same runner, alternating the sides: base then head, head then base, and so on. It
then posts the comparison as a comment on the pull request, and updates that comment on every later
push.
A shared runner’s load comes in bursts that last longer than a benchmark. When the whole base runs before the whole head, a burst that hits one side shifts every benchmark of that side. A parallel benchmark can also settle in a slower mode for a whole process. With alternating rounds, either one hits one round of one side, and the other rounds disagree with it.
The comment lists the changed benchmarks first: faster, slower, new, removed, or with different
allocations. Every benchmark follows in a collapsed section. Base and Head are the fastest round of
each side, since load only adds time, and Change compares them. Rounds is the lowest and highest
change between a base round and the head round run next to it.
| Change | Meaning |
|---|---|
faster or slower | Every round differs in that direction by more than the error margins of both runs |
noise | At least one round doesn’t |
new or removed | The benchmark exists on one side only |
failed on the base or failed on the head | The benchmark has no result in any round of that side |
allocations changed | The allocations differ, whatever the time |
Each round runs a job shorter than the default one, which aims at 500 ms an iteration and runs up to 100 iterations when the times are noisy. More iterations in a round don’t help against a burst that lasts the whole round; more rounds do.
tool/benchmark-rounds.sh runs the rounds, and tool/benchmark-report.sh builds the comment’s
tables from their results. To reproduce the comparison locally, with the base checked out in a
worktree:
git worktree add --detach ../base <base commit>
nix develop --command tool/benchmark-rounds.sh ../base . /tmp/benchmarks 5 \
--iterationTime 250 --warmupCount 6 --iterationCount 10
tool/benchmark-report.sh /tmp/benchmarks/base /tmp/benchmarks/head
tool/benchmark-report.sh needs jq, which the dev shell doesn’t provide. It also reads two plain
--exporters json result folders, each as one round.
A benchmark that runs in parallel needs iterations of 250 ms and 6 warmups: with iterations of 100 ms and 3 warmups, the thread pool is still settling while it is measured.
Limitations:
- A load that lasts the whole run still slows both sides, and a real change smaller than the spread
of the rounds shows as
noise. Trust the allocations more than the times, and confirm a time on an idle machine. - Under the JIT, dynamic PGO profiles a parallel benchmark differently from one process to the next:
a change that only moves code can make a scenario bimodal, two stable means a few percent apart.
Before you treat such a gap as a regression, rerun both sides with
--envVars DOTNET_TieredPGO:0and time the Native AOT export, which has no dynamic PGO. - On a pull request from a fork, the workflow token can’t comment: the table is only in the job log.
- A pull request that changes no
.csor.csprojfile doesn’t run the workflow, and an older comment stays as it was.
Finding what to benchmark
A benchmark measures only the code you point it at. Profile a real run first to find where the
time goes. dotnet-trace attaches to a running process without stopping it:
nix develop --command dotnet tool run dotnet-trace collect -p <pid> --duration 00:00:00:30 -o run.nettrace
nix develop --command dotnet tool run dotnet-trace report run.nettrace topN -n 25
Profile a Release build: in a Debug build, small methods aren’t inlined and take a share of the
profile they don’t have in Release. Threads waiting in the thread pool
(LowLevelLifoSemaphore.WaitForSignal) are idle, not lost time: check the cores the process
uses with top.
Writing a benchmark
- Mirror the folders of the measured project, as the tests do: a benchmark of
BookAtlas.Exporter/Pipelines/Maps/Objects/goes inPipelines/Maps/Objects/. - Build the inputs in
[GlobalSetup], from code. Use seeded random data where the content changes the cost, so every run measures the same input. Shared builders go inSupport/. - End
[GlobalSetup]withTieredJit.WarmUp, calling the benchmark method. BenchmarkDotNet’s pilot sizes the iterations from the first calls: on code the JIT hasn’t optimized yet, it picks iterations shorter than--iterationTime, which are noisier. - Call the method the project itself calls, not a copy of its loop.
- Return the result, or a value derived from it, so the JIT doesn’t drop the work.
- When one call processes many items (pixels, samples, records), set
OperationsPerInvoketo their count:Meanis then the time per item. - Use
[Params]for the variants worth comparing, such as a kernel or a size. Each value multiplies the run time.
Logging
Both CLIs (BookAtlas.Exporter and BookAtlas.Generator) log through the same small helper,
Diagnostics/Logger.cs. Each project has its own copy because the generator can’t reference the
exporter (see Architecture). Keep the two copies identical apart from their
namespace and doc comment.
Two streams
| Stream | Carries | Examples |
|---|---|---|
| stdout | The command’s own output, written with Console.Write* | archive listings, --stats, histograms, decoded VMAD blocks |
| stderr | The log, written with Log.* | progress, summaries, warnings, errors |
You can redirect a command’s output to a file (> out.txt) and still see the log in the terminal,
or silence the log with 2>/dev/null.
Status line
A long stage of the exporter can show its progress on a status line under the log: the worldspace
map commands do, see Output and logging.
Diagnostics/StatusLine.cs wraps stderr, and the logger writes through it:
- the status line is rewritten in place (a carriage return, the text, then an erase to the end of the line), cut to the terminal’s width so it never wraps;
- a log line erases it, is written, then the status line is drawn again under it, so a warning or a
--verboseline never mixes with the progress; - the stage erases it when it ends, even on a failure.
When stderr is not a terminal (a file, a pipe), the status line is off: no carriage return, no escape sequence, only the log lines. A stage that shows a status line logs its progress some other way for that case, the map commands at each tenth of a large map. The generator has no status line.
Levels
| Level | Prefix | Shown | Use it for |
|---|---|---|---|
Log.Debug | [DEBUG] | with --verbose / -v | per-file and per-record detail, known gaps, full lists behind a counted warning |
Log.Info | [INFO] | always | one line per stage or per language: what was read, what was written, where |
Log.Warn | [WARN] | always | an incoherent or unexpected state the run recovers from |
Log.Error | [ERROR] | always | the command can’t do its job, or part of the output is missing |
A continuation line of a multi-line message is indented under the message text.
Warning or debug?
A warning means “the data isn’t what it should be”: a missing plugin or archive, a FormId whose master index isn’t in the master table, a string id missing from its string table, a texture referenced but not shipped, a malformed subrecord that was skipped. Someone should look at it.
A known limitation of this codebase is not a warning. An unsupported Havok shape type or a font face the fontconfig maps to a font no library embeds is expected, documented behavior: log it at debug level and, when useful, log one info line with the count.
When one cause can produce many warnings, log one warning with the count and the full list at
debug level (see Datasets/Merging/UnresolvedFormIdReport.cs and the generator’s unresolved image
report). The warning says “Run with –verbose to list them.”
Exit code and summary
Program.cs builds the logger from --verbose and passes the command’s exit code through
Logger.Complete. It logs Finished with N warning(s) and M error(s). when either count is
non-zero, and turns any logged error into exit code 1. A command reports failure with
Log.Error(...) and a return; it doesn’t need its own exit code.
Where logging happens
CreationEngineFormatsnever logs. It throwsInvalidDataExceptionfor malformed input or returns the problem as data.- Pure transforms in the CLIs (mergers, a dataset’s
MergeandBuildAsync, resolvers) return what they dropped or couldn’t resolve (for exampleBookMergeResult.UnresolvedFormIds,LocationMergeResult.UnresolvedFormIds,BookLocalizationResolver.CountUnresolved). The dataset’sReportlogs what a merge dropped, once per session; the pipeline logs the rest. This keeps them testable without capturing console output. - Code that does I/O against game files (
Game/Assets/, the font export, the interior resolvers) may log directly, with enough context to find the source: plugin, language, FormId, archive path. - Don’t log inside a per-record hot loop, even at debug level. Aggregate, then log once. Guard a
debug message that is costly to build with
Log.IsDebugEnabled.
CreationEngineFormats
The format library: no CLI, no I/O policy beyond reading a file, no knowledge of vanilla Skyrim Special Edition as a release. Each page in this part documents an on-disk layout and how the code reads it. See Architecture for how the library fits with the two CLIs.
BSA archive format
Implemented in CreationEngineFormats/ArchiveFile/. Reference:
UESP Archive File Format.
BsaListingReader.ReadAsync reads the blocks in the order the format requires (each offset
depends on the previous block) and returns a flat list of entries. BsaFileExtractor reads one
entry’s data on demand.
| Version | Game | Compression | Folder record |
|---|---|---|---|
| 104 | Skyrim | zlib | 16 bytes |
| 105 | Skyrim Special Edition | LZ4 frame | 24 bytes |
Header
The 36-byte header (Reader/HeaderReader.cs) follows the spec as written. BsaArchiveFlags
lists every archive flag of the spec. The ones the readers act on:
| Flag | Value | Effect |
|---|---|---|
IncludeDirectoryNames | 0x1 | Each file record block starts with the folder name |
IncludeFileNames | 0x2 | The file name block is present |
CompressedArchive | 0x4 | Files are compressed by default |
EmbedFileNames | 0x100 | Each file block starts with the file’s path |
Blocks
| Block | Reader | Layout |
|---|---|---|
| Folder records | FolderRecordsReader | v104: hash (8), file count (4), offset (4). v105 adds 4 padding bytes after the count and after the offset |
| File record blocks | FileRecordBlocksReader | Per folder: name as a bzstring (if 0x1), then one record per file: hash (8), size (4), offset (4) |
| File name block | FileNameBlockReader | One null-terminated name per file, in file record order (if 0x2) |
A folder record’s offset counts the file name block even though that block comes after the file
record blocks: the reader subtracts the total file name length. The file name block is read in one
call of that length, then split on the \0s; \0 padding after the last name is skipped, see
Assumptions. Without a file name
block, an entry is named after its hash.
In a file record’s size, bit 30 (0x40000000) inverts the archive’s default compression for that
file. BsaFileRecord.ActualSize masks it out, IsCompressed(flags) applies it.
File blocks
| Field | Present when |
|---|---|
| Path as a bstring | EmbedFileNames is set |
| uint32 original size | The file is compressed |
| Data | Always |
Version 105 stores each compressed file as a full LZ4 frame (magic 04 22 4D 18), not a raw
LZ4 block. The block decoder LZ4Codec.Decode doesn’t throw on a frame: it returns data of the
right length with the first bytes corrupted. BsaFileExtractor uses the frame decoder
LZ4Stream.Decode.
String tables
.strings, .dlstrings and .ilstrings files live under Strings\, named
<plugin>_<language>.<extension>. Vanilla ships them in Skyrim - Interface.bsa. Reference:
UESP String Table File Format.
SkyrimStringTable.Decode reads them.
| Part | Layout |
|---|---|
| Header | uint32 count, uint32 data size |
| Directory | Per entry: uint32 string id, uint32 offset into the data. Not required to be sorted |
Data (.strings) | Null-terminated strings |
Data (.dlstrings, .ilstrings) | uint32 length, null included, then the string |
Encodings and the fallback rules are in Localization.
Several archives
Vanilla content is split over several archives, and each plugin can add its own. The exporter
merges them into one path index, the archive file system (Game/Bsa/ArchiveFileSystem.cs), see
Load order: when a path is in
several archives, the last one wins, see
Spec deviations.
A loose file in Data overrides every archive, see
Loose files.
Each archive keeps one stream; extraction seeks and reads under a per-archive lock, so entries
can be extracted from several threads.
Plugin (ESM/ESP/ESL) file format
Implemented in CreationEngineFormats/Plugin/. Reference:
UESP Mod File Format, with one sub-page
per record type. Field types (zstring, lstring, formid, …) follow
UESP File Format Conventions.
Where the code departs from these pages, the entry is in
Spec deviations.
A plugin is one TES4 record followed by top-level GRUPs, one per record type.
PluginWalker.ReadHeader reads the TES4 record and returns the offset of the first group.
Record header
The 24-byte header (RecordHeader.cs) follows the spec: type, data size (header excluded),
flags, FormId, then version control fields the code doesn’t read.
RecordFlags.cs lists every flag of the UESP table. The ones this codebase reads:
| Flag | Value | Use |
|---|---|---|
Deleted | 0x20 | Deleted records are dropped by a query unless it asks for them |
DoorHiddenFromLocalMap | 0x40 | On a REFR of a DOOR: kept with the reference, see below |
Localized | 0x80 | On TES4: lstrings are string table ids |
HiddenFromLocalMap | 0x200 | On a REFR of an ACTI, STAT or TREE: kept with the reference, see below |
Persistent | 0x400 | On REFR: exported as a heuristic, see below |
InitiallyDisabled | 0x800 | On REFR: left off the maps, see export heuristics |
DataCompressed | 0x40000 | The data is compressed, see below |
IsMarker | 0x800000 | On a base object: ResolvedBaseObject.IsMarker |
When DataCompressed is set, the data is a uint32 decompressed size followed by a zlib stream.
Compression.DecompressIfNeeded handles it; every reader calls it first. This is independent
of BSA compression.
Groups
A GRUP header is also 24 bytes, but its size field includes the header. Its label’s meaning
depends on the group type:
| Group type | Name | Label |
|---|---|---|
| 0 | Top | Record type (BOOK, WRLD, …) |
| 1 | World children | Parent WRLD FormId |
| 2, 3 | Interior cell block, sub-block | Block number |
| 4, 5 | Exterior cell block, sub-block | Grid Y, X |
| 6 | Cell children | Parent CELL FormId |
| 7 | Topic children | Parent DIAL FormId |
| 8, 9 | Cell persistent, temporary children | Parent CELL FormId |
| 10 | Cell visible distant children | Parent CELL FormId, not in the UESP table |
Walking a plugin
PluginWalker visits the records a RecordTypeSet asks for. It follows this topology:
GRUP top WRLD
WRLD
GRUP 1 (world children)
CELL (persistent cell) + GRUP 6
GRUP 4 > GRUP 5 > CELL + GRUP 6
GRUP top CELL
GRUP 2 > GRUP 3 > CELL + GRUP 6
GRUP 6 (cell children)
GRUP 8 | 9 | 10 > REFR, ACHR, LAND, NAVM, PGRE, PHZD
GRUP top DIAL
DIAL + GRUP 7 (topic children) > INFO
GRUP top <any other type>
records of that type
A CELL has a children group only if one immediately follows it: the walker reads the next
header and leaves it to the enclosing level when it isn’t the matching group. Interior versus
exterior comes from which top group the walk is in, not from CELL’s DATA flags.
The walker enters a group only when a requested type can be inside it, and otherwise moves straight to the group’s end:
| Group | Entered when the set asks for |
|---|---|
Top WRLD | WRLD, CELL or a cell child type |
Group 1 (world children), top CELL | CELL or a cell child type |
| Group 6 (cell children) | A cell child type: REFR, ACHR, LAND, NAVM, PGRE, PHZD |
Top DIAL, group 7 | DIAL; the topic children only for INFO |
| Any other top group | Its own type, or every top group record |
Each visited record comes with its header, the offset of its data in the file and its enclosing
worldspace and cell (LocationContext). Deleted records are visited too: dropping them is the
caller’s choice, see Reading plugins with queries.
The walker checks every header against the end of the file, and throws InvalidDataException
on a truncated entry, a group smaller than its own header, or a nested group where the spec
allows none (anything but group 7 inside a top group, anything inside groups 7 to 10).
Subrecords
Each subrecord is a 4-byte tag, a uint16 size, then the data. An XXXX subrecord carries a
uint32 that replaces the size of the next subrecord. SubrecordCursor hides it.
Records read
Every reader returns nullable fields: an override record only carries the subrecords it changes, and merging is the caller’s job (see Load order and merging). A subrecord shorter than its spec size is skipped.
TES4
UESP TES4, TES4Reader.
| Subrecord | Type | Field |
|---|---|---|
HEDR | float32, uint32, uint32 | Version, record count, next object id |
CNAM | zstring | Author |
SNAM | zstring | Description |
MAST + DATA | zstring + uint64 | One master; DATA is always 0 |
The order of MAST entries is the master index a FormId’s top byte refers to.
BOOK
UESP BOOK, BookReader.
| Subrecord | Type | Field |
|---|---|---|
EDID | zstring | EditorId |
VMAD | VMAD | Vmad, see below |
FULL | lstring | Title |
ICON | zstring | InventoryImage |
DESC | lstring | Content |
KWDA | formid[] (KYWD) | KeywordFormIds |
DATA | struct, 16 bytes | Flags, Type, Teaches, Value, Weight, see below |
INAM | formid (STAT) | MenuArtFormId |
CNAM | lstring | Description |
DATA layout:
| Offset | Type | Field | Values |
|---|---|---|---|
| 0 | uint8 | Flags | 0x01 teaches skill, 0x02 can’t be taken, 0x04 teaches spell, 0x08 read |
| 1 | uint8 | Type | 0 book or tome, 255 note or scroll |
| 2 | uint8[2] | unused | always 0 |
| 4 | uint32 | Teaches | Actor value index with 0x01, SPEL FormId with 0x04 |
| 8 | uint32 | Value | Gold |
| 12 | float32 | Weight |
A truncated DATA keeps the fields it fully holds. A type outside 0 and 255 is kept as read;
the exporter reports it. KSIZ (the keyword count) isn’t read: KWDA’s length gives the count,
see Assumptions.
INAM points at a STAT whose model carries the artwork; map-like Creation Club books use it
instead of text. MODL, MICO, OBND, DEST, YNAM and ZNAM aren’t read, see
Not implemented.
Named records
NamedRecordReader reads EDID (zstring) and FULL (lstring) from any record type. The
exporter uses it for the SPEL, AVIF and KYWD records a BOOK points at. KYWD has no
FULL.
ActorValues maps the 18 skill actor value indices (6 to 23) to their name and their AVIF
FormId in Skyrim.esm, from UESP Actor Value Indices.
WRLD
UESP WRLD, WorldspaceReader.
| Subrecord | Type | Field |
|---|---|---|
EDID | zstring | EditorId |
FULL | lstring | Name |
WNAM | formid (WRLD) | ParentWorldspaceFormId |
PNAM | uint16 flags | ParentUseFlags |
CNAM | formid (CLMT) | ClimateFormId |
NAM2 | formid (WATR) | WaterFormId |
XLCN | formid (LCTN) | LocationFormId |
XEZN | formid (ECZN) | EncounterZoneFormId |
ZNAM | formid (MUSC) | MusicFormId |
DATA | uint8 flags | Flags |
WCTR | int16[2] | FixedCenterCell |
DNAM | float32[2] | LandData: default land and water heights |
MNAM | 16 or 28 bytes | MapData: map size and NW/SE cells |
NAM0, NAM9 | float32[2] each | Bounds, set only when both are present |
ONAM | float32[4] | MapOffset: world map scale, then X, Y and Z offsets |
Other WRLD subrecords aren’t read.
CELL
UESP CELL, CellReader.
| Subrecord | Type | Field |
|---|---|---|
EDID | zstring | EditorId |
XCLC | int32, int32, uint32 | GridX, GridY; the flags aren’t read |
DATA | uint16 flags, sometimes one byte | Flags, including “Has Water” |
XCLW | float32 | WaterHeight, as stored |
An XCLW can be a “no water” marker instead of a height. CellWaterHeight.IsWater sorts them
out, see Deviations.
LAND
UESP LAND, LandscapeReader. The
walker yields a LAND without reading it; only the map water layer and the raster-records
background parse it. VNML and DATA are not read.
| Subrecord | Type | Field |
|---|---|---|
VHGT | float32, int8[33x33], 3 unused | Heights: 33x33 heights in game units |
VCLR | uint8[33x33x3] | Colors: an RGB vertex color per vertex, on the VHGT grid |
BTXT | formid, uint8 quadrant, 3 unknown | Textures.BaseTextures: the base LTEX of a quadrant |
ATXT | formid, uint8 quadrant, 1 unknown, uint16 layer | Textures.Layers: one texture layer of a quadrant |
VTXT | 8 bytes per point: uint16 position, 2 unknown, float32 opacity | The points of the ATXT before it |
The float of VHGT is the south-west vertex. Each value of the first column offsets its row and
every row to the north; each other value offsets the rest of its row. One unit is 8 game units, the
offset included. Rows run south to north, columns west to east, 128 units apart.
The quadrants are 0 south-west, 1 south-east, 2 north-west, 3 north-east. A quadrant without a
BTXT, or with a zero LTEX, is drawn with dirt02.dds. The Skyrim page doesn’t describe VTXT;
its layout and the mapping of its points to the 33x33 grid are in
assumptions. A part whose subrecords are
missing or too short is null. A BTXT or ATXT with a quadrant past 3, the VTXT after such an
ATXT, a VTXT point past position 288 and a trailing partial point are dropped.
LTEX, TXST and GRAS
UESP LTEX (LandscapeTextureReader),
UESP TXST (TextureSetReader) and
UESP GRAS (GrassReader).
A LAND texture points at an LTEX, which points at the TXST holding the texture paths and at
the GRAS it grows.
| Record | Subrecord | Type | Field |
|---|---|---|---|
LTEX | EDID | zstring | EditorId |
LTEX | TNAM | formid | TextureSetFormId, the TXST |
LTEX | GNAM | formid, repeated | GrassFormIds, one per GRAS, in record order |
TXST | EDID | zstring | EditorId |
TXST | TX00 | zstring | DiffusePath, the color map, relative to textures\ |
TXST | TX01 | zstring | NormalPath, the normal map, relative to textures\ |
TXST | DNAM | uint16 flags | Flags: 0x01 no specular map, 0x02 facegen textures, 0x04 model-space normal map; null when shorter than 2 bytes |
GRAS | EDID | zstring | EditorId |
GRAS | MODL | zstring | ModelPath, relative to meshes\ |
GRAS | DATA | uint8 Density, uint8 Min Slope, uint8 Max Slope at offsets 0, 1, 2 | Density, MinSlope, MaxSlope; null when DATA is shorter than 3 bytes |
GRAS | DATA | uint16 Distance from water at offset 4, uint32 How water distance is applied at 8 | WaterDistance, WaterMode (GrassWaterMode, numbered from 0, see deviations); null when DATA is shorter than 12 bytes |
A GNAM shorter than a formid is skipped. The units of the GRAS fields are in
assumptions and
water distance; the fields not read are in
not implemented.
LIGH
UESP LIGH, LightReader. A light
placed in a cell is a REFR whose base is a LIGH; its XRDS changes the radius, see
REFR and ACHR.
| Subrecord | Type | Field |
|---|---|---|
EDID | zstring | EditorId |
DATA | uint32 Radius, rgb Color (0x00BBGGRR), uint32 Flags at offsets 4, 8, 12 | Radius, Color, Flags; null when DATA is shorter than 16 bytes |
The fields not read are in not implemented.
NAVM
UESP NAVM and
NVNM, NavmeshReader. Only the
roads layer of the maps parses a NAVM; the crop locates it from its header. Of NVNM, the reader
reads the vertices and the triangles, then stops: edge links, door triangles, cover triangles and
the grid are not read, nor are ONAM, PNAM and NNAM.
| Part | Layout | Field |
|---|---|---|
| Header | uint32 unknown (12), uint32 location marker, formid worldspace, 4 bytes cell or grid | Skipped |
| Vertices | int32 count, then float32 X, Y, Z each | Geometry.Vertices, world units |
| Triangles | int32 count, then 16 bytes each: int16 vertex 0 to 2, int16 edge 0, uint16 edge 1 and 2, uint16 “Cover marker?”, uint16 cover flags | Geometry.Triangles: vertices and the “Cover marker?” field as Flags |
The page names no bit of “Cover marker?”; what the code reads in it is in
assumptions. An NVNM whose counts run
past the subrecord, or with a triangle naming a vertex that isn’t there, leaves Geometry null.
REFR and ACHR
UESP REFR, ReferenceReader. An
ACHR (placed actor) has the same NAME and DATA layout and goes through the same reader.
| Subrecord | Type | Field |
|---|---|---|
NAME | formid | BaseFormId, the placed base object |
DATA | float32[6] | Position, then rotation in radians |
VMAD | VMAD | HasScript: presence only |
XTEL | struct, 32 bytes | HasTeleport; TeleportDestinationFormId is the first field |
XSCL | float32 | Scale, null when absent |
XPRM | struct, 32 bytes | HasPrimitive: presence only |
XRDS | float32 | Radius, null when absent; on a light, an offset to its base’s radius, see light radius |
XTEL marks a cell transition: its destination is the REFR on the other side. An XTEL too
short for the destination still sets HasTeleport.
A REFR’s header flags change meaning with its base’s record type: 0x200 hides an ACTI, STAT
or TREE from the local map but makes a LIGH cast shadows. ReferenceFlags.IsHiddenFromLocalMap
reads the bit the base gives that meaning, see
assumptions.
The Persistent record flag marks an always-loaded reference. Bethesda sets it on quest-critical
placements but also elsewhere, so the export presents it as “possibly quest-related”.
CONT, LVLI, NPC_ and FACT
These are definitions, not placements, so they have no enclosing cell.
| Record | Subrecord | Layout | Read |
|---|---|---|---|
| CONT | CNTO | formid, uint32 count | FormId |
| LVLI | LVLO | uint32 level, formid, uint32 count | All three |
| NPC_ | CNTO | formid, uint32 count | FormId |
| NPC_ | SNAM | formid, int8 rank, 3 unused | Faction FormId |
| FACT | VENC | formid (REFR) | Vendor chest |
An LVLO entry can be another LVLI, so reachability walks the list graph. VENC names a
placed chest REFR, not a CONT. How these combine into book locations is in
Load order and merging.
Base objects
ModeledObjectReader reads EDID, MODL and OBND from any record type: a REFR’s base object
can be a STAT, FURN, DOOR, CONT and a dozen more, all with their model path in MODL.
An ARMO is the exception: its MODL are the FormIDs of its ARMA armatures, and its model on
the ground is MOD2, else MOD4, see armor ground model.
OBND is six int16: x1, y1,
z1, x2, y2, z2, the object’s bounding box in its own space. An OBND shorter than 12 bytes
leaves Bounds null. A STAT’s DNAM gives Material: its Max Angle, its MATO and, in SSE, Considered
Snow. A DNAM under 8 bytes, or naming no material, leaves it null.
MATO
UESP MATO, xEdit for the fields by form version
(DirectionalMaterialReader). Its size tells which fields a DATA has, see
Projected materials.
| Offset | Type | Field | Size from |
|---|---|---|---|
| 0, 4, 8, 12 | float | FalloffScale, FalloffBias, NoiseUvScale, MaterialUvScale | 28 |
| 16 | float × 3 | ProjectionVector | 28 |
| 28 | float | NormalDampener | 32 |
| 32 | float × 3 | SinglePassColor, 0 to 1 | 48 |
| 44 | uint32 | SinglePass | 48 |
| 48 | uint32 | IsSnow | 52 |
A DATA under 28 bytes, or none, leaves Data null. DNAM, the properties of a multipass material, isn’t read.
VMAD
UESP VMAD field,
VmadReader. Decodes the header (version, object format, script count), each script (name,
status from version 4, properties) and each property (name, type, status from version 4,
value). The “Fragments” block of QUST, PERK, SCEN, INFO and PACK isn’t decoded.
Its wstrings are UTF-8, see VMAD string encoding.
| Type | Value |
|---|---|
| 1 | Object: formid and alias id, order depends on the object format |
| 2 | wstring |
| 3 | int32 |
| 4 | float32 |
| 5 | bool (uint8) |
| 11 to 15 | uint32 count, then items of type 1 to 5 |
| Object format | Layout |
|---|---|
| 1 | formid, uint16 alias, 2 zero bytes |
| 2 | 2 zero bytes, uint16 alias, formid |
Truncated data throws InvalidDataException. Only BOOK scripts are exported; REFR only
reports whether a VMAD exists. debug:dump:plugin:vmad
decodes the VMAD of every record type it scans.
lstrings
An lstring is inline text or a string table id, decided once per plugin by the TES4
Localized flag. BufferDecode.LString is the only place that branches on it. Resolving an id
is described in Localization.
Reading plugins with queries
Every command that reads plugins declares what it needs as a PluginQuery: which record types,
which of them to parse, and what to keep. The query runs in one walk per plugin. The layout it walks
is in Plugin file format.
Code: CreationEngineFormats/Plugin/PluginFile.cs, PluginWalker.cs, RecordTypeSet.cs and
Plugin/Query/.
Where the time goes
Measured on Skyrim.esm (238 MiB, about 750,000 records in the world and cell groups):
| Step | Cost |
|---|---|
| Reading a record header | Almost free: walking every header of the file takes ~30 ms |
| Reading and decompressing a record’s data | Expensive: zlib is the largest CPU cost of a worldspace read |
| Keeping a parsed record alive | The most expensive: 700,000 parsed REFRs keep the GC busy for the rest of the run |
A query makes the last two visible: a record is only parsed if a clause parses it, and only kept if a clause keeps it.
An example
var query = new PluginQuery();
var worldspaces = query.Records(Tags.WRLD).Parse(WorldspaceReader.Parse);
var cells = query.Records(Tags.CELL).Parse(CellReader.Parse);
var landscapeCells = query.Records(Tags.LAND).Distinct((in WalkedRecord r) => r.Context);
using (var file = PluginFile.Open(pluginFile))
query.Run(file);
// worldspaces.Items, cells.Items, landscapeCells.Items
landscapeCells never reads a LAND’s data: the clause only uses the header and the location.
The walker also skips every group this query doesn’t need (every REFR group, every top group
other than WRLD and CELL) with a single jump over the group.
Clauses
query.Records(types) matches records of these types wherever they sit in the GRUP tree.
query.TopGroupRecords() matches every record directly inside a top group other than WRLD and
CELL, whatever its type. It is what a FormId resolver uses, since a REFR’s base object can be
any placeable type and the code keeps no list of them.
| Filter | Effect |
|---|---|
.Where(record => ...) | Keeps the records the filter accepts. It sees the header and location only, so a rejected record’s data is never read |
.IncludeDeleted() | Deleted records are dropped by default. A merge that must see a deleted override asks for them |
| Terminal | Returns | Reads the data |
|---|---|---|
.Headers(record => value) | Collected<T>, one value per record | No |
.Distinct(record => value) | CollectedSet<T>, each value once | No |
.Parse(Reader.Parse) | Collected<Record<T>> through an existing reader | Yes |
.Select((record, raw, isLocalized) => value) | Collected<T>, for anything a reader alone doesn’t cover | Yes |
Parse and Select take parallel: true: the records are noted during the walk and parsed on
every core once it is done. Results keep the file order. Use it for record types with many
records, like REFR.
A result read before Run throws. An empty result therefore always means “no such record in the
plugin”, never “not asked” or “not run yet”.
How a dataset declares its clauses
The exporter keeps the clauses of one model in a query class next to it: BookQuery,
LocationQuery, WorldspaceQuery, WorldspaceMapQuery, VmadQuery. A dataset attaches that
class to the plugin’s query and returns its result:
public sealed record BookRecords : PluginDataset<PluginBooks, BookSet>
{
public override Func<PluginBooks> Attach(PluginQuery query) => new BookQuery(query).Result;
// Merge, Report
}
The session builds one PluginQuery per plugin and hands it to every dataset loaded together, so
export:books reads each plugin once for its books and its locations. A lookup (BaseObjects,
NamedRecords) also gets the plugin’s masters: its filter resolves FormIds during the walk, so it
only keeps the wanted records. See Architecture.
To read something new, add a clause to the query class that owns the model, or write a new query
class and a dataset for it in the domain’s folder of Datasets/. When a query reads some parts only
on demand, like WorldspaceMapReads does for the map’s playable cells and heights, a part not
asked for is null in the model, never an empty list: a caller can’t mistake “not read” for “none
in the plugin”.
The file
PluginFile.Open maps the plugin into memory. The walker and the readers see it as one
ReadOnlySpan<byte>: a record’s data is a slice of the file, never a copy, and pages are only read
from disk when a byte of them is used. PluginFile.FromBytes wraps a byte array for tests.
A span is indexed by an int, so a plugin can’t exceed 2 GiB. The largest vanilla master,
Skyrim.esm, is 238 MiB.
FormIds and GlobalFormIds
Reference: UESP Mod File Format, Form IDs.
FormId
A record’s FormId is only meaningful inside the plugin that stores it (BufferDecode.cs: FormId).
| Bits | Field | Meaning |
|---|---|---|
| 31 to 24 | MasterIndex | Index into this plugin’s MAST list, in declaration order |
| 23 to 0 | LocalId | Id within the plugin that defines the record |
A MasterIndex equal to the number of masters means the plugin defines the record itself. So
the same record, edited by three plugins, can appear with three different FormId values.
GlobalFormId
GlobalFormId.cs resolves a FormId to (OwningPlugin, LocalId), the same for every plugin of a
load order. Its text form is skyrim.esm:0B7736, which the CLI options also accept.
PluginMasters holds one plugin’s master list and resolves the FormIds it wrote:
var masters = new PluginMasters(pluginFileName, tes4);
if (masters.TryResolve(record.FormId, out var formId)) { ... }
GlobalFormId? menuArt = masters.Resolve(book.MenuArtFormId); // null when absent or unresolvable
A MasterIndex past the plugin itself doesn’t resolve. There is no safe fallback: callers drop
the record and report it (see Reported data problems).
Resolution needs the writing plugin’s master list, so it happens before records from different plugins are merged. Building a load order on top of this is the exporter’s job, see Load order and merging.
SWF font parsing: DefineFont3 to TrueType
Implemented in CreationEngineFormats/Swf/, without Skyrim-specific knowledge. References:
- SWF File Format Specification, version 19
(Adobe, “SWF19”): container,
RECT,SHAPE,DefineFont3,DefineFontName. - OpenType specification (Microsoft):
the sfnt container and the
cmap,glyf,head,hhea,hmtx,loca,maxp,name,OS/2andposttables.
The exporter side (which SWFs, which fonts) is in Font export.
SWF container
SwfReader: a 3-byte signature, a version byte and a uint32 file length, then the body.
| Signature | Body | Support |
|---|---|---|
FWS | Uncompressed | Read |
CWS | zlib | Read; the only kind in the interface archive |
ZWS | LZMA | Throws NotSupportedException |
The body starts with a bit-packed RECT, a frame rate and a frame count, all skipped, then the
tags. A tag header is a uint16: code in the top 10 bits, length in the low 6; a length of 0x3F
means a uint32 length follows. SwfBitReader reads the MSB-first bit fields.
DefineFont3
DefineFont3Reader (tag 75), the only font tag found in Skyrim SWFs. DefineFontName (tag 88)
supplies each font’s name.
| Field | Notes |
|---|---|
| Font id | uint16 |
| Flags | Has layout 0x80, wide offsets 0x08, wide codes 0x04, italic 0x02, bold 0x01 |
| Language code, name | Skipped: DefineFontName carries the name |
| Glyph count | uint16 |
| Offset table | uint16 or uint32 per glyph, then the code table offset |
| Glyph shapes | SHAPE records: move, straight and quadratic curve edges |
| Code table | uint8 or uint16 per glyph |
| Layout | Only with the layout flag: ascent, descent, leading, advances, bounds, kerning (not read) |
Quadratic curves are the same curve type as TrueType glyf, so no curve fitting is needed.
Three properties aren’t stated by SWF19 and were checked on real files, see
Spec deviations: the EM square is 20480
units, Y points down, and the per-glyph bounds are always zero.
TrueType writer
SfntBuilder writes the table directory, padding and checksums, including
head.checkSumAdjustment. TrueTypeFontWriter builds the tables:
| Choice | Why |
|---|---|
| 2048 units per EM | 20480 exceeds the head limit of 16384; dividing by 10 is exact |
Synthesized .notdef at glyph 0 | Required by TrueType; SWF glyphs follow in order |
glyf bounds from the contour points | The SWF bounds are unusable |
cmap format 4, format 12 when format 4’s uint16 length overflows | Firefox rejects format 6; format 12 covers the 17,514-glyph Chinese font |
Format 4 through idRangeOffset and glyphIdArray | Glyph order follows the SWF, not character codes |
OS/2 version 0 | Smallest version with usWinAscent and usWinDescent, which set line height |
post version 3.0 | No glyph names needed |
One hmtx entry per glyph | Simpler; the fonts are small |
Generated fonts pass fc-validate and fc-scan (FreeType). FreeType accepts cmap formats
browsers don’t: format 6 passed FreeType but Firefox refused it. Any change to the table formats
needs a check through @font-face in a browser. Glyph winding hasn’t been checked visually.
NIF / Havok format
Implemented in CreationEngineFormats/Nif/. There is no official NIF specification; the
reference is niftools’ nif.xml, the
description NifSkope is built from. Layouts below are for version 20.2.0.7, BS version 100
(Skyrim Special Edition).
The parser covers what a map needs from a model: the positions, normals, UVs and triangles of its
BSTriShape blocks placed in the model’s space, the diffuse texture of each shape and how it is
mapped, its alpha test, the vertex colors a shader tints it with, and the Havok collision a
footprint is built from. It reads no materials, particles or animation: a skinned shape is
posed by its bones as the file stores them.
debug:dump:plugin:interior-collision-shapes
measures which collision shapes resolve in practice. Truncated or inconsistent data makes NifReader.Parse, TriShapeReader and
NifSceneReader throw InvalidDataException; the other block readers return false.
Header
NifReader, nif.xml Header and BSStreamHeader.
| Field | Type | Condition |
|---|---|---|
| Header string | ASCII, ends with \n | |
| Version | uint32 | |
| Endian type | uint8 | |
| User version | uint32 | |
| Block count | uint32 | |
| BS version | uint32 | |
| Author | ExportString | |
| Unknown int | uint32 | BS version > 130 |
| Process script | ExportString | BS version < 131 |
| Export script | ExportString | |
| Max filepath | ExportString | BS version >= 103 |
| Block type count, block types | uint16, SizedString[] | |
| Block type index | uint16[block count] | |
| Block size | uint32[block count] | |
| String count, max length, strings | uint32, uint32, SizedString[] | |
| Group count, groups | uint32, uint32[] |
A SizedString is a uint32 length and the characters. An ExportString is a byte length, counting a
null terminator, and the characters. Blocks follow the header back to back, so NifDocument
locates block i from the sizes without parsing the blocks before it.
Blocks
| Block | Fields read | Reader |
|---|---|---|
NiNode and subtypes | Name (string index), extra data refs (skipped), controller, flags (uint32), translation, rotation (row-major 3x3), scale, collision object ref, children refs | NiNodeReader |
bhkCollisionObject | Target (skipped), flags (uint16), body ref | CollisionObjectReader |
bhkRigidBody, bhkRigidBodyT | Shape ref, the first field | CollisionObjectReader |
BSShaderTextureSet | int32 count, SizedString textures; slot 0 is the diffuse map, slot 1 the normal map, slot 2 the glow map of a Glow shader | ShaderTextureSetReader |
BSTriShape | See BSTriShape | TriShapeReader |
BSLightingShaderProperty | Shader type (uint32, before the name), NiObjectNET, two uint32 flags (flag 1 bit 12 Model_Space_Normals, bits 26 and 27 Decal and Dynamic_Decal, flag 2 bit 5 Vertex_Colors), UV offset and scale (2 floats each), texture set ref, emissive color and multiple (4 floats), texture clamp mode (uint32), alpha (float) | ShaderPropertyReader |
NiAlphaProperty | NiObjectNET, flags (uint16), threshold (uint8) | AlphaPropertyReader |
BSEffectShaderProperty | NiObjectNET, two uint32 flags (flag 1 bits 3 to 6 Vertex_Alpha, Greyscale_To_PaletteColor, Greyscale_To_PaletteAlpha, Use_Falloff, bit 30 Soft_Effect; flag 2 bit 5 Vertex_Colors), UV offset and scale, source texture (SizedString), texture clamp mode (uint8), three bytes skipped, falloff start and stop angles and opacities (4 floats), base color (Color4), base color scale (float), soft falloff depth (float), greyscale texture (SizedString) | ShaderPropertyReader |
BSWaterShaderProperty | NiObjectNET, two uint32 flags, UV offset and scale, water shader flags (uint32); only its block type is used: it marks a water surface | NifSceneShape.ShaderType |
NiNodeReader accepts NiNode, BSFadeNode, BSLeafAnimNode, BSMultiBoundNode,
BSOrderedNode and BSTreeNode: they share NiNode’s layout up to the children list.
BSFadeNode is the usual root of static meshes.
The rotation of a NiAVObject is nine floats. The code reads them as a row-major matrix and
applies it to column vectors; nif.xml calls the storage column-major without saying how a point is
multiplied. See Spec deviations.
BSTriShape
TriShapeReader, nif.xml BSTriShape and BSVertexDataSSE. The layout is read for BS version
100 only: Fallout 4 (130) widens the triangle count to uint32.
| Field | Type | Read |
|---|---|---|
NiObjectNET, NiAVObject | As for NiNode | Name, local transform |
| Bounding sphere | Center (Vector3), radius (float) | Skipped |
| Skin | Ref | Yes, see Skinned shapes |
| Shader property | Ref | Yes |
| Alpha property | Ref | Yes |
| Vertex desc | uint64 bitfield | Vertex size, UV, normal, tangent and color offsets, attributes |
| Triangle count | uint16 | Yes |
| Vertex count | uint16 | Yes |
| Data size | uint32 | Checked against the counts |
| Vertex data | Vertex count × vertex size bytes | Positions, UVs, normals, tangents, bitangents, colors |
| Triangles | Triangle count × three uint16 | Yes |
Vertex data and triangles are present only when the data size is above 0. A skinned shape stores
its geometry in its NiSkinPartition instead, see Skinned shapes.
The vertex desc (nif.xml BSVertexDesc) gives the vertex size, the offsets of the UVs, normal,
tangent, colors and skinning data, and the attribute flags; its offsets count in units of 4 bytes,
see assumptions. The reader takes the
position (always full precision in SSE, so Full_Precision is ignored), the HalfTexCoord UVs
(v grows down the texture’s rows), the ByteColor4 vertex colors and the bone weights and indices.
An offset that leaves no room for its field in the vertex throws.
The tangent frame follows each field’s condition in BSVertexDataSSE:
| Field | Where | Read when |
|---|---|---|
| Normal | Three normbytes at the normal offset | Normals |
| Bitangent Y | The normbyte after the normal | Normals |
| Tangent | Three normbytes at the tangent offset | Vertex, Normals and Tangents |
| Bitangent Z | The normbyte after the tangent | Vertex, Normals and Tangents |
| Bitangent X | The float after the position | Vertex, Normals and Tangents |
A normbyte maps 0 to 255 onto -1 to 1, see
assumptions. NifSceneShape.Normals turns
the normals into the model’s space by the shape’s model transform, without its scale, and brings
them back to unit length; Tangents and Bitangents are turned the same way.
A shape takes its vertex colors only when its shader property also sets Vertex_Colors, bit 5 of
its second flags (NifSceneShape.VertexColors): the vertex desc says the colors are stored, the
shader that it multiplies its color by them. Without a shader, or with a truncated one, the shape
is untinted.
The data size must equal vertex size × vertex count + 6 × triangle count, and every triangle
index must be below the vertex count; otherwise the reader throws.
A shape’s diffuse texture comes from its shader property: slot 0 of the BSShaderTextureSet a
BSLightingShaderProperty points at, or the source texture of a BSEffectShaderProperty. Other
shader types (sky, water) have none. A lighting shader also gives its normal map, slot 1
(NormalTexturePath), and whether it sets Model_Space_Normals (ModelSpaceNormals): the map then
holds normals in the model’s space instead of the vertices’ tangent space. It gives what the shape
emits (Emissive), with on a Glow shader its glow map, slot 2 (GlowTexturePath), and whether it is a
decal (Decal). A texture set with fewer slots, an empty slot or a truncated one gives no path. The scene also gives each shape the block type of its shader
property (ShaderType), so a reader can tell an effect from a lit surface.
A lighting or effect shader also gives the shape its TextureMapping: a texture coordinate is
uv × UV Scale + UV Offset, then wrapped or clamped along u (S) and v (T) by the clamp mode
(TexClampMode: 0 clamps both, 1 clamps S and wraps T, 2 wraps S and clamps T, 3 wraps both;
a byte in an effect shader). An effect shader also gives the shape its material
(NifSceneShape.Effect), the fields after its source texture. Any other shader, or a truncated
block, gives the nif.xml defaults: no offset, a scale of 1, wrapped both ways.
The shape’s NiAlphaProperty gives its alpha test (test function and threshold) and its blending
(source and destination AlphaFunction), with nif.xml’s flag layout. A missing or truncated block
gives no alpha property.
A shape also takes its lighting shader’s material opacity, the Alpha float after Texture Clamp Mode (NifSceneShape.MaterialAlpha, 1 for any other shader or a truncated one), and its vertex
alphas when the vertex desc stores colors and its shader sets Vertex_Alpha, bit 3 of its first
flags (NifSceneShape.VertexAlphas), whatever Vertex_Colors says. How a map uses them is in
Blending.
Skinned shapes
SkinReader, nif.xml NiSkinInstance, NiSkinData, NiSkinPartition and SkinPartition. A
BSTriShape whose skin ref points at a NiSkinInstance or a BSDismemberSkinInstance has a data
size of 0 and takes its geometry from the skin:
| Block | Field | Read |
|---|---|---|
NiSkinInstance | Data, skin partition | Refs, checked against their block type |
NiSkinInstance | Skeleton root | Skipped |
NiSkinInstance | Bones | Node refs |
NiSkinData | Skin transform | Skipped |
NiSkinData | Bone list | Each bone’s skin transform; bounding sphere and weights skipped |
NiSkinPartition | Vertex desc, vertex data | As for BSTriShape, bone weights and indices included |
SkinPartition | Triangles copy | Indices into the vertex data; every other field skipped |
A skin data with fewer bones than its instance, a vertex data size that isn’t a whole number of vertices, a bone index past the bones, a triangle past the vertices or a bone that isn’t a node under the root throws.
NifSceneReader poses each vertex: every bone with a weight above 0 moves it by its skin transform,
then by the bone node’s transform in the model’s space, and the results are blended by the weights.
The bone index of a vertex points into the instance’s bones. The pose is the one the file stores
the bone nodes in; the game’s tree animations aren’t played. The shape’s own transform and the
skin data’s overall transform aren’t applied to a weighted vertex. See
Spec deviations. The same bones and
weights turn the vertex normals, tangents and bitangents, by the rotation of each, before they’re
brought back to unit length. Most vanilla trees are skinned, so their crowns keep their normals this way.
Scene graph
NifSceneReader walks the graph depth-first from block 0:
- A node of a type
NiNodeReadersupports composes its transform with its parent’s and visits its children. A null child ref (-1) is skipped; a ref past the block table throws. - A
NiSwitchNodevisits only the child at itsIndex, read after theNiNodeeffects, and none whenIndexis past its children. See Spec deviations. - A
BSTriShapeis read withTriShapeReader. Its model transform is every node’s transform from the root down, then its own. The root’s transform is included. A skinned shape’s positions, normals, tangents and bitangents are posed in the model’s space instead, under an identity model transform. - A node or shape named
EditorMarkeris left out with its subtree: it holds geometry the editor shows and the game doesn’t. See Spec deviations. - A node or shape whose
NiAVObjectflags set bit 0, hidden, is left out with its subtree. In vanilla, those are particle emitter meshes, forge markers and the spare parts of some weapons and tools. See Spec deviations. - Any other child type is skipped and reported once in
SkippedBlockTypes:NiTriShape,NiTriStrips,BSLODTriShape,BSDynamicTriShape, particle systems, and nodes whose children aren’t all drawn as is, such asNiBillboardNode(turned to the camera). - A child ref back to a node on the current path is not followed, so a malformed cycle ends.
A transform is a rotation, a translation and a uniform scale, applied as
rotation × (point × scale) + translation. Two compose into one transform of the same form.
Havok shapes
HavokShapeReader. All Havok lengths are scaled by 69.9915 to game units, see
Spec deviations.
| Shape | Layout read | Footprint |
|---|---|---|
bhkBoxShape | Half extents (Vector3) at offset 16 | 8 corners |
bhkSphereShape | Radius at offset 4 | 8-point circle |
bhkCapsuleShape | At offset 16: point 1, radius 1, point 2, radius 2 | Two circles |
bhkConvexVerticesShape | At offset 32: uint32 count, Vector4 vertices | The vertices |
bhkConvexTransformShape | Shape ref, then a 4x4 matrix at offset 20 | Wrapped shape, transformed |
bhkListShape | uint32 count, shape refs | Union of the resolvable sub-shapes |
bhkMoppBvTreeShape | Shape ref, the first field; the MOPP code is skipped | Wrapped shape |
bhkPackedNiTriStripsShape | Data ref at offset 52 | See hkPackedNiTriStripsData |
hkPackedNiTriStripsData | Triangles (8 bytes each, skipped), uint32 vertex count, compressed flag, Vector3 or half-float vertices | The vertices |
bhkCompressedMeshShape | Data ref at offset 52 | See bhkCompressedMeshShapeData |
bhkCompressedMeshShapeData | See below | Big vertices and chunk vertices |
Shapes reached through bhkMoppBvTreeShape are static room geometry and flagged
IsArchitecture.
bhkCompressedMeshShapeData starts with 54 bytes of bit counts, masks, AABB and type bytes, then
four counted material arrays and a named material count, all skipped. Then:
| Field | Layout |
|---|---|
| Chunk transforms | uint32 count, then per transform: translation (Vector4), rotation (hkQuaternion, x y z w) |
| Big vertices | uint32 count, Vector4 each, full precision |
| Big triangles | uint32 count, 12 bytes each, skipped |
| Chunks | uint32 count, then per chunk: translation (Vector4), material index, reference, transform index (uint16), uint32 vertex component count (3 per vertex), uint16 vertices in Havok units × 1000, then indices, strips and welding info, each a counted uint16 array |
A chunk vertex is rotation(chunkTranslation + vertex / 1000) + transformTranslation. That order
is unverified.
Findings from real data
- Top groups aren’t all flat:
DIALhas nested topic children, so the base object lookup skips nested groups. bhkMoppBvTreeShapewrapsbhkCompressedMeshShapein vanilla interiors, notbhkPackedNiTriStripsShape: most placed interior objects resolve through it.NifSceneReaderreads every NIF of the Anniversary Edition archives plus the Moon and Star and Vominheim mods without an error. A few are Skyrim LE (BS version 82 or 83), whoseNiTriShapegeometry the walk skips.EditorMarkeris always spelled that way.
LOD settings (.lod)
Implemented in CreationEngineFormats/Lod/. A lodsettings\<worldspace>.lod file describes the
terrain LOD grid generated for one worldspace: its origin, its stride and the levels that exist.
Spec: UESP LOD Settings File Format.
xEdit reads the same layout (TwbLodSettings.LoadFromData in Core/wbLOD.pas).
The file name is the worldspace EditorID in lowercase. A worldspace without this file has no terrain LOD of its own.
Layout
16 bytes, little-endian. The file is this struct alone.
| Offset | Type | Spec field | Meaning |
|---|---|---|---|
| 0 | int16 | left | Grid X of the grid’s south-west cell |
| 2 | int16 | bottom | Grid Y of the grid’s south-west cell |
| 4 | int32 | stride_pow2 | Side of the grid, in cells, a power of two |
| 8 | int32 | lowestsize_lod | Smallest tile size generated, in cells |
| 12 | int32 | highestsize_lod | Largest tile size generated, in cells |
A tile of level L sits at (x, y) = (left + i * L, bottom + j * L), the same alignment as
xEdit’s TwbLodSettings.BlockForCell. The south-west cell doesn’t have to be a multiple of the
level: Blackreach’s is (-23, -9), and its only level-32 tile is blackreach.32.-23.-9.dds.
LodSettingsReader throws InvalidDataException on a file that isn’t exactly 16 bytes, a stride
that isn’t a positive power of two, a min level of zero or less, or a max level below the min
level. The spec names the struct fields and nothing else; the checks follow from the field names
and xEdit’s size check.
Vanilla values
| File | South-west cell | Stride | Levels |
|---|---|---|---|
tamriel.lod | (-96, -96) | 256 | 4 to 32 |
dlc2solstheimworld.lod | (-64, -64) | 256 | 4 to 32 |
blackreach.lod | (-23, -9) | 32 | 4 to 32 |
japhetsfollyworld.lod | (-9, -6) | 16 | 4 to 16 |
The other eight vanilla files follow the same pattern. Every vanilla file is 16 bytes.
DDS textures
Skyrim stores its textures as DirectDraw Surface (.dds) files: terrain LOD tiles and their normal
maps, landscape textures, the diffuse textures of models. CreationEngineFormats/Dds/ reads the
header and decodes a mip level to RGBA. The layout is Microsoft’s, not Bethesda’s: see the
DDS header and the
programming guide.
| Type | Does |
|---|---|
DdsHeader | The header layout; TryReadSize reads the top level’s size without decoding |
DdsDecoder | Decodes the top level, or the first level within a given size, to RGBA with Pfim |
DdsMipLevel | Cuts one mip level out of a texture, so the decoder skips the larger ones |
DdsImage | A decoded level: top-down, tightly packed RGBA8 |
File layout
"DDS " 4 bytes, magic
DDS_HEADER 124 bytes: flags, height, width, pitch, depth, mip count, pixel format, caps
DDS_HEADER_DXT10 20 bytes, only when the pixel format's FourCC is "DX10": DXGI format, dimension, array size
level 0 then each smaller level, halving each side down to 1
A level’s size comes from its pitch: 8 bytes per 4x4 block for DXT1, BC1 and BC4, 16 for the other block-compressed formats, and whole bytes per pixel for uncompressed formats.
Decoding
Pfim decodes the pixels. DdsDecoder maps its 24-bit and 32-bit output from BGR(A) to RGBA, and
returns null for any other output format. A 32-bit texture without DDPF_ALPHAPIXELS is X8R8G8B8:
its fourth byte is padding, not alpha, and vanilla Solstheim terrain LOD tiles leave it 0, so it
decodes as opaque.
Asked for a size, DdsDecoder decodes the first level whose sides both fit, or the last level. It
copies the header and that level into a one-level texture, so Pfim never reads the larger levels.
The texture kinds and formats it can’t cut are listed in
Not implemented.
BookAtlas.Exporter
The CLI: everything specific to vanilla Skyrim Special Edition, built on the format parsing of
CreationEngineFormats. Its layers and where new code goes are in
Architecture.
The production commands are export:books and the
export:worldspace-maps:* commands. The debug:* commands are
inspection tools.
export:books pipeline
export:books <data-directory> -o <dir> [--clean] [--load-order se|ae|custom [--load-order-plugins <names|file>] [--load-order-archives <names|file>]] [--stats]
Exports every book, merged across the load order, for every language with string tables in the load order’s archives. Without any string table there is nothing to export: there is no single-language fallback.
--clean empties <dir> first. It is refused when <dir> holds the Data directory or a load order list file.
| Output | Content |
|---|---|
localized/<language>/<book>.json | One file per book, shape in Book export JSON format |
localized/<language>/fonts/*.ttf | The language’s fonts, see Font export |
localized/<language>/index.json | The language’s books and fonts |
export.json | The load order the export read and the options it ran with, shared by all languages, see Export manifest |
textures/ | Every texture book markup references, shared by all languages |
textures/menuart/ | Menu art converted to PNG |
Flow
Pipelines/Books/BookExportPipeline.cs runs the steps; Commands/ExportBooksCommand.cs only parses the options:
| Step | Code | Runs |
|---|---|---|
| Open the string archives, list the languages | Game/Assets/LocalizationSource | Once |
| Read every plugin’s books and location records | The BookRecords and LocationRecords datasets, loaded together: one walk per plugin | Once, plugins in parallel |
| Merge the raw books for the set of book FormIds | Datasets/Books/BookMerger | Once |
| Merge locations and find each book’s placements | Datasets/Locations/LocationMerger, Datasets/Locations/BookReachability | Once |
| Read the menu art objects and the records books point at | The BaseObjects and NamedRecords lookups, loaded together | Once, plugins in parallel |
| Resolve menu art objects and convert their textures | Pipelines/Books/MenuArtResolution | Once, objects in parallel |
| Resolve the spells, skills and keywords books point at | Pipelines/Books/BookReferences | Once |
| Localize, merge and write each language | Pipelines/Books/BookLanguageExporter | Per language, in parallel |
| Copy markup textures | Pipelines/Books/BookTextureCopier | Once |
Location data, menu art and book references don’t depend on language, so they’re computed once
from the raw, unlocalized records. Text does: each language localizes every plugin’s books
against that plugin’s own tables before merging (Datasets/Books/BookLocalization), see
Localization.
Per language, BookLanguageExporter writes each book file (Pipelines/Books/BookFileExporter), collects
the fonts and textures its markup references (Pipelines/Books/BookMarkupScanner), converts the fonts
(Pipelines/Books/Fonts/FontLibraryExporter) and writes index.json (Pipelines/Books/BookIndexWriter). Languages write to
separate directories; their log lines interleave, each naming its language.
Book references
A book’s DATA can name what it teaches (a SPEL, or a skill through its AVIF), and its
KWDA lists KYWD records. BookMerger resolves these FormIds against the writing plugin’s
masters. BookReferences then reads each distinct record once for the whole run
(the Datasets/Lookups/NamedRecords lookup): its EditorID and its FULL name.
- A record the load order doesn’t have is a warning; the book keeps the bare FormId.
- The
FULLname is localized per language, in the tables of the plugin that wrote it, see Localization. - The scan covers every top-level group except
WRLD,CELLandBOOK, like the menu art scan, and skips records it doesn’t want without reading their data.
MenuArt resolution
A book’s INAM points at an object whose model shows the book’s artwork. Every vanilla spell tome
has one. MenuArtResolution resolves each distinct object once for the whole run: the base object
(the Datasets/Lookups/BaseObjects lookup), its NIF, then every diffuse texture, converted to PNG
(Pipelines/Books/MenuArtImageResolver, Pipelines/Books/MenuArtTextureConverter).
- Objects resolve concurrently. Log lines are written afterwards in a fixed order, so
--verboseoutput is stable. - A texture shared by several objects is converted once. The PNG is named after the archive entry; two different entries with the same file name make the second one fail for its object rather than overwrite the first. No vanilla texture hits this.
- Every outcome other than
Resolvedis a warning; a book whose object doesn’t resolve stays text-only. - Whether a book has text of its own is checked on one language, for the
--statscount only.
--stats prints the book reachability counts, the merged record counts, the markup counts and
the menu art outcomes on stdout.
Worldspace maps
The export:worldspace-maps:* commands write one map per worldspace of the load order: one PNG,
or with --format grid or --format pmtiles the tiles of a zoomable map viewer (see
Output formats).
A map is a background, then layers drawn over it, bottom to top. Each command has its own background; the layers, the crop, the parent LOD and the output are shared. This page documents what the commands share; each command’s page documents its background, its own options and its results on the vanilla data.
| Command | Background |
|---|---|
export:worldspace-maps:lod | The terrain LOD diffuse tiles of the archives, stitched |
export:worldspace-maps:raster-records | Each cell rasterized from its LAND record: landscape textures, vertex colors, relief |
No map marker or book is drawn on the image. With --markers, the grid and pmtiles outputs list them
for a viewer, see Markers. The only labels drawn are the cell labels of --cell-grid,
see Cell grid.
Pipeline
The code is in Pipelines/Maps/, by what each folder does:
| Folder | Holds |
|---|---|
| (root) | MapPipeline, MapOptions and MapRegionRenderer, which draws a region |
Planning/ | Which cells each worldspace draws, from the plugins alone, and what is read for them |
Geometry/ | The projection, pixel rectangles, cell windows and the rotation of a placed object |
Surface/ | The height of the LAND under each pixel, between vertices |
Style/ | The light, the tone and the colors the terrain and the objects share |
Backgrounds/ | The bottom of a map: Lod/ and Landscape/ (Terrain/, Textures/ and Grass/) |
Canvas/ | The image being drawn and the planes its layers pass each other |
Layers/ | The layers, a folder for each with the pieces only it uses |
Levels/, Markers/, Output/ | The floors of a multi-level map, the marker catalog, the writers |
Objects/ | What draws the placed objects |
Layers/PlacedObjects/ holds the objects layer and the map’s object logs, and its Materials/
holds what each objects mode reads in the archives to give the shapes their materials. Objects/ holds the rasterizer at its root,
the models and their placements in Scene/, the textures and their mip selection in Textures/,
each shape’s material (its pass, color, texture and effect, resolved once per map), the face
lighting and the shading of effect shapes in Materials/, the region’s pixel frame, the
transformed vertices and the traversal of a triangle’s pixels in Raster/, the region’s buffers, its
candidate instances and the face shading in Drawing/, with the passes over
a band’s shapes (opaque then blended, or depth then edges in wireframe) in Passes/, what a
covered pixel becomes in each in Writers/, and the blended faces in Blended/, and the heights sampled on a world grid in Sampling/.
Each step reads only what the previous one gave it, so the planning is tested without
archives, a background without plugins, and a layer on a synthetic image.
| Step | Code | Reads | Gives |
|---|---|---|---|
| Read | MapPipeline, with the WorldspaceRecords and WorldspaceMaps datasets | Every plugin, in one pass | Merged worldspaces, their cells, what the background and the layers read |
| Plan | MapPlanner | The merged records | Per worldspace: the cells to draw, the crop, the parent whose LOD it uses |
| Background | MapBackground (LodBackground, LandscapeBackground), prepared once into an IBackgroundRun, which opens each map | The archives, and the plugins’ data it asked for | The map’s MapProjection, cropped, and a BackgroundRaster that draws any rectangle of it |
| Render | MapRegionRenderer: the surface when a layer reads it, the raster, then each layer’s drawer in the order of MapLayers | A rectangle of the map, the plugins’ data of the worldspace | The rectangle’s pixels, at each level |
| Write | MapWriter, with a MapSink per format (PlainPngSink, GridSink, PmTilesSink) and per level | The regions’ pixels, one at a time | A PNG, a tile grid or a PMTiles archive, and one per level |
- Ask the background and every layer what they read in the plugins (
WorldspaceMapReads), and read their union withDatasets/Worldspaces/WorldspaceMapQuery.csin one pass over every plugin of--load-order. It readsWRLDandCELLand locates eachLANDfrom its header; it parses nothing else unless a background or a layer asks for it. Merge theWRLDrecords withWorldspaceMerger, and collect each worldspace’s exteriorLANDcells withWorldspaceCells.FindLandscapeCellsByWorldspace. FormIds resolve through each plugin’s masters, so a DLC adding cells to Tamriel counts toward Tamriel. When a layer reads references, a second walk reads the base objects they place (BaseObjects), known only once the references are merged. With--lights, the same walk reads theLIGHbases among them (LightBases, see Lights). With--markers=books, the same pass reads everyBOOK(BookRecords, shared with the book export) to tell which placed references are books and to name them. - Plan each worldspace from the records alone: its
LANDcells, with--crop-to-playableonly those inside the playable bounds (see below), and with--parent-lodthe cells of its parent (see below). With--worldspace, only the worldspaces named are planned; a name no worldspace has stops the command here, before anything is drawn. A child named alone still uses its parent with--parent-lod. - Prepare the background over the planned cells, cropped to the kept cells when there is a crop:
what is computed once per map (vertex colors, decoded tiles), and the
MapProjectionthat maps every pixel to its cell. - Draw a region of the map: the background’s pixels in it, then each layer, in a fixed order (see
Layers). A region where the background draws nothing is not drawn: it stays
transparent. In a region that draws one level, the background leaves its colors until the first layer that
reads them: the objects layer only paints over pixels, so the background then paints only the
pixels it left uncovered (
BackgroundRaster.DrawDeferred, theCoveredplane, see Region planes). On Tamriel at 512 pixels per cell, an object covers 47 % of the ground’s pixels. The pixels don’t depend on how the map is cut into regions. A layer that reads the pixels around its own (ILayerDrawer.Margin, the lighting’s contact occlusion) gets them: the region is drawn that many pixels larger, up to the map’s edge, then cropped. In that margin only the surface and the blended shapes are computed (MapCanvas.Shown): no colors, normals or relief. - Write each region as it is drawn (see Output formats). The format picks the
regions: square blocks of 4 x 4 tiles for
gridandpmtiles, bands of the full width forplain-png. The next regions are drawn while the last one is written, 2 bands at a time, or one block per logical core, from 2 to 32, unless--jobssets the count: one region’s parallel loops leave cores idle as they end, and the other regions fill them. Measured on 4, 8 and 16 logical cores, half as many blocks takes up to 17 % longer on Blackreach and twice as many saves at most 8 %, for more memory. A smaller block also redraws fewer levels, since a level is drawn again only in the regions where it differs from level 0. A block under 2 tiles costs more than it saves: the contact occlusion’s margin weighs more against the pixels kept. A band stays at 2, since it holds 16 times a block’s pixels. A map takes the memory of the regions drawn and the one written, whatever its size; with levels, those regions at each level that differs from level 0. The tiles waiting for their siblings in the lower zooms add to it, and grow with the map’s width. The exporter setsSystem.GC.ConserveMemory: the regions’ large arrays pile up in the heap faster than the GC returns them. Blackreach at 4096 pixels per cell peaks at 7 GB with it, 16 GB without, and takes no longer. A map is refused only when a side passes 2^31 - 1 pixels, the most a PNG holds.
Crop to the playable area
A worldspace’s LAND records cover much more than the part you can walk in. Solstheim has 34,383
LAND cells: most are sea floor, and a large part of the south is Vvardenfell scenery. Sovngarde
has strips of filler terrain around its valley, and Tamriel has mountains past the borders.
--crop-to-playable (MapCrop) keeps the LAND cells inside the overlap of two bounding boxes,
grown by one cell:
| Box | Cells | What it leaves out alone |
|---|---|---|
| Navmesh | Cells with a NAVM record | Scenery nobody walks on (Tamriel’s borders, Vvardenfell) |
| References | Cells with a non-persistent REFR or ACHR | Stray navmeshes (the columns of navmesh in Sovngarde’s filler) |
Persistent references are left out because they sit in the worldspace’s persistent cell, not in
the cell where they are placed. The one-cell margin keeps the terrain you see from the edge of the
walkable area. When a worldspace has no navmesh or no reference, the other box is used alone; when
the boxes don’t overlap, the navmesh box is used. Cells without LAND inside the kept area are
transparent. The crop and the mask come from the records, not from the pixel colors, so a dark
area inside a real cell is kept.
This is a heuristic chosen on the vanilla worldspaces, see assumptions. Results on the vanilla SE load order:
| Worldspace | Without crop | With crop |
|---|---|---|
| Tamriel | 119x94 cells | 103x82 cells |
| DLC2SolstheimWorld | 192x192 cells | 31x30 cells |
| Sovngarde | 58x73 cells | 31x34 cells |
| MarkarthWorld | 18x9 cells | 4x5 cells |
MarkarthWorld’s navmeshes cover 2x3 cells: the city is built from objects on a small patch of terrain, so its cropped map is small.
Parent LOD
A child worldspace whose WRLD PNAM sets “Use LOD Data” (0x02), the Creation Kit’s “Use LOD
Data” checkbox under its parent worldspace, shows the LOD of its WNAM parent around it in game.
On the vanilla SE load order, 7 worldspaces set it: the cities (SolitudeWorld, RiftenWorld,
WhiterunWorld, WindhelmWorld), WindhelmPitWorldspace, WhiterunDragonsreachWorld and KatariahWorld.
The last two have no exterior LAND and get no map. With --parent-lod
(WorldspaceLodSource), such a worldspace is drawn with the first ancestor that doesn’t set the
flag. A missing parent or a WNAM loop leaves the
worldspace without a parent. raster-records takes the same parent, though it draws its LAND,
not its LOD.
The child’s cells sit at the same grid coordinates as in its parent. A child’s own LAND has holes
(about half of WhiterunWorld’s bounding box has no LAND), and in game the parent’s LOD fills them.
The map draws the child’s LAND cells and the parent’s inside their bounding box
(MapCrop.WithParentLandCellsWithin), and is always cropped to them, with or without
--crop-to-playable. With --crop-to-playable, the box comes from the child’s playable cells.
The data the background and the layers read (LAND, heights, water, navmesh triangles,
references) comes from the child where the child has the cell, and from the parent elsewhere
(MapInputs.ContentFor). A navmesh triangle belongs to the cell of its centroid, a reference to
the cell of its position. Where the two disagree, the water stops on a straight cell edge
(Solitude’s harbour). How each background draws a child is on its page.
Child worldspaces
A child worldspace’s WRLD ONAM says where its map markers fall on the map of its WNAM parent:
a point (x, y) of the child lands at (x * scale + X offset, y * scale + Y offset) on the parent
(WorldspaceMapPlacement). A scale of -1 hides them. The Z offset isn’t used: the map is flat. A
grandchild goes through each offset on the way up. A child without ONAM, or a WNAM loop, stops
the walk there.
The scale tells how the child relates to its parent:
| Scale and offsets | Vanilla examples | Its markers on the parent’s map |
|---|---|---|
| 1, offsets 0 | The cities, MarkarthWorld, but also SkuldafnWorld and DLC01Boneyard | At their own position |
| 1, X/Y offsets | KarthspireRedoubtWorld, DLC1HunterHQWorld | Moved as a block, same size |
| Near 0 | AlftandWorld, FallowstoneCaveWorldEnd | Gathered on one point, usually the entrance |
| Other | Blackreach (2.5), DLC01FalmerValley (0.5) | Scaled around the offset |
| -1 | Sovngarde | Hidden |
Only the markers use it: a parent’s map lists its children’s markers and books. The background and the layers draw the worldspace’s own records only, as the game does: Tamriel holds each city as seen from outside its walls, and the city’s worldspace holds it as seen from inside. A city’s walls cross its cells, so no cell of Tamriel can be swapped for the city’s without losing the gate, the road or the bank outside it.
To draw the cities on Tamriel’s map, load a mod that moves them into Tamriel, such as Open Cities
Skyrim, with --load-order custom: their records are then Tamriel’s.
Interpolation
--interpolation sets how a value between samples is computed, wherever the map reads one between
them:
| Samples | Read for | With |
|---|---|---|
The 33x33 vertices of a LAND cell | The terrain height of the surface the objects stand on and the water tints | --objects or --water |
| The same vertices | The colors, the texture weights and the slopes of the hillshade | raster-records |
| The texels of a mip level, wrapping every repeat | The pattern of the landscape textures, see Textures | raster-records --terrain texture |
| The texels of a mip level, wrapped or clamped | The objects’ textures, see Texture mode | --objects=texture |
It doesn’t apply where nothing is read between samples. The lod tiles are drawn at their own size:
every vanilla tile and its normal map are 256x256, apart from 20 tiles of 4x4 that are redrawn (see
placeholder tiles). Two mip levels blend linearly, and each zoom of a
grid is the mean of 2x2 pixels of the one above, whatever the option.
The table and the edges below are written for the LAND vertices. On a texture, the same kernels
read texels, and past the texture’s edge they wrap or clamp as the texture does.
| Value | Reads | Result |
|---|---|---|
nearest | The nearest vertex | A square of one value around each vertex: the raw data, blocky past 32 pixels per cell |
bilinear | The 2x2 nearest vertices | The default. Straight blends, diamond-shaped corners past 64 pixels per cell |
bicubic | The 4x4 nearest vertices, Catmull-Rom | Smoother transitions, and the relief has no crease at each vertex |
bspline | The 4x4 nearest vertices, cubic B-spline | The softest: smooth curvature, no overshoot, but it doesn’t pass through the vertices |
bspline smooths the data instead of interpolating it: a peak comes out lower and a valley
shallower than their vertices, and a lone vertex of another color fades into its neighbours. The
water follows that smoothed terrain, so a shallow shore can move by a fraction of a vertex.
bicubic and bspline read one vertex past the cell’s edge. For the colors, the hillshade and
the water it comes from the neighbouring cell, so the map has no seam there. Where that cell has no
LAND, the cell repeats its own edge. The texture weights always repeat the edge: two cells don’t
weigh the same textures. Bicubic can overshoot past its samples; the colors are clamped to 0 to 255
and a negative texture weight is ignored.
At 32 pixels per cell or less, the pixels sit close to the vertices: bilinear and bicubic give
about the same map. bspline still softens it.
Kernels
The code is in Imaging/Interpolation/, which knows nothing of the landscape. A kernel, in
Kernels/, gives weights for a position between two samples. Taps, in Taps/, apply a kernel at
one position on one axis: which samples it weighs and with which weights.
| Type | Role |
|---|---|
InterpolationKernel | One way to interpolate along one axis: samples, weights, margin |
NearestKernel, BilinearKernel, BicubicKernel, BSplineKernel | The kernels |
SampleGrid | A grid of values and its margin, interpolated with its kernel at a row, then along that row |
KernelTaps | The samples and weights of a kernel at one position on one axis of a SampleGrid |
TexelTaps | The same along one axis of a texture, without a margin: an index past the edge wraps or is clamped |
A kernel says which samples around a position it weighs, with which weights, and how far past the
grid’s edge it reads (its margin). It weighs at most InterpolationKernel.MaxTaps samples.
InterpolationKernel.All lists the kernels the commands offer. Pipelines/Maps/CellVertexGrid fills
a SampleGrid with a cell’s vertices and the margin from its neighbours. To add a way, write a
subclass of InterpolationKernel and list it in All: --interpolation takes its Name, and every
map layer and background uses it.
Surface
The objects and the water share one height per pixel, the surface: the height of what the pixel
shows. MapRegionRenderer computes it for each region when a layer reads the LAND heights
(TerrainSurface): the terrain under each pixel center, interpolated between the vertices with
--interpolation, reading the neighbouring cells past the edge (see
Interpolation). A pixel of a cell without LAND has no
surface.
The layers then change it in their order:
| Layer | Reads the surface | Changes it |
|---|---|---|
| Objects | An object shows where it rises above the surface, less a tolerance of 32 units | Raised to the object where a pixel shows it: a face in colormap or texture, an edge in wireframe |
| Lighting | Its contact occlusion measures the sky each pixel sees, see Lighting | No |
| Water | A pixel is tinted where the surface lies below its cell’s water height | No |
| Lights | A glow shows where the surface lies under its light, see Lights | No |
The tolerance (ObjectRasterizer.GroundTolerance) keeps the objects laid on the ground: a road
piece follows the LAND only roughly. Measured on Tamriel’s 5,500 road pieces against the bilinear
terrain, 5.3 % of their vertices lie more than 32 units under it, and 0.4 % of the pieces have
half their vertices there. A face less than 32 units under the terrain shows, but leaves the
surface at the terrain’s height.
Without --objects, the surface is the terrain: the water tints by the depth of the ground, and only
the ground covers a light.
Region planes
The surface is one of the planes a region’s layers pass each other (RegionPlanes, in Canvas/):
| Plane | Written by | Read by |
|---|---|---|
Surface | The renderer (the terrain), then the objects layer (raised) | The objects layer, the lighting layer, the water layer, the lights layer |
PlacedWater | The objects layer, when the region shows a water shape | The water layer |
BlendedObjects | The objects layer, when the region shows a blended shape | The blended objects layer, then the lights layer |
Covered | The objects layer and the grass tufts, where they paint a pixel | The background, which paints its colors only elsewhere |
Normals | The objects layer where it paints a pixel, then the background on the ground it leaves | The lighting layer |
Relief | The objects layer, the broad relief and curvature of the surface it raises; then the background, the ground’s, where none is written | The lighting layer |
Emission | The objects layer, where it paints a pixel | The emissive layer |
Normals and Relief exist only on a lit map, with --hillshade: the renderer rents them when a
layer reads Normals, every pixel without a normal, which the lighting layer leaves as it is. Each
level of a map drawn with levels holds a copy of the plane, so a normal takes four bytes
(PackedNormal): its east and north as halves, its up recomputed, as it always faces up. Emission
exists only with --objects=texture: three bytes per pixel, black for a pixel that emits nothing.
The background marks its pixels pending and resolves them when it paints its colors, since no layer
reads either plane before: on the ground of a map with objects and textures, each would otherwise be
computed twice and written over.
MapRegionRenderer owns the planes of the region it draws. It rents the surface and the placed water
from pools kept for the regions (RegionPools), and gives them back once the region is drawn. The
normals and the relief, the objects’ depth, slope and cut, the covered pixels, and the ground’s relief
under the grass, come from the same pools. A pool keeps an array at the length a region asked for: a grid block and its margin
is past a power of two, and rounding it up would make each array half as long again. With
levels, each level draws over a copy of the background’s planes, given back once that
level is drawn, but for Relief, which level 0 writes: the levels share it.
Each layer declares the planes it writes (MapLayer.Produces) and reads (MapLayer.Consumes).
MapLayers.PrepareAsync refuses an order where a layer reads a plane that a layer above it writes:
it would read the plane before it is written. A plane that no layer writes is read as the renderer
leaves it, so the water layer runs without the objects layer and reads the terrain.
Lighting
With --hillshade, the lighting layer (LightingLayer) lights the map once, after the objects and
before the water: each pixel is multiplied by the map’s one formula on the normal of what it shows,
see Map shading. The layers under it don’t
shade their colors: they leave each pixel’s normal and cartographic terms in the
region planes.
| What the pixel shows | Normal | Cartographic terms |
|---|---|---|
LAND (raster-records) | The VHGT slope, bent by the landscape textures’ normal maps where the pattern is drawn, see Hillshade | Broad relief and curvature, of the surface with --objects |
Terrain LOD (lod) | The tile’s _n.dds texel, see Hillshade | None |
| A grass tuft | The ground’s under it; its color is multiplied by 0.8 only | The ground’s |
| An opaque object face | Its vertex normals blended at the pixel, bent by its normal map in texture mode (see Texture mode) and by a projected material, else its face’s, turned up when it faces down | The surface’s, see Hillshade |
An effect face, a wireframe edge, a pixel without LAND | None: left as drawn | None |
Then the contact occlusion darkens a pixel by the sky its surface doesn’t see within 64 units around it: the foot of a wall, the gap between two rocks, a hollow. A plane, a slope or a ridge sees the whole sky over its tangent plane and keeps its light. It reads the surface, so a region is drawn 64 units wider, see Pipeline. Its radius, directions and weight are in Contact occlusion.
The blended shapes can’t leave a normal: what lies under them shows through. They are lit as they are drawn, by the same formula on their normals, without cartographic terms or contact occlusion.
Limits:
- A wall or a house casts no shadow: its foot darkens on every side the same, whatever the light. Only the relief casts one, see Cast shadows.
- With grass tufts that blend (see Grass tufts), a tuft takes the ground’s normal with the grain of its normal maps; tufts that don’t blend take it without.
- In the cells
--levelscuts, the broad relief and the curvature read theLANDalone: under a vault, meshes enter them at no level, see Surface relief. - In
wireframe, the objects aren’t lit and don’t enter the relief: the ground keeps its own.
Hillshade hour
By default the map is lit from the north-west, 45 degrees above the horizon, the usual convention for
shaded relief maps. --hillshade-hour picks another light from a few presets, for how the map reads,
not to simulate the game’s sky: the weather and the climate aren’t read. It needs --hillshade. The
light (MapLighting.At) is the one the lighting layer lights the map by.
Without --hillshade, the map has no light: nothing is shaded, neither the ground, the LOD tiles,
the objects nor the grass tufts.
--hillshade-hour | Light from | Elevation | Tint |
|---|---|---|---|
| none | North-west | 45 degrees | None |
sunrise | East | 20 degrees | None |
midday | South | 65 degrees | None |
sunset | West | 20 degrees | None |
midnight | North-east | 35 degrees | Red x 0.55, green x 0.62, blue x 0.85 |
The angles and the tint are style choices. Flat ground keeps its color under every light; the
night tint then darkens and cools the whole map (LightTintLayer, see Layers).
Limits:
- A low sun brightens the slopes facing it up to the bound of the map’s formula, x 1.35: a whole mountain side reaches it.
middaylights from the south: the north slopes, steep in the terrain LOD, fall in shade, and the map is darker than with the default light.
Layers
A layer (Pipelines/Maps/Layers/, in a folder of its own) declares what it reads in the plugins,
then changes a region’s pixels in place from the region’s projection and the worldspace’s data. It goes through three
stages, each a type of its own, so what a stage computes exists only once that stage has run:
| Stage | Type | Built by | Holds |
|---|---|---|---|
| Options | MapLayer record | MapLayers.From | What it reads, its label in the manifest |
| Run | ILayerRun | PrepareAsync, once per run, after the plugins are read, with the archives | The objects: the meshes to read, the texture colors read so far |
| Map | ILayerDrawer | ForMapAsync, once per map, before its first region | The roads’ and the lights’ reach; the objects’ models, instances, index and levels |
The drawer draws each region of its map (Apply) and gives the renderer its margin and its levels.
Adding a layer is a record, its WorldspaceMapReads flag if it reads something new, its option,
and its place in MapLayers.From. Its base follows what it keeps:
StatelessLayerkeeps nothing: it is its own run and its own drawer.PerMapLayercomputes something once per map: it is its own run, and itsForMapAsyncreturns anILayerDrawerthat holds what it computed.MapLayerwith a run of its own keeps something across the maps of the run, as the objects layer does with the textures it has read.
A layer draws an object in every region its shape reaches. The roads and the lights look for the objects of the cells under the region, widened by how far past its own cell an object of the map reaches, measured once per map. The objects layer lists each object in every cell its box covers instead.
A layer never changes a transparent pixel: where the background draws nothing, the map stays transparent whatever the layers, so the parts of a map left empty can be skipped without changing it.
| Order | Layer | Option | Reads in the plugins |
|---|---|---|---|
| 1 | Objects (ObjectsLayer) | --objects | With --projected-materials, every MATO; LAND VHGT; exterior REFR NAME, DATA, XSCL, XPRM and header flags, their bases’ model and Is Marker flag; with --levels, every exterior NAVM NVNM vertex and triangle; then the NIF models and, in colormap and texture modes, their diffuse textures |
| 2 | Lighting (LightingLayer) | --hillshade | LAND VHGT |
| 3 | Water (WaterLayer) | --water | LAND VHGT, CELL XCLW and DATA, WRLD DNAM |
| 4 | Blended objects (BlendedObjectsLayer) | --objects | Nothing more |
| 5 | Roads (RoadsLayer) | --roads | NAVM NVNM, exterior REFR NAME, DATA, XSCL, their bases’ MODL and OBND |
| 6 | Light tint (LightTintLayer) | --hillshade-hour midnight | Nothing more |
| 7 | Emissive (EmissiveLayer) | --objects=texture | Nothing more |
| 8 | Lights (LightsLayer) | --lights | Exterior REFR NAME, DATA, XRDS, their LIGH bases’ DATA |
| 9 | Cell grid (CellGridLayer) | --cell-grid | Exterior CELL EDID and XCLC, located from their group |
| 10 | Land mask (LandMaskLayer) | With a crop | Nothing more |
The lighting comes after the objects, whose normals it reads, see Lighting. The water comes after the lighting, so it tints what is already lit, and after the objects, so it tints what lies under it, ground or object, and leaves dry what rises above it. The objects’ blended shapes come after the water, so a waterfall body mixes over its pool instead of being tinted under it, see Blending. These constraints are checked from what each layer declares, see Region planes. The roads come after them, so a road stays visible under the clutter along it and bridges show over the rivers. When the objects, the roads or the lights are on, the references are read once and serve them all. The light tint comes after them, so the night darkens everything the world shows. What the objects emit and the lights come after the tint, so the night darkens the map but not its windows or its lights, and before the cell grid, whose lines and labels keep their colors.
The land mask is last: it clears every pixel outside the kept LAND cells, whatever the layers
below drew there. It runs when the plan has a crop, with --crop-to-playable or
with --parent-lod.
Objects
--objects draws every exterior object placed in the worldspace, seen from above, from its NIF
model: buildings, walls, rocks, mountains, trees, furniture, clutter. Where two objects cover a
pixel, the higher surface wins. The code is in Pipelines/Maps/Objects/, wired by ObjectsLayer.
| Option | Mode | Reads the textures | Draws |
|---|---|---|---|
--objects, --objects=colormap | colormap | Yes | Each face filled with the mean color of its diffuse texture (color map), shaded by the map’s light |
--objects=texture | texture | Yes | Each face mapped with its diffuse texture through its UVs, shaded by the map’s light |
--objects=wireframe | wireframe | No | The edges seen from above in one dark color; the ground shows between them |
The value is optional, so --objects takes the next argument as its mode: write
--objects=wireframe, or put --objects after the data directory. --objects Data -o out is
refused because Data is not a mode.
It reads the same references as the road pieces (WorldspaceMapReads.Placements), merged and
filtered the same way (see Roads), with their DATA height and rotations, their XPRM
and their header flags, then each base’s model path and Is Marker flag. Markers, primitives,
references hidden from the local map and objects without a model are left out: the rules are in
export heuristics. Each model is placed
by its reference’s position, scale and three rotations, see
assumptions.
Models. For each map, the models its references place are extracted from the archives and
decoded in parallel, once each whatever the number of references: every BSTriShape under the
root, each node’s transform applied, see NIF format.
The geometry is released with the map. A map drawn with --parent-lod decodes the parent’s
models too: an object outside the child’s cells can reach over them.
Drawing. An index of the cells each object’s box covers finds the objects of a region, and an object whose box holds no pixel center is skipped, since it would draw nothing. A depth buffer per region keeps the highest surface of each pixel, starting from the surface: a rock half buried in the ground shows only what rises above it. Bands of rows are drawn in parallel, objects in the order of the references, so the image is the same however the map is cut.
colormap: each face takes the color of its shape’s diffuse texture, its color map: the mean of its first mip level of 64 texels a side or less, weighted by alpha, toned like the terrain (see Colors). Each texture is read once per run, whatever the maps that show it. With--hillshade, each pixel of a face is lit by the vertex normals blended there, as the game lights a model, in the same pass and by the same formula as the ground, see Lighting, so objects and ground read together. A face whose shape has no normals is lit by its slope. Without--hillshade, the faces aren’t shaded. A shape without a texture, or whose texture is missing or unreadable, is gray.texture: each pixel of a face takes its diffuse texture at the pixel’s UVs, see Texture mode. It is toned, tinted and shaded as incolormap.wireframe: the faces fill the depth buffer without color, then each edge is drawn where it is at the height of the top surface, within half a pixel of that surface’s slope. Edges hidden under a higher face or under the terrain, and the undersides of objects, are not drawn. Inside the faces, the ground shows, and so does the water over it.
In colormap and texture, a shape whose shader sets Vertex_Colors is tinted by its vertex
colors, blended across each face, as the game multiplies its diffuse by them (see
BSTriShape). Models bake their shading
into them: the hollows of rocks and mountains darken, a waterfall body turns blue-green. Most vanilla
shapes carry them, so the objects are darker than their textures alone.
The shapes a lighting shader draws are painted, and those an effect shader draws, see Effect
shaders. A shape whose shader is a water shader (BSWaterShaderProperty) is a
water surface: it isn’t painted, and with --water the water layer tints what lies under
it. Shapes without a shader and hidden blocks are left out, see
export heuristics.
Limits:
- An object less than 32 units under the terrain still shows: a buried stone that close to the ground is drawn. See Surface.
- A skinned shape, such as a tree, a banner or a flag, is drawn in the pose its file stores, not
swaying.
NiTriShape,NiTriStrips, particles and billboards aren’t drawn, see not implemented. - In
colormap, leaves are alpha-tested cards drawn opaque: a tree is a blob of its leaves’ mean color, and a face has one color, no pattern. - No snow from
DNAMmaterials. The alternate textures of a base (MODS) or aTXSTaren’t read. - The alpha test reads the texel’s alpha alone, not the vertex alpha or the material
Alpha, see not implemented. - In
wireframe, below about 64 pixels per cell most edges are shorter than a pixel: forests and rocks become dark patches. The mode reads at the scales where a triangle covers several pixels.
Blending
A shape whose NiAlphaProperty sets Alpha Blend (flag 0x0001) mixes with what lies under it, in
colormap and texture, as the game draws it. Its opacity is the product of:
| Factor | From | In colormap |
|---|---|---|
| Texel alpha | The diffuse texture at the pixel’s UVs | 1 |
| Vertex alpha | The vertex colors’ alpha, blended across the face, when the shader sets Vertex_Alpha | Yes |
| Material alpha | The lighting shader’s Alpha field | Yes |
The product is clamped to 0 to 1. The shape’s color, shaded and tinted as an opaque one, then goes
through the property’s blend modes: color × source factor + pixel × destination factor, clamped,
with the factors of nif.xml’s AlphaFunction. Most vanilla shapes blend over (SRC_ALPHA,
INV_SRC_ALPHA); a few add (SRC_ALPHA, ONE) or multiply (ZERO, SRC_COLOR).
The opaque shapes are drawn first. Each blended face then leaves a fragment over every pixel where it
rises above the top opaque surface, without raising it: the water layer still tints the
ground under a waterfall body. Once the water is drawn, BlendedObjectsLayer mixes the fragments of
each pixel from the lowest up, as the game draws its blended shapes back to front; faces at one height
mix in the order of the references, then of their triangles. The image is the same however the map is
cut. The rules are in assumptions.
The waterfall bodies of Markarth and Whiterun (markarthwaterfallcliff*, mrkkeepwaterfall,
wrterwind01waterfall01) blend at a mean vertex alpha of 80 to 216 out of 255: the rock under them
shows through.
Limits:
- In
colormap, the texture’s alpha isn’t read: a blended shape is as opaque as its vertex and material alpha. - A blended face under the water is mixed over it, not tinted by it.
- The game’s waterfall bodies
effects\fxwaterfallbody*have noNiAlphaProperty: they stay opaque, dark with their vertex colors. Their foam, an effect shader shape, lightens them; their spray, a particle system, isn’t drawn. - A pixel center exactly on an edge shared by two triangles belongs to both, so a blended shape mixes there twice: at 0.5 opacity, 0.25 of what lies under it comes through instead of 0.5. A mod’s blended mesh set exactly on the pixel grid shows a line one pixel wide. See below why this stays.
The rasterizer keeps edges inclusive because the case doesn’t occur on the vanilla data: of about 100 million blended fragments, over 29 exports from 32 to 4096 pixels per cell, none has its center on an edge. The edge has to fall on the center to the bit. A top-left fill rule would give each such center to one triangle, but it applies to every face: it moves pixels of the other faces on these same exports, and it can leave a center to neither triangle when their rounding disagrees.
Effect shaders
A shape whose shader is a BSEffectShaderProperty (foam, falling water, mist, clouds, glows) is
drawn in colormap and texture, as NifSkope’s Skyrim effect shader computes it, then blended by
its NiAlphaProperty like any shape (see Blending); without one, it is opaque. The
fields are listed in NIF format.
| Output | Computed from |
|---|---|
| Color | Texture × vertex colors × Base Color, all × Base Color Scale |
Color, with Greyscale_To_PaletteColor | The palette (Greyscale Texture) at u = the texture’s green, v = vertex green × falloff × Base Color red; × Base Color Scale |
| Alpha | Texture alpha × vertex alpha × falloff × Base Color alpha² |
Alpha, with Greyscale_To_PaletteAlpha | The palette’s alpha at u = the texture’s alpha, v = vertex alpha × falloff × Base Color alpha² |
Falloff, with Use_Falloff | The stop opacity at the stop angle, the start opacity at the start angle, smooth between; the angle is the face’s with the view straight down |
Soft fade, with Soft_Effect | Alpha × height above the opaque surface / Soft Falloff Depth, at most 1; blended shapes only |
An effect shape isn’t shaded by the map’s light: its colors are its own. In texture, a texture
that gives a palette its u is read untoned, since the tone would move it along the palette; the
palette is toned, read whole up to 1,024 texels a side.
Glows and fire add to the map (SRC_ALPHA, ONE). The foam of the waterfalls, rapids and creeks (FXWhiteWater01) reads
both in a GradWhiteWater* gradient.
Limits:
- In
colormap, the palettes aren’t read: an effect shape takes its texture’s mean, times its vertex colors and base color. - The UVs don’t scroll: the foam is frozen as the file stores it.
- The soft fade is an assumption. A soft falloff depth of 1,024 or more isn’t drawn, see map objects.
- Lighting influence and refraction aren’t read, see not implemented.
Texture mode
For each map, the shapes on its ground ask their diffuse texture at the side that gives one texel per pixel: the map’s pixels per unit, times the largest scale among the shape’s instances on the map, over the texture’s repeats per unit along the shape (the square root of its UV area over its area), rounded up to a power of two. The DDS is read on its first mip level whose sides are at most that, toned like the terrain, then halved down to one texel, colors weighted by alpha. A texture is read once per run, and read again only when a later map needs it larger and the run hasn’t read its first level yet.
Each face then picks one level of that chain, as anisotropic filtering does: the texels per pixel
along the least stretched pixel axis, or along the most stretched one over 16, whichever is more.
Without this, a steep face such as a leaf card seen from above would read a level where its alpha
has averaged out. At each pixel center, the UVs interpolated on the face (uv × UV Scale + UV Offset, see NIF format) sample the level
with --interpolation (bilinear by default, see Interpolation), wrapped or clamped by the shader’s clamp mode. A texel the shape’s alpha test discards
leaves the pixel and its depth as they are: what lies under shows through the leaves. A shape
without UVs takes the last level, the texture’s mean.
With --hillshade, a shape’s normal map, slot 1 of its texture set, bends the vertex normal at each
pixel, as the game’s lighting shader does: the texel’s red runs along the vertex bitangent, its green
along the tangent, its blue along the normal. The map keeps half the texel’s tilt, see
Map shading. The map is read untoned at the same side as the
diffuse, every texel weighed alike (its alpha is the gloss), and sampled at its own level for the
face, so its pattern flattens as the map zooms out, as the landscape textures’ do. A shape without
tangents or UVs, a model-space normal map, or a normal map missing from the archives leaves the
vertex normal as it is; a missing one is logged with the missing textures. See
Object normal maps. colormap reads no
normal map: it draws no pattern.
Limits:
- A shape’s texture is read for its average repeats per unit: a part of it mapped finer, such as a small island of an atlas, is read blurred.
- Alpha-tested plants are mostly transparent: at 256 pixels per cell a shrub or a flower shows a
few pixels of leaves where
colormapshows a solid blob. That is what their textures hold: the vanilla shrubs and flowers of WhiterunWorld are 9 to 35 % opaque. - A part of a normal map mapped finer than the shape’s average, as for the diffuse, reads flattened.
Projected materials
--projected-materials covers the statics with the snow, ash or moss their STAT names in DNAM: a
MATO, a directional material. It needs --objects in colormap or texture mode, and works with or
without --hillshade. It does what the game’s lighting shader does for a single pass material:
| Step | What the map does |
|---|---|
| How much shows | From how far the pixel’s normal faces up, its vertex color’s alpha, the MATO’s falloff and the noise, under the STAT’s Max Angle |
| From where | Straight above in the world, whatever the object’s rotation: it lies on what faces up where the object stands |
| Color | ProjectedDiffuse.dds times the MATO’s Single Pass Color, between the texture and the vertex colors, so they tint it too |
Normal, texture mode | ProjectedNormal.dds and ProjectedNormalDetail.dds blended into the surface’s normal, at half tilt as an object’s normal map |
The four textures under textures\effects\ are read once per run, in world coordinates seen from
above: a covered object is the same however the map is cut. colormap shows no pattern: it reads the
diffuse as its mean, and no normal, but keeps the noise. The formula and its sources are in
Projected materials.
The covered statics match the LAND’s snow without a tuning constant: the colors of the
vanilla snow materials give about the tone of its snow textures once toned.
Limits:
- A multipass material, which draws a second geometry with textures of its own (glaciers, ice), leaves the object bare, see not implemented.
- A
MATOthat is missing or has no usableDATAleaves the object bare: logged in one warning, listed with--verbose. A missing texture goes without it: no noise, the color alone, no bending. - Skinned shapes and parallax, face tint, multilayer parallax and sparkle snow shaders stay bare, as in the shader.
- Nothing ties the coverage to what lies over an object: snow shows under a roof where the shader would show it, unless the model’s vertex alpha holds it back.
Emissive
With --objects=texture, the map adds what the opaque shapes emit: embers, windows, candles. The other
modes emit nothing, as a glow map lies on the shape’s UVs. It works at any hour, with or without
--hillshade, and shows most at night. Seen from above, the map shows little of a window on its wall. The game’s
shader adds the emission to the light on the pixel’s color, so a pixel emits its color, vertex colors
and projected material included, times the shape’s Emissive Color and Emissive Multiple. On a
Glow shader the glow map, slot 2 of its texture set, weighs that per channel; on another shader the
whole shape emits, whatever its slot 2 holds.
The objects layer leaves this in the Emission plane. The emissive layer adds it over the tint, so
the night doesn’t darken it, less what the blended shapes above the pixel hold back. A glow map missing
from the archives leaves its shape dark, and is logged with the other textures.
Limits, see not implemented and assumptions:
- A blended shape emits nothing on the map.
External_Emittanceis ignored: the game scales such a shape, a window among others, by the light or region its reference names inXEMI. The map draws it at its own color, at every hour.
Decals
The shapes their lighting shader marks Decal or Dynamic_Decal, layers of moss, snow or paving laid
over rocks and walls, are drawn closer to how the game does: in a pass over the opaque faces, showing
over what they lie on even a hair under it, without raising the surface. Each stays lit by its own
normal. See export heuristics. The wireframe mode
draws them as any face.
Levels
Seen from above, a cave is its rock shell: the back of its ceiling hides the floor you walk on.
--levels cuts that ceiling. In the cells whose floor lies under a vault, the objects layer leaves
out every face more than 160 units above the walkable floor under each pixel, so the map shows the
floor, its paths and what stands on it. The other cells are drawn as without --levels. It needs
--objects. The code is in Pipelines/Maps/Levels/.
| Step | Code | Gives |
|---|---|---|
| Floors | FloorField | Per 32-unit square: the heights of the navmesh over it, merged into floors at least 128 units apart; the LAND height where there is no navmesh; elsewhere the floors of the nearest square that has some |
| Vaults | VaultMap | The cells whose navmesh lies under faces with no face up above them, the back of a shell |
| Stops | LevelStops | The altitudes where a floor passes under another, each one a level under the top one |
| Cut | LevelCut | Per pixel, the floor the level shows plus 160 where the cell is cut, no limit elsewhere |
MapLevelsBuilder computes the floors, the vaults and the stops once per map, before its first region. The
floors cover the cut cells and one cell around them, so a floor near their edge comes from the
navmesh past it. The cut of a pixel comes from its world position alone: a pixel gets the same cut
whatever the region that draws it. A face above the cut at a pixel is not there: it is not drawn
and hides nothing under it. The same holds for an edge in wireframe mode and for a water surface.
The map written is level 0, which shows each square’s top floor. Each stop gives one level more:
level k shows, at each square, its highest floor less than 64 units above the k-th stop, else its
lowest. Every level is written next to level 0, holding only what differs from it (see
Level files). A map without navmesh, or without a cell under a vault, is drawn as
without --levels and has no level file. The rules and their thresholds are in
export heuristics; the navmesh as the
walkable floor and the faces’ winding are
assumptions.
Per region, the renderer first asks which levels change, then draws the background once. A level under which no pixel of the region, margin included, changes floor is not drawn: it reuses level 0’s pixels. Where no level changes, level 0 draws like a map of one level, over the background itself. Otherwise, each level starts from a copy of the background and of its planes, then applies every layer: the water layer reads the surface the objects raise, so it is drawn again at each level.
On the vanilla SE load order, 25 of the 45 maps cut at least one cell. Most cave worldspaces
(Blackreach, DLC1DarkfallPassageWorld) cut every cell, Tamriel 5 of 5,644, the cities none. The
counts don’t depend on --pixels-per-cell.
A map of one level with cut cells writes no level file, but its level 0 changes: the cut cells show their floor.
Limitations:
- A cell is cut whole. Where an open cell holds enough navmesh under rock, its mountain is cut too
and the
LANDshows through as a square: on Tamriel, 4 cells west of Solitude and one more. - A one-sided shell over open ground counts as a vault. On DLC2SolstheimWorld, 8 cells cut a dark dome over open ground; the part of the dome outside them stays, as a rectangle.
- No threshold leaves Tamriel’s cells out: they have 5.7 % to 10.7 % of their navmesh under a vault, the cut cells of the cave worldspaces as little as 7.1 %. See export heuristics.
- The
LANDis never cut. A worldspace whoseLANDlies over its caves shows theLAND.
Water
--water also reads every exterior LAND record’s VHGT heights, in the same pass over the
plugins (WorldspaceMapReads.Heights, CreationEngineFormats LandscapeReader),
33x33 vertices per cell. Datasets/Worldspaces/WorldspaceTerrain.cs joins them with each cell’s water:
| Cell | Water height |
|---|---|
DATA without “Has Water” | None |
“Has Water” and an XCLW height | XCLW, for rivers and lakes |
“Has Water”, XCLW absent or a no-water value | The worldspace’s DNAM default water height, the sea (-14000 on Tamriel) |
A child worldspace whose PNAM sets “Use Land Data” takes its parent’s DNAM. The no-water
values include two that the spec doesn’t list, see
deviations.
A pixel whose surface lies below its cell’s water height is tinted, darker with depth
(WaterLayer): the terrain, or with --objects an object under the water, a wreck or a sunken
rock. A dock or a ship above the water stays dry. With bicubic the shore follows the terrain’s
curve between vertices instead of a straight line.
With --objects, water placed as objects counts too: a pixel under the surface of a shape whose
shader is a BSWaterShaderProperty is tinted as if its cell’s water stood at that height, the
highest of the two winning. It fills the pools, troughs, puddles and tundra streams that no cell
water reaches. Over a pixel without LAND, only a cell’s water is drawn.
It shows Tamriel’s sea, the rivers and lakes (Lake Honrich, the White River, the Eastmarch hot springs) and Solstheim’s sea with its shallows. Limits:
- Water is one flat plane per cell. Where neighbouring cells store different
XCLWheights, the water stops on a straight cell edge, as in Blackreach. - A waterfall body has a lighting shader, not a water shader: the objects layer paints it with its
vertex colors, mixed over the ground when it blends, with its foam over it, see
Effect shaders. Every water body has the same
color: the
WATRwater types aren’t read. - A
LANDwithoutVHGT(183 in vanilla) is flat at the worldspace’sDNAMdefault land height, see assumptions. - Every exterior cell’s heights are held at once.
Roads
--roads paints the roads and trails in one color over the layers below, from two sources:
| Source | Records | Reads |
|---|---|---|
| Navmesh | Each NAVM’s triangles with the “Preferred” bit, the paths the AI prefers | NVNM vertices and triangles (WorldspaceMapReads.Paths) |
| Road pieces | Each exterior REFR of a STAT under landscape\roads\ | REFR NAME, DATA, XSCL (WorldspaceMapReads.Placements), then the base’s MODL and OBND |
The navmesh alone misses roads: the bit covers Tamriel’s network, but only part of a mod’s
(Vominheim marks 3,776 triangles, and its 468 references to vanilla road pieces fill the gaps). Each
road piece is drawn as a stroke with round ends through its OBND box, scaled and turned by its
reference: see road pieces and
assumptions. Which objects count as road
pieces is in export heuristics.
The records are merged over the load order (WorldspacePaths, WorldspacePlacements): the last
version of a NAVM replaces the whole navmesh, and a deleted one removes it. A reference that is
deleted or “Initially Disabled” in its last version isn’t drawn, see
disabled references. Persistent
references count, placed by their DATA position.
The layer fills every shape into one pixel mask, then paints the mask once
(PolygonRasterizer): overlapping triangles don’t darken. A pixel is covered when its center lies
in a shape; a shape too small to hold a pixel center anywhere, inside the image or not, covers
the pixel under its centroid, so trails stay connected at a low resolution. Limits:
- Roads have no outline and one width: a trail is as wide as its navmesh, a road piece half as wide as its box. The color is blended at 35 % over the map, so the relief shows through.
- Bridges are drawn like roads, over the water.
- Only the navmesh triangles are kept in memory.
Lights
--lights adds a glow around each exterior reference whose base is a LIGH: torches, candles,
campfires, forges, street lamps, and the magic and fill lights of caves and the Soul Cairn. It reads
three things from the light:
| Value | Read from |
|---|---|
| Color | The LIGH DATA Color |
| Radius | The LIGH DATA Radius plus the reference’s XRDS, see light radius |
| On or off | The LIGH DATA flag Off by default (0x20), and the reference’s state as for any layer: deleted and initially disabled references aren’t drawn |
The glow falls from the light’s color at its position to nothing at its radius, as the square of
the remaining distance, so most of it stays near the light. It is blended in screen mode
(1 - (1 - map) x (1 - glow)), which only lightens: on a bright map a glow barely shows, on a dark
one it stands out. The layer doesn’t know the hour: it comes after the
night tint, and --hillshade-hour midnight gives the dark map it reads best on.
On the five vanilla masters, 1,680 lights are placed in worldspaces, 559 of them on Tamriel, spread
over about 200 locations (forts, camps, redoubts) with at most a dozen each. The cities are their
own worldspaces: WindhelmWorld has 50, WhiterunWorld 24. A light’s radius plus XRDS has a median of
about 460 units, nine in ten under 1,000. A cell is 4,096 units: a glow is about 2 pixels across at
16 pixels per cell and reads from about 128.
Limits:
- A flame the game draws with particles has its own light only when a
LIGHis placed near it: on vanilla worldspaces, about two thirds of the burning campfires, torches and braziers. The rest have no glow. - A glow is centered on the light, not on the flame it stands for: level designers place a light where it should shine from, often in front of a brazier or a sconce and above it. The median distance from a light to the nearest flame model is 14 units on Tamriel, where campfire lights sit over the fire, but 110 in RiftenWorld and 200 in WhiterunWorld, 25 pixels at 512 pixels per cell.
- A light whose radius plus
XRDSis over 100,000 units isn’t drawn: see data problems. - Falloff Exponent, Fade, FOV and the flicker and pulse effects aren’t read, see not implemented. The glow’s shape is in export heuristics.
Cover
A light shows only where the sky is open over it. The layer reads the surface and the
blended shapes the objects layer leaves, and compares them with the light’s height
(its reference’s DATA Z):
| Where | Covered when | Then |
|---|---|---|
| The light’s own pixel | The surface rises more than 32 units above the light: a roof, a cave ceiling, a tree’s canopy | No glow at all, even past the cover’s edge |
| A pixel of the glow | The surface there rises more than 32 units above the light | That pixel isn’t lit: a glow stops at the edge of a roof above it |
A blended face higher than the light, over its pixel or over a pixel of the glow, dims the glow
there by what it keeps of what lies under it: its destination factor, 1 - alpha for a shape
blended over, while a shape that adds lets all of it through. The faces over one pixel multiply.
A pixel takes the lesser of what leaves the light and what its own faces let through, so a canopy
over both the light and the pixel counts once.
The 32 units (LightCover.Tolerance) leave a light lit inside its lantern or brazier, whose top
rises a little above it. Measured at 256 pixels per cell on the 1,561 vanilla lights placed over
LAND, 32 lie 0 to 32 units under the surface at their pixel, 22 lie 32 to 64 units under it, and
815 more than 64. Without --objects, only the terrain covers a light.
The cover of a light whose glow reaches a region from outside it is read at the light’s pixel alone
(MapRegionRenderer.ProbeAt): the renderer draws that pixel by itself at the level drawn, with the
objects and nothing shown, and keeps it for the other regions the glow reaches. A glow reaches about
4,000 pixels at 4096 pixels per cell: a grid block drawn out to its light would take over 70 times
its pixels on Blackreach, at each of its levels, and most of the map’s memory.
Limits:
- The surface is a height per pixel, with nothing under it: an eave, a porch roof or a tree’s canopy over a light hides all of its glow, though in the game the light spills out from under it. Lights in cave worldspaces, such as Blackreach, are all under the ceiling the objects draw.
- The top of a fixture more than 32 units above its light, such as a street lamp’s cap, stays unlit in the middle of its glow.
- A slope rising more than 32 units above a light isn’t lit, though the light faces it.
Cell grid
--cell-grid draws the grid of the worldspace’s exterior CELL records, labels each cell, and
outlines the LAND cells the map draws: every LAND cell, or only those inside the playable
bounds with --crop-to-playable. A CELL without LAND has its grid line and label too. The
cells are listed from their place under the worldspace’s children group, with their XCLC grid
position and EDID (WorldspaceMapReads.CellNames). A CELL override without EDID or XCLC
keeps the earlier one.
| Mark | Drawn as |
|---|---|
Line between two cells, either a CELL record | Black blended at 35 %, on the west or south border of a cell |
Edge between a LAND cell and a cell without LAND | Black blended at 80 %, inside the LAND cell |
| Label | x,y, then (EditorID) on the lines below, white with a black shadow, in the north-west corner |
A line is one pixel wide per 32 pixels of cell, at least one: 1 pixel at 32 pixels per cell, 4 at 128. The label’s font is 5x7 pixels, scaled up by one per 128 pixels of cell. It draws capitals only and wraps the EditorID at the cell’s width. A label never spills into the next cell.
A pixel belongs to the cell under its center, so the lines and labels fall at the same place however the map is cut into regions or tiles. The layer comes after the roads, so the grid shows over every layer. Limits:
- A cell narrower than 4 pixels would be mostly lines, so the layer draws nothing on that map and
logs it at debug level (
--verbose). Below 32 pixels per cell, the lines are drawn without labels. Raise--pixels-per-cell, or pick a finer--level. - A child drawn with
--parent-lodshows its own cells and the parent’s cells inside its bounds alike. Where both have aCELLat the same grid position, the child’s label wins.
Output formats
--format picks how each map is written. All three hold the same image. --png-compression sets the
deflate level of every PNG written, 4 by default: lower writes faster and larger files.
--format | Writes | For |
|---|---|---|
plain-png (default) | <output-directory>/<EditorID>.png | Viewing the whole map at once |
grid | <output-directory>/<EditorID>/<z>/<x>/<y>.png and tiles.json, <EditorID>.json and maps.json | Leaflet, OpenLayers or any viewer of XYZ tiles |
pmtiles | <output-directory>/<EditorID>.pmtiles, <EditorID>.json and maps.json | The grid’s tiles in one file, for large maps, see PMTiles output |
With grid and pmtiles, each map gets a manifest, <EditorID>.json, next to its tiles, and
maps.json lists the maps of the run, replacing any earlier one. They follow the
map export format, which the generated site reads. The manifest adds
what tiles.json doesn’t hold: the worldspace’s name, parent and flags, the plugins that carry
it, the load order and how the map was drawn. To list these plugins, the plugins’ pass also lists
every exterior CELL under its worldspace (WorldspaceMapReads.Contributors).
Grid output
The grid is a pyramid of 256x256 tiles (MapTilePyramid). The highest zoom holds the image at
full size; each zoom below halves it, down to zoom 0, where the whole image fits in one tile. x
counts columns from the left edge and y rows from the top. Tiles past the image’s right or bottom
edge are transparent where the image ends. A tile with no visible pixel is not written: a viewer
shows a missing tile as empty, which is what it holds. Each zoom is built from the tiles of the zoom
above as they are written, never from the whole image.
tiles.json describes the grid:
| Property | Meaning |
|---|---|
editorId, formId | The worldspace |
width, height | The full-size image, in pixels |
tileSize | 256 |
minZoom, maxZoom | 0, and the zoom at full size |
emptyTilesOmitted | true: a fully transparent tile is not written |
pixelsPerCell | The width of a cell at full size, in pixels |
lodLevel | The terrain LOD level drawn. Only with the lod background |
worldBounds | west, north, east, south: the image’s edges in game units (X east, Y north) |
language | The language of the names. Only with --markers |
markerGroups | The groups of markers on the image, see Markers. Only with --markers |
levelOf, level, altitude | The map a level is drawn over, the level’s index and its stop in game units. Only in a level’s tiles.json |
A pixel at full size spans (east - west) / width game units. With Leaflet, use CRS.Simple
and a tile layer on <EditorID>/{z}/{x}/{y}.png with maxNativeZoom set to maxZoom.
PMTiles output
--format pmtiles writes the tiles of the grid into one
PMTiles v3 archive,
<EditorID>.pmtiles, with tiles.json as the archive’s metadata. The tiles, their z/x/y and
the JSON are those of grid, byte for byte. A grid of a large map is millions of small files:
each costs the file system an inode and a directory entry, and on a hard disk a seek. The archive
is written from start to end instead.
Tamriel cropped to the playable area at 512 pixels per cell (45,110 tiles, --water), written to
an ext4 hard disk, timed from the command’s start to a sync after it:
--format | Time | Size |
|---|---|---|
pmtiles | 30 s | 830 MB, one file |
grid | 57 s | 931 MB, 45,110 files |
The same archive takes about 26 s on an NVMe SSD: on the hard disk, pmtiles costs little more
than the drawing. The gap grows with the tile count, once the page cache no longer absorbs the
grid’s writes.
The archive is written in one pass (PmTilesSink, PmTiles/PmTilesWriter):
- The archive is written as
<EditorID>.pmtiles.part. Its first 16 KiB are left as zeros, for the header and the root directory. - Each block’s tiles are encoded in parallel, then appended in the order the pyramid emits them. A tile identical to one already written (by SHA-256) is not written again: its entry points at the first one.
- Once the map is drawn, the entries are sorted by TileId, the leaf directories and the gzipped metadata are appended, then the header and the root directory are written at the start.
- The
.partfile is renamed<EditorID>.pmtiles, replacing the archive of an earlier run.
| Header field | Value |
|---|---|
| Tile type | PNG |
| Tile compression | None: a PNG is already compressed |
| Internal compression | gzip, for the directories and the metadata |
| Clustered | No: tiles are in the order they are drawn, not in TileId order |
| Min zoom, max zoom | minZoom and maxZoom of tiles.json |
| Bounds, center | Where the image sits on zoom 0’s Web Mercator tile; the map isn’t georeferenced |
The root directory holds every entry when it fits in the first 16 KiB; otherwise it points at leaf directories of at least 4,096 entries, grown until it fits. A Tamriel at 512 pixels per cell has 45,110 tiles and 40,351 entries in about 10 leaves.
Limits:
- A run cut short (a crash, Ctrl+C) leaves its
.partfile, with no header: no reader opens it. The archive of the last complete run stays in place. Run the command again: it overwrites the.partfile. - The entries and the hashes of the tiles stay in memory until the end: about 100 bytes a tile, some 400 MB for 4 million tiles.
To read an archive:
| Reader | How |
|---|---|
| Leaflet | pmtiles.leafletRasterLayer(new pmtiles.PMTiles(url), options) of the pmtiles library, with a grid layer’s options; getMetadata() returns tiles.json |
| A local file in a browser | new pmtiles.FileSource(file) on a file input: the browser reads only the ranges it needs |
| A server | It must answer HTTP Range requests (nginx, caddy file-server, or serve <folder> [port] in the dev shell). Python’s http.server doesn’t |
pmtiles CLI | pmtiles serve <dir> serves /<EditorID>/{z}/{x}/{y}.png to any XYZ viewer; pmtiles verify checks an archive |
| QGIS | Not directly: GDAL reads vector PMTiles only. Add pmtiles serve as an XYZ connection. QGIS shows it in Web Mercator, not in game units |
tool/map-viewer.html opens both a grid folder and an archive, by URL or by file input.
Level files
With --levels, a map with stops writes each level next to level 0. A level is a layer
of tiles meant to be stacked over level 0: it holds only the tiles whose pixels differ from level
0’s tile at the same z/x/y, at every zoom. Where it has no tile, a viewer shows level 0, which
is right there since nothing changes.
--format | Level k | Missing tile |
|---|---|---|
plain-png | <EditorID>.level-<k>.png, the whole image: a PNG has no tile to leave out | None |
grid | <EditorID>.level-<k>/<z>/<x>/<y>.png, with its tiles.json | Left out, as a transparent tile is |
pmtiles | <EditorID>.level-<k>.pmtiles, its tiles.json as metadata | Not in the archive |
A level’s tiles.json is level 0’s with levelOf, level and altitude added (see
Grid output). A level equal to level 0 everywhere still gets its folder or archive,
with no tile. The map’s manifest lists each level with its stop and its path, see
Map levels.
The regions are drawn once and handed to each level’s sink in turn, level 0 first. Level 0’s sink
keeps the tiles the region completes, transparent ones included, until every level has written
the region (LevelTileFilter). Every pyramid gets the same regions, so each emits the same z/x/y
at the same step, and the comparison holds at every zoom. A level tile byte-equal to level 0’s is
neither encoded nor written.
Stacking is exact only where a level is opaque wherever level 0 is: a pixel transparent in the level but opaque in level 0 would show level 0 through it. A worldspace map is opaque wherever its background is, at every level, so the writer checks it and stops with an error naming the tile if a level breaks it. A map without background, such as an interior, would break it wherever the cut empties a pixel: it would need to paint such a pixel with an opaque void color first. The worldspace maps don’t need it.
Markers
With --markers, tiles.json and the map manifest list what a viewer places on the image, with
--format grid or pmtiles only: a plain PNG has nowhere to put it. Nothing is drawn: a viewer
places each marker from its pixel position. The value picks the kinds of marker, comma-separated;
without a value every kind is listed. Each kind is one group of markerGroups, with its name,
color and whether a viewer shows it at first, see
Marker groups.
| Kind | Records | Marker placed at | Marker data |
|---|---|---|---|
location | Each exterior REFR with XMRK: its FNAM flags, FULL name and TNAM type | Its DATA position | The type’s name, and the Visible and Can travel to flags |
books | Each exterior REFR whose NAME is a BOOK: the book’s FULL title | The REFR’s DATA position | None |
The plugins’ pass decodes every exterior REFR for the kinds asked. Each record’s last version
wins, see Load order and merging. A location marker whose last
version is deleted, or a REFR that no longer has XMRK, is removed. A marker whose last version
is “Initially Disabled” stays, with disabled set: a quest enables it, such as the Dark
Brotherhood Sanctuary, and a viewer draws it fainter. A book follows the same rule, a deleted
REFR left off. A book is listed once per REFR: its formId is the BOOK, so a book lying in
several places appears several times. Only the books lying in the world are listed: those in a
container or on an NPC have no position. A book’s content, image and page are not part of the list.
The names are resolved in --language (english by default), against the string tables of the
plugin that wrote the record’s last version. A map lists the markers of its worldspace whose
position falls on the image, and with --parent-lod its parent’s too. It adds those of each
descendant placed by its ONAM, see Child worldspaces.
With --levels, a map with stops gives each marker the levels whose floor under it is
the floor nearest its height (levels). The floor is read once per map from the level set the
objects layer built for the drawing, so a marker’s levels and the tiles agree.
tiles.json leaves out a property that is null; a map manifest writes it as null.
A kind is a MapMarkerSource in Pipelines/Maps/Markers/, one file per kind, listed in
MapMarkerSources. The source says what it reads in the plugins (Reads, Datasets), builds its
markers with their data once the plugins are read, and gives its group’s id, name, color and
default visibility. MapMarkerCatalog resolves the names, places the markers on each image and
writes the groups; the options, the manifest and the viewers need no change for a new kind.
Limits:
- A name is the record’s
FULLonly: no script or quest changes it. - A book with no
FULLis listed without a name. - A child’s
ONAMis taken as is. FallowstoneCaveWorldEnd is built in Tamriel’s coordinates, but itsONAMgathers it near Whiterun: Giant’s Grove is listed there, see the assumption.
Output and logging
Each map logs how it was drawn at debug level. A problem in the data is counted in one warning per
map or per run and listed with --verbose, see
data problems. The run ends with
N of M worldspace map(s) written to <dir>., M counting only the worldspaces named by
--worldspace when given. A run that writes no map, or a --worldspace that names no worldspace,
is an error.
While a map is written, a status line under the log gives its progress, redrawn twice a second:
Tamriel [skyrim.esm:00003C]: 14.1 of 35.4 Gpx (40.0%), 39.3 Mpx/s, 5m39s, ~8m left
It reads: pixels written of the total, the speed over the last 10 seconds, the time elapsed, and the time left at the average speed so far. The transparent regions outside the worldspace’s cells count as written pixels and take almost no time. The status line appears only on a terminal and is erased once the map is written, see Logging. A large map then logs its summary:
[INFO] Tamriel [skyrim.esm:00003C]: 210944x167936 px (35.4 Gpx), 33784 region(s), 540544 tile(s) at zoom 10.
[INFO] Tamriel [skyrim.esm:00003C]: 35.4 Gpx in 14m46s, 40.0 Mpx/s.
When stderr goes to a file or a pipe, a large map logs the status line at each tenth of its pixels instead, ending with a period. A map below 2^30 pixels logs none of these lines.
The worldspaces that get no map are counted in one warning, and --verbose gives each one’s
reason. Each background adds its own reasons, see its page. The ones shared by every background are:
- no EditorID, which names the map;
- no exterior
LANDrecord in the load order; - with
--crop-to-playable, noLANDcell inside its playable bounds.
When the worldspace has a parent (WNAM) and PNAM sets “Use LOD Data”, the reason adds that
the worldspace uses its parent’s LOD and that --parent-lod draws it.
Shared arguments and options
Every export:worldspace-maps:* command takes these, after its own options:
<data-directory> --output-directory <dir> [--clean] [--crop-to-playable] [--water] [--interpolation nearest|bilinear|bicubic|bspline] [--objects[=colormap|texture|wireframe]] [--levels] [--projected-materials] [--hillshade-hour sunrise|midday|sunset|midnight] [--roads] [--lights] [--cell-grid] [--parent-lod] [--worldspace <EditorID>]... [--format plain-png|grid|pmtiles] [--png-compression <1-9>] [--jobs auto|<count>] [--markers[=location,books] [--language <language>]] [--load-order se|ae|custom [--load-order-plugins <names|file>] [--load-order-archives <names|file>]]
Each option is described in its section above; <command> --help lists them with their defaults.
export:worldspace-maps:lod
export:worldspace-maps:lod <data-directory> --output-directory <dir> [--level <4|8|16|32|auto>] [--max-size <px>] [--hillshade] [<shared options>]
The shared options are in Worldspace maps.
Draws each worldspace’s map over its terrain LOD diffuse tiles, stitched. The
tiles show the terrain only: there is no object LOD. Buildings, rocks and trees need --objects,
roads and trails --roads, see Objects and Roads.
A worldspace that uses its parent’s LOD is drawn from it with --parent-lod, see
Parent LOD.
It builds on the same tile derivation as
debug:*:archive:terrain-lod, for every worldspace of the load
order instead of one. The sources for the tile naming and the lodsettings layout are listed in
assumptions.
Pipeline
The background is Pipelines/Maps/Backgrounds/Lod/LodBackground.cs. For each planned worldspace,
LodRenderer:
- Reads
lodsettings\<editor id>.lodfrom the archive file system (LOD settings format). It gives the tile grid’s origin and the levels that exist. A worldspace drawn with--parent-lodreads its parent’s. - Picks the level:
--level, or with--level autothe finest one that fits--max-size(see Size). - Groups the planned cells into tiles (
LodTile) stepping by the level from the settings’ origin, and extracts each tile’s diffuse.ddsfrom the archive file system (TerrainLodTileSource). - Decodes each tile (
DdsDecoder.TryDecode, see DDS textures). With--hillshade, also decodes its_n.ddsnormal map, scaled to the tile (TerrainLodNormals, see below). - Redraws each placeholder tile, and its normal map, from the next finer level (see below).
- Places every tile on a north-up grid, scaled to the largest tile’s size, and with a crop keeps
the part over the kept cells (
MapProjection). - Draws a region of the map (
LodRaster): each tile under it, scaled with nearest-neighbor sampling, tiles in parallel, and with--hillshadeeach pixel’s normal from its tile’s normal map. A tile that is missing or can’t be decoded stays transparent. The layers are drawn next.
A tile covers --level x --level cells whether or not they exist, and vanilla tiles are black
where a cell has no LAND (most of MarkarthWorld’s only level-32 tile): --crop-to-playable
clears them.
Size
--level sets how many cells a LOD tile covers on each side: 4, 8, 16 or 32 (LOD_LOWLEVEL, the
default). A vanilla tile is 256x256 pixels, so a level gives 256 / level pixels per cell: 8 at
level 32, 64 at level 4. A finer level reads finer tiles: the detail grows with the image. Tamriel
fits in a 1024x1024 image at level 32, and is a grid of about 31x24 tiles, 7936x6144 pixels, at
level 4.
Automatic level
--level auto tries the levels the worldspace’s LOD settings generate, finest first, and keeps
the first one whose image fits --max-size pixels on its longest side (default 2048). The size is
measured from the DDS headers of the tiles, before decoding them. One tile’s header is read
first: when that tile alone already makes the image too large, the level is skipped without
extracting the others. When no level fits, the coarsest level with tiles is used. A small
worldspace gets level 4 (64 pixels per cell with 256x256 tiles), Tamriel gets level 16.
JaphetsFollyWorld, whose LOD stops at level 16, gets a map only this way.
Placeholder tiles
Vanilla ships tiles much smaller than the others: at level 32, Tamriel’s 4x4
tamriel.32.-64.-64.dds sits next to 256x256 tiles. Scaled up, it’s a block of 64x64-pixel
squares, and its normal map shades each square as one flat facet. A tile smaller than the largest
tile of its level is redrawn from the four tiles of the next finer level covering it, recursively
while a child is itself too small. It stays as is when the settings generate no finer level or
none of the children exists. tamriel.32.-64.-64 is the only placeholder among Tamriel’s
tiles, and every level-16 tile under it is 256x256.
Hillshade
The _n.dds next to each diffuse tile is a world-space normal map: red is east, green is up and
blue is north (see assumptions).
--hillshade lights it from the north-west, 45 degrees above the horizon, the usual convention
for shaded relief maps, or from the preset of --hillshade-hour (see
Hillshade hour). The tile isn’t shaded as it is read: each pixel
leaves the normal of its texel to the lighting layer, which lights the
tiles and the objects in one pass, by the map’s one formula, see
Map shading. A tile whose normal map is
missing or undecodable is left unlit. Flat ground keeps its diffuse color. A slope facing the light gets up to 23% brighter from the north-west; under a lower light
the factor stops at 35% brighter. A slope facing away keeps at least 55% of its color.
Without --hillshade, neither the tiles nor the objects are shaded.
The tiles take the formula’s slope term only. The broad relief, the curvature and the cast shadows are
measured on VHGT heights, which this background doesn’t read: see
Hillshade and Surface relief.
The shading is per pixel of the LOD tile, so its detail follows the level: 8x8 pixels per cell at level 32, 64x64 at level 4. It shows mountain ranges and valleys, not paths or buildings: the layers add them.
Parent LOD
A worldspace whose PNAM sets “Use LOD Data” has no terrain LOD of its own. Without
--parent-lod, it gets no map. With --parent-lod, it is drawn from the tiles and lodsettings
of its parent, cropped to its cells (see Parent LOD).
The image is the parent’s terrain LOD, not the city’s buildings: Tamriel’s LOD shows Whiterun as a
flat dark area. --objects draws them over it, see Objects.
MarkarthWorld has its own LOD and is drawn without --parent-lod.
Worldspaces without a map
A worldspace without the requested LOD counts in the shared warning, which reads “have no level-32
terrain LOD”. Its --verbose reason is one of the shared ones, or:
- no
lodsettings\<editor id>.lodin the archives; - its LOD settings don’t generate this level (JaphetsFollyWorld stops at 16);
- none of its expected tiles is in the archives, or none decodes;
- with
--parent-lod, its LOD parent has no EditorID, which names its LOD folder.
On the vanilla SE load order at level 32, every worldspace with a lodsettings file gets a map
except JaphetsFollyWorld, which --level auto draws. A tile missing or undecodable stays
transparent and is counted in one warning per worldspace.
export:worldspace-maps:raster-records
export:worldspace-maps:raster-records <data-directory> --output-directory <dir> [--pixels-per-cell <1-4096>|auto [--max-size <pixels>]] [--terrain auto|colormap|texture] [--hillshade] [--grass] [<shared options>]
The shared options are in Worldspace maps.
Draws each worldspace’s map from its LAND records: the landscape textures each
cell paints, its vertex colors, with --hillshade its relief and with --grass the grass its
textures grow. Unlike lod, it needs no terrain LOD: every worldspace with exterior
LAND gets a map, including the ones that ship no LOD, and a mod that edits the landscape shows on
the map without regenerating LOD. The archives are read only for the landscape textures and, with
--grass, the grass models and their textures.
The background shows the ground, tinted by its grass with --grass, or from 512 pixels per cell covered
with grass tufts (see Grass).
Buildings, rocks and trees need --objects, roads and trails --roads, see
Objects and
Roads. Without them, a forest looks like the ground under it. A worldspace that
uses its parent’s LOD has holes where it has no LAND; --parent-lod fills them from its parent,
see Parent LOD.
Pipeline
The background is Pipelines/Maps/Backgrounds/Landscape/LandscapeBackground.cs.
- In the same pass as the worldspaces, read every exterior
LAND’sBTXT,ATXT,VTXTandVCLR(WorldspaceMapReads.Textures), itsVHGTwith--hillshadeor--grass, everyLTEXandTXSTwith itsTX00,TX01andDNAM(Datasets/Landscape/LandscapeTextures), and with--grasseveryGRAS(Datasets/Landscape/GrassTypes). - Keep each cell’s last
LANDover the load order and resolve itsLTEXFormIds (Datasets/Worldspaces/WorldspaceLandscapes). A laterLANDreplaces the whole cell. - Before the first map, give each
LTEXa color (LandscapePalette, see Colors), when the maps draw the pattern, its swatches (see Textures) and with--hillshadethose of its normal map (see Normal maps), and with--grassits grass (GrassPalette,GrassCover, see Grass); from 512 pixels per cell, the grass models with their UVs and textures (GrassTuftModels, see Grass tufts). - Size the image on the planned cells,
--pixels-per-cellpixels per cell side (MapProjection.ForCells, see Size), and compute every cell’s vertex colors (LandscapeRasterizer). - Draw a region of the map: the cells under it build their color, texture and relief grids, in
parallel, then the pixels of its cells are made opaque and its grass tufts are drawn. The rows
are painted in parallel last, once the objects are drawn, and only where neither a tuft nor an
object covers the ground (see Pipeline). A planned cell
without a
LANDrecord stays transparent.
With a crop, the image covers only the kept cells: there is nothing outside them to crop. The layers are drawn next.
Size
--pixels-per-cell sets the side of a cell in pixels, 1 to 4096. The default, 32, draws one pixel
per vertex step (128 units): a LAND cell has 33x33 vertices, and a path narrower than a vertex step
blurs. Past 64 pixels per cell, the ground is the vertices scaled up: soft blocks (rounder with
--interpolation bicubic), and a water shore drawn without anti-aliasing shows steps.
--terrain texture adds detail past that scale, see Textures.
Tamriel is 119x94 cells: 3808x3008 pixels at the default, 7616x6016 at 64, 243,712x192,512 at
2048, 210,944x167,936 cropped to the playable area. Any size is drawn region by region, see
Pipeline. Write a
single worldspace at that size with --worldspace.
Automatic size
--pixels-per-cell auto picks a size per worldspace: the largest whole number of pixels per cell
whose longest side fits --max-size, measured on the cropped cells with --crop-to-playable. It
never goes past 32, one pixel per vertex step: a larger size only scales the vertices up. A small
worldspace gets 32. With the default --max-size 2048, Tamriel (119 cells wide) gets 17,
2023x1598 pixels. A worldspace wider than --max-size cells gets 1 pixel per cell and exceeds it.
Terrain
--terrain sets how the landscape textures are drawn. Every mode builds each cell’s colors the
same way, see Colors.
--terrain | Draws |
|---|---|
auto, the default | texture from 768 pixels per cell, colormap below, see Automatic terrain |
colormap | Each landscape texture as the average color of its color map |
texture | The same colors, carrying each texture’s pattern repeated as in game, see Textures |
Automatic terrain
With auto, a map draws the pattern when a repeat is at least 32 pixels wide, 768 pixels per cell
and more (LandscapeOptions.AutoPatternPixelsPerCell), and the average colors below. The scale is
the map’s own: with --pixels-per-cell auto, which never goes past 32, every map draws the colors.
A repeat narrower than that shrinks a texture of 1024 texels or more to a few dozen pixels: what is left is its periodicity, a regular grain or grid of dots, not a texture you recognize (see the limits). On WhiterunWorld, compared side by side at 256, 512, 768 and 1024 pixels per cell, the grain reads as ground from 768. The 32 pixels are a style choice.
Colors
A landscape texture’s color is the average of its color map: LTEX TNAM points at a TXST,
whose TX00 is a path under textures\. A quadrant without a base texture uses
textures\landscape\dirt02.dds, as the engine does. A texture that can’t be read is drawn gray,
see data problems.
Each cell is drawn from its 33x33 vertices, then interpolated for each pixel (see Interpolation):
| Step | Source | Effect |
|---|---|---|
| Base | BTXT | Each quadrant’s 17x17 vertices take its base texture’s color |
| Layers | ATXT and VTXT | In ATXT layer order, each point moves toward the layer’s color by its opacity |
| Vertex colors | VCLR | The color is multiplied by the vertex color |
| Tone | 255 x (c / 255)^0.6 x 1.05 per channel | |
| Hillshade | VHGT, with --hillshade | Per pixel, after the tone, see Hillshade |
The tone curve lifts the dark average of the terrain textures, which VCLR darkens further. It is
a style choice.
The quadrant grid and the VTXT layout come from the Oblivion LAND page, see
assumptions.
Two cells share their edge vertices, but each quadrant carries its own base texture and layers, so neighbouring cells don’t always paint a shared vertex the same color: in Tamriel, the base texture changes across 6,220 of the 22,184 quadrant pairs that meet on a cell’s east edge. Drawn as is, each cell would stop on a straight line at its edge. Each vertex on a cell’s border takes the mean color of the cells sharing it, two along an edge and up to four at a corner, after the tone. Inside a cell, a vertex two quadrants share takes the later quadrant’s base texture and every layer that reaches it.
Limits:
- A texture’s average hides its pattern: a cobblestone texture and a gravel one of the same tone
look alike.
--terrain textureadds the pattern. - A quadrant painted with another base texture than its neighbours still ends on a straight line, one vertex step wide.
Textures
With --terrain texture, each pixel keeps its average color and takes on the pattern of
the textures under it (LandscapeTextureDetail). A landscape texture repeats 24 times per cell, 12
per quadrant, aligned on the cell edges, as in game (see
assumptions). A repeat is
pixels per cell / 24 pixels wide: 4 pixels at 96, about 11 at 256, 85 at 2048.
- Before the first map, each color map is shrunk to square power-of-two levels down to 1x1
(
LandscapeSwatch), each texel the mean of the pixels it covers. The finest level is the repeat’s width in pixels at--pixels-per-cell, rounded up to a power of two, and at most the color map’s shorter side: 16 texels at 256 pixels per cell, 128 at 2048, 256 at 4096. - The map samples the two levels around one texel per pixel, each with
--interpolation(bilinear by default, see Interpolation), wrapping at each repeat, and blends them linearly by where the scale falls between them. At 2048 pixels per cell, a repeat of 85 pixels reads the 64 and 128 texel levels. - Each vertex weighs its textures the way it blends their colors: a layer covers what lies under it by its opacity. The weights are interpolated to the pixel.
- The pixel’s color is multiplied by the weighted texture samples over the weighted texture means,
per channel, raised to the tone curve’s 0.6.
ToneCurvecomputes the power from a table, within a thousandth of a color level.
The colors stay those of --terrain colormap on average: the edges between cells, VCLR, the tone
and the hillshade work the same way. At 24 pixels per cell or less a repeat fits in a pixel and the
map is the same as with --terrain colormap.
A color map of N texels a side shows one texel per pixel at 24 x N pixels per cell, its repeat
then N pixels wide. Below that scale the map shows the color map reduced. Past it, the finest
level is the whole color map, scaled up with --interpolation: the map only zooms in on it, without
new detail.
| Color map side | One texel per pixel at | Magnified within --pixels-per-cell (1 to 4096) |
|---|---|---|
| 64 | 1,536 px per cell | Past 1,536 |
| 128 | 3,072 px per cell | Past 3,072 |
| 256 | 6,144 px per cell | Never |
| 1024 | 24,576 px per cell | Never |
At 4096 pixels per cell a repeat is 171 pixels: only a color map under 171 texels a side is
magnified. Apart from one 32-texel mask, the vanilla files under textures\landscape are 256 texels
or more on their shorter side, most of them 1024 or 2048: in the accepted range, the vanilla pattern
is always a reduction.
Pattern tiles
When a cell spans a power of two of pixels, the pattern comes back every 3 repeats, an eighth of a
cell: 512 pixels at 4096 pixels per cell. Each pixel’s place in a repeat is then an exact binary
fraction, so each period gives the same values to the bit. LandscapePatternTiles computes one
tile per color map and per normal map the first time a cell uses it, and a pixel reads the tile
instead of its texels. Other scales have no exact period, and some have none short enough to hold
in memory: 4097 pixels per cell would need a tile of 4097 x 4097 pixels. They read the texels for
each pixel.
A texture holds 10.5 MiB of tiles at 4096 pixels per cell, in double to keep the output exact, on
top of its levels. Only the textures of the cells drawn cost it.
Limits:
- Below 384 pixels per cell a repeat is under 16 pixels: the map shows a fine, regular grain,
not a texture you recognize. At 96 pixels per cell, Tamriel differs from
--terrain colormapby about 1.4 levels out of 255 on average. - The grain is regular, so a large area of one texture looks like a grid. At 2048 pixels per cell, the 85-pixel repeat is visible on rock and gravel.
VCLRis left out of the weights: where it changes fast, the pattern’s strength is off by the change.
Hillshade
With --hillshade, each pixel is multiplied by a shading factor, lit from the north-west at 45
degrees, or from the preset of --hillshade-hour (see Hillshade hour).
The ground computes its terms (LandscapeHillshade) and leaves them to the lighting
layer: the fine slope as the pixel’s normal, the broad and curvature terms
as its relief. Flat ground keeps its color. The factor is computed per pixel, not per vertex, so the
relief stays sharp past 32 pixels per cell, and after the tone curve, which would otherwise
flatten it.
| Term | Slope measured | Exaggeration | Weight |
|---|---|---|---|
| Fine | From the vertex on each side, at each vertex | 1 | 0.8 |
| Broad | From 12 vertices (1536 units) on each side, at each vertex | 2 | 0.4 |
Every term is computed at each vertex, then interpolated to the pixel with --interpolation.
Each slope term is the Lambert shading of its slope minus that of flat ground. The fine one shows
the vertex-scale detail, the broad one the shape of a mountain or a valley.
The curvature term doesn’t depend on the light. It measures how much the slope rises across the
vertex, from 4 vertices (512 units) on each side, on both axes: it is positive in a hollow and
negative on a ridge. The term is -0.18 x tanh(3 x change), so a hollow darkens, a ridge lightens,
and a cliff stays bounded. It shows the gullies and crests that face neither toward nor away from
the light. A curvature measured from the next vertex only shows the vertex grid: it draws a
mottling on snow at 64 pixels per cell, and a checkerboard 8 pixels wide at 256.
The factor is the map’s one formula, see Map shading,
on the fine slope, with the broad and curvature terms as its cartographic terms:
1 + fine + broad + curvature, kept between 0.55 and 1.35. The fine term’s weight is the formula’s
k, the one the objects and the LOD tiles are shaded by. Every term reads the
heights of the neighbouring cells, so the shading has no seam at a cell edge. Where a neighbour has
no LAND, the cell repeats its own edge. The weights, exaggerations and the curvature’s radius, weight
and 3 are style choices.
A ridge running diagonally across the vertex grid shows a step at each vertex: that is the terrain itself, which the game hides under rock meshes.
With --objects, those meshes are drawn and lit in the same pass, by the same light and formula;
without --hillshade, neither the ground nor the objects are shaded. The broad and curvature terms
then read the surface the map shows rather than the LAND alone: at each vertex, the LAND raised
to the highest object face that faces up over it. A mountain mesh enters the broad relief as a
LAND mountain would, and the ground around it takes its relief. See
Surface relief.
Normal maps
Where the map draws the pattern (see Terrain), --hillshade also shades the relief of
each landscape texture: the pebbles, clods and cracks of its normal map, TXST TX01. Nothing
else turns it on, and without --hillshade the map has no light to show it by.
- Before the first map, each normal map is shrunk to the same levels as its color map (see Textures), with the same repeats.
- At each pixel, each texture’s normal becomes a slope east and north, tilted at most 60 degrees,
and the slopes are weighted the way the colors are: a layer covers what lies under it by its
opacity, and with
--grassthe grass share counts as flat. - That slope is added to the fine term’s
LANDslope, before its Lambert shading. The factor keeps its terms and its bounds, 0.55 to 1.35: the relief of the texture tilts the ground, it isn’t a second shading.
A normal map averages out as it shrinks: the further out the scale, the flatter the relief, so
it fades with the pattern. The 60 degrees are a style choice: vanilla normal maps draw crevices
close to vertical (on dirt02_n.dds, 1% of texels lean past 84 degrees), which Lambert shading
turns into isolated black pixels at 2048 pixels per cell. How the map is oriented on the ground, and why a model-space one
(DNAM 0x04) is left out, is in
assumptions. On the vanilla SE load
order, the 90 LTEX with a TX01 all have a readable tangent-space normal map.
Limits:
- The default texture,
dirt02.ddsunder a quadrant without a base texture, has noTXST, so no normal map: it shows no relief. - The relief repeats with the pattern: at 1024 pixels per cell, a texture with a strong directional relief shows diagonal stripes 42 pixels apart.
Cast shadows
--hillshade adds to the cartographic terms the shadow the relief casts away from the light. The heights are those the broad relief reads: the LAND, raised with --objects
by the faces over it. So a mountain casts a shadow, mesh or LAND, and a house doesn’t: at 128 units
between vertices, the shadow has the scale of the relief. It shows most under a low sun, with
--hillshade-hour sunrise or sunset. The values are in
export heuristics.
The lod background casts none: it writes no relief, and reads no VHGT to cast from.
Grass
With --grass, the ground takes on the color of the grass its landscape textures grow
(GrassCover). Everything comes from the load order: a mod that adds or recolors grass changes the
map. Below 512 pixels per cell, it tints the ground where grass grows; from 512, it scatters the grass
models over it, see Grass tufts.
| Value | Source |
|---|---|
| Which grass a texture grows | LTEX GNAM, one per GRAS; a GRAS listed twice counts once |
| Its color | The GRAS MODL model’s diffuse textures, each alpha-weighted, the shapes weighted by triangle count (GrassPalette) |
| How much grows | GRAS DATA Density, read on 0 to 100 |
| Where it grows | GRAS DATA Min Slope and Max Slope, in degrees, both inclusive |
| Its side of the water | GRAS DATA Distance from water and How water distance is applied, against the cell’s water height |
At each vertex, the slope is measured from VHGT (LandscapeHeightField), from the vertex on each
side, across cell edges. --grass reads VHGT even without --hillshade. A cell without VHGT
counts as flat. The vertex’s height is compared with its cell’s water height (XCLW, or the
worldspace’s default): dry-land grass grows only over the water, kelp and coral only under it, see
water distance. Each texture’s grasses
whose slope range and water rule hold the vertex then give:
- a coverage, the sum of their densities over 100, at most 1;
- a grass color, their colors weighted by density.
The texture’s color moves toward its grass color by coverage x 0.6, before the layers are blended
(see Colors): VCLR, the tone and the hillshade then work as without grass. The 0.6
keeps the ground’s own color under full grass. It is a style choice, see
export heuristics.
With --terrain texture, the pattern of a texture applies to its ground share only; its grass
share is flat (see Textures).
A worldspace whose WRLD DATA sets No Grass (0x80) gets no grass. The map’s own worldspace
decides: with --parent-lod, the parent’s cells drawn in a child’s holes follow the child. On the
vanilla SE load order, 4 of the 45 maps have the flag, among them WhiterunWorld.
On the vanilla SE load order, 26 of the 91 LTEX list a GRAS, and 30 of the 31 GRAS get a
color. The last names a model that no archive holds, see
data problems. Every vanilla grass model reads
without a skipped NIF block.
Limits:
- Position, height and color range, wave period and the
DATAflags aren’t used, see not implemented. - The slope changes from one vertex to the next: at 64 pixels per cell and more, grass on uneven ground looks mottled.
- The grass color is the average of its texture: two grasses of the same tone look alike.
Grass tufts
From 512 pixels per cell (LandscapeOptions.TuftPixelsPerCell), --grass no longer tints the ground:
it places each GRAS model over it and draws them from above like the
objects, with their textures, alpha test and vertex colors (GrassTufts).
The ground between the tufts keeps its own color. Below that scale a tuft is a few pixels wide and the
tint reads better. A map with an automatic size stays under it.
The engine’s placement isn’t documented, so the tufts are placed the map’s own way (see export heuristics):
- A grass may grow every 32 world units on both axes (
GrassTufts.Spacing), moved within its 32-unit square. - A place holds a grass with a chance of the texture weights there times the grass’s density over 100, counted at each vertex where the grass’s slope range holds the slope, then interpolated bilinearly. A boundary between two textures or a slope limit fades over a vertex step instead of cutting along the grid.
- A kept tuft turns about its vertical axis, scales by 0.8 to 1.2 and stands upright at the ground’s
height, bilinear between the
VHGTvertices. - A tuft whose height doesn’t meet its grass’s water rule is dropped: the rule is checked at the
tuft’s own height, so the shore cuts the grass where the ground meets the water, not along the
vertex grid. Placed water (
WATRreferences) doesn’t count.
The place, turn, scale and the draw against the chance come from a hash of the place and the
GRAS FormId. Every region of every run draws the same tufts, and a grass that a mod adds to a
texture leaves the other grasses’ tufts where they were.
Every tuft is multiplied by 0.8 (GrassTufts.SelfShadow) for the blades’ shade on one another, its
only shading of its own. With --hillshade, the lighting layer then lights it
as the ground under it, by the ground’s normal and relief, so the relief still reads under a meadow.
The tufts are a cover of the ground: they leave the surface at the ground’s
height. The water layer tints them by the ground’s depth, and the contact occlusion doesn’t count
each tuft as a step.
Limits:
- Seen from straight above, a blade card shows its slant only: an upright card is a line.
- The tufts take their color from their texture: on the tundra, they read more saturated than the tint.
Parent LOD
Without --parent-lod, a worldspace whose PNAM sets “Use LOD Data” is drawn from its own LAND
only, with holes where it has none (about half of WhiterunWorld). With --parent-lod, its
parent’s LAND fills them, see Parent LOD.
A child and its parent paint the same place their own way, so a cell of the parent can stand out
from the child’s cells next to it. The rasterizer blends their shared edge (see Colors),
not the whole cell. SolitudeWorld shows it most: its own LAND is close to one flat texture,
Tamriel’s cells around it are not.
Worldspaces without a map
A worldspace without exterior LAND counts in the shared warning, which reads “have no exterior
LAND to rasterize”, see Output and logging. On the vanilla SE
load order, 4 worldspaces have none, among them KatariahWorld and WhiterunDragonsreachWorld.
A texture, normal map, grass model or tuft texture that can’t be read is drawn gray or left out, and counted in one warning, see data problems.
Load order and merging
A GlobalFormId identifies a record across plugins. This page covers the exporter side: which plugins load in which order, and how records from several plugins fold into one.
The engine clears a form and reloads it from each override; this codebase merges field by field instead, see Rule of One merge.
Load order
Game/LoadOrders/LoadOrder.cs holds the plugins a command merges and the BSA archives that make up its
archive file system, both in load order. You choose it with --load-order:
| Value | Plugins |
|---|---|
se | Skyrim.esm, Update.esm, Dawnguard.esm, HearthFires.esm, Dragonborn.esm |
ae | se, then ccBGSSSE001-Fish.esm, ccBGSSSE025-AdvDSGS.esm, ccBGSSSE037-Curios.esl, ccQDRSSE001-SurvivalMode.esl |
custom | The plugins of --load-order-plugins, see Custom load order |
ae adds the Creation Club content bundled with the Anniversary Edition upgrade, not separately
bought content. export:books, export:worldspace-maps:* and the terrain
LOD commands default to se; the other debug commands read one file unless --load-order is
given, see One file or a load order.
Game/GameSource.cs finds the plugins in the data directory, warns about each missing one and
logs an error when none is found. The session reads each plugin on its own thread and merges the
results in load order, see Architecture.
export:books writes the plugins it found and the archives it opened to export.json (see
Export manifest).
Archive file system
A load order’s archives are opened once per session, by Game/GameArchives.cs, as one
Game/Bsa/ArchiveFileSystem.cs: a single path index over every archive. Each lookup (a texture, a
NIF, a string table, a fontconfig, a terrain LOD tile) searches that whole index by path. When a
path is in several archives, the last archive in the list wins, see
Assumptions. An archive missing from
Data is skipped, and --verbose lists it.
Archive names only set the order:
- The vanilla archives of
Game/Vanilla/Archives.cs, inSkyrim_Default.ini’ssResourceArchiveListthensResourceArchiveList2order. - For each plugin beyond the five vanilla masters, in plugin order,
<plugin>.bsathen<plugin> - Textures.bsa. The engine loads both with the plugin, see Assumptions. The vanilla masters ship their resources in the sharedSkyrim - *.bsaarchives.
No code picks an archive by its name to find a kind of file: a texture in My Mod.bsa is found
the same way as one in Skyrim - Textures3.bsa.
Loose files
A file in a folder of Data (a loose file) overrides the same path in every archive, whatever the
load order: the engine looks for a loose file before it searches the archives. The archive file
system indexes them once per session, when it opens the archives, and every lookup checks them
first. This covers every kind of file the exporter reads: textures, NIFs, SWF font libraries,
fontconfig.txt, string tables, LOD settings and terrain LOD tiles. A translation that ships its
string tables loose in Data\Strings adds its language to export:books this way.
| Rule | Why |
|---|---|
| A loose file wins over every archive | Engine behavior, see Assumptions |
| Paths match ignoring case | The game runs on Windows: Textures\Landscape\Rocks01.DDS overrides textures\landscape\rocks01.dds |
Files at the root of Data aren’t indexed | Plugins, archives and ini files sit there; every resource path starts with a folder |
| A single archive file read on its own reads no loose file | The debug commands then show that archive’s content |
The log names a loose file’s origin loose where it would name an archive. --verbose lists the
files ignored because another one has the same path ignoring case, possible on Linux.
The data directory is scanned with all its subfolders. A lone plugin file reads the loose files of
its own folder, so pass a plugin that sits in Data, not in a large folder such as your home.
Custom load order
--load-order custom merges the plugins you list, in the order you list them:
| Option | Required | Value |
|---|---|---|
--load-order-plugins | Yes | Plugin file names (.esm, .esp, .esl) |
--load-order-archives | No | BSA file names (.bsa) |
Both options take either a comma-separated list or the path of a text file. A text file holds
one name per line; a line can also hold a comma-separated list. Blank lines and lines starting
with # are skipped:
# vanilla
Skyrim.esm
Update.esm
# mods
MoonAndStar_MAS.esp
A value that ends with a listed extension is always a name, never a list file, so Skyrim.esm
never reads a Skyrim.esm file in the current directory as a list. Every name is a file name in
the Data directory, without a path. A name listed twice, an unexpected extension or an empty
list is a parse error. Both options are parse errors with se or ae.
Names are matched to the files in Data ignoring case, as the game does on Windows, so
skyrim.esm finds Skyrim.esm on Linux.
Without --load-order-archives, the archive file system is built as for se and ae: the vanilla
archives, then the archives named after each listed plugin that exist in Data. With it, the
archive file system is exactly the archives you list, in order. List the vanilla archives
yourself when you need their string tables, fonts, textures or meshes.
BookAtlas.Exporter export:books Data -o export \
--load-order custom --load-order-plugins "Skyrim.esm,Update.esm,MoonAndStar_MAS.esp"
BookAtlas.Exporter export:books Data -o export \
--load-order custom --load-order-plugins plugins.txt --load-order-archives archives.txt
load-orders/ae-mods.txt is an example: the vanilla masters, the Creation Club content of Data
in Skyrim.ccc order, then a few mods ordered by their master flag and their masters.
The plugin list isn’t checked against each plugin’s masters. A master missing from the list shows up as unresolved FormIds in the merge reports.
The merge step
Datasets/Merging/RecordMerge.cs is shared by every merger:
- Resolve the record’s FormId with the writing plugin’s
PluginMasters. When it doesn’t resolve, drop the record and report it. - Build the merged value. FormIds inside the record (items, entries, destinations) are resolved here too: after merging, the writing plugin is no longer known.
- Insert it, or combine it with the value from earlier plugins.
The combine step is per record type. By default a non-null incoming field replaces the existing one and a null field leaves it alone:
| Field | Rule | Why |
|---|---|---|
| Scalar subrecords (EDID, FULL, DATA, XCLC, VENC, …) | Latest non-null wins | An override only carries what it changes |
Lists (CNTO, LVLO, SNAM) | Replaced whole when the override has any entry | Entries aren’t individually addressable |
REFR cell and interior flag | Latest wins | A move to another cell is an override |
REFR Persistent flag | Latest wins | Header flags are always present |
REFR HasScript | Latest wins | The engine clears script data on every override |
REFR HasTeleport | Or-ed across overrides | XTEL clearing isn’t documented |
BOOK DATA fields (flags, type, teaches, weight) | Replaced together by an override with DATA | One subrecord: an override that clears a teaches flag also clears what it taught |
Mergers:
| Merger | Records | Output |
|---|---|---|
Datasets/Books/BookMerger.cs | BOOK | One MergedBook per book, in first-seen order, with the plugin that last set each field |
Datasets/Locations/LocationMerger.MergeRecords | WRLD, CELL, REFR/ACHR, CONT, LVLI, NPC_, FACT | MergedLocations, one dictionary per type |
Datasets/Worldspaces/WorldspaceMerger.cs | WRLD and exterior cell headers | Worldspace details and cell counts |
MergedLocations is used both by book placement (below) and by the interior commands
(through the LocationRecords dataset), so every command sees the same merged references.
Localized text is resolved per plugin before merging, see Localization.
Merging locations
Datasets/Locations/BookReachability.cs finds where each book can be found in MergedLocations. Each
placed REFR or ACHR with a base object and a position is checked in turn:
| Base object | Placement source |
|---|---|
| The book itself | Direct |
A CONT whose items lead to the book | Container, or Vendor when the container is a vendor chest |
An NPC_ whose items lead to the book | Npc, or Vendor when the NPC is in a vendor faction |
“Leads to” follows nested leveled lists: an LVLO entry can be another LVLI. Results are
cached per FormId and a cycle stops the walk. ComputeLeveledListMemberships inverts the same
graph into “which lists can produce this book”.
Vendor chest resolution
A faction’s VENC names a placed chest REFR, not a CONT. The chain is faction, chest REFR,
its base CONT, then that container’s items. The chest is usually placed somewhere the player
never goes (Urag gro-Shub’s spell tomes, for example), so a vendor NPC’s stock is its own items
plus its vendor factions’ chest items, all at the NPC’s placement: that’s where the trade menu is.
A chest that is placed somewhere reachable is also reported as a Vendor placement.
Localization
A book’s FULL, DESC and CNAM are LStringS fields: inline bytes, or a string table id when
the plugin’s TES4 sets Localized. The decode is in
Plugin file format, the table layout in
BSA archive format. This page
covers how the exporter turns an id or inline bytes into text, per language.
Which table for which field
| Field | Table |
|---|---|
BOOK FULL | .strings |
BOOK DESC | .dlstrings |
BOOK CNAM | .dlstrings, see assumptions |
FULL of a referenced SPEL or AVIF, of a WRLD | .strings |
.ilstrings holds interface strings; nothing the exporter reads uses it.
Where the tables live
At Strings\<plugin>_<language>.<extension>, for example Strings\skyrim_english.dlstrings,
looked up by that path in the load order’s
archive file system. Vanilla packs every master’s
tables in Skyrim - Interface.bsa; a mod ships its own in its plugin archive or loose. A table
outside Strings\ isn’t read. The languages come from these file names, not from a hardcoded list.
Encoding
Text/GameTextDecoder tries each string as strict UTF-8, then the language’s secondary encoding
(Game/Vanilla/StringEncodings.SecondaryFallback, from the UESP table), then a lenient UTF-8
decode. SkyrimStringTable.Decode counts the fallbacks in FallbackCount, and its callers warn
when it isn’t 0. The missing secondary encodings and the decode rules are in
assumptions; alias substitution and font
coverage, which the exporter doesn’t handle, in
not implemented.
A non-localized plugin keeps its inline text as raw bytes (LStringS.InlineBytes), decoded per
export language with the same rule by Game/Assets/LStringResolver, see
inline string encoding.
Resolution pipeline
| Step | Code |
|---|---|
| Read string tables from the archive file system, list the languages | Game/Assets/LocalizationSource |
Decode one plugin’s .strings and .dlstrings for one language | Game/Assets/StringTableLoader |
| Replace each id with its text, decode inline bytes | Game/Assets/LStringResolver, Datasets/Books/BookLocalizationResolver |
| Do it for every plugin of a load order, warning about missing ids | Datasets/Books/BookLocalization |
| Localize the name of each record a book teaches, in its own plugin’s tables | Pipelines/Books/BookReferences.LocalizeAsync |
A missing id is exported as (localized, (XXXXXXXX)) rather than dropped. Id 0 means “no string”,
see assumptions.
Why resolution happens before merging
An id is only meaningful in its own plugin’s tables, and BookMerger loses which plugin wrote a
field. So each plugin’s books are localized first, then merged.
The SPEL and AVIF names a book points at and a worldspace’s WRLD name are the exception: the
Datasets/Lookups/NamedRecords lookup and WorldspaceMerger keep, with each merged name, the
plugin that wrote it (NameSource), so those names resolve after merging.
Book markup: fonts and textures
A resolved BOOK DESC is HTML-like markup:
<font face='$HandwrittenFont'><font size='40'><p align='center'>
Conjure Dremora Lord
<img src='img://Textures/Interface/Books/Alchemy Ingredients/dragonfly.png'>
Pipelines/Books/BookMarkupScanner.Scan collects every face='...' and src='...' value of a
language’s books. export:books then exports the fonts behind the faces, see
Font export, and copies the textures. A face with no map entry resolves to
(unmapped): vanilla text has at least one typo’d tag ($DwemerFont size=, a missing quote). How
the site renders the markup is in Bethesda markup handling.
Textures
Game/Assets/TextureSource looks a texture up in the load order’s
archive file system. It normalizes the
reference first (NormalizeToArchivePath):
- Strip a leading
img://. - Convert
/to\. - Drop everything before a
data\textures\folder, see assumptions. - Prepend
Textures\when the path doesn’t start with it.
The entry found is copied to <output>/textures/<path under Textures\>, named with the archive
entry’s casing, not the reference’s: vanilla spells the same letter W_letter.png and
w_letter.png, and the file name must not depend on which book is scanned first. Textures are
copied once for all languages.
A reference matching nothing logs a warning and the export goes on, see data problems.
The generator copies textures/ and each language’s fonts/ into the site and resolves the same
references with its own code (Rendering/SiteAssets/), since it can’t reference the exporter.
Font export: SWF to TrueType, per language
A book’s markup names a font by a face (<font face='$HandwrittenFont'>). export:books converts
each language’s fonts to TTF, so the site can show the text in the game’s fonts. The SWF parsing and
the TrueType writer are in
SWF font parsing; this page covers the exporter’s
side, Pipelines/Books/Fonts/ and Game/Assets/FontConfig*.cs.
fontconfig
A face isn’t a file: Interface\fontconfig*.txt maps it to a font embedded in a SWF.
fontlib "Interface\fonts_en.swf"
map "$DaedricFont" = "Daedric" Normal
fontlib lines name the SWFs a language’s fonts are embedded in; map lines map a face to a font
name. FontConfigParser.Parse reads both into a FontConfig. The syntax has no published spec:
the parser follows the vanilla files, see
assumptions. The weight word after a
name (Bold, Roman, Demi) is appended to it unless it is Normal, so $EverywhereBoldFont
maps to "Futura Condensed Bold".
Game/Vanilla/FontConfigFiles.cs picks the file per language: Chinese, Japanese, Polish and
Russian have their own (fontconfig_cn.txt, _ja.txt, _pl.txt, _ru.txt), the other languages
share fontconfig.txt.
Every embedded font is exported
FontLibraryExporter converts every DefineFont3 of each fontlib SWF, instead of resolving each
face to one font by name. A face whose map name matches no embedded font still has its font
exported under its real name: vanilla maps $CClub_Font to “Eurostile LT Cyr Std”, while
fonts_cclub.swf embeds “Eurostile LT Std Roman”, see
data problems.
The SWF-to-SWF symbol graph (ImportAssets2, ExportAssets, as in book.swf importing from
gfxfontlib.swf) isn’t implemented: every font a language needs is already embedded in its own
fontlib SWFs.
Fonts are converted per language, unlike textures: each language’s SWFs embed different glyphs.
Output
localized/<language>/fonts/<font name>.ttf per embedded font, listed under fonts in the
language’s index.json, see Book export format:
{
"books": [ ],
"fonts": [
{ "name": "Daedric", "styles": ["$DaedricFont"], "path": "fonts/Daedric.ttf" }
]
}
styles lists the faces mapped to the font. A face maps to the font whose name equals its map
name; failing that, to the font whose name contains it, because fontconfig_ja.txt maps
22_Skyrim_JP_BookFont_0805 while the SWF embeds 22_Skyrim_JP_BookFont_0805 Regular. When
several fonts contain the name, the weight word after it picks one, in the order Regular (also
Roman, Book, Normal), Medium, Light, Demi (also SemiBold), Bold. Two fonts of the same weight, or
suffixes outside this list, leave the face unresolved. styles is empty when no face maps to the
font.
Debug commands
The debug:* commands are inspection tools, not production exports. Use them to look inside a BSA
or a plugin, check the load-order merge, or survey the interior collision data before trusting
what export:books or the map commands produce.
Naming
Every debug command is named debug:<kind>:<source>:<domain>:
| Part | Values | Meaning |
|---|---|---|
<kind> | dump | Prints to stdout only. Never writes a file: redirect stdout to keep the output |
<kind> | export | Writes files under a required -o/--output-directory |
<source> | plugin | Reads records from one .esm/.esp/.esl file, or from a whole load order |
<source> | archive | Reads entries from one BSA archive, or from a whole load order’s |
<domain> | e.g. book, strings-tables | What is inspected. A domain can have both a dump and an export |
BookAtlas.Exporter --help prints this scheme, and <command> --help each command’s options and
examples.
Commands
| Command | Page | What it shows |
|---|---|---|
debug:dump:archive:files | archive files | Entry listing, optional hex dump |
debug:export:archive:files | archive files | Raw entries extracted to disk |
debug:dump:archive:strings-tables | strings tables | Decoded string tables, filterable by id or text |
debug:export:archive:strings-tables | strings tables | One decoded .txt per table |
debug:dump:archive:terrain-lod | terrain LOD | Expected LOD tiles and their archive |
debug:export:archive:terrain-lod | terrain LOD | LOD tiles extracted as .dds |
debug:dump:plugin:book | book | Merged BOOK records with per-field provenance |
debug:dump:plugin:vmad | VMAD | Papyrus scripts attached to a plugin’s records |
debug:dump:plugin:worldspaces | worldspaces | Merged WRLD records |
debug:dump:plugin:interior-collision-shapes | collision shapes | Havok shape histogram of placed interior objects |
All are registered in BookAtlas.Exporter/Commands/ExporterCli.cs and live in
BookAtlas.Exporter/Commands/Debug/.
One file or a load order
Every plugin and archive command except the terrain LOD ones reads either one file or a whole
load order. The --load-order option picks the mode:
| Invocation | Reads |
|---|---|
<command> Data/Skyrim.esm | That plugin only |
<command> "Data/Skyrim - Interface.bsa" | That archive only |
<command> Data --load-order se | Every plugin or archive of the vanilla Special Edition load order in Data |
<command> Data --load-order ae | The same, plus the Anniversary Edition Creation Club plugins and archives |
<command> Data --load-order custom --load-order-plugins <list> | The plugins you list, see Custom load order |
The debug:*:archive:files and debug:*:archive:strings-tables commands list archive entries
only, never loose files. The terrain LOD commands
resolve each tile as the game does, a loose tile first.
With --load-order, the argument must be the Data directory. Without it, the argument must be
a file. Any other pairing is a parse error. --load-order has no default on these commands: its
presence is what switches to the load order. The terrain LOD commands always read a load order:
they take <data-directory>, and their --load-order defaults to se.
Every command reads the same archives for a load order: its
archive file system, the vanilla archives then
the archives of each non-vanilla plugin. archive:strings-tables picks the string tables out of
it. The voices archive depends on the install language, so each shipped
Skyrim - Voices_<lang>0.bsa is listed and only the installed ones are found.
The archives are merged the way they are for export:books: a path present in several archives
resolves to the last one, and the earlier entries are counted as
shadowed in the summary line. With a load order, the listings add an archive column after the
size and compression.
A plugin read on its own is not merged with its masters:
- Its string tables and meshes come from the vanilla archives, plus the archives named after the
plugin when they exist (
ccBGSSSE001-Fish.bsaforccBGSSSE001-Fish.esm), since the engine loads those archives with the plugin. - FormIds still resolve to their owning plugin through the plugin’s master table, so an override
shows under its master’s
GlobalFormId. It shows only the fields this plugin sets. - A reference to a record the plugin doesn’t contain (for example a book’s MenuArt STAT in
Skyrim.esm) stays unresolved. Read the load order to see it resolved.
Shared behavior
- Every command opens game files via
Game/Bsa/GameFileStreams.OpenRead. Exports write throughIO/DestinationPathResolver, which rejects any archive-derived path that would escape the output directory. - A file or directory argument that doesn’t exist is a parse error, reported before anything is read.
- A plugin listed in the load order but absent from the data directory is skipped with a
[WARN]. Only finding none of them is an[ERROR]. A load order’s missing archives are expected (see above) and only listed at--verbose. Finding none is a[WARN]for the plugin commands, which still print what doesn’t need an archive, and an[ERROR]for the archive commands. - A filter option that matches nothing (
--worldspace,--cell) is an[ERROR]when the command can’t show anything without it, a[WARN]otherwise. - Output goes to stdout; progress, warnings and errors go to stderr.
--verboseadds per-file detail. See Logging. - The
archive:filesandarchive:strings-tablescommands log a one-line archive summary (version/codec, flags, folder/file counts, entry match count) before acting, viaGame/Bsa/BsaHeaderSummary.cs. With--load-order, that line moves to--verbose, one per archive, and a single[INFO]line gives the archives found, the matching entries, and the shadowed ones. The terrain LOD commands log their own summary instead (landscape cell count -> tile count -> expected file count), since they resolve tiles rather than list entries.
debug:*:archive:files
debug:dump:archive:files <bsa-archive|data-directory> [--load-order se|ae|custom [--load-order-plugins <names|file>] [--load-order-archives <names|file>]] [--file-glob <glob>] [--hex] [--bytes <count>]
debug:export:archive:files <bsa-archive|data-directory> [--load-order se|ae|custom [--load-order-plugins <names|file>] [--load-order-archives <names|file>]] --output-directory <dir> [--clean] [--file-glob <glob>]
The lowest-level archive tools. They don’t know what the files are: they list entries by path, or pull their bytes out as is.
debug:dump:archive:filesprints one line per matching entry: size, compression, archive path. It reads the archive’s listing only, no decompression, unless you ask for--hex.debug:export:archive:filesextracts every matching entry under<dir>, mirroring the archive’s folders.
--file-glob matches the archive-internal path; / in the glob matches the \ the BSA stores.
Output
The dump prints <size> <compressed|raw> <path>, with the archive name before the path under
--load-order. size is the stored size (BsaFileRecord.ActualSize). compressed is the
archive’s default (flag 0x4) inverted by the record’s bit 30, see
BSA archive format. With --hex, each line is
followed by a 16-bytes-per-line dump (Pipelines/Debug/HexDump.cs) of the first --bytes bytes.
1456 raw interface\fontconfig.txt
00000000 66 6F 6E 74 6C 69 62 20 22 49 6E 74 65 72 66 61 |fontlib "Interfa|
00000010 63 65 5C 66 6F 6E 74 73 5F 63 6F 6E 73 6F 6C 65 |ce\fonts_console|
... 1424 more byte(s)
Both commands log the archive summary first, see Shared behavior.
debug:*:archive:strings-tables
debug:dump:archive:strings-tables <bsa-archive|data-directory> [--load-order se|ae|custom [--load-order-plugins <names|file>] [--load-order-archives <names|file>]] [--file-glob <glob>] [--id <hex-id>]... [--search <text>] [--list]
debug:export:archive:strings-tables <bsa-archive|data-directory> [--load-order se|ae|custom [--load-order-plugins <names|file>] [--load-order-archives <names|file>]] --output-directory <dir> [--clean] [--file-glob <glob>]
Decodes the .strings, .dlstrings and .ilstrings entries of a BSA, or of every archive of a
load order, into readable text. Entries that aren’t string tables are skipped, whatever
--file-glob matched.
debug:dump:archive:strings-tablesprints the decoded tables.--idand--searchfind one string without reading 30,000; a table with no match is left out.--listlists the tables without decoding them.debug:export:archive:strings-tableswrites one.txtper table,.txtappended to the original extension (skyrim_english.dlstrings.txt).
Output
The dump and the export share one layout (Game/Bsa/StringTableTextWriter.cs):
# Skyrim String Table
# Source: strings\skyrim_english.strings
# Entries: 2
[0000EE7A]
The Lusty Argonian Maid, v1
[00010C4F]
The Lusty Argonian Maid, v2
# Entries counts the strings printed, after --id and --search. A table with strings that
aren’t valid UTF-8 is a warning, see Localization. The table format
is in BSA archive format.
debug:*:archive:terrain-lod
debug:dump:archive:terrain-lod <data-directory> <worldspace> [--level <4|8|16|32>] [--no-normal-maps] [--missing-only] [--load-order se|ae|custom [--load-order-plugins <names|file>] [--load-order-archives <names|file>]]
debug:export:archive:terrain-lod <data-directory> <worldspace> --output-directory <dir> [--clean] [--level <4|8|16|32>] [--no-normal-maps] [--load-order se|ae|custom [--load-order-plugins <names|file>] [--load-order-archives <names|file>]]
Lists or extracts the terrain LOD tiles of one worldspace, the raw tiles that
export:worldspace-maps:lod stitches.
debug:dump:archive:terrain-lodprints each expected tile and the archive it resolves to, orloosefor a loose file.debug:export:archive:terrain-lodextracts the tiles as.ddsfiles.
Unlike the other archive commands, these don’t glob the archives. They derive the tiles a
worldspace needs from its records and its LOD settings, then look each one up. They always read a
load order, se by default.
Pipeline
- Read every plugin’s
WRLDandCELLrecords and the cells holding aLAND(Datasets/Worldspaces/WorldspaceMapQuery.cs), merged over the load order, and keep the exterior cells with aLANDunder<worldspace>, matched by EditorID. A DLC adding cells to a vanilla worldspace counts. ALAND’s own subrecords are never read. - Read
lodsettings\<worldspace>.lod, see LOD settings. Without it, or when it doesn’t generate--level, the command stops with an error. - Group the cells into tiles at
--level(Game/Assets/TerrainLod/TerrainLodGrid.ToTileCoordinates), stepping from the settings’ south-west cell. - Build each tile’s path,
textures\terrain\<worldspace>\<worldspace>.<level>.<x>.<y>.dds, and unless--no-normal-mapsits_n.dds, and resolve it in the archive file system (Pipelines/Debug/TerrainLodTileFinder.cs). - Print or extract each tile. A tile no archive provides is printed
MISSINGby the dump and logged as a warning by the export, not an error: a mod’s landscape needn’t ship every tile.
The naming convention and the grid origin are not in the UESP spec, see assumptions.
Output
133 Skyrim - Textures7.bsa textures\terrain\tamriel\tamriel.32.-64.-64.dds
79071 Skyrim - Textures7.bsa textures\terrain\tamriel\tamriel.32.-64.-32.dds
Both commands first log the landscape cell count, the tile count and the expected file count.
debug:dump:plugin:book
debug:dump:plugin:book <plugin-file|data-directory> [--load-order se|ae|custom [--load-order-plugins <names|file>] [--load-order-archives <names|file>]] [--language <lang>] [--form-id <form-id>]... [--editor-id <text>] [--no-text]
Runs the BOOK pipeline (read, localize, merge, see
Load order and merging) for one language, on one plugin or on a
load order, and prints the result. Use it to see what the merge decided, including which plugin
last set each field. --form-id takes a GlobalFormId, such as skyrim.esm:0B7736.
Output
=== Load Order ===
Skyrim.esm
...
=== BOOKS (1042) ===
[skyrim.esm:10BEDF] NN01SinderionsTome (from Update.esm)
Title: The Nirnroot Missive (from Update.esm)
Data: type BookOrTome, flags None, weight 1 (from Update.esm)
Keywords: skyrim.esm:0937A2 (from Update.esm)
Text: ... (from Update.esm)
Each book is keyed by its GlobalFormId. (from <plugin>) names the plugin that last set that
field (MergedBook.*Source), not the plugin that defines the book: above, the book is owned by
skyrim.esm and Update.esm overrides every field. BOOKS (N) counts the books printed, after
the filters.
The Data, Teaches, Description and Keywords lines appear only when the book has that data.
Teaches shows the skill’s actor value name or the spell’s FormId. A Description with string id
0 is left out.
Without the plugin’s string tables in the archives, unresolved text shows as
(localized, (XXXXXXXX)). Dropped records and fields left out are counted in one warning each,
see data problems.
debug:dump:plugin:vmad
debug:dump:plugin:vmad <plugin-file|data-directory> [--load-order se|ae|custom [--load-order-plugins <names|file>] [--load-order-archives <names|file>]] [--record-type <type>]... [--form-id <hex-form-id>]... [--script <name>]
Scans a plugin, or each plugin of a load order in turn, for VMAD subrecords (the Papyrus scripts
attached to a record) and decodes every one it finds, with the record it came from. No merge, no
.pex decompilation: a raw dump of each file. The layout is in
Plugin file format.
It scans WRLD, CELL, REFR/ACHR, LAND, CONT, LVLI, NPC_ and FACT, deleted records
skipped, then BOOK, deleted ones included (Datasets/Scripts/VmadQuery.cs). --form-id takes the
FormId as stored in the file, master index included, which is what the output prints: not a
GlobalFormId.
Output
=== CONT FormId=0x000A918C (VMAD version=5, objectFormat=2) ===
script: critterspawn [status=0]
fMaxPlayerDistance (Float) [status=1] = 4000
CritterTypes (Object) [status=1] = FormId=0x000A914D, Alias=65535
iMaxCritterCount (Int32) [status=1] = 4
=== REFR FormId=0x000C5840 (cell=0x00027D1C, interior=True) (VMAD version=5, objectFormat=2) ===
script: dunKilkreathBeamStart [status=0]
beamTarget (Object) [status=1] = FormId=0x000C583E, Alias=65535
Under --load-order, each header starts with the plugin, since a file-local FormId is ambiguous
across plugins.
| Value | Meaning |
|---|---|
Alias=65535 | Not alias-bound: a plain FormId reference. Any other value is a quest alias index |
Script [status] | 0 local, 1 inherited and altered, 3 inherited and removed |
Property [status] | 1 edited, 3 removed |
status exists from VMAD version 4; on older data the field is absent, not 0. A VMAD that
fails to decode is skipped and counted in one warning per plugin.
debug:dump:plugin:worldspaces
debug:dump:plugin:worldspaces <plugin-file|data-directory> [--load-order se|ae|custom [--load-order-plugins <names|file>] [--load-order-archives <names|file>]] [--language <lang>] [--worldspace <editor-id|form-id>]
Prints every WRLD record of one plugin, or of a load order merged across plugins. --worldspace
takes an EditorID or a GlobalFormId; the Parent line still names a parent it left out. Without
the plugin’s string tables, names print as (localized, 0xXXXXXXXX).
Pipeline: Datasets/Worldspaces/WorldspaceQuery.cs reads each plugin’s WRLD records and the headers
of the exterior CELLs under them. Datasets/Worldspaces/WorldspaceLocalizationResolver.cs resolves FULL
per plugin. Datasets/Worldspaces/WorldspaceMerger.cs merges them with the same field-level overwrite as
the other mergers (see Load order and merging).
Pipelines/Debug/WorldspaceTextFormatter.cs prints the result. See
plugin-file-format.md for the
subrecords read.
Output
Worldspaces are sorted by EditorID. A field the merged record doesn’t carry is omitted.
=== [skyrim.esm:00003C] Tamriel ===
Name: "Skyrim"
Plugins: Skyrim.esm -> Update.esm -> Dawnguard.esm -> HearthFires.esm -> Dragonborn.esm -> ccBGSSSE001-Fish.esm -> ccBGSSSE025-AdvDSGS.esm
Flags: none
Climate: skyrim.esm:000812
Water: skyrim.esm:000018
Music: skyrim.esm:01BA72
Default heights: land -27000, water -14000
Map: 0x0 px, NW cell (-30, 15), SE cell (40, -40)
Bounds: (-233472, -176128) to (253952, 208896)
Exterior cells: 11187
=== [skyrim.esm:01EE62] Blackreach ===
Name: "Blackreach"
Plugins: Skyrim.esm -> Update.esm -> Dawnguard.esm -> ccBGSSSE001-Fish.esm
Parent: skyrim.esm:00003C Tamriel
Inherits: MapData
Flags: SmallWorld, CantFastTravel, NoSky
...
| Line | Source |
|---|---|
| Header | GlobalFormId and EDID |
Name | FULL, resolved against the string tables |
Plugins | Every plugin carrying the record, in load order. The first one defines it |
Parent | WNAM, with the parent’s EditorID |
Inherits | PNAM: which parts come from the parent |
Flags | DATA |
Climate, Water, Location, Encounter zone, Music | CNAM, NAM2, XLCN, XEZN, ZNAM, as GlobalFormIds. Their EditorIDs aren’t looked up |
Center cell | WCTR |
Default heights | DNAM |
Map | MNAM: usable map size in pixels, NW and SE cell corners |
Map offset | ONAM: where its map markers fall on its parent’s map, see Child worldspaces |
Bounds | NAM0/NAM9 in world units |
Exterior cells | Distinct exterior CELL records under the worldspace, across the load order |
A WRLD or CELL whose FormId doesn’t resolve against its plugin’s masters is dropped with one
[WARN]. So is a referenced FormId (WNAM, CNAM, …) that doesn’t resolve: the field is left
out. --verbose lists them.
debug:dump:plugin:interior-collision-shapes
debug:dump:plugin:interior-collision-shapes <plugin-file|data-directory> [--load-order se|ae|custom [--load-order-plugins <names|file>] [--load-order-archives <names|file>]] [--cell <editor-id|form-id>]
Surveys which Havok collision shapes placed interior objects carry, and where resolution stops for
the others. It measures what HavokShapeReader covers: run it again after changing the reader to
see the effect. Collision is searched depth-first from the root node, which must have the NiNode
layout. Supported shapes are in
NIF / Havok format. Without --cell it
scans every interior cell with a placed object.
Output
Three histograms, each row <label> <count> (<share of placed objects>), largest first. Shares are
of placed references; each base object is still resolved once.
| Histogram | Counts |
|---|---|
| Root NIF block types | The root block of each object’s model |
| Havok collision shape types | The shape block reached through collision object and rigid body |
| Resolution outcome | The step where resolution stopped, below |
| Outcome | Meaning |
|---|---|
NoModelPath | The base object has no MODL |
MeshNotFound | The model isn’t in any archive |
NifParseFailed | The NIF doesn’t parse, or has no blocks |
UnsupportedRootNodeType | The root isn’t a NiNode-layout block |
NoCollisionNode | No node carries a collision object |
UnsupportedCollisionObject | Not a bhkCollisionObject with a bhkRigidBody(T) |
UnresolvedShapeType | A shape was reached but isn’t supported |
Resolved | A precise footprint |
On vanilla Special Edition, most of what doesn’t resolve is NoCollisionNode and NoModelPath,
not a missing shape type.
Pipelines/Interiors/InteriorCellFinder.FindAllInteriors lists the cells,
Pipelines/Interiors/InteriorCollisionShapeStatsCollector.cs classifies each object.
BookAtlas.Generator: the static site generator
generate:site <export-directory> --output-directory <dir> [--clean] [--with-pdf] [--with-map <map-directory> [--map-cdn-url <url>]] [--base-url <url>]
generate:pdf <export-directory> --output-directory <dir> [--clean]
BookAtlas.Generator turns what export:books writes into the static
Book Atlas site: a language picker, then one subsite per
language with an index and one page per book.
It references neither BookAtlas.Exporter nor CreationEngineFormats. It reads only the JSON
contracts, book export format and
map export format, with its own model types (Import/). Any export that
matches the contract works, and only a contract change can break the generator.
Input
The export directory holds export.json (the manifest, whose load order the about page shows),
textures/, and one localized/<language>/ folder per language with its index.json, one JSON
file per book and a fonts/ folder.
Command
dotnet run --project BookAtlas.Generator -- \
generate:site path/to/exported --output-directory ./site
--clean empties ./site first, so books dropped from the export leave no stale page. It is
refused when ./site holds the export or the map directory.
A language without index.json or a book file that doesn’t parse is skipped with a warning, and an
image not in textures/ shows as text. An index.json that doesn’t parse, or no language left, is
an error. A missing book field is not an error: the page shows “(none)” or “(no content)”. An index only
links pages that were written.
Site structure
<output-directory>/
index.html map link, then the language picker
about.html options and load order of each export, see About page
404.html page for unknown URLs, see Not found page
style.<hash>.css see Styling
robots.txt, sitemap.xml see Search engines
textures/ copy of the export's textures/
maps/ with --with-map, see Maps
index.html, embed.html, <tiles path>
<language-slug>/
index.html the books, sorted, with a search box
<owningPlugin>_<localId>_<editorId>.html one page per book
<owningPlugin>_<localId>_<editorId>.pdf with --with-pdf, see PDF export
fonts/ copy of the language's fonts/
A language’s slug is its localized/ folder name. A book’s file name comes from its FormId, with
the EditorID as a readable suffix, never from its title, so a title fix never changes a URL
(Rendering/BookFileNaming.cs). Each part goes through an allowlist (letters, digits, ., _,
-; unknown when nothing is left), and a numeric suffix settles a collision, which a valid export
never has.
Language index
Books are sorted by title as written, <Alias=Home> placeholders included
(Rendering/TitleSortKey.cs):
- numbers by value: “9e sermon” before “10e sermon”;
- case and the accents of the game’s Latin-script languages ignored: É with E, Œ as OE;
- kanji by code point: the export has no reading for them;
- equal titles by file name.
The search box filters by title or GlobalFormId (skyrim.esm:0B7736, or part of it), ignoring case
and accents. Under it, a folded Advanced search has one dropdown of checkboxes per filter:
Plugin (the book’s owning plugin), Type (book or note) and Teaches (skill or spell). Values
checked in one dropdown add up, dropdowns narrow each other, and the count shows how many books
match. A filter shows only when it splits the list, a book without a value being a part of its own:
the vanilla game types every book as a book, so Type shows only with a mod that adds notes. Both
need JavaScript and are hidden without it.
About page
about.html shows the options and the load order of each export, from the optional meta and
the loadOrder (see Export meta): first the book export’s,
from export.json, then each map’s, from its manifest, folded under its EditorID, GlobalFormId and name. A map’s options
and load order are its own and can differ from the books’. The plugins and archives are folded under
their count; without meta, there are no options. Every site page links about.html from its
footer, the PDF excepted.
Not found page
404.html is the page a static host serves for an unknown URL. It links the stylesheet, the language
picker and about.html. Without --base-url those links are relative, so they resolve only when the
404 is served from the site’s root. With --base-url, they are absolute. The page is left out of
sitemap.xml and carries noindex.
Search engines
robots.txt allows every crawler. --base-url https://example.com/books/ also writes a
sitemap.xml (sitemaps.org), points robots.txt at it, and gives the
pages the absolute URLs that search engines and link previews need.
| Item | Behavior |
|---|---|
| Base URL | Absolute http or https, no query or fragment; a trailing / is added. Anything else fails before writing |
| URLs listed | Root index, about.html, language indexes, book pages, PDFs written, maps/index.html. Not textures nor maps/embed.html |
<lastmod> | None: the export has no date per book |
| Over 50,000 URLs | sitemap.xml becomes an index over sitemap-1.xml, sitemap-2.xml, … |
| Canonical | Every listed page except PDFs, as <link rel="canonical"> and og:url, the same URL as the sitemap’s. maps/embed.html is noindex and has none |
| Preview image | A book page’s og:image is its inventory image, when it has one |
| Languages | A book page in several languages lists each as <link rel="alternate" hreflang>, itself included. A language without a tag is left out |
Maps
--with-map <map-directory> adds maps/index.html, the worldspace maps in Leaflet, and
maps/embed.html, the map alone for the book pages. The map directory is what
export:worldspace-maps:lod or raster-records write, or an index you write by hand to combine
several runs. Import/MapCatalog.cs applies the format’s consumer rules.
The navigation bar of the root index, about.html, the language indexes and the book pages links
maps/index.html on its right.
maps.json and the manifests are read before any book; the tiles are copied after the books, to the
same relative path under maps/. A map with levels gets the
tiles of each level it keeps copied the same way, and the page data lists each level with its label,
altitude and tile URL (under --map-cdn-url when given).
A map or a level the consumer rules drop is counted in one warning, each reason at --verbose. A
missing maps.json, or no map kept, is an error; the books are still written.
The page’s left column has a Search tab (the worldspaces, each child under its parent) and a
Metadata tab (the current map: identity, flags, size, render, then folded its children, the
plugins that carry the worldspace, its levels and the markers). The map’s load order and export
options are on the About page. The levels list the map’s own tiles as level 0, top,
then each level in index order with its tiles and altitude. You resize the column by dragging its
border or with the arrow keys on it; the browser keeps the width. In a narrow window the column
sits above the map and its list shows about seven worldspaces, the rest under a scrollbar.
Without JavaScript the column splits in half, the worldspaces above the metadata of every map, and a note takes the map’s place. A worldspace link then leaves that map’s metadata alone.
Both pages take the view from the URL:
| Parameter | Meaning | Missing or invalid |
|---|---|---|
worldspace | EditorID, case-insensitive | Tamriel when listed, else the first map |
x, y | Center in game units | Whole map fitted |
zoom | Leaflet zoom, clamped to minZoom..maxZoom + 3 | Whole map fitted |
z | Altitude in game units: the level of the lowest stop at or above it, the top above every stop. Only for a map with levels | Top of the slider |
Game units keep a link valid after a re-export at another resolution. Moving updates the URL; switching worldspace adds a history entry.
A map with levels shows an altitude slider on both pages, one stop per level, top for the map’s
own tiles. Every level is a hidden tile layer added when the map opens: switching level changes
opacities and loads nothing, so a map with many levels costs more requests on first view. Markers
outside their levels are dimmed, and a disabled one is drawn fainter. Each
group of markers is a layer of its own, off at first when its defaultVisible is false. A level
without an altitude is left out of the slider; a map with none left has no slider and no z.
A book location in a mapped worldspace gets a folded Map: maps/embed.html in a lazy iframe,
centered on it two levels under the map’s maxZoom (Rendering/Maps/MapLinks.cs), and a link to
the full page. Interiors and unmapped worldspaces get none.
The libraries are pinned CDN URLs with a sha384 integrity hash (Rendering/Maps/MapLibraries.cs):
Leaflet, Leaflet-MiniMap, and pmtiles when a map is an archive. To update one, change its URL and
its hash:
curl -fsSL <url> | openssl dgst -sha384 -binary | base64 -w0
A .pmtiles archive needs a server that answers Range requests. The dev shell’s serve runs Caddy
with Range requests and CORS: nix develop --command serve ./site 8080.
Tiles served elsewhere
A full-resolution map directory weighs hundreds of gigabytes. When its tiles are already served,
--map-cdn-url https://cdn.example.com/maps/ copies none: the pages load
<url><tiles path>. --with-map is still needed for maps.json and the manifests, and each map’s
tiles must still exist on disk. The URL follows the same rules as the sitemap’s base URL. For a
.pmtiles archive the server must answer Range requests and send Access-Control-Allow-Origin. To
try it locally, serve path/to/maps 8081 and pass --map-cdn-url http://127.0.0.1:8081/.
Book page contents
A book page has a header, then three tabs: Metadata, Content (selected first) and
Locations (N). The URL hash #metadata, #content or #locations opens a tab, and follows
the one you pick, so a link can point at a book’s locations. Without JavaScript there are no tabs
and the three panels follow each other.
The page is in English; the book’s own text, its title and content, carries the language of its
localized/ folder as lang (ExportLanguage.LanguageTag: french is fr, chinese is
zh-Hant, an unknown folder gets none). A placeholder note is the site’s English and gets none. The
language index marks its list of titles the same way, and the PDF its title and content.
Header
A link back to the language index, the title, then one summary line: the FormId, type, value and
weight, “title set by X” or “text set by X” when another plugin changed the title or the text, and
a PDF link when the site has the book’s PDF. The title falls back to the EditorID, then the
FormId, then a placeholder (Rendering/BookDisplayTitle.cs).
An “Also in” line links the same book in every other language whose index.json lists its FormId,
with hreflang. A book’s page has the same file name in every language, so the link is
../<language>/<same file name> (Rendering/BookLanguages.cs). It would only lead nowhere if the
book’s file failed to load in that language, which the run reports as a [WARN].
Metadata
Every scalar field of the export: FormId, owning plugin, local FormId, EditorID, inventory image, menu art, value, type, weight, “can be taken”, what the book teaches (skill or spell, its localized name first), inventory description and keywords. An absent field reads “(none)”.
A field shows the plugin that set it (its *Source field, see
Book export format) only when that plugin isn’t the book’s owning
plugin, compared without case. On an unmodded game most books show none: a “set by X” note means a
DLC or a mod changed the book (BookPageFields.OverridingSource).
Three folded sections follow. An empty one keeps its place, grayed and inert.
| Section | Content |
|---|---|
| Leveled lists (N) | Every LVLI that can produce the book. A direct entry shows its level and count; a list reached only through a nested LVLI shows none |
| Scripts (N) | One fold per attached script, listing its properties: name, type and value. An object property shows its FormId and its alias |
| Menu art images (N) | The textures of the book’s menu art object, each a thumbnail you click to zoom, no JavaScript. “Own artwork” marks the one named after the object |
Content
The book’s text, rendered as described in Bethesda markup handling. A book
whose text is a placeholder (contentIsPlaceholder: the real text is baked into its menu art) shows
the placeholder sentence in the site’s font, then a folded gallery of the menu art images. A book
with real text shows its images only in the Metadata tab: a picture doesn’t belong in the middle of
its prose.
Locations
The locations are grouped by source, in this order: Direct, Vendor, Container, NPC. A book sold by dozens of vendors would otherwise bury its few real placements. Each group starts folded, its summary giving its count. The list is never cut, even for a book placed thousands of times. A book with none shows “No known location.”
Each location is one line, for example Container: QABooksContainer — QASmoke · (2048, 2368, 6976):
- The source’s own EditorID (the container or the NPC), then the cell’s EditorID, or the worldspace’s when there is no cell.
- The grid
(grid X,Y)for an exterior cell; its absence means an interior. - The position in game units.
- A Persistent or Scripted badge, only when true.
- The console commands to go there.
player.movetoalone can drop you somewhere wrong when the target cell isn’t loaded, so acocorcowcommand comes first when the cell or worldspace is known, joined by;so the console runs both from one paste (TemplateFunctions.ConsoleTeleportCommands). - With the site’s map, a folded Map of the location, see Maps.
The PDF of a book keeps only the content, then the title and the metadata fields on a page of their own. See PDF export.
Bethesda markup handling
A book’s content is Bethesda’s HTML-like markup (see
book markup assets):
<font face='$HandwrittenFont'><font size='40'><p align='center'>
Conjure Dremora Lord
<img src='img://Textures/Interface/Books/Alchemy Ingredients/dragonfly.png'>
BookContentSanitizer.RenderParagraphsHtml interprets a small set of tags and shows every other
tag as text. It is a single forward scan, no regex (see Performance); tag
matching, attributes and the <img>/<font> rendering live in Rendering/Markup/. Every other
value on a page (title, EditorIDs, cell names) is only HTML-encoded (EscapePlainText): its markup,
such as <Alias=Home>, shows as text.
Interpreted tags
| Markup | Output | Notes |
|---|---|---|
<p align>, <div align> | <p style="text-align: ..."> | One paragraph: blank lines inside become <br />. align is checked against left, right, center, justify, else left. Vanilla journals use <div align> the same way and never close it |
[pagebreak], <pagebreak> | <hr class="pagebreak"> | Both spellings exist in vanilla data |
<HR> | <hr> | A different construct, seen around an embedded poem |
<b>, <i>, <u> | the same tag | Inline: never starts a paragraph |
<br>, <BR>, <br/> | <br /> | |
<img src> | <img> from the site’s textures/ | Only when the reference resolves (TextureAssets, same normalization as the exporter’s TextureSource, duplicated on purpose). width and height carry over, see Book page geometry. The alt is empty, except for a vanilla illuminated letter (X_letter.png or the Lost Library mod’s X_letter_LL.png, in a folder named Illuminated_Letters): its capital letter, which the book page’s meta description also reads |
<font face size alpha> | <span style> | face through the language’s fonts (FontAssets) into font-family; size as px in the book’s stage pixels; alpha (#XX) as opacity. Any one attribute is enough |
Anything else stays in the text, HTML-encoded, where it was: an unresolved <img> or <font face>,
the game’s runtime placeholders (<Alias=...>, <Global=...>), unfilled dev placeholders
(<Cool graphic>), localizers’ “untranslatable” markers, typos (<align='left'>, <imgsrc=...>).
The reader sees the real markup instead of a guess or a gap.
Rules
- Paragraphs. Text outside
<p>splits into paragraphs on a blank line; a single line break becomes<br />. The blank line is found during the scan, not by splitting afterwards, so a tag open across it is never cut into an unclosed half and an orphan close. - Unclosed tags. An unclosed or reopened
<p align>is closed.<b>,<i>and<u>are also closed at every paragraph boundary (</p>, page break, blank line): vanilla books leave an<i>open, or reopen it by typo, and it must not leak. A stray closing tag shows as text. <font>crosses boundaries. A still-open font span is closed and reopened across a new<p>, a page break or a blank line. Vanilla titles put<font size='40'>right before a new<p align>, and letters never close their<font face>: the tag is meant for what follows (InlineStyleStack).- Missing
=. Every vanilla spell tome writesface'$HandwrittenFont'(a Creation Kit bug, e.g.skyrim.esm:10F7F4).AttributeScannerreads a quote right after an attribute name as if the=were there. - Face names. A face resolves only on an exact fontconfig name.
$CClub_Fontdoesn’t match its embedded font’s name (see Font export), so it shows as text.
Default face
Book text without a <font face> uses $SkyrimBooks in-game. BookPageWriter sets it on the
content block (FontAssets.DefaultContentFamily), falling back to a font named
SkyrimBooks_Gaelic when the fontconfig name doesn’t resolve, and to the stylesheet’s serif when the
language has neither. An explicit <font face> inside overrides it.
Images and fonts on disk
generate:site copies the export’s textures/ once and each language’s fonts/ into its subsite;
TextureAssets and FontAssets resolve against what was really copied. A book page carries its
language’s @font-face rules inline. A book’s inventoryImage resolves the same way and shows as a
thumbnail next to its field.
Templating
Pages are rendered with Scriban. The .sbn files in
Templates/ hold the HTML; a page writer (BookPageWriter, IndexPageWriter,
LanguageIndexPageWriter, MapPageWriter) builds a plain ScriptObject model (strings, numbers,
lists, no project types) and calls TemplateEngine.Render(template, model). Templates, scripts and
the stylesheet are embedded resources: the published binary has no file to deploy beside it.
Escaping
Scriban doesn’t escape its output. Every value goes through one of the functions of
TemplateFunctions, registered by TemplateEngine.CreateFunctions:
| Function | Use |
|---|---|
escape | Any text: HTML-encoded, markup shown as text |
field_value | A metadata value: escape, or “(none)” when blank |
format_source, place_label, grid_suffix, position | The parts of a location line |
capitalize | A language’s display name |
An attribute value built in C# uses WebUtility.HtmlEncode (the map menu’s data-worldspace, the
book index’s data-search).
Some HTML is built in C# and passed to a template as is: the book content
(BookContentSanitizer.RenderParagraphsHtml, which needs the texture and font resolvers), the
locations, leveled lists, scripts and menu art (*HtmlBuilder, see Performance),
and the map menu, a tree of any depth.
layout.sbn wraps every page. HtmlPage.Wrap takes optional <head> content and a <body> class;
the map pages use them for their libraries and full-window layout.
Templates are parsed once and cached in a ConcurrentDictionary: books render in parallel, and a
parsed Template is safe to share as long as each render has its own TemplateContext.
LoopLimit is unbounded, since a book can have thousands of locations.
Scripts
The scripts are embedded .js files, read by TemplateEngine.Resource and inlined in <script>
elements. Each page includes the shared ones before its own:
| Script | Used by | Role |
|---|---|---|
search.js | Book index, map page | bindSearch: hides the items whose data-search doesn’t match, ignoring case and accents, or that fail an extra test (the index’s filters) |
tabs.js | Book page, map page | bindTabs: shows the panel of the selected tab; a tab with a data-hash also follows the URL hash |
map_view.js | Map page, embed page | mapView: the Leaflet map, its overlays and the URL |
map_index.js | Map page | The menu around the map: links, search, tabs, resizing |
Map data reaches the scripts as a maps-data JSON block, written with System.Text.Json’s default
encoder, which escapes <, > and &.
Native AOT
Register each function as a delegate with ScriptObject.Import(name, delegate). Scriban finds the
static methods of a ScriptObject subclass by reflection only, so Native AOT trims them and the
published binary fails on the first template (“The function escape was not found”) while the JIT
build and the tests pass. A delegate references its method, so the trimmer keeps it.
Import still calls the method by reflection; its IL2026 warning is suppressed on
CreateFunctions. After a Scriban upgrade, run the published binary: the tests run under JIT and
can’t catch this.
Styling
The site has one stylesheet, Assets/style.css. It is embedded in the generator, written once per
run to <output-directory>/style.<hash>.css and linked from every page, so a browser caches it once.
The name holds a hash of the content: an update gets a new name, and the browser fetches it without a
full refresh. A book page adds an inline <style> with its language’s @font-face rules, the one part that differs
per language. The PDF has its own Assets/pdf.css, which imports this one; see
PDF export.
Guidelines
- Plain. No CSS framework, no theme, no external stylesheet or font. Pages keep a centered reading column; only the map pages use the full window.
- Light and dark for free.
color-scheme: light darkand colors relative to the text (opacity,rgba,color-mix) rather than fixed values, so no rule needs a dark-mode override. The parchment is the one fixed palette. - Hierarchy by weight and gray, not boxes. Secondary information (FormIds, sources, counts, empty values) is smaller or grayed. Avoid boxed panels and heavy rules; a thin light rule is enough to separate blocks.
- Show, don’t hide. An absent value reads “(none)”, grayed; an empty section keeps its shape, grayed and inert. The reader sees that the field exists and is empty.
- Semantic HTML, no tables. Label/value pairs are a
<dl>laid out as a grid, lists are lists, foldable parts are<details>. - Works without JavaScript. A script adds
jsto<body>; anything that needs it (tabs, search boxes) is shown only then. Without it, the panels a tab would switch between follow each other. - Native controls. Buttons, links and
<details>, so the keyboard works the browser’s way: Tab moves the focus, Enter or Space acts. No custom key handling. - Narrow windows. Every page sets a
viewportmeta. Below36rema reading page gives its text the width (a list row stacks, the parchment’s padding shrinks); below48remthe map’s menu folds above the map. A line of short items wraps between items, never inside one. - Motion. Honor
prefers-reduced-motion. - The book is the game’s, the rest is the site’s. Book content keeps the game’s fonts and proportions (below). Text the game never showed, such as a placeholder note about missing content or a menu-art gallery, uses the site’s UI font so it doesn’t pass for book text.
- No rule depends on the text of a book.
Book page geometry
The book content is not a 1:1 copy of the in-game page: it fills the site’s column and uses a web
reading line height. What it keeps from the game is the size of images and markup fonts relative
to the body text. The page is laid out in the book menu’s Flash stage pixels, with the game’s
22 px body text, then scaled down to screen with CSS zoom. Authored <img width height> and
<font size> values are in that same unit, so they keep their in-game proportion to the text.
| Property | Value | Source |
|---|---|---|
| Font size | 22 px | book.swf PageTextField font height, written size="22" in its htmlText |
Unsized <img> | 64 × 64 px, stretched | Measured in-game |
Sized <img> | Its width × height | The tag’s own attributes, see below |
| Screen scale | zoom: 0.75 | Body text at about 16.5 CSS px |
| Width, line height, spacing | Site column, 1.6, 1.1em between paragraphs | Web reading, not the game’s 296 px page |
PageTextField is the one DefineEditText (HTML, word wrap, multiline) in interface/book.swf
from Skyrim - Interface.bsa; the book menu places it once per page.
Images are inline, on the text baseline, the way Scaleform lays out an <img> in a book text
field: the text after an image starts at the image’s bottom line, and the next line starts below
the image. No float and no wrap around it. In the QA book (skyrim.esm:0B7736), an illuminated
letter followed by “mage within text.” renders that way in-game, with or without the surrounding
<p>.
An <img> without width and height is drawn in-game into a fixed box, not at the texture’s
own size: the QA book’s dbhand.png (512 × 512) and I_letter.png (132 × 197) both measure about
64 × 62 stage px in a 1080p screenshot, the letter visibly squashed out of its portrait shape. The
64 is measured, not read from a file: if a drop cap or an unsized picture looks off against the
game, check this value first.
Rendering/Markup/ImageTagRenderer.TryRenderImage carries a tag’s own width/height through
onto the rendered <img> when both are present and each parses as a positive integer. That size,
not the PNG’s pixel size, is what the book shows: the Dark Brotherhood hand-print is a 512 × 512
PNG, shown at 230×230 in one book and 300×300 in another; a puzzle illustration is a
1300 × 1200 PNG shown at 296×278, the full width of the in-game page. An image wider than the
column shrinks to it and keeps its aspect ratio.
Line breaks and page breaks don’t follow the game: the column is wider than the 296 px in-game
page, and [pagebreak] shows as a rule instead of starting a new page. Site text inside the book
area (a placeholder note, a menu-art gallery) cancels the zoom to stay at the site’s UI size.
Map pages
The map page (maps/index.html, see Maps) uses the full window: the worldspace
menu on the left, scrolling on its own, the map on the right. The page itself never scrolls. The
iframe page (maps/embed.html) is the map alone.
Leaflet-MiniMap lays its control out at full size before folding it, with a CSS transition, so a
minimap that starts folded would visibly shrink as the page opens. map_view.js turns the
transition off while it adds the minimap; the fold button still animates.
PDF export
generate:pdf <export-directory> --output-directory <dir> [--clean] [--browser <path>] [--pdf-jobs <n>]
generate:site <export-directory> --output-directory <dir> [--clean] --with-pdf [--browser <path>] [--pdf-jobs <n>]
Each book prints to one A4 PDF that looks like its site page: same stylesheet, same fonts, same parchment content block. You get the PDFs two ways:
| Command | Output |
|---|---|
generate:pdf | <dir>/<language-slug>/<book>.pdf only, no HTML |
generate:site --with-pdf | The site, plus <book>.pdf next to each <book>.html, linked from a PDF link at the end of the line under the book’s title |
A PDF has the same file name as the book’s page, with .pdf in place of .html
(BookFileNaming.GetPdfFileName), so both commands name a book’s PDF the same way.
Requirements
Printing needs Firefox. The generator looks for firefox, then firefox-esr, on PATH, or uses
--browser <path>. The flake’s dev shell provides firefox. Without it, the command logs an
[ERROR] and writes nothing: generate:site --with-pdf doesn’t fall back to a site without PDFs.
What a PDF contains
The printable page (BookPageWriter.RenderPrintable) has its own template, book_pdf.sbn, and its
own stylesheet, Assets/pdf.css, which imports the site’s style.css for the book typography. It
holds three parts:
- The cover. The title alone, centered on the first sheet, on the parchment and in the book’s default face, the same as the content. A language without a default face falls back to Georgia.
- The content, full page. The book’s text alone, without title, heading or site layout, on
parchment that covers the whole A4 sheet. The page has no margin (
@page { margin: 0 }): the parchment is the root element’s background, fixed so every page gets the whole gradient, and the text margin is the.contentblock’s padding, repeated on every page bybox-decoration-break: clone. A placeholder book’s referenced artwork prints open below its note. - The metadata, on a page of its own. The title, then one plain
label: valueline per field (the same fields as the site’s Metadata tab, see Book page contents), then the number of locations, leveled lists and scripts. No location details, no “set by X” sources, no images, in a system font on a white page. The site’s copyright footer, without its link to the about page, sits at the bottom of this page: the page is a flex column of at least one A4 sheet, and the footer is part of it rather than of the page shell, so it never spills onto a parchment page of its own.
Nothing in pdf.css applies to the site, and printing a site page from your browser uses the
browser’s defaults.
Limitations:
- No page numbers or running footer. WebDriver BiDi’s print command has no header or footer
option, Firefox’s own footer preferences don’t apply to it, and Firefox doesn’t support
@pagemargin boxes (@bottom-right { content: counter(page) }). - The PDF is not tagged and has no outline.
- With Firefox, a page’s background stops at the
@pagemargin, which is why the text margin is a padding rather than a page margin.
How it works
| Type | Role |
|---|---|
Rendering/Pdf/FirefoxProcess | Starts headless Firefox with a temporary profile and reads its WebDriver BiDi endpoint from stderr |
Rendering/Pdf/BidiConnection | WebDriver BiDi client over one WebSocket |
Rendering/Pdf/PdfPrinter | A pool of --pdf-jobs tabs; navigates, waits for images and fonts, prints |
Rendering/Pdf/BookPdfWriter | Renders the printable page to a temporary HTML file, prints it (one retry on failure), deletes the file |
LanguagePdfGenerator | One language for generate:pdf |
LanguageSiteGenerator | One language for generate:site, calling BookPdfWriter before writing each page |
Both commands share ExportLanguage.Discover (the language folders and their output names),
BookBatch.ForEachAsync (reading a language’s books concurrently and naming them) and
BookPdfWriter. generate:site never calls generate:pdf.
The printable page is a temporary file, so its asset URLs are absolute file:// URLs:
| Asset | generate:pdf reads it from | generate:site --with-pdf reads it from |
|---|---|---|
| Textures | <export>/textures/ | <site>/textures/ |
| Fonts | <export>/localized/<language>/fonts/ | <site>/<language-slug>/fonts/ |
| Stylesheet | a copy in the temporary directory | a copy in the temporary directory |
TextureAssets.WithUrlPrefix and FontAssets.Build(fonts, urlPrefix) give these URLs; the site
page keeps its relative ones.
The communication with Firefox is written with ClientWebSocket and Utf8JsonWriter/
JsonDocument, without a WebDriver package, so it stays Native AOT safe.
Firefox profile
Each run uses a fresh temporary profile. Its user.js sets
security.fileuri.strict_origin_policy to false: by default Firefox only lets a file:// page
load fonts from its own directory, and the printable page loads them from the export or the site.
The other preferences there only skip first-run prompts, telemetry and updates.
Lazy images
The printable page drops the loading="lazy" attribute the site’s images carry: with it, the
English PDFs don’t finish within 20 minutes.
Placeholder books
A placeholder book’s note prints in the game’s own Arial, one of the web fonts every language
exports, rather than the site’s system font stack. Firefox prints a page set only in system fonts
many times slower, and the cost grows with the number of such pages printing at once: 8 copies of a
treasure map printed together take 46 s in system fonts and 5 s in Arial, and enough of them
printing at once hit the 120 s print timeout. The metadata page stays in system fonts, since
switching it doesn’t change the time.
Links
Firefox prints an <a href> as a clickable link annotation, with its default profile. It drops
the annotation when the link sits inside an element with opacity below 1: the site footer’s muted
look comes from opacity, so pdf.css resets it on the metadata page and greys the text with
color instead. Check a PDF’s links with qpdf --qdf --object-streams=disable in.pdf out.pdf,
then search out.pdf for /Subtype /Link.
Verbose output
With --verbose, each book logs its print time split into tab wait, load, images and fonts, and
print, and the run ends with the average per phase. The tab wait is how long a book queued for a free tab. When it dominates, the tabs are all busy
and --pdf-jobs limits the run. When the print phase dominates, Firefox is the bottleneck.
Performance
Measured with generate:site --with-pdf on the full export (9 languages × 1042 books), Native AOT
binary, 16-core machine, Firefox 156, --pdf-jobs 64:
| Measure | Value |
|---|---|
| Whole run, site and 9378 PDFs | 11 min 13 s |
One language, generate:pdf | about 70 s |
| PDFs, all languages | 1.35 GB, median 47 KB per book |
| Site size with PDFs | 1.8 GB |
Printing is latency-bound, not CPU-bound: the process uses about 7 minutes of CPU over the
11-minute run, and Firefox sits idle for part of each print. Many tabs in flight hide that
latency, which is why --pdf-jobs defaults to four tabs per processor. Throughput stops growing
past about 64 tabs on this machine, and running several Firefox processes instead of one tab pool
doesn’t raise it.
The largest PDFs are the books with images: a texture is embedded at its full resolution.
Performance
generate:site on the full export (9 languages × 1042 books, 9387 book files) takes ~4.3s with
dotnet run (JIT) on a 16-core machine, best of 5 runs. Most of the work is spread over every core:
the process uses ~38s of CPU time in that run. A published Native AOT binary skips JIT compilation,
which a one-shot batch CLI pays on every run; publish it for any real generation run (see
“Development” in the top-level README.md).
Parallelism
Each book is cheap: read its JSON file, render its page, write the HTML file. What matters is that
they overlap. LanguageSiteGenerator.GenerateAsync processes a language’s books concurrently with
Parallel.ForEachAsync; its doc comment explains how output order and the file name collision
suffixes stay deterministic. TemplateEngine’s template cache is a ConcurrentDictionary:
Scriban’s parsed Template is immutable and safe to render from several threads against separate
TemplateContexts, the cache holding it has to be too.
The degree of parallelism is Environment.ProcessorCount * 4. The workload mixes CPU work (JSON
deserialization, Scriban rendering) with small-file disk I/O, so running more tasks than cores lets
tasks blocked on I/O overlap with CPU-bound ones. On the 16-core machine, ProcessorCount alone
leaves cores idle, and ProcessorCount * 16 only adds scheduling overhead.
Hot paths
Each choice below was found by timing one language’s 1042 books phase by phase (Stopwatch
around each phase), not guessed.
- Locations are rendered in C#, not in Scriban. Scriban’s interpreter overhead, not the
formatting itself, dominates rendering. One language has 178,872 locations (~1.6 million across
all 9), and calling four custom functions per location through Scriban’s reflection-based
DynamicCustomFunctiondispatch costs ~2.4ms per book.Rendering/Pages/BookPage/LocationsHtmlBuilder.Buildbuilds the whole<ul class="locations">...</ul>fragment in a plain C# loop with the sameTemplateFunctionsmethods (same escaping, same output), ~0.18ms per book, andbook_page.sbninserts the string as is. - The book JSON files are read synchronously.
BookExportReader.ReadIndexAsync/ReadBookAsyncuseFile.ReadAllBytesandJsonSerializer.Deserialize. Driving aFileStreamnot opened withFileOptions.AsynchronousthroughJsonSerializer.DeserializeAsyncis “async over sync”: the thread-pool reads and extra state machines cost ~30× the synchronous read for the same files. The methods still return aTask: they run inside a boundedParallel.ForEachAsyncworker, where a short synchronous read blocks nothing else. - Book markup is scanned by hand.
BookContentSanitizer(book markup to HTML, see Bethesda markup handling) uses noSystem.Text.RegularExpressions: it walks the content in one forward scan withIndexOfandReadOnlySpan<char>. Every pattern it needs (the next</>pair, a tag name compared to a fixed word, one attribute’s value) is simple enough to scan directly, and regex engine overhead over every book of every language is a real cost.
PDF export
Printing PDFs dominates a generate:site --with-pdf run. Its figures and parallelism are on the
PDF export page.