From 892329ec78acf4d4d63749e8c248227aabc2aded Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 4 Nov 2026 18:17:55 +0100 Subject: Chams: model-safe styles and a dedicated viewmodel material VGUI/white materials do not draw skinned models, so every viewmodel style except the model debug one made the hands/weapon disappear. Use model debug materials for all styles: wireframe, additive vertex colour, translucent single colour, translucent vertex colour, MRM fullbright. The viewmodel always uses debug/debugtranslucentsinglecolor. A missing style now falls back to that material instead of vgui/white. --- CONTEXT.md | 16 +++++++++++----- src/gui.cpp | 4 ++-- src/menu.cpp | 2 +- src/studio.cpp | 22 ++++++++++++++++------ src/world.cpp | 3 ++- 5 files changed, 32 insertions(+), 15 deletions(-) diff --git a/CONTEXT.md b/CONTEXT.md index 9233517..ce79800 100644 --- a/CONTEXT.md +++ b/CONTEXT.md @@ -299,11 +299,17 @@ vocabulary / decisions. - Material lookup walks the `IMaterialSystem` list (`world_find_material`), with `FindMaterial` (slot 71) as the fallback. The **exact requested style** is tried first (resident, then loaded on demand), and only if that fails does it - fall back to `models/debug/debugwhite`/`vgui/white`. Styles: Flat, Wireframe, - Additive glow, Solid, White. The chosen material name is logged. -- `Viewmodel (hands/weapon)` also applies the override to entities whose class - contains `viewmodel` or whose model path is `.../v_...`. The viewmodel gets - only the normal-depth pass (no ignorez). + fall back to `debug/debugtranslucentsinglecolor`/debugwhite/vgui white. + Styles: 0 Flat (`models/debug/debugwhite`), 1 Wireframe + (`debug/debugwireframe`), 2 Additive (`debug/additivevertexcolorvertexalpha`), + 3 Solid (`debug/debugtranslucentsinglecolor`), 4 White + (`debug/debugtranslucentvertexcolor`), 5 Fullbright + (`debug/debugmrmfullbright2`). The chosen material name is logged. +- `Viewmodel (hands/weapon)` applies the override to entities whose class + contains `viewmodel` or whose model path is `.../v_...`. Viewmodels always + use the model-safe solid material (`debug/debugtranslucentsinglecolor`); + VGUI/white materials do not draw skinned models and made the hands/weapon + disappear. Only the normal-depth pass is used. - Feature is off by default; `[chams] active/bind/walls/viewmodel/material/r/g/b`, with Through walls, Viewmodel, a Material dropdown and colour in the Visuals card. diff --git a/src/gui.cpp b/src/gui.cpp index 4adc440..9c09bec 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -454,8 +454,8 @@ static void build_cards() { "Apply chams to the first-person hands and weapon too.", &g_chams_viewmodel); static const char *const chams_mat_names[] = { - "Flat", "Wireframe", "Additive glow", "Solid", "White"}; - add_dropdown(chams, "Material", "Chams material.", chams_mat_names, 5, + "Flat", "Wireframe", "Additive glow", "Solid", "White", "Fullbright"}; + add_dropdown(chams, "Material", "Chams material.", chams_mat_names, 6, &g_chams_mat_index); add_color(chams, "Colour", "Chams colour.", g_chams_rgb); int view = add_card(2, nullptr, "Camera / display", diff --git a/src/menu.cpp b/src/menu.cpp index 4f22d39..376a779 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -402,7 +402,7 @@ static bool config_load() { else if (strcmp(key, "material") == 0) { int v = atoi(val); if (v < 0) v = 0; - if (v > 4) v = 4; + if (v > 5) v = 5; g_chams_mat_index = v; } else if (strcmp(key, "r") == 0 || strcmp(key, "g") == 0 || strcmp(key, "b") == 0) { diff --git a/src/studio.cpp b/src/studio.cpp index e667c4b..f67936c 100644 --- a/src/studio.cpp +++ b/src/studio.cpp @@ -201,10 +201,11 @@ int g_chams_mat_idx = -1; const char *chams_material_name(int idx) { switch (idx) { - case 1: return "debug/debugwireframevertexcolorignorez"; - case 2: return "vgui/white_additive"; + case 1: return "debug/debugwireframe"; + case 2: return "debug/additivevertexcolorvertexalpha"; case 3: return "debug/debugtranslucentsinglecolor"; - case 4: return "vgui/white"; + case 4: return "debug/debugtranslucentvertexcolor"; + case 5: return "debug/debugmrmfullbright2"; default: return "models/debug/debugwhite"; } } @@ -212,17 +213,26 @@ const char *chams_material_name(int idx) { void *chams_material() { int idx = g_chams_mat_index; if (idx < 0) idx = 0; - if (idx > 4) idx = 4; + if (idx > 5) idx = 5; if (g_chams_mat && g_chams_mat_idx == idx) return g_chams_mat; g_chams_mat = world_find_material(chams_material_name(idx)); if (!g_chams_mat) - g_chams_mat = world_find_material("models/debug/debugwhite"); + g_chams_mat = world_find_material("debug/debugtranslucentsinglecolor"); g_chams_mat_idx = idx; logf("chams: style %d -> %p", idx, g_chams_mat); return g_chams_mat; } +// Viewmodels need a model shader; the VGUI white materials used by some +// styles do not draw skinned models and make the hands/weapon disappear. +void *viewmodel_material() { + static void *mat = nullptr; + if (!mat) + mat = world_find_material("debug/debugtranslucentsinglecolor"); + return mat; +} + void chams_color(void *mat, float r, float g, float b) { using ColorFn = void (*)(void *, float, float, float); using FindVarFn = void *(*)(void *, const char *, bool *, bool); @@ -257,7 +267,7 @@ void hkdModelExecute(void *self, const void *state, const void *info, bool is_npc = esp_is_npc_index(idx); bool is_vm = g_chams_viewmodel && esp_is_viewmodel_index(idx); if (is_npc || is_vm) { - void *mat = chams_material(); + void *mat = is_vm ? viewmodel_material() : chams_material(); if (mat) { if (g_chams_walls && !is_vm) { chams_apply(mat, true); diff --git a/src/world.cpp b/src/world.cpp index a2e65cc..d071281 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -1065,7 +1065,8 @@ void *world_find_material(const char *name) { logf("chams: material %s = %p", name, mat); return mat; } - static const char *fallbacks[] = {"models/debug/debugwhite", "vgui/white", + static const char *fallbacks[] = {"debug/debugtranslucentsinglecolor", + "models/debug/debugwhite", "vgui/white", nullptr}; for (int i = 0; fallbacks[i]; i++) { mat = walk(fallbacks[i]); -- cgit v1.2.3