Fire VISUALS wave: the authored firesmoke sheet, vertex-alpha effect cards, the case-4 wreck dressing
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>
This commit is contained in:
co-authored by
Claude Fable 5
parent
bb795e2805
commit
48c9c8444f
@@ -423,7 +423,14 @@ d3d_OBJECT* d3d_OBJECT::LoadObjectBGF(LPDIRECT3DDEVICE9 device, char *fileName)
|
||||
m.Diffuse.a = 1.0f;
|
||||
m.Ambient = m.Diffuse; // matches the .x path; lit by scene ambient even w/o direct lights
|
||||
|
||||
object->mDrawOps[i].alphaTest = object->mIsShadow != 0; // shadow -> blend pass
|
||||
// shadow -> blend pass; vertex-alpha effect cards (flame fans) too.
|
||||
// SKY objects are excluded: a drawAsSky op with alphaTest set passes
|
||||
// NEITHER pass filter (sky pass rejects alphaTest, blend pass rejects
|
||||
// drawAsSky) and vanishes -- DECLOUDS carries vertex alpha but must
|
||||
// stay in the sky pass.
|
||||
const bool vtxAlphaOp = data.batches[i].vertexAlpha && !isSkyObj;
|
||||
object->mDrawOps[i].alphaTest = (object->mIsShadow != 0) || vtxAlphaOp;
|
||||
object->mDrawOps[i].vertexAlphaBlend = vtxAlphaOp;
|
||||
object->mDrawOps[i].drawAsDecal = false;
|
||||
object->mDrawOps[i].drawAsSky = isSkyObj; // sky dome -> PASS_SKY (fullbright)
|
||||
// PUNCH (dpl_Punchize; BT_PUNCH=0 disables): cutout batch -- black texels
|
||||
@@ -435,7 +442,12 @@ d3d_OBJECT* d3d_OBJECT::LoadObjectBGF(LPDIRECT3DDEVICE9 device, char *fileName)
|
||||
object->mDrawOps[i].texture.texture = NULL;
|
||||
object->mDrawOps[i].texture.wrap_u = L4TEXOP::REPEAT;
|
||||
object->mDrawOps[i].texture.wrap_v = L4TEXOP::REPEAT;
|
||||
object->mDrawOps[i].texture.doScroll = false;
|
||||
// Authored TEXTURE SCROLL (BMF SPECIAL " SCROLL u0 v0 du dv"): the
|
||||
// firesmoke family (flamebig/fire5 flame cards) rolls its fire noise.
|
||||
// SetTextureScrolling in the draw path honours these per-op.
|
||||
object->mDrawOps[i].texture.doScroll = data.batches[i].texScroll;
|
||||
object->mDrawOps[i].texture.scrollUDelta = data.batches[i].texScrollU;
|
||||
object->mDrawOps[i].texture.scrollVDelta = data.batches[i].texScrollV;
|
||||
|
||||
const std::string &tp = data.batches[i].texPath;
|
||||
if (!tp.empty())
|
||||
@@ -863,6 +875,15 @@ void d3d_OBJECT::SetCameraPosition(float x, float y, float z)
|
||||
gCamPos.x = x; gCamPos.y = y; gCamPos.z = z;
|
||||
}
|
||||
|
||||
// The camera's world position (set once per frame above) -- the wreck flame
|
||||
// billboard (dpl_SetDCSReorientAxes analog) yaws its card toward this.
|
||||
void d3d_OBJECT::GetCameraPosition(float *x, float *y, float *z)
|
||||
{
|
||||
if (x) *x = gCamPos.x;
|
||||
if (y) *y = gCamPos.y;
|
||||
if (z) *z = gCamPos.z;
|
||||
}
|
||||
|
||||
void d3d_OBJECT::SetCullFrustum(const D3DXMATRIX *viewProj)
|
||||
{
|
||||
if (viewProj == NULL) { gCullValid = 0; return; }
|
||||
@@ -1203,6 +1224,34 @@ void d3d_OBJECT::DrawMesh(int pass, const D3DXMATRIX *viewTransform, Time target
|
||||
// 3. re-draw the mask writing stencil 0 (clean up for other punch groups)
|
||||
// The stencil never touches z, so entities drawn later still show through
|
||||
// the apertures correctly.
|
||||
// VERTEX-ALPHA effect card (the FLAMEBIG flame fan): unlit -- the
|
||||
// authored per-vertex gradient (white-hot base -> dark faded tip) IS
|
||||
// the shading -- colour = texture x gradient, alpha = the vertex fade
|
||||
// (SRCALPHA/INVSRCALPHA). Runs only in the blend pass (the op filter
|
||||
// above routed it there; ALPHABLEND is on and z-write off pass-wide).
|
||||
DWORD sVLight = 0, sVSrc = 0, sVDst = 0, sVCop = 0, sVCa1 = 0, sVCa2 = 0, sVAop = 0, sVAa2 = 0;
|
||||
const bool vtxAlphaCard = (drawOp->vertexAlphaBlend && pass == PASS_ALPHABLEND);
|
||||
if (vtxAlphaCard)
|
||||
{
|
||||
mDevice->GetRenderState(D3DRS_LIGHTING, &sVLight);
|
||||
mDevice->GetRenderState(D3DRS_SRCBLEND, &sVSrc);
|
||||
mDevice->GetRenderState(D3DRS_DESTBLEND, &sVDst);
|
||||
mDevice->GetTextureStageState(0, D3DTSS_COLOROP, &sVCop);
|
||||
mDevice->GetTextureStageState(0, D3DTSS_COLORARG1, &sVCa1);
|
||||
mDevice->GetTextureStageState(0, D3DTSS_COLORARG2, &sVCa2);
|
||||
mDevice->GetTextureStageState(0, D3DTSS_ALPHAOP, &sVAop);
|
||||
mDevice->GetTextureStageState(0, D3DTSS_ALPHAARG2, &sVAa2);
|
||||
mDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
|
||||
mDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
mDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
||||
mDevice->SetTextureStageState(0, D3DTSS_COLOROP,
|
||||
drawOp->texture.texture != NULL ? D3DTOP_MODULATE : D3DTOP_SELECTARG2);
|
||||
mDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||
mDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
|
||||
mDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG2);
|
||||
mDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
|
||||
}
|
||||
|
||||
const bool copCut = (drawOp->copRole == 2 && iOp > 0
|
||||
&& mDrawOps[iOp - 1].copRole == 1
|
||||
&& mDrawOps[iOp - 1].bgfPrimCount > 0
|
||||
@@ -1266,6 +1315,17 @@ void d3d_OBJECT::DrawMesh(int pass, const D3DXMATRIX *viewTransform, Time target
|
||||
mDevice->SetRenderState(D3DRS_ALPHAREF, sARef);
|
||||
mDevice->SetRenderState(D3DRS_ALPHAFUNC, sAFunc);
|
||||
}
|
||||
if (vtxAlphaCard)
|
||||
{
|
||||
mDevice->SetRenderState(D3DRS_LIGHTING, sVLight);
|
||||
mDevice->SetRenderState(D3DRS_SRCBLEND, sVSrc);
|
||||
mDevice->SetRenderState(D3DRS_DESTBLEND, sVDst);
|
||||
mDevice->SetTextureStageState(0, D3DTSS_COLOROP, sVCop);
|
||||
mDevice->SetTextureStageState(0, D3DTSS_COLORARG1, sVCa1);
|
||||
mDevice->SetTextureStageState(0, D3DTSS_COLORARG2, sVCa2);
|
||||
mDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, sVAop);
|
||||
mDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, sVAa2);
|
||||
}
|
||||
if (drawOp->lodDepthBias != 0.0f)
|
||||
mDevice->SetRenderState(D3DRS_DEPTHBIAS, sDB);
|
||||
}
|
||||
|
||||
@@ -109,13 +109,48 @@ static bool DevGaugeComposite()
|
||||
return v != 0;
|
||||
}
|
||||
|
||||
// DOCK-BOTTOM (2026-07-12, single-window mode): the gauge strip is APPENDED to
|
||||
// the main window's bottom band -- the world renders in the top region via a
|
||||
// restricted viewport, the strip in the remainder, everything scales with the
|
||||
// window. Enabled by btl4main when BT_DEV_GAUGES is set (BT_DEV_GAUGES_WINDOW=1
|
||||
// restores the separate-window mode). Strip height = width x (480/1320), the
|
||||
// panel's design aspect.
|
||||
int gBTGaugeDockBottom = 0;
|
||||
static const float kBTDockStripRatio = 480.0f / 1320.0f;
|
||||
|
||||
// The strip's height for a given window width: proportional to width at the
|
||||
// panel's design aspect, CAPPED at the design height (480) -- a very wide
|
||||
// window renders the strip at native 1:1 instead of upscaling it.
|
||||
int BTGaugeStripHeightFor(int width)
|
||||
{
|
||||
int h = (int)((float)width * kBTDockStripRatio);
|
||||
return (h > 480) ? 480 : h;
|
||||
}
|
||||
|
||||
// Restrict rasterization to the WORLD region (target minus the bottom strip).
|
||||
// Called by the main renderer right after BeginScene; no-op unless dock-bottom.
|
||||
void BTApplyWorldViewport(LPDIRECT3DDEVICE9 device)
|
||||
{
|
||||
if (!gBTGaugeDockBottom || device == NULL) return;
|
||||
IDirect3DSurface9 *rt = NULL;
|
||||
if (FAILED(device->GetRenderTarget(0, &rt)) || rt == NULL) return;
|
||||
D3DSURFACE_DESC d;
|
||||
rt->GetDesc(&d);
|
||||
rt->Release();
|
||||
DWORD stripH = (DWORD)BTGaugeStripHeightFor((int)d.Width);
|
||||
if (stripH == 0 || stripH >= d.Height) return;
|
||||
D3DVIEWPORT9 vp = { 0, 0, d.Width, d.Height - stripH, 0.0f, 1.0f };
|
||||
device->SetViewport(&vp);
|
||||
}
|
||||
|
||||
// DEV-COMPOSITE: BT_DEV_GAUGES_DOCK=1 docks the 6-surface panel INTO the main 800x600
|
||||
// window (occludes the 3D view); default (unset) presents them in a SEPARATE window.
|
||||
// window (occludes the 3D view); dock-bottom (above) also counts as docked --
|
||||
// both suppress the separate gauge window and draw via the main-window inset.
|
||||
static bool DevGaugeDocked()
|
||||
{
|
||||
static int v = -1;
|
||||
if (v < 0) v = (getenv("BT_DEV_GAUGES_DOCK") != NULL) ? 1 : 0;
|
||||
return v != 0;
|
||||
return v != 0 || gBTGaugeDockBottom != 0;
|
||||
}
|
||||
|
||||
//===========================================================================//
|
||||
@@ -285,6 +320,22 @@ void BTDrawGaugeSurfaces(LPDIRECT3DDEVICE9 device, float px, float py, float pw,
|
||||
IDirect3DStateBlock9 *stateBlock = NULL;
|
||||
device->CreateStateBlock(D3DSBT_ALL, &stateBlock);
|
||||
|
||||
// DOCK-BOTTOM: the world pass restricted the viewport to the top region;
|
||||
// the strip's pretransformed quads land BELOW it and would be clipped.
|
||||
// Draw with the FULL target viewport (the captured state block restores
|
||||
// the world viewport afterwards).
|
||||
{
|
||||
IDirect3DSurface9 *rt = NULL;
|
||||
if (SUCCEEDED(device->GetRenderTarget(0, &rt)) && rt != NULL)
|
||||
{
|
||||
D3DSURFACE_DESC d;
|
||||
rt->GetDesc(&d);
|
||||
rt->Release();
|
||||
D3DVIEWPORT9 vp = { 0, 0, d.Width, d.Height, 0.0f, 1.0f };
|
||||
device->SetViewport(&vp);
|
||||
}
|
||||
}
|
||||
|
||||
// Reach the shared display once (any present port shares the same SVGA16/pixelBuffer).
|
||||
SVGA16 *svga = NULL;
|
||||
for (int i = 0; i < 6 && svga == NULL; i++)
|
||||
@@ -335,8 +386,23 @@ void BTDrawGaugeSurfaces(LPDIRECT3DDEVICE9 device, float px, float py, float pw,
|
||||
void BTDrawGaugeInset(LPDIRECT3DDEVICE9 device)
|
||||
{
|
||||
if (!DevGaugeComposite() || !DevGaugeDocked() || device == NULL) return;
|
||||
// DOCKED mode only: draw into the main backbuffer (this runs before EndScene).
|
||||
// Keep the new panel's 1320:480 aspect (2.75) so nothing distorts.
|
||||
if (gBTGaugeDockBottom)
|
||||
{
|
||||
// DOCK-BOTTOM: the strip owns the bottom band of the target (the world
|
||||
// viewport excludes it) -- full width, design-aspect height.
|
||||
IDirect3DSurface9 *rt = NULL;
|
||||
if (FAILED(device->GetRenderTarget(0, &rt)) || rt == NULL) return;
|
||||
D3DSURFACE_DESC d;
|
||||
rt->GetDesc(&d);
|
||||
rt->Release();
|
||||
float stripH = (float)BTGaugeStripHeightFor((int)d.Width);
|
||||
if (stripH <= 0.0f || stripH >= (float)d.Height) return;
|
||||
BTDrawGaugeSurfaces(device, 0.0f, (float)d.Height - stripH,
|
||||
(float)d.Width, stripH);
|
||||
return;
|
||||
}
|
||||
// Legacy overlay dock (BT_DEV_GAUGES_DOCK): fixed inset over the 3D view.
|
||||
// Keep the panel's 1320:480 aspect (2.75) so nothing distorts.
|
||||
BTDrawGaugeSurfaces(device, 2.0f, 400.0f, 540.0f, 540.0f / 2.75f);
|
||||
}
|
||||
|
||||
|
||||
+206
-51
@@ -20,6 +20,7 @@
|
||||
#include "l4particles.h"
|
||||
#include "DXUtils.h"
|
||||
#include "bgfload.h" // BT: SetVideoPathPriority (day/night path priority)
|
||||
#include "image.h" // BT: decodeImage (the authored firesmoke sheet bintA)
|
||||
|
||||
using namespace std;
|
||||
#include <conio.h>
|
||||
@@ -936,6 +937,9 @@ void BTDrawPfx(LPDIRECT3DDEVICE9 dev, const D3DXMATRIX *view, float dt)
|
||||
dev->GetTextureStageState(0, D3DTSS_ALPHAOP, &sAop);
|
||||
dev->GetTextureStageState(0, D3DTSS_ALPHAARG1, &sAa1);
|
||||
dev->GetTextureStageState(0, D3DTSS_ALPHAARG2, &sAa2);
|
||||
DWORD sAdrU, sAdrV; // the scroll WRAPs sampler 0
|
||||
dev->GetSamplerState(0, D3DSAMP_ADDRESSU, &sAdrU);
|
||||
dev->GetSamplerState(0, D3DSAMP_ADDRESSV, &sAdrV);
|
||||
|
||||
// PREMULTIPLIED blending (ONE, INVSRCALPHA): the one model that renders BOTH
|
||||
// authored particle families correctly. FIRE (bright colour, the additive
|
||||
@@ -959,43 +963,62 @@ void BTDrawPfx(LPDIRECT3DDEVICE9 dev, const D3DXMATRIX *view, float dt)
|
||||
dev->SetRenderState(D3DRS_DESTBLEND, s_pfxAdditive ? D3DBLEND_ONE : D3DBLEND_INVSRCALPHA);
|
||||
dev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
|
||||
|
||||
// Particle sprite texture: the beams' authentic grit sheet MASKED by a
|
||||
// radial falloff -> soft round fiery blobs (an unmasked square sheet on an
|
||||
// additive quad reads as a hard BOX, which the 1995 sprites never did).
|
||||
// Baked once from the decoded grit; pure radial gradient if grit is absent.
|
||||
static LPDIRECT3DTEXTURE9 s_pfxTex = 0;
|
||||
// Particle sprite texture -- the AUTHORED firesmoke sheet. Every
|
||||
// firesmokeN_scr_tex in BTFX.VMF maps the SAME 64x64 tileable noise image
|
||||
// "bintA" (the variants differ only in SCROLL rate: firesmoke1 = 0.05,-0.331
|
||||
// uv/s, firesmoke2 = 0,0.131, firesmoke4 = 0.05,-0.131), and firesmoke1_mtl
|
||||
// colours it through the "fiery" ramp (0.3,0.1,0.1)->(0.9,0.7,0.3) -- the
|
||||
// rolling orange fireball of the original. Bake ramp(lum) as the sprite
|
||||
// colour with the noise detail in alpha; the RADIAL falloff lives in a
|
||||
// SECOND (CLAMPed) texture stage so the WRAPPED scroll can roll flame
|
||||
// through the sprite without scrolling the soft edge away. (The mask is
|
||||
// port-shaped: we draw billboards where the original drew flame geometry,
|
||||
// and a square scrolled sheet on a quad reads as a hard box.)
|
||||
// Fallback when BINTA.VTX is absent: the old grit x radial single-tex bake.
|
||||
static LPDIRECT3DTEXTURE9 s_pfxTex = 0; // fallback single-texture
|
||||
static LPDIRECT3DTEXTURE9 s_pfxNoise = 0; // bintA through the "fiery" ramp
|
||||
static LPDIRECT3DTEXTURE9 s_pfxMask = 0; // radial falloff (stage 1, CLAMP)
|
||||
static int s_pfxTexTried = 0;
|
||||
if (!s_pfxTexTried)
|
||||
{
|
||||
s_pfxTexTried = 1;
|
||||
const int TW = 64, TH = 64;
|
||||
LPDIRECT3DTEXTURE9 grit = BTGetBeamGritTexture();
|
||||
unsigned char gritLum[128 * 64]; // grit is 128x64 when present
|
||||
int gw = 0, gh = 0;
|
||||
if (grit)
|
||||
{
|
||||
D3DSURFACE_DESC gd;
|
||||
if (SUCCEEDED(grit->GetLevelDesc(0, &gd)) && gd.Width <= 128 && gd.Height <= 64)
|
||||
{
|
||||
D3DLOCKED_RECT glr;
|
||||
if (SUCCEEDED(grit->LockRect(0, &glr, NULL, D3DLOCK_READONLY)))
|
||||
{
|
||||
gw = gd.Width; gh = gd.Height;
|
||||
for (int y = 0; y < gh; ++y)
|
||||
{
|
||||
const DWORD *src = (const DWORD *)((const char *)glr.pBits + y * glr.Pitch);
|
||||
for (int x = 0; x < gw; ++x)
|
||||
gritLum[y * gw + x] = (unsigned char)(src[x] & 0xFF);
|
||||
}
|
||||
grit->UnlockRect(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (SUCCEEDED(dev->CreateTexture(TW, TH, 1, 0, D3DFMT_A8R8G8B8,
|
||||
D3DPOOL_MANAGED, &s_pfxTex, NULL)))
|
||||
Image fireImg = decodeImage("VIDEO\\TEX\\BINTA.VTX");
|
||||
if (fireImg.ok && fireImg.w > 0 && fireImg.h > 0 &&
|
||||
SUCCEEDED(dev->CreateTexture(fireImg.w, fireImg.h, 1, 0, D3DFMT_A8R8G8B8,
|
||||
D3DPOOL_MANAGED, &s_pfxNoise, NULL)))
|
||||
{
|
||||
D3DLOCKED_RECT lr;
|
||||
if (SUCCEEDED(s_pfxTex->LockRect(0, &lr, NULL, 0)))
|
||||
if (SUCCEEDED(s_pfxNoise->LockRect(0, &lr, NULL, 0)))
|
||||
{
|
||||
const float lo[3] = { 0.3f, 0.1f, 0.1f }; // RAMP "fiery" (BTFX.VMF)
|
||||
const float hi[3] = { 0.9f, 0.7f, 0.3f };
|
||||
for (int y = 0; y < fireImg.h; ++y)
|
||||
{
|
||||
DWORD *dst = (DWORD *)((char *)lr.pBits + y * lr.Pitch);
|
||||
for (int x = 0; x < fireImg.w; ++x)
|
||||
{
|
||||
uint32_t s = fireImg.argb[(size_t)y * fireImg.w + x];
|
||||
float lum = (((s >> 16) & 0xFF) + ((s >> 8) & 0xFF) + (s & 0xFF)) / (3.0f * 255.0f);
|
||||
int r = (int)((lo[0] + (hi[0] - lo[0]) * lum) * 255.0f);
|
||||
int g = (int)((lo[1] + (hi[1] - lo[1]) * lum) * 255.0f);
|
||||
int b = (int)((lo[2] + (hi[2] - lo[2]) * lum) * 255.0f);
|
||||
// alpha carries the noise detail (same 0.35 floor the grit
|
||||
// bake used) -> the occlusion edge breaks up like flame
|
||||
int a = (int)((0.35f + 0.65f * lum) * 255.0f);
|
||||
dst[x] = ((DWORD)a << 24) | (r << 16) | (g << 8) | b;
|
||||
}
|
||||
}
|
||||
s_pfxNoise->UnlockRect(0);
|
||||
}
|
||||
else { s_pfxNoise->Release(); s_pfxNoise = 0; }
|
||||
}
|
||||
if (s_pfxNoise &&
|
||||
SUCCEEDED(dev->CreateTexture(TW, TH, 1, 0, D3DFMT_A8R8G8B8,
|
||||
D3DPOOL_MANAGED, &s_pfxMask, NULL)))
|
||||
{
|
||||
D3DLOCKED_RECT lr;
|
||||
if (SUCCEEDED(s_pfxMask->LockRect(0, &lr, NULL, 0)))
|
||||
{
|
||||
for (int y = 0; y < TH; ++y)
|
||||
{
|
||||
@@ -1008,30 +1031,125 @@ void BTDrawPfx(LPDIRECT3DDEVICE9 dev, const D3DXMATRIX *view, float dt)
|
||||
float f = 1.0f - r; // radial falloff
|
||||
if (f < 0.0f) f = 0.0f;
|
||||
f = f * f * (3.0f - 2.0f * f); // smoothstep edge
|
||||
float n = 1.0f;
|
||||
if (gw > 0) // authentic grit detail
|
||||
n = 0.35f + 0.65f * (gritLum[(y % gh) * gw + (x % gw)] / 255.0f);
|
||||
int v = (int)(f * n * 255.0f);
|
||||
if (v > 255) v = 255;
|
||||
// the falloff mask lives in ALPHA too: the premultiplied
|
||||
// draw (ONE, INVSRCALPHA) needs soft-edged OCCLUSION for
|
||||
// smoke, not just soft-edged colour for fire
|
||||
dst[x] = (v << 24) | (v << 16) | (v << 8) | v;
|
||||
int v = (int)(f * 255.0f);
|
||||
dst[x] = ((DWORD)v << 24) | (v << 16) | (v << 8) | v;
|
||||
}
|
||||
}
|
||||
s_pfxTex->UnlockRect(0);
|
||||
s_pfxMask->UnlockRect(0);
|
||||
}
|
||||
else { s_pfxMask->Release(); s_pfxMask = 0; }
|
||||
}
|
||||
if (s_pfxNoise && !s_pfxMask) { s_pfxNoise->Release(); s_pfxNoise = 0; }
|
||||
if (!s_pfxNoise)
|
||||
{
|
||||
LPDIRECT3DTEXTURE9 grit = BTGetBeamGritTexture();
|
||||
unsigned char gritLum[128 * 64]; // grit is 128x64 when present
|
||||
int gw = 0, gh = 0;
|
||||
if (grit)
|
||||
{
|
||||
D3DSURFACE_DESC gd;
|
||||
if (SUCCEEDED(grit->GetLevelDesc(0, &gd)) && gd.Width <= 128 && gd.Height <= 64)
|
||||
{
|
||||
D3DLOCKED_RECT glr;
|
||||
if (SUCCEEDED(grit->LockRect(0, &glr, NULL, D3DLOCK_READONLY)))
|
||||
{
|
||||
gw = gd.Width; gh = gd.Height;
|
||||
for (int y = 0; y < gh; ++y)
|
||||
{
|
||||
const DWORD *src = (const DWORD *)((const char *)glr.pBits + y * glr.Pitch);
|
||||
for (int x = 0; x < gw; ++x)
|
||||
gritLum[y * gw + x] = (unsigned char)(src[x] & 0xFF);
|
||||
}
|
||||
grit->UnlockRect(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (SUCCEEDED(dev->CreateTexture(TW, TH, 1, 0, D3DFMT_A8R8G8B8,
|
||||
D3DPOOL_MANAGED, &s_pfxTex, NULL)))
|
||||
{
|
||||
D3DLOCKED_RECT lr;
|
||||
if (SUCCEEDED(s_pfxTex->LockRect(0, &lr, NULL, 0)))
|
||||
{
|
||||
for (int y = 0; y < TH; ++y)
|
||||
{
|
||||
DWORD *dst = (DWORD *)((char *)lr.pBits + y * lr.Pitch);
|
||||
for (int x = 0; x < TW; ++x)
|
||||
{
|
||||
float dx = (x + 0.5f) / TW * 2.0f - 1.0f;
|
||||
float dy = (y + 0.5f) / TH * 2.0f - 1.0f;
|
||||
float r = sqrtf(dx * dx + dy * dy);
|
||||
float f = 1.0f - r; // radial falloff
|
||||
if (f < 0.0f) f = 0.0f;
|
||||
f = f * f * (3.0f - 2.0f * f); // smoothstep edge
|
||||
float n = 1.0f;
|
||||
if (gw > 0) // authentic grit detail
|
||||
n = 0.35f + 0.65f * (gritLum[(y % gh) * gw + (x % gw)] / 255.0f);
|
||||
int v = (int)(f * n * 255.0f);
|
||||
if (v > 255) v = 255;
|
||||
// the falloff mask lives in ALPHA too: the premultiplied
|
||||
// draw (ONE, INVSRCALPHA) needs soft-edged OCCLUSION for
|
||||
// smoke, not just soft-edged colour for fire
|
||||
dst[x] = (v << 24) | (v << 16) | (v << 8) | v;
|
||||
}
|
||||
}
|
||||
s_pfxTex->UnlockRect(0);
|
||||
}
|
||||
else { s_pfxTex->Release(); s_pfxTex = 0; }
|
||||
}
|
||||
else { s_pfxTex->Release(); s_pfxTex = 0; }
|
||||
}
|
||||
}
|
||||
dev->SetTexture(0, s_pfxTex);
|
||||
dev->SetTextureStageState(0, D3DTSS_COLOROP, s_pfxTex ? D3DTOP_MODULATE : D3DTOP_SELECTARG1);
|
||||
dev->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
|
||||
dev->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TEXTURE);
|
||||
// occlusion = vertex alpha x the texture's falloff mask (soft-edged smoke)
|
||||
dev->SetTextureStageState(0, D3DTSS_ALPHAOP, s_pfxTex ? D3DTOP_MODULATE : D3DTOP_SELECTARG1);
|
||||
dev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
|
||||
dev->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE);
|
||||
|
||||
// The authored SCROLL clock (firesmoke1's rate; the shipped variants share
|
||||
// the sheet and differ only in rate, so the port rolls every sprite at the
|
||||
// dominant one). Accumulate the OFFSETS and wrap each into [0,1) -- an
|
||||
// unbounded time * rate loses float precision over a long session (the
|
||||
// tsphere scroll-precision lesson).
|
||||
static float s_pfxScrollU = 0.0f, s_pfxScrollV = 0.0f;
|
||||
s_pfxScrollU += 0.05f * dt; s_pfxScrollU -= floorf(s_pfxScrollU);
|
||||
s_pfxScrollV += -0.331f * dt; s_pfxScrollV -= floorf(s_pfxScrollV);
|
||||
|
||||
if (s_pfxNoise)
|
||||
{
|
||||
// stage 0: diffuse x the scrolled fire noise (WRAPped)
|
||||
dev->SetTexture(0, s_pfxNoise);
|
||||
dev->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||
dev->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
|
||||
dev->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TEXTURE);
|
||||
dev->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
||||
dev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
|
||||
dev->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE);
|
||||
D3DXMATRIX tm; D3DXMatrixIdentity(&tm);
|
||||
tm._31 = s_pfxScrollU; tm._32 = s_pfxScrollV; // (u,v) translation
|
||||
dev->SetTransform(D3DTS_TEXTURE0, &tm);
|
||||
dev->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
|
||||
dev->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
|
||||
dev->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
|
||||
// stage 1: x the CLAMPed radial mask (same UV set, UNscrolled) -- both
|
||||
// colour and alpha, so the premultiplied occlusion stays soft-edged
|
||||
dev->SetTexture(1, s_pfxMask);
|
||||
dev->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||
dev->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_CURRENT);
|
||||
dev->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_TEXTURE);
|
||||
dev->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
||||
dev->SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_CURRENT);
|
||||
dev->SetTextureStageState(1, D3DTSS_ALPHAARG2, D3DTA_TEXTURE);
|
||||
dev->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 0);
|
||||
dev->SetSamplerState(1, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
|
||||
dev->SetSamplerState(1, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
|
||||
dev->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
|
||||
dev->SetSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
|
||||
}
|
||||
else
|
||||
{
|
||||
dev->SetTexture(0, s_pfxTex);
|
||||
dev->SetTextureStageState(0, D3DTSS_COLOROP, s_pfxTex ? D3DTOP_MODULATE : D3DTOP_SELECTARG1);
|
||||
dev->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
|
||||
dev->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TEXTURE);
|
||||
// occlusion = vertex alpha x the texture's falloff mask (soft-edged smoke)
|
||||
dev->SetTextureStageState(0, D3DTSS_ALPHAOP, s_pfxTex ? D3DTOP_MODULATE : D3DTOP_SELECTARG1);
|
||||
dev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
|
||||
dev->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE);
|
||||
}
|
||||
|
||||
D3DXMATRIX ident; D3DXMatrixIdentity(&ident);
|
||||
dev->SetTransform(D3DTS_WORLD, &ident);
|
||||
@@ -1108,6 +1226,17 @@ void BTDrawPfx(LPDIRECT3DDEVICE9 dev, const D3DXMATRIX *view, float dt)
|
||||
&verts[0], sizeof(V));
|
||||
|
||||
dev->SetTexture(0, NULL);
|
||||
if (s_pfxNoise)
|
||||
{
|
||||
// tear down the two-stage fire pipe: stage 1 back to the D3D default
|
||||
// (DISABLE), the scroll transform off, sampler 0 addressing restored
|
||||
dev->SetTexture(1, NULL);
|
||||
dev->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
||||
dev->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
||||
dev->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);
|
||||
}
|
||||
dev->SetSamplerState(0, D3DSAMP_ADDRESSU, sAdrU);
|
||||
dev->SetSamplerState(0, D3DSAMP_ADDRESSV, sAdrV);
|
||||
dev->SetRenderState(D3DRS_LIGHTING, sLight);
|
||||
dev->SetRenderState(D3DRS_FOGENABLE, sFog);
|
||||
dev->SetRenderState(D3DRS_ZWRITEENABLE, sZW);
|
||||
@@ -7445,6 +7574,14 @@ void DPLRenderer::ExecuteImplementation(RendererComplexity, RendererOrigin::Inte
|
||||
|
||||
hr = mDevice->BeginScene();
|
||||
|
||||
// DOCK-BOTTOM (single-window gauges): keep the world in the top region;
|
||||
// the gauge strip owns the bottom band (drawn by BTDrawGaugeInset with a
|
||||
// full-target viewport before EndScene). No-op unless the mode is on.
|
||||
{
|
||||
extern void BTApplyWorldViewport(LPDIRECT3DDEVICE9 device);
|
||||
BTApplyWorldViewport(mDevice);
|
||||
}
|
||||
|
||||
mDevice->SetFVF(L4VERTEX_FVF);
|
||||
|
||||
D3DXMATRIX viewTransform;
|
||||
@@ -8558,11 +8695,29 @@ void
|
||||
// backbuffer into the client area, so rendering with the CLIENT aspect cancels
|
||||
// the stretch.
|
||||
//
|
||||
// DOCK-BOTTOM (single-window gauges): the world occupies the client MINUS the
|
||||
// gauge strip (strip height tracks width at the panel's 480/1320 design ratio),
|
||||
// so the projection aspect must come from the WORLD region or the scene
|
||||
// stretches vertically by the strip's share.
|
||||
static float BTWorldAspectOf(int client_w, int client_h)
|
||||
{
|
||||
extern int gBTGaugeDockBottom;
|
||||
extern int BTGaugeStripHeightFor(int width);
|
||||
float world_h = (float)client_h;
|
||||
if (gBTGaugeDockBottom)
|
||||
{
|
||||
float strip = (float)BTGaugeStripHeightFor(client_w);
|
||||
if (strip > 0.0f && strip < world_h - 8.0f)
|
||||
world_h -= strip;
|
||||
}
|
||||
return (float)client_w / world_h;
|
||||
}
|
||||
|
||||
void L4NotifyWindowResized(int client_w, int client_h)
|
||||
{
|
||||
if (client_w <= 0 || client_h <= 0)
|
||||
return;
|
||||
gWindowAspect = (float)client_w / (float)client_h;
|
||||
gWindowAspect = BTWorldAspectOf(client_w, client_h);
|
||||
DEBUG_STREAM << "[resize] client " << client_w << "x" << client_h
|
||||
<< " aspect=" << gWindowAspect
|
||||
<< " app=" << (void *)l4_application << "\n" << std::flush;
|
||||
@@ -8579,7 +8734,7 @@ void
|
||||
{
|
||||
if (client_w <= 0 || client_h <= 0)
|
||||
return;
|
||||
gWindowAspect = (float)client_w / (float)client_h;
|
||||
gWindowAspect = BTWorldAspectOf(client_w, client_h);
|
||||
if (viewAngle <= 0.0f || clipFar <= clipNear)
|
||||
{
|
||||
DEBUG_STREAM << "[resize] projection not built yet (viewAngle="
|
||||
|
||||
@@ -1910,6 +1910,17 @@ public:
|
||||
OrientationMatrix(3, 1) = y;
|
||||
OrientationMatrix(3, 2) = z;
|
||||
}
|
||||
// Overwrite the offset's ROTATION rows with a yaw (rotation about local Y).
|
||||
// The BT wreck-flame billboard (the 1996 dpl_SetDCSReorientAxes(dcs,
|
||||
// dpl_reorient_axes_y) on flamebig) yaws the flame card toward the camera
|
||||
// each frame; translation row is left untouched.
|
||||
void SetOffsetYaw(float yaw)
|
||||
{
|
||||
float c = cosf(yaw), s = sinf(yaw);
|
||||
OrientationMatrix(0, 0) = c; OrientationMatrix(0, 1) = 0.0f; OrientationMatrix(0, 2) = -s;
|
||||
OrientationMatrix(1, 0) = 0.0f; OrientationMatrix(1, 1) = 1.0f; OrientationMatrix(1, 2) = 0.0f;
|
||||
OrientationMatrix(2, 0) = s; OrientationMatrix(2, 1) = 0.0f; OrientationMatrix(2, 2) = c;
|
||||
}
|
||||
protected:
|
||||
dpl_DCS *myDCS, *myParentDCS;
|
||||
|
||||
|
||||
@@ -295,6 +295,9 @@ struct MatInfo {
|
||||
bool hasDiffuse = false; // material carried an explicit DIFFUSE/AMBIENT tag
|
||||
std::string texPath;
|
||||
int texChannel = 0; // BSL bit-slice (BMF TEXTURE tag 0x18; absent = 0)
|
||||
bool texScroll = false; // TEXTURE SPECIAL " SCROLL" (tag 0x2037): UV animation
|
||||
float texScrollU = 0.0f; // cycles/second
|
||||
float texScrollV = 0.0f;
|
||||
// RAMP (task #20): the material's 2-endpoint colour ramp (dpl_SetMaterialRamp).
|
||||
// The grayscale texture's luminance indexes a low->high colour gradient -- this
|
||||
// is how the IG board coloured terrain (rock 0.25,0.21,0.16->0.8,0.5,0.4=warm
|
||||
@@ -316,6 +319,11 @@ struct MatInfo {
|
||||
struct TexRef {
|
||||
std::string map;
|
||||
int channel = 0;
|
||||
// TEXTURE-record SPECIAL " SCROLL u0 v0 du dv" (tag 0x2037): authored UV
|
||||
// scroll rates in cycles/second (the firesmoke fire-noise roll).
|
||||
bool scroll = false;
|
||||
float scrollU = 0.0f;
|
||||
float scrollV = 0.0f;
|
||||
};
|
||||
|
||||
struct MaterialResolver {
|
||||
@@ -333,6 +341,22 @@ struct MaterialResolver {
|
||||
if (ch.id == TAG_NAME) name = chunkStr(ch);
|
||||
else if (ch.id == TAG_TEXTURE_MAP) ref.map = chunkStr(ch);
|
||||
else if (ch.id == TAG_BITSLICE && ch.len >= 1) ref.channel = ch.data[0];
|
||||
else if (ch.id == TAG_SV_SPECIAL && ch.len > 8) {
|
||||
// " SCROLL u0 v0 du dv" -- authored UV scroll (BTFX's
|
||||
// firesmoke family). u0/v0 initial offsets are 0 in every
|
||||
// shipped record; only the rates matter.
|
||||
std::string sp = chunkStr(ch);
|
||||
size_t at = sp.find("SCROLL");
|
||||
if (at != std::string::npos) {
|
||||
float u0 = 0, v0 = 0, du = 0, dv = 0;
|
||||
if (sscanf(sp.c_str() + at + 6, "%f %f %f %f", &u0, &v0, &du, &dv) == 4
|
||||
&& (du != 0.0f || dv != 0.0f)) {
|
||||
ref.scroll = true;
|
||||
ref.scrollU = du;
|
||||
ref.scrollV = dv;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!name.empty() && !ref.map.empty()) out[name] = ref;
|
||||
}
|
||||
@@ -442,7 +466,13 @@ struct MaterialResolver {
|
||||
if (tm != texMaps.end()) {
|
||||
const auto& imgs = imageIndex();
|
||||
auto f = imgs.find(stemLower(tm->second.map));
|
||||
if (f != imgs.end()) { info.texPath = f->second; info.texChannel = tm->second.channel; }
|
||||
if (f != imgs.end()) {
|
||||
info.texPath = f->second;
|
||||
info.texChannel = tm->second.channel;
|
||||
info.texScroll = tm->second.scroll;
|
||||
info.texScrollU = tm->second.scrollU;
|
||||
info.texScrollV = tm->second.scrollV;
|
||||
}
|
||||
}
|
||||
out[name] = info;
|
||||
}
|
||||
@@ -501,6 +531,8 @@ struct Builder {
|
||||
bool currentHasDiffuse = false; // material carried an explicit diffuse tag
|
||||
std::string currentTex;
|
||||
int currentTexChannel = 0; // BSL bit-slice (BMF tag 0x18)
|
||||
bool currentTexScroll = false; // TEXTURE SPECIAL " SCROLL" (tag 0x2037)
|
||||
float currentTexScrollU = 0.0f, currentTexScrollV = 0.0f;
|
||||
bool currentHasRamp = false;
|
||||
float currentRampLo[3] = {0,0,0};
|
||||
float currentRampHi[3] = {1,1,1};
|
||||
@@ -569,18 +601,32 @@ struct Builder {
|
||||
|
||||
void buildPmesh(const Chunk& pmesh) {
|
||||
std::vector<float> lx, ly, lz, lu, lv;
|
||||
// Authored per-vertex RGBA (tags 0x0082/0x008A: 4 floats at offset 12).
|
||||
// Values run OUTSIDE [0,1] (the flame card FLAMEBIG.BGF fades its tip
|
||||
// to alpha -0.2 and over-brightens its base to 1.2 -- the DPL clamp
|
||||
// convention, same as the .PFX negative colour ramps).
|
||||
std::vector<uint32_t> lrgba;
|
||||
bool vertexAlpha = false; // any authored alpha < 1 -> BLENDED batch
|
||||
uint16_t vtag = 0;
|
||||
for (const Chunk& ch : pmesh.children) {
|
||||
int stride = vertexStride(ch.id);
|
||||
if (!stride) continue;
|
||||
vtag = ch.id;
|
||||
int uvOff = uvOffset(ch.id);
|
||||
const bool hasRGBA = (ch.id == TAG_VERTEX_XYZ_RGBA || ch.id == TAG_VERTEX_XYZ_RGBA_UV);
|
||||
size_t count = ch.len / (size_t)stride;
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
const uint8_t* v = ch.data + i * stride;
|
||||
lx.push_back(rdF32(v)); ly.push_back(rdF32(v + 4)); lz.push_back(rdF32(v + 8));
|
||||
if (uvOff >= 0) { lu.push_back(rdF32(v + uvOff)); lv.push_back(rdF32(v + uvOff + 4)); }
|
||||
else { lu.push_back(0.0f); lv.push_back(0.0f); }
|
||||
if (hasRGBA) {
|
||||
float cr = rdF32(v + 12), cg = rdF32(v + 16), cb = rdF32(v + 20), ca = rdF32(v + 24);
|
||||
if (ca < 0.999f) vertexAlpha = true;
|
||||
auto C8 = [](float f) { int n = (int)(f * 255.0f + 0.5f); return (uint32_t)(n < 0 ? 0 : n > 255 ? 255 : n); };
|
||||
lrgba.push_back((C8(ca) << 24) | (C8(cr) << 16) | (C8(cg) << 8) | C8(cb));
|
||||
} else
|
||||
lrgba.push_back(0xFFFFFFFFu);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -670,7 +716,13 @@ struct Builder {
|
||||
px.push_back(lx[i]); py.push_back(ly[i]); pz.push_back(lz[i]);
|
||||
nx.push_back(0); ny.push_back(0); nz.push_back(0);
|
||||
uu.push_back(lu[i] * tileU + twist * lv[i]); vv.push_back(lv[i] * tileV);
|
||||
col.push_back(vcol);
|
||||
// VERTEX-ALPHA batches (the flame cards) keep their AUTHORED
|
||||
// per-vertex gradient (white-hot base -> dark faded tip) -- it IS
|
||||
// the flame's shading, modulated by the (ramped, scrolling)
|
||||
// texture in the blend pass. Opaque batches keep the flat
|
||||
// tint/diffuse rule unchanged (alpha==1 skins carry no gradient
|
||||
// the verified look depends on).
|
||||
col.push_back(vertexAlpha ? lrgba[i] : vcol);
|
||||
}
|
||||
|
||||
const uint32_t idxStart = (uint32_t)mesh->indices.size();
|
||||
@@ -729,6 +781,10 @@ struct Builder {
|
||||
: (useRamp ? rampTint : currentColor); // pure-emissive test keys on it
|
||||
batch.texPath = currentTex;
|
||||
batch.texChannel = currentTexChannel;
|
||||
batch.texScroll = currentTexScroll;
|
||||
batch.texScrollU = currentTexScrollU;
|
||||
batch.texScrollV = currentTexScrollV;
|
||||
batch.vertexAlpha = vertexAlpha;
|
||||
batch.hasRamp = useRamp;
|
||||
// tsphere warp flag: warpBands>0 signals L4D3D's ramp bake to CONTRAST-
|
||||
// COMPRESS the bintA cloud toward mid-grey (BT_WARP_CONTRAST) before applying
|
||||
@@ -966,6 +1022,8 @@ struct Builder {
|
||||
bool savedHasDiffuse = currentHasDiffuse;
|
||||
std::string savedTex = currentTex;
|
||||
int savedTexChannel = currentTexChannel;
|
||||
bool savedTexScroll = currentTexScroll;
|
||||
float savedTexScrollU = currentTexScrollU, savedTexScrollV = currentTexScrollV;
|
||||
bool savedHasRamp = currentHasRamp;
|
||||
bool savedPunch = currentPunch;
|
||||
bool savedShadowMat = currentShadowMat;
|
||||
@@ -1048,12 +1106,15 @@ struct Builder {
|
||||
currentColor = info.color; currentTex = info.texPath;
|
||||
currentHasDiffuse = info.hasDiffuse;
|
||||
currentTexChannel = info.texChannel;
|
||||
currentTexScroll = info.texScroll;
|
||||
currentTexScrollU = info.texScrollU;
|
||||
currentTexScrollV = info.texScrollV;
|
||||
currentHasRamp = info.hasRamp;
|
||||
for (int i = 0; i < 3; ++i) { currentRampLo[i] = info.rampLo[i]; currentRampHi[i] = info.rampHi[i]; }
|
||||
currentHasEmissive = info.hasEmissive;
|
||||
for (int i = 0; i < 3; ++i) currentEmissive[i] = info.emissive[i];
|
||||
}
|
||||
else { currentColor = colorForMaterial(full); currentTex.clear(); currentHasDiffuse = false; currentTexChannel = 0; }
|
||||
else { currentColor = colorForMaterial(full); currentTex.clear(); currentHasDiffuse = false; currentTexChannel = 0; currentTexScroll = false; currentTexScrollU = currentTexScrollV = 0.0f; }
|
||||
// TRANSLOCATION WARP: override the material's coarse "sky" ramp with the
|
||||
// NARROW LAVENDER ramp that matched the original (capture.png). The swirl
|
||||
// is the bintA cloud coloured lo->hi by luminance; a wide sky ramp
|
||||
@@ -1085,6 +1146,9 @@ struct Builder {
|
||||
currentHasDiffuse = savedHasDiffuse;
|
||||
currentTex = savedTex;
|
||||
currentTexChannel = savedTexChannel;
|
||||
currentTexScroll = savedTexScroll;
|
||||
currentTexScrollU = savedTexScrollU;
|
||||
currentTexScrollV = savedTexScrollV;
|
||||
currentHasRamp = savedHasRamp;
|
||||
currentPunch = savedPunch;
|
||||
currentShadowMat = savedShadowMat;
|
||||
|
||||
@@ -31,6 +31,19 @@ struct BgfDrawBatch {
|
||||
// holds blkhwk1..4); decoding the packed word as one RGBA image overlaid
|
||||
// 2-3 different sheets as color channels = the rainbow "graffiti" mechs.
|
||||
int texChannel = 0;
|
||||
// TEXTURE SCROLL (the BMF TEXTURE record's SPECIAL " SCROLL u0 v0 du dv",
|
||||
// tag 0x2037): authored UV animation in cycles/second -- the firesmoke
|
||||
// family (flamebig/fire5 flame cards, the burning-wreck dressing) rolls
|
||||
// its fire noise this way. Propagated to L4TEXOP::doScroll, which the
|
||||
// draw path (d3d_OBJECT::SetTextureScrolling) already honours.
|
||||
bool texScroll = false;
|
||||
float texScrollU = 0.0f;
|
||||
float texScrollV = 0.0f;
|
||||
// VERTEX ALPHA (tags 0x0082/0x008A with any authored alpha < 1): the batch
|
||||
// is a BLENDED effect card (FLAMEBIG's flame fan fades its tip to negative
|
||||
// alpha). The verts keep their authored RGBA gradient and the draw routes
|
||||
// to the alpha-blend pass, unlit, colour = texture x vertex gradient.
|
||||
bool vertexAlpha = false;
|
||||
// RAMP (task #20): colorize the grayscale texture by luminance across
|
||||
// rampLo->rampHi (the authentic IG-board terrain colouring). When set, the
|
||||
// renderer bakes lerp(rampLo, rampHi, texLum) into the texture and draws with
|
||||
|
||||
@@ -98,6 +98,11 @@ struct L4DRAWOP
|
||||
// black texels were loaded with alpha 0; draw with alpha TEST in the opaque pass
|
||||
// (z-write preserved), rejecting hole texels.
|
||||
bool punchThrough;
|
||||
// VERTEX-ALPHA BLEND (BGF 0x0082/0x008A verts with authored alpha < 1): an
|
||||
// effect card (the FLAMEBIG flame fan). Drawn in the alpha-blend pass,
|
||||
// UNLIT, colour = texture x the authored per-vertex gradient, alpha = the
|
||||
// per-vertex fade (SRCALPHA/INVSRCALPHA).
|
||||
bool vertexAlphaBlend;
|
||||
// COCKPIT PUNCH STENCIL-CUT (task #55, i860-firmware-decoded): 0=normal,
|
||||
// 1=aperture MASK (drawn stencil-only, paired with the following hull op),
|
||||
// 2=HULL (drawn stencil-rejected under the mask = window cutouts).
|
||||
@@ -158,6 +163,7 @@ public:
|
||||
// frustum once (SetCullFrustum); Draw() then skips objects fully outside it.
|
||||
static void SetCullFrustum(const D3DXMATRIX *viewProj); // NULL disables for the frame
|
||||
static void SetCameraPosition(float x, float y, float z); // for LOD distance selection
|
||||
static void GetCameraPosition(float *x, float *y, float *z); // wreck-flame billboard yaw
|
||||
D3DXVECTOR3 mCullCenter; // model-space bounding sphere (computed at load)
|
||||
float mCullRadius; // <= 0 -> unknown, never culled
|
||||
|
||||
|
||||
Reference in New Issue
Block a user