Glow pass (bloom) and the post filters
Decoded from PDUWP.exe and the
.cso shaders
(dxbc_dis.py) in branch
bloom; our reading of the machine
code, addresses as leads. Godot:
godot/scripts/pd_glow.gd.
- Shader table: the PC port
maps each original Xbox shader object to a
.csofile through a table of {Xbox object, name} records around 0x1403db5d8. The post-filter programs live in 0x20-byte records at 0x1403fc100 (PS id +8, VS id +0xc, Xbox PS object +0x18, VS object +0x20), created lazily at device setup (0x140285d60): GFilter2 (0x1403fc100), GFilter (0x1403fc120), SelColor (0x1403fc140), PreRender (0x1403fc160), AuraBox (0x1403fc198), FFilter (0x1403fc1d8), MFilter (0x1403fc1f8), BlendSimple (0x1403fc218). FFilter has no user. - Targets: device setup also makes four 512×512 render targets (formats from the table at 0x1402f7730; the texture of slot k at 0x14054c200 + 8k, the surface at 0x14054c220 + 8k). The glow uses only the top-left corners: a 256×256 tile of slot 0 and two 64×64 tiles of slot 1 (at x 0 and x 128).
- When: at the end of each view’s scene render (0x1401c78c0 → 0x1402886e0, the variant 0x140288b00 when bit 3 of 0x140530034 is set, not followed), after the 3D (effects included), when bit 0x40000 of the render flags 0x14052fff4 is set (set by the battle scene setup 0x140204860 and other scene inits, cleared by 0x14010a7e0 in one mode).
- 1. Bright pass (SelColor,
0x140286590): the frame (resolved back
buffer, the special texture 0x140582a18) is
drawn into the 256×256 tile, the whole view
mapped onto it, sampled bilinear twice at the
same coordinate (the PC vertex shader adds
c91= 0 to both) and mixed 0.44 / 0.56. The pixel shader’sc1= s · (0.3, 0.6, 0.1); a texel keeps its colour (saturated) when dot(colour, c1) > 0.5, else black (alpha 2·(l − 0.5), not used later). - Glow scale s (0x14054c2e4):
1.0 at device setup; the battle scene setup
(0x14019a020) sets the current and target value
(0x140527cc4 / 0x140527cc0) to 0.5; the
per-update light function 0x1401991e0 moves
current 10 % of the way to the target; applying
light set 0 (0x140199360) sets the target from
the stage script’s value and copies current into
s. The stage script call
0x2003(f, rgb)(handler 0x140206900, table entry 3) stores f as that target (0x1403e8ba4, default 1.0) and the colour at 0x1403e8ba0 (copied to 0x14054c2e8, default 0x4c991a at device setup; no reader found). - 2. Reduce (MFilter,
0x140286c60): the 256 tile to a 64×64
tile, four bilinear taps at texel offsets (−0.5,
−1.5), (1.5, −1.5), (−1.5, 0.5), (0.5, 0.5)
weighted 0.200746, 0.149627, 0.200746, 0.448881
(
.rdata0x1402f8720/0x1402f8770; sum 1). - 3. Blur (GFilter, 0x140287080), four passes: pass p uses the tap offsets of row p of the table at 0x14048e890 (in 1/512 units) and the weights of row p & 1 of 0x14048e790: p 0 horizontal −1.5, −3.5, −5.5, −7.5 (y +0.5) weights 0.257405, 0.126010, 0.034836, 0.005439; p 1 horizontal 0.5, 2.5, 4.5, 6.5 (y +0.5) weights 0.296933, 0.193434, 0.071160, 0.014783; p 2/3 the same vertically (x +0.5). Passes 0/1 read the 64 tile at x 0 and write the tile at x 128, 2/3 the reverse; passes 1 and 3 are added onto 0 and 2 (the blend word 0x1101 of 0x14028e4e0: source ONE, destination ONE, add; its tables 0x1402f77c0 / 0x1402f7798 hold GL enums). Each pass saturates; all weights of a direction sum to 1.
- 4. Composite (BlendSimple,
0x1402885d0 → 0x140288100): the final
64 tile on a quad over the whole 853×480 virtual
screen (x −107..746), blend ONE, ONE onto the
back buffer, colour scaled by
c2.w= 1.0 (0.125 when the game state 0x140530264 is 0xe), saturated. - Xbox: default.xbe holds the
same blur offset/weight tables and the same
MFilter, GFilter and BlendSimple shader objects;
one glow serves both looks. The Xbox SelColor
vertex program (object 0x1403fc570) may place
its two taps apart (the PC one gets a
c90of (1, 1.05, random · 0.00586) it doesn’t read): not decoded. - Other filter shaders:
glowdraws pure white with a model transform (a mask pass, unused here);GFilter2the same four taps with per-vertex weights;FFiltera 4-tap box average;vk_glowtexture × vertex colour (sprite glow);vk_blurvertex colour only;PreRendera plain copy.