Stage shaders (<NAME>_vs.cso / <NAME>_ps.cso)
The material shader name
(extras.pd_shader, e.g.
sd) maps to SD_vs.cso
/ SD_ps.cso in the package root
(upper-case name; vkblink →
vkBLINK). They are DXBC shader
model 4.0 with RDEF reflection, so constant
buffer variables keep their names.
converter/dxbc_dis.py (our own
minimal disassembler) prints the bindings,
signatures and instructions. Findings:
Vertex shader (SD, SDREFS, SDYFOG; SBTS does the same per pixel in tangent space):
- hemisphere:
k = dot(n, cS0_VEC.xyz) + cS0_VEC.w;ambient = cS1_COLv + k · (cS0_COLv − cS1_COLv)(clamped to [0, c0.y] in the REFS variants); - directional:
cDL_COL · max(dot(n, −cDL_VEC), 0); - one point light:
cP0_COL · max(dot(P0_POS − p, n) / |P0_POS − p|³, c0.x); - both are multiplied by the vertex colour
(
COLOR0.rgb, our baked shade); - specular from
cDL_SVEC/cSPECULAR(power in.w), weighted byCOLOR0.a · (cEYEVEC.w − max(dot(cEYEVEC.xyz, n), 0)); FOG0= clip-space w (the view depth), UV ×c_SCALES.z.
- hemisphere:
Pixel shader (SD):
rgb = saturate(tex · ambient + tex · diffuse) + specular. There is no 2× modulate and no gamma conversion: plain 0..1 products of texture and constants. The alpha channel is an alpha-test value (misc_constant.x), and a screen-door stipple (StippleBuffer) discards pixels for fades.SV_TARGET1getsblend_colour.SBTS (normal mapped): see “SBTS (normal mapped)” below.
REF variants: see “Reflection (REF shaders)” below.
sbtscloud3: sky layers, see “Sky dome and clouds” below.vkblink:saturate(tex · c32)with a constant colour from the vertex shader; no stage light.scal(skycol2 r2, 11-15): the inner sky dome of st05 / st15 / st25 (stage model 2, vertex format 0x09). Likesc, the vertex shader only transforms the position, scales the UV byc_SCALES.zand passes the vertex colour on; neither shader has a light constant. Pixel:rgb = tex.rgb · clamp(COLOR0.rgb, −1, 1),alpha = tex.a · clamp(COLOR0.a, −1, 1), discarded whenalpha ≤ misc_constant.x(andalphakillontex.a = 0); no stipple (SC has one). The material entry (all three stages): flags 0x10011, blend word 0x11xx = one / one, additive. So set 2’s point light never reaches it: drawn unlit (PdData.UNLIT_SHADERS).Alpha (SD, SBTS, SBTSREFS): the texture alpha
abecomes(4a − 3) · w(SD/SBTS:w = COLOR0.w · c0.z + c0.w, where the vertex shader’sCOLOR0.wismax(N·L, 0)), and the pixel is discarded when it is≤ misc_constant.x; separately,alphakilldiscardsa = 0. The executable fillsc0(pixel shader: 0.8, 0.8, 0.8, 1/124) andmisc_constant.x(alpha reference 0), so texels pass when a > 0.75 (see “Shadow volumes”). Godot and the glTF (alphaCutoff) cut at 0.75.sdal(st07, st17): lit like SD, but the output alpha is the texture alpha unchanged, and it is discarded only when≤ misc_constant.x. Its texture is near black (mean RGB 0/0/16 of 255) with soft alpha (7 % zero, 47 % below 0.5, 32 % opaque), drawn on 119 primitives of st07’s model 0: a shadow overlay that is alpha-blended over the walls and floor. With a 0.5 cutout and no blending it showed as hard pure-black blotches (playtester, 11-02). pdconv writesalphaMode: BLEND; Godot draws it withblend_mix, no depth write (PdData.BLEND_SHADERS). The blend state is not in the .cso but in the stage’s material entry (same layout as the effect materials, “Effect drawing”): st07/st17’ssdalmaterial has flags 0x1D (blend on, no depth write, back faces culled) and blend word 0x5400 = source alpha / inverse source alpha, add. Decoded (lightextras): ourblend_mixwithout depth write is that state. Checked the same way:scflags 0x10011 / word 0x1100 (one/one, additive),sbtscloud3word 0x1400 (source alpha / one), thesbpxref*allayers 0x1400 or 0x5400.isyogore(st07, 4 primitives): the output alpha and its alpha test use the vertex alpha (COLOR0.a · c34.w; 255 on st07), not the texture alpha. The texture alpha only weights the second (slot 1) and third (slot 3) texture terms. So it is opaque, never cut by texture alpha (pdconv writes noalphaMode; Godot:PdData.OPAQUE_SHADERS). Its layered combine is not reproduced yet (base texture only).No fog in the PC pixel shaders: they receive
FOG0but never read it (the Xbox original used fixed-function fog, which D3D11 lacks). Godot draws none either (PC target); the light script’s fog values are converted but unused.Hemisphere weight: not decoded. The shaders don’t show how the executable fills
cS0_VEC.w(andcS1_COLp.wfor SBTS), i.e. half-Lambert0.5 + 0.5 n·aor plainn·a. Checked and ruled out as sources: the light script’s axis is unit length in every set of all 20 stages (no weight in its length), its colours have no alpha byte,0x2000has no spare argument, and0x2003has no set index. The executable references constants by register, not by name (no constant or reflection names in it), so finding the upload needs a real disassembly. Godot’s half-Lambert (PdData.hemi) was chosen by comparison with one capture (st03 walls), not decoded — needs playtester; plainn·amakes those walls about half as bright as the capture.Constants from the executable (lightextras). The exe keeps one class per shader (RTTI names
alsh_Shader<NAME>, e.g.alsh_ShaderSDYFOG) and a table of 48-byte entries {object,.csoname} per vertex/pixel shader; each class’s draw method uploads the vertex constants through one setter (register, data, count). Found so far:cSPECULAR(c2): only when the material entry’s flags (u32 0x0C) have bit 2 (0x4), else 0: rgb = material bytes 0x36, 0x35, 0x34 (Esper-RE’sunk11, read as B, G, R) × the directional light colour × 2/255; w (power) = byte 0x37. The vertex shader uses it asspec = [N·L > 0] · [N·H > 0] · |N·H|^power · cSPECULAR.rgbwithH = −cDL_SVEC, then the pixel shader addsmax(spec · w, 0)with the fresnel weightwof the REF notes.- The view matrix (global, the camera’s or built by the look-at helper) is a row-vector, left-handed look-at: column 2 = normalize(target − eye), translation row = −(axis · eye), so view z grows away from the camera (D3DXMatrixLookAtLH layout). The upload multiplies the model matrix by it (MV = model × view, row-vector).
cEYEVEC(c14) = (MV[0][2], MV[1][2], MV[2][2], 1 + 0.01 × the material’s s16 at 0x40): column 2 of MV, i.e. the camera’s forward axis in model space, pointing away from the viewer (not normalized; the stage model matrix has no rotation or scale). Somax(cEYEVEC.xyz · n, 0)is 0 on surfaces facing the camera and the weight there is the fullCOLOR0.a · cEYEVEC.w; it only drops on faces turned away. w: Esper-REunk12[2], 50–100 on REF materials, so 1.5–2.cDL_SVEC(c5) = normalize(L + 0.5 · (MV[2][0], MV[2][1], MV[2][2])), L the light set’s direction (the light’s travel direction, ascDL_VEC): row 2 of MV, not the column the eye vector uses (for a stage, the world z axis in view coordinates). The shader’sH = −cDL_SVEC. Reproduced as is.cP0_COL(c6) = point light 0’s colour × its range;cP0_POS(c7) = its position in model space, w = range.cDL_COL(c3) = the light set’s light colour;cS0_COLv/cS1_COLv(c8, c9) = sky / ground colour with w = 0.5 (the hemisphere light entry).cS0_VEC(c10): the character shaders (SWBOS,SWBOSM2,SWD,SWDSP) upload the axis with w = 0.5, i.e.k = n·axis + 0.5. The upload for the stage shaders was not found (it is not in their draw path,SD*class methods), so the stage weight stays as chosen.cTMAT0(c16) forSDYFOG/SBTSYFOG: the model matrix’s y column (x, y, z rows) and w = its y translation + dot(two global vectors at 0x1405a5cb0 / 0x1405a5cd0), i.e. the fog coordinate is the world height plus an offset. Since no PC pixel shader readsFOG0(all 69 with aFOG0input checked), height fog has no visible effect on PC.