Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

fix(w3ddevice): halve -volsmoke building and trail smoke again

Olcay Seygan320c04bdd94c
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9245673a7..42d40f2e7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -115,8 +115,8 @@ found and fixed, EA's own, not port damage.**
- A tank goes up the way the footage of a real one does. Orange flame and black smoke burst out low along its own hull, long under an Overlord and short under a Crusader, and roll along the ground off both ends over a skirt of pale dust. A ragged fan of blown-out white fire with orange edges rises straight off the hull and opens wider as it climbs, tallest in the middle, on High about twice as tall as the fire is wide and on Low a shorter fan of the same shape, and in about a second it has cooled through orange to grey-brown smoke. Near-black soot banks up low along the hull, licked red by the fire under it, and swells for nearly a second after the flash, while hot sparks streak up out of the fire in long thin lines and fall back. The wreck's black column is gone about four seconds after the death, and a thin wisp over a glowing ember fades out by seven, half as long as the game's own smoke with the setting Off, so a fast game is never fighting through last minute's smoke; it used to stand for half a minute, which in a fast game left a field of black pillars. A Crusader's fan no longer stands on a thin stem or grows horns at its edges. The glowing ball and the rays round it are gone, and so is the ring on the ground. Shells that hit a tank's armour no longer throw a fountain of dirt off it. The scrap flying off a dead tank keeps its own sparks but no longer drags thick grey arcs across the fire, and a gun's muzzle smoke is the soft grey puff it always was, where it had turned into a flat tan disc on the ground.
- A nuke builds a mushroom you can read. The flash is light: the ground, the buildings and the missile's own smoke trail go white for a third of a second, where a flat white disc used to cover half the screen for most of a second. From the first frame a lumpy ball of fire sits on the ground, yellow-white inside an orange-red rim, with a thin white dome running out round it, and the orange disc that lay on the ground under it is gone. The ball rises and slows, and by five seconds is an orange cap on a thin grey-brown stem. A white collar rings the stem for a few seconds. The cap cools to cream and lumpy cauliflower, three to four times as wide as the stem, and it stays up for over a minute; the old one was a dark brown disc that had thinned away inside twelve seconds. The dark dust that used to bury the whole base under the cloud is gone, and a low wall of dust runs out along the ground between the buildings instead. The missile's own trail is smoke in the same air now, a thick pale column behind it on the way up from the silo and on the way down, drifting with the wind and spreading as it thins, where it used to stay a column of flat sprites.
- Every other smoke goes the same way while it is on: missile and rocket trails, the dust behind a tank, a burning building's column, muzzle smoke. They are fed into one body of air round the camera instead of being drawn as sprites, and a unit moving through it pushes it. A tank's hull shoves the smoke aside and leaves a turning wake, a jet drags a sheet of it down between two wingtip vortices, and a helicopter hovering low flattens a burning column into a dark ring on the ground and lifts a band of dust round itself. A blast's front pushes the smoke already hanging round it outwards. Units you cannot see push nothing, so the smoke never gives away a stealthed tank or an unscouted base.
-- Missile and rocket trails are thin ribbons of real smoke. A Tomahawk's, a Rocket Buggy's and a Scud Launcher's lay a pale line that breaks into puffs, widens towards its old end, stirs and drifts off with the wind, and is gone about as soon as the game's own trail would be, so a Rocket Buggy salvo no longer leaves a tan haze over the field: a Tomahawk's arc over Heartland Shield is gone about 3.5 s after the launch, where it hung on for 5 to 6 and the game's own lasts about 3. A trail that climbs high, a Scud's arc or the nine columns a Scud Storm puts up, goes into a second, taller body of air over the battlefield, a thousand units high, where it thins just as fast. The trails are lit by the sun like any smoke: the Scud Storm's columns had stood as straight glowing pillars of one width, and at night on Dark Night the trails stood out pale blue as if lit from inside. Before, a fast missile's trail broke into a dotted line of brown blobs, and once a missile climbed past about 200 units over the ground the top of its trail simply vanished.
-- Buildings come down in their own shape. The smoke reads the building's model: the moment one dies, smoke and dust fill each of its parts where it stood, a War Factory's hall and its two stacks, a Speaker Tower's mast, and slump down, while fire bursts out of the tops of the biggest parts and a ragged plume climbs out of them and cools to smoke. Pale dust pours out from under every wall along the ground and runs round the buildings beside it, between their real walls and stacks rather than over one box, and the ruin burns under a grey-brown column for seven seconds, so a fall's smoke is off the screen about when the game's own is (it stayed for fourteen, and in a fast game that hid the next fight); a damaged building's own smoke also thins as quickly as its puffs do. The size follows the building: an American Power Plant's is about half the width of a War Factory's or a Particle Cannon's. Each damaged stage on the way down blows fire out of the top of the standing building with a little smoke, where it used to leave a big black cloud over the roof, and the shells landing on it in that moment no longer leave their fireballs floating over the cloud. The fall's smoke is lit on its sunny side: on Winter Wolf's snow it had stood as one block of pure black across the middle of the screen. The game's own fireball sprites, flare and flat shock ring for that moment are gone while the smoke is on; flying debris keeps its sparks.
+- Missile and rocket trails are thin ribbons of real smoke. A Tomahawk's, a Rocket Buggy's and a Scud Launcher's lay a pale line that breaks into puffs, widens towards its old end, stirs and drifts off with the wind, and fades out along its length as it goes, the oldest end first, so a Rocket Buggy salvo no longer leaves a tan haze over the field: a Tomahawk's arc over Heartland Shield is gone about 2.5 s after the launch, where it hung on for 5 to 6 and the game's own lasts about 3. A trail that climbs high, a Scud's arc or the nine columns a Scud Storm puts up, goes into a second, taller body of air over the battlefield, a thousand units high, where it thins just as fast. The trails are lit by the sun like any smoke: the Scud Storm's columns had stood as straight glowing pillars of one width, and at night on Dark Night the trails stood out pale blue as if lit from inside. Before, a fast missile's trail broke into a dotted line of brown blobs, and once a missile climbed past about 200 units over the ground the top of its trail simply vanished.
+- Buildings come down in their own shape. The smoke reads the building's model: the moment one dies, smoke and dust fill each of its parts where it stood, a War Factory's hall and its two stacks, a Speaker Tower's mast, and slump down, while fire bursts out of the tops of the biggest parts and a ragged plume climbs out of them and cools to smoke. Pale dust pours out from under every wall along the ground and runs round the buildings beside it, between their real walls and stacks rather than over one box, and the ruin burns under a grey-brown column for four seconds, so a fall's smoke and dust are off the screen 5 to 6 s after it, sooner than the game's own at 7 to 8 (it stayed for fourteen at first, and in a fast game that hid the next fight); a damaged building's own smoke and the dust round it thin within a couple of seconds of their puffs. The size follows the building: an American Power Plant's is about half the width of a War Factory's or a Particle Cannon's. Each damaged stage on the way down blows fire out of the top of the standing building with a little smoke, where it used to leave a big black cloud over the roof, and the shells landing on it in that moment no longer leave their fireballs floating over the cloud. The fall's smoke is lit on its sunny side: on Winter Wolf's snow it had stood as one block of pure black across the middle of the screen. The game's own fireball sprites, flare and flat shock ring for that moment are gone while the smoke is on; flying debris keeps its sparks.
- It costs the graphics card. Three armies and three superweapons on Twilight Flame at 1920x1080, on an RTX 2060: 5.2 ms of GPU time a frame with it Off, 8.6 on Low and 10.0 to 10.2 on High; the frame itself took 5.3, 5.6 and 6.9 to 7.2 ms. Low runs half as many blasts at once in a coarser body of air, so a weak card should leave it Off or take Low. A nuke on an American base on the same map costs 2.4 ms of GPU time a frame Off, 4.1 to 4.7 on Low and 6.9 to 7.1 on High. A rocket fight with Scud Launchers, then a Scud Storm and a nuke, seen from over the rockets: 2.2 ms Off, 3.1 on Low, 4.1 to 4.2 on High. Five buildings brought down one after another on that base: 1.3 ms Off, 1.9 to 2.0 on Low, 2.2 on High.
## A rank ladder for every army
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DX11VolumeSmoke.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DX11VolumeSmoke.cpp
index 00edceade..4842d9d0d 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DX11VolumeSmoke.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DX11VolumeSmoke.cpp
@@ -24,7 +24,7 @@
// Gather, and sized by them: each mesh fills with smoke and dust in its own place and slumps, fire
// bursts out of the tops of the biggest, a ragged plume climbs out of them and cools to grey-brown
// smoke, the collapse pours pale dust out from under every wall along the ground and round the
-// buildings beside it, and the ruin burns under a column for seven seconds. A damaged stage
+// buildings beside it, and the ruin burns under a column for four seconds. A damaged stage
// blows fire out of the top of a building that stays standing.
//
// A nuclear-class blast (the missile, the GLA's, the MOAB) has a volume of its own, much bigger:
@@ -127,7 +127,7 @@ const float VelocityHalfLife = 3.0f;
const float HeatHalfLife = 1.8f;
const float DustHalfLife = 6.0f;
const float CapSpillHalfLife = 1.0f; // a nuclear cap's soot once the flow has carried it out of the cap
-const float StructureSootHalfLife = 3.0f; // a building's blast's soot: at 7 a fall's smoke was on screen for 14 s, stock's for 7 to 10
+const float StructureSootHalfLife = 1.5f; // a building's blast's soot: at 7 a fall's smoke was on screen for 14 s, at 3 for 7 to 10
// A tank's soot from 2.5 s on, once its column is falling: its black column is gone from the play
// camera about 4 s after the death and a thin smoulder fades out by 7 s (the volume lives 8.5, so its
// own 3 s end fade starts as the smoulder's ends and does not dim it twice). The
@@ -1008,7 +1008,10 @@ const unsigned AirTileEntries = 27; // brick list room a particle: a sphere of
const float AirExtinction = 0.04f; // per world unit at density 1: the air's smoke is thinner than a blast's
// seconds, once no particle holds it up: a damaged building's SmokeFaction* puffs live 2 to 5.3 s
// and StructureDamagedSmoke's 1.5 s, and at 7 the air kept them on screen for twice as long again
-const float AirSootHalfLife = 3.0f;
+const float AirSootHalfLife = 1.5f; // (halved again from 3 at the owner's word: a fast game)
+// The air's dust thins on its own clock, apart from a blast's DustHalfLife: a tan lobe of dust stood
+// beside a fallen War Factory long after its smoke had gone at the shared 6 s
+const float AirDustHalfLife = 2.0f;
const float AirTakeUp = 8.0f; // a second: how fast the cells under a particle reach its smoke
const float AirCoverage = 0.7f; // a billboard's opacity at its centre, against its alpha
// A sphere's falloff, the trilinear blur of a few cells and the noise take most of the opacity a
@@ -1030,7 +1033,10 @@ const float TrailBright = 1.7f;
// over Heartland Shield was on screen for 5 to 6 s where stock's is gone in 3; a cell holds what its
// particle laid while it lives, so the half-life is what follows the particle's 2 s: at 1.5 the arc
// still showed 4.5 s after the launch)
-const float TrailHalfLife[2] = { 0.8f, 0.8f };
+const float TrailHalfLife[2] = { 0.5f, 0.5f };
+// and so a trail's particle lays less the older it is (by (1 - age)^TrailAgeFade), so its cells sink
+// with it over its life and are gone about half a second after it: at a fixed rate the arc showed 5 s
+const float TrailAgeFade = 1.5f;
// A trail's particle stands for more smoke the older it is, spread wider: the end of a column
// farthest from the missile is up to this much wider than its head, so it opens out as it ages.
const float TrailSpread = 1.5f;
@@ -1930,8 +1936,8 @@ void schedule(const Volume &volume, unsigned slab, float t, DrawConstants *draw)
// half its radius into the ground so only a low lens of it stands over it, and the eight
// overlap into one sheet the shape of the footprint. Standing on the ground, the same
// bodies stood round the building as a ring of grey balls. A standing building drops none.
- if (!standing && t > 0.1f && t < 3.0f) {
- const float fade = 1 - (t - 0.1f) / 2.9f, pour = 1.0f;
+ if (!standing && t > 0.1f && t < 1.8f) {
+ const float fade = 1 - (t - 0.1f) / 1.7f, pour = 1.0f; // (to 3 s, the dust still lay round the ruin at 10)
for (unsigned k = 0; k < 8; ++k) {
const bool end = k >= 4;
const float s = (k & 1) ? 1.0f : -1.0f, along = (k & 2) ? 0.5f : -0.5f;
@@ -1946,11 +1952,11 @@ void schedule(const Volume &volume, unsigned slab, float t, DrawConstants *draw)
}
}
// The ruin burning: a column off the ground its two biggest meshes stood on, leaning with the
- // wind, done by 7.5 s, as the stock building smoke is (StructureTransition*Smoke lives 6.7 s,
- // ReforgedStructureSmoke 7.3 to 8.7 s): the game is fast, and a column that hung on for
- // fifteen seconds hid the next fight. Its fire goes out with it.
- if (!standing && t > 0.8f && t < 7.5f) {
- const float rise = (std::min)((t - 0.8f) / 1.5f, 1.0f), fall = t > 3.0f ? 1 - (t - 3.0f) / 4.5f : 1.0f;
+ // wind, done by 4.5 s: the game is fast, and the owner halved it again from 7.5 s (stock's
+ // StructureTransition*Smoke lives 6.7 s), where it had hung on for fifteen at first and hidden
+ // the next fight. Its fire goes out with it.
+ if (!standing && t > 0.8f && t < 4.5f) {
+ const float rise = (std::min)((t - 0.8f) / 0.8f, 1.0f), fall = t > 2.0f ? 1 - (t - 2.0f) / 2.5f : 1.0f;
for (unsigned i = 0; i < (std::min)(partCount, 2u); ++i) {
const Part &p = parts[big[i]];
onFootprint(p.along, p.across, 0.6f, (std::max)((std::min)(p.halfAlong, p.halfAcross) * 0.6f, 2.0f), 0, 0, 12.0f,
@@ -2671,7 +2677,7 @@ void stepAir(ID3D11DeviceContext *context, unsigned g, int now, float dt, float
const unsigned h = (p->getPersonality() ^ unsigned(reinterpret_cast<uintptr_t>(p) >> 4)) * 2654435761u;
const float age = p->m_lifetime ? 1.0f - (float)p->getLifetimeLeft() / (float)p->m_lifetime : 0.0f;
puff = (0.65f + 0.8f * ((h >> 8) & 255) / 255.0f) * (1.0f + TrailSpread * (std::min)((std::max)(age, 0.0f), 1.0f));
- thick = 0.55f + 0.9f * ((h >> 16) & 255) / 255.0f;
+ thick = (0.55f + 0.9f * ((h >> 16) & 255) / 255.0f) * std::pow(1.0f - (std::min)((std::max)(age, 0.0f), 1.0f), TrailAgeFade);
}
const float radius = (std::min)((std::max)(p->getSize() * 0.6f, cell * (streak ? 0.6f : 0.8f)) * puff, cell * 8.0f);
// inside the box less its faded rim
@@ -2825,7 +2831,7 @@ void stepAir(ID3D11DeviceContext *context, unsigned g, int now, float dt, float
sim.Forces[3] = Drag;
sim.Keep[0] = std::pow(0.5f, dt / HeatHalfLife);
sim.Keep[1] = std::pow(0.5f, dt / VelocityHalfLife);
- sim.Keep[2] = std::pow(0.5f, dt / DustHalfLife);
+ sim.Keep[2] = std::pow(0.5f, dt / AirDustHalfLife);
sim.Keep[3] = std::pow(0.5f, dt / AirSootHalfLife);
for (unsigned i = 0; i < 3; ++i) sim.Sun[i] = sunToward[i];
sim.Sun[3] = AirExtinction;
@@ -2901,7 +2907,7 @@ bool screenRect(const float boxLow[3], const float boxHigh[3], const float viewP
// How long each kind lives, in seconds, how big its cell is, how far and how long after its blast
// another system of the same FX joins it, and which of those it takes.
-float lifeOf(Kind kind) { return kind == TankDeath ? 8.5f : kind == Structure ? 12.0f : kind == Nuclear ? 90.0f : 12.0f; }
+float lifeOf(Kind kind) { return kind == TankDeath ? 8.5f : kind == Structure ? 6.0f : kind == Nuclear ? 90.0f : 12.0f; }
float cellOf(Kind kind, float scale) { return kind == TankDeath ? 3.0f : kind == Nuclear ? 10.0f : 2.0f * scale; }
float joinRadius(const Volume &volume)
{
@@ -3206,7 +3212,7 @@ bool Takes(ParticleSystem *system)
volume.partCount ? volume.parts[0].bottom * cell : 0.0f, volume.partCount ? volume.parts[0].top * cell : 0.0f));
}
volume.born = now;
- volume.life = int((type == Structure && volume.standing ? 8.0f : lifeOf(type)) * LOGICFRAMES_PER_SECOND);
+ volume.life = int((type == Structure && volume.standing ? 4.0f : lifeOf(type)) * LOGICFRAMES_PER_SECOND);
// its front through the air round it, in world units a second. A tank's has none: a sphere
// pushing out from the hull's middle blew its own fire into a dome and the dust round it into
// rings, where a real one bursts out along the hull and up (schedule).