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(w3ddevice): steady readable cloak, stronger outage and emp looks
Olcay Seyganc1f0172e4c9b
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex b5fb3e9ec..21d0a7faa 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1375,8 +1375,8 @@ The whole HUD is on the hardware. Four colours carry it, and they mean the same- Smoke and fire no longer end on a straight line where they meet the ground or a building. A puff that sinks into a hillside or drifts against a wall thins out over its last few metres, softly enough that a nuke's haze and a Scud's grey smoke no longer come out as stacked, stair-stepped terraces, and a toxin cloud lying low over the ground keeps its body instead of breaking into hard-edged green islands. A China mine field blinks where you can see it again: its lights hang just off the ground, and the fade had eaten all but a thirtieth of their bright middle. No effect fades over more than its own size now, so a small spark close to the ground keeps its light. This is the default renderer; Classic and the old renderer keep the hard edge they had in 2003.- Gunfire shows at the zoom you play at. A rifle's tracer was a third of a unit wide, about one pixel from the default camera, and a bullet hit nothing you could see. Tracers from rifles, Gattlings, Humvees, Technicals and Quad Cannons are now twice as wide and half again as long, the muzzle flash is half as big again, and every hit kicks up sparks and a puff of dirt where it lands. A tank shell burns a short hot streak behind it all the way to the target, where it used to be a grey sliver you could not pick out between the flash and the blast. A Crusader's, Battlemaster's, Scorpion's, Paladin's or Overlord's shot used to be a soft white glow drifting out in front of the gun, wider than the tank; it is now a short orange blast at the barrel tip, with a bigger flame and smoke puff behind it. A shell landing throws dirt and sparks around its blast. The colours are the ones the game always used, and no weapon does anything different.- A China mine field has mines in it. EA's field had no model at all, only a white glint blinking on each of its eight spots, so your own minefield looked like a patch of fireflies. Each spot is now a round steel mine pressed into a ring of dug earth, at a random turn, with an arming LED over its fuse that flicks on for a quarter of a second every second and a half, red on standard and cluster mines and a cold blue on EMP mines. You and your allies see them a little see-through, the way you see your own stealthed units. The enemy still sees nothing until he detects the field, and then he sees the same mines. 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 adds 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 short of power, 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 cloaked instead of faded. What stands behind a Pathfinder, Colonel Burton or a stealthed GLA unit bends through its body in a slow ripple, under a cold edge you can still read the unit by. When an enemy detector has found him, that edge pulses amber. An enemy stealth unit your detector finds used to turn into a flat orange shape with no paint; now it keeps its own paint, drained of colour, under a burning red-orange outline with scan lines running up it, and all of it flares on every sweep of the detector. This is the default renderer; Classic and the old renderer keep the 2003 look for all of these.+- 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 cloaked instead of faded. What stands behind a Pathfinder, Colonel Burton or a stealthed GLA unit bends through its body in a slow ripple, under a cold edge you can still read the unit by. When an enemy detector has found him, that edge turns amber and flares with each sweep. 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 keeps its own paint, drained of colour, under a burning red-orange outline with scan lines running up it, and all of it flares on every sweep of the detector. This is the default renderer; Classic and the old renderer keep the 2003 look for all of these.- 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.- A Scud Storm or a carpet bomb shakes the screen as hard as it should. The game cut a pile of heavy shakes back to a mild one, so a run of missiles or bombs landing together shook less than one of them alone. Each now shakes a step lighter and the run builds up. Demo traps and Aurora bombs shake now, and a falling building shakes harder the bigger it was.diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cppindex 84b0efb30..7938afcde 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp@@ -91,6 +91,19 @@ extern void DoTrees(RenderInfoClass & rinfo);extern void DoShadows(RenderInfoClass & rinfo, Bool stencilPass);extern void DoParticles(RenderInfoClass & rinfo);+// The Direct3D 11 cloak goes by the stealthed state, not by the opacity, which a friendly stealth+// unit swings between about a half and one: drawn by the opacity it blinked on and off. Such a+// unit always goes in the translucent pass, after the opaque world, because the cloak bends a copy+// of the scene taken at its first draw. theTranslucentPass is up while that pass draws.+static Bool theTranslucentPass = FALSE;++static Bool wearsCloak( const Drawable *draw )+{+ const StealthLookType look = draw->getStealthLook();+ return ( look == STEALTHLOOK_VISIBLE_FRIENDLY || look == STEALTHLOOK_VISIBLE_FRIENDLY_DETECTED )+ && Direct3D11_Draw_Effects();+}+// No texturing, no zbuffer reading/writing, primary gradient, no// blending, no fogging - mostly for use in solid-colored opaque objects.#define SC_PLAYER_COLOR ( SHADE_CNST(ShaderClass::PASS_ALWAYS, ShaderClass::DEPTH_WRITE_DISABLE, ShaderClass::COLOR_WRITE_ENABLE, \@@ -515,7 +528,7 @@ void RTS3DScene::Visibility_Check(CameraClass * camera)if ( ! isVisible )continue;- if (draw->getEffectiveOpacity() != 1.0f && m_translucentObjectsCount < TheGlobalData->m_maxVisibleTranslucentObjects)+ if ((draw->getEffectiveOpacity() != 1.0f || wearsCloak(draw)) && m_translucentObjectsCount < TheGlobalData->m_maxVisibleTranslucentObjects){ drawInfo->m_flags |= DrawableInfo::ERF_IS_TRANSLUCENT; //object is translucentm_translucentObjectsBuffer[m_translucentObjectsCount++] = robj;}@@ -622,10 +635,10 @@ void RTS3DScene::renderSpecificDrawables(RenderInfoClass &rinfo, Int numDrawable* goes back into the logic. None under -d3d9, -headless or Classic graphics, where the heat* vision pass and the disabled tint draw what they always drew.*- * An enemy a detector found is revealed, and an own stealthed unit that is see-through is cloaked,- * with the detector's pulse as the strength in both. The cloak only in the translucent pass: the- * scene's copy it bends is taken at its first draw, and the behind-building markers draw an- * occluded unit early, mid-way through the opaque world. Mines keep the heat vision's old exception.+ * An enemy a detector found is revealed, and an own stealthed unit is cloaked whatever its opacity+ * (wearsCloak), with the detector's pulse in the strength of both. The cloak only in the+ * translucent pass: the scene's copy it bends is taken at its first draw, and the behind-building+ * markers draw an occluded unit early, mid-way through the opaque world. Mines keep the heat vision's old exception.* An EMP takes precedence over power: an EMP'd building is out of power as well. *///=============================================================================static unsigned chooseDrawEffect( const Drawable *draw, const Object *obj, Bool translucentPass, float parameters[4] )@@ -644,11 +657,12 @@ static unsigned chooseDrawEffect( const Drawable *draw, const Object *obj, Booleffect = DRAW_EFFECT_REVEALED;strength = pulse;}- else if ( ( look == STEALTHLOOK_VISIBLE_FRIENDLY || look == STEALTHLOOK_VISIBLE_FRIENDLY_DETECTED )- && opacity < 0.99f && translucentPass )+ else if ( translucentPass && wearsCloak( draw ) ){+ // Detected, the amber stays on and the detector's sweep brightens it; on the pulse alone it+ // showed for a few frames a sweep and was never seen.effect = DRAW_EFFECT_CLOAK;- strength = ( look == STEALTHLOOK_VISIBLE_FRIENDLY_DETECTED ) ? pulse : 0.0f;+ strength = ( look == STEALTHLOOK_VISIBLE_FRIENDLY_DETECTED ) ? MAX( 0.6f, pulse ) : 0.0f;}else if ( obj && !obj->isEffectivelyDead() ){@@ -762,7 +776,7 @@ void RTS3DScene::renderOneObject(RenderInfoClass &rinfo, RenderObjClass *robj, I// The Direct3D 11 frame's own look for this object, if it is in one of the four states that// have one. The two that replace the disabled tint skip it: the dark grey under them only// muddied the cold grey they draw.- rinfo.drawEffect = chooseDrawEffect( draw, obj, rinfo.alphaOverride < 1.0f, rinfo.drawEffectParameters );+ rinfo.drawEffect = chooseDrawEffect( draw, obj, theTranslucentPass, rinfo.drawEffectParameters );// HANDLE THE SPECIAL DRAWABLE-LEVEL COLORING SETTINGS FIRST@@ -1740,10 +1754,14 @@ void RTS3DScene::flushOccludedObjectsIntoStencil(RenderInfoClass & rinfo){ //no occluded objects so don't need to render anything special. Just draw the queued up//objects like normal because they were skipped in the main scene traversal.+ // A translucent occludee is drawn by the translucent pass; drawn here as well it came out+ // solid, a stealthed unit under its own see-through copy, whenever no building was in view.RenderObjClass **occludeeList=m_potentialOccludees;for (i=0; i<m_numPotentialOccludees; i++){- renderOneObject(rinfo, (*occludeeList), localPlayerIndex);+ const DrawableInfo *occludeeInfo = (const DrawableInfo *)(*occludeeList)->Get_User_Data();+ if (!(occludeeInfo->m_flags & DrawableInfo::ERF_IS_TRANSLUCENT))+ renderOneObject(rinfo, (*occludeeList), localPlayerIndex);occludeeList++; //advance to next one}@@ -1858,7 +1876,9 @@ void RTS3DScene::flushTranslucentObjects(RenderInfoClass & rinfo)rinfo.alphaOverride = draw->getEffectiveOpacity();+ theTranslucentPass = TRUE;renderOneObject(rinfo, robj, localPlayerIndex);//WW3D::Render(*robj,rinfo);+ theTranslucentPass = FALSE;}//Flush all the submitted translucent objects.@@ -2181,7 +2201,7 @@ void RTS3DScene::Visibility_Check(CameraClass * camera)drawInfo->m_flags = DrawableInfo::ERF_IS_NORMAL; //clear any rendering flags that may be in effect.- if (draw->getEffectiveOpacity() != 1.0f && m_translucentObjectsCount < TheGlobalData->m_maxVisibleTranslucentObjects)+ if ((draw->getEffectiveOpacity() != 1.0f || wearsCloak(draw)) && m_translucentObjectsCount < TheGlobalData->m_maxVisibleTranslucentObjects){ drawInfo->m_flags |= DrawableInfo::ERF_IS_TRANSLUCENT; //object is translucentm_translucentObjectsBuffer[m_translucentObjectsCount++] = robj;}diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.hindex 0b0a122ea..5ba8c986e 100644--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.h+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.h@@ -519,20 +519,22 @@ const unsigned NORMAL_MAPPED_LIGHTS = 4;" float seed = DrawEffectParameters.z;\n" \" float grey = dot(current.rgb, float3(0.299, 0.587, 0.114));\n" \" float3 cold = grey * float3(0.80, 0.88, 1.0);\n" \- " float stutter = effect_hash(float3(floor(t * 9.0 + seed * 31.0), seed * 97.0, 1.0));\n" \- " float sag = 0.60 + 0.07 * sin(t * 1.7 + seed * 6.2832);\n" \- " float dip = (stutter > 0.92) ? 0.6 : 1.0;\n" \- " float relit = (stutter > 0.975) ? 1.0 : 0.0;\n" \- " float lamp = smoothstep(0.55, 0.9, max(current.r, max(current.g, current.b)));\n" \- " float3 dark = cold * sag * dip * (1.0 - 0.8 * lamp * (1.0 - relit));\n" \- " float3 cell = floor(world * 0.25);\n" \- " float3 inside = frac(world * 0.25) - 0.5;\n" \- " float slot = floor(t * 6.0 + seed * 7.0);\n" \- " float live = step(0.9975, effect_hash(cell + float3(slot * 1.31, seed * 13.0, 0.0)));\n" \+ " float stutter = effect_hash(float3(floor(t * 7.0 + seed * 31.0), seed * 97.0, 1.0));\n" \+ " float sag = 0.45 + 0.08 * sin(t * 1.7 + seed * 6.2832);\n" \+ " float dip = (stutter > 0.82) ? 0.3 : 1.0;\n" \+ " float relit = (stutter > 0.95) ? 1.0 : 0.0;\n" \+ " float lamp = smoothstep(0.42, 0.8, max(current.r, max(current.g, current.b)));\n" \+ " float3 dark = cold * sag * dip * (1.0 - 0.95 * lamp * (1.0 - relit)) + relit * lamp * current.rgb * 0.8;\n" \+ " float3 cell = floor(world * 0.125);\n" \+ " float3 inside = frac(world * 0.125) - 0.5;\n" \+ " float slot = floor(t * 8.0 + seed * 7.0);\n" \+ " float live = step(0.985, effect_hash(cell + float3(slot * 1.31, seed * 13.0, 0.0)));\n" \" float3 point_at = float3(effect_hash(cell + 3.1), effect_hash(cell + 5.7), effect_hash(cell + 7.3)) - 0.5;\n" \- " float spark = live * saturate(1.0 - length((inside - point_at * 0.6) - surface * dot(inside - point_at * 0.6, surface)) * 4.0);\n" \+ " float3 off = inside - point_at * 0.6;\n" \+ " float spark = live * saturate(1.0 - length(off - surface * dot(off, surface)) * 2.5);\n" \+ " float crackle = 0.6 + 0.4 * effect_hash(float3(floor(t * 40.0), cell.x, cell.y));\n" \" current.rgb = lerp(current.rgb, dark, DrawEffectParameters.y)\n" \- " + spark * spark * saturate(grey * 4.0) * float3(1.6, 2.2, 3.0);\n" \+ " + spark * spark * crackle * saturate(grey * 8.0) * float3(4.0, 5.0, 6.5);\n" \" return current;\n" \"}\n" \"\n" \@@ -545,15 +547,16 @@ const unsigned NORMAL_MAPPED_LIGHTS = 4;" float t = DrawEffectParameters.x;\n" \" float seed = DrawEffectParameters.z;\n" \" float grey = dot(current.rgb, float3(0.299, 0.587, 0.114));\n" \- " float3 base = lerp(current.rgb, grey * float3(0.70, 0.80, 1.0), 0.55) * 0.75;\n" \+ " float3 base = lerp(current.rgb, grey * float3(0.70, 0.80, 1.0), 0.65) * 0.6;\n" \" float wide = effect_noise(world * 0.11 + float3(seed * 17.0, 0.0, t * 1.6));\n" \" float fine = effect_noise(world * 0.29 - float3(0.0, t * 2.3, seed * 9.0));\n" \- " float line_wide = saturate(1.0 - abs(wide - 0.5) * 28.0);\n" \- " float line_fine = saturate(1.0 - abs(fine - 0.5) * 40.0);\n" \- " float strobe = step(0.3, effect_hash(float3(floor(t * 24.0), seed * 41.0, 2.0)));\n" \- " float arc = (line_wide * line_wide + 0.7 * line_fine * line_fine) * strobe;\n" \- " float rim = pow(1.0 - facing, 3.0) * (0.55 + 0.45 * sin(t * 37.0 + seed * 6.2832));\n" \- " current.rgb = base + (arc * 2.4 + rim * 0.5) * float3(0.45, 0.72, 1.0) * DrawEffectParameters.y;\n" \+ " float line_wide = saturate(1.0 - abs(wide - 0.5) * 16.0);\n" \+ " float line_fine = saturate(1.0 - abs(fine - 0.5) * 24.0);\n" \+ " float strobe = 0.35 + 0.65 * step(0.25, effect_hash(float3(floor(t * 24.0), seed * 41.0, 2.0)));\n" \+ " float arc = (line_wide * line_wide + 0.8 * line_fine * line_fine) * strobe;\n" \+ " float rim = pow(1.0 - facing, 2.0) * (0.6 + 0.4 * sin(t * 37.0 + seed * 6.2832));\n" \+ " float hum = 0.08 + 0.05 * sin(t * 11.0 + seed * 6.2832);\n" \+ " current.rgb = base + (arc * 4.0 + rim * 0.9 + hum) * float3(0.45, 0.72, 1.0) * DrawEffectParameters.y;\n" \" return current;\n" \"}\n" \"\n" \@@ -567,19 +570,19 @@ const unsigned NORMAL_MAPPED_LIGHTS = 4;" effect_surface(position, world, surface, facing);\n" \" float t = DrawEffectParameters.x;\n" \" float opacity = max(DrawEffectParameters.w, 0.05);\n" \- " float rim = pow(1.0 - facing, 2.5);\n" \- " float swim_x = effect_noise(world * 0.35 + float3(t * 0.7, t * 0.4, t * 1.1)) - 0.5;\n" \- " float swim_y = effect_noise(world * 0.35 + float3(5.2 - t * 0.5, 1.3, t * 0.9)) - 0.5;\n" \+ " float rim = pow(1.0 - facing, 1.5);\n" \+ " float swim_x = effect_noise(world * 0.6 + float3(t * 0.9, t * 0.5, t * 1.3)) - 0.5;\n" \+ " float swim_y = effect_noise(world * 0.6 + float3(5.2 - t * 0.7, 1.3, t * 1.1)) - 0.5;\n" \" float2 screen = 1.0 / ShadowViewport.xy;\n" \- " float2 bend = float2(swim_x, swim_y) * (0.012 + 0.03 * rim) * screen.y + surface.xy * rim * 0.006 * screen.y;\n" \+ " float2 bend = float2(swim_x, swim_y) * (0.016 + 0.03 * rim) * screen.y + surface.xy * rim * 0.008 * screen.y;\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 band = smoothstep(0.92, 1.0, sin(world.z * 0.35 - t * 3.0)) * 0.12;\n" \- " float own = saturate(opacity * 0.6);\n" \+ " float band = smoothstep(0.85, 1.0, sin(world.z * 0.5 - t * 4.0)) * 0.35;\n" \+ " float own = 0.4;\n" \" float3 edge = lerp(float3(0.45, 0.85, 1.0), float3(1.0, 0.55, 0.15), DrawEffectParameters.y);\n" \- " float edge_gain = 0.45 + 0.35 * DrawEffectParameters.y * (0.5 + 0.5 * sin(t * 9.0));\n" \- " current.rgb = lerp(behind * float3(0.93, 0.98, 1.04), current.rgb, own)\n" \- " + (rim * edge_gain + band) * edge;\n" \+ " float edge_gain = 0.9 + 0.6 * DrawEffectParameters.y * (0.5 + 0.5 * sin(t * 9.0));\n" \+ " current.rgb = lerp(behind * float3(0.85, 0.95, 1.15), current.rgb, own)\n" \+ " + (rim * edge_gain + band + 0.08) * edge;\n" \" current.a = saturate(current.a / opacity);\n" \" return current;\n" \"}\n" \