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.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
fix(ww3d2): cloak bends the scene as glass
Olcay Seygan273ea4787f75
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 6ddb604c3..b28a68c2e 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1466,7 +1466,7 @@ The whole HUD is on the hardware. Four colours carry it, and they mean the same- Blasts throw fragments that smoke. The bigger explosions fling hot sparks into the air, each drawing a white line of smoke that arcs over and curves down. A Stinger, a rocket pod, a tank shell or a rocket used to throw them too, and a fight filled with them; they now show on a bomb, a heavy shell, a Scud or a building, eight that climb several times a tank's length, and on a nuke, a MOAB, a Daisy Cutter or a large building, fourteen that arc over its own fireball and hang for nearly five seconds. Where those land the spray opens back up the line it came in on, towards the gun that fired it. A vehicle that blows up throws burning pieces that drag near-black smoke and bounce where they land, and the turret, wheels and plates it throws off trail smoke and flame too, then smoulder a moment on the ground. In a fight of seventeen tanks the screen held about 1400 particles where it held 890, peaking at 2159 of the 2500 limit; the fragments and their smoke are the first effects that limit and a lower detail setting drop, so a bigger fight keeps its explosions and loses some lines. What a weapon does is unchanged. Rather have the explosions as they always were? Explosion Debris Trails in the launcher's Options turns all of it off, for you alone: the other players in your match keep whatever they picked, and nobody's game falls out of step over it.- A China mine field tells you what kind it is. EA's field had no model at all, only a soft white glint swelling and fading on each of its eight spots, so your own minefield looked like a patch of fireflies. Each mine is now marked by a small arming light that snaps on for a quarter of a second every second and a half, red on standard and cluster mines and blue on EMP mines, with a white-hot point and a dark rim that keep it readable on grass, sand or snow. No mine body is drawn on the ground, only the light. The enemy still sees nothing until he detects the field. A mine going off under a tank now throws a column of dark earth twice the tank's height, scatters clods round it and leaves a low black smoke and a scorch, with a short jolt of the screen; it used to puff a pale spray of specks that looked like dust kicked up. An EMP mine throws no earth, so you can tell which kind went off: it lights a blue ring across the ground, a crackle of blue sparks and a short blue flash at the spot; EA's flash grew until it washed the whole screen white for a fifth of a second. What a mine does is unchanged.- A base out of power looks out of power. A building that switches off when your power runs short, or one a hacker shut down, drains to a cold grey and sags darker, and its windows and lamps go out. Every few seconds it blinks dark for an instant or its lights catch again for a moment, and blue sparks jump on its walls where something shorts. A tank or building hit by an EMP crawls with thin blue arcs for as long as it stays dead, where it used to just turn dark grey.-- Your own stealthed units look like glass, not like ice. In 3.0 a camouflaged Rebel, a Pathfinder or Colonel Burton came out under a blue skin with bands running up it, which players rightly called ugly. The blue is gone: the ground behind him shows through his body in its own colours and bends, a slow lens that ripples along him and pulls harder at his outline, with a muted share of his own paint left in it. The bend is what you find him by: each face of him tips the ground behind it its own way, so his shape shows even on plain sand, and the bend never drops below a few pixels, and a cool haze that thickens at his outline makes a cloaked squad or a camouflaged base read at a glance at the zoom you play at, still as glass and without turning white. Up close a building's flat wall bends across its face. It moves slowly and never fizzes. He breathes solid at the top of the 2003 pulse and back to glass at the bottom, and a building going invisible or coming out of it fades instead of popping; an enemy a detector finds fades into heat the same way. His shadow fades with him, to between a quarter and a half of its strength as he breathes, where it used to lie on the ground at full strength and give him away before his body did; on Classic and the old renderer the shadow stays whole. When an enemy detector has found him, his whole body beats amber along with his edge, so a spotted building reads as spotted and does not just turn tan. On every renderer, a stealthed unit of yours no longer comes out solid whenever no building is on the screen: the game drew it a second time without its see-through. An enemy stealth unit your detector finds used to turn into a flat orange shape with no paint; now it shows as heat, its own shading run from dark red through orange to a warm yellow that stops short of white, so you can still tell a tank from a soldier and bright GLA paint keeps its detail, with a burning outline and a slow glow climbing it that flares on every sweep of the detector. The fine scan lines of 3.0 are gone, since zoomed out they broke into stripes. This is the default renderer; Classic and the old renderer keep the 2003 look for all of these.+- Your own stealthed units look like glass, not like ice. In 3.0 a camouflaged Rebel, a Pathfinder or Colonel Burton came out under a blue skin with bands running up it, which players rightly called ugly. The blue is gone: the ground behind him shows through his body in its own colours and bends, a slow lens that ripples along him and pulls harder at his outline, with a muted share of his own paint left in it. The bend is what you find him by: each face of him tips the ground behind it its own way, so his shape shows even on plain sand, and the bend never drops below a few pixels, and a cool haze that thickens at his outline makes a cloaked squad or a camouflaged base read at a glance at the zoom you play at, still as glass and without turning white. Up close a building's flat wall bends across its face. It moves slowly and never fizzes. He breathes solid at the top of the 2003 pulse and back to glass at the bottom. Going invisible, the body stays a lens: the ground behind it bends and the paint recedes with that same pulse. Coming out, the bend eases off until the paint is whole. An enemy a detector finds fades into heat the same way. His shadow fades with him, to between a quarter and a half of its strength as he breathes, where it used to lie on the ground at full strength and give him away before his body did; on Classic and the old renderer the shadow stays whole. When an enemy detector has found him, his whole body beats amber along with his edge, so a spotted building reads as spotted and does not just turn tan. On every renderer, a stealthed unit of yours no longer comes out solid whenever no building is on the screen: the game drew it a second time without its see-through. An enemy stealth unit your detector finds used to turn into a flat orange shape with no paint; now it shows as heat, its own shading run from dark red through orange to a warm yellow that stops short of white, so you can still tell a tank from a soldier and bright GLA paint keeps its detail, with a burning outline and a slow glow climbing it that flares on every sweep of the detector. The fine scan lines of 3.0 are gone, since zoomed out they broke into stripes. This is the default renderer; Classic and the old renderer keep the 2003 look for all of these.- A hidden base no longer burns in plain view. The fire and smoke on a stealthed building or unit, damage flames and chimney smoke alike, kept drawing for the enemy while the building itself was invisible, so a burning Stealth General base under Camo Netting stood out as a column of black smoke on an empty patch of ground. The enemy now sees none of it until a detector finds the building, and then all of it. On your own side the flames and smoke go faint with the building and breathe with it, the fire a little stronger than the smoke, so they no longer sit at full strength beside the glass. This holds on every renderer, and the smoke's shadow and the light its fire throws on nearby smoke go with it.- Effects fade out instead of blinking off. The rings a nuke sends across the ground, and any spark, flash or puff whose own colours never reached nothing, used to vanish at full strength on their last frame. Each one now dims away over its last quarter of a second, or over a quarter of its life when it lives shorter than that. One that was already fading looks the way it always did.- Toxin, anthrax and radiation pools lie on the ground. A pool is a carpet of puddle pictures spread up to 140 paces from where the shell or the spray came down, and every one of them was drawn dead flat at the height of that one spot: on a hillside the uphill half of the pool disappeared into the slope and the downhill half hung in the air above it. Each puddle now bends over the ground underneath it, on both renderers, and a pool on a bridge stays on the deck. The pool also holds still. It used to throb twice a second, because every half second the pool's poison fired a fresh batch of puddles that swelled out of black to full green and back to black in two seconds, each batch somewhere new. Now it comes up in half a second, stays one pool at full colour for as long as it does damage, and fades over its last three seconds, or over three seconds from the moment the fog of war closes over it. It is not frozen, though: each puddle fades down and back up on its own beat, so the surface shimmers like something liquid while the pool as a whole never pulses. Four Scud warheads landing on one spot used to stack into a white-hot blotch in the middle; overlapping pools now share their light and the middle stays toxin green. The ground under it takes on its colour, green for toxin and the anthrax colours for anthrax, so it looks spilled rather than shone onto the grass. China's radiation keeps its orange but glows instead of browning the grass, which made it look like a scorch mark, and small bubbles swell out of it and pop. A nuke's radiation lies on the hillside as a pool from three seconds after the blast, where its first ten seconds used to be flat squares cutting into the slope.diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h b/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.hindex 320863351..2f435277c 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h@@ -399,6 +399,17 @@ public:StealthLookType getStealthLook() const { return m_stealthLook; }StealthLookType getStealthDrawnLook() const { return m_stealthDrawnLook; }Real getStealthFade() const { return m_stealthFade; }+ // 1 is own paint with no bend, the breath (about a half to one) is glass. Fade 0 of a+ // cloak-in is solid; fade 0 of a decloak is solid too. The shader keeps coverage: this is+ // the mix, not alpha.+ Real getStealthSolid() const+ {+ const Real breath = getEffectiveOpacity();+ const Real fade = getStealthFade();+ if( getStealthLook() == STEALTHLOOK_NONE )+ return breath + ( 1.0f - breath ) * ( 1.0f - fade );+ return 1.0f - fade * ( 1.0f - breath );+ }void updateDrawableClipStatus( UnsignedInt shotsRemaining, UnsignedInt maxShots, WeaponSlotType slot ); ///< This will do the show/hide work if ProjectileBoneFeedbackEnabled is set.void updateDrawableSupplyStatus( Int maxSupply, Int currentSupply ); ///< This will do visual feedback on Supplies carrieddiff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cppindex 5f0f4fb6f..450d1e8e6 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp@@ -4418,10 +4418,11 @@ void W3DVolumetricShadowManager::renderShadowMap( CameraClass &sceneCamera )if (caster && Direct3D11_Draw_Effects()&& (caster->getStealthDrawnLook() == STEALTHLOOK_VISIBLE_FRIENDLY|| caster->getStealthDrawnLook() == STEALTHLOOK_VISIBLE_FRIENDLY_DETECTED)+ && !caster->isKindOf( KINDOF_MINE )&& caster->getStealthFade() > 0.001f){sunInfo.drawEffect = DRAW_EFFECT_CLOAK_SHADOW;- sunInfo.drawEffectParameters[3] = caster->getEffectiveOpacity() * caster->getStealthFade();+ sunInfo.drawEffectParameters[3] = caster->getStealthSolid();}robj->Render( sunInfo );diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cppindex fa936026a..e83d8e769 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp@@ -105,7 +105,12 @@ static Bool wearsCloak( const Drawable *draw )const StealthLookType look = draw->getStealthDrawnLook();const Real fade = draw->getStealthFade();if( look == STEALTHLOOK_VISIBLE_FRIENDLY || look == STEALTHLOOK_VISIBLE_FRIENDLY_DETECTED )- return fade > 0.001f;+ {+ // mines force opacity 0 and must not become a lens on the ground+ if( draw->isKindOf( KINDOF_MINE ) )+ return FALSE;+ return TRUE;+ }// revealed fades in the translucent pass so the heat can come up from nothingif( look == STEALTHLOOK_VISIBLE_DETECTED && fade < 0.99f )return TRUE;@@ -670,11 +675,7 @@ static unsigned chooseDrawEffect( const Drawable *draw, const Object *obj, Boolconst StealthLookType look = draw->getStealthDrawnLook();const Real pulse = draw->getSecondMaterialPassOpacity();const Real fade = draw->getStealthFade();- Real opacity = draw->getEffectiveOpacity();- if( draw->getStealthLook() == STEALTHLOOK_NONE )- opacity = opacity + ( 1.0f - opacity ) * ( 1.0f - fade );- else- opacity *= fade;+ Real opacity = draw->getStealthSolid();Real strength = 1.0f;if ( look == STEALTHLOOK_VISIBLE_DETECTED && !draw->isKindOf( KINDOF_MINE )diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.hindex b4ad6d3d4..92c96909b 100644--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.h+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.h@@ -572,17 +572,20 @@ const unsigned NORMAL_MAPPED_LIGHTS = 4;" about three quarters at the outline, where a soldier's round body has most of its faces and\n" \" a building's flat walls have few: a haze rather than a white edge, darkening bright ground as\n" \" much as it lifts dark ground. The unit's own paint is mixed in by the game's stealth opacity,\n" \- " so the 2003 breath goes solid at the top of the pulse and back to glass at the bottom. Detected (the strength is never below 0.6\n" \+ " so the 2003 breath goes solid at the top of the pulse and back to glass at the bottom. Glass\n" \+ " is the bent scene with alpha 1: dropping alpha showed the unbent ground through a ghost, and\n" \+ " meshes this program does not dress (additive glows, a refused scene copy) keep the stealth\n" \+ " opacity. The bend eases off as the paint comes back, full at the glass end of the pulse. Detected (the strength is never below 0.6\n" \" then), the whole body beats amber as well as its edge: a big flat building has almost no\n" \- " edge facing away from the eye, and with the beat on the rim alone it only turned tan. The\n" \- " alpha goes back up to the texel's own, because the shade already holds the mix. */\n" \+ " edge facing away from the eye, and with the beat on the rim alone it only turned tan. */\n" \"float4 effect_cloak(float4 current, float4 position)\n" \"{\n" \" float3 world; float3 surface; float facing;\n" \" effect_surface(position, world, surface, facing);\n" \" float t = DrawEffectParameters.x;\n" \" float detected = DrawEffectParameters.y;\n" \- " float opacity = saturate(DrawEffectParameters.w);\n" \+ " float solid = saturate(DrawEffectParameters.w);\n" \+ " float haze = 1.0 - solid;\n" \" float rim = pow(1.0 - facing, 2.0);\n" \" float swim_x = effect_noise(world * 0.09 + float3(t * 0.35, t * 0.2, t * 0.45)) - 0.5;\n" \" float swim_y = effect_noise(world * 0.09 + float3(7.3 - t * 0.3, 2.1, t * 0.4)) - 0.5;\n" \@@ -595,20 +598,20 @@ const unsigned NORMAL_MAPPED_LIGHTS = 4;" float world_per_pixel = max(length(up), 1e-4);\n" \" float2 lean = float2(dot(surface, right), -dot(surface, up)) / world_per_pixel;\n" \" float reach = clamp(3.0 / world_per_pixel, 0.005 * screen.y, 0.04 * screen.y);\n" \- " float2 bend = (lean * 0.8 + float2(swim_x, swim_y) * 1.2) * reach;\n" \+ " float2 bend = (lean * 0.8 + float2(swim_x, swim_y) * 1.2) * reach * saturate(2.0 * haze);\n" \" int2 at = int2(clamp(position.xy + bend, float2(0.0, 0.0), screen - 1.0));\n" \" float3 behind = SceneColour.Load(int3(at, 0)).rgb;\n" \" float grey = dot(current.rgb, float3(0.299, 0.587, 0.114));\n" \" float3 own = lerp(grey.xxx, current.rgb, 0.7);\n" \- " float3 glass = lerp(behind, own, opacity);\n" \- " glass = lerp(glass, float3(0.52, 0.55, 0.59), (1.0 - opacity) * (0.12 + 0.65 * rim));\n" \+ " float3 glass = lerp(behind, own, solid);\n" \+ " glass = lerp(glass, float3(0.52, 0.55, 0.59), haze * (0.12 + 0.65 * rim));\n" \" float found = step(0.01, detected);\n" \" float beat = 0.55 + 0.45 * sin(t * 6.0);\n" \" float3 amber = float3(1.0, 0.55, 0.15);\n" \" float lum = dot(glass, float3(0.299, 0.587, 0.114));\n" \" glass = lerp(glass, amber * (0.3 + lum), found * (0.25 + 0.3 * beat)) + found * (rim * 1.2 + 0.18) * beat * amber;\n" \" current.rgb = glass;\n" \- " current.a = (opacity < 0.02) ? 0.0 : saturate(current.a / max(opacity, 0.05));\n" \+ " current.a = 1.0;\n" \" return current;\n" \"}\n" \"\n" \