Sky and far scenery draw: light sets 2 and 3, dome colour, the st02 glow
Decoded from PDUWP.exe (our reading of the machine code; addresses as leads), the stage files and renders of our build at one spot on st02 (Highway). Class handles are the RTTI names.
The
sky object (pdMapSky, vtable
0x14048ca48, draw 0x1401c87f0)
The battle stage setup (0x140204e60, at 0x1402053be..0x1402053da) hands the stage ALR to the sky object twice: as a global (0x14052dda8) with sub-model index 1 (0x14052dda0), and as the object’s own model (+0x40) with sub-model index 2 (+0x48). The object’s draw method then draws both outside the normal stage walk, each under its own light set:
| Step | What | Light set | Placement |
|---|---|---|---|
| 1 | stage model 1 (when the global is set) | 3 (0x1401c8845) | identity rotation, moved to the object’s position (+0x4C..+0x54; zeroed by the init 0x1401c87c0, so the origin) |
| 2 | stage model 2 (skipped when render flag bit 0x8000 of 0x14052fff4 is set) | 2 (0x1401c8b1b) | identity rotation, moved to the camera position (eye = −Rᵀ·t of the view matrix at 0x1405a5ca0, all three axes) |
| 3 | back to light set 0 (0x1401c8b79) |
- Model 2 is the sky (domes and cloud layer). Model 1 is the far scenery: on st02 / st22 the distant city ring (189 primitives, 9 479 triangles, ±3 971 units, SD and SBTS materials; the playable part, model 0, is ±600..840). St03 has no model 1.
- Selecting a set applies its fog too. 0x140199970(set) returns at once when the set is the current one (0x140527c94); else it points the light slots at the set’s records and ends in 0x140199360(set), which writes the set’s fog to the render states from the 0x58-byte record: enable (state 0x5C; off when the mode byte +0x4F is 0), mode (0x5D), colour (0x8A, +0x4C), linear start / end (0x5E / 0x5F, +0x50 / +0x54) or the density for the exp modes (0x60, +0x54). Only set 0 also copies the glow scale (“Glow pass”). A linear fog of set 0 has an override path (bit 4 of 0x140530034 and an object with id 0xe02713 present: colour and range from 0x140527cac..; set / cleared in 0x140199ce0), not followed.
- Around step 2 the method sets depth mode 3 (0x14028e390), states 0x8F = 1 (2 with bit 2 of 0x14054c9dc), 0x40 = 0, 0x90 (stencil) = 0 and clears state 0x3C when it was set; after it the depth mode cache goes back to 0. What 0x40 / 0x3C / 0x3B are is not decoded.
- So the sets of the light script are: 0 the stage and everything in a match, 1 the characters’ set (with the player’s point lights), 2 the sky’s set, 3 the far scenery’s set. In all versus scripts checked (st01, st02, st03, st07, st12, st22) set 2 has a light that travels upward (script y +0.54..+1.0), a black ground colour and a far or no fog (st03 linear 1 602..12 822, st02 exp 8e-5, st22 exp² 2e-5): values made for a dome seen from inside. This corrects “Stage light script” (“sets 2 and 3: other modes or story events”) and the cloud paragraphs of “Sky dome and clouds” that took set 0.
What that does to the clouds (SBTSCLOUD3)
The cloud colour is
t0 · min(sat(N·L · light) + sat(N·P · point + sky), 1)
with the selected set’s constants. The cloud
dome’s normals point inward and down (mean N.y
−0.88), so set 0’s downward light gives N·L <
0 on most of it and the clouds came out as
t0 · sky(set 0). With set 2 the
light travels up, N·L is 0.6..1 over the whole
layer, and the sky colour is set 2’s:
| Stage | set 0 result (ours today) | set 2 result (the game) |
|---|---|---|
| st02 | t0 × (0.34, 0.40, 0.42) | t0 × min(N·L·(0.18, 0.38, 0.16) + (0.71, 0.73, 0.71), 1) ≈ t0 × (0.85, 1.0, 0.83) |
| st03 | t0 × (0.49, 0.51, 0.53) | t0 × min(N·L·(0.43, 0.22, 0.59) + (0.33, 0.41, 0.78), 1) ≈ t0 × (0.68, 0.59, 1.0) |
(skycol 11-15, corrected) Point
light 0 of set 2 is not black:
st02 has colour (113, 94, 0) and range 9e8, st03
(225, 255, 220) and range 1e8, and it saturates
the point term over most of the dome (“Sky
colour: set 2’s point light” below; the table
above leaves it out). Without it st03’s clouds
get 1.2–1.9 × brighter and bluer, st02’s about
2.5 × brighter and golden instead of grey-green.
This is the “lit dome” the skyfix5 note could
not find for the brighter xemu capture of st03:
the constants at draw time are set 2’s
(H for the set selection in the
PC code; M that the Xbox does
the same, by the footage of st02 and st03 and
the identical .dat scripts; the
Xbox draw code is not traced).
The dome’s vertex colour (SC, vertex format 0x09)
SC multiplies its texture by the
vertex colour (the vertex shader passes COLOR0
through). Format 0x09 is 20 bytes: position 3 ×
f32, UV 2 × s16, colour 4 × u8 at
+16 (grey on every dome checked, alpha
255). pdconv does not write it, so Godot draws
white. Values:
| Stage, dome | Material | Vertex colour |
|---|---|---|
| st02 outer dome (golden texture, 290 vertices, radius 12 400) | flags 0x10001 (no blend: opaque), blend word 0x1100 unused | grey 95..185 of 255: 136 on 139 vertices, 185 on the horizon ring (36), 95 / 110 in one sector (73); mean 0.52 |
| st02 inner dome (black texture with a few bright texels, 339 vertices, radius 6 300) | flags 0x10011 (blend on), one / one | 255 |
| st22 dome | flags 0x10001 (opaque) | 86..255, mean 0.55 |
| st07 domes | 0x10011, one / one | 255 |
The outer st02 dome is therefore about half as bright as its texture (texture mean (0.69, 0.54, 0.36) → about (0.36, 0.28, 0.19)), and opaque (over the black clear colour our additive draw gives the same result, but the order must be dome first).
Why our st02 sky clips (measured, our build bf52b1e, 1280 × 720, Xbox look)
Camera at the st02 spawn, looking up 25°, four headings; sky = top 40 % of the frame; luma = (0.3, 0.6, 0.1). The glow chain was also computed on the CPU from the frame without glow; it reproduces the rendered result within 0.014 mean on two headings (0.058 on the third), so the chain itself is drawn as decoded.
| Step | Decoded | Ours | Verdict |
|---|---|---|---|
| Dome before glow | texture × vertex grey (≈ 0.53) | texture × 1: dome-only sky mean (0.75, 0.60, 0.41), luma median 0.63 | wrong: no vertex colour |
| Clouds before glow | t0 × set 2 (≈ t0) | t0 × set 0’s sky: cloud-only mean (0.14, 0.11, 0.05) | wrong: light set |
| Sum before glow | — | mean (0.88, 0.72, 0.46), luma p5 / 50 / 95 = 0.58 / 0.75 / 0.87; 16 % of sky pixels already have a channel ≥ 0.98 | too bright and too flat |
| Glow scale s | script 0x2003: 0.71, eased from 0.5 | 0.710 (log) | right |
| Bright pass | keeps luma > 0.5 / 0.71 = 0.704 | 67 % of the sky passes (median luma 0.75 sits just over the threshold) | follows from the input |
| Composite | + blurred tile × 1.0, saturated | sky mean (0.98, 0.95, 0.78), 90 % of sky pixels clipped in a channel; glow adds 0.16 averaged over the whole frame | follows from the input |
| Colour space | textures sampled raw, 8-bit targets, every pass saturates | dome-only pixels equal the texture’s values (no gamma step), 8-bit, saturating | right |
The cause is the input, not the glow: a dome twice too bright puts most of the sky just above the bright-pass threshold, and the glow then adds the sky onto itself.
Model of the corrected sky
(same frames: dome-only render × 0.53 + the
cloud-only render under
--light-set=2, then the decoded
glow chain on the CPU;
--light-set=2 made the cloud-only
render 2.1–2.5 × brighter on two headings, 1.15
× on a third, not looked into):
| Heading | Today, with glow | Model, PC (no fog), with glow | Model with set 2’s fog on the clouds (× 0.55), with glow |
|---|---|---|---|
| +x | sky mean (0.98, 0.95, 0.78), luma median 0.98, 90 % clipped | (0.85, 0.75, 0.47), median 0.79, luma p5 0.37, 47 % clipped | (0.58, 0.47, 0.28), median 0.49, none clipped, no glow |
| −x | (0.84, 0.81, 0.65), median 0.97, 72 % | (0.69, 0.62, 0.40), median 0.62, 36 % | (0.51, 0.42, 0.26), median 0.44, none |
The modelled sky has the footage’s look: dark brown cloud bodies against bright golden gaps, instead of a flat yellow-white. Sky patches of the Xbox frames in the comparison clip read (0.55, 0.44, 0.26) at 159 s (close to the fogged model) and (0.89, 0.75, 0.42) at 111 s (close to the unfogged model with glow), so the Xbox lies between the two models; how strongly its cloud pass is fogged is the open part (L: the fog register is read by the cloud combiner, the set 2 fog values are decoded, the Xbox render state at that draw is not traced). On the PC (no fog) the sky keeps bright bloomed cores where the cloud texture is brightest: that is the decoded PC result, less white and far more contrasty than today.
Not a cause: sRGB / linear handling, HDR, the glow scale, the tap tables.
Stage light values of st02 (script, set 0 / 2 / 3; vectors in script order)
| Set | Used for | Light direction | Light | Sky | Ground | Fog |
|---|---|---|---|---|---|---|
| 0 | stage, objects | (−0.907, −0.419, −0.021) | (231, 195, 130) | (86, 101, 108) | (35, 35, 35) | exp, density 0.00144, colour (33, 34, 27) |
| 2 | sky | (−0.014, 0.995, 0.097) | (45, 97, 40) | (181, 187, 180) | 0 | exp, 0.00008, black |
| 3 | far scenery | (−0.877, −0.453, −0.158) | (135, 126, 100) | (120, 120, 120) | (130, 130, 130) | exp, 0.00136, colour (13, 19, 18) |
Glow: 0x2003(0.71, 0); shadow
colour 0x2001: black. On the PC no
pixel shader reads the fog, so the per-set fog
matters only for the Xbox look: there the far
city (2 000..4 000 units away) is fully in set
3’s dark fog colour, the near-black skyline of
the Xbox footage, and the cloud layer takes set
2’s weak black fog (factor e^(−0.00008·d): 0.71
overhead at 4 350 units, 0.40 at the rim), SC
domes none. Our Xbox look fogs model 1 with set
0’s values and colour.
The sand storm is on a clock that runs from boot
The storm intensity (“Stage ambient effects”)
is computed in the vkSAND constant
upload (0x1402342e9) from the float counter
0x14057f398. That counter has two writers only:
device setup zeroes it (0x1402927ae) and the
30 Hz game tick 0x1401c7630
adds 1.0 (0x1401c77fc; wraps at 4 000 000). The
tick runs in menus as well, and nothing resets
the counter at a stage load. So the storm does
not depend on the mission, an option or a random
draw: it is a slow wave on the time since the
game was started.
B = clamp(2·sin(0.001·t − 4096), 0, 1)has a period of 6 283 ticks = 209.4 s. In ticks since boot the storm is on for t < 2 505 (first 83.5 s, full strength until about 66 s), off from 2 505 to 5 646 (83.5..188.2 s), on again 5 646..8 788, and so on: 104.7 s on (17.5 s fade in, 69.8 s full, 17.5 s fade out), 104.7 s off.A(0.25..1) is the gusting inside an on phase.- A Highway match that falls into an off window has no storm; one started a minute or two later has it. That is the difference between the two Xbox runs (H for the PC code, M that the Xbox counter starts at boot the same way; its code is not traced).
- The same counter drives the cloud scroll and the capsule UV scroll: one step per 30 Hz tick is now decoded (it was inferred).
Implementation notes for the rebuild
- Converter: write COLOR_0 for vertex format
0x09 (u8 × 4 at +16, through a struct for the
20-byte vertex) and draw
scas texture × vertex colour. Expect on st02: dome-only sky mean about (0.39, 0.31, 0.21) instead of (0.75, 0.60, 0.41); st22’s dome 0.55 × today’s. - Draw the sky model (model 2:
sc,sbtscloud2/3) with light set 2 (light, direction, sky colour, point light 0), not set 0. Expect st02’s cloud-only render about 2.5 × brighter and golden; st03’s sky brighter and bluer (re-check the st03 capture numbers of skyfix5). - Draw model 1 (far scenery) with light set 3; in the Xbox look fog it with set 3’s fog and fog the cloud layers with set 2’s fog (SC stays unfogged).
- Sky model follows the camera position (all three axes); model 1 stays at the origin.
scmaterials: blend only when flag bit 4 is set (st02’s outer dome and st22’s dome are opaque; draw them before the additive layers).- Storm clock: one process-wide tick counter that starts with the game (30 per second, menus included), not a per-stage clock; the cloud scroll and capsule scroll use the same counter.
- Glow: no change to the chain. After 1 and 2, expect at the st02 spawn (looking up 25°, heading +x / −x): PC look sky mean about (0.85, 0.75, 0.47) / (0.69, 0.62, 0.40) with glow instead of (0.98, 0.95, 0.78) / (0.84, 0.81, 0.65), luma p5 0.37 instead of 0.68 (dark cloud bodies), bright-pass share of the sky 32 % / 26 % instead of 67 % / 53 %. Xbox look with the clouds in set 2’s fog: about (0.58, 0.47, 0.28) / (0.51, 0.42, 0.26) and almost no glow on the sky.
Built (skyglow 11-13): 1 (all 19
stages reconverted), 2, 3, 4 and 6
(PdClock, PdSky,
PdData.model_light_set); 5 and 7
unchanged. The sky is drawn without point lights
(p0 = 0), since set 2’s point light 0 is read as
black here; st02’s light.json lists a coloured
one, not reconciled (PLACEHOLDERS “Sky light
set”). (skycol 11-15: reconciled, the light
is real and the sky needs it; next
section.) Measured at the st02 spawn,
heading +x, PC look with glow: (0.82, 0.74,
0.49), luma p5 0.30, 51 % clipped, bright-pass
share 58 %; −x (0.71, 0.64, 0.42).