mirror of
https://github.com/rei-2/Amalgam
synced 2026-10-10 04:43:09 +08:00
changes to world material override
This commit is contained in:
@@ -1043,6 +1043,7 @@
|
||||
<ClCompile Include="src\Hooks\CHLClient_LevelShutdown.cpp" />
|
||||
<ClCompile Include="src\Hooks\IEngineVGui_Paint.cpp" />
|
||||
<ClCompile Include="src\Hooks\CInput_GetUserCmd.cpp" />
|
||||
<ClCompile Include="src\Hooks\IMaterialSystem_FindTexture.cpp" />
|
||||
<ClCompile Include="src\Hooks\IMatSystemSurface_OnScreenSizeChanged.cpp" />
|
||||
<ClCompile Include="src\Hooks\IPanel_PaintTraverse.cpp" />
|
||||
<ClCompile Include="src\Hooks\ISteamFriends_GetFriendPersonaName.cpp" />
|
||||
|
||||
@@ -198,6 +198,7 @@
|
||||
<ClCompile Include="src\Hooks\CTFWeaponBase_CanFireRandomCriticalShot.cpp" />
|
||||
<ClCompile Include="src\Hooks\CTFPlayer_GetMinFOV.cpp" />
|
||||
<ClCompile Include="src\Hooks\CWeaponMedigun_PrimaryAttack.cpp" />
|
||||
<ClCompile Include="src\Hooks\IMaterialSystem_FindTexture.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\Utils\UtlVector\UtlVector.h" />
|
||||
|
||||
@@ -859,8 +859,12 @@ void CVisuals::Store(CTFPlayer* pLocal)
|
||||
void CVisuals::OverrideWorldTextures()
|
||||
{
|
||||
auto uHash = FNV1A::Hash32(Vars::Visuals::World::WorldTexture.Value.c_str());
|
||||
if (uHash == FNV1A::Hash32Const("Default"))
|
||||
switch (uHash)
|
||||
{
|
||||
case FNV1A::Hash32Const("Default"):
|
||||
case FNV1A::Hash32Const("Flat"):
|
||||
return;
|
||||
}
|
||||
|
||||
KeyValues* kv = new KeyValues("LightmappedGeneric");
|
||||
if (!kv)
|
||||
@@ -880,7 +884,7 @@ void CVisuals::OverrideWorldTextures()
|
||||
case FNV1A::Hash32Const("White"):
|
||||
kv->SetString("$basetexture", "patterns/combat/white");
|
||||
break;
|
||||
case FNV1A::Hash32Const("Flat"):
|
||||
case FNV1A::Hash32Const("Gray"):
|
||||
kv->SetString("$basetexture", "vgui/white_additive");
|
||||
kv->SetString("$color2", "[0.12 0.12 0.15]");
|
||||
break;
|
||||
@@ -891,22 +895,15 @@ void CVisuals::OverrideWorldTextures()
|
||||
for (auto h = I::MaterialSystem->FirstMaterial(); h != I::MaterialSystem->InvalidMaterial(); h = I::MaterialSystem->NextMaterial(h))
|
||||
{
|
||||
auto pMaterial = I::MaterialSystem->GetMaterial(h);
|
||||
if (!pMaterial || pMaterial->IsErrorMaterial() || !pMaterial->IsPrecached() || pMaterial->IsTranslucent() || pMaterial->IsSpriteCard())
|
||||
if (!pMaterial || pMaterial->IsErrorMaterial() || !pMaterial->IsPrecached() || pMaterial->IsTranslucent() || pMaterial->IsAlphaTested() || pMaterial->IsSpriteCard())
|
||||
continue;
|
||||
|
||||
std::string_view sGroup = pMaterial->GetTextureGroupName();
|
||||
std::string_view sName = pMaterial->GetName();
|
||||
|
||||
if (!sGroup._Starts_with("World")
|
||||
|| sName.find("water") != std::string_view::npos || sName.find("glass") != std::string_view::npos
|
||||
|| sName.find("door") != std::string_view::npos || sName.find("tools") != std::string_view::npos
|
||||
|| sName.find("player") != std::string_view::npos || sName.find("chicken") != std::string_view::npos
|
||||
|| sName.find("wall28") != std::string_view::npos || sName.find("wall26") != std::string_view::npos
|
||||
|| sName.find("decal") != std::string_view::npos || sName.find("overlay") != std::string_view::npos
|
||||
|| sName.find("hay") != std::string_view::npos)
|
||||
{
|
||||
std::string_view sGroup = pMaterial->GetTextureGroupName();
|
||||
if (!sGroup.starts_with(TEXTURE_GROUP_WORLD)
|
||||
|| sName.find("sky") != std::string_view::npos
|
||||
|| sName.find("water") != std::string_view::npos)
|
||||
continue;
|
||||
}
|
||||
|
||||
pMaterial->SetShaderAndParams(kv);
|
||||
}
|
||||
@@ -920,9 +917,20 @@ static inline void ApplyModulation(Color_t tColor, bool bSky = false)
|
||||
if (!pMaterial || pMaterial->IsErrorMaterial() || !pMaterial->IsPrecached())
|
||||
continue;
|
||||
|
||||
auto sGroup = std::string_view(pMaterial->GetTextureGroupName());
|
||||
if (!bSky ? !sGroup._Starts_with("World") : !sGroup._Starts_with("SkyBox"))
|
||||
continue;
|
||||
std::string_view sName = pMaterial->GetName();
|
||||
std::string_view sGroup = pMaterial->GetTextureGroupName();
|
||||
if (!bSky)
|
||||
{
|
||||
if (!sGroup.starts_with(TEXTURE_GROUP_WORLD)
|
||||
|| sName.find("sky") != std::string_view::npos)
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!sGroup.starts_with(TEXTURE_GROUP_SKYBOX)
|
||||
&& sName.find("sky") == std::string_view::npos)
|
||||
continue;
|
||||
}
|
||||
|
||||
pMaterial->ColorModulate(tColor.r / 255.f, tColor.g / 255.f, tColor.b / 255.f);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
#include "../SDK/SDK.h"
|
||||
|
||||
MAKE_HOOK(IMaterialSystem_FindTexture, U::Memory.GetVirtual(I::MaterialSystem, 79), ITexture*,
|
||||
void* rcx, char const* pTextureName, const char* pTextureGroupName, bool complain, int nAdditionalCreationFlags)
|
||||
{
|
||||
auto pReturn = CALL_ORIGINAL(rcx, pTextureName, pTextureGroupName, complain, nAdditionalCreationFlags);
|
||||
|
||||
auto uHash = FNV1A::Hash32(Vars::Visuals::World::WorldTexture.Value.c_str());
|
||||
if (uHash == FNV1A::Hash32Const("Flat"))
|
||||
{
|
||||
auto overrideTexture = [&]()
|
||||
{
|
||||
if (!pReturn || pReturn->IsTranslucent() || !pTextureName || !pTextureGroupName)
|
||||
return;
|
||||
|
||||
std::string_view sName = pTextureName;
|
||||
std::string_view sGroup = pTextureGroupName;
|
||||
if (!sGroup.starts_with(TEXTURE_GROUP_WORLD))
|
||||
return;
|
||||
|
||||
Vec3 vColor; pReturn->GetLowResColorSample(0.5f, 0.5f, &vColor.x);
|
||||
Color_t tColor = { byte(vColor.x * 255), byte(vColor.y * 255), byte(vColor.z * 255), 255 };
|
||||
pReturn = I::MaterialSystem->CreateTextureFromBits(1, 1, 1, IMAGE_FORMAT_RGBA8888, 4, &tColor.r);
|
||||
};
|
||||
overrideTexture();
|
||||
}
|
||||
|
||||
return pReturn;
|
||||
}
|
||||
@@ -600,7 +600,7 @@ namespace Vars
|
||||
CVarValues(SkyboxChanger, "Skybox changer", std::string("Off"), VISUAL | DROPDOWN_CUSTOM, nullptr,
|
||||
VA_LIST("Off"));
|
||||
CVarValues(WorldTexture, "World texture", std::string("Default"), VISUAL | DROPDOWN_CUSTOM, nullptr,
|
||||
"Default", "Dev", "Camo", "Black", "White", "Flat");
|
||||
"Default", "Dev", "Camo", "Black", "White", "Gray", "Flat");
|
||||
CVar(NearPropFade, "Near prop fade", false, VISUAL);
|
||||
CVar(NoPropFade, "No prop fade", false, VISUAL);
|
||||
SUBNAMESPACE_END(World);
|
||||
|
||||
Reference in New Issue
Block a user