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
feat(w3ddevice): the sun shadow map is what the game draws with
Olcay Seygan473477b10bb0
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 27dabb397..7c02b04f2 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -779,8 +779,13 @@ found and fixed — EA's own, not port damage.**out from under it and spreads as it climbs, and pales with the same height, the way the sky fillsa shadow back in. The game drew every shadow as one hard silhouette before this, whether it cameoff a tank's hull or off something twenty metres up, and edges that sharp are the tell that a- picture was computed rather than photographed. `-shadowmap` turns it on; without it the old- shadows are what you get, and a machine that cannot run the newer picture keeps them.+ picture was computed rather than photographed. This is what the game draws with now; a machine+ that cannot run the newer picture keeps the old shadows on its own, and `-noshadowmap` puts them+ back on any machine.+- A building stands on the ground instead of sitting on top of it. There is a soft patch under every+ structure's footprint, the darkening a corner traps in daylight, and the shadow it casts starts at+ its own wall rather than a step away from it. The frame's corners and creases get the same+ treatment through the finishing passes.- Infantry shadows are built from the pose: arms, head, weapon, moving with him.- `UseShadowVolumesForSkins = No` puts the old flat blobs back.- Scuds, rockets and falling bombs cast a shadow running along the ground.diff --git a/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cppindex bd0a33522..f73e6687c 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp@@ -930,13 +930,29 @@ Int parseShadowMap(char *args[], int num)if (TheWritableGlobalData){// The map replaces the volumes rather than joining them: a caster that cast both would cast- // twice, once hard and once soft, and the hard one would win every argument.+ // twice, once hard and once soft, and the hard one would win every argument. On by default+ // since the shadows settled, so this switch only puts back what a -noshadowmap took off.TheWritableGlobalData->m_shadowMap = TRUE;TheWritableGlobalData->m_shadowMapOnly = TRUE;}return 1;}+/* -noshadowmap: the stencil volumes back, the way the game drew shadows before the map.++ It is what a comparison is made against, and it is what somebody types if the new shadows are+ wrong on their machine. A machine with no Direct3D 11 device needs nothing: it fills no map+ and keeps the volumes on its own. */+Int parseNoShadowMap(char *args[], int num)+{+ if (TheWritableGlobalData)+ {+ TheWritableGlobalData->m_shadowMap = FALSE;+ TheWritableGlobalData->m_shadowMapOnly = FALSE;+ }+ return 1;+}+/* -shadowtune <penumbra> <skyfill> <strength> <widest>: the four numbers that decide what a shadowfrom the map looks like, from the command line rather than from a rebuild.@@ -2275,6 +2291,7 @@ static CommandLineParam params[] ={ "-smoke", parseSmoke },{ "-particlecap", parseParticleCap },{ "-shadowmap", parseShadowMap },+ { "-noshadowmap", parseNoShadowMap },{ "-shadowmapreport", parseShadowMapReport },{ "-shadowmaponly", parseShadowMapOnly },{ "-shadowmapboth", parseShadowMapBoth },diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cppindex 215470947..53f01ec98 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp@@ -680,9 +680,9 @@ GlobalData::GlobalData()m_startAtMaxZoom = TRUE; //open a game framed as wide as the player could zoom by handm_shadowsForProps = TRUE; //likewise: scenery with no shadow of its own gets onem_shadowsForParticles = TRUE; //on by default: the shipped INI has no entry for it- m_shadowMap = FALSE; //the sun's depth pass is off until something reads it+ m_shadowMap = TRUE; //the sun's own shadows are what the game draws with now+ m_shadowMapOnly = TRUE; //and they replace the stencil volumes rather than joining themm_shadowMapReport = FALSE;- m_shadowMapOnly = FALSE;m_shadowMapPenumbra = 0.0f; //zero anywhere here means the built-in value standsm_shadowMapSkyFill = 0.0f;m_shadowMapStrength = 0.0f;diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cppindex bb83c37c1..0f6ff4d60 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp@@ -121,6 +121,10 @@ const Real cosAngleToCare = cos ((0.2 * PI) / 180.0); //1.5 degree difference#define SHADOW_MAP_PENUMBRA_PER_UNIT 0.04f#define SHADOW_MAP_SKY_FILL 0.12f+// Whether the sun's map took this frame. The volumes read it to know whether to stand down, and it+// is false on a machine with no Direct3D 11 device, which is what keeps that machine's shadows.+static Bool theShadowMapHoldsTheFrame = FALSE;+//#define SV_DEBUG//#define SV_DEBUG_BOUNDS@@ -3818,11 +3822,13 @@ DECLARE_PERF_TIMER(shadowVolumeSubmit)more than one view. SHADOW-MAP-PLAN.md phase 1. */void W3DVolumetricShadowManager::renderShadowMap( CameraClass &sceneCamera ){+ theShadowMapHoldsTheFrame = FALSE;+if (!TheGlobalData->m_shadowMap || m_shadowList == NULL || TheTacticalView == NULL)return;if (!Direct3D11_Begin_Shadow_Map( SHADOW_MAP_TEXELS ))- return;+ return; //no Direct3D 11 device, or it refused the surface: the volumes keep the frameCoord3D look;TheTacticalView->getPosition( &look );@@ -3916,6 +3922,10 @@ void W3DVolumetricShadowManager::renderShadowMap( CameraClass &sceneCamera )Direct3D11_Set_Shadow_Parameters( SHADOW_MAP_DEPTH_BIAS, strength, widest,SHADOW_MAP_NARROWEST_TEXELS, penumbra / worldPerTexel, unitsPerUnitOfDepth, skyFill );+ // Said last, and only on the way out: everything above can bail, and the volumes have to know+ // whether this frame's shadows are in the map or still theirs to draw.+ theShadowMapHoldsTheFrame = (casters > 0);+// The report costs a full stall of the pipeline, so it is one line a second rather than one a// frame: what it answers is whether the pass draws the world at all, and that does not change// thirty times a second.@@ -3938,10 +3948,11 @@ void W3DVolumetricShadowManager::renderShadows( Bool forceStencilFill )W3DVolumetricShadow *shadow;Int numRenderedShadows = 0;- /* -shadowmaponly leaves the casters registered, and so in the sun's map, while taking the- volumes' own darkening off the frame. Turning the volumes off in the options instead would- stop the casters being registered at all and leave the map with nothing in it. */- if (TheGlobalData->m_shadowMapOnly)+ /* The volumes stand down only where the sun's map has actually taken this frame. The casters+ stay registered either way, which is what keeps them in the map; what stops is the volumes'+ own darkening pass. A machine with no Direct3D 11 device fills no map and keeps the volumes,+ so nobody ends up with no shadows at all. */+ if (TheGlobalData->m_shadowMapOnly && theShadowMapHoldsTheFrame)return;AABoxClass bbox;