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.

feat(ww3d2): no soft particles under Classic graphics

Olcay Seyganeee89627c5af
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp
index 9d781bdfe..1d897486f 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp
@@ -831,6 +831,8 @@ static void sizeWindowToClient( Int mode, Int width, Int height )
// and share the back buffer's depth with it.
static void pushDirect3D11PostChain( void )
{
+ // Classic graphics is the game's own picture, which is what -d3d9 draws: hard edged sprites.
+ Direct3D11_Allow_Soft_Particles( !TheGlobalData->m_classicGraphics );
const AsciiString & requested = TheGlobalData->m_direct3D11PostChain;
if( !Direct3D11_Post_Chain( requested.str() ) && !requested.isEmpty() )
{
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.cpp
index 557fb9e53..bb5d36ad1 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.cpp
@@ -311,6 +311,7 @@ DX11BackendClass::DX11BackendClass()
memset(BlastLights, 0, sizeof(BlastLights));
BlastLightCount = 0;
SoftParticles = false;
+ SoftParticlesAllowed = true;
SceneDepthCopy = NULL;
SceneDepthCopyView = NULL;
SceneDepthStale = true;
@@ -952,7 +953,7 @@ void DX11BackendClass::Set_Soft_Particles(bool soft)
hard, because faded towards zero it would darken rather than vanish. */
unsigned DX11BackendClass::Soft_Particle() const
{
- if (!SoftParticles || SceneDepthCopyView == NULL || ShadowMapBound) {
+ if (!SoftParticles || !SoftParticlesAllowed || SceneDepthCopyView == NULL || ShadowMapBound) {
return SOFT_PARTICLE_NONE;
}
if (VertexProgram != ENGINE_SHADER_NONE || PixelProgram != ENGINE_SHADER_NONE
@@ -995,7 +996,7 @@ void DX11BackendClass::Release_Scene_Depth()
changes either, and refreshed only when a draw has written depth since the last one. */
void DX11BackendClass::Take_Scene_Depth()
{
- if (SceneDepthRefused || Device == NULL) {
+ if (SceneDepthRefused || !SoftParticlesAllowed || Device == NULL) {
return;
}
ID3D11ShaderResourceView * const source_view = Device->Get_Depth_Texture();
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.h
index 0a4c54ec4..00ef7edd0 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.h
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11backend.h
@@ -113,6 +113,14 @@ public:
void Take_Scene_Depth();
// How many depth copies Take_Scene_Depth made since the last call. Taking it resets it.
unsigned Take_Frame_Depth_Copies();
+ // Off under the Classic graphics setting, whose picture is -d3d9's: no draw fades, no copy.
+ void Allow_Soft_Particles(bool allowed)
+ {
+ if (SoftParticlesAllowed != allowed) {
+ SoftParticlesAllowed = allowed;
+ PipelineChanged = true;
+ }
+ }
// The engine bound a texture at this stage that has no D3D11 copy - a render target it drew
// into, most often. Sampling white there paints a full screen quad over the frame, so a draw
@@ -495,6 +503,7 @@ private:
unsigned BlastLightCount;
// Set_Soft_Particles, and which fade the current draw takes (a SOFT_PARTICLE_* value).
bool SoftParticles;
+ bool SoftParticlesAllowed;
unsigned Soft_Particle() const;
// The scene's depth as a texture, copied when a soft particle first needs it after anything
// wrote depth: a depth buffer cannot be sampled while it is the one being tested against.
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime.cpp
index 9478af414..4a1c0a780 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime.cpp
@@ -289,6 +289,11 @@ void Direct3D11_Take_Scene_Depth()
}
}
+void Direct3D11_Allow_Soft_Particles(bool allowed)
+{
+ Backend.Allow_Soft_Particles(allowed);
+}
+
bool Direct3D11_Begin_Shadow_Map(unsigned size)
{
return Active ? Backend.Begin_Shadow_Map(size) : false;
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime.h
index 3afaf0323..c5ff6a5af 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime.h
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime.h
@@ -133,6 +133,10 @@ void Direct3D11_Set_Soft_Particles(bool soft);
// sorting pool calls it at the top of each flush, before any particle run resolves its program.
void Direct3D11_Take_Scene_Depth();
+// Whether the soft particles run at all. Off under the Classic graphics setting, so its picture
+// matches -d3d9's. On by default.
+void Direct3D11_Allow_Soft_Particles(bool allowed);
+
// The sun's depth buffer. Between Begin and End every draw lands in it and nowhere else, which is
// how the caster pass is written without the engine knowing what a render target is. False from
// Begin means there is no Direct3D 11 backend or the device refused the surface, and the caller
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime_posix.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime_posix.cpp
index d8776fd6e..6189974c7 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime_posix.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx11runtime_posix.cpp
@@ -64,6 +64,7 @@ void Direct3D11_Set_Blast_Lights(const float *, unsigned) {}
bool Direct3D11_Lights_Per_Pixel() { return false; }
void Direct3D11_Set_Soft_Particles(bool) {}
void Direct3D11_Take_Scene_Depth() {}
+void Direct3D11_Allow_Soft_Particles(bool) {}
bool Direct3D11_Begin_Shadow_Map(unsigned) { return false; }
void Direct3D11_End_Shadow_Map() {}