St03 sky brightness against the Xbox: the sky model’s vertex-colour domes
Read from default.xbe (Xbox) and PDUWP.exe
(PC) on the data machine, the stage files of
both builds, and probe renders of our build
against the xemu intro pan. Proof of the layout:
converter/svcdump.py (struct based,
synthetic test
tests/test_svcdump.py).
The answer. The game’s st03
sky is not “clouds over a dark clear colour”.
Its sky model (stage model 2) has three layers
and pdconv converts one: it has no branch for
vertex format 0x0B (position +
colour, no texture), so the two svc
layers are dropped (“3 index buffers -> 1
visual”). The dropped outer layer is an
opaque blue-grey backdrop dome,
(76, 80, 102) / 255 = (0.30, 0.31, 0.40) over
the whole upper sky. The clouds are added on top
of it. With that dome drawn, our sky box reads
the xemu frames to within 0.01..0.03 (table
below) (H: data, code,
renders). The same kind of layer is dropped on
16 of the 19 versus stages.
Vertex
format 0x0B and the sv*
shaders
- Format 0x0B (16 B):
position 3 × f32, then one D3DCOLOR (bytes B, G,
R, A). No normal, no UV. The material’s texture
indices are unused. (The same format number
carries the aura shells of the characters,
saura.) SVC/SVCAL/SV, PC pixel shader:rgb = saturate(vertex colour); alpha = the alpha-test constant (c0.w), discarded when the test value is not below it. No texture, no light, no fog input, and the material colour is not read (st03’s outer dome has a material colour of (127, 127, 127), which has no effect).SVCALhas the same colour path.- Xbox
SVC(shader record 0x2af728): combiner rgb = vertex colour, final combinerfog.a · colour + (1 − fog.a) · fog colour, alpha = c0.a. The vertex program writes the colour from input 2 and the fog coordinate asdot(position, c16)(c16 =cTMAT0), not the clip-space depth the other stage shaders write. What uploads c16 forSVCwas not found (the YFOG classes upload a height row there, “Constants from the executable”). - Material bind (PC 0x1402a6010, H): flags bit 4 = blend on, with the material’s blend word; bit 9 = depth mode 3 (depth write on, test less-or-equal), else mode 2 (depth write off); bit 7 = no culling, else back faces are culled. The sky draw overrides the depth mode (below). Blend word, high byte: low nibble = source factor, high nibble = destination factor, from the table at 0x1402f77c0: 0 zero, 1 one, 2 source colour, 3 inverse source colour, 4 source alpha, 5 inverse source alpha, 6 destination alpha, 7 inverse destination alpha, 8 destination colour. Operation = (word >> 5) & 7 from 0x1402f7798: 0 add, 1 subtract, 2 reverse subtract, 3 min, 4 max. So 0x11 = one / one, 0x14 = source alpha / one.
St03’s
sky model (identical bytes in the Xbox and the
PC st03.alr)
| Index buffer | Shader, flags, blend | Shape | Vertex colour | Winding |
|---|---|---|---|---|
| 0 | svc, 0x10001 (opaque) |
outer dome, radius 12 398, y −3 620..3 620, 329 vertices, 576 triangles | by height: (18, 19, 24) for y ≤ −2 794, (34, 36, 46) for −2 384..−1 385, (56, 59, 74) for −843..263, (76, 80, 102) for y ≥ 801 | all 576 face the centre |
| 1 | sbtscloud3, 0x43d, source alpha
/ one |
cloud dome, radius 11 742, 736 triangles | (format 0x03) | all face the centre |
| 2 | svc, 0x10011 (blend on), one /
one |
inner dome, radius 6 098, y −2 010..2 030, 306 vertices, 608 triangles | white below y 513; (76, 76, 56)..(253, 255, 189) above | all 608 face away from the centre |
- The inner dome is back-face culled
from inside on st03, so it is not seen
(H: its material has no no-cull
bit; a probe render with it drawn two-sided and
additive is white over the whole sky, which no
footage shows; with culling the sky box mean
moves by 0.02 or less). The same shell on st13 /
st06 / st16 / st26 / st02 is an
sclayer wound toward the centre and is seen. St03’s looks like a leftover of that shared sky model turned inside out (a guess). - Joint 2 of the model sits at (−1 692.1, 1 395.2, 1 733.6): the position of set 2’s point light (“Sky colour: set 2’s point light”).
- Draw order = index buffer order: backdrop, clouds, (inner dome). The backdrop is opaque and the sky draws with depth writes off, so it must come first.
All 19 versus stages: layers of stage model 2
No other stage model has format 0x0B
primitives. “Dropped” = not converted before
skycol2 (11-15); since then pdconv converts
every layer listed here
(pdconv --stats lists them with
flags, blend word and triangles; st02 / st13 /
st22 convert byte for byte as before).
| Stage | Dropped svc /
svcal layers (vertex colour range,
R G B) |
Other layers |
|---|---|---|
| st01 | backdrop r 12 699: (25, 0, 0)..(255, 255, 255) | 8 cloud layers |
| st08 | backdrop r 12 699: (0, 0, 0)..(255, 255,
127); svcal one / one, r 2 083, 8
triangles: (0, 0, 0)..(165, 144, 0) |
8 cloud layers |
| st02 | none | sc dome, clouds,
sc inner |
| st12 | backdrop r 12 415: (6, 6, 6)..(38, 38, 38) | clouds |
| st22 | none | sc dome, 2 cloud layers |
| st03 | backdrop (above); inner dome (culled) | clouds |
| st13 | none | sc dome, clouds,
sc inner |
| st23 | backdrop r 12 390: (30, 35, 35)..(46, 58,
54); svcal one / one, r 3 258, 304
triangles: (0, 0, 0)..(248, 236, 112) |
clouds |
| st04, st24 | backdrop r 13 512: uniform (120, 104, 130) | clouds |
| st14 | backdrop r 13 512, flags 0xd: uniform (176, 176, 176) | clouds |
| st05 | backdrop r 12 398: (46, 41, 36)..(255, 229, 202) | clouds, scal inner |
| st15 | backdrop r 12 487, flags 0x9: (0, 0, 0)..(255, 255, 255) | clouds, scal inner |
| st25 | backdrop r 12 487: (10, 14, 19)..(255, 255, 255) | clouds, scal inner |
| st06 | backdrop r 12 398: (0, 0, 0)..(124, 157, 142) | clouds, sc inner |
| st16 | backdrop r 12 398: (0, 0, 0)..(254, 207, 188) | clouds, sc inner |
| st26 | backdrop r 12 398: all black | clouds, sc inner |
| st07 | backdrop r 12 398: (21, 13, 13)..(255, 240,
196); second svc, r 7 004, y 982..1
705, triangle list (primitive type 5): (29, 16,
11)..(115, 64, 44) |
clouds, sc inner |
| st17 | backdrop r 12 398: (21, 27, 48)..(43, 54,
92); second svc, r 9 821, y 1
304..2 383: (24, 31, 65)..(33, 41, 87), mixed
winding (164 toward / 102 away) |
clouds, sc inner |
The backdrops are opaque (flags 0x10001; st14 0xd and st15 0x9 have other low bits, blend bit clear) and gradients by height on most stages, so each of these skies is today missing its base colour and horizon gradient, not only st03. St26’s is black (no change).
The Xbox sky draw, fog and light-set selection (default.xbe, H)
The Xbox code has the PC’s structure, function for function:
| What | Xbox | PC |
|---|---|---|
| Sky object draw | 0xb1580 | 0x1401c87f0 |
| Light set builder | 0x896e0 | 0x140199670 |
| Fog apply for a set | 0x89440 | 0x140199360 |
| Set selection (calls the fog apply) | 0x89a40 | (as “Sky and far scenery draw”) |
| Set records, 0x58 bytes each | 0x2c4980 | |
| Light records, 0x70 bytes each (index set · 8 + 0x40 + k) | 0x2e65d0 | |
| Current set | 0x396b10 |
- Sky draw 0xb1580: step 1 draws stage model 1 under set 3. Step 2 draws stage model 2 (skipped when bit 0x8000 of 0x39e7bc is set): moved to the eye position (from the view matrix), depth mode 3, then depth writes off, alpha test off, light set 2 selected, the model drawn, blending off, set 0 selected again.
- Fog apply 0x89440: mode byte at set + 0x4F; writes the D3D fog states (enable, table mode, start = set + 0x50, end = set + 0x54, density, colour = set + 0x4C). The only other writer of the fog-enable state is device setup. So set 2’s fog is enabled for the whole sky draw, and there is no separate “cloud pass” state.
- Clouds (
SBTSCLOUD3, record 0x2ad4d8): final combinerfog.a · (lit colour · t0) + (1 − fog.a) · fog colour, alpha from t1; the vertex program writes the fog coordinate = clip w. So the Xbox clouds are fogged by view depth with set 2’s fog (st03: linear 1 602..12 822, colour (30, 45, 55)). This is what the Xbox look already draws (it was an inference; now H). - Point vector on the Xbox: the cloud vertex program writes the packed point vector (× 0.5 + 0.5) to the second colour output, which the hardware clamps to [0, 1]. So P stays in [−1, 1] on the Xbox (H, was M in “Sky colour”); the PC’s one-sided clamp lets it reach −3.
- Backdrop fog:
SVCis in the fogged list, but its fog coordinate isdot(position, c16), not the depth. By view depth the backdrop (12 398 away, fog end 12 822) would be 96 % fog colour, (0.12, 0.18, 0.22). The xemu frames’ darkest clean sky reads (0.24..0.27, 0.26..0.30, 0.33..0.39), the dome’s own (0.30, 0.31, 0.40) or a little under, and far from the fog colour’s green-heavy ratio. So the backdrop is unfogged or nearly so on the Xbox (M: renders; the c16 upload forSVCis not found). - Frame clear (PC, H): the
battle frame clears to black
(clear routine 0x140021620, colour argument 0 at
0x1401c81d3). The light script’s
0x2001colour is the shadow colour only. Ourmain.gdclears with it ((15, 18, 25) on st03), which shows wherever a backdrop is missing; behind an opaque backdrop the clear colour is never seen. (skycol2 r2) All 14 calls of 0x140021620 in the exe pass a constant colour (0 at 12 of them, opaque black at one, white at one, none read from the stage or its light script), so no clear can produce the 0x2001 colour on any stage, st13 included. The routine clears the colour target only when one of its flag bits 0xf0 is set; at 0x1401c81d3 that happens only while bit 0x800 of the game flag word 0x140530034 is set (else it passes 3: depth and stencil only). Bit 0x800 is set at 0x1401aec4b, 0x1401d19f7, 0x1401d1d33, 0x14021846d and cleared at 0x1401ae9f8; which game states those are is not traced. If a battle frame runs without it, the colour target keeps what was drawn into it before (not followed), so “black behind st13’s additive dome” is H for the clear colour and open for whether the battle frame clears at all (PLACEHOLDERS “St13 sky against footage”).
Check against xemu (probe renders, nothing committed)
Our build at 461794f with two probe flags:
set 2’s point light on (as “Sky colour”), and
the st03 svc backdrop drawn from
svcdump.py --json (unlit, opaque,
back faces culled, depth writes off, before the
clouds, unfogged). Intro shot 2
at tick 150, Xbox look, glow on, 1280 × 720; sky
box = x 0.02..0.68, y 0.20..0.50 of the picture;
xemu = three frames of the intro pan
(x1125_5/15/25).
| Picture | Mean RGB | Dark half | Bright half | Clipped |
|---|---|---|---|---|
| xemu frame 15 | (0.48, 0.52, 0.60) | (0.28, 0.32, 0.40) | (0.68, 0.72, 0.80) | 14 % |
| xemu frame 25 | (0.39, 0.43, 0.52) | (0.27, 0.31, 0.39) | (0.52, 0.56, 0.66) | 0 % |
| xemu frame 5 (camera nearer the white core) | (0.74, 0.78, 0.83) | (0.52, 0.58, 0.67) | (0.95, 0.97, 0.99) | 44 % |
| ours + backdrop, 8 scroll phases | (0.40..0.61, 0.43..0.65, 0.52..0.72) | (0.27..0.34, 0.31..0.38, 0.39..0.47) | (0.52..0.89, …) | 1..35 % |
| ours + backdrop, phase 25 000 | (0.40, 0.43, 0.52) | (0.27, 0.31, 0.39) | (0.52, 0.56, 0.66) | 5 % |
| ours + backdrop, phase 12 500 | (0.50, 0.54, 0.63) | (0.29, 0.34, 0.42) | (0.70, 0.74, 0.83) | 16 % |
| ours without backdrop (point light on), same tick as the next row | (0.38, 0.41, 0.46) | (0.16, 0.19, 0.23) | (0.59, 0.63, 0.68) | 10 % |
| ours + backdrop, same tick (3 000) | (0.66, 0.69, 0.76) | (0.41, 0.45, 0.54) | (0.92, 0.94, 0.98) | 40 % |
| ours + backdrop, no glow, tick 3 000 | (0.51, 0.55, 0.64) | (0.30, 0.34, 0.42) | (0.73, 0.77, 0.86) | 16 % |
| ours + backdrop, PC look, tick 3 000 | (0.68, 0.70, 0.76) | (0.44, 0.46, 0.54) | (0.92, 0.94, 0.98) | 39 % |
| backdrop alone (clouds hidden, no glow) | exactly (76, 80, 102) / 255 over the upper sky | 0 |
- Brightness: the missing “2 ×” is the backdrop. It lifts the dark half from (0.16, 0.19, 0.23) to the footage’s (0.27..0.30, 0.31..0.34, 0.39..0.42); two of the eight phases reproduce an xemu frame’s mean, dark half and bright half to 0.01..0.03 (H).
- Scroll phase (brief item 3): eight phases over the 100 000-tick cloud period were rendered. The pattern was not matched: correlation of the sky box with each xemu frame stays under 0.2 for every phase (the footage’s pan is also at a different camera time per frame). The comparison above is therefore by distribution, where the phase moves the mean by ± 0.1 but the dark half by only ± 0.03. Exact phase match stays open; it is no longer needed to explain the brightness.
- Glow (brief item 2): with our glow chain the sky box matches the xemu frames; without it the bright half at the same tick is 0.19 lower. Nothing points to a different Xbox bright pass on this sky (M: one tick with / without glow, statistics only; the Xbox SelColor tap spacing stays undecoded, “Glow paths not modelled”).
- Violet specks: the xemu frames show the same faint violet fringes at cloud edges, so a small amount is the original’s picture (M, by eye at 852 × 600). The Xbox clamp of the point vector (above) is what keeps them fainter than in the PC look.
- PC: no PC footage of this sky in the library. By the decoded PC code the PC draws the same backdrop and unfogged clouds, a brighter sky than the Xbox (row “PC look”) (H code, no footage).
- Probe note: the probe’s fog option for the backdrop had no effect (the backdrop read its raw colour in both renders), so every “+ backdrop” row is an unfogged backdrop.
Implementation notes for the
rebuild (items 1-4 built in skycol2
11-15: pdconv writes the layers as glTF
primitives with COLOR_0 and a
material whose extras carry
pd_shader, pd_flags
(the u32 at entry + 0x0C) and
pd_blend (the u16 at + 0x14),
single-sided, untextured; Godot
PdData.vcol_sky_material,
PdData.frame_clear_color. Item 5
was built in skycol, as the material’s
cloud_p_low since skycol2)
- pdconv: convert format 0x0B primitives of
stage model 2 (position +
COLOR_0 from the D3DCOLOR, no UV, no normal),
with the material’s shader name, flags and blend
word, in index buffer order. Today they are
dropped on 16 stages. Use the structs in
svcdump.py/ Esper-RE; strips and (st07) lists. - Godot: draw
sv/svc/svcalunlit as the vertex colour only (no texture, no material colour, no light), depth writes off, back faces culled by the stored winding (this hides st03’s inner dome; st17’s second layer has mixed winding and loses 102 faces, as in the game), blend from the material: flag bit 4 clear = opaque, set = the blend word (one / one on st03 / st08 / st23). Order inside the sky model = index buffer order (backdrop before clouds). - Fog: clouds keep set 2’s depth fog in the
Xbox look (now decoded). Leave
svc/svcalunfogged in both looks until the c16 upload is decoded (XboxLook.FOGGEDlistssvc,svcaltoday: take the sky model’s out). - Clear the frame to black, not the 0x2001 shadow colour.
- Xbox look: clamp the packed point vector to [0, 1] (already task 3 of “Sky colour”; now H).
- Expect at st03 intro shot 2, Xbox look, with the point light: sky box mean (0.40..0.61, 0.43..0.65, 0.52..0.72) by phase, dark half about (0.28, 0.32, 0.40), cloud gaps exactly (76, 80, 102) / 255 where no cloud covers them. Re-shoot every stage of the table above (st01, st04 / st24, st14, st05, st12 and st23 gain the most).
- Open: what
SVCuploads to c16 (the backdrop’s fog coordinate on the Xbox); the exact cloud phase of the footage; the second set-2 selection site at Xbox 0x10d94a.