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. --- src/studio.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src/studio.cpp') 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); -- cgit v1.2.3