Crater and debris models

What a surface mark looks like, what flies off it and where the models come from. Read in PDUWP.exe and checked against Map/st03.alr / st03.dat / st00.alr / st00.dat (and the MD00 sections of the other versus stages). converter/craterconv.py exports everything named here to crater.json (+ the PNGs through pdconv --textures); test converter/tests/test_craterconv.py. The look was compared with the playtester’s Rebirth close-ups (private recording, 208–226 s): a hole sunk into the floor with a broken rim, some three character widths across.

System model table: where entries 24 and up come from (H)

The loader 0x1401d9210 fills the table (0x140530390, {model, animation}, at most 144 entries) in two passes with one running entry counter:

Pass Entries Source
0 0–23 the system stage st00: model k of st00.alr, animation record k of st00.dat (24 named rows in the table at 0x1403ee490)
1 24 + j pair j of the stage layout’s MD00 section

MD00 section (stNN.dat header word 0xA0, section 0x27; setup 0x1401d9180, getter 0x1401d85b0):

Part Layout
header magic MD00, u32 bytes of the model name list, u32 bytes of the animation name list, u32 pair count (80 on the versus stages, 16 on st09)
names the two lists of NUL-terminated names (not used at run time for the lookup)
pairs per entry: i32 model index into the stage ALR’s model offset table, i32 animation record index (−1 = none). A model index of 0 ends the list; −1 leaves the entry empty

The animation index counts records of the layout’s animation list (header word 0xF4, section 0x3C): one u32, then per record an i32 size and a run of 0x5 chunks, the same record form as st00.dat’s list (capsuleformconv.animation_records).

Entry use, with the Palace (st03) values:

Entries Use st03 model (animation record)
0x0E impact burst (st00) st00 model 14 (st00 record 14)
0x2C + k, k = 0..19 debris kind k 0x2C–0x33 → 76–83 (prop debris kinds 0–7); 0x3B (kind 15) → 84
0x40 + k, k = 0..3 mark kind k 85, 86, 87 (none)
0x45 impact smoke 88 (7)
0x4A + 3 k + facing fragments of mark kind k; facing 0 ceiling, 1 wall, 2 floor kind 0: none; kind 1: 89, 90, 91 (8, 9, 10)

Other stages follow the same plan (st02, st04, st12, st13, st23 like st03). Differences seen: st05 has marks only; st06 marks and smoke; st01 smoke only, no marks; st07 and st17 give their three marks an animation (records 3–5 / 2–4); st08 has further entries 0x54–0x67 (not followed); st09 has only 16 pairs. The material table yields kinds 0 and 1 only, so the third mark model (entry 0x42) is never used by the mark routine (M).

The mark model (H data, M draw)

On st03 the three mark kinds are three models with identical geometry: one mesh, vertex format 0x01 (24 bytes: position, packed normal, UV, colour), 445 vertices, a strip of 574 triangles, one material (shader handle sd, flags 9, blend word 0x1100) with its own texture. No joints beyond the root, no animation.

Debris manager (handle pdvkCrash, M code, H data)

Object 0x1405332e8 (0x2E00 bytes, constructor 0x140225020, vtable 0x14048ced8: init 0x14021cd90, update 0x14021ced0, draw 0x14021d0f0).

Offset Content
+0x50 60 requests × 0x90 bytes
+0x2210 next request index (a new request takes the first free slot from here, modulo 60)
+0x2218 20 kind model pointers (system entries 0x2C + kind)
+0x22C0 20 kind records × 0x90 bytes; +0x60..+0x8C = the kind’s twelve parameters

Init: for each kind with a model, copy the twelve floats at the start of the model’s first 0x13 chunk into the kind record and set flag 0x2000 on each of the model’s material entries.

Kind parameters (the 0x13 chunk’s twelve floats; also the request’s +0x60..+0x8C):

Float Meaning st03 kind 15
0, 1 spin rates about two axes, turns per frame, multiplied by each piece’s own spin pair 0.03, 0.03
2 frame (written each draw) 0
3 life in frames 90
4–6 launch velocity, units per frame (0, 1.5, 0)
7 spread: factor on each piece’s own velocity 1.0
8–10 gravity, units per frame² (0, −0.05, 0)
11 time scale 1.0

The prop debris kinds 0–7 of st03 use the same form (spin 0.02–0.1, life 90, launch 1.0 or 1.5 up, gravity −0.03 or −0.05).

Request (0x90 bytes): +0 position, +0x0C active, +0x10 kind, +0x14 loop count, +0x18 fade-start frame, +0x20 matrix, +0x60 the twelve parameters. 0x14021ca30 queues one with the caller’s parameters; 0x14021cb30 takes the kind’s parameters and only the directions of the caller’s launch and gravity vectors, rescaled to the kind’s lengths.

Update (per tick): frame += 1; when frame ≥ life − 1 the loop count drops by one and the request ends at 0, else frame restarts at 0. Draw: the request’s parameters are written into the model’s 0x13 chunk, the model is drawn with the request’s matrix and position. With a fade-start frame f ≠ 0 and frame > f: alpha = 1 − clamp((frame − f) / (life − 1 − f)) (through the colour word 0x14057f38c, M).

