PC rendering¶
The port converts PC meshes and materials as scene archives load. PC installation data lists the files each converter reads.
Post filters (M00's sepia)¶
The real PC game shows M00 in a strong sepia: a near-white cream sky and brown shadows (Compared with the real PC game). Until 25 November 2026 the port drew the same view grey-green, and this section said the PC data's grade was weaker than the disc's. Both were wrong. The post-filter data is not weaker: the grade (palette set 0) that MixPalettes builds for M00's start is the same 3 × 3 colour mix from the disc and from the PC installation (PostFilterPalettes entries 2 to 10 in both; at full input it maps red to (171, 41, 46), green to (57, 175, 37) and blue to (31, 46, 171), and a grey of 128 to (153, 147, 112)). What differed was the picture the grade starts from, in two places, and the finish pass:
- The sky was fogged. M00's sky is a
Gradient_01dome (TEX 207, an RGBA grey ramp from 169 to 237) under theM00_Clouds_*andSUNlayers. Their materials haveFENA0 in theRenderState(mat.md), which the PC's material reader (PC 0x471b90) passes to the material's render-state setter with the blend mode and opacity; the PC's picture shows them unfogged. The converter ignoredFENAfor plain strips, so the port fogged the whole backdrop into the fog colour: the sky came out at (128, 145, 157) before the grade, against (206, 182, 158) without fog. The PC's effect setup skips fog when the draw mode has 0x100000 (FUN_00495070:test [esi+0xc], 0x100000at PC 0x49517e, before it setsFogEnabledandvFogColor), the PS2'sPRIMDRAWMODE_NO_FOG. The converter now sets that bit on every material withFENA0 (MakeDrawSetupinpcprims.cpp; prm.md "PC version"). - The fog colour had red and blue exchanged.
ZROOM::SetFogColor(PS2 0x191514, PC 0x4f6a30, the same code) reads the scene'sCameraBackgroundColor(M00: 0x7d6243, red 0x7d) and stores it with red and blue exchanged, 0x43627d, the GSFOGCOLorder (red in bits 0 to 7). The PS2 writes that value toFOGCOLunchanged (ZOldDrawPS2::CalcGSRegs,RoomFogColor), so the fog is the scene's brown. The PC'sZRenderWintelD3Dfog setter (vtable +0x124, PC 0x488f90) puts its colour intoD3DRS_FOGCOLORand splits it intovFogColorwith red from bits 16 to 23 (FUN_004908d0); the captured PC picture has the brown fog, so the PC's colour arrives in that order (the call that passes it was not traced). The port'sGsCalcMaterialStatealso reads red from bits 16 to 23, which is right for the camera'sBackCol(the sprite path passes it, and drew brown fog already) but exchanges red and blue for the room's colour, which every other path passes: the port fogged M00 blue-grey (0x43, 0x62, 0x7d). Those paths now passGsRoomFogColor()(gsstatesdl.cpp), which returns the room colour in the orderGsCalcMaterialStatereads; the bones, dot3, PC material, strips, grass, water and mirror draws use it, from the PC installation and from the disc (see below). - The finish.
ZPostFilterWintelD3D(vtable 0x764c34;UpdatePC 0x4ab8f0) runs, in order,FUN_004a9950(copies the scene into one of two frame textures), the bloom (FUN_004aab10: the bloom list blurred and added with shaderadd r0, t0, t1), the colour curves and the depth blend (FUN_004aad40: palette set 0 throughFUN_004a7430; withPostFilterLOD2 the depth blend with palette set 1), the heat shimmer (FUN_004a9b40), the finish (FUN_004ab720), the last-frame blend (FUN_004ab500, palette set 2), the colour offsets (FUN_004a8140) and the noise (FUN_004a8710);FUN_004a5500copies the result to the back buffer. The pixel shaders are ps_1_1 token streams built inAllocateDeviceBuffers(PC 0x4a5bf0,FUN_0048fc60). The curves are the PS2's: three palette textures per set (red and blue 1 × 256, green 256 × 1, A8R8G8B8,GetRedPaletteand the others lock them), looked up with point sampling bytexreg2ar/texreg2gband summed (add r0.rgb, t1, t3; add r0.rgb, r0, t2), and the PC's MixPalettes (0x536400) packs each 9-byte palette entry as the PS2'sMergePalettedoes, red output in the texture's red. The finish key differs from the PS2's:FUN_004a94c0takes the luminance asdp3 r0, t0, t0(the colour dotted with itself, saturated, where the PS2 weights 38, 75 and 15 of 128), maps it through the same select palette (rebuilt when the finish amount or select changes:(i / 255 − (1 − amount)) / amount, then(1 − select) x + select, times 255) and writes half of it into the frame's alpha (mov_d2 r0.a, t1.a); after the finish blurFUN_004a7430blends the palette set 3 picture over the frame by that alpha (source alpha, inverse source alpha). The PS2 reads its key with 0x80 as 1.0, up to twice the curved picture's difference, where the PC's blend stops at a half. From the PC installationpostfilter.hlslnow keys and blends the PC's way (Pass.z1, set whenPcDataActive()); the disc keeps the PS2's. The PC also takes the curved picture from a blur level of the frame (0x108, a low-resolution copy); the port curves its half-size copy. Blurring the curved picture as well was tried and changed the sky by 2.
The bloom was compared too: the PC weights each blur tap by ((amount × 128 − 64) × 0.8 × level gain + 64) / 255 (FUN_004a6c40, four taps a pass), about 0.85 a pass for M00's amount 0.4, where the port's PS2 blur multiplies by 0.8 a pass; left as it is then, and followed since with the PC's blur (below).
The blurs (M13's funeral, 26 November 2026). M13 starts at the funeral with the credits over a blurred view: the depth blend with a depth blur of about 0.58 (OPENBLOOD_TRACE_POSTFILTER=1), the bloom (8 entries, amount 0.003 to 0.14) and the curves. On the real PC (pc-m13-b.png) the people, the coffin and the window bars are recognisable; the port's PC version smeared them. All four of ZPostFilterWintelD3D's blurs (the bloom FUN_004aab10, the depth blend FUN_004aad40, the last-frame blend FUN_004ab500, the finish FUN_004ab720) go through one routine, FUN_004aaa80 (PC 0x4aaa80), with the record's blur (PC +0x74, +0x10, +0x14, +0x38: the PS2 ZPostFilter fields in the same order) times 3.7999 (PC 0x764d0c):
- The blur textures (+0xfc, +0x100 and +0x104) are half the frame's size (
AllocateDeviceBuffers, PC 0x4a5bf0:0x1b8 >> 1by0x1bc >> 1, A8R8G8B8), so half the window's: 512 × 384 at 1,024 × 768.FUN_004aaa80copies the source into the first (FUN_004a6c40with level −1) and callsFUN_004aa910(0, amount). - A pass (
FUN_004a6c40(level, a, b), both clamped to 0..1) draws the whole texture into the other one with four taps at (±d, ±d) texels, d = a × 2^(level + 1) (a × 2^level when the target is already the third texture), each tap weighted by(bloom × b × 0.8 + 64) / 255, where bloom is the signed byteamount × 128 − 64thatFUN_004aab10stores at +0x1ac for the bloom and clears after it (0 for the other blurs, so four taps of 64/255). FUN_004aa910(level, amount): an amount up to 1 is one pass of d = amount × 2^level into the third texture, copied back into texturelevel & 1, which becomes the result (+0x108); above 1, with a = amount − 1, a pass of d = min(a, 1) × 2^(level + 1), the next level with a, and a pass of d = min(a, 1) × 2^(level + 2). The passes ping-pong between the two textures, so when the deepest level is odd the result texture misses the last pass back up.
The PS2's blur, which the port drew from both data sets, is a Gaussian of the PS2's 256 × 224 half picture (BlurSigma: sqrt(1.14 × (4^level − 1)) half-picture texels, the level growing by 1 every 0.25 of the amount). In texels the two are close (M13's 0.577: about 4.8 texels on the PC, 5.2 on the PS2), but the PC's texels are pixels of a half-size window, so at 1,024 × 768 its blur is half as wide as the PS2's scaled to the window (about 10 window pixels against 21 for M13). From the PC installation (PcDataActive()), PostBlurPc in postfiltersdl.cpp now runs the PC's chain: the same recursion, reduced to the list of passes that reach the result texture, each pass drawn by the postfilter program's four-tap mode (MODE_BLUR_PC) with the PC's offsets and weights. The offsets are in pixels of a half-size window, times the render scale (the target's height over the picture's height in window pixels). OPENBLOOD_PS2_BLUR=1 keeps the PS2 blur from the PC installation, for comparisons. Because the bloom goes through the same routine, its strength now follows the PC's tap weights: four taps of ((amount × 128 − 64) × 0.8 × b + 64) / 255 a pass instead of the PS2's (2 × amount) a pass, so a faint bloom (M13's amount 0.04: about 0.85 a pass on the PC, 0.08 on the PS2) is much stronger, as on the PC.
The PS2 blur in the port also had a bug of its own, in both versions: it stepped one PS2 half-picture texel (1/256 of the width), which is two texels of the port's half textures at 1,024 × 768, so every other column and row was skipped and a fine grid of stripes lay over a blurred picture (M13 from the disc, below 47's feet: the mean difference between horizontal neighbours fell from 0.42 to 0.31 with the fix, the vertical from 0.52 to 0.47, and the grid means did not change). It now steps one texel of the texture it blurs, wider only where the 48 taps run out, with the same width as before.
Measured at M13's start (1,024 × 768, frame 1,200; the credits scroll, so text regions differ): the mean difference between horizontal neighbours, a measure of sharpness, in the lower right (700..1000, 420..720) is 0.62 on the PC, 0.37 in the port before and 0.55 now; in the upper left (20..320, 300..500) 0.53, 0.22 and 0.31. The upper left, the window bars against the sky, is still softer than the PC's: the PC's depth blend (its own pixel shader with the depth texture, FUN_004aad40 from PC 0x4aaf76) may key that depth differently; not followed. The 4 × 4 grid of mean colours moved from 17.2 to 15.2 average luma difference from the PC; the port's picture is still about 20 darker than the PC's in the upper half (the window and the sky).
Over the 13 missions' start views against the real PC (build/pc-real/levels, frame 2,000, the 4 × 4 grid's mean luma difference, before (tip 9b710daf2) and after this change and the blended windows): M00 6.8 to 6.3, M01 12.0 to 12.0, M02 6.2 to 4.8, M03 3.6 to 3.5, M04 7.4 to 7.5, M05 10.5 to 10.4, M06 5.0 to 5.1, M08 4.9 to 4.6, M09 12.8 to 12.8, M10 1.9 to 2.5, M11 3.4 to 2.9, M12 2.5 to 2.9, M13 18.1 to 18.0 (its credits scroll differently, and its picture is darker than the PC's). The PC's bloom weights brighten the bloom lists' lights and skies by up to 4 (M10's upper left, M12's windows), which moves M10 and M12 slightly away from the PC in the grid; their views were not examined further. Scripts and captures: build/post/ in the hud worktree (portall.sh, grid.ps1, levels/port-r10/, side-*-r10.png).
Measured at M00's start (the view of Compared with the real PC game, 1,024 × 768, frame 2,000, region means R G B; the port's view is framed a little differently, so the regions hold slightly different scenery; build/grade/ in the grade worktree):
| Region (pixels) | Real PC | Port before | Fog flag and colour | Fog and the PC finish (now) |
|---|---|---|---|---|
| sky right of the hotel (880–1010, 90–200) | 248 244 223 | 205 206 183 | 247 245 230 | 226 219 181 |
| sky top left (230–380, 70–120) | 231 225 188 | 239 235 216 | 219 211 175 | |
| sky lower right (950–1020, 250–350) | 243 235 204 | 245 243 225 | 227 219 181 | |
| hotel wall (560–700, 290–350) | 47 41 27 | 40 43 35 | 49 43 28 | 48 42 28 |
| right turret roof (790–830, 140–200) | 159 155 142 | 179 167 138 | 143 135 111 | |
| whole frame | 99 94 76 | 81 83 70 | 107 101 84 | 99 92 71 |
Grouped by brightness, the real PC's picture has red 4 to 14 above green and green 10 to 42 above blue in every band (a sepia that hardly depends on the scene's own colours); the port before had red at or below green in the dark half (−1.7 to 0.3 for bands up to 64) and green only 5 to 24 above blue. Now the bands agree within a few units: 192 to 223 is (8.7, 39.3) against the PC's (6.9, 39.8), 160 to 191 (12.1, 41.8) against (13.5, 41.9). With the PS2's finish key the dark roofs against the sky turned golden (the blurred key reaches them and the PS2 blend doubles it) and the sky held more blue; with the PC's they stay dark, as on the PC. The sky is still about 15 below the PC's: the port's sky before the grade is (200, 177, 153) on average and the PC's is not known (analysis of the PC executable); the additive cloud and sun layers or the low-resolution curved picture are the candidates.
Other missions, from the PC installation at frame 1,900 of the sweep below (whole-frame means, before and after): only the missions with a finish pass or a fog colour that is not grey change. M06's start (finish amount 0.91, select 0.52) changes most: with the PS2's key the snow, the lights and the walls burned out to white (172 163 143); with the PC's the snow and the garlands keep their detail (119 107 97). The PC game was not captured there, so this rests on the PC code; a reference view of M06's start would confirm it. M03 (87 88 72 to 89 90 75), M05, M07, M09 and M11 (59 60 42 to 63 64 47) change by 2 to 5; M01, M02, M04, M10 and M12 are the same (M08 was captured at different moments of its loading and is not compared).
How it was found: OPENBLOOD_NO_POSTFILTER=1 draws the frame without the bloom and the grade; applying the dumped palette set 0 to that frame offline gave the port's grade exactly, and gave the PC's colours only for a grey input (grey 230 gives (248, 247, 222), the PC sky; grey 40 gives (47, 45, 34), the PC wall). The frame before the grade had a blue sky and bluish shadows where the textures are grey, which led to the fog.
The disc. The disc's draws read the room colour the same way, so the port's disc fog has red and blue exchanged as well (M00: blue-grey where the GS draws the scene's brown 0x7d, 0x62, 0x43). Reading it in the GS order on the disc as well (a test build only) turns M00's hotel wall from (52, 54, 43) to (61, 54, 36) and the frame from (94, 91, 72) to (99, 91, 69): the same sepia shift, with the sky, which has its own fog switch on the disc, unchanged at (243, 239, 209). On 25 November 2026 the owner chose to fix it for the disc too: GsRoomFogColor() now returns the GS order from both data sets, and the disc's M00 shows the scene's brown fog (build/pc-real/disc-m00-fix/).
Surfaces¶
The PC draws its surfaces with D3D9 materials (.MAT, mat.md) and .fx effects; the port draws the PS2 renderer's records. Four kinds of surface had no working PS2 counterpart in the converted data: water, the M12 toilet water, scatter fields and bump-mapped surfaces. Each is now converted so that the PS2 engine and the port's existing draw code handle it; only where that cannot give the PC's look does the port add a path of its own, and that path runs in PC-data mode only (PcDataActive()). PS2-disc rendering does not change: deterministic captures (OPENBLOOD_DETERMINISTIC=1) of M00 and of the M10 pool from the disc are identical pixel for pixel before and after.
Water¶
On the PS2 a water patch draws a small environment texture (Reflection_10#Back_a, Reflection_06_FX_H3#Reflection_d, Reflection_09#Reflection_a, Reflection_M10_01#Diffuse_a) in sphere-map coordinates, then the refraction of the frame. Those textures are not in the PC data (the PC scenes have the cube maps they were cut from, not the PS2 faces), and the PC does not draw water that way. WaterSurface.fx (technique AmbientHQ_VS20_PS20, the WaterSurface class's "Ambient" pass) mixes:
- a planar reflection:
FUN_004b8a50renders the scene mirrored in the water plane intomapReflection2D, as it does for mirrors (ZRenderEntryReflectorD3D, PC 0x4b7710, first named here, has no caller; mat.md "Other classes"); - the refraction of the frame behind the water (
mapRefraction2D), whose alpha the "RefractionMask" technique sets to 1 on the water's own pixels, so a distorted sample that lands on something above the water falls back to the undistorted one; - a bump normal: the average of four samples of
mapNormalat UVs scrolled bygm_vScrollPosition(uv + (t.x, 0),uv.yx + (t.x, 0),(uv − (0, 1.2 t.y)) × 1.03and the same onuv.yx), timesv4BumpScale, with z rebuilt. The diffuse map is never sampled; lerp(refraction × gm_vRefraction2DColor, reflection × gm_vReflection2DColor + specular, Fresnel), withFresnel = lerp(gm_vFresnelMin, gm_vFresnelMax, (1 − |bump · eye|)^gm_vFresnelPow)and the specularv4SpecularColor × (half · bump)^v4SpecularPower × vSpecularLevel. A material without the reflection pass draws the refraction alone (and no specular); one without refraction drawsreflection × Fresnel(the M12 toilets).
The PS2 engine has the same planar reflection, unused on the disc: a water record with lTextureId 0xffff goes into a mirror group (ZOldDrawBase::GeomCreate with g_bUseTrueReflections, group m_lGroupID + 1), and ZOldViewBase gathers a ZOldDrawIdListMirrorGroup sub-list of the view mirrored in the patch's plane (GetMirrorBound, ZOldDrawIdListMirror::UpdateCamera). So:
- Converter (
EncodeWaterinpcprims.cpp): a patch whose material hasReflection2DEnabledgets texture 0xffff and the projective flag (m_lFlags1), the others no texture; the refraction flag (2) followsRefraction2DEnabled. The PC-only terms (normal map, bump scale, specular colour, power and level, Fresnel power, scroll speed, the object's UV rectangle, and the colours and scales as floats) go into anSPcWaterExtension(pcwater.h, magicPCWS) appended to the 0xc4-byteSPrimWaterPatch. No PS2 code reads pastSPrimWaterPatch. - Port (
zoldviewwatersdl.cpp,zoldviewmirrorsdl.cpp,water.hlsl):DrawMirrorsrecords each mirror group's sub-list of the frame (WaterRecordMirrorGroup), asZOldViewPS2::Drawkeepsm_pMirrorStartIndicesforDrawWaterMirrors. When a water entry carries the PC extension,DrawWaterPccopies the frame (the refraction), writes the RefractionMask into the copy's alpha (an alpha clear over the target, then the visible patch grids with alpha 1), and for each mirror group draws the reflected view across the whole view, as the PC'smapReflection2Dcovers it: a pass into the reflection target (GpuReflectTarget) with a depth target of its own (GpuReflectDepthTarget,DrawListAddTargetPass), both cleared, the camera's background colour filled in (the PC's clear, below), and the sub-list drawn with the mirrored camera fromUpdateCameraSpaceand a clip plane at the water (DrawWaterMirrorGroup,DrawWaterReflectedView); the next pass returns to the frame. The frame and its depth are not touched. See Full-view reflection. Each patch is then drawn opaque with depth by thewaterpcprogram (VSWaterPc/PSWaterPc, samplers: frame copy, reflection, normal map) on the grid the PS2 path uses (WaterBuildGrid: the four sine waves and Hitman's ripples), with the wave normal's slope in the vertex colour, the normal map's UVs from the UV rectangle and the light direction from the geom's lights (LightsDot3Vertexat the patch centre); the eye and half vectors are computed per vertex, as the PC's vs_1_1 program does. A group whose reflected view is not visible (the camera below the plane, or the group not gathered this frame) reflects the camera's background colour, which is all the PC's cleared target would hold. - The draw list now binds up to eight extra textures for a call (
DrawListSetExtraTextures) and allows 64 passes a frame.
Full-view reflection¶
Until 25 November 2026 the reflected view was drawn as DrawMirror draws a mirror: a stencil mask of the group's patch grids filled with the room's fog colour, depth cleared inside it, the sub-list drawn into the frame with the stencil test, the frame copied to the reflection target and the patches' depth restored. The reflection therefore existed only in the water's own pixels. PSWaterPc samples it at the pixel's screen position plus the bump normal times the reflection scale, so near a patch's edge (the far side of M05's pool, the water's edge along M00's pier) the offset reached past the mask and sampled the unreflected frame: floor tiles and walls showed through the reflection in broken patches. The PC renders the planar reflection into a target that covers the whole view (FUN_004b8a50; WaterSurface.fx samples tex2D(samplerReflection2D, vCoords + vReflectOffset) with vCoords the projected position), so its offsets land on reflected scenery.
The port now does the same. The draw list's passes gained an optional depth target (SDrawPassSDL::pDepthTarget, bClearDepth; 0 is the frame's depth), which the reflection pass uses so the frame's depth stays as it was. Nothing else changes: the same sub-list, the same mirrored camera and clip plane, the same shader. OPENBLOOD_WATER_STENCIL_REFLECTION=1 keeps the stencil version, for comparisons.
Checked with captures before and after (OPENBLOOD_SCENEFX_AT, port/engine/debug/_sdl/scenefxtestsdl.cpp, which places 47 and sets the camera's yaw and pitch):
- M05's indoor pool (
1020,0,2560,0,0.45): the reflection of the far wall and door no longer breaks into pale floor tiles at the pool's far edge. - M00 at the start: the sea along the pier looks the same; its bump offsets are small against the size of the patches.
- M12's toilets (
6480,-440,150,0,1.2): unchanged. Their material has reflection without refraction, which the PC draws aslerp(0, reflection, Fresnel); looking down into the bowl the Fresnel term is at its minimum, so the water is black on the PC too. - M09's bayou: unchanged, its material has refraction only (no mirror group).
Cost: the reflected view is now filled across the whole view instead of only the water's pixels; the draw calls are the same. M00 from its start, 1,300 deterministic frames (OPENBLOOD_DETERMINISTIC=1, wall time including the load) took 7.21 s and 7.18 s with the full view against 7.31 s and 7.26 s with OPENBLOOD_WATER_STENCIL_REFLECTION=1: no measurable difference on this machine. All 13 missions ran 2,000 frames from the PC installation and exited 0 (25 November 2026).
Reflected rooms and the real PC game¶
The real PC game at M00's start (Compared with the real PC game) has dark brown water that shows the piles; the port's was grey-blue, flat in the foreground, with a bright band along the horizon. Three differences from the PC were found and fixed (26 November 2026), all in PC-data mode only.
Only one of the two sea tiles had a reflection. M00's start view shows two of the four sea tiles, Waterplane05 at (−1,580, −496, 357) and at (−4,734, −500, 1,052), 7 × 7 quads of 2,143 units each, overlapping, 4 units apart in height. The PS2 engine gives them mirror groups 1 and 2 (m_lGroupID + 1). OPENBLOOD_TRACE_WATER=1 showed group 2 drawn with 29 entries (sky dome, sun, clouds, fog plane, piles) and group 1, the upper tile and so most of the visible water, with no sub-list at all, so it reflected the flat fill colour. The reason: ZOldDrawIdListMirror::UpdateCamera starts the reflected view's room search (ZCameraSpace::m_vCameraStartPoint, read by LocateRoomsAndExits through GetInnerRoomsLst) at the centre of the group's bound. Group 1's centre is (8,985, −496, 8,190), out at sea beyond every room, so no room is found and nothing is gathered; group 2's centre (236, −500, −7,904) is inside one. The PS2's mirror groups are pools inside one room and never meet this. The PC renders a reflected view for every reflector (FUN_004b8a50, FUN_004b8290). Tried first: starting the search at the point of the bound nearest the camera. Group 1 then gathered 98 entries but group 2 lost its own, and the backdrop was not reached. Tried next: gathering the whole scene tree with the clip planes alone (the bDisableExits path of FindVisibleAndAddResourcesToView). That enters every geom of the level and stops in ZOldDrawBase::OnGeomNotify when the draw ids run out (frame 1). What the port does now (WaterMirrorRooms in viewoverridesdl.cpp): the port's ZOldViewBase::UpdateCamera keeps the rooms of the camera's own view, and a PC-data water group's reflected view enters each of them as a room the camera is inside, without exits, so its geoms are culled by the mirrored camera's planes only. Group 1 now draws 366 entries and group 2 86 (the backdrop room M00__Backdrop included: the PC's gather, FUN_0047c520, adds the rooms' attached backdrop rooms, flag +0x100fc set by FUN_0047bb00). OPENBLOOD_WATER_ENGINE_ROOMS=1 keeps the engine's search, for comparisons.
The reflection target's clear colour. FUN_004b8a50 clears mapReflection2D (and its depth) with FUN_004b1bb0(…, 3, BackCol | 0xff000000), where BackCol is ZCAMERA +0x54, the camera's background colour, the frame's own clear colour. The port filled the target with the root's fog colour (grey-blue). M00's camera background is 0x7d6243, a brown. WaterReflectionClearColor (zoldviewmirrorsdl.cpp) now gives the camera's colour, for the fill and for a group with no reflected view.
Per-vertex eye and half vectors. AmbientHQ_VS20 is compiled for vs_1_1: vEyeDirTS (from v4EyePosObject − IN.v4Position, the flat grid position without the waves), vLightDirTS and vHalfDirTS = L + E are computed per vertex in the tangent space (1, 0, 0), (0, 0, 1) and the unnormalised wave normal, and the pixel shader gets them interpolated and normalises them. PSWaterPc computed the eye per pixel. VSWaterPc now does it per vertex, with the eye and the patch's surface height in SDrawUniformsSDL::Material[0] and the light direction in Material[1]. On M00's coarse grid this changes the Fresnel term over whole quads; in M05's pool (small quads) the difference is not visible.
Checked on the way: the M00 sea material (Waterplane05; the trace now prints every term of the PC extension) has bump scale 0.235, specular (1, 0.95, 0.86) power 100 level 2.4, Fresnel 0 to 1 power 10, reflection scale (0.4, 0.4) and refraction scale (0.7, 0.7) (both components, so the offset is two-dimensional on the PC too), reflection colour 0.976 and refraction colour 1, no fog (FENA off). The objects the PC reflects are the ones whose destination has bit 0x08 or 0x10 (FUN_004b18c0 with mask 0x18 reads the render entry's +0xd, which FUN_00476b70 sets from the prim's byte 0); the converter's SKIP_MIRROR_VIEW for a destination without DD_MIRROR matches that, and no M00 object has 0x10. M00's destinations: 0x89 (mirror) on 5,466 sub-objects, 0x81 on 2,333, 0x8b, 0x82 and 0x01 on a few hundred. The hotel's walls, roofs and floors (So00A_*, So00B_House*) are 0x81, so neither the PC nor the port reflects them; the piles, the pier's concrete cores and the backdrop are reflected.
OPENBLOOD_WATER_DEBUG=1 to 4 shows one term of PSWaterPc without fog: the refraction, the reflection with the specular, the Fresnel term, and the fog factor (red) with the eye cosine (green).
Measured at M00's start (the reference's view, version=pc, 1,024 × 768; region means R G B, PC reference against the port; the port's grade is still its own, so compare against the hotel wall in the same frame):
| Region | PC | Port before | Port after |
|---|---|---|---|
| Water right of 47 (700–1000, 560–640) | 43 38 24 | 39 41 32 | 35 37 28 |
| Water under the hotel (560–900, 450–540) | 35 30 18 | 56 62 51 | 54 56 44 |
| Water bottom left (0–330, 700–768) | 45 38 24 | 38 37 27 | 38 37 27 |
| Horizon at the right (940–1020, 420–450) | 210 205 180 | 197 200 187 | 205 207 192 |
| Hotel wall (560–760, 240–340) | 47 41 27 | 44 46 37 | 44 46 37 |
The reflection includes the piles and pier. The intended reflected-view fog comes from PROPERTY_REFLECTION2D and is applied in DrawWaterReflectedView. The earlier under-hotel pixel comparison predates that change.
The seam (26 November 2026). ZOldDrawIdListMirror::UpdateCameraSpace (PS2 0x26febc) puts the four planes of m_Planes, the group's bound as the mirrored camera sees it, in place of the view's side clip planes (clip planes 2 to 5). With the view's rooms entered whole (above), that culling was the only thing that differed between the two tiles' reflected views, and where the tiles overlap under the hotel each drew its own: the edge between them was the edge between two gathers. A PC-data water group now keeps the view's own side planes (in camera space they are the same for the mirrored camera, whose frustum is the view's reflected), so both tiles gather the same scenery (UpdateCamera in viewoverridesdl.cpp; OPENBLOOD_WATER_BOUND_PLANES=1 keeps the bound planes). The edge is gone, and the water under the hotel now reflects the piles under the hotel's far side instead of the sky beside them: (74, 64, 42) with the bound planes, (58, 50, 31) without, against the PC's (35, 30, 18); the water right of 47 is (46, 40, 26) against (43, 38, 24). Still lighter than the PC's there: the sky at the right edge of that region, past the piles. Crops: build/light/m00-water.png in the matfx worktree (the PC, the bound planes, the view's planes).
The PS2 version does not change: deterministic captures (version=ps2, OPENBLOOD_DETERMINISTIC=1) of M00 from the disc (frames 0 to 900) and of M05's indoor pool (OPENBLOOD_SCENEFX_AT=1020,0,2560,0,0.45, frames 0 to 600) are identical pixel for pixel to the build before. M05's pool from the PC installation looks the same as before (its quads are small, so the per-vertex vectors change little). All 13 missions ran 2,000 frames from the PC installation (version=pc) and from the disc and exited 0.
The refraction mask and the Refraction pass¶
Two port bugs in PC-data mode, found against the real PC's start views of M02 and M09 (27 November 2026, scenefx worktree build/r11/). The disc does not change: both paths run for PC water and PC Glass only.
The mask was 1 everywhere. DrawWaterPc and the Glass run (DrawPcMaterialStrips) clear the frame copy's alpha with DrawListFillRect before the RefractionMask pass writes 1 on their own pixels, and PSWaterPc takes the distorted sample only where its alpha is above 0.9. The fill gave its vertices the alpha 0x80, which general.hlsl scales to 1.0 (GS_COLOR_SCALE), so the "clear" wrote 1 and every distorted sample was taken. M02's sea (Water_plane_02, _05, _07 at y −4,090, flat, refraction only with a scale of 0.95) then pulled the bridge, its snow and the railings' lower boards into the water in wavy blots, and drew water over those boards. With OPENBLOOD_WATER_DEBUG=3 (the Fresnel term, a flat colour) the water's own pixels end cleanly at the railings, which is how the cause was told from a depth problem; lowering the water by 200 units changed nothing. DrawListFillRect now takes the vertex alpha (default 0x80) and both masks clear with 0. The railings' edges are now as clean as the PC's (c-m02-mask.png: the PC, round 10's port and this one).
The water was drawn before the blended surfaces. The PC copies mapRefraction2D after the opaque Ambient pass (in which the blended objects are drawn too), the shadows and the lights, and draws the water in the Refraction pass after that (mat.md, "Water surface materials"). The PS2 sorts a water patch with the blended strips (texture priority 19, CalcTexturePrioity), so the blended PC-material surfaces sorted after it (in M09: burnt walls, the inner terrain ring, parts of the boats, all dot3 records with a TRANS material) were missing from the copy, and the ones under the water were hidden by its depth. M09's bayou showed a reddish bed with black blots under the water where the PC shows the frame behind it unchanged: without the water (OPENBLOOD_HIDE_ENTRY=Water_plane) the port's frame matched the PC within 2 levels in the regions below. ZOldViewSDL::Draw (zoldviewsdl.cpp) now keeps each run of PC water entries (WaterPcRunLength) and draws it at the end of its camera's list: before the first sprite entry (the particles, texture priority 22, which the PC draws after its water: drawn before it, a cigarette's smoke and a torch flame in front of the water were refracted into dark smears), before the post filter, before the next camera's entries and before a list break. OPENBLOOD_PC_WATER_IN_SORT=1 draws them in the PS2's place, for comparisons.
Measured at M09's start (launcher mission 8, frame 2,400 against pc-m09-b.png; region means R G B):
| Region | PC | Round 10 (port-r4) |
Mask fix only | Mask fix and the water drawn last |
|---|---|---|---|---|
| Left of the cage (0..230, 100..560) | 34 29 24 | 34 25 21 | 41 32 27 | 31 26 22 |
| The bed beyond the boats (330..450, 170..260) | 90 83 79 | 81 71 71 | 91 83 79 | |
| The boats and the water around them (210..1024, 180..460) | 38 36 34 | 39 36 34 | 39 37 35 |
The two runs on the right include the boats' lighting (Rigid meshes); the left region's round-10 mean is close by accident (a reddish bed and black blots average out). OPENBLOOD_TRACE_WATER now also logs each patch's offset (m_vPos), axis scale and four waves.
Reflection fog uses the scene’s reflection material. Compare the hotel and sky with the same camera and weather before attributing a difference to the mask.
M12's toilets keep their water in the same header as three meshes, so the patch is not a chain root. ZEngineDataBase sizes ZWaterManager from the geoms whose root prim is a water patch, made no manager in M12, and the toilets got no patch. In PC-data mode WaterEnsureManager (from ZOldDrawSDL::UpdateDynamic and WaterPatchCreate, once per level by MeshCacheGeneration) counts every water patch in every ZSTDOBJ chain and makes a manager of that size when the engine's is smaller and still empty (6 patches in M12).
Water by scene (PC folders): M00 (the four sea tiles; reflection and refraction), M01 (the river at night; both), M02 (the backdrop sea, the pool and the jacuzzi; refraction only), M04 (jacuzzi and pool; both), M05 (two pools; both), M08 (the Mississippi; refraction only), M09 (the bayou; refraction only), M10 (the pool and the fountain; refraction only), M11 (the shark tank; refraction only), M12 (the toilets; reflection only). OPENBLOOD_TRACE_WATER=1 logs each patch as it is created, the geoms whose chains hold water, and every 100 frames which mirror groups drew a reflection.
Water in play¶
This section applies to both modes. The pc_fixes work reported that the port's ZWaterManager never registered a water patch, so ZHitman3::m_bIsInWater (PS2 0xb3c, PC 0xb8c) was never set and the test of the sniper-case rule had to set it by hand. That report is wrong. The port registers patches as the PS2 does. The test failed because M09 on the disc has no water patch the game ever draws, and that is also true on the PS2.
How a patch is registered, on the PS2 and in the port:
ZEngineDataBase(enginedatabase.cpp, afterClearSaveLoadFlags) counts theZSTDOBJgeoms whose root prim is a water patch (type 11) and makes aZWaterManagerwith that many slots. With no such geom there is no manager.- A patch enters the manager when its geom enters a view.
ZOldViewBase::AllocatePrimInstances(0x27ca54; the port uses its own copy inviewoverridesdl.cpp) creates the prim instance. On the PS2,ZOldDrawPS2::PrimInstanceCreate(0x29e13c) then callsPrimInstanceCreateWaterPatch(0x2a3e78), which callsZWaterManager::AllocWaterPatch(0x13ee38). In the port,ZOldDrawSDL::PrimInstanceCreatecallsWaterPatchCreate(zoldviewwatersdl.cpp), which fills theSWaterPatchInstthe same way. The patch leaves the manager inPrimInstanceFreethroughFreeWaterPatch(0x13ee88), when the instance is freed after the geom leaves view. So the manager only holds the patches that are drawn now or were drawn recently, on both platforms. ZHitman3::UpdateObjectVisibleFlags(0x329ba8) runs the test while 47 moves (PLAYER_STATUS_MASK_Moving). It runs once perg_wfInterval1(0.2 s) when he runs and once perg_wfInterval2(0.8 s) when he walks. It takes his left toe's root point and asksZWaterManager::CheckInside(0x13eef4), which tests the point against each patch's x–z rectangle and ignores rotation. If the toe is below the patch'sfYPos, the function adds a ripple (AddDefaultRipple, amplitude 8 when running and 6 when walking) and setsm_bIsInWater. Otherwise it clears the flag. The flag keeps its value while 47 stands still. On the PS2 nothing else reads the flag. The PC'sCanUnpackSniper(0x5ee730) reads it, and so does the port withpc_fixes.- The PC registers its patches in the D3D renderer instead. The
ZRenderObjectInstanceWaterPatchD3Dconstructor (0x4a17d0,renderobjectwaterpatchd3d.cpp) makes a 256-slot manager on first use (0x4728c0 callsInitManager(0x100)) and allocates the patch. It takes the position fromGetMatPosplusm_vPos, and the segment size from the size divided by the segment count, without the axis scale the PS2 applies.UpdateObjectVisibleFlagsis the same function on the PC (0x5f7580).
Why M09 has no water on the disc. The geoms the disc's M09 draws as the bayou, So09P_WaterPatch_*, are strips (prim type 0) despite their name. Its three real water patches, WorldColi_SurfaceWater_1a and two WorldColi_SurfaceWater_1b, carry control bit 0x200 (BASEGEOM_Bit9) from the scene's lGeomAndGroupCon. ZBaseGeom::AttachToRoomsDrawLists (0x11b264) returns early for that bit, and nothing clears it at run time. These geoms are never in a room's draw list, so they are never drawn and never registered. The manager keeps its three empty slots, and m_bIsInWater stays false in the bayou on the PS2 as well. Their rectangles would not fit the bayou anyway: all three cover z ≥ 0 only, including the one whose geom stands at z = −5000. In PC data the bayou is twelve drawn patches, Water_plane_02 to 07 and Water_plane_02_PC to 07_PC (y −35, 10,000 × 10,000 each), so wading there works in PC-data mode.
Water patches on the disc, as OPENBLOOD_PCFIXES_TEST=water lists them at load (scene folders):
| Scene | Patches (geom, surface height) | Drawn |
|---|---|---|
| M00, M03, M06, M08, M12, M13 | none (no manager) | |
| M01 | WaterSurface_01 twice and WaterSurface_02, y −4200 |
yes |
| M02 | WaterSurface_01 (two, y 93 and −25), WaterSurface (y 93), Water_Jazucci_PS2 (y −22) |
yes |
| M04 | WaterSurface (y −316), Water_Jazucci_PS03 and Water_Jazucci_PS2 (y −5) |
yes |
| M05 | two WaterSurface (the indoor pool at y −9, and y −40) |
yes |
| M09 | WorldColi_SurfaceWater_1a, _1b (two), y −30 |
no (bit 0x200) |
| M10 | WaterSurface_01_PS2 to 03_PS2 (y −15 and −47) |
yes |
| M11 | Water_Surface_01 (y −1264) |
yes |
No disc patch sits inside a chain; every one is its chain's root. WaterEnsureManager (above) runs in PC-data mode only and changes nothing on the disc. In PC data M09's engine count already gives 12 slots. It is needed only where a patch is not a root, as in M12. No code change was needed. The test scenario no longer sets the flag by hand.
Verified with OPENBLOOD_PCFIXES_TEST=water, which now waits for the game to set the flag itself and then asks CanUnpackSniper with the setting on and off:
| Run | Result |
|---|---|
Disc, M05 indoor pool (OPENBLOOD_PCFIXES_WATER_AT=850,0,2000, walking) |
the patch registered as the pool came into view; flag set by the game at the scenario's frame 370, soon after 47 started walking; 3 to 4 ripples on the patch; CanUnpackSniper 0 with pc_fixes, 1 without |
| PC data, same place | the same |
PC data, M09 bayou (-600,20,-5500, walking into the water) |
8 to 10 of the 12 patches registered; flag set when the toe passed below y −35; 3 to 4 ripples; CanUnpackSniper 0 with pc_fixes, 1 without |
Disc, M09 (-600,20,-5500 and -5000,100,4000) |
0 of 3 patches registered, flag never set (as on the PS2) |
The water manager plays no sound. Other water behaviour does not use it. Bodies, ragdolls and thrown items use ZWaterBox and ZWaterBoxManager (waterbox.cpp, ragdoll.cpp, particle.cpp). A water box sends WaterBoxEnter and WaterBoxLeave, which set ZHM3Actor::m_bIsInWater (0x8c1, a different member). The ragdoll's bWaterImpact drives the splash. Footstep sounds follow the floor's material. ZWaterManager::FrameUpdate takes 0.1 off each ripple's amplitude once per rendered frame on the PS2; the port steps it per 1/30 s, so ripples last as long at any frame rate (frame-rate.md).
Scatter¶
A scatter field (grass, undergrowth, leaves, backdrop trees: 361 in M01, M02, M04, M05, M08, M13 and the title scene) is a 0x80-byte PC object with float tile vertices where the PS2 has a 0xa0-byte SScatterHeader with byte-packed ones. The converter (EncodeScatter) writes the PS2 record at the header's handle with the tile grid packed right after it in 8 × 8 sub-grids, so the existing grass draw (zoldviewgrasssdl.cpp, after VU_GrassDraw) renders it unchanged; prm.md "Scatter" has the field map. The billboard size and the alpha reference come from the ScatterMaterial (ScatterWidth, ScatterHeight, ScatterRandomHeight, AREF), the colours from the object. OPENBLOOD_TRACE_SCATTER=1 logs each drawn field once.
Draw distance. The PS2's grass draw fades a field's billboards out beyond its fDrawDist (VU_GrassDraw; the port's GrassVertexColor). The PC never reads the PC object's draw distance: ZRenderObjectScatterD3D (PC 0x4a0430) puts every billboard of the field into one static vertex buffer when the field is created, ZRenderObjectInstanceScatterD3D (0x4a0230) draws all of it whenever scatter is enabled, and ScatterBillboard.fx has no fade. M08's backdrop trees (six Scatter_Plane fields 26,000 to 33,000 units west of the boat, draw distance 500) were therefore faded out completely and the hills behind the river were bare and black. The converter now writes 1e38 as the PS2 record's fDrawDist (the value the PC data uses for "no limit"), and the hills are covered in trees. OPENBLOOD_SCATTER_FADE=1 keeps the PC value. In M01 (190 fields) the start view changes in 576 of 691,200 pixels (distant grass), and 1,000 deterministic frames take 3.1 s against 3.5 s with the fade, within the timing's noise.
Opacity. M08's tree material (Backdrop/M08/Scatter_Trees, the only ScatterMaterial of the 68 archives whose opacity is not 1) has BMOD TRANS, OPAC 0.12, alpha test above 127. The opacity has no effect on the PC: the D3DFX material looks up the effect parameter v4Opacity (PC 0x495430, the handle at +0x40) and sets it to four copies of the opacity (0x496680), and that is its only use, and ScatterBillboard.fx never reads v4Opacity (its pixel shader returns tex2D(samplerDiffuse, uv) * float4(diffuse.rgb, 1)). The blend is source alpha over inverse source alpha (BlendSrc 5, BlendDst 6) with the texture's alpha, which is what the port's grass draw does. So the port does not carry the opacity over, and the earlier note that the PS2 record "has no field for it" does not describe a difference.
Alpha test (26 November 2026). The converter wrote the material's AREF unchanged into the PS2 record's lAlphaRef. The PS2's grass program modulates the texture alpha by a vertex alpha of 64 (VU_GrassDraw, vu-programs.md; the port's GRASS_GS_HALF), so a billboard's alpha reaches at most 127 and TEST compares that half with the reference (alpha GREATER, AFAIL FB_ONLY: the failing texels are still drawn, without depth). M08's trees (AREF 127) therefore passed nowhere: the backdrop wrote no depth at all, every texel was blended by the second pass, and the riverbank fire behind the trees, which is in the bloom list (OPENBLOOD_TRACE_POSTFILTER now lists its geoms), came through the canopy as a bright cloud after the bloom's blur. The PC tests the texture alpha itself (ScatterBillboard.fx: AlphaTestEnable, AlphaRef = AREF, AlphaFunc Greater) and discards what fails. The converter now writes half the reference (AREF >> 1, as MakeDrawSetup does for strips), and from a PC installation the grass draw leaves out the PS2's second pass (GrassFlush). The disc's records carry the same unhalved references (M01: 76, 127 and 191) and keep the PS2's two passes. Over the scene archives the references are 76 to 252 (M01 76, 127, 191, 229, 242; M04 252; M08 127). At M08's start the fire now glows under the trees as a band between the trunks, as on the PC (crops in the scenery worktree's build/scenery/: m08-fix1z.png, before m08-match.png). OPENBLOOD_TRACE_SCATTER also logs each field's material, alpha test, tint colours and mean vertex colour as it is converted.
Static shadows on characters¶
A character's light is scaled by the room's static shadow data at its root (ComputeStaticShadowMultiplier, rendering.md). Dumped at load (OPENBLOOD_SCENEFX_TEST=shadowdata), the blocks of that data differ between the two data sets:
| Scene | Disc blocks by flags | PC blocks by flags |
|---|---|---|
| M00 (43 rooms, 16 with data) | 71 × 0x01 | 58 × 0x01, 32 × 0x19, 4 × 0x1d |
| M01 (79 rooms, 10 with data) | 46 × 0x01 | 40 × 0x01, 53 × 0x09, 8 × 0x0d, 53 × 0x19, 4 × 0x1d |
0x01 is the ordinary block both sample bilinearly from its one-bit grid. A block with flag 8 is read by the PS2 code as no shadow (SampleStaticShadowData sets the intensity to 0), and by the PC's sampler (PC 0x472b10) as no shadow too unless 0x10 is also set. Then it is a projected shadow: the PC does not darken the character but draws a shadow texture onto it. In PC-data mode the PS2 code therefore left characters fully lit in every projected shadow (in M00, for example, most of the shadow behind the palace, M00_Section_PalaceBack_Left_01, whose largest block covers 5,000 by 4,800 units). With pc_lighting (on by default in PC-data mode, Enhancements: PC lighting) the port does what the PC does, as below. The second round had approximated it by reading those blocks' grids as ordinary blocks, which darkened the whole character; that is gone.
The projection record¶
A projected block's bit grid (rounded up to four bytes; none with flag 4) is followed by a record of 0x54 bytes. The PC's binder (ZRenderBinderContextD3DFX, PC 0x491150) reads it into four effect parameters through PC 0x473520 (the record of projection i) and 0x473540 (its fade); the engine parameter table at PC 0x760fd8 (12-byte entries: kind, id, name; vStaticShadowColor is 0x38, m44StaticShadowProjectionMatrix 0x39) gives their names and ids:
| Offset | What | Effect parameter (id) |
|---|---|---|
| 0x00 | 4 × 4 matrix, row vectors: root (world) position to the shadow texture, divided by w (tex2Dproj) |
m44TextureProjectionMatrix (0x40), copied as it is |
| 0x40 | texture word: the scene texture's id in bits 0 to 15; bit 31 wraps along U and bit 30 along V instead of clamping (PC 0x492470 sets D3DSAMP_ADDRESSU and V); bit 29 selects the additive kind (below) |
mapTextureProjection2D (0x43) |
| 0x44 | the light's position, 3 floats | v4TextureProjectionLightPos (0x42), w = 1 |
| 0x50 | colour 0x00RRGGBB: the light left in the shadow | v4TextureProjectionColor (0x41) = colour / 255 × fade + (1 − fade), w = 1 |
In M00 all 36 projected blocks carry the colour 0x213030 and the light (−767941, 582982, 265326), a sun far above the sea, and one of three textures from a Projector folder: 0x81 Tree_shadow_06 (19 blocks; 256 × 256, mean 74), 0x82 Wheel_shadow_01 (the Ferris wheel, 11 blocks; 256 × 256, mean 84) and 0x83 LampPost_Shadow_01 (6 blocks; 256 × 128, mean 25). They are white where the shadow is, on black. The box centre of most blocks falls at the middle of its texture (u, v = 0.5, 0.5). Projected onto a block's floor, the textures follow its grid: the lamp-post block's grid holds a diagonal line of 25 cells and the texture's thin shadow falls on the cells beside it (OPENBLOOD_SCENEFX_GRIDART=1 draws it); for the wheel's 102 × 96 block, 82 % of the cells where the texture is in shadow are set in the grid as the port samples the texture, against 79 %, 77 % and 71 % with the texture mirrored in u, v or both. The grid is a coarser and wider mask than the texture: it says where a projection applies and the texture where the shadow falls. OPENBLOOD_SCENEFX_TEST=shadowdata logs all of this per block (port/engine/debug/_sdl/scenefxtestsdl.cpp) and OPENBLOOD_SCENEFX_DUMP=DIR writes the textures as BMPs.
Over the 13 missions (OPENBLOOD_SCENEFX_TEST=shadowdata in each, 25 November 2026) the PC data has projected blocks in eleven; M02 and M08 have none, and the disc none at all. Block flag 0x20 (0x39, 0x3d) marks exactly the 21 blocks whose word has bit 29, the additive kind; the sampler does not test it.
| Scene | Projected blocks | Texture words | Colours | Textures |
|---|---|---|---|---|
| M00 | 32 × 0x19, 4 × 0x1d | 0x81 × 19, 0x82 × 11, 0x83 × 6 | 0x213030 | Tree_shadow_06, Wheel_shadow_01, LampPost_Shadow_01 |
| M01 | 53 × 0x19, 4 × 0x1d | 0x81 × 30, 0x83 × 27 | 0x83969f | two PlantShadows_M01_01 (512 × 512) |
| M03 | 37 × 0x19, 5 × 0x1d | 0x81 × 28, 0x82 × 14 | 0x636353 × 41, 0 × 1 | Tree_shadow_03, Tree_shadow_08 |
| M04 | 55 × 0x19, 18 × 0x1d | 0x82 × 30, 0x83 × 43 | 0x53575e | Tree_shadow_03, Tree_shadow_02 |
| M05 | 1 × 0x19 | 0x81 | 0 | Tree_shadow_06 |
| M06 | 8 × 0x19 | 0x40000081 × 8 (wraps along V) | 0x422824 | Grid_Squares_01 |
| M09 | 62 × 0x19, 18 × 0x1d | 0x81 × 63, 0x82 × 17 | 0 × 22, 0x040c0c × 32, 0x061414 × 26 | Plants/_SHADOW/Tree_01, Plants/CatTails_01 |
| M10 | 34 × 0x19, 38 × 0x1d | 0x80 × 72 | 0 × 21, 0x636c77 × 32, 0x6e786e × 10, 0x37250d × 5, 0x303a3c × 4 | Tree_shadow_02 |
| M11 | 19 × 0x19, 7 × 0x1d, 1 × 0x39 | 0x81 × 11, 0xc0000082 × 15, 0xe0000083 × 1 (additive) | 0 × 19, 0x223545 × 5, two more | Tree_shadow_02, Fabric/Curtain_02, M11_projector_01 |
| M12 | 13 × 0x19, 1 × 0x1d, 12 × 0x39, 8 × 0x3d | 0x20000083 × 4, 0xe0000080 × 16 (additive), 0xc0000082 × 14 | 0 × 18, 0x4a4e50 × 13, two more | M12_WindowAdditive (two, 128 × 64), Window_04 |
| M13 | 31 × 0x19, 5 × 0x1d | 0x81 × 36 | 0x436580 | Branch_M13_02 |
In M12's halls the additive kind is the light of the windows: M12_WindowAdditive is white with a soft dark border and is tiled (both wrap bits), with the colour 0, so a character standing in it is brightened, by up to 1.75 times where his surface faces the light (0.3 + 0.45 at most).
How the PC uses it¶
- Sampling (PC 0x473100, called from
ComputeStaticShadowMultiplier, PC 0x473310, with the draw entry): every block at the character's root is read in order, through the room's grid of block lists as on the PS2. A projected block in whose box the root lies returns its record when its grid is in shadow there (flag 4: anywhere in its box) and no earlier block has given any shadow; PC 0x473030 then adds it to the draw entry. The grid test has a slip: PC 0x472cf6 tests the two top bits of the word 0x40 bytes past the grid counted from the block's own 32-byte entry in the block array instead of from its data, so whether the grid is read at all depends on whatever lies there (another block's coordinates or data offset); when neither bit is set the whole box counts as in shadow. Of M00's 32 blocks with a grid, 19 are read through it and 13 as their whole box. - The draw entry's projections (PC entry +0x04 to +0x24: four record pointers, the count, four fades). A record already in the list fades towards 1; a new one is appended (no more than four) with a fade of 1 when the entry's multiplier has never been computed (byte 0xff) and of 0.001 otherwise; every projection not met this frame fades towards 0. The step is twice the frame time (PC 0x472a10 reads
g_pSysInterface+0x50, the PC'sDeltaFrameTime), so a shadow fades in or out in half a second. Nothing removes a projection: the four slots keep whatever the character met first, for the entry's life. - The multiplier stays at 1 while the entry holds any projection (PC 0x473370 tests the count, not the fades), so the environment light is not dimmed. Because the slots are never freed, a character who has walked through one projected shadow is not darkened by the ordinary blocks afterwards either.
- Drawing: in its shadow-buffer pass (PC 0x4b42d0) the PC computes the multiplier of every character, then for each projection index below the largest count draws every entry that has that many projections and whose texture word lacks bit 29, together with the geoms attached to it (PC 0x4b4110: command 0x28 sets the index the binder reads, +0x180, and the meshes are drawn with material layer 0xc,
TextureProjection). Every Standard material carries that technique (Standard20.fx;TextureProjectionMPSfor skinned meshes):(1 − v4TextureProjectionColor) × (0.3 + 0.45 × saturate(2 N·L)) × tex2Dproj(map, worldPos × matrix), withsaturate(N·L)for rigid meshes and L towards the light's position, fogged towards black. The pass draws into the shadow buffer between commands 0xd and 0xe, which set the blend to MAX (PC 0x4b08f0,D3DRS_BLENDOP5), as for the drop shadows and the ShadowSub layer; command 0xf multiplies the picture by one minus the buffer (DESTBLENDINVSRCCOLOR, PC 0x4b0984). Words with bit 29 are drawn by a second call after the scene's lighting passes (PC 0x4b4110 with 1 and layer 0x10,TextureProjectionAdditive), straight into the picture with the blendDESTCOLOR, ONE, so the picture is multiplied by one plus the same term: light falling through a window. M11 and M12 have them (below). - The scenery's own projected shadows (the
StaticShadowTextureShadowmeshes, withm44StaticShadowProjectionMatrix, engine parameter 0x39) are a different thing: the converter turns them into the PS2's textured shadow meshes (prm.md), and the port draws them as the PC does (Scenery shadows).
What the port does¶
ComputeStaticShadowMultiplier (port/engine/drawing/_sdl/staticshadowoverridesdl.cpp) runs the PC's sampler and keeps each draw entry's projections (copies of the records, the fades, and the record addresses to tell them apart) in its table of per-entry state, with the PC's quirks: the grid test reads the same word (bounded by the room's sample data; outside it the whole box counts), the slots are never freed, and an ordinary block that samples nothing leaves the last projection in place, so the same projection can be met twice in a frame and fade in twice as fast there, as on the PC. One quirk is not kept: PC 0x472a10 adds the step when a fade equals its target, so a faded-out projection alternates between 0 and twice the frame time, a flicker of about 6 % of its strength every other frame; the port's stays at 0. The scene's StaticShadowSampleHeightLimit is read through OBM_STATIC (g_fStaticShadowSampleHeightLimit).
The bone drawing (zoldviewbonessdl.cpp) records each mesh of a character whose entry, or whose owner's, holds a projection that has not faded out: the skinned meshes (the plain per-vertex program, bonepixel and the pcskin program of pc_shading), the rigid strips attached to him, and attached geoms drawn with the PC material program (zoldviewpcmaterialsdl.cpp). A mesh lit per pixel already carries its normals in its vertex colours; for one lit per vertex the drawing writes a second copy of its vertices with the normals (DrawListReserveVertices). At the character shadows' flush, staticprojectionsdl.cpp draws every recorded mesh once per projection into the character shadows' mask (shaders/staticprojection.hlsl) with the PC's formula, the transform the mesh was drawn with, and a test against the scene's depth, so only the surfaces the picture shows receive it; the additive kind is drawn in the same pass straight into the picture with the PC's blend (both kinds multiply the picture, so the order does not matter). The mask blends with MAX and its apply pass multiplies the picture by one minus it (now per channel, since the projection's colour is not grey), which is the PC's shadow buffer. It is the mask the character shadows use, and works with shadow_detail 0 as well. The light term uses the light's position and the normal in root space; the PC's skinned technique subtracts the skinned position in model space from the light's position, which is the same when the PC's model space is the world. Mirror reflections are not recorded.
Measured in M00 with OPENBLOOD_SCENEFX_AT="-11500,0,-5400,0,0.3" and OPENBLOOD_SCENEFX_WALK="0,15,160,20" (47 moved north 15 units a frame into the tree shadow behind the palace, OPENBLOOD_DETERMINISTIC=1, OPENBLOOD_TRACE_STATIC_SHADOW=Ground with OPENBLOOD_TRACE_STATIC_SHADOW_EVERY=1): the projection (texture 0x81) is added at z = −5145, as he enters the block's box, and fades from 0.001 to 1 in 15 frames (0.067 a frame at 30 frames a second); leaving the box at z = −3360 it fades to 0 in 15 frames and stays there, and the multiplier stays at 1 all along. Walking from z = −5100, the average brightness of the box around his head falls to 0.68 of its value with the setting off where the dappled shadow is densest (52 against 77); the dapples move over his head and shoulders, and over the rifle case he carries (OPENBLOOD_SCENEFX_TEST=firstperson gives it to him at frame 150: 8 skinned meshes recorded before, 8 skinned, 6 rigid and 2 PC-material ones after). Through the Ferris wheel's shadow (OPENBLOOD_SCENEFX_AT="-13800,0,2400,1.57,0.3", OPENBLOOD_SCENEFX_WALK="20,0,80,8": 47 moved east 20 units a frame, seen from the front) the box around his head is, against the setting off, 0.59 as bright at x = −13780 (the wheel's base), 0.74 at −13620 and −13460, 1.0 at −13300 and −13140 (in a gap), 0.70 and 0.64 at −12980 and −12820 (a beam of the frame), 1.0 at −12660 and −12500, and 0.65 at −12340, which is the texture's pattern along that line. In M01 at 47's starting place (−1109, −160, 2488) the plant shadows (0x83, colour 0x83969f) leave his head at 57, 43, 33 against 74, 51, 40 without the setting, a cooler shade, since the light left in the shadow is bluish. In M12's main hall at (−1180, 0, 2400) a window's additive projection (0x80, wrapped, colour 0) makes the box around his head 1.75 times as bright. The plain program (pc_shading=0), pixel_lighting=1 and shadow_detail=0 give the same shadow. With the setting off, and from the disc (which has no projected blocks) with it on or off, deterministic captures are identical pixel for pixel to the build before this change (M00 behind the palace, frames 200 to 800 from the disc, 300 and 600 from the PC installation).
Not covered: crowd characters (DrawBoneArrays) have no draw entry and get no projection; nor does a geom attached to a character that the plain dot3 path draws (pc_shading=0 with a bump-mapped weapon). A picture-in-picture view that draws before the main view takes the frame's recording, as for the character shadows. Whether the PC's draw entries outlive a character leaving the view was not checked; the port forgets an entry's state after two frames without a call, so a character who comes back into view starts with no projections.
Scenery shadows¶
The PC data's scenery carries its own static shadows: meshes laid over the ground and walls that darken what lies under them, most with a projected texture of branches, leaves, palms or window bars. They come from the release's shadow tool and are separate from the characters' projections above. Until 25 November 2026 the port drew none of them, from the PC data or from the disc, although it converted and decoded them; M01's courtyard and M05's street lacked all their tree and building shadows.
The PC's objects. A static shadow object (0x80 bytes, prm.md "PC version") names a material of the type StaticShadow, of one of three classes (mat.md):
| Class | Effect, technique | Blend (BMOD) |
What it draws |
|---|---|---|---|
StaticShadow |
StaticShadow.fx ShadowDrop (layer ShadowSub) |
STATICSHADOW (_Glacier/StaticShadows/Subtractive) |
a × (1 − vStaticShadowColor), One/One |
StaticShadow |
StaticShadow.fx ShadowAdd |
ADD (_Glacier/StaticShadows/Additive) |
v4Diffuse × vStaticShadowColor, SrcAlpha/One: light added |
StaticShadowTextureShadow |
StaticShadowTextureShadow.fx Ambient |
STATICSHADOW |
tex2Dproj(mapDiffuse, pos × m44StaticShadowProjectionMatrix) × a × (1 − vStaticShadowColor), One/One |
StaticShadowTextureAdditive |
StaticShadowTextureAdditive.fx Ambient |
ADD |
tex2Dproj(...) × v4Diffuse × vStaticShadowColor: projected light (windows) |
a is the vertex colour's alpha (the PS2 records' intensity byte), vStaticShadowColor the object's word 0x78 as RGB / 255 (engine parameter 0x38, the light left in the shadow), and every one is fogged towards black (FogColor = 0), so a shadow fades out with distance. The subtractive kind is drawn into the shadow buffer, where commands 0xd and 0xe set the blend operation to MAX (PC 0x4b08f0), and command 0xf multiplies the picture by one minus the buffer, as for the character projections above. The materials have ZBIA 7, FENA 1 and CULL DontCare, or TwoSided for the plant shadows.
Over the scene archives (build/m01/matshadows.py in the scenefx worktree, counts from the .MAT usage table): M00 61 objects (41 untextured, 20 textured: trees, the wheel, lamp posts), M01 163 (50 untextured, 1 additive, 112 textured plant and vine shadows), M02 57, M03 62, M04 54, M05 80 (35 untextured, 5 additive, 40 textured trees and a gate), M06 127, M08 100, M09 163, M10 295, M11 106, M12 115 (with 27 projected window lights), M13 230, the hideout 3; the post-mission scenes have 6 to 68. M01's colour is 0x83969f (the colour of its character shadow environments, Engine Core: ZENVIRONMENT), M05's 0x53575e.
Why the port drew nothing. PcConvertPrims turns each object into a PS2 SPrimShadowMesh (prm.md), and the SDL view draws those as ZOldViewPS2::DrawStaticShadows does (zoldviewshadowssdl.cpp, vu-programs.md "VUStaticShadowDraw"). Its shader discards back faces to follow the VU program's cull, but it discards the wrong side: a triangle whose decoded winding agrees with the surface's normals is clockwise in clip space and so the pipeline's back face (drawlistsdl.cpp, the cull_mode comment, since 16 November 2026), while shadow.hlsl keeps the pipeline's front faces (SHADOW_CULL_BACK = 1, written on 14 November before that convention was settled). Every M01 mesh, from either data set, faces up: summed over its decoded triangles, the normal points along +y (for example (−115630, 1884241, 1012408) for the 453-index plant shadow over 47's start). So only slivers seen from behind were drawn: with the shadows' merge colour forced to red, M00's and M01's frames showed thin red lines along roof and wall edges, and with the cull off the whole courtyard turned red. The disc's meshes are the same (the disc's M01 has 16 at the start, five of them textured with the same plant texture at 128 × 128), so the disc version drew no static shadows either. On 25 November 2026 the owner chose to fix that too: DrawShadowsOfType (the PS2 path) now discards the front faces as well (SHADOW_CULL_FRONT_FACES; SHADOW_CULL_BACK is gone), and the disc's M01 courtyard and M05 street show their shadows (build/pc-real/disc-m01-fix/, disc-m05-fix/; M01's ground under 47 from (63, 52, 38) to (48, 41, 31)). Even with the cull fixed, the PS2's formula would blend the frame towards a near-black constant (the converter's colour, a 21st of the PC's) where the PC multiplies by the colour.
What the port does now. With pc_lighting (Enhancements: PC lighting; on by default in PC-data mode) and the PC data, the port draws them the PC's way:
PcConvertPrimsappends anSPcStaticShadowExtension(port/engine/system/_sdl/pcdata/pcstaticshadow.h) after the 0x60-byte record: the magic "PCSS", the PC colour and the kind, subtractive forBMOD STATICSHADOW, additive for the ADD modes, other for the rest (drawn the PS2's way).StaticShadowTextureAdditivematerials now count as textured (PCMATCLASS_STATICSHADOW_TEXTURE_ADDITIVE) and keep their texture and projection, and additive meshes are written as the disc's light pools are,bIsLerp0 with half the PC colour (0x80 = 1.0); before, the converter treated them as untextured shadows.ZOldViewSDL::DrawPcStaticShadowstakes those entries out of the PS2 grouping. The subtractive ones are drawn into the temp target, cleared to black, with the blend MAX and(1 − colour) × a × fade, times the projected texture for the textured class; the frame is then multiplied by one minus that buffer, one channel per pass (MergePcShadows, the merge shader with the blend(0 − Cd) × As + Cd). The additive ones are then added to the frame withcolour × a × fade(times the texture). Both keep the visible side (SHADOW_CULL_FRONT_FACES).OPENBLOOD_TRACE_STATIC_SHADOW_MESHES=Nlogs every Nth frame's static shadow meshes: record, texture, lerp flag, the PS2 and PC colours, the kind, draw mode, triangles and bounds.
Measured at the starts of M01 and M05 (below), the shadows fall where the real PC's do, dapple for dapple, and their strength matches: in M05, where the port's shadow leaves 0.34 of a pixel's brightness, the PC's picture is 0.43 of the port's picture without shadows, while where the port has no shadow the PC's is 1.20 of it, so the PC's shadow leaves 0.36 of its own unshadowed brightness. In M12's main hall (OPENBLOOD_SCENEFX_AT="-1180,0,2400,0,0.3") a window's additive mesh (texture 128, colour 0xffe4f3ff) now lays the window's light on the floor beside 47, where the character projection already lit him. From the disc, and with pc_lighting=off, nothing changes: a disc capture of M01 differs from the base build's only on 47's and the worker's outlines (their animation phase), as two runs of the same build do.
Not followed: the materials' z bias (ZBIA 7; the meshes pass the port's GEQUAL test against the coplanar ground as they are); TwoSided culling (a mesh's back faces lie behind the surface it covers); the texture's alpha in the additive kind; fog by radial distance (the port fades by depth, as the PS2 program does). The PC's buffer shared with the character shadows is followed since 26 November 2026 (below).
Character drop shadows¶
At M04's start the port drew 47's shadow across the drive beside him, a dark figure to his left, where the real PC shows nothing (pc-m04-b.png, enhanced threefold: no darkening at all). From the disc the port draws the same shadow, as the PS2 rules have it: ZShadowListBuild::ProcessEnvironment gives 47 the yard's character shadow environment Spot_Env_Character_01 (type 3, direction (−0.50, −0.62, 0.61), receivers So04B_ParkPath_02_01, the drive, and the grass), and the port draws every pair at a fixed half strength (DROP_STRENGTH, shadowmapsdl.cpp).
The PC's shadow (FUN_004b42d0, the shadow-buffer pass of the PC renderer; PC addresses):
- The pairs come from the same
ZShadowListBuild(lights throughProcessLightunless their record has flag 4, or flag 2 at shader quality 2 or more, which cast their own shadow maps in the Lighting pass; thenProcessEnvironment, 0x46b940). The PC'sProcessEnvironmenttestsCastShadowon the room environment's character shadow (+0x24) and opens the set with its character light (+0x20); in M04 and M10 both are the same geom. - Ranking: the distance term is
(2000 − d) × 0.2133, capped at 64, times1 − d × 0.00015, times the light term (0x4b2c10: 1 for an environment, the range and cone for the others), then times the mean of one minus the light record's colour (below); a pair of 47 (the caster type at 0x99b354) always ranks 64. Up to sixteen pairs, drawn four at a time. - The colour: at 0x4b5672 the drawing packs the light record's word +0x1c,
SPrimLight::lStaticShadowColor, as the RGB ofg_vDropShadowColor(engine parameter 0x3a, from the draw command 7, word 0x12) with the alphamin(4.24 × strength, 255)(0x7652d0, 0x7f71f8), which is 255 for 47 and for any strong pair.ShadowDrop_VS20(Standard20.fx) writes(1 − g_vDropShadowColor) × g_vDropShadowColor.a × clamp(8 N·L) × distance fade(for an environment light, types 3 and 4,v4LightAttributesis (1, 0, multiplier, 1/60000), so no distance fade) into the shadow buffer, with the blend MAX, between the commands 0xd and 0xe, the same buffer the scenery'sShadowSublayer is drawn into; command 0xf multiplies the picture by one minus it. So the colour is the light left in the shadow, and where a static shadow is darker than the drop shadow the drop shadow adds nothing. - In M00, M01, M04 and M05
ZENVIRONMENT::ClassInit(0x4e4bf0) copies each room environment's non-zero word into its character shadow environment (Engine Core: ZENVIRONMENT). In M04 the yard'sSpot_Sun_B_01gives 0xa1a197 toSpot_Env_Character_01(its own word 0xb1b1a9); the otherSpot_Sun_B_01gives 0xedf0ee to the secondSpot_Env_Character_01(0x8a8f96). Other scenes keep their own words: M10'sAmbient_env_character0x616161, M06's_env_character_0x58564e, M05'sSun_Light0x53575e.
In M04, 0xa1a197 makes a shadow of 0.37, 0.37 and 0.41, and the yard's static shadows there already take about 0.32 of the light (the drive measures 60.9 with them and 90.0 without), so MAX adds about 0.07: nothing visible.
What the port does now. With pc_lighting (Enhancements: PC lighting):
DrawPair(shadowmapsdl.cpp) uses the pair’s calculated strength and the colour one minus the light record'slStaticShadowColor(Colorin the mask uniforms,shadowmap.hlsl), where the PS2's shadows are a grey 0.5. The alpha is capped at one after scaling the pair’s strength by 4.24/255. Every pair of 47 is drawn at full strength, as the PC's rank of 64 gives.DrawPcStaticShadows(zoldviewshadowssdl.cpp) keeps a copy of the static shadows' buffer (ShadowMapKeepStaticShadows) after multiplying the picture by it; the mask pass of the same camera reads it and writes(max(S, c) − S) / (1 − S)per channel, so that the picture, already multiplied by1 − S, ends at1 − max(S, c), the PC's MAX. With several static shadow batches in one view only the last is kept.ZENVIRONMENT::ClassInitis replaced (port/engine/geomsbase/_sdl/environmentoverridesdl.cpp) to make the PC's copy in those four scenes. The port's scene name is the.gms(host0:SCENES\M04\M04_Main.gms), so its file name without the extension is compared.
Measured at the mission starts (PC version, build/r9 in the scenefx worktree): M04's drive left of 47 reads 53.4 on the PC, 41.9 before (the shadow), 47.5 with the colour alone, and 64.7 now (no shadow; the port's drive is brighter there than the PC's, as the neighbouring ground is: 60.9 against 53.5). M06's shadow core is 0.58 of the light beside it (PC 0.53, before 0.70), and M10's long shadow to the right keeps the PC's shape and darkness, its head fainter where it reaches the building's static shadow, as on the PC. With the disc and pc_lighting off (the default there) nothing changes.
With pc_lighting, HandleShadows gives 47 priority within the 16-pair limit. It ranks lights on the same caster by range, cone and shadow colour, with a camera-distance fade from 1,700 to 2,000 units.
Bright dashes along edges inside a shadow (fixed 1 December 2026). Players saw a thin white outline around 47, guards and bodies lying in their shadows on M02's pier, and dashed bright lines along stair edges and handrails inside 47's shadow. The mask pass (PSMask, shadowmap.hlsl) fades a shadow by clamp(8 N·L) with a normal rebuilt from the depth, and took it as cross(ddx(P), ddy(P)). Beside a depth jump (a character's outline over the ground, a kerb, a stair nosing) half of each 2 × 2 pixel quad lies on the far side of the jump, the normal is wrong there, and the shadow dropped out of every other pixel, which kept the lit colour. SurfaceNormal now builds the normal from the neighbour on each axis that is nearer in position, as the occlusion pass does (CameraNormal, enhance.hlsl). Reproduced at M10's start with the camera above 47 (OPENBLOOD_CAMERA=-2150,330,-8300,-2193,20,-8376, frame 150): the kerb inside his shadow had a dashed bright line and his shoes and trouser legs a bright rim; both are gone, and the frame differs only at those edges.
Two shadows in M02's staircase. In the concrete staff staircase (M02_Staircase_101), two instances of Pc02E_Lamp_Shower_Spot_00 cast shadows on 47, and both are drawn at full strength, as on the PC (OPENBLOOD_SCENEFX_AT=-1485,165,-340, OPENBLOOD_CAMERA=-1485,350,-305,-1485,225,-340). For a while the port kept only the stronger of 47's shadows at full strength and drew the other at its light's own strength (0.23 there); that was undone on 3 December 2026, because the PC ranks every pair of 47 at 64, which its alpha min(4.24 × strength, 255) makes 255. The mask uses the scene depth for its receiving surfaces.
Bump-mapped surfaces (dot3)¶
The PC lights every Standard material with BumpEnabled per pixel from its normal map (CalculateBumpNormalPS; x in the alpha, y in the green, tex.md). The PS2 did that for selected surfaces with dot3 strips (SPrimStripsDot3PS2, type 6), which the port already draws (DrawNormalMapped: the geom's lights per vertex, N·L from the normal map into the frame's alpha, the diffuse texture scaled by it, and a specular pass). The converter now writes an opaque bump-mapped Standard material on a static or rigid object as dot3 strips: lNormalMapId from mapNormal, lSpecularMapId from mapSpecularMask, lSpecularColor from v4SpecularColor × vSpecularLevel (0x80 = 1.0, the PS2's most common value), the PS2 records' usual cut-offs (the normal map to 2,000 units, the specular pass to 3,000) and the PC vertices' tangents and binormals. The texture converter already decodes PC normal maps to the RGB normals dot3.hlsl reads. Skinned objects, blended materials and the Glass, Mirror, Glow and SkinCloth classes stay plain strips. This is the conversion and drawing with pc_shading=0; with pc_shading (the default) the records carry the PC's terms and are drawn by the PC material program (below). About a quarter of a mission scene's sub-prims become dot3 (807 of 4,464 in M01, 1,358 of 4,308 in M00).
A dot3 sub-prim costs one prim handle: its tangents and binormals share one block, and lBiNormals is that handle with bit 31 set, which PrimDecodeStrips reads and FreePrimData masks. M06 does not fit the handle table with every bump-mapped object as dot3, so a scene that does not fit is converted again with dot3 only for objects of 32, 128 and then 512 triangles or more, and finally without (M06 keeps 717 dot3 sub-prims). The dot3 passes draw immediate vertices (M00's first view: 179,000 a frame against 6,000 without dot3), so the draw list doubles its vertex and index room, up to eight times, at the frame after one runs out (draw list: out of room in the log). On M00 at the pier, 1,000 frames take 4.9 s with the water reflections and dot3 against 3.6 s before, 1.4 ms more a frame.
Depth bias: the PS2's dot3 program takes no bias, so the port draws a disc dot3 surface a quarter of a bias step nearer than a bias 0 strip (stability.md: Posters sinking into normal-mapped walls). A converted dot3 record's lBias is the PC material's ZBIA, and with PC data Dot3BiasScale adds it (since 1 December 2026), so a dot3 surface sits where a strip of the same bias would, a quarter step nearer. Before, layered ground lost its bias and fought the surface under it: in M05 the 1 m lawn strips in front of the hedges (So05D_Lawn_1x12m_*, bias 1) lie level with the pavement slab that runs under them (So05C_SidewalkTurn_20m_07, bias 0), both dot3, and the slab's streaky edge showed through the grass in jagged triangles. Five mission starts (M01, M03, M05, M10, M11) draw the same with and without the change, apart from single edge pixels.
47's tie stuck out stiffly, then crumpled (fixed 2 December 2026). With the PC data 47's tie (Tie_LOD1, a ZTie cloth) kept the pose it had when it was first drawn: straight out at about 45° from his chest at A New Life's start (M05, launcher mission 4) and in the outdoor missions, hanging only where it happened to have settled before its first draw (M06's lobby). The cloth stepped (OPENBLOOD_TRACE_FRAMERATE: 50 steps a second) and its particles moved, but none of it reached the picture, for two reasons. The tie's PC material is bump-mapped, so the converter writes it as dot3 strips (type 6), and ZPrimControlPS2::SetPrimExtraData (0x285608) rewrites only plain strips: the cloth's vertices and normals were dropped. A dot3 record begins with the plain record's fields (SPrimStripsDot3PS2), so the port's prim control (renderdllsdl.cpp) now writes them as for plain strips. And the PC material program's cache (zoldviewpcmaterialsdl.cpp) decoded a prim once: MeshChanged now marks it stale, its next draw decodes it again and lights its instances again, and a prim decoded again has its stored tangent and binormal turned to its new normals, so the normal map follows the cloth. With those two fixed the tie moved, but crumpled at the knot and went thin in parts: the PC data's cloth block is the PC version's, with one particle per vertex of the PC mesh in its vertex order and no copy list (the tie: 25 particles), which the PC renderer writes straight into its vertex buffer, while the converted strips order the vertices by strip and repeat some (the tie: 33 elements). Written as they came, the positions landed on the wrong elements. The port's ZCloth::DrawIt (clothoverridesdl.cpp) now matches each strip element once to the particle at its rest position (every element of the cloths met in the missions lies within 0.11 of a unit of one particle and within 0.25 of no other) and writes the cloth's positions and normals per element. A sub-prim that does not lie on the particles is left as it is. The same fault scrambled A New Life's other cloth (49 particles over 84 elements, plain strips), which the PS2 writer did reach. The tie now hangs and swings with 47 with its full width (checked from the side and the front in A New Life; every cloth in the other missions' openings matched). From the disc the cloth blocks are the PS2's, one particle per strip element with a copy list, and are written as before.
Sky layers¶
A scene's sky is a pack of its own (PRIMPACK_SKY_BACKGROUND), drawn first, and CalcTexturePrioity orders it: opaque layers (0), blended ones (1), additive ones (2), then by texture id. With PC data the layers' depth state comes from the materials' blend modes (MakeDrawSetup): TRANS writes depth and TRANS_ON_OPAQUE does not, and neither keeps the PC object's FORCE_NO_ZWRITE (the PC sets mesh depth writes from the blend mode alone). M05's sky is Sky_Dome (GradientSky_M05_01a, opaque, no depth test), hills Horizon_06 to _08 (LosAngelesView_01b/_01c, texture 153; _01c is TRANS, so its whole card, transparent sky included, writes depth) and clouds Clouds, Cloud_09 to _13 (M05_Clouds_01, texture 154, TRANS_ON_OPAQUE, depth tested). In one priority the hills came first by texture id, and the clouds behind them were cut along the cards' straight edges, a pale rectangle with a hard vertical side above the gate at the start. Since 1 December 2026 the port's CalcTexturePrioity puts, with PC data, the blended sky layers that write depth after those that do not (2 after 1), as the scenery's blended strips do (5 before 19), and the additive ones last (3): the clouds are drawn whole and the hills over them. The starts of M00, M02, M04, M05 and M12 draw the same in both orders, apart from a few faint pixels.
No far plane for the sky (4 December 2026). The PS2 draws the sky pack with the ...NoFar planes (its VU far plane moved to 1,000,000), and backdrop rooms are gathered past the far plane (GROUP_CONTROL_NO_FAR_CLIP). The port drew the pack through the camera's own projection, so its layers past the camera's far plane were cut. M02's camera far is 20,000 and its sky dome (Sky, in M02__Backdrop with Clouds, Fogplane04 and Fogplane06) is about 35,000 away. On the Retroid Pocket's Adreno, which clips at the far plane, the sky came out in pieces with straight edges and the clear colour between them. Windows and other GPUs with depth clamping drew those parts at the far depth instead, behind the nearer layers. Sky-pack strips and PC-material prims now take the depth c / w (SkyPackDepth, zoldviewsdl.cpp), which behaves like a far plane at infinity: the layers are never clipped and keep their order by distance. m_fSkyDepth sets c so that this depth stays below the depth of scenery at 99.9 % of the far plane, which keeps every scenery object in front. OPENBLOOD_DEPTH_CLIP=1 turns depth clamping off in the draw pipelines, so a desktop GPU reproduces a clipping one. Checks:
- M02 with
OPENBLOOD_DEPTH_CLIP=1at 1,280 × 960: before the change the sky had triangular holes along straight lines, or was missing behind the rock; after it the sky is whole. - M02 with depth clamping: the frames are the same as before the change.
- M04 and M05 starts: unchanged.
- M12: a glow in the sky pack now shows in front of the backdrop tree card (
TreePlane01) beside the flag, about 170 of 34,240 sampled pixels. Before the change the clamp to the far depth had put the glow behind the card.
Blended surfaces¶
The pause map from the PC installation was pale: the whole map lay under a light haze, and the zoom box, which grows from the point clicked (CIngameMap::UpdateMapPosition), was a bright, nearly opaque rectangle (a yellow-white sheet over the whole map when it was large). Neither version draws an outline there. On the disc ZoomBox (prim 0x4d67 in M01) is a 157 × 120 quad of two triangles with the noise texture Screens/InGameMap/Overlay/NoiseLayer#Noise (578, grey about 100), vertex colours 0x80 and alpha 16 to 32, alpha-blended and lit by the map's environment light (Ambient, colour 0x77775e, the same record in both data sets), so it is a faint, sepia-tinted translucent sheet. The PC's (0x5572) is the same quad with the material Screens/InGameMap/Overlay/Noise_01 (Standard, TRANS, texture 1087, whose statistics equal 578's) and vertex alpha 64 to 128 in D3D units (twice the disc's numbers). The PC's AmbientHQ technique outputs IN.Diffuse.a * cTexel.a (Standard20.fx, the vertex alpha times the opacity) and blends TRANS by source alpha (PC 0x495430: SrcBlend 5, DestBlend 6), so the PC draws it at 0.25 to 0.5. The GS takes a texel's 255 as 2.0 and a vertex's 0x80 as 1.0 (general.hlsl: Texel.a * Input.Color.a * GS_COLOR_SCALE²), so the disc's 16 to 32 give the same 0.25 to 0.5; the converter's halves, 32 to 64, gave 0.5 to 1.0. Every blended layer of the map has the same factor (its Raster_Plane_01 and Background noise layers, and GLOW, ADD, 76 against 19).
The converter (ReadObject in pcprims.cpp) now quarters the vertex alpha of objects whose material blends by source alpha (TRANS, TRANS_ON_OPAQUE, ADD, ADD_ON_OPAQUE, ADD_BEFORE_TRANS) and has a diffuse map. SHADOW (ZERO, INVSRCCOLOR: the PC ignores alpha) and TRANSADD_ON_OPAQUE (ONE, INVSRCALPHA) keep the half, and opaque materials keep 0x80 for 255, as the disc's records have it for their alpha test. The map from the PC installation is then as dark as the disc's (mean 81 against 70 for the disc and 123 before), and the zoom box is the disc's translucent sepia sheet. Elsewhere the change shows on every blended PC surface: in M05's hotel lobby the fake shadows under the tables are as light as the disc's (they were nearly black), and the candle glows are smaller. It applies in PC-data mode only.
Blended bump-mapped decals. M11's drive had a large black quad beside 47 and bold black tyre marks, where the real PC shows a faint wet patch and faint marks. Both are blended (TRANS) bump-mapped Standard materials: Pc11J_WaterPuddleA_02 (Overlays/WaterPuddle_01, 512 × 512, mean alpha 68, OPAC 0.8, with a cube-map reflection) and Pc11J_TyremarksC_01 (Overlays/Tyremarks_01). pc_shading wrote them as dot3 records, but ZOldViewBase::CalcTexturePrioity (0x281bb8) gives every dot3 record the opaque priority 4 whatever its draw mode, so they were sorted among the opaque ground they lie on (So11A_GroundDriveway*, dot3 too) and drawn before it: blended over the cleared frame, they wrote depth, and the ground then failed the depth test there. Found with OPENBLOOD_DEBUG_COLORS (the quad kept its colour) and by skipping one object at a time. The round-9 fix wrote a blended material's PC terms on a plain strips record (bStripFx), which CalcTexturePrioity sorts by its draw mode (TRANS: 19, after the opaque layers), as the PC draws TRANS after its opaque Ambient layer. The same round's glass door fix sorts a dot3 record whose PC material blends at 19 too, which fixes the decals by itself, and the two were merged together. The strips records lost the tangent streams, and the PC material program rebuilds a strips record's tangent frame from the screen derivatives of the position and the texture coordinates (PSPcMaterial, pcmaterial.hlsl). On M06's bar tablecloths (blended, bump-mapped; launcher mission 5) that frame striped the cloth's sides with a two-pixel weave the PC does not show, and left black notches and single white pixels on the cloths that moved from run to run (port-r3/m06: a black wedge of about 15 × 8 pixels on the left table near (185, 390), more at the right table's edge and the near table's rim; two runs of the same build drew one black pixel and none there). Since 26 November 2026 (round 10) the converter writes those materials as dot3 records again, with their tangent and binormal streams, and the sort override alone keeps them after the ground. The cloths are then smooth and without the notches, as on the PC (build/r10/m06-e.png and m06-f.png in the scenefx worktree: the PC, port-r3, the round-9 build, and the fix). M11's decals stay where the round-9 fix put them: the puddle's patch (620..820, 400..540) reads green 18.4 against 17.6 with the derived frame and 16.8 on the PC, the tyre marks' strip (520..740, 200..260) 25.7 either way (PC 23.8, as much darker as the bare drive beside it: 23.8 against 25.5); M03's guests still show through the glass doors.
Opacity. The puddle was then too faint (its patch 23.7 against the PC's 16.8, 30.1 without it). The converter wrote OPAC below 1 as opacity × 127 in the diffuse colour's alpha, which is what the disc's records carry (the disc's puddle has 0x65 for 0.8, the glass Booth_glass and the facade 0x3d for 0.5, the floor tiles 0x49), but the draw takes 0xff as 1.0 (127 × vertex × diffuse / 32768, vu-programs.md "VUStaticDraw"), so the PS2 draws those surfaces at half their opacity. The PC multiplies the vertex alpha by v4Opacity (Standard20.fx), so the converter now writes opacity × 255: the puddle's patch is 17.7 (PC 16.8). Every blended PC material with an opacity below 1 is affected (about 1,000 over the 49 scene archives that have them, mostly TRANS, ADD and TRANS_ON_OPAQUE glass, glows and decals: build/r9/py/matopac.py). The disc is unchanged.
Picture-in-picture¶
When a security camera films 47 (ZSecurityCamera::SetupPictureInPicture), the event camera's inset gets the security overlay: ZOSD::UpdateSecOverlay draws UI_SecuritycamOverlay#Blue (SI_SECOVERLAY1, draw mode PRIMDRAWMODE_MULTIPLY, vertex colour 0x808080) over the inset with the frame mask 0xff00ff00. On the PS2 the multiply is Cd × As and the mask leaves green alone, so red and blue fall with the texel's alpha and green keeps its level. The port drew it that way from the PC installation too, and players saw a bright, saturated green inset where the PC game's is dark with a faint green (issue #9: the inset's floor about (11, 23, 16) on the PC against (38, 81, 34) in the port). The PC's texture (M02's 1093, 64 × 64) has a mean colour of (69, 158, 110); halved for the vertex grey that is 0.14, 0.31 and 0.22, the proportions of the PC's inset, so the PC multiplies all three channels by the texel colour times the vertex colour (the PC's D3D code for it was not read; this rests on the picture). Since 1 December 2026, with PC data, a multiply sprite blends with Zero and SrcColor (DRAW_BLEND_MODULATE) and writes red, green and blue (ZOldViewSDL::SpriteState). M02's inset (the security camera pushed on 47 at the start, frame 217) went from (66, 133, 37) on the pier's floor to (21, 41, 19). The disc keeps the PS2's blend.
Edges of the inset (4 December 2026). Two things left a row of the inset unshaded on a 1,280 × 960 handheld:
- The overlay. With the PC's HUD size, the HUD camera adds half a HUD unit to undo the half unit the game takes off its own HUD sprites. The overlay is placed from the inset's position in the game's 512 × 448 without that offset, so it moved down and right by half a unit. Where the display scale makes a unit two window pixels (the Retroid Pocket), that is a whole pixel, and the inset's top row and left column showed through.
DrawBufferViewUpdate(osdoverridesdl.cpp) now places it half a unit up and left. - The border. The overlay camera's border beside the inset ends at y 447.5. On the PS2 that still covers row 447, because the GS samples a pixel at its top left corner. Drawn larger, the screen's bottom row or two showed the inset through the border. The overlay camera's view (its masks and this border) is now grown about the screen's centre by 1.25 of the game's pixels in each direction (
UpdateMatrices,zoldviewsdl.cpp).
Checked with OPENBLOOD_PCTUNING_TEST=seccam, which opens a security camera's inset on 47 in M02. At 1,280 × 960 and 2,560 × 1,920 the border reaches the bottom row and the inset is shaded from its first row to its last. The binoculars' mask still covers every edge pixel.
Character levels of detail¶
The PC characters' finest level of detail (LOD mask 0x01, 1.22 to 1.51 times the PS2's triangles, drawn within about 3 m and always for 47) needs nothing here: PcConvertPrims keeps each object's LOD mask as the sub-prim's lLODControl and puts each variant's objects in its own variant list, so the engine's LOD code picks the PC's levels as the PC does. pc_models_test --pc measures it (M00: the 16 PC characters with a finer level 0 draw 71,073 triangles there against 52,216 at level 1), and OPENBLOOD_MODELS_LOG=1 shows 47 drawing 2,771 triangles in PC-data mode (the eye shell included, drawn additively with its black diffuse colour) against 2,663 with pc_models in a disc run and 2,275 on the disc. pc_models itself does nothing here (pc-assets.md).
On 25 November 2026 the converter changed for every mesh: chunks up to 500 units across share one 1/64-unit vertex grid instead of a scale each, which closed the pinholes that showed the background through faces and other seams (prm.md "PC version"). Wider chunks kept a scale of their own until 26 November (below).
Seams and white dots¶
Players reported white dots on things and along texture seams. Captures of all 13 missions from both versions (1024 × 768 and resolution_scale=2, frames 800, 1,200 and 1,600 after the quick start; build/dots/ in the matfx worktree, whose run names number the missions by the launcher's index: cap.sh, compare.sh, and dots.ps1, which counts pixels at least 30 levels of luma brighter than all eight neighbours, crops and scales them) showed two port bugs, both in PC-data mode. Both were fixed on 26 November 2026.
NaN from pow in the shaders (characters, with pc_shading). M01's courtyard at frame 1,200 showed white single pixels on the gardener's shoulder seams and hat and on 47's ear (232, 231, 228 on a dark vest). They went away with pc_shading=0 and stayed with pc_lighting=off, OPENBLOOD_NO_POSTFILTER=1, mipmaps or anisotropy. Debug colours in PSPcSkin (a temporary branch per term) showed the specular sum NaN over the whole of every skinned PC mesh, and only where one of the three bone lights gave saturate(dot(N, H)) = 0: pow(0, power) returned NaN with a positive power on the test machine's driver (Vulkan, NVIDIA GeForce RTX 3070, driver 621.14). DXC turns HLSL pow into GLSL.std.450 Pow, whose result SPIR-V leaves undefined for some bases. The final clamp(Added, 0, 4) turned the NaN into 0 on most pixels, so the shading looked right, and into white on a few. The same pow of a saturated base was in PSPcMaterial's specular and Fresnel terms, the skin rim light, dot3.hlsl's specular pass (the disc's dot3 surfaces too), PSWaterPc's Fresnel and specular, and the brightness pass (PSGamma, at a black channel). Each now goes through SafePow (Base > 0 ? pow(Base, Exponent) : 0; select in PSGamma), and the white pixels are gone: at 2,048 × 1,536 the gardener had three (two white, one green), 47's ear two, and both now have none.
Wide chunks with a scale of their own (scenery, both shading paths). The same frame showed lines of bright single pixels, evenly spaced, along straight lines across the courtyard's ground (185, 178, 128 on dark earth): 28 at 1,024 × 768, 97 at 2,048 × 1,536, twice as many at twice the resolution, so geometry. They stayed with pc_shading=0, without the post filter and with the static shadows left out (a temporary switch), so they were not shadow seams. The converter's 1/64-unit grid covered only chunks up to 500 units across; the wider ones (1,412 of M01_main's 15,586 chunks: ground, walls, terrain, up to 371,000 units for the backdrop) kept the scale extent / 32,000, so a vertex two such chunks share decoded up to half a step apart in each, about 0.015 units for a 1,000-unit chunk, and the pixels along the seam fell through to what lay behind. ObjectVertexScale (pcprims.cpp) now gives every chunk of an object one grid: 1/64 unit times the smallest power of two whose steps carry the largest delta between consecutive vertices of any chunk in 16 bits (and the start values in 30), over every key. A position two chunks, two sub-prims or the two copies of a texture-seam vertex share then decodes to the same float in each. In M01_main 3,606 objects (14,140 chunks) keep 1/64, 332 take 1/32, 133 1/16, 77 1/8, 46 1/4, 32 1/2, 28 1, 2 two units, 16 four units and 1 sixteen. The same frame now has 0 such pixels at 1,024 × 768 and 1 at 2,048 × 1,536 (an orange pixel where two objects meet: their grids can still differ). The static shadow meshes had the same kind of scale per batch (half the batch's extent / 32,000); ShadowMeshScale now gives a mesh's batches one power-of-two grid, which may be finer than 1/64 (a 1/64 floor collapsed some of the PC's sliver triangles). No shadow seam was seen in the captures; this is the same correction, not a measured fix.
pc_prims_test still passes over the 68 archives: all 9,128,191 strip triangles match (its tolerance is now half a step of the object grid, at most the extent / 32,000 instead of / 40,000; the largest position error is 8 units, on a sky dome), and all 1,177,282 shadow triangles match. Its shadow pairing was greedy (best fit in order) and left 7 triangles unmatched before and 108 with the new grid, every one of them with a decoded triangle within tolerance that a near-duplicate had taken; it now finishes with an augmenting-path search (ShadowAugment, a maximum matching), which matches all of them with the old converter and the new. The intensity mismatches at coincident vertices went from 1,571 to 2,310 for the same reason: near-duplicate shadow triangles of different intensities pair differently.
Over every mission (compare.sh: frame 800, resolution_scale=2, the build before these changes against the build after), the detector's PC-data counts went from 30 to 21 in M00, 97 to 2 in M01, 246 to 225 in M02, 283 to 288 in M03, 95 to 70 in M04, 218 to 175 in M05, 73 to 75 in M06, 2,751 to 2,703 in M08, 209 to 171 in M10, 25 to 28 in M11, 45 to 33 in M12 and 0 to 0 in M13 (M09's frame 800 fell in a cutscene). Outside M01 most of what it counts is texture detail (marble, diamond plate, foliage, the specular of the bump maps), so only the falls are meaningful; from the disc the counts stayed within a few either way.
Before and after crops (left before, right after; matfx worktree): build/dots/evidence/m01_npc_2048.png and m01_npc_shoulder_1024.png (the gardener), m01_47_ear_2048.png, m01_ground_seam_2048.png.
Not fixed:
- Pinholes at some character seams in PC-data mode, such as two at 47's left cuff and glove in M03's opera lobby at frame 800 (the marble behind shows through; also with
pc_shading=0). A first look (a temporary count in the converter over M02_main, keyed by bind-pose position, reading a palette slot as the bone its copy-bone pair names, a reading not checked against the PC's skinning) found the converted weights of 44,635 of 625,664 vertices different from those of another weighted object at the same position, all characters together. In the cases printed the two objects carry the same float weights but name different slots for the third and fourth influence (one object two slots of one bone, the other two bones), which points to the PC data rather than the weight rounding; it was not followed further. Whether the PC release shows the same pinholes could not be checked (the PC game is not run for these tests). - Sparkle on thin bump-mapped geometry with
pc_shading, such as dashed highlights along the grooves of the handrail in M03's opera lobby; mipmaps do not change it. The dot detector counts 288 bright pixels in that frame withpc_shadingagainst 26 without, most on the handrail and the mirror frames. - On the disc the detector found the same counts before and after (M01 0 at frames 800 and 1,600, M02 129 at frame 800: falling snow and the Christmas lights); every hit inspected was in the textures.
Snow and rain¶
M02's falling snow and M12's rain are box particles: a ZParticleBox (the flakes or drops, their speeds, size and texture prim) shown through a ZCubeGridParticles, whose enabled sub-boxes each become an SSpriteBox the particles wrap around (src/engine/geomsbase/zparticlebox.cpp; the same code on both releases). Each frame ZCubeGridParticles::DrawBufferViewUpdate hands up to 32 visible boxes at a time to DrawSpriteArray as an SSpriteArrayBox: sprite type 3 (SPRITETYPE_ARRAY_BOX, snow) or 4 (..._BOX_SCALE, rain, whose sprites carry a direction). The PC scenes keep the PS2 sprite-array records (the converter copies them, prm.md), so the port already drew both from the PC installation, with the same counts as from the disc: in M02's start 2,788 flakes of the 32-box array (400 sprites a box) and a few dozen of two 3-box arrays each frame, in M12's start about 300 of 2,100 drops (7 boxes of 300). It drew them the PS2's way, and from the PC installation that was nearly invisible: the real PC game shows dense, bright flakes over M02's whole view (pc-m02-b.png) and thin streaks in M12 (pc-m12-b.png), where the port showed a few faint specks and no streaks.
What the PC draws differently (rendermaterialspritesd3d.cpp: ZRenderObjectInstanceSpritesArraySnowD3D PC 0x49a760 and ...RainD3D 0x49aec0, the binder ZRenderMaterialBinderSpriteD3DFX 0x495070, and Sprite.fx's Ambient_SpritesSnow_VS11 and Ambient_SpritesRain_VS11):
- Size.
ZParticleBox::ClassInithalvesm_fParticleSizeinto each sprite'sfScaleon the PS2 (0x18a538) and stores it whole on the PC (0x4f1750): M02's 5.2 becomes 2.6 on the PS2, M12's 0.75 becomes 0.375 (Engine Core: Particles). - Snow flakes are clip-space billboards. Each PC flake is four vertices
(p, 2 × fScale, corner x, corner y, u)(vertex declaration at file offset 0x363dc4: position float3, blend weight float1, blend indices float3); the shader moves the transformed centre by(corner − 0.5) × 2 fScaletimesgi_vSpriteBoxAspectin clip units, before the divide by w. On screen the flake's half height isfScale / depthof the view's half height, so with the PC'sfScaleit is 2 / P11 times the PS2's world square of half sizefScale_PS2(P11 = 1 / tan of half the vertical field of view, 2.0 at both starts), about the same size. The PS2 also drops every flake that is not wholly inside the view; the PC draws the ones that cross its edge. - Rain streaks go through the box at the particle and at the particle plus its direction (M12: about 89 units straight down); the PC centres the streak on the particle (from half the direction before it to half after) and gives it
fScaleeither side acrosscross(p, v)in view space, the plane of the eye ray and the streak (vertex declaration at 0x363e4c). The PS2's starts at the particle, is as wide as the PS2'sfScaleand lies across the view direction. - Colour.
FUN_004908d0turns the array'slColor(M02 and M12: 0x64a0a0a0) into a D3D colour at byte / 255, and the pixel shader returns2 × diffuse × texel. The PS2'sZOldViewPS2::DrawSpritesBox(0x2b0d80) sends red, green and blue halved and the alpha quartered (lColor >> 26) to the VU program. So the PC's flake is twice as bright and its alpha four times as strong: eight times the light added by the same texel. Both blend by source alpha onto the frame (SrcAlpha, One: M02's snow and M12's rain both have draw mode 0x4c002, whose bit 1 which0x495070turns intoD3DBLEND_ONE; the port'sGsCalcMaterialStategives the GSALPHAregisterCs × As + Cdfor it and for the disc's 0x40092). - Fade. Both PC shaders multiply the colour by
saturate((fFar − z) / (0.1 fFar)), so the flakes and drops fade out over the last tenth of the box's depth (M02 1,200, M12 2,000). The PS2 cuts them off atfFar. - Masks. The PC's update (
FUN_004f0900, the PS2'sZParticleBox_UpdateParticlePositionsassembly) writes the same history mask intolMask1andlMask2 = mask >> 16as the port's, and its draw keeps a sprite whenlMask1 & box mask == lMask1, or every sprite of a box whose mask is all ones; that is the PS2's test of the two halves. - Textures. The PC's are DXT3 with 8-bit alpha (M02's
Effects/Particles/Particle_01_FX_H3, id 624, 256 × 64; M12'sEffects/Weather/Rain_01_FX_H3, id 1120, 128 × 64); the disc's are the same pictures in the PS2's 0x80 alpha range (369 and 607). Four frames side by side, chosen by each sprite'sfULeft/fURight. Both releases runualong the rain streak andvacross it, so a streak is brightest at its middle where the drop in the texture is.
The port (port/engine/drawing/old/_sdl/zoldviewparticlessdl.cpp): in PC-data mode DrawSpritesBox and DrawSpritesBoxScale build their quads with SnowCornersPc and StreakCornersPc, which follow the list above: the PC's size (twice the sprite's fScale), the flake as a screen-aligned square of half height 2 fScale / w of the viewport's half height (and the camera's pixel aspect across), the centred streak in camera space, a per-vertex fade, and the colour converted to the port's GS units (general.hlsl takes a vertex byte of 0x80 and a texel alpha of 255 as 1.0 and 2.0, so the PC's 2c / 255 becomes the byte c × 256 / 255 and its alpha a × 2 × 128² / 255², about a / 2). The disc keeps the PS2's path. OPENBLOOD_PC_WEATHER=0 draws the PC installation's weather the PS2's way and =1 the PC's way from the disc (whose textures are then too faint by half); OPENBLOOD_TRACE_WEATHER=1 logs every 600th box array drawn (kind, boxes, sprites, quads drawn, colour, near and far, fScale, P11, texture and draw mode) and every 300th particle array.
Not followed: the PC fogs both (FogEnabled unless draw mode bit 0x100000, through CalculateFog on the object-space distance), the PS2 sprites never are; gi_vSpriteBoxAspect is read from two getters of the render target (vtable + 0xbc / + 0xb8, PC 0x495070) that were not identified, and the port takes it as the view's height over width, which keeps the flakes square as they look in the PC capture. The PC's rain multiplies its projected position by the same aspect; the port projects the streak with the view's own projection (the PC capture has streaks down to the view's left edge, which a second squeeze by 0.75 would leave empty).
Widescreen (fixed 2 December 2026). The box particles were kept to the 4:3 picture: BoxSpace took the screen bounds from the game's 512-pixel viewport, so in a wide window M02's snow and M12's rain stopped at the 4:3 picture's sides. A view across the whole 4:3 picture now takes the wider picture's edges (GpuWidenScreenEdges), from the disc as from the PC installation. At M02's start in 16:9 (deterministic, frames 1,200 to 2,400) about 2,450 flakes a frame are drawn instead of 1,950, and the frames differ only in the two side strips; M12's streaks reach the edges.
The disc's look is the PS2's own. On the disc the snow is sparse, small and faint, and so it is on the PS2: the halved colour and quartered alpha are in ZOldViewPS2::DrawSpritesBox and the halved size in ZParticleBox::ClassInit, both decompiled code that matches the original, and the port's PS2 path follows the SnowDraw program’s InitSnow and SnowDraw_Begin entries as before. It is not a port bug and stays as it is.
The particle systems (ZParticleController, sprite type 7: smoke, sparks, fountains, splashes) do not have this gap. The PS2 halves their colour keys and quarters the alpha in ZParticleTemplate::ClassInit (0x1883cc); the PC keeps the keys whole and halves all four channels at draw time (ZRenderObjectInstanceSpritesArrayD3D 0x499ae0, colour >> 1 & 0x7f7f7f7f) before its doubling shader, which gives the same colour and, with the PC texture's 8-bit alpha, the same alpha as the port's PS2 path; their corners are ±0.5 of the size on both (PC table at 0x7f6a38).
Results (26 November 2026; the recipe of Compared with the real PC game: version=pc, 1,024 × 768, the briefing closed by an input script, frame 2,000; scripts and captures in the mouse worktree's build/w9/, untracked). In M02's water left of the bridge (20..220, 290..450), pixels at least 30 levels of luma above the mean of their 7 × 7 neighbourhood, and the region's mean luma: the PC 507 and 42.8, the port before 233 and 37.8 (the water's own glints), after 564 and 40.7, the disc 14 and 37.2. The flakes now have the PC's size (2 to 4 pixels across in the middle distance, a dozen near the camera), brightness and spread over the whole view, including the near ones across 47's back. M12's rain is drawn as thin streaks fading towards their ends, with the PC's width and length; a single frame holds about as many streaks as the PC's (the drops are random, so the counts are not compared). Crops, left to right the PC, the port before, the port after and the disc:


