SBTS (normal mapped)
SBTS, SBTSYFOG (the
same pixel shader; the vertex shader differs
only in FOG0, see “Height fog”),
SBTSREFS, SBTSREFP.
Used on every versus stage: 1587 plain
SBTS/SBTSYFOG index buffers and 109 REF ones
over the 19 stages (st03: 40 sbts +
7 sbtsrefp materials; the Palace
floor is sbtsrefp). Read from our
disassembly of the PC shaders and the exe.
- Tangent frame: vertex
format 0x03 bytes 24 and 28 hold the tangent and
the binormal the vertex shader reads, packed
11:11:10 like the normal. pdconv
--statsover all 19 stages: every frame is either unit length with the binormal on the +cross(N, T) side (glTF space; 0 vertices with w = −1 on any stage) or near zero (both vectors shorter than 0.1: st03 1526 of 56 933, st24 1329 of 19 315, 190–1103 elsewhere; st04/st14/st24 have about 20 more unit frames whose binormal is skewed off cross(N, T)). The binormal follows −V of the UV (mean B·∂P/∂v = −0.96 over st03’s 25 546 SBTS triangles of model 0); the tangent is ±∂P/∂u. pdconv writes TANGENT with w = the stored binormal’s side; Godot builds B from it (BINORMAL = cross(N, T)·w). - Vertex stage: the lighting
vectors go to tangent space per vertex, by dot
products with the stored T, B, N. The light
vector (towards the light,
−
cDL_VEC) and the half vector H = normalize(normalize(cEYEPOS− p) −cDL_VEC) (the per-vertex Blinn half vector, not the SD shaders’cDL_SVEC) use (T, B, N). The hemisphere axiscS0_VECand the unit vector to point light 0 (scaled bycP0_POS.w/ distance²) use the opposite tangent signs, (−T, −B, N), and are passed packed as x·c0.w + c0.w (c0.w inferred 0.5, see PLACEHOLDERS). The fresnel weight is vertex alpha × (cEYEVEC.w− max(E·N, 0)) with E the unit vector from the vertex to the eye; the vertex shadeCOLOR0.ris passed on as a scalar. Slot 0 and slot 1 share one UV (×c_SCALES.z). A zero stored frame gives zero tangent-space x and y, which Godot reproduces by keeping T = B = 0 there. On all 19 stages every near-zero frame sits on a vertex whose stored normal is zero too (st03: all 1526, used by 673 triangles whose three corners are all zero), so the game’s tangent-space vectors are fully zero there. glTF gets T = N = 0 for them, and Godot’s import turns both into the same unit vector (so T = N after import), which the shader reads as “no frame”. The imported unit normal is not the game’s zero (PLACEHOLDERS “SBTS zero stored normal”). - Pixel stage (plain SBTS):
colour from slot 0 (wrap) and the normal map
from slot 1 (wrap, same UV). The normal is n =
(rgb − 0.5)·2, neither normalized nor
green-flipped. The ramp (slot 3) is sampled at
(n·L, n·H); its rgb times the
light colour
cDL_COL, saturated, is the diffuse. Hemisphere: k = n·axis·h + h with h =cS1_COLp.w, ambient = sat(sat(k)·sky + (1 − k)·ground). Point light: pl = sat(n·P), and the point colour (pixel c5) enters twice, sat(pl·c5)·c5. Then rgb = max(sat(tex·D + tex·ambient)·shade, 0) + sat(ramp.a × normal-map alpha × fresnel weight ×cSPECULAR.rgb), with D = sat(point term + diffuse) and shade the vertex’sCOLOR0.r. The packed vectors unpack as (clamp(x, −1, 1) − 0.5)·2. Alpha: (4a − 3)·(sat(ramp.b)·c0.z + c0.w), which keeps the same cut at a > 0.75. - The ramp (slot 3) is not in
the stage: the class
alsh_ShaderSBTS(vtable 0x14048fce8) loads.\system\spec77.ddsin its init (0x1402a0030: path from the strings at 0x1402f3790 and 0x1402f78c8, loader 0x14028e220) into its +0x10, and its bind (0x14029fe60) sets slot 3 to the material’s third texture if it has one, else that ramp. The material’s third index (normal_backup_idx) is 0 on every plain SBTS/SBTSYFOG buffer of all 19 stages, so they all use the ramp. The file (Assets/Data/System/spec77.dds, also a copy inAssets/Data) is an uncompressed 256² A8R8G8B8 DDS without mip maps: rgb = u (the grey value is the column, so the diffuse is plain sat(N·L)), alpha = f(v) only, 0 below row 194 and rising to 255 at row 255 (≈ v^20: the shine curve, so the material’s power byte is not used by SBTS; the shine needs N·H above ≈ 0.76 and the fresnel weight, so it shows on grazing edges more than on floors seen from above). The class’s sampler setup (0x14029fd30, state setter 0x140020c40: state 0/1 = AddressU/V, value 3 = D3D11 CLAMP) sets slot 3 to clamp in U and V (slots 0/1: wrap), linear filtering.converter/rampconv.pywrites it as<data>/system/sbts_ramp.png. - Pixel constants (bind
0x1402a7880, shared by SBTS and the REF
variants): c2
cSPECULAR= the SD specular colour (0x1402a75e0: material bytes 0x36/0x35/0x34 × the light colour × 2/255, only with flag 0x4; w = power, unread), c3 = the light colour, c5 = point light 0’s colour with w = 0.5, c6/c7 = the hemisphere’s sky/ground with w = 0.5 (stored at 0x1402a78df), so k = 0.5·n·a + 0.5 (half-Lambert, decoded for SBTS). Pixel c0 = (0.8, 0.8, 0.8, 1/124) (0x140490c00). One st08 material has a blackcSPECULAR(no shine). - REF variants
(
SBTSREFS/SBTSREFP, no slot 3, nocSPECULAR): a Lambert of the normal map, D = sat(n·L)·cDL_COL+ sat(n·P)·point colour, the same hemisphere ambient A (not saturated before use), mask m = normal-map alpha × fresnel weight, base’ = tex·sat(1 − m + env.rgb), and rgb = max(sat(D·base’ + A·base’)·shade, 0) + (D + A)·env.rgb·m·env.a·shade·2. The normal is (rgb − 0.5)·2, or expanded a second time when the pixel constantrgbsigned.yis set (not traced, taken as 0). The env UV is offset bybumpenv2(c21) × the normal map’s (b, g) (not traced). st03/st13/st23 use REFP (the floor), st04–st08, st14–st17, st24–st26 REFS. - Godot:
PdData._set_sbts/ PRELIT_CODEsbts1 (ramp) or 2 (REF);--no-sbtsturns it off,--no-sbts-shinedrops only the ramp shine.