commit
bfe8beb7cd
181
src/EffectGlow.cpp
Normal file
181
src/EffectGlow.cpp
Normal file
@ -0,0 +1,181 @@
|
||||
/*
|
||||
* EffectGlow.cpp
|
||||
*
|
||||
* Created on: Apr 13, 2017
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "EffectGlow.hpp"
|
||||
|
||||
IMaterialSystem* materials = nullptr;
|
||||
|
||||
// FIXME move to sdk
|
||||
CScreenSpaceEffectRegistration *CScreenSpaceEffectRegistration::s_pHead = NULL;
|
||||
IScreenSpaceEffectManager* g_pScreenSpaceEffects = nullptr;
|
||||
CScreenSpaceEffectRegistration** g_ppScreenSpaceRegistrationHead = nullptr;
|
||||
CScreenSpaceEffectRegistration::CScreenSpaceEffectRegistration( const char *pName, IScreenSpaceEffect *pEffect )
|
||||
{
|
||||
logging::Info("Creating new effect '%s', head: 0x%08x", pName, *g_ppScreenSpaceRegistrationHead);
|
||||
m_pEffectName = pName;
|
||||
m_pEffect = pEffect;
|
||||
m_pNext = *g_ppScreenSpaceRegistrationHead;
|
||||
*g_ppScreenSpaceRegistrationHead = this;
|
||||
logging::Info("New head: 0x%08x", *g_ppScreenSpaceRegistrationHead);
|
||||
}
|
||||
|
||||
/*IMaterial* GetRenderTarget() {
|
||||
if (!tr_cathook_rt) {
|
||||
tr_cathook_rt.InitRenderTarget(256, 256, RT_SIZE_FULL_FRAME_BUFFER, IMAGE_FORMAT_ARGB8888, MATERIAL_RT_DEPTH_NONE, false, "cathook_rt");
|
||||
}
|
||||
return tr_cathook_rt.;
|
||||
}*/
|
||||
|
||||
IMaterial* GetGlowMaterial() {
|
||||
return vfunc<IMaterial*(*)(IMaterialSystem*, const char*, const char*, bool, const char*)>(g_IMaterialSystem, 73)(g_IMaterialSystem, "dev/glow_color", TEXTURE_GROUP_OTHER, true, 0);
|
||||
}
|
||||
|
||||
static CatVar glow_experimental(CV_SWITCH, "glow_experimental", "0", "Experimental Glow");
|
||||
|
||||
void EffectGlow::Init() {
|
||||
logging::Info("Init EffectGlow...");
|
||||
if (!materials) materials = g_IMaterialSystem;
|
||||
logging::Info("materials: 0x%08x", materials);
|
||||
rt_A.InitRenderTarget(1920/2, 1080/2, RT_SIZE_DEFAULT, IMAGE_FORMAT_RGBA8888, MATERIAL_RT_DEPTH_SEPARATE, false, "__cathook_glow_rta");
|
||||
rt_B.InitRenderTarget(1920/2, 1080/2, RT_SIZE_DEFAULT, IMAGE_FORMAT_RGBA8888, MATERIAL_RT_DEPTH_SEPARATE, false, "__cathook_glow_rtb");
|
||||
logging::Info("Textures init!");
|
||||
//rt_B.InitRenderTarget(256, 256, RT_SIZE_FULL_FRAME_BUFFER, IMAGE_FORMAT_ARGB8888, MATERIAL_RT_DEPTH_NONE, false, "__cathook_glow_rtB");
|
||||
KeyValues *kv2 = new KeyValues( "VertexLitGeneric" );
|
||||
kv2->SetString( "$basetexture", "vgui/white" );
|
||||
kv2->SetInt( "$selfillum", 1 );
|
||||
kv2->SetString( "$selfillummask", "vgui/white" );
|
||||
kv2->SetInt( "$vertexalpha", 1 );
|
||||
kv2->SetInt( "$model", 1 );
|
||||
glow_material.Init( "__cathook_glow_mat_color", TEXTURE_GROUP_CLIENT_EFFECTS, kv2 );
|
||||
glow_material->Refresh();
|
||||
KeyValues* kv = new KeyValues("UnlitGeneric");
|
||||
kv->SetString("$basetexture", "_rt_FullFrameFB");
|
||||
kv->SetInt("$additive", 1);
|
||||
result_material.Init("__cathook_glow_mat", TEXTURE_GROUP_CLIENT_EFFECTS, kv);
|
||||
result_material->Refresh();
|
||||
logging::Info("Material init!");
|
||||
//dev_glow_color.Init(vfunc<IMaterial*(*)(IMaterialSystem*, const char*, const char*, bool, const char*)>(g_IMaterialSystem, 73)(g_IMaterialSystem, "dev/glow_color", TEXTURE_GROUP_OTHER, true, 0));
|
||||
dev_bloomdadd.Init(vfunc<IMaterial*(*)(IMaterialSystem*, const char*, const char*, bool, const char*)>(g_IMaterialSystem, 73)(g_IMaterialSystem, "dev/bloomadd", TEXTURE_GROUP_OTHER, true, 0));
|
||||
dev_blurfilterx.Init(vfunc<IMaterial*(*)(IMaterialSystem*, const char*, const char*, bool, const char*)>(g_IMaterialSystem, 73)(g_IMaterialSystem, "dev/blurfilterx", TEXTURE_GROUP_OTHER, true, 0));
|
||||
dev_blurfiltery.Init(vfunc<IMaterial*(*)(IMaterialSystem*, const char*, const char*, bool, const char*)>(g_IMaterialSystem, 73)(g_IMaterialSystem, "dev/blurfiltery", TEXTURE_GROUP_OTHER, true, 0));
|
||||
dev_halo_add_to_screen.Init(vfunc<IMaterial*(*)(IMaterialSystem*, const char*, const char*, bool, const char*)>(g_IMaterialSystem, 73)(g_IMaterialSystem, "dev/halo_add_to_screen", TEXTURE_GROUP_OTHER, true, 0));
|
||||
|
||||
logging::Info("Init done!");
|
||||
init = true;
|
||||
}
|
||||
|
||||
void EffectGlow::BeginRenderGlow() {
|
||||
CMatRenderContextPtr ptr(vfunc<IMatRenderContext*(*)(IMaterialSystem*)>(g_IMaterialSystem, 100, 0)(g_IMaterialSystem));
|
||||
ptr->PushRenderTargetAndViewport(rt_A);
|
||||
g_IVModelRender->SuppressEngineLighting(true);
|
||||
g_IVRenderView->GetColorModulation(orig_modulation);
|
||||
static Vector red(1.0f, 0.1f, 0.1f);
|
||||
g_IVRenderView->SetColorModulation(red.Base());
|
||||
g_IStudioRender->ForcedMaterialOverride(glow_material);
|
||||
g_IVRenderView->SetBlend(1.0f);
|
||||
}
|
||||
|
||||
void EffectGlow::EndRenderGlow() {
|
||||
CMatRenderContextPtr ptr(vfunc<IMatRenderContext*(*)(IMaterialSystem*)>(g_IMaterialSystem, 100, 0)(g_IMaterialSystem));
|
||||
g_IVRenderView->SetColorModulation(orig_modulation);
|
||||
g_IStudioRender->ForcedMaterialOverride(nullptr);
|
||||
g_IVModelRender->SuppressEngineLighting(false);
|
||||
ptr->PopRenderTargetAndViewport();
|
||||
}
|
||||
|
||||
void EffectGlow::RenderGlow(int idx) {
|
||||
CMatRenderContextPtr ptr(vfunc<IMatRenderContext*(*)(IMaterialSystem*)>(g_IMaterialSystem, 100, 0)(g_IMaterialSystem));
|
||||
ptr->PushRenderTargetAndViewport( rt_A );
|
||||
|
||||
g_IVModelRender->SuppressEngineLighting( true );
|
||||
|
||||
// Set the glow tint since selfillum trumps color modulation
|
||||
IMaterialVar *var = glow_material->FindVar( "$selfillumtint", NULL, false );
|
||||
static float color[4] = { 1.0f, 0.0f, 0.0f, 1.0f };
|
||||
var->SetVecValue( color, 4 ); // Fixed compilation error
|
||||
var = glow_material->FindVar( "$alpha", NULL, false );
|
||||
var->SetFloatValue( color[3] ); // Fixed compilation error
|
||||
|
||||
g_IVModelRender->ForcedMaterialOverride( glow_material );
|
||||
IClientEntity* ent = g_IEntityList->GetClientEntity(idx);
|
||||
if (ent) ent->DrawModel(1);
|
||||
g_IVModelRender->ForcedMaterialOverride( NULL );
|
||||
|
||||
g_IVModelRender->SuppressEngineLighting( false );
|
||||
|
||||
ptr->PopRenderTargetAndViewport();
|
||||
|
||||
|
||||
/*IClientEntity* ent = g_IEntityList->GetClientEntity(idx);
|
||||
if (ent) {
|
||||
ent->DrawModel(1);
|
||||
}*/
|
||||
}
|
||||
|
||||
void EffectGlow::Render(int x, int y, int w, int h) {
|
||||
if (!init) Init();
|
||||
if (!glow_experimental) return;
|
||||
CMatRenderContextPtr ptr(vfunc<IMatRenderContext*(*)(IMaterialSystem*)>(g_IMaterialSystem, 100, 0)(g_IMaterialSystem));
|
||||
|
||||
//ptr->Viewport(x, y, w, h);
|
||||
|
||||
ITexture* rt = ptr->GetRenderTarget();
|
||||
|
||||
IMaterialVar* var;
|
||||
var = dev_blurfilterx->FindVar("$basetexture", nullptr);
|
||||
var->SetTextureValue(rt_A);
|
||||
var = dev_blurfiltery->FindVar("$basetexture", nullptr);
|
||||
var->SetTextureValue(rt_B);
|
||||
var = result_material->FindVar("$basetexture", nullptr);
|
||||
var->SetTextureValue(rt_A);
|
||||
//var = dev_blurfilterx->FindVar("$bloomamount", nullptr);
|
||||
//var->SetFloatValue(10);
|
||||
var = dev_blurfiltery->FindVar("$bloomamount", nullptr);
|
||||
var->SetFloatValue(10);
|
||||
|
||||
ptr->ClearColor4ub(0, 0, 0, 255);
|
||||
ptr->PushRenderTargetAndViewport(rt_A);
|
||||
ptr->ClearBuffers(true, true);
|
||||
ptr->PopRenderTargetAndViewport();
|
||||
ptr->PushRenderTargetAndViewport(rt_B);
|
||||
ptr->ClearBuffers(true, true);
|
||||
ptr->PopRenderTargetAndViewport();
|
||||
|
||||
ptr->ClearStencilBufferRectangle( 0, 0, 1920, 1080, 0 );
|
||||
|
||||
BeginRenderGlow();
|
||||
for (int i = 1; i < 32; i++) {
|
||||
IClientEntity* ent = g_IEntityList->GetClientEntity(i);
|
||||
if (ent && !ent->IsDormant() && NET_BYTE(ent, netvar.iLifeState) == LIFE_ALIVE) {
|
||||
//BeginRenderGlow();
|
||||
RenderGlow(i);
|
||||
//EndRenderGlow();
|
||||
}
|
||||
}
|
||||
|
||||
ptr->PushRenderTargetAndViewport( rt_B );
|
||||
ptr->Viewport(x, y, w, h);
|
||||
ptr->DrawScreenSpaceQuad( dev_blurfilterx );
|
||||
ptr->PopRenderTargetAndViewport();
|
||||
|
||||
ptr->PushRenderTargetAndViewport( rt_A );
|
||||
ptr->Viewport(x, y, w, h);
|
||||
ptr->DrawScreenSpaceQuad( dev_blurfiltery );
|
||||
ptr->PopRenderTargetAndViewport();
|
||||
|
||||
ptr->SetRenderTarget(rt);
|
||||
ptr->Viewport(x, y, w, h);
|
||||
|
||||
ptr->DrawScreenSpaceQuad(result_material);
|
||||
var = result_material->FindVar("$basetexture", nullptr);
|
||||
//var->SetTextureValue(rt_B);
|
||||
//ptr->DrawScreenSpaceQuad(result_material);
|
||||
}
|
||||
|
||||
EffectGlow g_EffectGlow;
|
||||
CScreenSpaceEffectRegistration* g_pEffectGlow = nullptr;
|
45
src/EffectGlow.hpp
Normal file
45
src/EffectGlow.hpp
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* EffectGlow.hpp
|
||||
*
|
||||
* Created on: Apr 13, 2017
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#ifndef EFFECTGLOW_HPP_
|
||||
#define EFFECTGLOW_HPP_
|
||||
|
||||
#include "common.h"
|
||||
|
||||
class EffectGlow : public IScreenSpaceEffect {
|
||||
public:
|
||||
virtual void Init( );
|
||||
inline virtual void Shutdown( ) {};
|
||||
|
||||
inline virtual void SetParameters( KeyValues *params ) {};
|
||||
|
||||
virtual void Render( int x, int y, int w, int h );
|
||||
|
||||
inline virtual void Enable( bool bEnable ) { enabled = bEnable; };
|
||||
inline virtual bool IsEnabled( ) { return enabled; };
|
||||
|
||||
void RenderGlow(int idx);
|
||||
void BeginRenderGlow();
|
||||
void EndRenderGlow();
|
||||
public:
|
||||
bool init { false };
|
||||
bool enabled;
|
||||
float orig_modulation[3];
|
||||
CTextureReference rt_A;
|
||||
CTextureReference rt_B;
|
||||
CMaterialReference result_material;
|
||||
CMaterialReference glow_material;
|
||||
CMaterialReference dev_bloomdadd;
|
||||
CMaterialReference dev_halo_add_to_screen;
|
||||
CMaterialReference dev_blurfilterx;
|
||||
CMaterialReference dev_blurfiltery;
|
||||
};
|
||||
|
||||
extern EffectGlow g_EffectGlow;
|
||||
extern CScreenSpaceEffectRegistration* g_pEffectGlow;
|
||||
|
||||
#endif /* EFFECTGLOW_HPP_ */
|
@ -34,6 +34,7 @@
|
||||
#include "helpers.h"
|
||||
#include "playerlist.hpp"
|
||||
#include "interfaces.h"
|
||||
#include "EffectGlow.hpp"
|
||||
#include "localplayer.h"
|
||||
#include "logging.h"
|
||||
#include "playerresource.h"
|
||||
@ -50,6 +51,7 @@
|
||||
#include "textfile.h"
|
||||
#include "ipc.h"
|
||||
#include "gui/GUI.h"
|
||||
#include "hooks/hookedmethods.h"
|
||||
#include "classid.h"
|
||||
#include "crits.h"
|
||||
|
||||
|
@ -38,7 +38,6 @@ void EntityCache::Invalidate() {
|
||||
|
||||
void CachedEntity::Update(int idx) {
|
||||
SEGV_BEGIN
|
||||
|
||||
m_IDX = idx;
|
||||
if (!RAW_ENT(this)) return;
|
||||
#if PROXY_ENTITY != true
|
||||
@ -211,7 +210,8 @@ EntityCache::~EntityCache() {
|
||||
|
||||
void EntityCache::Update() {
|
||||
m_nMax = g_IEntityList->GetHighestEntityIndex();
|
||||
for (int i = 0; i < m_nMax && i < MAX_ENTITIES; i++) {
|
||||
// idk that can break something i guess
|
||||
for (int i = 0; i <= m_nMax && i < MAX_ENTITIES; i++) {
|
||||
m_pArray[i].Update(i);
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ static CatVar glow_teammates(CV_SWITCH, "glow_teammates", "0", "Teammates");
|
||||
static CatVar glow_teammate_buildings(CV_SWITCH, "glow_teammate_buildings", "0", "Teammate buildings");
|
||||
static CatVar glow_buildings(CV_SWITCH, "glow_buildings", "1", "Buildings");
|
||||
static CatVar glow_stickies(CV_SWITCH, "glow_stickies", "0", "Stickies");
|
||||
static CatVar glow_players(CV_SWITCH, "glow_players", "1", "Players");
|
||||
|
||||
int CGlowObjectManager::EnableGlow(IClientEntity* entity, int color) {
|
||||
int idx = GlowHandle(entity);
|
||||
@ -78,6 +79,7 @@ int GetEntityGlowColor(int idx) {
|
||||
}
|
||||
break;
|
||||
case ENTITY_PLAYER:
|
||||
if (!glow_players) return 0;
|
||||
if (!ent->m_bEnemy && !glow_teammates) return 0;
|
||||
if ((int)glow_color_scheme == 1) {
|
||||
return colors::Health(ent->m_iHealth, ent->m_iMaxHealth);
|
||||
@ -103,6 +105,7 @@ bool ShouldEntityGlow(int idx) {
|
||||
if (!ent->m_bEnemy && !(glow_teammate_buildings || glow_teammates)) return false;
|
||||
return true;
|
||||
case ENTITY_PLAYER:
|
||||
if (!glow_players) return false;
|
||||
if (!glow_teammates && !ent->m_bEnemy) return false;
|
||||
if (CE_BYTE(ent, netvar.iLifeState) != LIFE_ALIVE) return false;
|
||||
return true;
|
||||
|
@ -155,9 +155,25 @@ List& MainList() {
|
||||
]
|
||||
]
|
||||
|
||||
"Chams" [
|
||||
"Chams Menu"
|
||||
"chams_enable"
|
||||
"chams_health"
|
||||
"chams_players"
|
||||
"chams_teammates"
|
||||
"chams_buildings"
|
||||
"chams_teammate_buildings"
|
||||
"chams_flat"
|
||||
"chams_weapons"
|
||||
"chams_medkits"
|
||||
"chams_ammo"
|
||||
"chams_stickies"
|
||||
]
|
||||
|
||||
"Glow" [
|
||||
"Glow Menu"
|
||||
"glow_enabled"
|
||||
"glow_players"
|
||||
"glow_color_scheme"
|
||||
"glow_health_packs"
|
||||
"glow_ammo_boxes"
|
||||
|
12
src/hack.cpp
12
src/hack.cpp
@ -171,6 +171,10 @@ void hack::Initialize() {
|
||||
hooks::hkInput->Init((void*)g_IInput, 0);
|
||||
hooks::hkInput->HookMethod((void*)GetUserCmd_hook, hooks::offGetUserCmd);
|
||||
hooks::hkInput->Apply();
|
||||
hooks::hkIVModelRender = new hooks::VMTHook();
|
||||
hooks::hkIVModelRender->Init(g_IVModelRender, 0);
|
||||
hooks::hkIVModelRender->HookMethod((void*)DrawModelExecute_hook, hooks::offDrawModelExecute);
|
||||
hooks::hkIVModelRender->Apply();
|
||||
if (TF2) g_GlowObjectManager = *reinterpret_cast<CGlowObjectManager**>(gSignatures.GetClientSignature("C1 E0 05 03 05") + 5);
|
||||
InitStrings();
|
||||
hacks::shared::killsay::Init();
|
||||
@ -179,6 +183,13 @@ void hack::Initialize() {
|
||||
hack::command_stack().push("cat_spam_reload");
|
||||
logging::Info("Hooked!");
|
||||
playerlist::Load();
|
||||
//g_pEffectGlow = new CScreenSpaceEffectRegistration("_cathook_glow", &g_EffectGlow);
|
||||
//for (CScreenSpaceEffectRegistration* reg = *g_ppScreenSpaceRegistrationHead; reg; reg = reg->m_pNext) {
|
||||
// logging::Info("%s", reg->m_pEffectName);
|
||||
//}
|
||||
//g_pScreenSpaceEffects->EnableScreenSpaceEffect("_cathook_glow");
|
||||
//g_EffectGlow.Init();
|
||||
logging::Info("SSE enabled..");
|
||||
}
|
||||
|
||||
void hack::Think() {
|
||||
@ -197,6 +208,7 @@ void hack::Shutdown() {
|
||||
if (hooks::hkNetChannel) hooks::hkNetChannel->Kill();
|
||||
if (hooks::hkStudioRender) hooks::hkStudioRender->Kill();
|
||||
if (hooks::hkInput) hooks::hkInput->Kill();
|
||||
if (hooks::hkIVModelRender) hooks::hkIVModelRender->Kill();
|
||||
//if (hooks::hkCTFPlayer) hooks::hkCTFPlayer->Kill();
|
||||
logging::Info("Unregistering convars..");
|
||||
ConVar_Unregister();
|
||||
|
203
src/hacks/Chams.cpp
Normal file
203
src/hacks/Chams.cpp
Normal file
@ -0,0 +1,203 @@
|
||||
/*
|
||||
* Chams.cpp
|
||||
*
|
||||
* Created on: Apr 15, 2017
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#include "../common.h"
|
||||
|
||||
namespace hacks { namespace shared { namespace chams {
|
||||
|
||||
CatVar enable(CV_SWITCH, "chams_enable", "0", "Enable");
|
||||
static CatVar flat(CV_SWITCH, "chams_flat", "0", "Flat");
|
||||
static CatVar health(CV_SWITCH, "chams_health", "0", "Health");
|
||||
static CatVar teammates(CV_SWITCH, "chams_teammates", "0", "Teammates");
|
||||
static CatVar players(CV_SWITCH, "chams_players", "1", "Players");
|
||||
static CatVar medkits(CV_SWITCH, "chams_medkits", "0", "Medkits");
|
||||
static CatVar ammobox(CV_SWITCH, "chams_ammo", "0", "Ammoboxes");
|
||||
static CatVar buildings(CV_SWITCH, "chams_buildings", "0", "Buildings");
|
||||
static CatVar stickies(CV_SWITCH, "chams_stickies", "0", "Stickies");
|
||||
static CatVar teammate_buildings(CV_SWITCH, "chams_teammate_buildings", "0", "Teammate Buildings");
|
||||
static CatVar weapons(CV_SWITCH, "chams_weapons", "1", "Weapons");
|
||||
|
||||
static bool init = false;
|
||||
|
||||
CMaterialReference mat_unlit;
|
||||
CMaterialReference mat_unlit_z;
|
||||
CMaterialReference mat_lit;
|
||||
CMaterialReference mat_lit_z;
|
||||
|
||||
void Init() {
|
||||
if (!materials) materials = g_IMaterialSystem;
|
||||
{
|
||||
KeyValues* kv = new KeyValues("UnlitGeneric");
|
||||
kv->SetString("$basetexture", "vgui/white_additive");
|
||||
kv->SetInt("$ignorez", 0);
|
||||
mat_unlit.Init("__cathook_chams_unlit", kv);
|
||||
}
|
||||
{
|
||||
KeyValues* kv = new KeyValues("UnlitGeneric");
|
||||
kv->SetString("$basetexture", "vgui/white_additive");
|
||||
kv->SetInt("$ignorez", 1);
|
||||
mat_unlit_z.Init("__cathook_chams_unlit_z", kv);
|
||||
}
|
||||
{
|
||||
KeyValues* kv = new KeyValues("VertexLitGeneric");
|
||||
kv->SetString("$basetexture", "vgui/white_additive");
|
||||
kv->SetInt("$ignorez", 0);
|
||||
kv->SetInt("$halflambert", 1);
|
||||
mat_lit.Init("__cathook_chams_lit", kv);
|
||||
}
|
||||
{
|
||||
KeyValues* kv = new KeyValues("VertexLitGeneric");
|
||||
kv->SetString("$basetexture", "vgui/white_additive");
|
||||
kv->SetInt("$ignorez", 1);
|
||||
kv->SetInt("$halflambert", 1);
|
||||
mat_lit_z.Init("__cathook_chams_lit_z", kv);
|
||||
}
|
||||
init = true;
|
||||
}
|
||||
|
||||
int GetChamColor(int idx) {
|
||||
if (idx < 0 || idx > g_IEntityList->GetHighestEntityIndex()) return colors::white;
|
||||
CachedEntity* ent = ENTITY(idx);
|
||||
if (CE_BAD(ent)) return colors::white;
|
||||
IClientEntity* entity = RAW_ENT(ent);
|
||||
if (vfunc<bool(*)(IClientEntity*)>(entity, 0xBE, 0)(entity)) {
|
||||
IClientEntity* owner = vfunc<IClientEntity*(*)(IClientEntity*)>(entity, 0x1C3, 0)(entity);
|
||||
if (owner) {
|
||||
return GetChamColor(owner->entindex());
|
||||
}
|
||||
}
|
||||
switch (ent->m_Type) {
|
||||
case ENTITY_BUILDING:
|
||||
if (!ent->m_bEnemy && !(teammates || teammate_buildings)) {
|
||||
return 0;
|
||||
}
|
||||
if (health) {
|
||||
return colors::Health(ent->m_iHealth, ent->m_iMaxHealth);
|
||||
}
|
||||
break;
|
||||
case ENTITY_PLAYER:
|
||||
if (!players) return 0;
|
||||
if (!ent->m_bEnemy && !teammates) return 0;
|
||||
if (health) {
|
||||
return colors::Health(ent->m_iHealth, ent->m_iMaxHealth);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return colors::EntityF(ent);
|
||||
}
|
||||
|
||||
bool ShouldCham(int idx) {
|
||||
if (idx < 0 || idx > HIGHEST_ENTITY) return false;
|
||||
CachedEntity* ent = ENTITY(idx);
|
||||
if (CE_BAD(ent)) return false;
|
||||
IClientEntity* entity = RAW_ENT(ent);
|
||||
if (weapons && vfunc<bool(*)(IClientEntity*)>(entity, 0xBE, 0)(entity)) {
|
||||
IClientEntity* owner = vfunc<IClientEntity*(*)(IClientEntity*)>(entity, 0x1C3, 0)(entity);
|
||||
if (owner) {
|
||||
return ShouldCham(owner->entindex());
|
||||
}
|
||||
}
|
||||
switch (ent->m_Type) {
|
||||
case ENTITY_BUILDING:
|
||||
if (!buildings) return false;
|
||||
if (!ent->m_bEnemy && !(teammate_buildings || teammates)) return false;
|
||||
return true;
|
||||
case ENTITY_PLAYER:
|
||||
if (!players) return false;
|
||||
if (!teammates && !ent->m_bEnemy) return false;
|
||||
if (CE_BYTE(ent, netvar.iLifeState) != LIFE_ALIVE) return false;
|
||||
return true;
|
||||
break;
|
||||
case ENTITY_PROJECTILE:
|
||||
if (!ent->m_bEnemy) return false;
|
||||
if (stickies && ent->m_iClassID == g_pClassID->CTFGrenadePipebombProjectile) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case ENTITY_GENERIC:
|
||||
switch (ent->m_ItemType) {
|
||||
case ITEM_HEALTH_LARGE:
|
||||
case ITEM_HEALTH_MEDIUM:
|
||||
case ITEM_HEALTH_SMALL:
|
||||
return medkits;
|
||||
case ITEM_AMMO_LARGE:
|
||||
case ITEM_AMMO_MEDIUM:
|
||||
case ITEM_AMMO_SMALL:
|
||||
return ammobox;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void DrawModelExecute(IVModelRender* _this, const DrawModelState_t& state, const ModelRenderInfo_t& info, matrix3x4_t* matrix) {
|
||||
if (!enable) return;
|
||||
if (!init) {
|
||||
Init();
|
||||
}
|
||||
//std::string name(g_IModelInfo->GetModelName(info.pModel));
|
||||
IClientUnknown* unknown = info.pRenderable->GetIClientUnknown();
|
||||
if (unknown) {
|
||||
IClientEntity* entity = unknown->GetIClientEntity();
|
||||
//logging::Info("entity: 0x%08x", entity);
|
||||
if (entity && !entity->IsDormant()) {
|
||||
if (ShouldCham(entity->entindex())) {
|
||||
int color = GetChamColor(entity->entindex());
|
||||
unsigned char _b = (color >> 16) & 0xFF;
|
||||
unsigned char _g = (color >> 8) & 0xFF;
|
||||
unsigned char _r = (color) & 0xFF;
|
||||
float color_1[] = { (float)_r / 255.0f, (float)_g / 255.0f, (float)_b / 255.0f };
|
||||
float color_2[] = { color_1[0] * 0.6f, color_1[1] * 0.6f, color_1[2] * 0.6f };
|
||||
mat_unlit_z->AlphaModulate(1.0f);
|
||||
g_IVRenderView->SetColorModulation(color_1);
|
||||
g_IVModelRender->ForcedMaterialOverride(flat ? mat_unlit_z : mat_lit_z);
|
||||
((DrawModelExecute_t)(hooks::hkIVModelRender->GetMethod(hooks::offDrawModelExecute)))(_this, state, info, matrix);
|
||||
mat_unlit->AlphaModulate(1.0f);
|
||||
g_IVRenderView->SetColorModulation(color_2);
|
||||
g_IVModelRender->ForcedMaterialOverride(flat ? mat_unlit : mat_lit);
|
||||
}
|
||||
//logging::Info("lit player");
|
||||
// IsBaseCombatWeapon
|
||||
/*if (vfunc<bool(*)(IClientEntity*)>(entity, 0xBE, 0)(entity)) {
|
||||
IClientEntity* owner = vfunc<IClientEntity*(*)(IClientEntity*)>(entity, 0x1C3, 0)(entity);
|
||||
if (owner) {
|
||||
int color = colors::EntityF(ENTITY(owner->entindex()));
|
||||
unsigned char _b = (color >> 16) & 0xFF;
|
||||
unsigned char _g = (color >> 8) & 0xFF;
|
||||
unsigned char _r = (color) & 0xFF;
|
||||
float color_1[] = { (float)_r / 255.0f, (float)_g / 255.0f, (float)_b / 255.0f };
|
||||
float color_2[] = { color_1[0] * 0.6f, color_1[1] * 0.6f, color_1[2] * 0.6f };
|
||||
mat_unlit_z->AlphaModulate(1.0f);
|
||||
g_IVRenderView->SetColorModulation(color_1);
|
||||
g_IVModelRender->ForcedMaterialOverride(flat ? mat_unlit_z : mat_lit_z);
|
||||
((DrawModelExecute_t)(hooks::hkIVModelRender->GetMethod(hooks::offDrawModelExecute)))(_this, state, info, matrix);
|
||||
mat_unlit->AlphaModulate(1.0f);
|
||||
g_IVRenderView->SetColorModulation(color_2);
|
||||
g_IVModelRender->ForcedMaterialOverride(flat ? mat_unlit : mat_lit);
|
||||
}
|
||||
} else if (entity->GetClientClass()->m_ClassID == g_pClassID->C_Player) {
|
||||
int color = colors::EntityF(ENTITY(entity->entindex()));
|
||||
unsigned char _b = (color >> 16) & 0xFF;
|
||||
unsigned char _g = (color >> 8) & 0xFF;
|
||||
unsigned char _r = (color) & 0xFF;
|
||||
float color_1[] = { (float)_r / 255.0f, (float)_g / 255.0f, (float)_b / 255.0f };
|
||||
float color_2[] = { color_1[0] * 0.6f, color_1[1] * 0.6f, color_1[2] * 0.6f };
|
||||
mat_unlit_z->AlphaModulate(1.0f);
|
||||
g_IVRenderView->SetColorModulation(color_1);
|
||||
g_IVModelRender->ForcedMaterialOverride(flat ? mat_unlit_z : mat_lit_z);
|
||||
((DrawModelExecute_t)(hooks::hkIVModelRender->GetMethod(hooks::offDrawModelExecute)))(_this, state, info, matrix);
|
||||
mat_unlit->AlphaModulate(1.0f);
|
||||
g_IVRenderView->SetColorModulation(color_2);
|
||||
g_IVModelRender->ForcedMaterialOverride(flat ? mat_unlit : mat_lit);
|
||||
}*/
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}}}
|
19
src/hacks/Chams.hpp
Normal file
19
src/hacks/Chams.hpp
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Chams.hpp
|
||||
*
|
||||
* Created on: Apr 15, 2017
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#ifndef HACKS_CHAMS_HPP_
|
||||
#define HACKS_CHAMS_HPP_
|
||||
|
||||
namespace hacks { namespace shared { namespace chams {
|
||||
|
||||
extern CatVar enable;
|
||||
|
||||
void DrawModelExecute(IVModelRender* _this, const DrawModelState_t& state, const ModelRenderInfo_t& info, matrix3x4_t* matrix);
|
||||
|
||||
}}}
|
||||
|
||||
#endif /* HACKS_CHAMS_HPP_ */
|
@ -23,6 +23,7 @@
|
||||
#include "Misc.h"
|
||||
#include "SpyAlert.h"
|
||||
#include "Trigger.h"
|
||||
#include "Chams.hpp"
|
||||
#include "KillSay.h"
|
||||
#include "Achievement.h"
|
||||
#include "Spam.h"
|
||||
|
@ -81,3 +81,4 @@ hooks::VMTHook* hooks::hkNetChannel = 0;
|
||||
hooks::VMTHook* hooks::hkClientDLL = 0;
|
||||
hooks::VMTHook* hooks::hkMatSurface = 0;
|
||||
hooks::VMTHook* hooks::hkStudioRender = 0;
|
||||
hooks::VMTHook* hooks::hkIVModelRender = nullptr;
|
||||
|
@ -40,9 +40,11 @@ extern VMTHook* hkClientDLL;
|
||||
extern VMTHook* hkMatSurface;
|
||||
extern VMTHook* hkStudioRender;
|
||||
extern VMTHook* hkInput;
|
||||
extern VMTHook* hkIVModelRender;
|
||||
|
||||
constexpr unsigned int offGetUserCmd = 8;
|
||||
constexpr unsigned int offShouldDraw = 136;
|
||||
constexpr unsigned int offDrawModelExecute = 19;
|
||||
extern unsigned int offHandleInputEvent;
|
||||
extern unsigned int offPaintTraverse;
|
||||
extern unsigned int offCreateMove;
|
||||
|
@ -8,13 +8,7 @@
|
||||
#ifndef HOOKEDMETHODS_H_
|
||||
#define HOOKEDMETHODS_H_
|
||||
|
||||
class IStudioRender;
|
||||
class CUserCmd;
|
||||
class INetMessage;
|
||||
class bf_read;
|
||||
class CViewSetup;
|
||||
class IClientEntity;
|
||||
class IInput;
|
||||
#include "../common.h"
|
||||
|
||||
typedef bool(CreateMove_t)(void*, float, CUserCmd*);
|
||||
typedef void(PaintTraverse_t)(void*, unsigned int, bool, bool);
|
||||
@ -29,6 +23,7 @@ typedef void(LevelInit_t)(void*, const char*);
|
||||
typedef void(LevelShutdown_t)(void*);
|
||||
typedef void(BeginFrame_t)(IStudioRender*);
|
||||
typedef bool(*CanInspect_t)(IClientEntity*);
|
||||
typedef void(*DrawModelExecute_t)(IVModelRender*, const DrawModelState_t&, const ModelRenderInfo_t&, matrix3x4_t*);
|
||||
typedef CUserCmd*(GetUserCmd_t)(IInput*, int);
|
||||
//typedef void(*CInput__CreateMove_t)(void*, int, float, bool);
|
||||
//void CInput__CreateMove_hook(void*, int sequence_number, float input_sample_frametime, bool active);
|
||||
@ -36,6 +31,7 @@ bool CanInspect_hook(IClientEntity*);
|
||||
const unsigned int offCanInspect = 512;
|
||||
void BeginFrame_hook(IStudioRender*);
|
||||
CUserCmd* GetUserCmd_hook(IInput*, int);
|
||||
void DrawModelExecute_hook(IVModelRender* _this, const DrawModelState_t& state, const ModelRenderInfo_t& info, matrix3x4_t* matrix);
|
||||
|
||||
#include "CreateMove.h"
|
||||
#include "PaintTraverse.h"
|
||||
|
@ -10,6 +10,59 @@
|
||||
#include "../hack.h"
|
||||
#include "hookedmethods.h"
|
||||
|
||||
static CatVar no_invisibility(CV_SWITCH, "no_invis", "0", "Remove Invisibility", "Useful with chams!");
|
||||
|
||||
int C_TFPlayer__DrawModel_hook(IClientEntity* _this, int flags) {
|
||||
float old_invis = *(float*)((uintptr_t)_this + 79u);
|
||||
if (no_invisibility) {
|
||||
if (old_invis < 1.0f) {
|
||||
*(float*)((uintptr_t)_this + 79u) = 0.5f;
|
||||
}
|
||||
}
|
||||
|
||||
*(float*)((uintptr_t)_this + 79u) = old_invis;
|
||||
}
|
||||
|
||||
static CatVar no_arms(CV_SWITCH, "no_arms", "0", "No Arms");
|
||||
static CatVar no_hats(CV_SWITCH, "no_hats", "0", "No Hats");
|
||||
|
||||
void DrawModelExecute_hook(IVModelRender* _this, const DrawModelState_t& state, const ModelRenderInfo_t& info, matrix3x4_t* matrix) {
|
||||
/*IClientUnknown* unknown = info.pRenderable->GetIClientUnknown();
|
||||
if (unknown) {
|
||||
IClientEntity* entity = unknown->GetIClientEntity();
|
||||
if (entity && entity->entindex() != -1) {
|
||||
if (entity->GetClientClass()->m_ClassID == g_pClassID->C_Player) {
|
||||
//CMatRenderContextPtr ptr();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
if (!(no_arms || no_hats || hacks::shared::chams::enable)) {
|
||||
((DrawModelExecute_t)(hooks::hkIVModelRender->GetMethod(hooks::offDrawModelExecute)))(_this, state, info, matrix);
|
||||
return;
|
||||
}
|
||||
|
||||
if (no_arms || no_hats) {
|
||||
if (info.pModel) {
|
||||
const char* name = g_IModelInfo->GetModelName(info.pModel);
|
||||
if (name) {
|
||||
std::string sname(name);
|
||||
if (no_arms && sname.find("arms") != std::string::npos) {
|
||||
return;
|
||||
} else if (no_hats && sname.find("player/items") != std::string::npos) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float mod_old[3] { 0.0f };
|
||||
g_IVRenderView->GetColorModulation(mod_old);
|
||||
hacks::shared::chams::DrawModelExecute(_this, state, info, matrix);
|
||||
((DrawModelExecute_t)(hooks::hkIVModelRender->GetMethod(hooks::offDrawModelExecute)))(_this, state, info, matrix);
|
||||
g_IVModelRender->ForcedMaterialOverride(nullptr);
|
||||
g_IVRenderView->SetColorModulation(mod_old);
|
||||
}
|
||||
|
||||
bool CanPacket_hook(void* thisptr) {
|
||||
SEGV_BEGIN;
|
||||
return send_packets && ((CanPacket_t*)hooks::hkNetChannel->GetMethod(hooks::offCanPacket))(thisptr);
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
//class ISteamFriends002;
|
||||
|
||||
IVModelRender* g_IVModelRender = nullptr;
|
||||
ISteamClient* g_ISteamClient = nullptr;
|
||||
ISteamFriends* g_ISteamFriends = nullptr;
|
||||
IVEngineClient013* g_IEngine = nullptr;
|
||||
@ -44,6 +45,8 @@ IAchievementMgr* g_IAchievementMgr = nullptr;
|
||||
ISteamUserStats* g_ISteamUserStats = nullptr;
|
||||
IStudioRender* g_IStudioRender = nullptr;
|
||||
IVDebugOverlay* g_IVDebugOverlay = nullptr;
|
||||
IMaterialSystem* g_IMaterialSystem = nullptr;
|
||||
IVRenderView* g_IVRenderView = nullptr;
|
||||
|
||||
template<typename T>
|
||||
T* BruteforceInterface(std::string name, sharedobj::SharedObject* object, int start) {
|
||||
@ -83,10 +86,18 @@ void CreateInterfaces() {
|
||||
g_IVDebugOverlay = BruteforceInterface<IVDebugOverlay>("VDebugOverlay", sharedobj::engine);
|
||||
HSteamPipe sp = g_ISteamClient->CreateSteamPipe();
|
||||
HSteamUser su = g_ISteamClient->ConnectToGlobalUser(sp);
|
||||
g_IVModelRender = BruteforceInterface<IVModelRender>("VEngineModel", sharedobj::engine, 16);
|
||||
g_ISteamFriends = g_ISteamClient->GetISteamFriends(su, sp, "SteamFriends002");
|
||||
g_GlobalVars = **(reinterpret_cast<CGlobalVarsBase***>((uintptr_t)11 + gSignatures.GetClientSignature("55 89 E5 83 EC ? 8B 45 08 8B 15 ? ? ? ? F3 0F 10")));
|
||||
g_IPrediction = BruteforceInterface<IPrediction>("VClientPrediction", sharedobj::client);
|
||||
g_IGameMovement = BruteforceInterface<IGameMovement>("GameMovement", sharedobj::client);
|
||||
g_IVRenderView = BruteforceInterface<IVRenderView>("VEngineRenderView", sharedobj::engine);
|
||||
g_IMaterialSystem = BruteforceInterface<IMaterialSystem>("VMaterialSystem", sharedobj::materialsystem, 81);
|
||||
if (TF2) {
|
||||
// FIXME static offset FIXME FIXME FIXME FIXME IMPORTANT!
|
||||
g_pScreenSpaceEffects = **(IScreenSpaceEffectManager***)(gSignatures.GetClientSignature("F3 0F 10 83 40 05 00 00 C7 44 24 04 ? ? ? ? 89 34 24 F3 0F 11 44 24 08 E8 ? ? ? ? A1 ? ? ? ? 8B 10 89 04 24 89 74 24 08 C7 44 24 04 ? ? ? ? FF 52 0C A1 ? ? ? ? 8B 10 C7 44 24 04 ? ? ? ? 89 04 24 FF 52 14") + 31);
|
||||
g_ppScreenSpaceRegistrationHead = *(CScreenSpaceEffectRegistration***)(gSignatures.GetClientSignature("55 89 E5 53 83 EC 14 8B 1D ? ? ? ? 85 DB 74 25 8D B4 26 00 00 00 00 8B 43 04 85 C0 74 10") + 9);
|
||||
}
|
||||
if (TF2) g_IInput = **(reinterpret_cast<IInput***>((uintptr_t)1 + gSignatures.GetClientSignature("A1 ? ? ? ? C6 05 ? ? ? ? 01 8B 10 89 04 24 FF 92 B4 00 00 00 A1 ? ? ? ? 8B 10")));
|
||||
else if (TF2C) g_IInput = **(reinterpret_cast<IInput***>((uintptr_t)1 + gSignatures.GetClientSignature("A1 ? ? ? ? C6 05 ? ? ? ? 01 8B 10 89 04 24 FF 92 A8 00 00 00 A1 ? ? ? ? 8B 10")));
|
||||
else if (HL2DM) g_IInput = **(reinterpret_cast<IInput***>((uintptr_t)1 + gSignatures.GetClientSignature("A1 ? ? ? ? 8B 10 89 04 24 FF 52 78 A1 ? ? ? ? 8B 10")));
|
||||
|
@ -42,6 +42,10 @@ class IAchievementMgr;
|
||||
class ISteamUserStats;
|
||||
class IStudioRender;
|
||||
class IVDebugOverlay;
|
||||
class IVModelRender;
|
||||
class IVModelRender;
|
||||
class IVRenderView;
|
||||
class IMaterialSystem;
|
||||
|
||||
extern ISteamClient* g_ISteamClient;
|
||||
extern ISteamFriends* g_ISteamFriends;
|
||||
@ -66,6 +70,9 @@ extern IAchievementMgr* g_IAchievementMgr;
|
||||
extern ISteamUserStats* g_ISteamUserStats;
|
||||
extern IStudioRender* g_IStudioRender;
|
||||
extern IVDebugOverlay* g_IVDebugOverlay;
|
||||
extern IMaterialSystem* g_IMaterialSystem;
|
||||
extern IVModelRender* g_IVModelRender;
|
||||
extern IVRenderView* g_IVRenderView;
|
||||
|
||||
template<typename T>
|
||||
T* BruteforceInterface(std::string name, sharedobj::SharedObject* object, int start = 0);
|
||||
|
@ -20,7 +20,9 @@
|
||||
#include <inetchannelinfo.h>
|
||||
#include <gametrace.h>
|
||||
#include <engine/IEngineTrace.h>
|
||||
#include <materialsystem/imaterialvar.h>
|
||||
#include <globalvars_base.h>
|
||||
#include <materialsystem/itexture.h>
|
||||
#include <engine/ivmodelinfo.h>
|
||||
#include <inputsystem/iinputsystem.h>
|
||||
#include <mathlib/vector.h>
|
||||
@ -30,6 +32,7 @@
|
||||
#include <igameevents.h>
|
||||
#include <iclient.h>
|
||||
#include <inetchannel.h>
|
||||
#include <ivrenderview.h>
|
||||
#include <iconvar.h>
|
||||
#include <studio.h>
|
||||
#include <vgui/ISurface.h>
|
||||
@ -50,6 +53,7 @@
|
||||
#include <engine/ivdebugoverlay.h>
|
||||
|
||||
#include "sdk/in_buttons.h"
|
||||
#include "sdk/ScreenSpaceEffects.h"
|
||||
#include "sdk/iinput.h"
|
||||
|
||||
#endif /* SDK_H_ */
|
||||
|
259
src/sdk/MaterialSystemUtil.cpp
Normal file
259
src/sdk/MaterialSystemUtil.cpp
Normal file
@ -0,0 +1,259 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $Workfile: $
|
||||
// $NoKeywords: $
|
||||
//===========================================================================//
|
||||
|
||||
#include "materialsystem/MaterialSystemUtil.h"
|
||||
#include "materialsystem/imaterial.h"
|
||||
#include "materialsystem/itexture.h"
|
||||
#include "materialsystem/imaterialsystem.h"
|
||||
#include "tier1/KeyValues.h"
|
||||
|
||||
#include "../vfunc.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Little utility class to deal with material references
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// constructor, destructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CMaterialReference::CMaterialReference( char const* pMaterialName, const char *pTextureGroupName, bool bComplain ) : m_pMaterial( 0 )
|
||||
{
|
||||
if ( pMaterialName )
|
||||
{
|
||||
Assert( pTextureGroupName );
|
||||
Init( pMaterialName, pTextureGroupName, bComplain );
|
||||
}
|
||||
}
|
||||
|
||||
CMaterialReference::~CMaterialReference()
|
||||
{
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Attach to a material
|
||||
//-----------------------------------------------------------------------------
|
||||
void CMaterialReference::Init( char const* pMaterialName, const char *pTextureGroupName, bool bComplain )
|
||||
{
|
||||
IMaterial *pMaterial = materials->FindMaterial( pMaterialName, pTextureGroupName, bComplain);
|
||||
if( IsErrorMaterial( pMaterial ) )
|
||||
{
|
||||
if (IsOSX())
|
||||
{
|
||||
printf("\n ##### CMaterialReference::Init got error material for %s in tex group %s", pMaterialName, pTextureGroupName );
|
||||
}
|
||||
}
|
||||
|
||||
Assert( pMaterial );
|
||||
Init( pMaterial );
|
||||
}
|
||||
|
||||
void CMaterialReference::Init( const char *pMaterialName, KeyValues *pVMTKeyValues )
|
||||
{
|
||||
// CreateMaterial has a refcount of 1
|
||||
Shutdown();
|
||||
m_pMaterial = materials->CreateMaterial( pMaterialName, pVMTKeyValues );
|
||||
}
|
||||
|
||||
void CMaterialReference::Init( const char *pMaterialName, const char *pTextureGroupName, KeyValues *pVMTKeyValues )
|
||||
{
|
||||
IMaterial *pMaterial = materials->FindProceduralMaterial( pMaterialName, pTextureGroupName, pVMTKeyValues );
|
||||
Assert( pMaterial );
|
||||
Init( pMaterial );
|
||||
}
|
||||
|
||||
void CMaterialReference::Init( IMaterial* pMaterial )
|
||||
{
|
||||
if ( m_pMaterial != pMaterial )
|
||||
{
|
||||
Shutdown();
|
||||
m_pMaterial = pMaterial;
|
||||
if ( m_pMaterial )
|
||||
{
|
||||
m_pMaterial->IncrementReferenceCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CMaterialReference::Init( CMaterialReference& ref )
|
||||
{
|
||||
if ( m_pMaterial != ref.m_pMaterial )
|
||||
{
|
||||
Shutdown();
|
||||
m_pMaterial = ref.m_pMaterial;
|
||||
if (m_pMaterial)
|
||||
{
|
||||
m_pMaterial->IncrementReferenceCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Detach from a material
|
||||
//-----------------------------------------------------------------------------
|
||||
void CMaterialReference::Shutdown( )
|
||||
{
|
||||
if ( m_pMaterial && materials )
|
||||
{
|
||||
m_pMaterial->DecrementReferenceCount();
|
||||
m_pMaterial = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Little utility class to deal with texture references
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// constructor, destructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CTextureReference::CTextureReference( ) : m_pTexture(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
CTextureReference::CTextureReference( const CTextureReference &ref )
|
||||
{
|
||||
m_pTexture = ref.m_pTexture;
|
||||
if ( m_pTexture )
|
||||
{
|
||||
m_pTexture->IncrementReferenceCount();
|
||||
}
|
||||
}
|
||||
|
||||
void CTextureReference::operator=( CTextureReference &ref )
|
||||
{
|
||||
m_pTexture = ref.m_pTexture;
|
||||
if ( m_pTexture )
|
||||
{
|
||||
m_pTexture->IncrementReferenceCount();
|
||||
}
|
||||
}
|
||||
|
||||
CTextureReference::~CTextureReference( )
|
||||
{
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Attach to a texture
|
||||
//-----------------------------------------------------------------------------
|
||||
void CTextureReference::Init( char const* pTextureName, const char *pTextureGroupName, bool bComplain )
|
||||
{
|
||||
Shutdown();
|
||||
m_pTexture = materials->FindTexture( pTextureName, pTextureGroupName, bComplain );
|
||||
if ( m_pTexture )
|
||||
{
|
||||
m_pTexture->IncrementReferenceCount();
|
||||
}
|
||||
}
|
||||
|
||||
void CTextureReference::Init( ITexture* pTexture )
|
||||
{
|
||||
Shutdown();
|
||||
|
||||
m_pTexture = pTexture;
|
||||
if (m_pTexture)
|
||||
{
|
||||
m_pTexture->IncrementReferenceCount();
|
||||
}
|
||||
}
|
||||
|
||||
void CTextureReference::InitProceduralTexture( const char *pTextureName, const char *pTextureGroupName, int w, int h, ImageFormat fmt, int nFlags )
|
||||
{
|
||||
Shutdown();
|
||||
|
||||
m_pTexture = materials->CreateProceduralTexture( pTextureName, pTextureGroupName, w, h, fmt, nFlags );
|
||||
|
||||
// NOTE: The texture reference is already incremented internally above!
|
||||
/*
|
||||
if ( m_pTexture )
|
||||
{
|
||||
m_pTexture->IncrementReferenceCount();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void CTextureReference::InitRenderTarget( int w, int h, RenderTargetSizeMode_t sizeMode, ImageFormat fmt, MaterialRenderTargetDepth_t depth, bool bHDR, char *pStrOptionalName /* = NULL */ )
|
||||
{
|
||||
Shutdown();
|
||||
|
||||
int textureFlags = TEXTUREFLAGS_CLAMPS | TEXTUREFLAGS_CLAMPT;
|
||||
if ( depth == MATERIAL_RT_DEPTH_ONLY )
|
||||
textureFlags |= TEXTUREFLAGS_POINTSAMPLE;
|
||||
|
||||
int renderTargetFlags = bHDR ? CREATERENDERTARGETFLAGS_HDR : 0;
|
||||
|
||||
// NOTE: Refcount returned by CreateRenderTargetTexture is 1
|
||||
//m_pTexture = vfunc<ITexture*(*)(IMaterialSystem*, char const*,int,int,RenderTargetSizeMode_t,ImageFormat,MaterialRenderTargetDepth_t,uint,uint)>(materials, 87, 0)(materials, pStrOptionalName, w, h, sizeMode, fmt,
|
||||
// depth, textureFlags, renderTargetFlags);
|
||||
m_pTexture = materials->CreateNamedRenderTargetTextureEx( pStrOptionalName, w, h, sizeMode, fmt,
|
||||
depth, textureFlags, renderTargetFlags );
|
||||
|
||||
Assert( m_pTexture );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Detach from a texture
|
||||
//-----------------------------------------------------------------------------
|
||||
void CTextureReference::Shutdown( bool bDeleteIfUnReferenced )
|
||||
{
|
||||
if ( m_pTexture && materials )
|
||||
{
|
||||
m_pTexture->DecrementReferenceCount();
|
||||
if ( bDeleteIfUnReferenced )
|
||||
{
|
||||
m_pTexture->DeleteIfUnreferenced();
|
||||
}
|
||||
m_pTexture = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Builds ONLY the system ram render target. Used when caller is explicitly managing.
|
||||
// The paired EDRAM surface can be built in an alternate format.
|
||||
//-----------------------------------------------------------------------------
|
||||
#if defined( _X360 )
|
||||
void CTextureReference::InitRenderTargetTexture( int w, int h, RenderTargetSizeMode_t sizeMode, ImageFormat fmt, MaterialRenderTargetDepth_t depth, bool bHDR, char *pStrOptionalName )
|
||||
{
|
||||
// other variants not implemented yet
|
||||
Assert( depth == MATERIAL_RT_DEPTH_NONE || depth == MATERIAL_RT_DEPTH_SHARED );
|
||||
Assert( !bHDR );
|
||||
|
||||
int renderTargetFlags = CREATERENDERTARGETFLAGS_NOEDRAM;
|
||||
|
||||
m_pTexture = materials->CreateNamedRenderTargetTextureEx(
|
||||
pStrOptionalName,
|
||||
w,
|
||||
h,
|
||||
sizeMode,
|
||||
fmt,
|
||||
depth,
|
||||
TEXTUREFLAGS_CLAMPS | TEXTUREFLAGS_CLAMPT,
|
||||
renderTargetFlags );
|
||||
Assert( m_pTexture );
|
||||
}
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Builds ONLY the EDRAM render target surface. Used when caller is explicitly managing.
|
||||
// The paired system memory texture can be built in an alternate format.
|
||||
//-----------------------------------------------------------------------------
|
||||
#if defined( _X360 )
|
||||
void CTextureReference::InitRenderTargetSurface( int width, int height, ImageFormat fmt, bool bSameAsTexture )
|
||||
{
|
||||
// texture has to be created first
|
||||
Assert( m_pTexture && m_pTexture->IsRenderTarget() );
|
||||
|
||||
m_pTexture->CreateRenderTargetSurface( width, height, fmt, bSameAsTexture );
|
||||
}
|
||||
#endif
|
||||
|
92
src/sdk/ScreenSpaceEffects.h
Normal file
92
src/sdk/ScreenSpaceEffects.h
Normal file
@ -0,0 +1,92 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=====================================================================================//
|
||||
|
||||
#ifndef SCREENSPACEEFFECTS_H
|
||||
#define SCREENSPACEEFFECTS_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
class KeyValues;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Simple base class for screen space post-processing effects
|
||||
//------------------------------------------------------------------------------
|
||||
class IScreenSpaceEffect
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void Init( ) = 0;
|
||||
virtual void Shutdown( ) = 0;
|
||||
|
||||
virtual void SetParameters( KeyValues *params ) = 0;
|
||||
|
||||
virtual void Render( int x, int y, int w, int h ) = 0;
|
||||
|
||||
virtual void Enable( bool bEnable ) = 0;
|
||||
virtual bool IsEnabled( ) = 0;
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Interface class for managing screen space post-processing effects
|
||||
//------------------------------------------------------------------------------
|
||||
class IScreenSpaceEffectManager
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void InitScreenSpaceEffects( ) = 0;
|
||||
virtual void ShutdownScreenSpaceEffects( ) = 0;
|
||||
|
||||
virtual IScreenSpaceEffect *GetScreenSpaceEffect( const char *pEffectName ) = 0;
|
||||
|
||||
virtual void SetScreenSpaceEffectParams( const char *pEffectName, KeyValues *params ) = 0;
|
||||
virtual void SetScreenSpaceEffectParams( IScreenSpaceEffect *pEffect, KeyValues *params ) = 0;
|
||||
|
||||
virtual void EnableScreenSpaceEffect( const char *pEffectName ) = 0;
|
||||
virtual void EnableScreenSpaceEffect( IScreenSpaceEffect *pEffect ) = 0;
|
||||
|
||||
virtual void DisableScreenSpaceEffect( const char *pEffectName ) = 0;
|
||||
virtual void DisableScreenSpaceEffect( IScreenSpaceEffect *pEffect ) = 0;
|
||||
|
||||
virtual void DisableAllScreenSpaceEffects( ) = 0;
|
||||
|
||||
virtual void RenderEffects( int x, int y, int w, int h ) = 0;
|
||||
};
|
||||
|
||||
extern IScreenSpaceEffectManager *g_pScreenSpaceEffects;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
// Registration class for adding screen space effects to the IScreenSpaceEffectManager
|
||||
//-------------------------------------------------------------------------------------
|
||||
class CScreenSpaceEffectRegistration
|
||||
{
|
||||
public:
|
||||
CScreenSpaceEffectRegistration( const char *pName, IScreenSpaceEffect *pEffect );
|
||||
|
||||
const char *m_pEffectName;
|
||||
IScreenSpaceEffect *m_pEffect;
|
||||
|
||||
CScreenSpaceEffectRegistration *m_pNext;
|
||||
|
||||
// NEVER USE - CATHOOK
|
||||
static CScreenSpaceEffectRegistration *s_pHead;
|
||||
};
|
||||
|
||||
// CATHOOK
|
||||
extern CScreenSpaceEffectRegistration** g_ppScreenSpaceRegistrationHead;
|
||||
|
||||
#define ADD_SCREENSPACE_EFFECT( CEffect, pEffectName ) CEffect pEffectName##_effect; \
|
||||
CScreenSpaceEffectRegistration pEffectName##_reg( #pEffectName, &pEffectName##_effect );
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -77,6 +77,7 @@ sharedobj::SharedObject* sharedobj::vstdlib = 0;
|
||||
sharedobj::SharedObject* sharedobj::tier0 = 0;
|
||||
sharedobj::SharedObject* sharedobj::inputsystem = 0;
|
||||
sharedobj::SharedObject* sharedobj::studiorender = 0;
|
||||
sharedobj::SharedObject* sharedobj::materialsystem = 0;
|
||||
|
||||
sharedobj::SharedObject::SharedObject(const std::string& name, bool factory) {
|
||||
while (!(this->path = path_from_proc_maps(name))) {
|
||||
@ -132,5 +133,6 @@ void sharedobj::LoadAllSharedObjects() {
|
||||
sharedobj::vstdlib = new SharedObject("libvstdlib.so", true);
|
||||
sharedobj::inputsystem = new SharedObject("inputsystem.so", true);
|
||||
sharedobj::studiorender = new SharedObject("studiorender.so", true);
|
||||
sharedobj::materialsystem = new SharedObject("materialsystem.so", true);
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,7 @@ extern SharedObject* vstdlib;
|
||||
extern SharedObject* tier0;
|
||||
extern SharedObject* inputsystem;
|
||||
extern SharedObject* studiorender;
|
||||
extern SharedObject* materialsystem;
|
||||
|
||||
void LoadAllSharedObjects();
|
||||
|
||||
|
Reference in New Issue
Block a user