Skip to main content
A mesh is a mesh asset document (its name, its detail level group and one material slot for each material), a MeshSet resource that describes its detail levels and sections, and one chunk for each detail level with the vertices and indices. The game has 11,619 meshes.

Three kinds

A composite mesh’s parts are like bones: each vertex belongs to exactly one part, and the object that owns the mesh moves the parts as the game runs. The mesh stores the parts where they sit at rest.

Sections

A detail level is cut into sections. Each section is one material on a run of triangles:
  • it names the material slot of the mesh asset it uses (a mesh has up to 22 slots) and the material’s key (materials);
  • it has its own vertices, with a layout of its own: position, then some of colour, texture coordinates, a tangent frame, light map coordinates and, for a skinned section, bones and weights;
  • it is in one or more of five draw lists: opaque, transparent, decal, depth only and shadow. Which of the first three follows from the material’s shader.
A section holds at most 65,535 vertices for 16-bit indices. A section of 65,536 vertices or more makes the whole detail level use 32-bit indices, which only 22 of the game’s detail levels do. Studio’s Blender add-on cuts a map’s meshes into sections below that limit. Positions are stored as half floats in most of the game’s sections, and as full floats in the rest. Studio writes the meshes of props and maps with full floats.

Shadow sections

Most of the game’s drawn sections are not in the shadow list. The game’s tools give each opaque material a second section, after all the drawn ones: a copy with positions only, named after the material with _Shadow, in the depth only and shadow lists. A cut-out material’s shadow copy keeps its texture coordinates too, so the holes cast holes. (A few sections are drawn and cast their own shadow, in both lists at once.)
  • A mesh with no section in the shadow list casts no shadow.
  • In the world, one shadow section usually serves every opaque material of a detail level, welded from all of them. Studio builds a prop’s and a map’s shadows that way.
  • A shadow section has its own material key, on the same parameter block as the material it shadows.

Detail levels

A mesh has 1 to 6 detail levels, most detailed first. The distances they switch at are not in the mesh. The mesh asset names a detail level group, and the group has six distances: the distance at which the game goes from one level to the next. A group is made for a number of levels. The distances it really uses rise, and the ones past the last level are 1000, 1001, 1002 as filler. A level the mesh does not have is never asked for. The group also holds a shadow distance and the screen size below which the mesh is not drawn at all. The last level of every mesh, and sometimes a run of levels before it, stays loaded at all times; the others stream in as you come near. A world mesh keeps its last one or two; clothing keeps all but the first. A prop of your own takes one to five distances, and Studio writes a group for it with exactly those.

Rigs and weights

A skinned mesh names no skeleton. Each vertex holds bone numbers, and the game poses them with the skeleton of whatever wears the mesh. A character’s skeleton has 386 bones.
  • A vertex is weighted to at most 8 bones. Up to 4, the game takes its four-bone path; 5 to 8 use a second set of bones and weights.
  • Weights are stored in 8 bits each and add up to 255, so a weight smaller than about 1/255 is lost.
  • Some clothing adds procedural bones of its own after the skeleton’s.
  • Some bones have a box around their vertices in the rest pose, which the game uses to keep the mesh’s bounds right as it moves. Studio keeps the item’s own choice of bones and works the boxes out from your vertices.
Clothing that swings or flaps does so through its mesh’s swing bones and cloth, which every item made from the same garment shares. Studio does not change them: see movement.

What a replacement must keep

When your model takes the place of a game item’s mesh: Your model decides its vertices and triangles, its UVs (a missing second UV set is the first one again), its normals and its weights. The item decides the materials, the skeleton and the flags.
A model that is the game’s own mesh exported and brought back unchanged is the game’s mesh, not yours. It does not make an item your own: see the rule on store items.

Making one in Studio

Bringing in, exporting and checking models: see models in Studio.