Which missions have weather, from OPENBLOOD_TRACE_WEATHER=1 over the 13 missions' first 2,000 frames, from both data sets: snow only in M02 (one 32-box array and two 3-box arrays), rain only in M12 (one 7-box array); M06 has no box particles at its start. Every mission has particle systems; their counts per frame are the same from the disc and the PC installation except in M00, M01 and M09 (the trace logs every 300th array drawn, and those runs reached their systems at different moments). In M01 about 90 systems with sprites of size 400 to 990 are never drawn by either version at the start, all dropped as particles: outside near or far (the PS2 program's 50 to 10,000 depth range); the PC's particle draw has no such range, so if they are distant smoke or dust the PC shows them where the port does not. No PC reference view shows them, so this was not followed.
PC material shading (pc_shading)¶
The PC draws Standard materials with Standard20.fx and characters with Skin20.fx and Cloth20.fx (mat.md, "What each technique computes"): the bump normal lit per pixel with the material's own specular power, level and colour, a cube-map reflection, self-illumination, a parallax offset and, on characters, a rim light and translucency. The PS2 records have no room for those terms, and the PS2 dot3 passes above light per vertex with a fixed (N·H)^16 specular. With pc_shading (on with the PC version, Version; pc_shading=0 in a test gives the PS2 look, the conversion and drawing of the section above) the port draws them as the PC does:
- Converter.
PcPrimsSetPcShading(set byPcDataStartfrom the setting, so the prim and collision conversions of a scene agree) makesMakeDrawSetupfill anSPcMaterialExtension(pcmaterialfx.h, magicPMFX: the eight map ids,v4BumpScale, the detail scale and tiling, the specular colour, power and level, the reflection colour and level, the illumination colour, the parallax scale and bias, the opacity, the wobble terms, and for SkinCloth the translucency map, rim colour, power and strength and the sub-surface colour and transparency, with flags for each switch, blending, fog andTwoSidedculling).EncodeSubPrimappends it to a dot3 record (after its 0x60 bytes) or to a skinned object's bone strips record (after 0x90). Besides the opaque bump-mapped Standard materials of the section above, Standard materials that reflect (ReflectionEnabledwith a cube map) or self-illuminate without a normal map become dot3 records too, and so do blended (TRANS) bump-mapped ones (plain strips records from round 9 until round 10 restored this, Blended surfaces); a blended dot3 record sorts with the blended strips, after the opaque ground and the characters (Blended windows); a skinned object with a bump-mapped Standard or SkinCloth material keeps its bone record with the extension. Records onlypc_shadingmakes name their maps in the extension alone and need a diffuse map:ZOldViewBase::PrimCreate(0x27cf14) enters a dot3 record's diffuse, normal and specular textures without checking them, and M13's secret service materials name a texture its TEX lacks, which crashed the first sweep. The texture converter keeps each cube map's six face ids after its levels (SPcTextureBlock::lCubeFaces). - Static and rigid meshes (
zoldviewpcmaterialsdl.cpp,ZOldViewSDL::DrawPcMaterial, called first byDrawNormalMapped): one pass of thepcmaterialprogram (port/shaders/pcmaterial.hlsl,VSPcMaterial/PSPcMaterial), which isAmbientHQ_PS20plus the Reflection and Illuminate passes added in the same pixel (they are additive on the PC; a blended material divides them by its alpha so the frame's blend keeps them). The PC's per-vertex light streams (one light colour, one light direction, an ambient colour; mat.md "Effect files and vertex streams") are computed byLightsStaticVertexSplit(lightssdl.cpp) from the same lights as the lit strips, as the PC's own function does since round 3 (checks): a hemisphere environment as a light along the normal bent towards the environment's direction, a directional environment's ambient and sun, and the point, cone and square lights, all as one colour from their direction weighted by (r + g + b) / 3, divided by the cosine at the vertex normal (at most doubled, 0 behind it) so that a flat normal gives exactly the lit strips' colour. Prims withoutLIT, or withUNLIT, get full brightness, as the lit strips do. Each instance keeps a GPU vertex buffer ofSDrawPcMaterialVertexSDL(position, UV, colour, tangent, binormal, normal, light direction, ambient, light colour; the draw list'sDRAW_VERTEX_PC_MATERIALformat), rebuilt when a hash of its light set and matrix changes; the eye-dependent terms are computed on the GPU in root space, which is the PC's cube space, soreflect(−eye, N)indexes the cube map directly. Cube maps are made on first use from the six faces (CubeForDraw, anSDL_GPU_TEXTURETYPE_CUBEwith the faces' mip levels). Missing maps bind white, as the PC binds its White1x1 texture forTXID0 (checks). Culling follows the material (TwoSideddraws both sides, the others cull back faces, as the PS2 dot3 path does).v4BumpScale, the detail map,v4SpecularPower,vSpecularLevel, the specular mask, the reflection mask and fall-off and the parallax with the PC's own 4 / −12,851 scale are applied; the wobble is too, but no shipped material uses it. - Skinned meshes keep the bone draw (
zoldviewbonessdl.cpp):BoneUsePcMaterialswitches a mesh whose bone record carries the extension to thepcskinprogram (VSPcSkin/PSPcSkin) with the per-pixel character lighting's vertex (the skinned normal in the colour), so the shadow map and instinct highlights still read its positions. The pixel shader lights the normal map with the three bone lights and the ambient (the PC'sv4BonesLightsmodel,AmbientHQ_MPS_PS20), adds each light's specular with the material's power, and for SkinCloth adds the rim light and translucency of the Lighting pass with each bone light as the back light. The tangent frame is rebuilt per pixel from the derivatives of the position and the texture coordinates: the PC meshes' tangents and binormals are dP/du and dP/dv (on M05_main, 28,013 and 28,406 of 29,397 skinned triangles within 60°, 3,324 and 3,349 of 3,386 static ones;build/matfx/py/tbcheck.py), so no tangent stream is needed. Rigid parts, the cut sequences' Prettylights and debug colours keep the old path. The PC draws the rim light only in its per-light Lighting pass, for the dynamic lights it gives a character; the port has only the three bone lights, so the rim appears where one of them is behind the character as the camera sees it.
OPENBLOOD_TRACE_PCMATERIAL=1 logs every 100 frames the PC material draws, the lit buffers rebuilt and what the caches hold; =2 also logs each instance as it is first lit (geom name, position, flags with the technique in the top byte, light count); =3 also logs once per level every static geom whose chain carries a technique other than Standard, a PC blend, an alpha fade or a scroll, with its position (how the capture views below were found).
Measured on 25 November 2026 (PC-data mode, Windows build, captures in the matfx worktree's build/runs/):
- M05's diving board (camera
OPENBLOOD_CAMERA=-1200,250,3600,-1200,0,2552after the briefing; mean of the board top, pixels 430 to 560 by 420 to 560): lit strips before dot3 (215, 194, 146), the PS2 dot3 passes (192, 192, 136),pc_shading(220, 201, 153). The PC material is within 7 of the lit strips' colour where the PS2 dot3 passes were 23 darker in red and greener, and the board's bumps are as faint asv4BumpScalemakes them instead of the PS2 passes' full-strength noise. - Converter (
pc_prims_test --pc-shadingover the 68 archives): all convert and decode exactly as without (9,128,191 triangles matched); 28,030 dot3 sub-prims against 22,035, 8,092,254 dot3 vertex tangent frames checked (300 off by more than 0.06, degenerate PC vertices); largest handle table 36,382 of 40,960 (M06_main); 380.6 MB against 364.1 MB. - Instances: M00's first view draws 437 PC materials a frame (253 prims, 898 lit instances, 4 cube maps); a street in M05 259; once lit, 0 to 17 buffers a frame are rebuilt (moving objects).
- Frame time (
OPENBLOOD_DETERMINISTIC=1, which draws the frames as fast as it can; 960 × 720; the difference between a 2,500-frame and a 500-frame run of the same start, so loading cancels; other agents' games shared the machine, so the spread is about 1 ms): M00 at the pier 2.0, 3.7 and 3.7 ms a frame withpc_shadingagainst 4.9, 5.0 and 5.1 ms with the PS2 dot3 passes, and M11's start 1.7 against 1.9 ms. One pass from cached vertex buffers costs less than the PS2 path's five passes of immediate vertices relit every frame. - Captures,
pc_shadingon and off (OPENBLOOD_CAMERAviews after the briefing): M05's diving board and pool (bump scale and specular), M05's street (the van's side window shows its cube map; the road and the puddles carry the reflection pass, faint from that view), M06's lobby (the candles and lamp bulbs self-illuminated), M12's White House walls (the PS2 passes' full-strength bumps againstv4BumpScale), 47's suit in M00 and M01 (the skinned normal map). The rim light is faint (strength 0.2 times a bone light's colour, at grazing angles only); no capture shows it clearly. Round 3 checked the cube maps' orientation, the default texture, the rim light and the light streams against the PC code (below); no PC screenshot was compared (analysis of the PC executable).
Other material classes¶
Round 2 converted the Standard and SkinCloth classes; the other PC classes stayed plain strips. Counted over the 14 mission scenes (build/matfx3/survey3.py in the matfx worktree; mesh objects, static / rigid / skinned):
| Class or term | Objects | Where |
|---|---|---|
Glow (Glow*.fx) |
4,858 / 293 / 32 (and 54 tweened) | every scene; 2,246 static ADD, 1,826 opaque, 384 TRANS, 180 TRANS_ON_OPAQUE, 143 ADD_BEFORE_TRANS, 77 ADD_ON_OPAQUE |
Glow with AlphaFadeEnabled |
595 static, 5 tweened | M11 (28 instances), M09 (21), M00 and M06 (14) |
| Glow with a cube-map reflection | 102 static | M00 (62 instances: windows, fences, houses), M04, M08, M09, M11 |
| Glow with a scroll | 336 static | |
Glass (Glass.fx) |
7 / 29 / 32 | bottles and drinking glasses (Ground_GlassMartini_01_00, Ground_BottleCoke_01_00); the 32 skinned are Characters/_Nude/Accessories_Glass_Transp, spectacles |
GlassSurface (GlassSurface.fx) |
13 static | M01 (doors D1, D2), M04, M05, M11, M12 |
Mirror (Mirror.fx) |
31 static | toilets and bathrooms in M00, M02, M03, M04, M05, M06, M08, M09, M10, M11, M12, the hideout |
Anisotropic (Anisotropic*.fx) |
1 static | M05's vet room floor (FloorTile_M05_04a); no hair uses the class |
Standard with SHADOW blend |
424 / 4 | fake shadow quads (Fakeshadow_*, Shadow_Maps/*_Basic_Square_H3), mostly M00, M03, M10 |
Standard with TRANSADD_ON_OPAQUE |
28 / 4 | bullet holes in metal, M12's briefing glass |
| Standard with a scroll | 96 | |
| Standard reflecting, skinned | 116 | sunglasses (BodyGuard_SunGlasses in M02, M03, M05, M12, M13) |
With pc_shading (PC-data mode) the converter now gives all of these the PC terms (MakePcStripFx in pcprims.cpp). A plain strips record is written 0x50 bytes long, so SPcMaterialExtension (0x140 bytes) sits from 0x48 and a reader that finds no PMFX there stays inside the record. ZOldViewSDL::DrawEntry hands such an entry to DrawPcMaterialStrips, which draws it with the pcmaterial program's technique branch:
- Glow (
Glow20.fxAmbient_PS10): unlit, the vertex colour timesv4DiffuseColortimes the texture (the converter clearsLIT); withAlphaFadeEnabledon a blended material the alpha is multiplied byCalculateAlphaFadeper vertex: the distance rampssaturate(length × scale + offset)multiplied together, timeslerp(Alpha2, Alpha1, saturate(cos × scale + offset))with the cosine between the eye ray and the normal (gm_vAlphaFadeDistScaleOffset,gm_vAlphaFadeAngleScaleOffset; mat.md). The Reflection pass is added: the cube map times the mask, the vertex colour (faded too) and the fall-off, with neitherv4ReflectionColornor a level, asGlow20.fxhas it. - Glass and GlassSurface:
DRAWMODE_ALPHA_BLENDsorts them after the opaque strips (texture priority 19), as the PC draws its Refraction layer after the Ambient one, but they draw opaque with depth. A run of them copies the frame (WaterCopyFrame, the PC'smapRefraction2D), clears the copy's alpha and draws the run's surfaces into it with alpha 1 (the RefractionMask technique), then draws each: Glass the lit texel (no ambient) overrefracted frame × gm_vRefraction2DColor × maskby the texel's alpha plus the specular; GlassSurface its specular (inv4SpecularColoralone, doubled) plus the refracted frame. The refracted frame is sampled at the pixel lessbump.xy × gm_vRefraction2DScale, or undistorted where that sample's mask alpha is not above 0.9. WithoutRefraction2DEnabledGlass is its specular over black, as on the PC. The Standard Reflection pass is added for both. - Mirror: the converter adds
DRAWMODE_MIRROR_MASKand gives the chain anSPrimHeaderStripMirror(0x80 bytes, no fog, not only the current room) when the header's bound is flat (shortest side at most a fifth of the next; M09's water mirror is not, and draws its mix over black).ZOldDrawBase::GeomCreatethen makes the geom a PS2 planar mirror,ZOldDrawIdListMirror::UpdateCameratakes the plane from the geom's bound as the PC does (FUN_004b31d0: the shortest axis through the centre), andZOldViewSDL::DrawMirrordraws the reflected view where the surface is: the PC'smapReflection2Dat those pixels. The main list's mirror entry then drawsMirror.fx's mix over it, premultiplied (One, InvSrcAlpha): withMirrorEnabledandMirrorMaskEnabledlerp(lerp(texel × lit, reflection, mask.a), colour × lit, colour.a), withMirrorEnabledalonelerp(reflection, texel × lit, texel.a), withMirrorMaskEnabledalonelerp(colour × lit, reflection, mask.a), plus the specular;litis(ambient + N·L light) × v4DiffuseColorfrom the light streams. No shipped Mirror material is bump-mapped, sogm_vMirrorBumpScaleoffsets nothing. In PC-data mode the reflected view keeps what lies more than 3 units in front of the plane (1 on the disc): M12's toilet mirrors sit about 2 units behind their wall's surface as the bound gives the plane, and with 1 unit the wall covered the reflection (the PC culls it: every material butTwoSidedculls back faces there).OPENBLOOD_PC_MIRROR_OVERLAY=0leaves the reflected view without the mix,OPENBLOOD_TRACE_MIRRORS=1logs each mirror drawn (geom, sub-list size, plane) and its entries every 100 frames,OPENBLOOD_MIRROR_MARGINoverrides the clip margin andOPENBLOOD_MIRROR_DEBUG=1draws the reflected view over the whole frame. - Anisotropic (
Anisotropic20.fxAmbientHQ_PS20):(ambient + anisoMap(N·L, N·H).rgb × light) × v4DiffuseColor × texel + anisoMap.a × light × v4AnisoColor. The one instance bindsTXID0, the white texture, so its whole surface takesv4AnisoColortimes the light; itsmapEnvironmentis an engine cube (below) and is not drawn. - Blends the PS2 equation
(A − B) × C + Dcannot express get blend factors of their own (SDrawStateSDL::lBlendFactors):TRANSADD_ON_OPAQUEOne, InvSrcAlpha andSHADOWZero, InvSrcColor, the PC's factors (ZRenderMaterialD3DFX, PC 0x494820:TRANSandTRANS_ON_OPAQUESrcAlpha, InvSrcAlpha;ADD,ADD_ON_OPAQUEandADD_BEFORE_TRANSSrcAlpha, One; onlyTRANSwrites depth). The converter's PS2 mapping drew the fake shadow quads as alpha blends, a pale blue patch on the floor (M00's crates); withpc_shadingthey darken the floor as on the PC. - Scroll:
gm_vScrollPosition, theSCRLspeed times the frame time, wrapped, added to the texture coordinates of every class (the water's rule; the PC's own time base was not traced). Standard materials withAlphaFadeEnabled(31 static objects) fade as Glow does. - Skinned meshes:
pcskinalso draws the Reflection pass (the cube map in the bump-reflected direction rotated to root space, times the mask, fall-off,v4ReflectionColor, the level andv4BonesLights[6].a, the bone-light total times 0.6667, capped at 1) for reflecting Standard materials, the sunglasses, and skinned Glass (spectacles; every one has a refraction scale of 0, so the refracted frame is the frame and the record's alpha blend by the texel's alpha is the PC's mix). Skinned Glow stays plain.
pcskin now normalises zero vectors safely: an unused bone light has no direction, and normalize of it made a NaN that, once the shader grew, a multiply by zero spread over 47's whole suit (drawn black).
Measured and seen on 25 November 2026 (PC-data mode, Windows build; captures in the matfx worktree's build/runs/at/ and build/runs/r3-*):
- M12's toilet mirror (
OPENBLOOD_SCENEFX_AT="6400,-440,60,0,0.2", mission 11): the mirror shows the room behind 47 (the door, 47's back, the waiter) under the material's dirt texture; with the 1-unit margin it showed the back of the wall, and from the disc the same mirror shows only its PS2 overlay texture (the disc keeps the 1-unit margin; not changed). - M00's fake shadows (
-13896,500,-244,0,0.6, mission 0):pc_shadingdarkens the floor around the crates; off, the same quads are a pale blue patch. - M00's car windows (
319,0,505,0,0.1): the Glow windows reflect the cube map (the fence and the sky); off, they show their texture. - Spectacles (the briefing portraits): Delahunt's glasses are transparent.
- M05's diving board (round 2's view): unchanged to the decimal, (220.1, 201.1, 152.8): it is lit by a directional environment, whose split did not change. The starts of M00, M05, M06 and M12 show no other change than these.
- Not captured: a static Glass or GlassSurface object and the Anisotropic floor (the views tried put 47 out of the rooms); the alpha fade of a Glow from up close.
Checks against the PC code¶
The shader behavior was checked against Ghidra’s C output and disassembly of the retail PC executable.
- Cube maps.
m34ObjToCubeSpace(parameter id 0xf, the switch around PC 0x491ea0) is the same matrix asm44World(case 4):FUN_00489560reorders the engine's z-row-first 3 × 3 into rows X, Y, Z and the switch transposes it, somul(m33, v)is the object-to-world rotation with no axis swapped. The port's root space is that world. The Windows build runs Vulkan (GPU driver vulkanin the log; the device is created for SPIR-V and MSL only), whose cube-face selection and face orientation are Direct3D's. But the face order was wrong: the TEX lists a cube's six images in its own order, andFUN_0048c900uploads image k to the Direct3D face{5, 4, 1, 0, 2, 3}[k](table at 0x00762db4), so the list is −Z (the cube's own id), +Z, −X, +X, +Y, −Y. The port took it for Direct3D's +X, −X, +Y, −Y, +Z, −Z and put two horizon images on top and bottom; the outdoor cubes' fifth image is the sky with the sun and the sixth the ground (M05's cube 296), now +Y and −Y. Fixed inCubeFaces. - Missing maps.
ZTextureManagerD3D::GetTexture(vtable +4, PC 0x48ef40) returnsWhite1x1for id 0 (and 0x800), a one-pixel 0xffffffff texture made inFUN_00489f70, so aTXID0 binding samples (1, 1, 1, 1): the port's white is right. A non-zero id whose slot was never loaded binds a null texture without a check (FUN_00496420), which the driver decides (usually black); the port binds white there too. ATXIDwith bit 31 selects an engine texture(n & 0x7fffffff) + 0x22: 0x80000000 to 0x80000003 are four dynamic 64 × 64 environment cubes thatZRenderEntryEnvSamplerD3D(render 0x4b6b90) renders from the nearestZEnvSamplergeom, one face per frame; 0x80000004 ismapReflection2D, 0x80000005mapRefraction2D. 140 Standard instances, one Glow and the Anisotropic floor reflect a dynamic cube; the port does not render those cubes and draws them without the reflection. - Rim light. Strength 0.2 is what the PC computes: the engine never sets
fRimLightStrengthor the other rim parameters (their names are not among the executable's strings), andSkin20.fx/Cloth20.fxaddsaturate(−E·L) × (1 − saturate(N·E)²)^power × v4RimLightColor × strengthto the diffuse term without the texture and without doubling, then multiply everything byv4DiffuseColor × v4LightColor × vertex colour, the light's attenuation and the shadow map.v4LightColoris the light's colour / 255 with no halving, the same scale as a bone light in the port, so a full light gives a rim of 0.2 × (0.977, 0.97, 0.72) at the silhouette: faint by design. What differs is which lights: the PC draws the rim only in the per-light Lighting pass, below. - Static light streams. The PC fills them in
FUN_0049eb00(fromFUN_004b1f90andFUN_0047ff10, which gathers up to 12 lights), 32 vertices at a time (0x49b7c0unpack, the SSE lighting at0x47ef40,0x4a2120pack), per vertex, cached per instance and redone only when the geom's lights are dirty. Light colour = Σ colour × attenuation × max(d·N, 0) / |d| × the cone or square term; direction = Σ d̂ × (r + g + b) / 3 × that factor; a hemisphere environment (type 3) addsback + (front − back)(0.5 + 0.5 N·−A)times V·N to the colour, along V =normalize(N + (−A − N) × max(N·−A, 0))(the V·N weight was missed until round 10, Hemisphere environments); a directional environment (type 4) adds its back colour to the ambient stream and its front colour × N·L to the light; the light colour is then divided by the cosine of the direction at the normal, at most twice, and is 0 behind it; the vertex colour (byte / 510) is folded into both colours. Round 3 changed the split to match: the hemisphere environment is now a light along the bent normal (round 2 put it in the ambient, which the bump does not shade), the weights are (r + g + b) / 3 (were 76/150/29), the cap is 2 and 0 behind (was 4 and 4), and the Reflection, Glass, Mirror and Anisotropic terms take the vertex colour with the streams. One difference remains: the vertex colour is applied on the GPU after the streams are clamped, not before. Until 26 November 2026 a second one was kept on purpose: a directional environment kept the lit strips' split (back + (front − back) × N·L, the PS2's) so that converted surfaces matched their plain neighbours, which the lit strips drew the PS2 way. That was the cause of the dark sunlit ground in M01 and M05; the plain surfaces and the split now both take the PC's sum (Directional environments).
Character lighting on the PC¶
The PC lights a skinned mesh in two parts (CalcBoneLightSources, PC 0x4af470, through ZRenderDrawD3D vtable 0x764f14 +0xbc; ZRenderEntryLightD3D, 0x4b5a70). v4BonesLights holds three directional lights and the ambient from the lights without per-light flag 0x2: the environment light as −row 0 with colour RGB / 255 × the static shadow multiplier × multiplier × 0.5 and its back colour as the ambient (not subtracted from the light as on the PS2), omni and spot lights by distance and cone, more than three merged pairwise into the one with the closest direction; v4BonesLights[6].a is min(1, 0.6667 × the total light received), which scales the skinned Reflection pass. Every light with flag 0x2 is left out of the bone lights at shader quality 2 or more and instead draws one additive Lighting pass on every geom in its volume (no count limit): the diffuse, specular, rim and translucency of that one light, with v4LightColor = colour / 255, v4LightAttributes (1 + k n², √k, multiplier, 1 / far) with k = 1 / (f² − n²), and its projector and shadow map. The environment's bone light takes the PC's colour (the front colour not reduced by the back colour) with pc_lighting from a PC installation (Directional environments and the sunlit ground). The port's bone draw keeps the PS2's three bone lights for everything and applies the rim and translucency with each of them, so the rim follows the strongest lights where the PC's follows the flag-0x2 lights only. Splitting the lights the PC's way needs the light records' flag 0x2 carried into the converted lights and a per-light pass on characters; not done.
Directional environments and the sunlit ground¶
At the starts of M01 and M05 the real PC game's sunlit ground was about 1.2 times as bright as the port's, while the walls and houses were within about 10 % and 47's back was 0.8 of the PC's (Compared with the real PC game). The cause was the environment light. Both scenes are lit by a directional environment (light type 4, bIsDirectional): M01's courtyard by front colour 0xffeabc × 1.1 and back colour 0x596868, M05's street by a similar pair. The PS2 and the PC combine the two colours differently:
- PS2. The lit strips' VU program and the port's
LightsStaticVertexgiveback + (front − back) × N·L(SetDot3Environmentincalclightdot3.cppthe same), andZOldDrawBase::CalcBoneLightSources(PS2 0x275c70) gives the characters' third bone lightfront × multiplier × static shadow multiplier − back(at least 0) withbackas the ambient. - PC. The static vertex streams:
FUN_0047ff10stores, for an environment light, the back colour at slot +0x1e0 andfront − backat +0x1ec (FUN_004287f0is a vector subtraction; the colours are the record's bytes × multiplier / 255, PC 0x48024d to 0x4802ff).FUN_0047ef40then, for type 4 (PC 0x47f8d1), adds the back colour to the ambient stream and(back + (front − back)) × N·−A, that isfront × N·L, to the light stream (FUN_00429220is a vector sum,FUN_0047eea0adds to the light colour,FUN_0047eef0to the direction):back + front × N·Lin all. The characters' bone lights (CalcBoneLightSources, PC 0x4af470) keep the front colour whole too, with the back colour as the ambient (Character lighting on the PC).
So where the sun shines straight on, the PC adds the back colour on top of the PS2's sum. The PC data's environments are made for that sum: M01's back colour is 0x596868 in the PC data against 0x445050 on the disc. In shade (N·L ≤ 0) both give the back colour, which is why the walls matched.
With pc_lighting from a PC installation (LightsPcEnvironment in lightssdl.cpp) the port now does the PC's:
LightsEnvironmentadds the back colour to a directional environment's direction colour. Every user of the light set blendsback + (direction − back) × N·L, so the plain lit strips (LightsStaticVertex), the PC material streams (LightsStaticVertexSplit) and the PS2 dot3 passes all giveback + front × N·L.ZOldDrawSDL::UpdateDynamic(zolddrawbonessdl.cpp) callsCalcBoneLightSourcesand then redoes the third bone light's easing step from the stored light with the environment's colour unreduced (PcBoneEnvironmentLight:front × multiplier × static shadow multiplier, the PS2 code's half-colour bytes and its flag test included), for every environment type, as the PC's function treats them alike.
OPENBLOOD_PS2_ENVIRONMENT=1 keeps the PS2's blend, for comparisons. The disc and pc_lighting=off do not change. Hemisphere environments (type 3) were taken to be lit as the PC does, so M00, M02, M04, M09 and the indoor scenes did not change, except for the characters; they were not, see Hemisphere environments.
Measured against the real PC game at the starts (version=pc, 1,024 × 768, frame 2,000; region means R G B; build/light/ in the matfx worktree, meas.sh):
| Region | PC | Port before | Port after |
|---|---|---|---|
| M01 ground under 47 (300..700, 500..700) | 54 51 40 | 40 38 30 | 51 49 39 |
| M01 sunlit ground (150..400, 250..330) | 98 84 57 | 75 64 41 | 99 86 58 |
| M01 a sunlit dapple (150..200, 645..690) | 111 91 61 | 76 64 42 | 105 86 59 |
| M01 a shaded dapple (215..250, 555..595) | 64 63 45 | 49 47 33 | 62 62 44 |
| M01 wall (700..1000, 150..250) | 53 56 45 | 50 52 41 | 57 59 46 |
| M01 47's back (430..540, 430..560) | 22 22 26 | 18 18 24 | 21 21 25 |
| M01 whole frame | 67 63 45 | 53 50 36 | 68 64 46 |
| M05 lawn (0..300, 520..700) | 44 38 23 | 37 31 18 | 44 38 23 |
| M05 pavement (650..900, 300..600) | 66 53 40 | 54 42 30 | 66 53 41 |
| M05 road (100..500, 250..450) | 101 85 66 | 83 67 49 | 99 84 64 |
| M05 houses (300..700, 0..100) | 90 82 66 | 81 73 58 | 85 77 61 |
| M05 47's back (340..560, 330..600) | 33 28 21 | 28 23 18 | 31 27 20 |
| M05 whole frame | 68 59 44 | 57 48 34 | 67 58 43 |
The 4 × 4 grid's mean luma difference from the PC fell from 12.0 to 2.2 in M01, from 10.5 to 1.1 in M05 and from 18.1 to 7.3 in M13 (the credits behind the funeral, also a directional environment); the table of every level is under Compared with the real PC game.
Hemisphere environments: the V·N weight¶
At M04's start (round 10) the port's path and lawn were about 1.2 times as bright as the real PC game's (the 4 × 4 grid 8 above on average), while the huts, the rocks and the trees behind matched. M04 is lit by a hemisphere environment (Spot_Sun_B_01, type 3, front 0xfef7eb × 1.2, axis (−0.50, −0.62, 0.61): a high sun), so the directional fix above did not apply. Binning the pixels below the horizon by the port's own static shadow factor (the frame with and without OPENBLOOD_NO_STATIC_SHADOWS=1) gave a PC-to-port ratio of 0.83 to 0.87 in every shadow band from 0.5 to 0.9 and 1.05 where nothing is shadowed (the huts, the characters): not the shadows' strength, but a factor on the lit ground.
The factor is in the PC's static light streams (FUN_0047ef40, the type-3 case at PC 0x47f69b, from the jump table at 0x47fef4; the hemisphere factor is the mulps/addps with 0x7620e0 at 0x47f7e7). For each vertex it computes the hemisphere colour C = back + (front − back)(0.5 + 0.5 N·−A) (the constant at 0x7620e0 is 0.5) and the bent vector V = N + (−A − N) × max(N·−A, 0), normalised, and then adds C × V·N to the colour stream and V × (r + g + b) / 3 of C (0x762140 is 1/3) to the direction stream. The final loop divides the colour by D·N for the summed direction D (the reciprocal capped at 2, 0x7620c0) and the shader's saturate(dot(vLightDirTS, N)) (Standard20.fx) multiplies it back, so a surface lit by the hemisphere alone is lit by C × V·N. The port's lit strips (LightsStaticVertex) took C and its PC material streams (LightsStaticVertexSplit) took C along V, so both missed V·N. For a horizontal surface under M04's sun, N·−A = 0.62, V = (0.31, 0.76, −0.38) / 0.907 and V·N = 0.84, the measured ratio. A surface turned away from the light (N·−A ≤ 0) has V = N and keeps the whole colour, which is why the huts' fronts matched.
With pc_lighting from a PC installation (LightsPcEnvironment) both now weight a hemisphere environment by V·N; OPENBLOOD_PS2_ENVIRONMENT=1 and the disc keep the whole colour. At M04's start (frame 1,600 of a deterministic run, region means R G B, PC against the port before and after): the path (300..600, 280..420) 96 96 83, 106 108 93 and 93 94 81; the far path (450..700, 170..230) 71 77 65, 84 92 77 and 71 77 64; the lawn right (650..820, 150..220) 39 45 30, 44 51 33 and 37 43 28; the lawn left (180..330, 60..180) 48 56 35, 57 67 42 and 48 57 36; the path at the bottom left 52 56 46, 62 67 55 and 53 56 46; the hut on the right 75 75 58, 79 78 61 and 75 75 58. The characters' bone lights are not changed (the PC's CalcBoneLightSources treats environments separately, Character lighting on the PC).
Blended windows (M03's glass doors)¶
At M03's start (launcher mission 2) the real PC shows the opera's guests through the glass of the closed entrance door at the top of the stairs (pc-m03-b.png); the port's PC version showed the lobby behind the glass without them, and the guests appeared only when someone opened the door. From the disc, and with pc_shading=0, they were there. Ruled out first: the room exits (a test build that treated every closed exit as open changed nothing; CDoorBase::CloseGates, PS2 0x2cdb5c, PC 0x5b4eb0, closes the door's exit on both). The glass panes are Window_Big and Window_Small of Si03G_Door_Entrance_Geom_00 (at 3,428, −595, ±145), a Standard material with TRANS, a specular term and a cube map (OPENBLOOD_TRACE_PCMATERIAL=2: flags 0x146).
The cause: with pc_shading the converter writes blended Standard materials that reflect, self-illuminate or have a normal map as dot3 records, and ZOldViewBase::CalcTexturePrioity (PS2 0x281bb8) sorts every dot3 record with the opaque strips (texture priority 4), before the characters (9 to 14). The window, drawn blended but writing its depth, came before the guests behind it, whose pixels then failed the depth test, so the glass showed only what was drawn before it (red-carpeted stairs and a grey wall, where the PC, the disc and the port now show a white door, two guards and the guests). An alpha-blended strips record sorts after the characters (19), as the PC draws its "Blend" layer after the opaque one. The port's ZOldViewBase::CalcTexturePrioity (viewoverridesdl.cpp; overrides) now gives a dot3 record whose PC material blends (PCMATFX_BLEND) that 19; from the disc nothing changes (no extension). Tried first and reverted: writing those materials as plain strips records carrying the extension from 0x48, as the other classes are. That fixed the doors but lost the records' tangent streams, and M06's bar tablecloths came out striped, with a black notch, from the tangent frame the shader rebuilds from the derivatives. With the sort fix the guests show through the glass at the PC's place and the tablecloths are as before (build/post/prio.png in the hud worktree: the PC's door, the port's, and M06's tablecloth before and after). The merge of round 9 brought that strips conversion back with the decal fix and with it the tablecloths' notches; round 10 removed it again (Blended surfaces).
Plane align: glows that face the camera¶
Found at M09's start in round 10 (26 November 2026), a port bug in both versions.
The PS2. A strips record whose draw mode has 0x10000000 is drawn facing the camera. ZOldDrawPS2::CalcStripChainStartValues turns the bit into VU1 control 0x100, and VColClip's InitPODRegs (0x497 to 0x4a6) then overwrites the object's rotation rows Z, Y and X (TOPS+3..5) with the camera's forward, up and right axes in root space, taken from m_RootToCamera44 (TOPS+45..47, its rows transposed), keeping the object's position (vu-programs.md). The same bit also turns the depth write off (CalcGSRegs). On the disc every glow, glow-system disc and dust quad has it (M09: 151 Glow, 51 Glow_MED, 16 Glow01_Large, 27 Al20_Dust, 5 GlowSystem02_Cone; draw mode 0x304c0052 or 0x305c0052), and 0x20000000 with it, which no PS2 code reads.
The PC data. The PC's mesh objects carry both bits in byte 0x0d, which prm.md called lProperties ("3 on tweened objects"): it is 3 on 7,204 of the 68 archives' objects (glows, Glow_Volume, glow-system cones, dust, candle flames, PlC05A_Billboard_Palm, smoke), 659 of them tweened. Paired by geom name with the disc's records over the mission scenes, the 1,583 objects with 3 are exactly the ones whose PS2 twin has 0x30000000, and no other paired object has either bit (build/light10/pair.py in the matfx worktree). The PC's own camera-facing code was not located; the captures show it does the same (below).
The port drew these prims with their own rotation, so a glow quad was seen flat or edge-on: M09's torch glows, which stand in vertical planes facing along x or z, were invisible from 47's camera, and the PC data's river-boat glow systems (Pc09M_Spotlight_RiverBoat_01 to _03!GlowSystem01_Cone1 to Cone8: eight quads of radius 26 to 325 units along each spotlight's beam, in the plane through the beam that ZMatrix's reversed rows give, which is horizontal) were the thin white shaft. Now:
PlaneAlignedMatrix(zoldviewsdl.cpp) gives a prim with 0x10000000 the camera-to-root rotation and its own position;StripsUniforms(plain strips, dot3 and the PC material draw) and the normal-plane cull use it. In the PC material draw the shader's normal, eye and alpha fade take the aligned matrix; the vertex lighting keeps the object's own (the materials concerned are unlit). Geoms in camera space (IsLocal) are left as they are.- The converter (
ReadObjectinpcprims.cpp) ORs byte 0x0d << 28 into the object's draw mode, so the PC data's records have the disc's bits. - With the disc, the newly visible glows also needed the PS2's angle-blend fade (draw mode 0x40, VU1 control 0x400,
Apply_AlphaEffect), which the port never drew: on the PS2 the torch glow fades in from 100 to 600 units, so a glow quad next to 47 is faint.StripsAngleBlendFade(zoldviewsdl.cpp, read bygeneral.hlsl'sVSMain) applies its distance ramps from the record'sSPrimHeaderStripDestinationAngleBlend, with the constantsZOldDrawPS2::AddPrimToDMAChainuploads: 0 at near 1 rising to 1 at near 2, 1 at far 1 falling to 0 at far 2, by the vertex's distance from the eye in object space. When the header's two angles are equal (every glow header of M09: both 0, opacities 100 and 0, 80 or 90) the opacity is opacity 1, as the PC's conversion of the same headers has it (the Glow materials'gm_vAlphaFadeAngleScaleOffset(0, 1, opacity 1, opacity 2), whose angle term is always 1). The angle ramp between two different angles is still not drawn; the PC data's materials have their own fade (CalculateAlphaFade, Other material classes).
OPENBLOOD_NO_PLANE_ALIGN=1 draws the prims with their own rotation again, for comparisons.
On the disc at M09's start the torches now show a glow at a distance and a faint one next to 47; M05's start (no such prims in view) is unchanged.
Rigid meshes: the bone lights¶
Found at M09's start in round 11 (27 November 2026). The river boats moored beside 47's pier (Ground_Boat_RiverBoat_01_Skin01 to Skin04, PC-data only; the disc's boats are part of the static scenery) are bone objects with rigid parts, bump-mapped, so with pc_shading their parts are dot3 records drawn by DrawPcMaterial with the static per-vertex streams. Their light sets had two to four lights (the boats' spotlights, the torches, Spot_Graveyard_02) and no environment: ZOldDrawBase::GeomCreate/UpdateEnvLightChoice give a geom with bones none (a bone object gets its environment through CalcBoneLightSources), and ZOldDrawSDL::UpdateLight gathers the lights of a bone geom with dot3 records (GEOMCONTROL_DOT3, 0x100, which zolddrawsdl.cpp calls GEOMCONTROL_OWNER_BONES) for the static streams. So the boats were black, and the nearer one's deck was lit white where the spotlight's cone reached its vertices.
The PC lights a rigid mesh as it lights a skinned one (mat.md, "Effect files and vertex streams": a2vStandardRigid has no light streams, and the AmbientRigid technique takes v4BonesLights): the three directional lights and the ambient CalcBoneLightSources (PC 0x4af470) computes for the object, the lights evaluated at the object's centre, not per vertex. In PC-data mode DrawPcMaterial now takes, for a geom with bones (or drawn by an owner with bones), its streams from the entry's DirectLights (LightsBoneSet, lightssdl.cpp): three lights of a new type LIGHT_DIRECTIONAL (the root-space direction towards the light and its colour; the third is the environment, with pc_lighting's unreduced front colour, Character lighting on the PC) and the ambient, which LightsStaticSetup, LightsStaticVertex and LightsStaticVertexSplit take (an ambient term vAmbient was added to the light sets). The pixel shader is unchanged: three lights collapse into one stream as the static lights do, exact for a flat normal. OPENBLOOD_PC_RIGID_STATIC_LIGHTS=1 keeps the static streams.
At M09's start (frame 2,400 against pc-m09-b.png, region means R G B): the far boat's deck (500..600, 260..290) 59 57 59 on the PC, 57 55 56 now; the nearer boat's deck (640..740, 300..330) 48 47 48 on the PC, 193 185 180 before (the spotlight's white) and 46 46 47 now; the boats' chain and both decks are visible as on the PC (c-m09-bone1.png in the scenefx worktree's build/r11/). Tried first: giving such geoms their room's environment for the static streams (Outside_env_background), which lit the boats grey but kept the spotlight's white deck. This also applies to items attached to characters and drawn with the PC material program (they take their owner's bone lights, as on the PC).
Standard material shaders¶
Effect files and vertex streams¶
The .fx sources ship in every scene archive. A class layer's PATH names a family ("Standard", "Skin", "Cloth", "Glow", "Anisotropic"; or a whole file such as "Glass.fx"); the 00, 13, 20 and 30 files of a family are its shader-model levels (ps_1_x fixed function, ps_1_1/1_3, ps_2_0, ps_3_0; the executable formats the names with %s%d, string 0x7b85a0). Standard30.fx only redefines the three Lighting techniques (with GetShadowMapPS3's 16-tap shadow filter); everything else is Standard20.fx, so a ps_2_0 or better card draws the techniques below. Each technique's Identifier is the layer's IDEN; the MESH_STANDARD, MESH_TWEENED, MESH_RIGID and MESH_WEIGHTED symbols select the variant by the object's sub type, and BLENDENABLED the blended render states.
The vertex declarations (D3DVERTEXELEMENT9 arrays in the executable's data, 0x763a74 to 0x764c98) show where the shaders' inputs come from:
| Declaration | Stream 0 (the PRM vertex buffer, prm.md) | Further streams |
|---|---|---|
0x7644a8 (rigid, a2vStandardRigid) |
position, normal, COLOR0 vertex colour, UV, tangent, binormal (D3DCOLOR), TEXCOORD1 SHORT2 at 0x24 |
none |
0x764368 (static, a2vStandardHQ) |
as above, the vertex colour as COLOR3 |
stream 1: COLOR0 light colour, COLOR1 light direction, COLOR2 ambient (three D3DCOLOR) |
0x764320 (static, a2vStandard) |
as above, the vertex colour as COLOR1 |
stream 1: COLOR0 light colour |
0x764460 (weighted, a2vStandardMPS) |
position, three weights, bone indices, normal, colour, UV, tangent, binormal | none |
| 0x7641f8, 0x764558 (tweened) | the two keys in streams 0 and 2 | streams 1 and 3: the light colour, direction and ambient of each key |
So a static mesh's lighting is not in the files: the PC engine computes one light colour, one light direction and an ambient colour per vertex and streams them beside the PRM buffer, and the shaders light per pixel from those (and per light, additively, in the Lighting pass, below). A skinned or rigid mesh is lit by v4BonesLights: three directional lights (direction, colour) and an ambient, the same model as the PS2 bone draw. The word at 0x24 of every PC 0x28-byte vertex is 0xcdcdcdcd (the debug heap's fill; the exporter never wrote it), and the declaration reads it as vParallax, (−12,851, −12,851) as SHORT2.
What each technique computes¶
tosigned(x) is 2x − 1; D3DCOLOR inputs are 0 to 1. N is the bump normal of CalculateBumpNormalPS: (tosigned(tex.agb) × v4BumpScale).xy plus the detail map's at uv × vBumpDetailTileFactor times v4BumpDetailScale, with z rebuilt as √(1 − x² − y²) (so v4BumpScale below 1 flattens the bumps; 2,023 of the bump-mapped instances have 0.99). L, E and H are the light, eye and half vectors in tangent space (CalculateTangentSpace: the rows tangent, binormal, normal).
| Technique (layer) | Blend | Colour |
|---|---|---|
Ambient (static, AmbientHQ_PS20) |
replace (or the material's blend) | 2 × ((ambient × v4DiffuseColor + saturate(L·N) × lightcolour × v4DiffuseColor) × tex + pow(saturate(N·H), v4SpecularPower.x) × vSpecularLevel × lightcolour × v4SpecularColor × mask); alpha vertex alpha × OPAC × tex alpha |
AmbientRigid, AmbientMPS (AmbientHQ_MPS_PS20) |
as above | 2 × ((Σₖ colourₖ × saturate(Lₖ·N) + ambient) × vertex colour × tex × v4DiffuseColor + Σₖ colourₖ × pow(saturate(N·Hₖ), power) × mask × level × v4SpecularColor) over the three bone lights; no parallax for skinned meshes (the vertex shader sets the scale to 0) |
Lighting (Lighting_PS20), per dynamic light |
add (SrcAlpha, One), black fog | (saturate(N·L) × v4DiffuseColor × v4LightColor × vertex colour × tex + pow(saturate(N·H), power) × level × v4SpecularColor × v4LightColor × mask) × the light's projector map, back-face and distance attenuation × the shadow map |
Reflection (Reflection_PS20) |
add (One, One), z equal, black fog | mask.rgb × texCUBE(mapEnvironment, reflect(−E′, N′)) × v4ReflectionColor × (max(n·L, 0) × lightcolour + ambient) × falloff(1 − saturate(E.z)) × vReflectionLevel, with N′, E′ in cube space (m34ObjToCubeSpace) and n the vertex normal; rigid and skinned meshes use v4ReflectionColor × v4BonesLights[6].a instead of the lighting term |
Illuminate (Illuminate_PS20) |
add (SrcAlpha, One), black fog | tex × mapIllumination × vertex colour × v4IlluminationColor; alpha tex alpha × map alpha × vertex alpha × OPAC |
Skin DiffuseBumpSpecularTransRimLight, Cloth DiffuseBumpSpecularRimLight (the SkinCloth class's Lighting layer) |
add (SrcAlpha, One), z equal | (saturate(N·L) × tex + saturate(−E·L) × (1 − saturate(N·E)²)^fRimLightPower × v4RimLightColor × fRimLightStrength + v4SubSurfaceColor × fSubSurfaceTransparency × |mapTranslucency.rgb · e| × saturate(−E·L)) × v4DiffuseColor × v4LightColor × vertex colour + specular, times the light's attenuation and shadow; e is the object-space direction from the eye to the vertex. Cloth has no translucency term. The rim term is a back light: it is strongest at the silhouette when the light is behind the surface as the eye sees it |
Skin and Cloth Ambient, AmbientMPS |
replace | as Standard's (the static one without the ambient term) |
- Parallax (
CalculateTexCoordsPS):uv += normalize(E).xy × (mapParallax.r × vParallaxScale − vParallaxBias) × 4 / vParallax. WithvParallaxthe vertex's (−12,851, −12,851) the offset is at most a few thousandths of the texture (M01's roof, bias 8, 0.0025: a texel and a half of a 512 map) and runs against the eye: the PC's parallax is practically invisible. - Wobble (
AmbientHQ_VS20andReflection_VS20withWOBBLEENABLED):position += fWobblePosAmplitude × normal × cos(fWobbleWaveLength × (vEngineTime − u × fWobbleUSpeed − v × fWobbleVSpeed)), and the same cosine timesfWobbleNorAmplitudeadded to the normal's x. No shipped material enables it. - Cube maps:
mapEnvironmentnames the cube map, whose own id is the first of the six images the TEX's second table lists (tex.md), several often the same texture (Reflection_08_FX_H3: 279, 280, 280, 280, 281, 281). The list is not in Direct3D's face order:FUN_0048c900uploads image k to the Direct3D face{5, 4, 1, 0, 2, 3}[k](table at PC 0x00762db4), so the images are −Z, +Z, −X, +X, +Y, −Y (in M05's outdoor cube 296 the fifth image is the sky with the sun and the sixth the ground).m34ObjToCubeSpace(effect parameter id 0xf, set by the switch at PC 0x491ea0 exactly asm44World, case 4) is the transposed matrixFUN_00489560builds from the object'sZMatrix(rows in the order m0[2], m0[1], m0[0], asmload44does): the object-to-world rotation, so the cube is indexed in world (root) coordinates with no axis swapped. - Default textures: a map binding with
TXID0 (no texture; 483 of the 1,282 reflecting Standard instances have no mask, 332 no fall-off, and many self-illuminated ones no illumination map) is looked up through the texture manager like any other (ZRenderMaterialBinderTextureD3DFX, PC 0x496420; the binder at 0x471b90 readsTXID,FMIN,FMAG,FMIP,TILU,TILV,TILW).ZTextureManagerD3D::GetTexture(vtable +4, PC 0x48ef40) returnsWhite1x1for id 0, a one-pixel 0xffffffff texture made inFUN_00489f70, so the binding samples (1, 1, 1, 1), as the port's missing maps do. A non-zero id whose slot holds no texture binds a null texture (no check inFUN_00496420). ATXIDwith bit 31 set names an engine texture, parameter(n & 0x7fffffff) + 0x22: 0x80000000 to 0x80000003 the four dynamic 64 × 64 environment cubesZRenderEntryEnvSamplerD3D(PC 0x4b6b90) renders from the nearestZEnvSamplergeom of its slot, one face per frame; 0x80000004mapReflection2D, 0x80000005mapRefraction2D. 140 Standard instances, one Glow and the Anisotropic floor reflect a dynamic cube (0x80000000 or 0x80000001); the port does not render those cubes.
Effects by scene¶
Counted over the 14 mission scenes' .MAT and .PRM: instances of the Standard and SkinCloth classes with each switch on (and, where needed, its map present), and in brackets the mesh objects that use them, static and rigid / skinned. WobbleEnabled is never on.
| Scene | Bump | Specular | Reflection | Illumination | Parallax | BumpDetail | RimLighting | SubSurface |
|---|---|---|---|---|---|---|---|---|
| hideout_main | 187 (785/29) | 296 (1127/33) | 26 (72/0) | 2 (3/0) | 16 (21/2) | 6 (156/0) | 5 (0/18) | 1 (0/3) |
| M00_main | 306 (1521/360) | 382 (1713/360) | 61 (262/6) | 7 (13/0) | 25 (162/4) | 13 (58/0) | 43 (1/331) | 7 (0/69) |
| M01_main | 293 (961/1104) | 399 (1375/1104) | 28 (91/3) | 10 (16/0) | 7 (46/2) | 6 (93/0) | 67 (6/1049) | 9 (0/212) |
| M02_main | 312 (1247/1695) | 391 (1606/1695) | 106 (530/30) | 25 (71/0) | 19 (102/31) | 14 (72/0) | 65 (5/1595) | 9 (0/378) |
| M03_main | 276 (1136/1067) | 343 (1341/1067) | 64 (287/15) | 9 (12/0) | 16 (29/8) | 8 (103/0) | 58 (10/986) | 10 (0/259) |
| M04_main | 248 (1440/1010) | 312 (1652/1010) | 38 (349/15) | 11 (25/0) | 14 (143/4) | 16 (334/0) | 56 (6/942) | 12 (0/227) |
| M05_main | 325 (1449/656) | 413 (1675/656) | 72 (284/19) | 14 (44/0) | 28 (184/10) | 6 (71/0) | 58 (46/599) | 12 (0/156) |
| M06_main | 376 (2235/1412) | 445 (2722/1412) | 68 (533/0) | 18 (55/0) | 26 (162/2) | 2 (17/0) | 79 (6/1327) | 7 (0/335) |
| M08_main | 246 (1224/1233) | 350 (1673/1233) | 78 (561/0) | 11 (26/0) | 10 (29/8) | 3 (12/0) | 58 (14/1169) | 9 (0/278) |
| M09_main | 265 (1562/1301) | 300 (1676/1305) | 41 (335/8) | 5 (22/0) | 19 (78/11) | 3 (19/0) | 59 (6/1222) | 9 (0/328) |
| M10_main | 236 (1276/787) | 330 (1740/787) | 58 (539/0) | 8 (31/0) | 17 (49/8) | 1 (1/0) | 58 (7/745) | 9 (0/171) |
| M11_main | 328 (1392/1990) | 419 (1718/1992) | 72 (496/0) | 17 (56/12) | 30 (169/30) | 19 (128/0) | 81 (6/1892) | 11 (0/442) |
| M12_main | 301 (1638/1049) | 399 (2036/1049) | 75 (527/10) | 15 (34/0) | 12 (43/10) | 3 (6/0) | 66 (22/981) | 10 (0/282) |
| M13_main | 170 (565/280) | 246 (976/282) | 26 (86/10) | 11 (18/0) | 4 (2/8) | 1 (1/0) | 32 (0/249) | 8 (0/73) |
Over all 68 archives: 9,981 Standard instances (4,978 bump-mapped, 6,890 specular, 1,282 reflecting, 250 self-illuminated, 287 parallax, 164 with a detail map), 880 SkinCloth (860 bump-mapped and specular, all 880 with the rim light, 146 with sub-surface translucency), 2,619 Glow (85 reflecting, 168 alpha-faded). Specular powers (v4SpecularPower.x) are most often 64 (2,806 specular Standard and SkinCloth instances), 50, 25 and 100, and reach 255; the PS2 dot3 passes use 16 for all. The SkinCloth rim light is almost always v4RimLightColor (0.977, 0.97, 0.72), power 16, strength 0.2; the translucency colour (0.99, 0.29, 0.29) with transparency 0.2. The reflecting Standard instances are mostly opaque (256 with a mask, a fall-off and a normal map, 142 flat with a fall-off and no mask), 253 blended; cars, chrome, glass, puddles and the White House floors (Reflection_Cube_M12_Whitehouse).