refactor: remove contested territory smoke effects and add tile count tracking

- Remove unused GLSL noise functions (hash12, valueNoise, fbm) from TerritoryWebGLRenderer
- Remove contested fill smoke rendering code that used these noise functions
- Add contestTileCount field to TerritoryLayer to track total contested tiles
- Update debug output to include contest tile count for monitoring
This commit is contained in:
scamiv
2026-01-12 00:39:08 +01:00
parent 370d8eec7b
commit 6bb22ca571
2 changed files with 7 additions and 53 deletions
@@ -69,6 +69,7 @@ export class TerritoryLayer implements Layer {
private contestAttackers: Uint16Array | null = null;
private contestTileIndices: Int32Array | null = null;
private contestComponents = new Map<number, ContestComponent>();
private contestTileCount = 0;
private tickSnapshotPending = false;
private tickTimeMsCurrent = 0;
private tickTimeMsPrev = 0;
@@ -133,6 +134,11 @@ export class TerritoryLayer implements Layer {
this.applyContestChanges(ownerUpdates, nowTickPacked);
this.updateContestState(nowTickPacked);
this.updateContestStrengths();
let tileCount = 0;
for (const component of this.contestComponents.values()) {
tileCount += component.tiles.length;
}
this.contestTileCount = tileCount;
const updates = this.game.updatesSinceLastTick();
// Detect alliance mutations
@@ -1135,6 +1141,7 @@ export class TerritoryLayer implements Layer {
`smoothPrereq: prevCopy ${stats.prevStateCopySupported ? "yes" : "no"}`,
`jfa: ${jfaStatus} dirty ${stats.jfaDirty ? "yes" : "no"}`,
`contest: ${this.contestActive ? "on" : "off"} comps ${this.contestComponents.size}`,
`contestTiles: ${this.contestTileCount}`,
`contestTicks: ${this.contestDurationTicks}`,
`hovered: ${stats.hoveredPlayerId}`,
];
@@ -2718,35 +2718,6 @@ export class TerritoryWebGLRenderer {
return fract(52.9829189 * x);
}
float hash12(vec2 p) {
return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);
}
float valueNoise(vec2 p) {
vec2 i = floor(p);
vec2 f = fract(p);
float a = hash12(i);
float b = hash12(i + vec2(1.0, 0.0));
float c = hash12(i + vec2(0.0, 1.0));
float d = hash12(i + vec2(1.0, 1.0));
vec2 u = f * f * (3.0 - 2.0 * f);
return mix(mix(a, b, u.x), mix(c, d, u.x), u.y);
}
float fbm(vec2 p) {
float value = 0.0;
float amp = 0.65;
vec2 shift = vec2(19.0, 7.0);
value += amp * valueNoise(p);
amp *= 0.5;
p = p * 2.1 + shift;
value += amp * valueNoise(p);
amp *= 0.5;
p = p * 2.05 + shift;
value += amp * valueNoise(p);
return value;
}
uint relationCode(uint owner, uint other) {
if (owner == 0u || other == 0u) {
return 0u;
@@ -3094,30 +3065,6 @@ export class TerritoryWebGLRenderer {
}
}
if (useContestedFill && u_jfaAvailable) {
vec2 seedOld = jfaSeedOldAtTex(texCoord);
vec2 seedNew = jfaSeedNewAtTex(texCoord);
if (seedOld.x >= 0.0 && seedNew.x >= 0.0) {
float oldDistance = length(seedOld - vec2(texCoord));
float newDistance = length(seedNew - vec2(texCoord));
float battle = clamp(abs(contestStrength(contestId) - 0.5) * 2.0, 0.0, 1.0);
float bandWidth = mix(1.6, 0.9, battle);
float frontDistance = min(oldDistance, newDistance);
float band =
1.0 - smoothstep(bandWidth, bandWidth + 0.6, frontDistance);
float scale = mix(0.1, 0.2, battle);
float drift = mix(0.05, 0.14, battle);
vec2 p = vec2(texCoord) * scale +
vec2(u_time * drift, -u_time * drift * 0.6);
float n = fbm(p);
float cloud = smoothstep(0.55, 0.82, n);
float intensity = mix(0.06, 0.22, battle);
float alpha = cloud * band * intensity;
vec3 smoke = vec3(0.85, 0.83, 0.8);
color = mix(color, smoke, alpha);
}
}
if (u_hoveredPlayerId >= 0.0 && abs(float(owner) - u_hoveredPlayerId) < 0.5) {
float pulse = u_hoverPulseStrength > 0.0
? (1.0 - u_hoverPulseStrength) +