This commit is contained in:
evanpelle
2026-06-06 19:14:45 -07:00
parent 385b4dd686
commit 27b1dedbcd
14 changed files with 442 additions and 98 deletions
+34 -4
View File
@@ -33,6 +33,7 @@ import { BorderComputePass } from "./passes/BorderComputePass";
import { BorderStampPass } from "./passes/BorderStampPass";
import { CoordinateGridPass } from "./passes/CoordinateGridPass";
import { CrosshairPass } from "./passes/CrosshairPass";
import { DefenseCoveragePass } from "./passes/DefenseCoveragePass";
import { FalloutBloomPass } from "./passes/FalloutBloomPass";
import { FalloutLightPass } from "./passes/FalloutLightPass";
import { FxPass } from "./passes/fx-pass";
@@ -101,6 +102,7 @@ export class GPURenderer {
private trailPass: TrailPass;
private borderStampPass: BorderStampPass;
private borderPass: BorderComputePass;
private defenseCoveragePass: DefenseCoveragePass;
private bloomPass: FalloutBloomPass;
private pointLightPass: PointLightPass;
private falloutLightPass: FalloutLightPass;
@@ -308,6 +310,17 @@ export class GPURenderer {
);
this.res.borderTex = this.borderPass.getBorderTex();
// --- Defense coverage (needs tileTex) — per-tile "defended by same-owner
// post" flag, stamped one instanced circle per post. Replaces the old
// 64-cap uniform loop; consumed by BorderStampPass. ---
this.defenseCoveragePass = new DefenseCoveragePass(
gl,
mapW,
mapH,
this.res.tileTex,
this.settings,
);
// --- Heat manager (needs tileTex, heatTexA/B) ---
this.heatManager = new HeatManager(
gl,
@@ -334,10 +347,19 @@ export class GPURenderer {
this.settings,
);
// Route per-tile changes to the border pass so it can scatter-recompute
// just the affected tiles instead of rebuilding the whole map.
this.territoryPass.setBorderPatchConsumer((x, y) =>
this.borderPass.patchTile(x, y),
// just the affected tiles instead of rebuilding the whole map. A tile
// changing owner can also flip its defense-coverage flag (same-owner test),
// so mark the coverage stale too — one coalesced re-stamp happens per frame.
this.territoryPass.setBorderPatchConsumer((x, y) => {
this.borderPass.patchTile(x, y);
this.defenseCoveragePass.markTileDirty(x, y);
});
// Territory fill darkens on interior tiles defended by a same-owner post;
// borderTex lets the fill skip border tiles (those get the checkerboard).
this.territoryPass.setDefenseCoverageTex(
this.defenseCoveragePass.getCoverageTex(),
);
this.territoryPass.setBorderTex(this.res.borderTex);
// --- Spawn overlay (needs tileTex) ---
this.spawnOverlayPass = new SpawnOverlayPass(
@@ -368,6 +390,9 @@ export class GPURenderer {
this.res.borderTex,
this.settings,
);
this.borderStampPass.setDefenseCoverageTex(
this.defenseCoveragePass.getCoverageTex(),
);
// --- Fallout bloom (needs tileTex, heatManager) ---
this.bloomPass = new FalloutBloomPass(
@@ -822,7 +847,7 @@ export class GPURenderer {
});
}
}
this.borderPass.updateDefensePosts(posts);
this.defenseCoveragePass.updateDefensePosts(posts);
}
applyDeadUnits(deadUnits: DeadUnitFx[]): void {
@@ -1203,6 +1228,7 @@ export class GPURenderer {
// pushed per-tile border patches via the wired `borderPatchConsumer`.
if (this.territoryPass.flushTileTexture() === "full") {
this.borderPass.markGlobalDirty();
this.defenseCoveragePass.markDirty();
}
this.trailPass.flushTexture();
this.heatManager.updateHeat();
@@ -1210,6 +1236,9 @@ export class GPURenderer {
private computeTextures(): void {
if (this.settings.passEnabled.borderCompute) this.borderPass.draw();
// Re-stamp defense coverage if posts/territory changed (dirty-gated).
// Leaves the default framebuffer bound; renderFrame resets the viewport.
this.defenseCoveragePass.draw();
}
private renderFrame(): void {
@@ -1328,6 +1357,7 @@ export class GPURenderer {
this.trailPass.dispose();
this.borderStampPass.dispose();
this.borderPass.dispose();
this.defenseCoveragePass.dispose();
this.bloomPass.dispose();
this.pointLightPass.dispose();
this.falloutLightPass.dispose();