The mark’s request (in 0x14021d740): kind 15, loop count 1, fade start 50; matrix = a random turn about Y; launch direction = the surface normal (expressed in that turned frame, so the world launch is along the normal), gravity direction (0, −1, 0) with its length multiplied by 1 − 0.9 × clamp(−n.y, 0, 1) (0x1402f7cdc = 0.1: under a ceiling the pieces fall at a tenth of the gravity, since they are already launched downward). The 0.1 / 0.1 / 0 / 90 / 0.3 / 1.0 values the caller prepares are replaced by the kind’s. So: one burst of 200 pieces, 1.5 units per frame along the normal plus each piece’s own velocity, gravity 0.05 per frame², 90 ticks (3 s), fading out over ticks 50–89.

The model (st03 model 84). One material (shader handle scrash2, flags 9, blend word 0x1100, its own texture), one vertex buffer of format 0x1A (40 bytes), 600 vertices, drawn unindexed: 200 triangles, each a separate piece.

Offset Type Content
0 f32 × 3 corner, relative to the piece’s centre
12 u32 normal, signed 11:11:10
16 s16 × 2 UV / 4096
20 s16 × 2 spin pair, the same on a piece’s three corners (/ 32767, scale INFERRED)
24 f32 × 3 the piece’s centre in the model
36 u32 the piece’s own velocity, signed 11:11:10 (not unit: lengths 0.3–0.6)

The motion (vertex shader of that handle; its class: vtable RVA 0x490198, begin 0x1402a1a90, per draw 0x1402a1c80). Per draw the frame advances by one (wrapping at the life) and T = time scale × frame. Per vertex:

a1 = frac(spin.x * rate.x * T)        a2 = frac(spin.y * rate.y * T)      (turns)
p  = RotY(a2) * RotX(a1) * corner
   + centre + (velocity * spread + launch) * T + gravity * T^2            (no 1/2)

The angles are looked up in a table of 64 steps of a full turn (index floor(frac × 63)), so the tumbling is stepped, not smooth. No culling (both faces). Lit by the stage’s directional and point light with the turned normal. The pixel shader was not read.

One-shot system models (M)

Object 0x140533448; spawn 0x14022e7d0(entry, matrix, pool, loops, fade flag, fade start); update 0x14022ea00. Five pools (pointers at +0x70, counts at +0x98) of 0x60-byte records: +0 s16 entry, +2 pool, +4 loops, +5 alpha, +6 fade flag, +8 frame, +0x0C fade start, +0x10 matrix, +0x50 animation length. Frame += 1 per tick; the record ends when the frame passes the animation’s length on its last loop; with the fade flag, alpha = 1 − (frame − start) / (length − start) once past the start.

Entry Pool, fade Model Animation
0x0E burst 2, none; mark matrix × 2 st00 model 14: point sprites (handle vkpsprite), 21 elements on 46 joints 59 frames
0x45 smoke 2, none; mark matrix point sprites, 2 elements (size 1000, second value 60) on 5 joints, blend word 0x5400, two textures 59 frames: position and scale keys on two joints, rotation keys on two
0x4A + 3 k + facing fragments 1, fade from frame 30; at the mark position, facings 0 / 2 unrotated, facing 1 turned to the flattened normal 17 solid chunks (handle sd, one texture), one per joint under a root 39 frames, 40 position and 40 rotation keys per joint (a baked throw)

Key layouts as in the character animations: position / scale keys 16 bytes (f32 frame, f32 xyz), rotation keys 8 bytes (u16 frame, 3 × s16 in 1/32768 turns).

Corrections to earlier text

Implementation notes for the rebuild

  1. Data: craterconv.py stNN.alr stNN.dat st00.alr st00.dat out → crater.json (format pd-crater 1, game space like effect.json): marks (kind, bounds with radius, materials, meshes), debris (kind, params, pieces: positions, normals, uvs, spin, centers, velocities, three vertices per piece), fragments (kind, facing, joints, meshes, anim), smoke and burst (elements, joints, anim; burst textures prefixed st00_). The Palace output is on the test machine under converted/crater/st03/ (1.5 MB).
  2. (Built, crater 11-15: Godot 4.7’s stencil_mode only replaces with the reference, so the count is made from the faces’ sides: the entry faces in front of the scene set the stencil, the exit faces behind it draw with the depth test inverted where it is set, a third pass clears it; mark_models.gd. Data path <stage>/crater/.) Mark: replace the disc by the mark model at contact + normal × 1, Y = normal, random spin, drawn as the carve: in Godot, either the three stencil passes (4.5+ stencil materials: back faces increment / front faces decrement on depth fail, then the model with depth test inverted and stencil not-equal, writing depth), or the equivalent in one shader: draw the model’s inward faces with depth function greater only where the scene depth lies inside the volume. The refusal radius and the camera-removal box come from bounds (24.57 on the Palace), not the placeholder 10.
  3. Debris: replace the chips by one shader mesh of the 200 pieces using the motion formula above (per-vertex centre, velocity and spin as custom attributes; the frame as a uniform stepped once per 30 Hz tick), launch along the normal, gravity scaled by 1 − 0.9 × clamp(−n.y, 0, 1), 90 ticks, alpha fade over ticks 50–89, no culling. Made on every mark request, also a refused one. At most 60 live requests.
  4. One-shots: smoke every time (60 ticks); with an added mark the burst at twice the size (60 ticks) and, for kind 1, the facing’s fragment model playing its 40-tick baked animation once, fading from tick 30. Point-sprite models draw as the effect elements of that handle already do (capsuleformconv.model form).
  5. Stage objects’ debris (kinds 0–7, type 9 records) use the same manager and shader: the same code path serves “Stage object hit / break effects”.
  6. Other stages: convert each stage’s own entries; st07 / st17 marks animate (age 0.5 per tick, removed at the animation’s end), st01 has no marks.