SC (the sky
dome on st22 and others):
rgb = tex · COLOR0, no light and no
fog output; the alpha is the usual alpha-test
value. Godot draws sc unlit and
unfogged (it was lit and fogged), still
additive: over the black clear colour that
equals opaque, and on st07 a cloud layer lies
behind the dome, which an opaque dome hid
(checked by render). pdconv writes no COLOR_0
for its vertex format, so the vertex colour is
white. (skyglow 11-13) The format
(0x09) has a grey vertex colour at +16 (st02’s
outer dome about 0.5, st22’s 0.55) and the blend
is per material (st02’s outer dome and st22’s
dome are opaque): see “Sky and far scenery
draw”. On st22 its texture is a flat dark
blue.
SBTSCLOUD3:
three texture sets on the same UV, each with its
own offset (vertex constants
c90.xy, c90.zw,
c91.xy, set by the executable each
frame: the scroll). Slot 0 is
the cloud colour (texture_idx),
slots 1 and 2 are normal maps
(normal_idx,
normal_backup_idx; pdconv:
pd_layer1, pd_layer2)
whose alpha gives the coverage:
(skyfix2, re-read from
SBTSCLOUD3_ps) two overlay-like steps, but
the second factor of each step is one minus the
step’s own clamped product, not
one minus the other alpha (the shader reuses the
product’s register):
p = sat(2·a1·a2),
m = a1 > 0.5 ? 1 − sat(2(1 − a1)(1 − p)) : p;
then r = sat(2·m·a0),
alpha = (m > 0.5 ? 1 − sat(2(1 − m)(1 − r)) : r) · COLOR0.a,
alpha-tested at misc_constant.x
(the stage materials’ reference 0). The textbook
overlay we used before
(1 − 2(1 − a1)(1 − a2),
1 − 2(1 − m)(1 − a0)) gives less:
st03’s mean coverage was 0.60, with 15 % of
texels below 0.1; e.g. (a0, a1, a2) = (0.38,
0.66, 0.55) is 0.858, not 0.62.
Colour:
sat(t0 · min(sat(N·L · cDL_COL) + sat(N·P · c5 + cS0_COLp), 1)).
N is the two layers’ normal maps, each ×2 − 1,
summed and clamped to ±1, then one Newton step
toward unit length,
N + (1 − N·N)·c0.w·N (c0.w = 0.5,
decoded in skyfix5). L and P come from the
vertex shader in tangent space, packed x·c0.w +
c0.w: L = (−cDL_VEC·T, −cDL_VEC·B, −cDL_VEC·N),
and P the direction from the vertex to cP0_POS
in the same frame, × cP0_POS.w / distance². No
vertex colour. UVs:
uv · c_SCALES.z + c90.xy / c90.zw / c91.xy.
Draw state (material
record, st03 model 2): flags 0x43d (blend on, no
depth write, back faces culled), blend word
0x1400 = source alpha / one. Godot:
blend_add (src · alpha + dst),
which is that state. The colour texture’s alpha
is only one input of the coverage. pdconv writes
the material as MASK when that texture has alpha
(st03/st13/st23), but Godot must not cut by it
(PdData skips
alpha_mask for CLOUD_SHADERS).
Godot pitfall (skyfix2):
once a shader writes
ALPHA_SCISSOR_THRESHOLD on any
path, Godot cuts every fragment by it (default
1.0 where it isn’t set) and draws the survivors
at alpha 1. In the additive pass that dropped
every cloud texel below coverage 1 and drew the
rest at full weight, giving the hard blotches
(st03/st13/st17), st02’s lost cap (vertex alpha
0.9) and st12’s black cut-off cap. The additive
shader no longer writes it (masked glows discard
by hand). On st22 every alpha (colour texture
and both layers) is 255, so the alpha is 1
everywhere and the cloud shape is only in the
colour (white clouds on black): the layer must
be added over the dome
(alpha-blended it would hide the dome
completely), as Esper-RE’s viewer draws it.
Godot keeps it additive, weighted by that alpha,
lit as above.
(skyfix5)The cloud class’s
draw (RTTI
alsh_ShaderSBTSCLOUD3, vtable
0x14048fe28, draw method 0x1402a07b0): the
vertex constants go through the shared stage
path (0x1402a7200: matrices, then 0x1402a6750,
which writes cDL_VEC (c4) as the
light set’s direction turned into the model’s
space and cP0_POS (c7) as point
light 0’s position in model space); the pixel
constants through the bind SBTS uses
(0x1402a7880: c3 the directional colour, c5
point light 0’s colour, c6 the hemisphere’s sky
colour), from the light slots 0x1402a7a00 fills
(the set chosen by 0x140199970, set 0 in a
match; (skyglow 11-13, corrected)set 2 while the sky object
draws the sky model: “Sky and far scenery
draw”). Then its own two uploads:
pixel c0 = (0, 0, 0, 0.5)
(0x1402f8780): the 0.5 in the normal
renormalisation is decoded.
scroll c90.xy / c90.zw /
c91.xy = the material’s three velocity pairs
(s16 at material +0x3c..+0x46) × the integer
part of a global counter (0x14057f398) ×
1e-5 (0x1402f7c08). The counter
goes up by one in the update at 0x1401c77fc and
wraps at 4 000 000 (that update is inside the 30
Hz game tick 0x1401c7630: one step per tick,
decoded (skyglow 11-13)). Godot takes
one step per 30 Hz game tick (PLACEHOLDERS
“Cloud scroll rate”): st03’s colour layer moves
(0.039, −0.022) UV per second.
(skyfix5)Why st03’s sky is
about half as bright as the texture.
St03 has no SC dome. Its only sky is model 2,
one SBTSCLOUD3 layer (736 triangles), added over
the clear colour (the script’s 0x2001 colour,
(15, 18, 25)). Behind the clouds there is only
that colour: a render with the layer hidden
reads exactly (15, 18, 25), so Godot applies no
gamma or tonemap to it. The dome’s stored
normals point inward: mean N.y
= −0.88, N·(−light direction) between −0.92 and
−0.24 (p10/p90). They agree with the winding on
all 736 faces, and the game culls back faces, so
the front faces look inward. (skybright
11-15: wrong in one point. Model 2 has three
index buffers; the two pdconv drops are
untextured svc layers, and the
first is an opaque backdrop dome of (76, 80,
102) behind the clouds. The game’s frame clear
is black and the 0x2001 colour is the shadow
colour. See “St03 sky brightness against the
Xbox”.) The tangent-space light is
therefore negative everywhere, sat(N·L) = 0, and
the colour is t0 × sat(N·P·c5 + sky). Point
light 0 is black in set 0, so that is t0 × the
set’s sky colour, (0.49, 0.51, 0.53) on st03.
(skyglow 11-13, corrected) That holds
for set 0 only. The sky model is drawn with
light set 2, whose light
travels upward: N·L is positive over the dome
and st03’s result is about t0 × (0.68, 0.59,
1.0) (“Sky and far scenery draw”). Godot uses
set 2 for the sky model since skyglow (11-13).
(skycol 11-15, corrected) That product
leaves out set 2’s point light 0, which is near
white on st03 and lifts most of the dome to t0 ×
(1, 1, 1): “Sky colour: set 2’s point
light”.
(skyfix5)Xbox
side (default.xbe, read as in “Xbox
capsule shading”). The disc’s
st03.alr converts to a
byte-identical glTF/bin with identical cloud
textures, so the data is the same. The
SBTSCLOUD3 vertex program builds the same terms
as the PC’s (L = −c4 on (T, B, N), the point
light likewise, UV × c12.z + c90/c91, vertex
alpha passed on, fog = clip w). The combiner’s
colour is the PC formula: sat(N·L)·c3 +
sat(sat(N·P)·c5 + c6), × t0, with the constants
in registers 3/5/6. The coverage
differs: each overlay step takes one
minus the other input, the textbook
overlay
m = a1 ≥ 0.5 ? 1 − sat(2(1 − a1)(1 − a2)) : sat(2·a1·a2),
then the same with m and a0, × vertex alpha. The
PC port’s second factor is one minus the step’s
own product. The PC form gives more cover
(st03’s textures: the Xbox form gives 0.89 × the
PC’s coverage-weighted colour). The Xbox look
uses the Xbox form (cloud_xbox).
Not explained by anything decoded: the xemu
capture of st03’s intro is about twice as bright
with white highlights. Same data and same colour
math would need a lit dome (N·L > 0) or other
constants at draw time on the Xbox; the Xbox
draw code (which light set and c4
the sky pass uploads) is not traced.
(skyglow 11-13) The PC code selects
light set 2 for the sky model, which lights the
dome; very likely the same on the Xbox, and it
explains the capture.
Why st22’s sky was grey:
the sc dome was drawn additive
and fogged; additive surfaces fog
toward black, and the dome lies beyond st22’s
linear fog end (1474 units), so it came out
black and only the grey clouds were left. SC has
no fog output, so the dome now gets no fog (and
no light): it shows its navy texture with the
clouds added on top.
SBTSCLOUD2:
the same alpha, coloured with the hemisphere
(cS0_COLp/cS1_COLp)
instead.
Scroll: the cloud
materials’ unk12[0..5] (Esper-RE’s
material_entry) are three s16
pairs, one per UV set (checked on st01, st03,
st07, st22: the cloud materials have signed
values in pairs there; SC/SD/SBTS/YFOG materials
are 0 in [0], [1] and [3]) (st22: (−100, 50),
(−160, 80), (−60, 0); st03: (130, −72), (118,
−131), (80, −68); st07: (120, 0), (60, 0), (160,
0)). We read them as the velocities behind
c90.xy, c90.zw,
c91.xy (colour, layer 1, layer 2).
pdconv writes them as
extras.pd_scroll. The unit is
decoded (skyfix5, above): 1e-5 UV per counter
step
(PdData.CLOUD_SCROLL_UNIT).
Other material fields (hypothesis,
not used):unk11 looks
like the specular colour and power
(cSPECULAR): RGB + a power byte,
e.g. 4c4c4c/20 on st03’s SBTS
floors, 67676750 on SDREFS,
7f7f7f14 on every cloud. REF
materials also have unk12[2] =
50–100 and unk12[4..6] = (5–50,
same, 10–20); meaning unknown.