Skip to content

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.

fix(gameenginedevice): multiply blob shadows again, no square under mods

Olcay Seygana5e97e26bd1a
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 63fd24bc0..655d25a76 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -32,6 +32,7 @@ found and fixed — EA's own, not port damage.**
- Contra and The Power of the West start and play now, The Power of the West beside ShockWave too; every one of those used to crash while loading. Contra's China base fell over the carpet bombers it never had, and one misspelt armour line in The Power of the West stopped the game where Zero Hour itself had shrugged it off. A mod's patch archive named to sort first, like Contra's `!!` one, wins over the rest of the mod again, as it always did in Zero Hour.
- No empty slots in a mod general's power tray. Mods give unrelated powers the same few types, Contra's small Scud Storm counting as a carpet bomb, so a Contra Cybernetic player's tray picked up another faction's button for a power he only held one of the same type as, then hid it, and an empty frame stood where it had been. The tray offers a button now only for the very power you hold, and a slot whose button goes away takes its frame with it.
- Contra's units have their attack move, guard and stop buttons again, and A, G and S press them. Contra draws its command bar with eighteen buttons and keeps those three in the last row, which our fourteen-button bar does not have, so they went missing on every Contra unit, the Cybernetic general's cyborgs among them. A button a mod puts past the end of our bar now moves to an empty one, the three orders to the places Zero Hour gives them.
+- Contra's cyborgs no longer stand on black squares. Their little ground shadow is drawn the way Zero Hour draws it again, darkening the ground by the shape painted in the picture, so it comes out as a soft patch under the feet. We had been reading the shape from the picture's transparency instead, and Contra's shadow picture has none: it filled its whole square. Zero Hour's own shadows look as they did.
## One interface
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp
index 637bb16aa..c9bfaeef4 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp
@@ -128,11 +128,6 @@ int nShadowDecalIndicesInBuf=0; //model vetices in vertex buffer
int 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 160
//queueDecal lays the long axis of anything this high above the ground down the sun ray, and lets it
//grow to at most this many times the decal's own length doing it.
#define DECAL_AIRBORNE_HEIGHT 1.0f
@@ -781,14 +776,11 @@ void W3DProjectedShadowManager::flushDecals(W3DShadowTexture *texture, ShadowTyp
switch (type)
{
case SHADOW_DECAL:
- //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);
+ //Multiplied onto the ground (dest * texture), as EA drew it: the blob's shape is in its
+ //colour, white where the ground is left alone. A mod's blob need not fade its alpha at
+ //all - Contra's shadowih.dds is opaque edge to edge - so alpha blending it laid a dark
+ //square under every unit that named it.
+ DX8Wrapper::Set_Shader(ShaderClass::_PresetMultiplicativeShader);
break;
case SHADOW_ALPHA_DECAL:
DX8Wrapper::Set_Shader(ShaderClass::_PresetAlphaShader);
@@ -2128,10 +2120,6 @@ W3DProjectedShadow* W3DProjectedShadowManager::addShadow(RenderObjClass *robj, S
shadow->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
@@ -2270,10 +2258,6 @@ W3DProjectedShadow* W3DProjectedShadowManager::createDecalShadow(Shadow::ShadowT
shadow->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;
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.cpp
index af3b66c7c..7ad4f0198 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.cpp
@@ -2051,7 +2051,8 @@ bool DX11BackendClass::Shadow_Receiving() const
const DWORD source = RenderStates.Get_Render_State(D3DRS_SRCBLEND);
const DWORD destination = RenderStates.Get_Render_State(D3DRS_DESTBLEND);
if (destination == D3DBLEND_ONE || source == D3DBLEND_ONE
- || destination == D3DBLEND_DESTCOLOR || source == D3DBLEND_DESTCOLOR) {
+ || destination == D3DBLEND_DESTCOLOR || source == D3DBLEND_DESTCOLOR
+ || destination == D3DBLEND_SRCCOLOR) {
return false; // additive and multiplicative passes: fire, glow, the shadows themselves
}
if (destination == D3DBLEND_INVSRCCOLOR) {