summaryrefslogtreecommitdiffstats
path: root/src/studio.cpp
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 /src/studio.cpp
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.
Diffstat (limited to 'src/studio.cpp')
-rw-r--r--src/studio.cpp22
1 files changed, 16 insertions, 6 deletions
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);