From ca226f247ddf6af324ca9be38c583df480ad5689 Mon Sep 17 00:00:00 2001 From: Jacob Ledbetter Date: Tue, 1 Sep 2026 13:48:32 -0600 Subject: [PATCH 1/6] bugfix(ww3d2): Initialize mesh material colors safely --- .../Source/WWVegas/WW3D2/meshmatdesc.cpp | 16 +++++++++++++--- .../Source/WWVegas/WW3D2/meshmatdesc.cpp | 16 +++++++++++++--- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp index 27e556bae5f..44f40f697c8 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp @@ -693,9 +693,9 @@ void MeshMatDescClass::Post_Load_Process(bool lighting_enabled,MeshModelClass * bool emissive_used=false; bool opacity_used=false; - Vector3 mtl_diffuse; - Vector3 mtl_ambient; - Vector3 mtl_emissive; + Vector3 mtl_diffuse(0.0f,0.0f,0.0f); + Vector3 mtl_ambient(0.0f,0.0f,0.0f); + Vector3 mtl_emissive(0.0f,0.0f,0.0f); float mtl_opacity = 1.0f; VertexMaterialClass * prev_mtl = nullptr; @@ -714,6 +714,11 @@ void MeshMatDescClass::Post_Load_Process(bool lighting_enabled,MeshModelClass * for (int vidx=0; vidxGet_Diffuse(&mtl_diffuse); @@ -770,6 +775,11 @@ void MeshMatDescClass::Post_Load_Process(bool lighting_enabled,MeshModelClass * for (int vidx=0; vidxGet_Diffuse(&mtl_diffuse); diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp index 982afc7549e..b2eddd6290b 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp @@ -695,9 +695,9 @@ void MeshMatDescClass::Post_Load_Process(bool lighting_enabled,MeshModelClass * bool emissive_used=false; bool opacity_used=false; - Vector3 mtl_diffuse; - Vector3 mtl_ambient; - Vector3 mtl_emissive; + Vector3 mtl_diffuse(0.0f,0.0f,0.0f); + Vector3 mtl_ambient(0.0f,0.0f,0.0f); + Vector3 mtl_emissive(0.0f,0.0f,0.0f); float mtl_opacity = 1.0f; VertexMaterialClass * prev_mtl = nullptr; @@ -716,6 +716,11 @@ void MeshMatDescClass::Post_Load_Process(bool lighting_enabled,MeshModelClass * for (int vidx=0; vidxGet_Diffuse(&mtl_diffuse); @@ -772,6 +777,11 @@ void MeshMatDescClass::Post_Load_Process(bool lighting_enabled,MeshModelClass * for (int vidx=0; vidxGet_Diffuse(&mtl_diffuse); From d72a2ebcc2c7c6113642ea37ab02c4b630a90191 Mon Sep 17 00:00:00 2001 From: Jacob Ledbetter Date: Wed, 9 Sep 2026 09:45:31 -0600 Subject: [PATCH 2/6] bugfix(ww3d2): Guard null materials in Zero Hour lighting scans --- .../Source/WWVegas/WW3D2/meshmatdesc.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp index b2eddd6290b..1c2d9148cd3 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp @@ -901,9 +901,9 @@ void MeshMatDescClass::Post_Load_Process(bool lighting_enabled,MeshModelClass * bool ambient_used=false; bool emissive_used=false; - Vector3 mtl_diffuse; - Vector3 mtl_ambient; - Vector3 mtl_emissive; + Vector3 mtl_diffuse(0.0f,0.0f,0.0f); + Vector3 mtl_ambient(0.0f,0.0f,0.0f); + Vector3 mtl_emissive(0.0f,0.0f,0.0f); VertexMaterialClass * prev_mtl = nullptr; VertexMaterialClass * mtl = Peek_Material(0, pass); @@ -919,6 +919,12 @@ void MeshMatDescClass::Post_Load_Process(bool lighting_enabled,MeshModelClass * for (int vidx=0; vidxGet_Diffuse(&mtl_diffuse); @@ -936,6 +942,12 @@ void MeshMatDescClass::Post_Load_Process(bool lighting_enabled,MeshModelClass * VertexMaterialClass * mtl = Peek_Material(0,pass); for (int vidx=0; vidx Date: Thu, 10 Sep 2026 08:47:55 -0600 Subject: [PATCH 3/6] bugfix(ww3d2): Use per-material colors and remove unused baseline analysis --- .../Source/WWVegas/WW3D2/meshmatdesc.cpp | 73 ++++------- .../Source/WWVegas/WW3D2/meshmatdesc.cpp | 113 ++++++------------ 2 files changed, 56 insertions(+), 130 deletions(-) diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp index 44f40f697c8..1d309ab418a 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp @@ -680,71 +680,35 @@ void MeshMatDescClass::Post_Load_Process(bool lighting_enabled,MeshModelClass * if (!ColorArray[0] && !ColorArray[1]) continue; // If no color arrays, we don't have a problem - Vector3 single_diffuse(0.0f,0.0f,0.0f); - Vector3 single_ambient(0.0f,0.0f,0.0f); - Vector3 single_emissive(0.0f,0.0f,0.0f); - float single_opacity=1.0f; - bool single_diffuse_used=true; - bool single_ambient_used=true; - bool single_emissive_used=true; - bool single_opacity_used=true; + // Aggregate color usage across valid materials; no first-material baseline is needed. bool diffuse_used=false; bool ambient_used=false; bool emissive_used=false; - bool opacity_used=false; - - Vector3 mtl_diffuse(0.0f,0.0f,0.0f); - Vector3 mtl_ambient(0.0f,0.0f,0.0f); - Vector3 mtl_emissive(0.0f,0.0f,0.0f); - float mtl_opacity = 1.0f; - - VertexMaterialClass * prev_mtl = nullptr; - VertexMaterialClass * mtl = Peek_Material(0, pass); - if (mtl) { - mtl->Get_Diffuse(&single_diffuse); - single_opacity = mtl->Get_Opacity(); - mtl->Get_Ambient(&single_ambient); - mtl->Get_Emissive(&single_emissive); - - if (single_diffuse.X || single_diffuse.Y || single_diffuse.Z) diffuse_used=true; - if (single_ambient.X || single_ambient.Y || single_ambient.Z) ambient_used=true; - if (single_emissive.X || single_emissive.Y || single_emissive.Z) emissive_used=true; - if (single_opacity!=1.0f) opacity_used=true; - } - for (int vidx=0; vidxGet_Diffuse(&mtl_diffuse); - mtl_opacity = mtl->Get_Opacity(); mtl->Get_Ambient(&mtl_ambient); mtl->Get_Emissive(&mtl_emissive); - } - if (mtl_diffuse.X!=single_diffuse.X || mtl_diffuse.Y!=single_diffuse.Y || mtl_diffuse.Z!=single_diffuse.Z) { - single_diffuse_used=false; - } - if (mtl_ambient.X!=single_ambient.X || mtl_ambient.Y!=single_ambient.Y || mtl_ambient.Z!=single_ambient.Z) { - single_ambient_used=false; - } - if (mtl_emissive.X!=single_emissive.X || mtl_emissive.Y!=single_emissive.Y || mtl_emissive.Z!=single_emissive.Z) { - single_emissive_used=false; - } - if (mtl_opacity!=single_opacity) { - single_opacity_used=false; + diffuse_used = diffuse_used || mtl_diffuse.X || mtl_diffuse.Y || mtl_diffuse.Z; + ambient_used = ambient_used || mtl_ambient.X || mtl_ambient.Y || mtl_ambient.Z; + emissive_used = emissive_used || mtl_emissive.X || mtl_emissive.Y || mtl_emissive.Z; } - - if (mtl_diffuse.X || mtl_diffuse.Y || mtl_diffuse.Z) diffuse_used=true; - if (mtl_ambient.X || mtl_ambient.Y || mtl_ambient.Z) ambient_used=true; - if (mtl_emissive.X || mtl_emissive.Y || mtl_emissive.Z) emissive_used=true; - if (mtl_opacity!=1.0f) opacity_used=true; - } // If both DCG and DIG arrays are submitted, multiply them together to DCG channel @@ -766,7 +730,9 @@ void MeshMatDescClass::Post_Load_Process(bool lighting_enabled,MeshModelClass * if ((DCGSource[pass] != VertexMaterialClass::MATERIAL) && (ColorArray[0] != nullptr)) { unsigned * diffuse_array = ColorArray[0]->Get_Array(); - Vector3 mtl_diffuse; + Vector3 mtl_diffuse(0.0f,0.0f,0.0f); + Vector3 mtl_ambient(0.0f,0.0f,0.0f); + Vector3 mtl_emissive(0.0f,0.0f,0.0f); float mtl_opacity = 1.0f; VertexMaterialClass * prev_mtl = nullptr; @@ -783,6 +749,9 @@ void MeshMatDescClass::Post_Load_Process(bool lighting_enabled,MeshModelClass * if (mtl != prev_mtl) { prev_mtl = mtl; mtl->Get_Diffuse(&mtl_diffuse); + // TheSuperHackers @bugfix Cryo 10/09/2026 Use this vertex's material colors, not the last analyzed material. + mtl->Get_Ambient(&mtl_ambient); + mtl->Get_Emissive(&mtl_emissive); mtl_opacity = mtl->Get_Opacity(); } diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp index 1c2d9148cd3..2d44c96479f 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp @@ -682,71 +682,35 @@ void MeshMatDescClass::Post_Load_Process(bool lighting_enabled,MeshModelClass * if (!ColorArray[0] && !ColorArray[1]) continue; // If no color arrays, we don't have a problem - Vector3 single_diffuse(0.0f,0.0f,0.0f); - Vector3 single_ambient(0.0f,0.0f,0.0f); - Vector3 single_emissive(0.0f,0.0f,0.0f); - float single_opacity=1.0f; - bool single_diffuse_used=true; - bool single_ambient_used=true; - bool single_emissive_used=true; - bool single_opacity_used=true; + // Aggregate color usage across valid materials; no first-material baseline is needed. bool diffuse_used=false; bool ambient_used=false; bool emissive_used=false; - bool opacity_used=false; - - Vector3 mtl_diffuse(0.0f,0.0f,0.0f); - Vector3 mtl_ambient(0.0f,0.0f,0.0f); - Vector3 mtl_emissive(0.0f,0.0f,0.0f); - float mtl_opacity = 1.0f; - - VertexMaterialClass * prev_mtl = nullptr; - VertexMaterialClass * mtl = Peek_Material(0, pass); - if (mtl) { - mtl->Get_Diffuse(&single_diffuse); - single_opacity = mtl->Get_Opacity(); - mtl->Get_Ambient(&single_ambient); - mtl->Get_Emissive(&single_emissive); - - if (single_diffuse.X || single_diffuse.Y || single_diffuse.Z) diffuse_used=true; - if (single_ambient.X || single_ambient.Y || single_ambient.Z) ambient_used=true; - if (single_emissive.X || single_emissive.Y || single_emissive.Z) emissive_used=true; - if (single_opacity!=1.0f) opacity_used=true; - } - for (int vidx=0; vidxGet_Diffuse(&mtl_diffuse); - mtl_opacity = mtl->Get_Opacity(); mtl->Get_Ambient(&mtl_ambient); mtl->Get_Emissive(&mtl_emissive); - } - if (mtl_diffuse.X!=single_diffuse.X || mtl_diffuse.Y!=single_diffuse.Y || mtl_diffuse.Z!=single_diffuse.Z) { - single_diffuse_used=false; - } - if (mtl_ambient.X!=single_ambient.X || mtl_ambient.Y!=single_ambient.Y || mtl_ambient.Z!=single_ambient.Z) { - single_ambient_used=false; + diffuse_used = diffuse_used || mtl_diffuse.X || mtl_diffuse.Y || mtl_diffuse.Z; + ambient_used = ambient_used || mtl_ambient.X || mtl_ambient.Y || mtl_ambient.Z; + emissive_used = emissive_used || mtl_emissive.X || mtl_emissive.Y || mtl_emissive.Z; } - if (mtl_emissive.X!=single_emissive.X || mtl_emissive.Y!=single_emissive.Y || mtl_emissive.Z!=single_emissive.Z) { - single_emissive_used=false; - } - if (mtl_opacity!=single_opacity) { - single_opacity_used=false; - } - - if (mtl_diffuse.X || mtl_diffuse.Y || mtl_diffuse.Z) diffuse_used=true; - if (mtl_ambient.X || mtl_ambient.Y || mtl_ambient.Z) ambient_used=true; - if (mtl_emissive.X || mtl_emissive.Y || mtl_emissive.Z) emissive_used=true; - if (mtl_opacity!=1.0f) opacity_used=true; - } // If both DCG and DIG arrays are submitted, multiply them together to DCG channel @@ -768,7 +732,9 @@ void MeshMatDescClass::Post_Load_Process(bool lighting_enabled,MeshModelClass * if ((DCGSource[pass] != VertexMaterialClass::MATERIAL) && (ColorArray[0] != nullptr)) { unsigned * diffuse_array = ColorArray[0]->Get_Array(); - Vector3 mtl_diffuse; + Vector3 mtl_diffuse(0.0f,0.0f,0.0f); + Vector3 mtl_ambient(0.0f,0.0f,0.0f); + Vector3 mtl_emissive(0.0f,0.0f,0.0f); float mtl_opacity = 1.0f; VertexMaterialClass * prev_mtl = nullptr; @@ -785,6 +751,9 @@ void MeshMatDescClass::Post_Load_Process(bool lighting_enabled,MeshModelClass * if (mtl != prev_mtl) { prev_mtl = mtl; mtl->Get_Diffuse(&mtl_diffuse); + // TheSuperHackers @bugfix Cryo 10/09/2026 Use this vertex's material colors, not the last analyzed material. + mtl->Get_Ambient(&mtl_ambient); + mtl->Get_Emissive(&mtl_emissive); mtl_opacity = mtl->Get_Opacity(); } @@ -894,47 +863,35 @@ void MeshMatDescClass::Post_Load_Process(bool lighting_enabled,MeshModelClass * } // Set lighting to false if requested in all passes... else if (set_lighting_to_false) { - Vector3 single_diffuse(0.0f,0.0f,0.0f); - Vector3 single_ambient(0.0f,0.0f,0.0f); - Vector3 single_emissive(0.0f,0.0f,0.0f); + // Aggregate color usage across valid materials; no first-material baseline is needed. bool diffuse_used=false; bool ambient_used=false; bool emissive_used=false; - Vector3 mtl_diffuse(0.0f,0.0f,0.0f); - Vector3 mtl_ambient(0.0f,0.0f,0.0f); - Vector3 mtl_emissive(0.0f,0.0f,0.0f); - - VertexMaterialClass * prev_mtl = nullptr; - VertexMaterialClass * mtl = Peek_Material(0, pass); - if (mtl) { - mtl->Get_Diffuse(&single_diffuse); - mtl->Get_Ambient(&single_ambient); - mtl->Get_Emissive(&single_emissive); - - if (single_diffuse.X || single_diffuse.Y || single_diffuse.Z) diffuse_used=true; - if (single_ambient.X || single_ambient.Y || single_ambient.Z) ambient_used=true; - if (single_emissive.X || single_emissive.Y || single_emissive.Z) emissive_used=true; - } - - for (int vidx=0; vidxGet_Diffuse(&mtl_diffuse); mtl->Get_Ambient(&mtl_ambient); mtl->Get_Emissive(&mtl_emissive); - } - if (mtl_diffuse.X || mtl_diffuse.Y || mtl_diffuse.Z) diffuse_used=true; - if (mtl_ambient.X || mtl_ambient.Y || mtl_ambient.Z) ambient_used=true; - if (mtl_emissive.X || mtl_emissive.Y || mtl_emissive.Z) emissive_used=true; + diffuse_used = diffuse_used || mtl_diffuse.X || mtl_diffuse.Y || mtl_diffuse.Z; + ambient_used = ambient_used || mtl_ambient.X || mtl_ambient.Y || mtl_ambient.Z; + emissive_used = emissive_used || mtl_emissive.X || mtl_emissive.Y || mtl_emissive.Z; + } } if ((DCGSource[pass] != VertexMaterialClass::MATERIAL) && (ColorArray[0] != nullptr)) { From 62f7fbef8d0ab9069d75647081dbac5d75b3bcdd Mon Sep 17 00:00:00 2001 From: Jacob Ledbetter Date: Thu, 10 Sep 2026 09:29:32 -0600 Subject: [PATCH 4/6] refactor(ww3d2): Remove redundant material initialization and consolidate fix notes --- .../Source/WWVegas/WW3D2/meshmatdesc.cpp | 20 ++++++------- .../Source/WWVegas/WW3D2/meshmatdesc.cpp | 29 ++++++++----------- 2 files changed, 21 insertions(+), 28 deletions(-) diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp index 1d309ab418a..6e2fbd03ca8 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp @@ -639,6 +639,8 @@ void MeshMatDescClass::Install_UV_Array(int pass,int stage,Vector2 * uvs,int cou } +// TheSuperHackers @bugfix Cryo 10/09/2026 Skip null materials to prevent crashes and +// use each vertex's material colors to avoid incorrect ambient/emissive vertex colors. void MeshMatDescClass::Post_Load_Process(bool lighting_enabled,MeshModelClass * parent) { /* @@ -680,7 +682,6 @@ void MeshMatDescClass::Post_Load_Process(bool lighting_enabled,MeshModelClass * if (!ColorArray[0] && !ColorArray[1]) continue; // If no color arrays, we don't have a problem - // Aggregate color usage across valid materials; no first-material baseline is needed. bool diffuse_used=false; bool ambient_used=false; bool emissive_used=false; @@ -689,7 +690,6 @@ void MeshMatDescClass::Post_Load_Process(bool lighting_enabled,MeshModelClass * for (int vidx=0; vidxGet_Diffuse(&mtl_diffuse); mtl->Get_Ambient(&mtl_ambient); mtl->Get_Emissive(&mtl_emissive); @@ -730,10 +730,10 @@ void MeshMatDescClass::Post_Load_Process(bool lighting_enabled,MeshModelClass * if ((DCGSource[pass] != VertexMaterialClass::MATERIAL) && (ColorArray[0] != nullptr)) { unsigned * diffuse_array = ColorArray[0]->Get_Array(); - Vector3 mtl_diffuse(0.0f,0.0f,0.0f); - Vector3 mtl_ambient(0.0f,0.0f,0.0f); - Vector3 mtl_emissive(0.0f,0.0f,0.0f); - float mtl_opacity = 1.0f; + Vector3 mtl_diffuse; + Vector3 mtl_ambient; + Vector3 mtl_emissive; + float mtl_opacity; VertexMaterialClass * prev_mtl = nullptr; VertexMaterialClass * mtl = Peek_Material(0,pass); @@ -741,7 +741,6 @@ void MeshMatDescClass::Post_Load_Process(bool lighting_enabled,MeshModelClass * for (int vidx=0; vidxGet_Diffuse(&mtl_diffuse); - // TheSuperHackers @bugfix Cryo 10/09/2026 Use this vertex's material colors, not the last analyzed material. mtl->Get_Ambient(&mtl_ambient); mtl->Get_Emissive(&mtl_emissive); mtl_opacity = mtl->Get_Opacity(); diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp index 2d44c96479f..a7b91b6cdfd 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp @@ -640,6 +640,8 @@ void MeshMatDescClass::Install_UV_Array(int pass,int stage,Vector2 * uvs,int cou } +// TheSuperHackers @bugfix Cryo 10/09/2026 Skip null materials to prevent crashes and +// use each vertex's material colors to avoid incorrect ambient/emissive vertex colors. void MeshMatDescClass::Post_Load_Process(bool lighting_enabled,MeshModelClass * parent) { /* @@ -682,7 +684,6 @@ void MeshMatDescClass::Post_Load_Process(bool lighting_enabled,MeshModelClass * if (!ColorArray[0] && !ColorArray[1]) continue; // If no color arrays, we don't have a problem - // Aggregate color usage across valid materials; no first-material baseline is needed. bool diffuse_used=false; bool ambient_used=false; bool emissive_used=false; @@ -691,7 +692,6 @@ void MeshMatDescClass::Post_Load_Process(bool lighting_enabled,MeshModelClass * for (int vidx=0; vidxGet_Diffuse(&mtl_diffuse); mtl->Get_Ambient(&mtl_ambient); mtl->Get_Emissive(&mtl_emissive); @@ -732,10 +732,10 @@ void MeshMatDescClass::Post_Load_Process(bool lighting_enabled,MeshModelClass * if ((DCGSource[pass] != VertexMaterialClass::MATERIAL) && (ColorArray[0] != nullptr)) { unsigned * diffuse_array = ColorArray[0]->Get_Array(); - Vector3 mtl_diffuse(0.0f,0.0f,0.0f); - Vector3 mtl_ambient(0.0f,0.0f,0.0f); - Vector3 mtl_emissive(0.0f,0.0f,0.0f); - float mtl_opacity = 1.0f; + Vector3 mtl_diffuse; + Vector3 mtl_ambient; + Vector3 mtl_emissive; + float mtl_opacity; VertexMaterialClass * prev_mtl = nullptr; VertexMaterialClass * mtl = Peek_Material(0,pass); @@ -743,7 +743,6 @@ void MeshMatDescClass::Post_Load_Process(bool lighting_enabled,MeshModelClass * for (int vidx=0; vidxGet_Diffuse(&mtl_diffuse); - // TheSuperHackers @bugfix Cryo 10/09/2026 Use this vertex's material colors, not the last analyzed material. mtl->Get_Ambient(&mtl_ambient); mtl->Get_Emissive(&mtl_emissive); mtl_opacity = mtl->Get_Opacity(); @@ -863,7 +861,6 @@ void MeshMatDescClass::Post_Load_Process(bool lighting_enabled,MeshModelClass * } // Set lighting to false if requested in all passes... else if (set_lighting_to_false) { - // Aggregate color usage across valid materials; no first-material baseline is needed. bool diffuse_used=false; bool ambient_used=false; bool emissive_used=false; @@ -872,7 +869,6 @@ void MeshMatDescClass::Post_Load_Process(bool lighting_enabled,MeshModelClass * for (int vidx=0; vidxGet_Diffuse(&mtl_diffuse); mtl->Get_Ambient(&mtl_ambient); mtl->Get_Emissive(&mtl_emissive); @@ -899,7 +895,6 @@ void MeshMatDescClass::Post_Load_Process(bool lighting_enabled,MeshModelClass * VertexMaterialClass * mtl = Peek_Material(0,pass); for (int vidx=0; vidx Date: Thu, 10 Sep 2026 10:23:26 -0600 Subject: [PATCH 5/6] refactor(ww3d2): Skip unnecessary material lighting traversal --- .../Source/WWVegas/WW3D2/meshmatdesc.cpp | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp index a7b91b6cdfd..2512e8afc2f 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp @@ -890,22 +890,23 @@ void MeshMatDescClass::Post_Load_Process(bool lighting_enabled,MeshModelClass * } } - if ((DCGSource[pass] != VertexMaterialClass::MATERIAL) && (ColorArray[0] != nullptr)) { - VertexMaterialClass * prev_mtl = nullptr; - VertexMaterialClass * mtl = Peek_Material(0,pass); - for (int vidx=0; vidxSet_Lighting(false); - } + mtl->Set_Lighting(false); } } } From 16ab04bd42aba1d81ca3b732c18638bea9bd0300 Mon Sep 17 00:00:00 2001 From: Jacob Ledbetter Date: Sat, 12 Sep 2026 09:04:05 -0600 Subject: [PATCH 6/6] refactor(ww3d2): Stop material analysis once all color channels are used --- .../Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp | 5 +++++ .../Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp index 6e2fbd03ca8..548c0b5e07b 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp @@ -708,6 +708,11 @@ void MeshMatDescClass::Post_Load_Process(bool lighting_enabled,MeshModelClass * diffuse_used = diffuse_used || mtl_diffuse.X || mtl_diffuse.Y || mtl_diffuse.Z; ambient_used = ambient_used || mtl_ambient.X || mtl_ambient.Y || mtl_ambient.Z; emissive_used = emissive_used || mtl_emissive.X || mtl_emissive.Y || mtl_emissive.Z; + + if (diffuse_used && ambient_used && emissive_used) + { + break; + } } } diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp index 2512e8afc2f..c80f3d3d10d 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp @@ -710,6 +710,11 @@ void MeshMatDescClass::Post_Load_Process(bool lighting_enabled,MeshModelClass * diffuse_used = diffuse_used || mtl_diffuse.X || mtl_diffuse.Y || mtl_diffuse.Z; ambient_used = ambient_used || mtl_ambient.X || mtl_ambient.Y || mtl_ambient.Z; emissive_used = emissive_used || mtl_emissive.X || mtl_emissive.Y || mtl_emissive.Z; + + if (diffuse_used && ambient_used && emissive_used) + { + break; + } } } @@ -887,6 +892,11 @@ void MeshMatDescClass::Post_Load_Process(bool lighting_enabled,MeshModelClass * diffuse_used = diffuse_used || mtl_diffuse.X || mtl_diffuse.Y || mtl_diffuse.Z; ambient_used = ambient_used || mtl_ambient.X || mtl_ambient.Y || mtl_ambient.Z; emissive_used = emissive_used || mtl_emissive.X || mtl_emissive.Y || mtl_emissive.Z; + + if (diffuse_used && ambient_used && emissive_used) + { + break; + } } }