glow
This commit is contained in:
parent
961f0a21b2
commit
0d74d3c5b8
@ -25,15 +25,15 @@ CScreenSpaceEffectRegistration::CScreenSpaceEffectRegistration( const char *pNam
|
|||||||
|
|
||||||
namespace effect_glow {
|
namespace effect_glow {
|
||||||
|
|
||||||
CatVar enable(CV_SWITCH, "glow_experimental_enable", "0", "Enable");
|
CatVar enable(CV_SWITCH, "glow_enable", "0", "Enable");
|
||||||
static CatVar health(CV_SWITCH, "glow_experimental_health", "0", "Health");
|
static CatVar health(CV_SWITCH, "glow_health", "0", "Health");
|
||||||
static CatVar teammates(CV_SWITCH, "glow_experimental_teammates", "0", "Teammates");
|
static CatVar teammates(CV_SWITCH, "glow_teammates", "0", "Teammates");
|
||||||
static CatVar players(CV_SWITCH, "glow_experimental_players", "1", "Players");
|
static CatVar players(CV_SWITCH, "glow_players", "1", "Players");
|
||||||
static CatVar medkits(CV_SWITCH, "glow_experimental_medkits", "0", "Medkits");
|
static CatVar medkits(CV_SWITCH, "glow_medkits", "0", "Medkits");
|
||||||
static CatVar ammobox(CV_SWITCH, "glow_experimental_ammo", "0", "Ammoboxes");
|
static CatVar ammobox(CV_SWITCH, "glow_ammo", "0", "Ammoboxes");
|
||||||
static CatVar buildings(CV_SWITCH, "glow_experimental_buildings", "0", "Buildings");
|
static CatVar buildings(CV_SWITCH, "glow_buildings", "0", "Buildings");
|
||||||
static CatVar stickies(CV_SWITCH, "glow_experimental_stickies", "0", "Stickies");
|
static CatVar stickies(CV_SWITCH, "glow_stickies", "0", "Stickies");
|
||||||
static CatVar teammate_buildings(CV_SWITCH, "glow_experimental_teammate_buildings", "0", "Teammate Buildings");
|
static CatVar teammate_buildings(CV_SWITCH, "glow_teammate_buildings", "0", "Teammate Buildings");
|
||||||
|
|
||||||
void EffectGlow::Init() {
|
void EffectGlow::Init() {
|
||||||
logging::Info("Init EffectChams...");
|
logging::Info("Init EffectChams...");
|
||||||
@ -53,17 +53,6 @@ void EffectGlow::Init() {
|
|||||||
init = true;
|
init = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EffectGlow::BeginRenderChams() {
|
|
||||||
drawing = true;
|
|
||||||
CMatRenderContextPtr ptr(vfunc<IMatRenderContext*(*)(IMaterialSystemFixed*)>(g_IMaterialSystem, 100, 0)(g_IMaterialSystem));
|
|
||||||
}
|
|
||||||
|
|
||||||
void EffectGlow::EndRenderChams() {
|
|
||||||
drawing = false;
|
|
||||||
CMatRenderContextPtr ptr(vfunc<IMatRenderContext*(*)(IMaterialSystemFixed*)>(g_IMaterialSystem, 100, 0)(g_IMaterialSystem));
|
|
||||||
g_IVModelRender->ForcedMaterialOverride(nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
int EffectGlow::ChamsColor(IClientEntity* entity) {
|
int EffectGlow::ChamsColor(IClientEntity* entity) {
|
||||||
CachedEntity* ent = ENTITY(entity->entindex());
|
CachedEntity* ent = ENTITY(entity->entindex());
|
||||||
if (CE_BAD(ent)) return colors::white;
|
if (CE_BAD(ent)) return colors::white;
|
||||||
@ -222,9 +211,32 @@ IMaterial* GetBlurY() {
|
|||||||
return blur;
|
return blur;
|
||||||
}
|
}
|
||||||
|
|
||||||
static CatVar solid_when(CV_INT, "glow_experimental_solid_when", "0", "...", "Never, Always, Unoccluded, Occluded");
|
|
||||||
|
|
||||||
void EffectGlow::DrawToStencil(IClientEntity* entity) {
|
void EffectGlow::BeginRenderChams() {
|
||||||
|
drawing = true;
|
||||||
|
CMatRenderContextPtr ptr(vfunc<IMatRenderContext*(*)(IMaterialSystemFixed*)>(g_IMaterialSystem, 100, 0)(g_IMaterialSystem));
|
||||||
|
ptr->ClearColor4ub(0, 0, 0, 0);
|
||||||
|
ptr->PushRenderTargetAndViewport();
|
||||||
|
ptr->SetRenderTarget(GetBuffer(1));
|
||||||
|
//ptr->Viewport(x, y, w, h);
|
||||||
|
ptr->OverrideAlphaWriteEnable( true, true );
|
||||||
|
g_IVRenderView->SetBlend(0.99f);
|
||||||
|
ptr->ClearBuffers(true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EffectGlow::EndRenderChams() {
|
||||||
|
drawing = false;
|
||||||
|
CMatRenderContextPtr ptr(vfunc<IMatRenderContext*(*)(IMaterialSystemFixed*)>(g_IMaterialSystem, 100, 0)(g_IMaterialSystem));
|
||||||
|
g_IVModelRender->ForcedMaterialOverride(nullptr);
|
||||||
|
ptr->PopRenderTargetAndViewport();
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://puu.sh/vobH4/5da8367aef.png
|
||||||
|
static CatEnum solid_when_enum({"Never", "Always", "Invisible"});
|
||||||
|
static CatVar blur_scale(CV_INT, "glow_blur_scale", "5", "Blur amount");
|
||||||
|
static CatVar solid_when(solid_when_enum, "glow_solid_when", "0", "Solid when", "Glow will be solid when entity is...");
|
||||||
|
|
||||||
|
void EffectGlow::StartStenciling() {
|
||||||
ShaderStencilState_t state;
|
ShaderStencilState_t state;
|
||||||
state.m_bEnable = true;
|
state.m_bEnable = true;
|
||||||
switch ((int)solid_when) {
|
switch ((int)solid_when) {
|
||||||
@ -234,8 +246,41 @@ void EffectGlow::DrawToStencil(IClientEntity* entity) {
|
|||||||
state.m_ZFailOp = STENCILOPERATION_KEEP;
|
state.m_ZFailOp = STENCILOPERATION_KEEP;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
state.m_PassOp = STENCILOPERATION_REPLACE;
|
||||||
|
state.m_FailOp = STENCILOPERATION_KEEP;
|
||||||
|
state.m_ZFailOp = STENCILOPERATION_KEEP;
|
||||||
|
break;
|
||||||
|
/*case 3: https://puu.sh/vobH4/5da8367aef.png
|
||||||
|
state.m_PassOp = STENCILOPERATION_KEEP;
|
||||||
|
state.m_FailOp = STENCILOPERATION_KEEP;
|
||||||
|
state.m_ZFailOp = STENCILOPERATION_REPLACE;*/
|
||||||
}
|
}
|
||||||
|
state.m_CompareFunc = STENCILCOMPARISONFUNCTION_ALWAYS;
|
||||||
|
state.m_nWriteMask = 1;
|
||||||
|
state.m_nReferenceValue = 1;
|
||||||
|
CMatRenderContextPtr ptr(g_IMaterialSystem->GetRenderContext());
|
||||||
|
state.SetStencilState(ptr);
|
||||||
|
if (!solid_when) {
|
||||||
|
ptr->DepthRange(0.0f, 0.01f);
|
||||||
|
} else {
|
||||||
|
ptr->DepthRange(0.0f, 1.0f);
|
||||||
|
}
|
||||||
|
g_IVRenderView->SetBlend(0.0f);
|
||||||
|
mat_unlit->AlphaModulate(1.0f);
|
||||||
|
g_IVModelRender->ForcedMaterialOverride(solid_when ? mat_unlit : mat_unlit_z);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EffectGlow::EndStenciling() {
|
||||||
|
g_IVModelRender->ForcedMaterialOverride(nullptr);
|
||||||
|
CMatRenderContextPtr ptr(g_IMaterialSystem->GetRenderContext());
|
||||||
|
ShaderStencilState_t state {};
|
||||||
|
state.SetStencilState(ptr);
|
||||||
|
ptr->DepthRange(0.0f, 1.0f);
|
||||||
|
g_IVRenderView->SetBlend(1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EffectGlow::DrawToStencil(IClientEntity* entity) {
|
||||||
|
DrawEntity(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EffectGlow::DrawToBuffer(IClientEntity* entity) {
|
void EffectGlow::DrawToBuffer(IClientEntity* entity) {
|
||||||
@ -249,28 +294,23 @@ void EffectGlow::DrawEntity(IClientEntity* entity) {
|
|||||||
if (attach->ShouldDraw()) {
|
if (attach->ShouldDraw()) {
|
||||||
attach->DrawModel(1);
|
attach->DrawModel(1);
|
||||||
}
|
}
|
||||||
attach = g_IEntityList->GetClientEntity(*(int*)((uintptr_t)entity + netvar.m_Collision - 20) & 0xFFF);
|
attach = g_IEntityList->GetClientEntity(*(int*)((uintptr_t)attach + netvar.m_Collision - 20) & 0xFFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EffectGlow::RenderChams(int idx) {
|
void EffectGlow::RenderChams(IClientEntity* entity) {
|
||||||
CMatRenderContextPtr ptr(g_IMaterialSystem->GetRenderContext());
|
CMatRenderContextPtr ptr(g_IMaterialSystem->GetRenderContext());
|
||||||
IClientEntity* entity = g_IEntityList->GetClientEntity(idx);
|
int color = ChamsColor(entity);
|
||||||
if (entity && !entity->IsDormant()) {
|
unsigned char _b = (color >> 16) & 0xFF;
|
||||||
if (ShouldRenderChams(entity)) {
|
unsigned char _g = (color >> 8) & 0xFF;
|
||||||
int color = ChamsColor(entity);
|
unsigned char _r = (color) & 0xFF;
|
||||||
unsigned char _b = (color >> 16) & 0xFF;
|
float color_1[] = { (float)_r / 255.0f, (float)_g / 255.0f, (float)_b / 255.0f };
|
||||||
unsigned char _g = (color >> 8) & 0xFF;
|
float color_2[] = { color_1[0] * 0.6f, color_1[1] * 0.6f, color_1[2] * 0.6f };
|
||||||
unsigned char _r = (color) & 0xFF;
|
mat_unlit_z->AlphaModulate(1.0f);
|
||||||
float color_1[] = { (float)_r / 255.0f, (float)_g / 255.0f, (float)_b / 255.0f };
|
ptr->DepthRange(0.0f, 0.01f);
|
||||||
float color_2[] = { color_1[0] * 0.6f, color_1[1] * 0.6f, color_1[2] * 0.6f };
|
g_IVRenderView->SetColorModulation(color_1);
|
||||||
mat_unlit_z->AlphaModulate(1.0f);
|
g_IVModelRender->ForcedMaterialOverride(mat_unlit_z);
|
||||||
ptr->DepthRange(0.0f, 0.01f);
|
DrawEntity(entity);
|
||||||
g_IVRenderView->SetColorModulation(color_1);
|
|
||||||
g_IVModelRender->ForcedMaterialOverride(mat_unlit_z);
|
|
||||||
DrawEntity(entity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EffectGlow::Render(int x, int y, int w, int h) {
|
void EffectGlow::Render(int x, int y, int w, int h) {
|
||||||
@ -278,23 +318,26 @@ void EffectGlow::Render(int x, int y, int w, int h) {
|
|||||||
if (g_IEngine->IsTakingScreenshot() && clean_screenshots) return;
|
if (g_IEngine->IsTakingScreenshot() && clean_screenshots) return;
|
||||||
if (!enable) return;
|
if (!enable) return;
|
||||||
CMatRenderContextPtr ptr(g_IMaterialSystem->GetRenderContext());
|
CMatRenderContextPtr ptr(g_IMaterialSystem->GetRenderContext());
|
||||||
|
|
||||||
ITexture* orig = ptr->GetRenderTarget();
|
ITexture* orig = ptr->GetRenderTarget();
|
||||||
ptr->ClearColor4ub(0, 0, 0, 0);
|
|
||||||
ptr->PushRenderTargetAndViewport();
|
|
||||||
ptr->SetRenderTarget(GetBuffer(1));
|
|
||||||
ptr->Viewport(x, y, w, h);
|
|
||||||
ptr->OverrideAlphaWriteEnable( true, true );
|
|
||||||
g_IVRenderView->SetBlend(0.99f);
|
|
||||||
ptr->ClearBuffers(true, false);
|
|
||||||
BeginRenderChams();
|
BeginRenderChams();
|
||||||
for (int i = 1; i < HIGHEST_ENTITY; i++) {
|
for (int i = 1; i < HIGHEST_ENTITY; i++) {
|
||||||
IClientEntity* ent = g_IEntityList->GetClientEntity(i);
|
IClientEntity* ent = g_IEntityList->GetClientEntity(i);
|
||||||
if (ent && !ent->IsDormant()) {
|
if (ent && !ent->IsDormant() && ShouldRenderChams(ent)) {
|
||||||
RenderChams(i);
|
RenderChams(ent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EndRenderChams();
|
EndRenderChams();
|
||||||
|
if ((int)solid_when != 1) {
|
||||||
|
ptr->ClearStencilBufferRectangle(x, y, w, h, 0);
|
||||||
|
StartStenciling();
|
||||||
|
for (int i = 1; i < HIGHEST_ENTITY; i++) {
|
||||||
|
IClientEntity* ent = g_IEntityList->GetClientEntity(i);
|
||||||
|
if (ent && !ent->IsDormant() && ShouldRenderChams(ent)) {
|
||||||
|
DrawToStencil(ent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EndStenciling();
|
||||||
|
}
|
||||||
ptr->SetRenderTarget(GetBuffer(2));
|
ptr->SetRenderTarget(GetBuffer(2));
|
||||||
ptr->Viewport(x, y, w, h);
|
ptr->Viewport(x, y, w, h);
|
||||||
ptr->ClearBuffers(true, false);
|
ptr->ClearBuffers(true, false);
|
||||||
@ -308,11 +351,27 @@ void EffectGlow::Render(int x, int y, int w, int h) {
|
|||||||
blitmat->Refresh();
|
blitmat->Refresh();
|
||||||
}
|
}
|
||||||
ptr->SetRenderTarget(GetBuffer(1));
|
ptr->SetRenderTarget(GetBuffer(1));
|
||||||
|
IMaterial* blury = GetBlurY();
|
||||||
|
static IMaterialVar* blury_bloomamount = blury->FindVar("$bloomamount", nullptr);
|
||||||
|
blury_bloomamount->SetIntValue((int)blur_scale);
|
||||||
ptr->DrawScreenSpaceRectangle(GetBlurY(), x, y, w, h, 0, 0, w - 1, h - 1, w, h);
|
ptr->DrawScreenSpaceRectangle(GetBlurY(), x, y, w, h, 0, 0, w - 1, h - 1, w, h);
|
||||||
ptr->Viewport(x, y, w, h);
|
ptr->Viewport(x, y, w, h);
|
||||||
ptr->PopRenderTargetAndViewport();
|
ptr->SetRenderTarget(orig);
|
||||||
g_IVRenderView->SetBlend(0.0f);
|
g_IVRenderView->SetBlend(0.0f);
|
||||||
|
if ((int)solid_when != 1) {
|
||||||
|
ShaderStencilState_t state {};
|
||||||
|
state.m_bEnable = true;
|
||||||
|
state.m_nReferenceValue = 0;
|
||||||
|
state.m_nTestMask = 1;
|
||||||
|
state.m_CompareFunc = STENCILCOMPARISONFUNCTION_EQUAL;
|
||||||
|
state.m_PassOp = STENCILOPERATION_ZERO;
|
||||||
|
state.SetStencilState(ptr);
|
||||||
|
}
|
||||||
ptr->DrawScreenSpaceRectangle(blitmat, x, y, w, h, 0, 0, w - 1, h - 1, w, h);
|
ptr->DrawScreenSpaceRectangle(blitmat, x, y, w, h, 0, 0, w - 1, h - 1, w, h);
|
||||||
|
if ((int)solid_when != -1) {
|
||||||
|
static ShaderStencilState_t zeroStencil {};
|
||||||
|
zeroStencil.SetStencilState(ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EffectGlow g_EffectGlow;
|
EffectGlow g_EffectGlow;
|
||||||
|
@ -24,12 +24,14 @@ public:
|
|||||||
inline virtual void Enable( bool bEnable ) { enabled = bEnable; };
|
inline virtual void Enable( bool bEnable ) { enabled = bEnable; };
|
||||||
inline virtual bool IsEnabled( ) { return enabled; };
|
inline virtual bool IsEnabled( ) { return enabled; };
|
||||||
|
|
||||||
|
void StartStenciling();
|
||||||
|
void EndStenciling();
|
||||||
void DrawEntity(IClientEntity* entity);
|
void DrawEntity(IClientEntity* entity);
|
||||||
void DrawToStencil(IClientEntity* entity);
|
void DrawToStencil(IClientEntity* entity);
|
||||||
void DrawToBuffer(IClientEntity* entity);
|
void DrawToBuffer(IClientEntity* entity);
|
||||||
int ChamsColor(IClientEntity* entity);
|
int ChamsColor(IClientEntity* entity);
|
||||||
bool ShouldRenderChams(IClientEntity* entity);
|
bool ShouldRenderChams(IClientEntity* entity);
|
||||||
void RenderChams(int idx);
|
void RenderChams(IClientEntity* entity);
|
||||||
void BeginRenderChams();
|
void BeginRenderChams();
|
||||||
void EndRenderChams();
|
void EndRenderChams();
|
||||||
public:
|
public:
|
||||||
|
@ -9,15 +9,15 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
static CatEnum glow_color_scheme_enum({"ESP", "HEALTH"});
|
static CatEnum glow_color_scheme_enum({"ESP", "HEALTH"});
|
||||||
static CatVar glow_color_scheme(glow_color_scheme_enum, "glow_color_scheme", "1", "Colors", "Doesn't need a description");
|
static CatVar glow_color_scheme(glow_color_scheme_enum, "glow_old_color_scheme", "1", "Colors", "Doesn't need a description");
|
||||||
// Doesn't work - has to be registered manually.
|
// Doesn't work - has to be registered manually.
|
||||||
static CatVar glow_ammo_boxes(CV_SWITCH, "glow_ammo_boxes", "0", "Ammo");
|
static CatVar glow_ammo_boxes(CV_SWITCH, "glow_old_ammo_boxes", "0", "Ammo");
|
||||||
static CatVar glow_health_packs(CV_SWITCH, "glow_health_packs", "0", "Health");
|
static CatVar glow_health_packs(CV_SWITCH, "glow_old_health_packs", "0", "Health");
|
||||||
static CatVar glow_teammates(CV_SWITCH, "glow_teammates", "0", "Teammates");
|
static CatVar glow_teammates(CV_SWITCH, "glow_old_teammates", "0", "Teammates");
|
||||||
static CatVar glow_teammate_buildings(CV_SWITCH, "glow_teammate_buildings", "0", "Teammate buildings");
|
static CatVar glow_teammate_buildings(CV_SWITCH, "glow_old_teammate_buildings", "0", "Teammate buildings");
|
||||||
static CatVar glow_buildings(CV_SWITCH, "glow_buildings", "1", "Buildings");
|
static CatVar glow_buildings(CV_SWITCH, "glow_old_buildings", "1", "Buildings");
|
||||||
static CatVar glow_stickies(CV_SWITCH, "glow_stickies", "0", "Stickies");
|
static CatVar glow_stickies(CV_SWITCH, "glow_old_stickies", "0", "Stickies");
|
||||||
static CatVar glow_players(CV_SWITCH, "glow_players", "1", "Players");
|
static CatVar glow_players(CV_SWITCH, "glow_old_players", "1", "Players");
|
||||||
|
|
||||||
int CGlowObjectManager::EnableGlow(IClientEntity* entity, int color) {
|
int CGlowObjectManager::EnableGlow(IClientEntity* entity, int color) {
|
||||||
int idx = GlowHandle(entity);
|
int idx = GlowHandle(entity);
|
||||||
|
@ -172,17 +172,33 @@ List& MainList() {
|
|||||||
|
|
||||||
"Glow" [
|
"Glow" [
|
||||||
"Glow Menu"
|
"Glow Menu"
|
||||||
"glow_enabled"
|
"glow_enable"
|
||||||
|
"glow_solid_when"
|
||||||
|
"glow_blur_scale"
|
||||||
|
"glow_health"
|
||||||
"glow_players"
|
"glow_players"
|
||||||
"glow_color_scheme"
|
|
||||||
"glow_health_packs"
|
|
||||||
"glow_ammo_boxes"
|
|
||||||
"glow_teammates"
|
"glow_teammates"
|
||||||
"glow_teammate_buildings"
|
|
||||||
"glow_buildings"
|
"glow_buildings"
|
||||||
|
"glow_teammate_buildings"
|
||||||
|
"glow_medkits"
|
||||||
|
"glow_ammo"
|
||||||
"glow_stickies"
|
"glow_stickies"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
"TF2 Glow Outline" [
|
||||||
|
"TF2 Glow Menu"
|
||||||
|
"glow_old_enabled"
|
||||||
|
"glow_old_players"
|
||||||
|
"glow_old_color_scheme"
|
||||||
|
"glow_old_health_packs"
|
||||||
|
"glow_old_ammo_boxes"
|
||||||
|
"glow_old_alpha"
|
||||||
|
"glow_old_teammates"
|
||||||
|
"glow_old_teammate_buildings"
|
||||||
|
"glow_old_buildings"
|
||||||
|
"glow_old_stickies"
|
||||||
|
]
|
||||||
|
|
||||||
"ESP" [
|
"ESP" [
|
||||||
"ESP Menu"
|
"ESP Menu"
|
||||||
"esp_enabled"
|
"esp_enabled"
|
||||||
|
@ -152,8 +152,8 @@ void Shutdown_hook(void* thisptr, const char* reason) {
|
|||||||
SEGV_END;
|
SEGV_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
static CatVar glow_enabled(CV_SWITCH, "glow_enabled", "0", "Enable", "Make sure to enable glow_outline_effect_enable in tf2 settings");
|
static CatVar glow_enabled(CV_SWITCH, "glow_old_enabled", "0", "Enable", "Make sure to enable glow_outline_effect_enable in tf2 settings");
|
||||||
static CatVar glow_alpha(CV_FLOAT, "glow_alpha", "1", "Alpha", "Glow Transparency", 0.0f, 1.0f);
|
static CatVar glow_alpha(CV_FLOAT, "glow_old_alpha", "1", "Alpha", "Glow Transparency", 0.0f, 1.0f);
|
||||||
|
|
||||||
void FrameStageNotify_hook(void* thisptr, int stage) {
|
void FrameStageNotify_hook(void* thisptr, int stage) {
|
||||||
SEGV_BEGIN;
|
SEGV_BEGIN;
|
||||||
|
Reference in New Issue
Block a user