The "fireballs like the demo vids" arc, decomp/content-grounded end to end,
plus the live-play UX batch verified over the same sessions:
FIRESMOKE SHEET (the PFX fireball fix): every firesmokeN_scr_tex in BTFX.VMF
maps the SAME 64x64 tileable noise image bintA (variants differ only in SCROLL
rate) and firesmoke1_mtl colours it through the "fiery" ramp (0.3,0.1,0.1)->
(0.9,0.7,0.3). The particle layer now bakes ramp(lum(bintA)) as its sprite
colour (noise detail in alpha) and SCROLLS it at firesmoke1's authored rate
via a texture-transform; the port's radial soft-edge mask moved to a second
CLAMPed stage so the WRAPPED scroll rolls flame through the sprite without
scrolling the edge away. Old grit x radial bake kept as the no-BINTA fallback.
Impact hits, damage-band smoke and death booms all ride this layer.
AUTHORED TEXTURE SCROLL in the model path: the BMF TEXTURE records carry
SPECIAL " SCROLL u0 v0 du dv" (tag 0x2037); the draw path always supported
per-op scrolling (SetTextureScrolling) but the BGF loader never parsed it, so
every scrolling material rendered frozen. Wired TexRef -> MatInfo -> batch ->
L4TEXOP.doScroll: the flame cards (flamebig/fire5) now roll fire noise.
VERTEX-ALPHA EFFECT CARDS (the "twisted drill bit of fire" fix): FLAMEBIG's
verts carry authored float RGBA -- white-hot base (1.0,0.99,0.97) -> dark-red
tip fading to alpha -0.2 (the DPL clamp convention). The loader kept a flat
batch colour and drew it OPAQUE = a solid orange spike. Corpus sweep: exactly
14 shipped BGFs carry vertex alpha, ALL effect cards (flames, MUZFLASH,
EXDISK_A/B/C, TMST_A/B/C, beam models, DECLOUDS). Such batches now keep the
authored per-vertex gradient and route to the alpha-blend pass, unlit,
colour = texture x gradient, alpha = the vertex fade; sky objects excluded
(drawAsSky + alphaTest passes NEITHER pass filter -- DECLOUDS stays in the
sky pass). MUZFLASH/EXDISK render correctly for free when the muzzle-model
work lands.
WRECK DRESSING (the 1996 ExplosionScripts case-4 transcription): pieces spawn
HIDDEN and reveal 0.25s after the boom (the InstanceSwitch delay, behind the
dnboom flash); flamebig hangs over the pile, Y-BILLBOARDED at the camera
(SetOffsetYaw + a camera-pos getter -- the dpl_SetDCSReorientAxes analog);
the MakeDCSFall settle arms at the reveal with the two authored rates (hulk/
debris -0.025 t^2, fires -0.01 t^2 -- the flames ride above the sinking pile
and die with it at burial). EMPTY-PLACEHOLDER hulk guard: THRDBR.BGF is a
153-byte zero-geometry stub that "loads fine" -- vertex-count check now routes
it to the gendbr fallback (a Thor wreck was invisible). Hulk content census
recorded: AVADBR==MADDBR==VULDBR geometry (palette-only prefix diffs),
RAPDBR==SNDDBR==STIDBR byte-identical -- wreck variety is materials + the
dressing, not unique piles.
LIVE-PLAY BATCH: muzzle resolve uses the named segmentIndex (raw +0xdc read
was layout garbage); forward launch frame (authored MuzzleVelocity +Z vs the
mech's -Z facing); dock-bottom single window (gauge strip appended below the
world viewport, 1100x600 default, BT_DEV_GAUGES_WINDOW=1 restores the separate
window); portrait sec surface unrotated CW; ammo counters live via typed
bridges (BTAmmoBinCountPtr/BTAmmoBinFeeding/BTWeaponAmmoBin -- raw bin+0x180
and a hand-rolled link walk were garbage); fourth fire key ('4' = Pinky);
panel/arc probes de-aliased (%61 prime).
KB: rendering.md (vertex-alpha card family + scroll), combat-damage.md (hulk
census + THRDBR stub), gauges-hud.md (ammo bridges).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
7.5 KiB
id, title, status, source_sections, related_topics, key_terms, open_questions
| id | title | status | source_sections | related_topics | key_terms | open_questions | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| rendering | Rendering — the D3D9 pipeline, materials, sky, beams, performance | established | PROGRESS_LOG.md §10 (render-fidelity notes); docs/BGF_FORMAT.md |
|
|
|
Rendering
The port renders via the WinTesla L4D3D/L4VIDEO Direct3D9 path (wintesla-port), carrying our
BT loader (bgfload.cpp) + fidelity work. The goal: match the authentic pod footage. Geometry/LOD
mechanics are in bgf-format; this topic covers the D3D9 draw path + the fidelity fixes. Full
detail: docs/PROGRESS_LOG.md §10.
The IG-board shading model (from libDPL DPLTYPES.H)
Shading is selected PER-GEOMETRY by vertex type: no-normal geometry (terrain/mesas/sky/buildings/
mech — WHITE baked verts) is UNLIT, colorized by the material's 2-endpoint material-ramp
(dpl_SetMaterialRamp — texture luminance indexes a low→high gradient); normal-bearing geometry
(~150 vehicle/missile files) is LIT by the map light. Applying the ramp to lit geometry = the "dusty
white blobs" bug (gate on hasNormals). [T2]
Exception: cockpit-frame (*_cop) batches are pure-emissive constant colour (0.13,0.12,0.15),
BT_COP_FRAME overrides — see cockpit-view (task #55; the old BT_COP_RAMP_L ramp-index
approach is retired). [T2]
VERTEX-ALPHA EFFECT CARDS (2026-07-12) [T1 corpus-swept]: exactly 14 shipped BGFs carry
per-vertex float RGBA with alpha < 1 (tags 0x0082/0x008A, RGBA at +12, values OUTSIDE [0,1] —
clamp): FLAMEBIG/FIRE5 (flames), MUZFLASH, EXDISK_A/B/C, TMST_A/B/C, BLUEBEAM/GREEBEAM/RED_BEAM/
PPC, DECLOUDS — the EFFECT-CARD family. Their authored gradient (white-hot base → dark tip fading
to alpha −0.2) IS the shading: drawn opaque with a flat batch colour they render as solid shapes
(the wreck flame read as a "twisted drill bit"). The loader now keeps the authored per-vertex
RGBA for any batch with vertex alpha < 1 (BgfDrawBatch.vertexAlpha) and L4D3D routes it to the
ALPHA-BLEND pass, unlit, colour = texture × gradient, alpha = vertex fade (SRCALPHA/INVSRCALPHA).
SKY objects are excluded from the routing (drawAsSky + alphaTest passes NEITHER pass filter —
DECLOUDS must stay in the sky pass). Authored TEXTURE SCROLL (BMF TEXTURE tag 0x2037
" SCROLL u0 v0 du dv", e.g. firesmoke1 = 0.05,−0.331 uv/s) is now parsed and propagated to
L4TEXOP::doScroll — scrolling materials (firesmoke flame cards) animate in the model path. [T2]
The big render-fidelity fixes (dbase/desert matched to pod footage)
- Geometry: CONN is a flat trilist (not fan); CONN+PCONN coexist — see bgf-format. Malformed fan-garbage was the "faceted mountains" bug. [T2]
- RAMP colorize (default-on
BT_RAMP) + day/night material priority (default-onBT_MATPRIfor the ramps): themat\daylibs carry the warm ramps; the generic GEO libs are gray. Terrain/mesas render warm tan; the sky'sdsky_mtlramp (0→0.99) gives bright clouds.hasNormalsgate keeps vehicles LIT (colored trucks). Ramp tint rule: explicit diffuse + NEUTRAL ramp ⇒ tint; coloured ramp ⇒ white. [T2] - Sky: a
*sky.bgfdome/plane drawn in a dedicated fullbright PASS_SKY (LIGHTING off, extended far=9000 + world fog); taggeddrawAsSkyat load (the.xsidecar path doesn't exist). [T2] - The env pipeline (
DPLReadEnvironment→DPLReadINIPage, readscontent/BTDPL.INIviaL4DPLCFG): resolves map+time → clip/fog/ambient + a directional sun. Bring-up stubs (EnsureValidProjection / per-frame ambient / uninit cloud colours) had clobbered it — now they RE-ASSERT the env values. Debug: copy BTDPL.INI → *DBG.INI withdebug=True. [T2] - Projection / stencil (task #55): the BTDPL.INI
viewangle=60is the HORIZONTAL FOV — authentic 60×47 frustum at 4:3; fovY derived viaBTFovYFromHorizontal(L4VIDEO.cpp), applied at all 5 projection sites (it was mis-applied as vertical). The device depth-stencil is nowD3DFMT_D24S8for the cockpit punch stencil-cut (L4VIDEO.cpp:2799; sequence L4D3D.cpp:1199-1248) — see cockpit-view. [T2]
Backface culling (default CW, BT_CULL)
The bring-up D3DCULL_NONE drew interior/back faces (the "dark wedge" shapes = mesh insides). CW is
correct for the BGF quad triangulation [a b c][a c d]. [T2] Exception: cockpit *_cop batches
default DOUBLE-SIDED (BT_COP_SINGLE=1 restores single-siding, diag) — see cockpit-view. [T2]
LODs (default: shipping-engine first-LOD + ADDITIVE_LODS; BT_ADDLOD/BT_LOD_SCALE/BT_PUNCH)
See bgf-format for the √3 range decode, the ADDITIVE_LODS cumulative rule, PUNCH cutouts, and the coplanar-shell submission-order depth bias. Replacement LOD selection for NON-additive multi-LOD models is deferred (needs the board's hot-spot semantics). [T2]
Mech skins (BSL bit-slice — the rainbow-mech fix)
.BSL is a bit-sliced container (6 grayscale sub-images per file); the BMF 0x18 BITSLICE tag picks
the slice. Reading it as RGB overlaid 2-3 gray sheets = the "rainbow/graffiti" bug. Fixed:
image.cpp decodeBSL slice-decodes; bgfload threads the 0x18 channel; a cross-library RAMP registry
resolves the mech-skin softer ramp (defined in OTHER libs). Every mech renders authentic gray-metal
paint now. See asset-formats. [T2]
Weapon beams (the unported dpl_* layer)
The dpl_* beam renderable was never ported → beams are drawn by BTPushBeam/BTDrawBeams
(L4VIDEO). The real look is the ermlaser.bgf TUBE (native Z 0..−2000, UVs tiled) with the scrolling
bexp grit texture (from the .VMF SCROLL). ER lasers red, PPC blue, standard yellow. The beam
origin re-anchors to the live muzzle every frame (can't run out from under your own beam). See
combat-damage for fire-rate/muzzle. [T2]
Translocation warp (the respawn vortex) — see translocation-warp
The death/respawn "blue whirlwind" is tsphere.bgf (a 12-facet bicone) spun on-axis with the bintA
cloud through a wide lavender ramp, drawn as SKY. Full geometry/material/lifecycle/env in
translocation-warp. ⚠ Rendering-wide fix that came out of it: L4D3D::SetTextureScrolling
computed its texture-matrix offset as scrollDelta × absolute_time, which grew unbounded and collapsed
UV float precision → grainy/spoked scrolled textures the longer a session ran. Wrapped with fmodf(…, 1.0f). This also cleans up the scrolling bexp beam grit and any other SCROLL material. [T2]
(Bug class: reconstruction-gotchas §13.)
Performance — the 10fps→60fps fix (~50-80× render speedup)
The 10fps baseline had THREE stacked causes, all fixed (engine tree): (1) D3DCREATE_SOFTWARE_ VERTEXPROCESSING — every vertex transformed+lit on the CPU → HARDWARE first; (2) D3DX DrawSubset
attribute-table scan (our double-sided tris broke OptimizeInplace) → explicit SetAttributeTable +
direct DrawIndexedPrimitive; (3) no frustum culling → bounding-sphere culling per frame. ⚠ LESSON:
the user plays the DEBUG build, but the 10fps was NOT the debug build (RelWithDebInfo identical) —
split draw-vs-present + check the DEVICE flags before blaming the compiler. Diagnostics kept:
[spike]/[loadobj]/[rstat]. [T2]
Key Relationships
- Geometry/LOD: bgf-format. Base: wintesla-port (L4D3D). Shadow/visual-conform: locomotion.
- Renders on: pod-hardware (main 3D view).