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.

revert(gameenginedevice): take the tree shadow back to the blob

Olcay Seygan785d1853ef64
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5f598fa99..2fd5bede8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -245,23 +245,17 @@ darken a single pixel, so a forest sat on clean bright sand next to tanks with s
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 — and not just a pool. A tree was the last thing out
-there whose shadow was a circle while everything else threw its own shape. It threw a circle for
-three reasons, all of them the game's own: the trees ask for the cheap kind by name; the shadow
-builder refuses any part of a model marked see-through, and a tree's *trunk* is marked see-through
-along with its leaves, so the whole tree was refused; and leaves are flat sheets, which cannot cast
-a solid shadow no matter what you do with them.
-
-Trees are now handled the way the soldiers were: they get a real shadow built from the model, and
-the see-through rule is only lifted when it would otherwise leave the tree with nothing at all — a
-helicopter's rotor still does not throw a solid disc. What comes out is the trunk, stretched across
-the ground in the sun's direction, with the soft pool kept underneath for the crown the leaves
-cannot cast. Palms on a beach now lie their trunks across the sand.
-
-Every tree, too, not most of them: 27 of the game's 128 tree types never said whether they should
-cast at all, and silently got nothing. They cast now. So do the bushes, the palms and the scenery.
-`ShadowsForProps = No` in `GameData.ini` puts every bit of this back the way it was if a map full
-of trees costs you frames.
+So every tree on the map has a shadow now — every one of them, not most: 27 of the game's 128 tree
+types never said whether they should cast at all and silently got nothing. They cast now, and so do
+the bushes and the palms.
+
+It is the soft pool rather than the tree's own outline, and that is where it stays. Giving trees a
+sculpted shadow like the tanks have was tried and put back: the models are flat sheets of leaves,
+and the sculpted kind needs something solid to work from. A palm managed to throw its trunk and
+nothing else; a leafy tree threw nothing; and forcing the leaves through laid the tree's shadow
+across its own branches. The pool under the tree is the honest answer for foliage, and it is the
+one EA drew the artwork for.
+
And the scenery nobody gave a shadow to at all: fences, walls of tyres, rubbish piles, low
shrubs, the props that dress a map. They stood on the terrain with nothing under them, which is
the one thing the eye picks out instantly. Anything that cannot move and had no shadow now casts
@@ -342,7 +336,8 @@ question. The aircraft attack-move fix came from a log line, not an argument.
looked past the edge of the maps and went back. Four separate pathfinding experiments were tried in
game, made things worse, and were reverted. A three-panel command bar that fixed the widescreen
stretch was tried and reverted too — the game's own bar is the one people want to see. Tree shadows
-that leaned away from the sun went the same way, on the evidence of before-and-after screenshots.
+that leaned away from the sun went the same way, on the evidence of before-and-after screenshots,
+and so did sculpted shadows for trees - the leaves ended up shadowing their own branches.
All of it is
recorded so nobody re-tries it in two years.
diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/Module/W3DModelDraw.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/Module/W3DModelDraw.h
index 2e336b7fc..0c24a7b26 100644
--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/Module/W3DModelDraw.h
+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/Module/W3DModelDraw.h
@@ -501,7 +501,6 @@ private:
Bool m_shadowEnabled; ///< cached state of shadow. Used to determine if shadows should be enabled via options screen.
RenderObjClass* m_renderObject; ///< W3D Render object for this drawable
Shadow* m_shadow; ///< Updates/Renders shadows of this object
- Shadow* m_shadowBlob; ///< a foliage prop's soft pool - its leaves are open planes and cast no volume
Shadow* m_terrainDecal;
TerrainTracksRenderObjClass* m_trackRenderObject; ///< This is rendered under object
ParticleSystemIDVec m_particleSystemIDs; ///< The ID numbers of the particle systems currently running.
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp
index 9b9c8d163..1fa8e1705 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp
@@ -1728,7 +1728,6 @@ W3DModelDraw::W3DModelDraw(Thing *thing, const ModuleData* moduleData) : DrawMod
m_hexColor = 0;
m_renderObject = NULL;
m_shadow = NULL;
- m_shadowBlob = NULL;
m_shadowEnabled = TRUE;
m_terrainDecal = NULL;
m_trackRenderObject = NULL;
@@ -1829,8 +1828,6 @@ void W3DModelDraw::setHidden(Bool hidden)
if (m_shadow)
m_shadow->enableShadowRender(!hidden);
- if (m_shadowBlob)
- m_shadowBlob->enableShadowRender(!hidden);
m_shadowEnabled = hidden;
@@ -1851,9 +1848,6 @@ void W3DModelDraw::releaseShadows(void) ///< frees all shadow resources used by
if (m_shadow)
m_shadow->release();
m_shadow = NULL;
- if (m_shadowBlob)
- m_shadowBlob->release();
- m_shadowBlob = NULL;
}
/** Does this model contain any skinned (bone-deformed) geometry? Infantry and other animated
@@ -1903,24 +1897,6 @@ never a volume; a zero decal size makes addShadow take the size from the model's
Returns FALSE when this drawable gets no shadow at all. */
static Bool fillShadowInfoFromTemplate(const ThingTemplate *tmplate, Shadow::ShadowTypeInfo *shadowInfo, Bool allowPropVolume = TRUE)
{
- //A prop the art gave a blob - a palm, a bush, a rock - cast a round pool instead of its own
- //shape. It never moves, so a volume is built once and then costs nothing to keep. Same
- //allowPropVolume retry as below: a model with no usable shadow geometry drops back to the blob.
- if (tmplate->getShadowType() == SHADOW_DECAL && allowPropVolume &&
- TheGlobalData->m_shadowsForProps && TheGlobalData->m_useShadowVolumes &&
- tmplate->isKindOf(KINDOF_IMMOBILE) && !tmplate->isKindOf(KINDOF_PROJECTILE))
- {
- shadowInfo->m_ShadowName[0] = 0;
- shadowInfo->allowUpdates = FALSE;
- shadowInfo->allowWorldAlign = TRUE;
- shadowInfo->m_type = SHADOW_VOLUME;
- shadowInfo->m_sizeX = 0.0f;
- shadowInfo->m_sizeY = 0.0f;
- shadowInfo->m_offsetX = 0.0f;
- shadowInfo->m_offsetY = 0.0f;
- return TRUE;
- }
-
if (tmplate->getShadowType() == SHADOW_NONE)
{
//a prop the art gave no shadow at all - a fence, a rubbish pile, a shrub - gets a real volume
@@ -1982,7 +1958,7 @@ void W3DModelDraw::allocateShadows(void)
Bool promotedToVolume = tmplate->getShadowType() != SHADOW_NONE &&
promoteSkinShadowToVolume(m_renderObject, &shadowInfo);
//a prop we handed a volume the template never asked for falls back the same way
- if (tmplate->getShadowType() != SHADOW_VOLUME && shadowInfo.m_type == SHADOW_VOLUME)
+ if (tmplate->getShadowType() == SHADOW_NONE && shadowInfo.m_type == SHADOW_VOLUME)
promotedToVolume = TRUE;
m_shadow = TheW3DShadowManager->addShadow(m_renderObject, &shadowInfo);
@@ -1993,17 +1969,6 @@ void W3DModelDraw::allocateShadows(void)
m_shadow = TheW3DShadowManager->addShadow(m_renderObject, &shadowInfo);
}
-
- //A tree's leaves are open planes: they contribute nothing to a stencil volume, so what the
- //volume gives is the trunk alone. Keep the blob under the crown as well - together they are
- //a trunk laid across the ground and a pool of shade under the branches.
- if (m_shadowBlob == NULL && m_shadow && shadowInfo.m_type == SHADOW_VOLUME &&
- tmplate->getShadowType() == SHADOW_DECAL)
- {
- Shadow::ShadowTypeInfo blobInfo;
- if (fillShadowInfoFromTemplate(tmplate, &blobInfo, FALSE))
- m_shadowBlob = TheW3DShadowManager->addShadow(m_renderObject, &blobInfo);
- }
if (m_shadow)
{ m_shadow->enableShadowInvisible(m_fullyObscuredByShroud);
if (m_renderObject->Is_Hidden() || !m_shadowEnabled)
@@ -2017,8 +1982,6 @@ void W3DModelDraw::setShadowsEnabled(Bool enable)
{
if (m_shadow)
m_shadow->enableShadowRender(enable);
- if (m_shadowBlob)
- m_shadowBlob->enableShadowRender(enable);
m_shadowEnabled = enable;
}
@@ -2082,8 +2045,6 @@ void W3DModelDraw::setFullyObscuredByShroud(Bool fullyObscured)
if (m_shadow)
m_shadow->enableShadowInvisible(m_fullyObscuredByShroud);
- if (m_shadowBlob)
- m_shadowBlob->enableShadowInvisible(m_fullyObscuredByShroud);
if (m_terrainDecal)
m_terrainDecal->enableShadowInvisible(m_fullyObscuredByShroud);
@@ -2933,9 +2894,6 @@ void W3DModelDraw::nukeCurrentRender(Matrix3D* xform)
if (m_shadow)
m_shadow->release();
m_shadow = NULL;
- if (m_shadowBlob)
- m_shadowBlob->release();
- m_shadowBlob = NULL;
if(m_terrainDecal)
m_terrainDecal->release();
@@ -3214,7 +3172,7 @@ void W3DModelDraw::setModelState(const ModelConditionInfo* newState)
Bool promotedToVolume = tmplate->getShadowType() != SHADOW_NONE &&
promoteSkinShadowToVolume(m_renderObject, &shadowInfo);
//a prop we handed a volume the template never asked for falls back the same way
- if (tmplate->getShadowType() != SHADOW_VOLUME && shadowInfo.m_type == SHADOW_VOLUME)
+ if (tmplate->getShadowType() == SHADOW_NONE && shadowInfo.m_type == SHADOW_VOLUME)
promotedToVolume = TRUE;
m_shadow = TheW3DShadowManager->addShadow(m_renderObject, &shadowInfo, draw);
@@ -3225,17 +3183,6 @@ void W3DModelDraw::setModelState(const ModelConditionInfo* newState)
m_shadow = TheW3DShadowManager->addShadow(m_renderObject, &shadowInfo, draw);
}
-
- //A tree's leaves are open planes: they contribute nothing to a stencil volume, so what the
- //volume gives is the trunk alone. Keep the blob under the crown as well - together they are
- //a trunk laid across the ground and a pool of shade under the branches.
- if (m_shadowBlob == NULL && m_shadow && shadowInfo.m_type == SHADOW_VOLUME &&
- tmplate->getShadowType() == SHADOW_DECAL)
- {
- Shadow::ShadowTypeInfo blobInfo;
- if (fillShadowInfoFromTemplate(tmplate, &blobInfo, FALSE))
- m_shadowBlob = TheW3DShadowManager->addShadow(m_renderObject, &blobInfo, draw);
- }
if (m_shadow)
{ m_shadow->enableShadowInvisible(m_fullyObscuredByShroud);
m_shadow->enableShadowRender(m_shadowEnabled);
@@ -3304,8 +3251,6 @@ void W3DModelDraw::setModelState(const ModelConditionInfo* newState)
m_renderObject->Set_Hidden(TRUE);
if (m_shadow)
m_shadow->enableShadowRender(FALSE);
- if (m_shadowBlob)
- m_shadowBlob->enableShadowRender(FALSE);
m_shadowEnabled = FALSE;
}
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp
index 3d1fa8010..a45a777d5 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp
@@ -655,16 +655,6 @@ Int W3DShadowGeometry::initFromHLOD(RenderObjClass *robj)
m_numTotalsVerts=0;
- //Two passes. The first is EA's: a transparent mesh is not a shadow caster, because its
- //silhouette is the quad it is painted on rather than the thing painted on it - a rotor disc
- //would throw a solid disc. The second pass runs only when that left the model with nothing
- //at all, which is every tree and bush in the game: their trunk is flagged transparent along
- //with their leaves, so the choice there is not 'a good shadow or a bad one' but 'the model's
- //own shadow or none'. Open leaf planes still contribute nothing to a stencil volume, so what
- //comes out is the solid part - the trunk.
- for (Int pass = 0; pass < 2 && m_meshCount == 0; pass++)
- {
- const Bool allowTransparent = (pass == 1);
for (i = 0; i < hlod->Get_Lod_Model_Count(top); i++)
{
if (hlod->Peek_Lod_Model(top,i) && hlod->Peek_Lod_Model(top,i)->Class_ID() == RenderObjClass::CLASSID_MESH)
@@ -677,7 +667,7 @@ Int W3DShadowGeometry::initFromHLOD(RenderObjClass *robj)
// if (!geomMesh->m_mesh->Peek_Model()->Get_Flag(MeshGeometryClass::CAST_SHADOW))
// continue; // CNC3 (gth) Only cast shadows from meshes with the shadow flag ENABLED!
- if (!allowTransparent && (geomMesh->m_mesh->Is_Alpha() || geomMesh->m_mesh->Is_Translucent()) && !geomMesh->m_mesh->Peek_Model()->Get_Flag(MeshGeometryClass::CAST_SHADOW))
+ if ((geomMesh->m_mesh->Is_Alpha() || geomMesh->m_mesh->Is_Translucent()) && !geomMesh->m_mesh->Peek_Model()->Get_Flag(MeshGeometryClass::CAST_SHADOW))
continue; //transparent meshes that don't have forced shadows will not cast volumetric shadows
// CNC3 (gth) skin meshes should never cast a volumetric shadow
if (geomMesh->m_mesh->Peek_Model()->Get_Flag(MeshGeometryClass::SKIN))
@@ -885,7 +875,6 @@ Int W3DShadowGeometry::initFromHLOD(RenderObjClass *robj)
m_meshCount++;
}
}
- }
// for (i = 0; i < AdditionalModels.Count(); i++) {
// res |= AdditionalModels[i].Model->Cast_Ray(raytest);
@@ -907,9 +896,8 @@ Int W3DShadowGeometry::initFromMesh(RenderObjClass *robj)
geomMesh->m_mesh = (MeshClass *)robj;
geomMesh->m_meshRobjIndex = -1; //robj is the mesh so no index needed.
- //A lone transparent mesh is the whole model, so refusing it is refusing the object any shadow
- //at all - see the two passes in initFromHLOD. It is taken, and its open planes simply do not
- //contribute to the volume.
+ if (((geomMesh->m_mesh->Is_Alpha() || geomMesh->m_mesh->Is_Translucent()) && !geomMesh->m_mesh->Peek_Model()->Get_Flag(MeshGeometryClass::CAST_SHADOW)))
+ return FALSE; //transparent meshes that don't have forced shadows will not cast volumetric shadows
MeshModelClass *mm = geomMesh->m_mesh->Peek_Model();
geomMesh->m_numVerts=mm->Get_Vertex_Count();