Stage cull mode
The render-state emulation (see “Shadow
volumes”) maps the cull state 0x93
as 0 → none, 0x900 → front,
0x901 → back (D3D11 cull modes
1/2/3). The 62 functions that set it with a
constant use 0x901 57 times, 0 23
times (mostly one draw, then back to
0x901) and 0x900
twice, so back-face culling is the
default. Which state is active while
the stage models draw is not traced yet. Godot
draws stage surfaces double-sided and lights the
side facing the camera (PdData
PRELIT_CODE). --cull-back (debug,
after --) draws them one-sided
instead. The scene pass set up at the function
that binds sampler slots 3–8 (slot 3 is the SBTS
lookup) sets cull none and doesn’t restore it,
so the stages most likely draw double-sided in
the game as well.
The stage vertex shaders light with the
stored normal (dot(n, −cDL_VEC), no
view term), so a back face is lit as its front.
Until this branch, Godot flipped the normal
toward the camera (written before pdconv’s
normals pointed out, to fix “up-facing” ceilings
that were really inverted normals). That made
lighting view-dependent: faces whose plane the
camera crosses switched between lit and unlit.
On st02 that showed as a dark patch growing
under the plank slabs as the camera moved (the
slabs, layout models 12–16, bridge a crater in
model 0; seen under a slab edge from a low
camera, the crater’s lip and side faces flip to
unlit). Godot now uses the stored normal;
--flip-normals (debug) brings the
flip back.