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): toxin fields show the units and ground inside them

Olcay Seygan8fbe589acf6b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5cce4e5ad..933c6f1c1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -104,6 +104,7 @@ found and fixed, EA's own, not port damage.**
## Volumetric hazard clouds
- Options has a Cloud Style box. Volumetric draws toxin, anthrax and nuclear fields as moving smoke at the size and for the time the hazard really lasts: low smoke hugs the ground and curls around infantry walking through it, and a nuclear field fades in across its whole width with dark billows and embers rising through the heat shimmer. The damage is exactly what it was. Classic stays the default until the cost in a big battle is measured.
+- You can see into a toxin field. The cloud was thick enough to hide the soldiers and the ground inside it, which is the one thing you need to read when deciding whether to walk in. Toxin, Anthrax Beta and Anthrax Gamma now share one thickness, 42% of plain toxin's old one, and the Classic puddles glow half as hard on Direct3D 11 and Direct3D 9 alike. Radiation looks as it did, and each field's damage, size and time are unchanged.
- Windows draws them too, on the default renderer, and so do Linux and macOS. The Direct3D 9 renderer and the Classic graphics setting keep the original puddles whatever the box says, and turning heat effects off takes the shimmer off a nuclear field as well. A cloud that only drifts redraws its smoke twenty times a second rather than every frame, and the second match of a session no longer stalls on the first toxin shell while the clouds' shaders are built again.
- The first toxin cloud of a fresh install no longer freezes the game for three and a half seconds: the clouds' shaders come with the game now, and are made ready when a match starts or the box is switched rather than when the first field opens. A toxin field also no longer comes back at full strength for ten seconds after it has run out; it fades with the hazard.
- A fresh install's first Scud Storm landing, Particle Cannon, nuke and general's air strikes no longer catch a picture for 110 to 130 milliseconds each, whichever cloud style is on. The explosion and lit-smoke shaders those strikes draw with come with the game now, where each one used to be built the first time its blast showed up; a superweapon battle on Twilight Flame from a fresh install now builds nothing at all.
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/HazardCloud.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/HazardCloud.cpp
index 62071e745..078a926c0 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/HazardCloud.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/HazardCloud.cpp
@@ -10,11 +10,16 @@
namespace HazardCloud {
namespace {
+// Toxin, nuclear, beta, gamma. The last number is the transparency: 0.67, 0.77 and 0.74 hid the
+// units and the ground inside a chemical field, so the three share one value now. A uniform, so no
+// program changes.
+constexpr float ToxinTransparency = 0.86f;
+
constexpr std::array<Palette, 4> approved = {{
- {{0.769999981f, 0.939999998f, 0.550000012f}, {0.125490203f, 0.31764707f, 0.0549019612f}, 0.699999988f, 0.670000017f},
+ {{0.769999981f, 0.939999998f, 0.550000012f}, {0.125490203f, 0.31764707f, 0.0549019612f}, 0.699999988f, ToxinTransparency},
{{0.749019623f, 0.670588255f, 0.469999999f}, {0.298039228f, 0.184313729f, 0.0705882385f}, 1.29999995f, 0.0f},
- {{0.660000026f, 0.75999999f, 1.0f}, {0.0649999976f, 0.100000001f, 0.209999993f}, 1.52999997f, 0.769999981f},
- {{0.839999974f, 0.629999995f, 1.0f}, {0.192156866f, 0.0470588244f, 0.235294119f}, 1.32000005f, 0.74000001f},
+ {{0.660000026f, 0.75999999f, 1.0f}, {0.0649999976f, 0.100000001f, 0.209999993f}, 1.52999997f, ToxinTransparency},
+ {{0.839999974f, 0.629999995f, 1.0f}, {0.192156866f, 0.0470588244f, 0.235294119f}, 1.32000005f, ToxinTransparency},
}};
} // namespace
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DParticleSys.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DParticleSys.cpp
index c1b9cf7ae..e292ab100 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DParticleSys.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DParticleSys.cpp
@@ -807,6 +807,7 @@ static const Real FIELD_BUBBLE_GAIN = 0.6f;
static const Real FIELD_COVER = 2.0f; ///< puddles per (radius / puddle size) squared
static const Int FIELD_MAX_PUDDLES = 48;
static const Real FIELD_GAIN = 0.7f; ///< of the template's brightest colour, a puddle
+static const Real FIELD_GAIN_TOXIN = 0.35f; ///< the same for a field that is not lit like radiation: at 0.7 a pool's middle added past white and hid the ground in it
static const Int FIELD_FADE_IN = LOGICFRAMES_PER_SECOND / 2; ///< logic frames
static const Int FIELD_FADE_OUT = 3 * LOGICFRAMES_PER_SECOND; ///< logic frames before the field object dies
static const Int FIELD_FADE_GONE = FIELD_FADE_OUT; ///< logic frames, a field fogged over or whose object went early
@@ -1646,7 +1647,7 @@ static Int collectGroundFields( const AABoxClass &view, CameraClass &sceneCamera
{
const FieldPuddle &puddle = s_fieldPuddles[ i ];
const Real stack = puddle.overlap > FIELD_STACK ? FIELD_STACK / puddle.overlap : 1.0f;
- const Real bright = FIELD_GAIN * draw.fade * puddle.bright * stack;
+ const Real bright = (draw.glowing ? FIELD_GAIN : FIELD_GAIN_TOXIN) * draw.fade * puddle.bright * stack;
const Real red = draw.color.red * bright, green = draw.color.green * bright, blue = draw.color.blue * bright;
const unsigned glowColor = DX8Wrapper::Convert_Color_Clamp( Vector4( red, green, blue, 1.0f ) );
unsigned stainColor = 0;
diff --git a/docs/hazard-clouds.md b/docs/hazard-clouds.md
index 8df540c6e..98f018706 100644
--- a/docs/hazard-clouds.md
+++ b/docs/hazard-clouds.md
@@ -60,7 +60,7 @@ second cloud drawn until 4436).
## What Volumetric draws
Approved green toxin, blue beta, purple gamma and amber nuclear palettes use transparency defaults
-of 67%, 77%, 74% and 0%. Effects read their actual emission radius and hazard lifetime. Toxin
+of 86%, 86%, 86% and 0%. Effects read their actual emission radius and hazard lifetime. Toxin
billows form outward; nuclear haze fades into its full footprint. Formation is capped to one quarter
of short hazard lifetimes. Visible infantry stir the smoke; hidden, stealthed or shrouded infantry
leave no wakes. Nothing here changes damage, weapons, movement, gameplay randomness or simulation