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(gameengine): set the shadow map softness from the command line
Olcay Seygan00573abf82c4
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.hindex 5649fbb7a..76a16d0bc 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h@@ -178,6 +178,10 @@ public:Bool m_shadowMap; // "-shadowmap": draw the casters into the sun's depth buffer as wellBool m_shadowMapReport; // "-shadowmapreport": log what ended up in that buffer, once a secondBool m_shadowMapOnly; // "-shadowmaponly": the map's shadows with the stencil volumes' own darkening off+ Real m_shadowMapPenumbra; // "-shadowtune": penumbra per world unit of gap under the caster, 0 for the built-in+ Real m_shadowMapSkyFill; // how much of a wide shadow the sky fills back in+ Real m_shadowMapStrength; // how dark a fully blocked pixel goes+ Real m_shadowMapWidest; // how far the filter may open, in texelsBool m_particleGroundBounce; // "-particlebounce": terrain collision on for every particle systemReal m_smokeThickness; // "-smoke": how much longer and thicker every smoke system runs, 0 for shipped behaviourInt m_particleCapOverride; // "-particlecap": stand in for the options slider's MaxParticleCount, 0 to use itdiff --git a/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cppindex 95920f851..bd0a33522 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp@@ -937,6 +937,26 @@ Int parseShadowMap(char *args[], int num)return 1;}+/* -shadowtune <penumbra> <skyfill> <strength> <widest>: the four numbers that decide what a shadow+ from the map looks like, from the command line rather than from a rebuild.++ They are a judgement and not a measurement, so they are settled by looking at the same frame at+ several settings, and a rebuild between every picture makes that an afternoon rather than a+ pass. A zero in any position leaves that one at the value the build carries. */+Int parseShadowTune(char *args[], int num)+{+ if (TheWritableGlobalData == NULL || num < 5)+ return 1;++ TheWritableGlobalData->m_shadowMap = TRUE;+ TheWritableGlobalData->m_shadowMapOnly = TRUE;+ TheWritableGlobalData->m_shadowMapPenumbra = (Real)atof( args[ 1 ] );+ TheWritableGlobalData->m_shadowMapSkyFill = (Real)atof( args[ 2 ] );+ TheWritableGlobalData->m_shadowMapStrength = (Real)atof( args[ 3 ] );+ TheWritableGlobalData->m_shadowMapWidest = (Real)atof( args[ 4 ] );+ return 5;+}+/* -shadowmapboth: the map and the stencil volumes at once, which is not a picture anybody shouldplay with. It exists because the two can only be compared in one frame when both are in it. */Int parseShadowMapBoth(char *args[], int num)@@ -2258,6 +2278,7 @@ static CommandLineParam params[] ={ "-shadowmapreport", parseShadowMapReport },{ "-shadowmaponly", parseShadowMapOnly },{ "-shadowmapboth", parseShadowMapBoth },+ { "-shadowtune", parseShadowTune },{ "-noparticleshadows", parseNoParticleShadows },{ "-quickstart", parseQuickStart },diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cppindex b0ba1623c..de14fe9f6 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp@@ -682,6 +682,10 @@ GlobalData::GlobalData()m_shadowMap = FALSE; //the sun's depth pass is off until something reads itm_shadowMapReport = FALSE;m_shadowMapOnly = FALSE;+ m_shadowMapPenumbra = 0.0f; //zero anywhere here means the built-in value stands+ m_shadowMapSkyFill = 0.0f;+ m_shadowMapStrength = 0.0f;+ m_shadowMapWidest = 0.0f;m_textureReductionFactor = -1;m_enableBehindBuildingMarkers = TRUE;m_scriptDebug = FALSE;diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cppindex 8a794f00f..8f1c65c41 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp@@ -3901,12 +3901,20 @@ void W3DVolumetricShadowManager::renderShadowMap( CameraClass &sceneCamera )many world units across, and a unit of depth is the whole of the near to far range, becausean orthographic projection puts depth on a straight line. */const Real worldPerTexel = (2.0f * SHADOW_MAP_HALF_WIDTH) / (Real)SHADOW_MAP_TEXELS;- const Real texelsPerUnitOfGap = SHADOW_MAP_PENUMBRA_PER_UNIT / worldPerTexel;const Real unitsPerUnitOfDepth = SHADOW_MAP_FAR_CLIP - SHADOW_MAP_NEAR_CLIP;- Direct3D11_Set_Shadow_Parameters( SHADOW_MAP_DEPTH_BIAS, SHADOW_MAP_STRENGTH,- SHADOW_MAP_WIDEST_TEXELS, SHADOW_MAP_NARROWEST_TEXELS, texelsPerUnitOfGap,- unitsPerUnitOfDepth, SHADOW_MAP_SKY_FILL );+ // -shadowtune overrules any of the four that it was given; a zero leaves the build's own.+ const Real penumbra = (TheGlobalData->m_shadowMapPenumbra > 0.0f)+ ? TheGlobalData->m_shadowMapPenumbra : SHADOW_MAP_PENUMBRA_PER_UNIT;+ const Real skyFill = (TheGlobalData->m_shadowMapSkyFill > 0.0f)+ ? TheGlobalData->m_shadowMapSkyFill : SHADOW_MAP_SKY_FILL;+ const Real strength = (TheGlobalData->m_shadowMapStrength > 0.0f)+ ? TheGlobalData->m_shadowMapStrength : SHADOW_MAP_STRENGTH;+ const Real widest = (TheGlobalData->m_shadowMapWidest > 0.0f)+ ? TheGlobalData->m_shadowMapWidest : SHADOW_MAP_WIDEST_TEXELS;++ Direct3D11_Set_Shadow_Parameters( SHADOW_MAP_DEPTH_BIAS, strength, widest,+ SHADOW_MAP_NARROWEST_TEXELS, penumbra / worldPerTexel, unitsPerUnitOfDepth, skyFill );// 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