Xbox fog

Which shaders are fogged. A scan of all 245 shaders in the table for the fog register in the final combiner: fogged are the stage families SD, SBTS, SBPX, SBOS, SWBOS, SWD, SV/SVC, DBTS, LBTS, the YFOG variants, the cloud layers SBTSCLOUD2/3, the crash shaders, the water shaders (vkWATER*), vkBLINK2, vkCOLANIMA and the capsule cores vkCAP02 / vkCAP02M2. Not fogged: the sky dome (SC, SCAL, SCA*, SCREF*), the shadow passes, the aura (SAURA), nearly all effect shaders (PDEFT*, ms*, yk*; only PDEFTBB03 is fogged), and the other capsule layers (vkCAP01, vkCAP04M4, vkCAPM2*). The characters’ shaders (SWBOS, SWBOSM2, SWD, SWDSP) are in the fogged list, so the Xbox look fogs the characters too (PdData.apply_character_light). The cloud layers’ pass (skybright 11-15, decoded in default.xbe): the sky draw selects light set 2, which enables that set’s fog for the whole sky model, and the cloud vertex program writes the view depth as the fog coordinate, so the clouds are fogged with set 2’s fog (what the Xbox look draws since skyglow). SV/SVC write dot(position, c16) as the fog coordinate instead of the depth; the sky backdrops drawn with them read as unfogged in xemu (“St03 sky brightness against the Xbox”). Fog before the shadow darkening (floorstain). The fog is part of each surface’s draw and the shadow passes are not fogged; the stencil darkening is the full-screen pass after the scene (“Shadow volumes”), so it blends the shadow colour over the already fogged colour. Our stage shaders darken inside the shader (the stage volumes, stage_shadowed), so the Xbox look mixes the fog in just before that call (XboxLook.with_fog); fogged after it, every stage shadow was lifted toward the fog colour (st03: teal). Additive passes. The fog is applied inside the shader, before blending: in an additive pass (one/one, the cloud layers) a fully fogged surface adds the fog colour to what is behind it, which is what the hardware does too (the final combiner mixes before the blend).

Where the values come from. The light script’s fog call (see “Stage light script”, 0x2002(a, b, rgb, mode, set), D3D fog mode numbering); the .dat files are byte-identical between Xbox and PC, so the values are the ones pdconv already writes to light.json. Set 0: st03 linear, start −319, end 1999 game units, colour (15, 65, 90)/255; st22 linear 86..1474, grey 15; st07 linear 20..622, dark red; st02 exp, density 0.00144; st12 exp 0.00125.

Function. The fog coordinate is the vertex program’s fog output (clip-space w = view depth in game units; for the YFOG shaders the height coordinate instead) and the D3D fixed-function fog: linear f = (end − z)/(end − start), exp f = e^(−density·z), exp² f = e^(−(density·z)²), clamped to [0, 1]; the final combiner mixes the colour toward the fog colour by 1 − f. Units: z is the view depth in game units; Godot’s view depth is in metres (geometry × PdData.WORLD_SCALE, 0.1 m per unit), so the shader multiplies it by 1/WORLD_SCALE before the fog function. Not traced: the x86 that turns the script’s call into the fog render states (enable, table mode, start/end/density, colour); we take the call’s arguments as those states (PLACEHOLDERS “Xbox fog render states”).