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(w3ddevice): stop a building going black as the camera pulls back
Olcay Seygan464ff82d70b5
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cppindex 3a8086858..083f75360 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp@@ -72,6 +72,7 @@#include "GameLogic/ScriptEngine.h"#include "GameLogic/Weapon.h"+#include "GameClient/CinemaDirector.h"#include "GameClient/Anim2D.h"#include "GameClient/Display.h"#include "GameClient/DisplayStringManager.h"@@ -2952,6 +2953,13 @@ Bool Drawable::drawsAnyUIText( void )// ------------------------------------------------------------------------------------------------void Drawable::drawIconUI( void ){+ /* -cinema takes the interface off, and these are interface: the health bar, the rank chevrons a+ promotion puts up, the healing cross, the ammo pips, the capture clock and the captions. The+ gate is here rather than on TheGameLogic's own m_drawIconUI because that one is logic state,+ saved with the game and carried in the network snapshot; footage must not touch it. */+ if( CinemaDirector_hidesHud() )+ return;+if( TheGameLogic->getDrawIconUI() && (TheScriptEngine->getFade()==ScriptEngine::FADE_NONE) ){IRegion2D healthBarRegionStorage;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/RadiusDecal.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/RadiusDecal.cppindex 3b848a0c1..499d124b2 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/RadiusDecal.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/RadiusDecal.cpp@@ -32,6 +32,7 @@#include "Common/Player.h"#include "Common/PlayerList.h"#include "Common/Xfer.h"+#include "GameClient/CinemaDirector.h"#include "GameClient/PlayerColorScheme.h"#include "GameClient/RadiusDecal.h"#include "GameClient/Shadow.h"@@ -202,13 +203,13 @@ void RadiusDecal::update()Real theta = (2*PI) * (Real)(now % m_template->m_opacityThrobTime) / (Real)m_template->m_opacityThrobTime;Real percent = 0.5f * (Sin(theta) + 1.0f);Int opac;- if( TheGameLogic->getDrawIconUI() )+ if( TheGameLogic->getDrawIconUI() && !CinemaDirector_hidesHud() ){opac = REAL_TO_INT((m_template->m_minOpacity + percent * (m_template->m_maxOpacity - m_template->m_minOpacity)) * 255.0f);}else{- //Scripts turned this off, so don't show them!+ //Scripts turned this off, or -cinema did, so don't show them!opac = 0;}m_decal->setOpacity(opac);diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/engineshader.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/engineshader.cppindex 203fd7c70..7dfec0c1c 100644--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/engineshader.cpp+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/engineshader.cpp@@ -407,7 +407,7 @@ static void write_multiply_chain(std::string & hlsl, const EngineShaderEntry & e}// The ground is where a shadow is read, so every transcribed program that paints it takes one.- hlsl += " current.rgb *= sun_reaching(input.Position);\n";+ hlsl += SHADOW_APPLY;if (!bumped) {return;diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.cppindex b98036877..d2a49d607 100644--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.cpp+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.cpp@@ -445,7 +445,7 @@ bool CombinerShader_Generate(const CombinerDescription & description, CombinerSh// Before the fog: a shadow is a thing in the world and the fog is between the world and the eye.if (description.ShadowReceiving) {- hlsl += " current.rgb *= sun_reaching(input.Position);\n";+ hlsl += SHADOW_APPLY;}if (target == COMBINER_SHADER_TARGET_D3D11diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.hindex 44291937d..c9629a264 100644--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.h+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.h@@ -123,7 +123,12 @@ const unsigned NORMAL_MAPPED_LIGHTS = 4;" if (map.x < 0.0 || map.x > 1.0 || map.y < 0.0 || map.y > 1.0) return 1.0;\n" \" if (sun.z < 0.0 || sun.z > 1.0) return 1.0;\n" \" float texel = ShadowParameters.x;\n" \- " float bias = ShadowParameters.y;\n" \+ " // The bias grows with how fast the depth changes across one pixel. A fixed one covers a\n" \+ " // surface seen from close up and nothing else: pull the camera back and a pixel spans\n" \+ " // several world units, the depth across it steps past the bias, and the wall reads as\n" \+ " // blocked by itself - a building that goes black as the camera leaves it.\n" \+ " float slope = max(abs(ddx(sun.z)), abs(ddy(sun.z)));\n" \+ " float bias = ShadowParameters.y + slope * 4.0;\n" \" float widest = ShadowParameters.w;\n" \" float narrowest = ShadowSoftness.x;\n" \"\n" \@@ -174,6 +179,15 @@ const unsigned NORMAL_MAPPED_LIGHTS = 4;"}\n" \"\n"+// Putting the shadow on the pixel, which is not a plain multiply. A pixel that is already dark is+// dark for a reason - it is under the shroud, or it is the fogged snapshot of a building somebody+// cannot see - and multiplying that again takes it to black: from a camera far enough out, a+// building in the fog turned into a black slab. The shadow therefore only reaches a pixel as far+// as the pixel is lit, which leaves the sunlit ground exactly as it was.+#define SHADOW_APPLY \+ " float shadow_lit = saturate(dot(current.rgb, float3(0.3333, 0.3333, 0.3333)) * 2.5);\n" \+ " current.rgb *= lerp(1.0, sun_reaching(input.Position), shadow_lit);\n"+// The HLSL for one description, or false when the description names an operation or an argument// this does not generate. A refusal is not a failure: the caller keeps the fixed-function path for// that draw, which is the only reason an unmeasured operation is safe to meet at run time.