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(gameenginedevice): make the blob shadow actually reach the ground
Olcay Seygan407492653e4c
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 58a3339d8..208203fb1 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -237,13 +237,18 @@ sparks are too small and too short-lived to earn it, and fire and glows are stilshade. It is one soft patch per plume rather than a shadow for every puff, so a battlefield full ofsmoke costs no more than a battlefield with one fire.-Then the trees. If you had shadows set to the good kind rather than the cheap kind, the trees-dropped nothing at all, so a forest sat on clean ground next to buildings with long shadows behind-them. Trees are drawn in one batch to keep a forest cheap, which is why they have never had a-shadow with a shape - what they get is one soft pool under the trunk, and it is now drawn whichever-shadow setting you are on. Leaning that pool away from the sun was tried and put back: a round-smudge sitting a tree's width to one side does not read as that tree's shadow, it reads as a stain-on the ground.+Then the trees — and it turned out to be bigger than the trees. The game has two kinds of shadow:+the sculpted kind that has the shape of the thing casting it, and the soft dark pool that trees,+bushes, fences and scenery get. **The soft pool has never once been drawn in this build.** Not+faintly, not in the wrong place: the game was painting it onto the ground in a way that could not+darken a single pixel, so a forest sat on clean bright sand next to tanks with shadows underneath+them. The blob is now blended onto the ground the way its own artwork describes it — the same+picture, the same darkness EA chose, actually visible.++So every tree on the map has a shadow now. So does every palm, every bush and every piece of+scenery that only ever had the soft kind, whichever shadow setting you play on. Leaning that pool+away from the sun was tried and put back: a round smudge sitting a tree's width to one side does+not read as that tree's shadow, it reads as a stain on the ground.And the scenery nobody gave a shadow to at all: fences, walls of tyres, rubbish piles, lowshrubs, the props that dress a map. They stood on the terrain with nothing under them, which is@@ -341,6 +346,12 @@ has stood in front of a skirmish full of soldiers to judge how they look, or meain frames. If they turn out to be ugly or expensive, `UseShadowVolumesForSkins = No` turns them offand this entry gets rewritten.+**The missing tree shadows were found with screenshots, not with reasoning.** Three separate+explanations for them looked convincing on paper and were all wrong. What settled it was painting+the shadows bright red for one build and looking: red under some trees and not others said the+drawing worked and the colour did not. Every state the graphics card was actually using was then+read back out of it mid-frame rather than assumed from the source.+**Zoom toward the cursor has been fixed twice and eyeballed once.** The first fix measured a camerathat had not moved; the second found the camera being pushed in the wrong units. The second one isargued from the code rather than watched: the mouse wheel cannot be faked from outside the game —diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cppindex aebaa5166..09b297cf4 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp@@ -118,6 +118,11 @@ int nShadowDecalIndicesInBuf=0; //model vetices in vertex bufferint nShadowDecalStartBatchIndex=0;int nShadowDecalPolysInBatch=0;int nShadowDecalVertsInBatch=0;+//A SHADOW_DECAL is alpha blended onto the terrain (see flushDecals), so its vertex colour is the+//shadow itself - black at this alpha, faded by the texture's own alpha channel. 160 lands on the+//darkness the multiplicative blob was asking for: shadow.dds is 45% grey at its centre with an+//alpha of about 0.85 there, and 1 - 0.85*160/255 is the same 45%.+#define DECAL_SHADOW_ALPHA 160int SHADOW_DECAL_VERTEX_SIZE=32768;int SHADOW_DECAL_INDEX_SIZE=65536;@@ -703,7 +708,14 @@ void W3DProjectedShadowManager::flushDecals(W3DShadowTexture *texture, ShadowTypswitch (type){case SHADOW_DECAL:- DX8Wrapper::Set_Shader(ShaderClass::_PresetMultiplicativeShader);+ //The blob used to be multiplied onto the ground (dest * texture). That is right on+ //paper and lands on nothing here: with the correct blend, the correct texture and the+ //correct states - all read back off the device - a blob decal never changed a pixel,+ //so no tree, prop or unit blob shadow in this port was ever visible. Alpha blending+ //the same texture does show, so the blob is now drawn the way its own alpha channel+ //describes it: the shadow colour, faded by the texture (DECAL_SHADOW_ALPHA, set on the+ //decal's diffuse where it is created).+ DX8Wrapper::Set_Shader(ShaderClass::_PresetAlphaShader);break;case SHADOW_ALPHA_DECAL:DX8Wrapper::Set_Shader(ShaderClass::_PresetAlphaShader);@@ -1885,6 +1897,10 @@ W3DProjectedShadow* W3DProjectedShadowManager::addShadow(RenderObjClass *robj, Sshadow->m_flags = allowSunDirection;+ //Alpha blended, so the plain white a decal is born with would draw a white blob.+ if (shadowType == SHADOW_DECAL)+ shadow->m_diffuse = (Int)(DECAL_SHADOW_ALPHA << 24);+shadow->init();// add to our shadow list through the shadow next links, insert next to other shadows using same texture@@ -2020,6 +2036,10 @@ W3DProjectedShadow* W3DProjectedShadowManager::createDecalShadow(Shadow::ShadowTshadow->m_flags = 0;+ //Alpha blended, so the plain white a decal is born with would draw a white blob.+ if (shadowType == SHADOW_DECAL)+ shadow->m_diffuse = (Int)(DECAL_SHADOW_ALPHA << 24);+shadow->init();return shadow;