summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-11-04 18:17:55 +0100
committersalmonik <salmonik@tuta.io>2026-11-04 18:17:55 +0100
commit892329ec78acf4d4d63749e8c248227aabc2aded (patch)
tree187490c992e028221599e43d1846399c4c34462d
parentChams: exact material styles, GUI dropdown, viewmodel hookup (diff)
downloadhl2h-892329ec78acf4d4d63749e8c248227aabc2aded.tar.gz
hl2h-892329ec78acf4d4d63749e8c248227aabc2aded.zip
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.
-rw-r--r--CONTEXT.md16
-rw-r--r--src/gui.cpp4
-rw-r--r--src/menu.cpp2
-rw-r--r--src/studio.cpp22
-rw-r--r--src/world.cpp3
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.
299- Material lookup walks the `IMaterialSystem` list (`world_find_material`), with 299- Material lookup walks the `IMaterialSystem` list (`world_find_material`), with
300 `FindMaterial` (slot 71) as the fallback. The **exact requested style** is 300 `FindMaterial` (slot 71) as the fallback. The **exact requested style** is
301 tried first (resident, then loaded on demand), and only if that fails does it 301 tried first (resident, then loaded on demand), and only if that fails does it
302 fall back to `models/debug/debugwhite`/`vgui/white`. Styles: Flat, Wireframe, 302 fall back to `debug/debugtranslucentsinglecolor`/debugwhite/vgui white.
303 Additive glow, Solid, White. The chosen material name is logged. 303 Styles: 0 Flat (`models/debug/debugwhite`), 1 Wireframe
304- `Viewmodel (hands/weapon)` also applies the override to entities whose class 304 (`debug/debugwireframe`), 2 Additive (`debug/additivevertexcolorvertexalpha`),
305 contains `viewmodel` or whose model path is `.../v_...`. The viewmodel gets 305 3 Solid (`debug/debugtranslucentsinglecolor`), 4 White
306 only the normal-depth pass (no ignorez). 306 (`debug/debugtranslucentvertexcolor`), 5 Fullbright
307 (`debug/debugmrmfullbright2`). The chosen material name is logged.
308- `Viewmodel (hands/weapon)` applies the override to entities whose class
309 contains `viewmodel` or whose model path is `.../v_...`. Viewmodels always
310 use the model-safe solid material (`debug/debugtranslucentsinglecolor`);
311 VGUI/white materials do not draw skinned models and made the hands/weapon
312 disappear. Only the normal-depth pass is used.
307- Feature is off by default; `[chams] active/bind/walls/viewmodel/material/r/g/b`, 313- Feature is off by default; `[chams] active/bind/walls/viewmodel/material/r/g/b`,
308 with Through walls, Viewmodel, a Material dropdown and colour in the Visuals 314 with Through walls, Viewmodel, a Material dropdown and colour in the Visuals
309 card. 315 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() {
454 "Apply chams to the first-person hands and weapon too.", 454 "Apply chams to the first-person hands and weapon too.",
455 &g_chams_viewmodel); 455 &g_chams_viewmodel);
456 static const char *const chams_mat_names[] = { 456 static const char *const chams_mat_names[] = {
457 "Flat", "Wireframe", "Additive glow", "Solid", "White"}; 457 "Flat", "Wireframe", "Additive glow", "Solid", "White", "Fullbright"};
458 add_dropdown(chams, "Material", "Chams material.", chams_mat_names, 5, 458 add_dropdown(chams, "Material", "Chams material.", chams_mat_names, 6,
459 &g_chams_mat_index); 459 &g_chams_mat_index);
460 add_color(chams, "Colour", "Chams colour.", g_chams_rgb); 460 add_color(chams, "Colour", "Chams colour.", g_chams_rgb);
461 int view = add_card(2, nullptr, "Camera / display", 461 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() {
402 else if (strcmp(key, "material") == 0) { 402 else if (strcmp(key, "material") == 0) {
403 int v = atoi(val); 403 int v = atoi(val);
404 if (v < 0) v = 0; 404 if (v < 0) v = 0;
405 if (v > 4) v = 4; 405 if (v > 5) v = 5;
406 g_chams_mat_index = v; 406 g_chams_mat_index = v;
407 } else if (strcmp(key, "r") == 0 || strcmp(key, "g") == 0 || 407 } else if (strcmp(key, "r") == 0 || strcmp(key, "g") == 0 ||
408 strcmp(key, "b") == 0) { 408 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;
201 201
202const char *chams_material_name(int idx) { 202const char *chams_material_name(int idx) {
203 switch (idx) { 203 switch (idx) {
204 case 1: return "debug/debugwireframevertexcolorignorez"; 204 case 1: return "debug/debugwireframe";
205 case 2: return "vgui/white_additive"; 205 case 2: return "debug/additivevertexcolorvertexalpha";
206 case 3: return "debug/debugtranslucentsinglecolor"; 206 case 3: return "debug/debugtranslucentsinglecolor";
207 case 4: return "vgui/white"; 207 case 4: return "debug/debugtranslucentvertexcolor";
208 case 5: return "debug/debugmrmfullbright2";
208 default: return "models/debug/debugwhite"; 209 default: return "models/debug/debugwhite";
209 } 210 }
210} 211}
@@ -212,17 +213,26 @@ const char *chams_material_name(int idx) {
212void *chams_material() { 213void *chams_material() {
213 int idx = g_chams_mat_index; 214 int idx = g_chams_mat_index;
214 if (idx < 0) idx = 0; 215 if (idx < 0) idx = 0;
215 if (idx > 4) idx = 4; 216 if (idx > 5) idx = 5;
216 if (g_chams_mat && g_chams_mat_idx == idx) 217 if (g_chams_mat && g_chams_mat_idx == idx)
217 return g_chams_mat; 218 return g_chams_mat;
218 g_chams_mat = world_find_material(chams_material_name(idx)); 219 g_chams_mat = world_find_material(chams_material_name(idx));
219 if (!g_chams_mat) 220 if (!g_chams_mat)
220 g_chams_mat = world_find_material("models/debug/debugwhite"); 221 g_chams_mat = world_find_material("debug/debugtranslucentsinglecolor");
221 g_chams_mat_idx = idx; 222 g_chams_mat_idx = idx;
222 logf("chams: style %d -> %p", idx, g_chams_mat); 223 logf("chams: style %d -> %p", idx, g_chams_mat);
223 return g_chams_mat; 224 return g_chams_mat;
224} 225}
225 226
227// Viewmodels need a model shader; the VGUI white materials used by some
228// styles do not draw skinned models and make the hands/weapon disappear.
229void *viewmodel_material() {
230 static void *mat = nullptr;
231 if (!mat)
232 mat = world_find_material("debug/debugtranslucentsinglecolor");
233 return mat;
234}
235
226void chams_color(void *mat, float r, float g, float b) { 236void chams_color(void *mat, float r, float g, float b) {
227 using ColorFn = void (*)(void *, float, float, float); 237 using ColorFn = void (*)(void *, float, float, float);
228 using FindVarFn = void *(*)(void *, const char *, bool *, bool); 238 using FindVarFn = void *(*)(void *, const char *, bool *, bool);
@@ -257,7 +267,7 @@ void hkdModelExecute(void *self, const void *state, const void *info,
257 bool is_npc = esp_is_npc_index(idx); 267 bool is_npc = esp_is_npc_index(idx);
258 bool is_vm = g_chams_viewmodel && esp_is_viewmodel_index(idx); 268 bool is_vm = g_chams_viewmodel && esp_is_viewmodel_index(idx);
259 if (is_npc || is_vm) { 269 if (is_npc || is_vm) {
260 void *mat = chams_material(); 270 void *mat = is_vm ? viewmodel_material() : chams_material();
261 if (mat) { 271 if (mat) {
262 if (g_chams_walls && !is_vm) { 272 if (g_chams_walls && !is_vm) {
263 chams_apply(mat, true); 273 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) {
1065 logf("chams: material %s = %p", name, mat); 1065 logf("chams: material %s = %p", name, mat);
1066 return mat; 1066 return mat;
1067 } 1067 }
1068 static const char *fallbacks[] = {"models/debug/debugwhite", "vgui/white", 1068 static const char *fallbacks[] = {"debug/debugtranslucentsinglecolor",
1069 "models/debug/debugwhite", "vgui/white",
1069 nullptr}; 1070 nullptr};
1070 for (int i = 0; fallbacks[i]; i++) { 1071 for (int i = 0; fallbacks[i]; i++) {
1071 mat = walk(fallbacks[i]); 1072 mat = walk(fallbacks[i]);