diff options
| author | salmonik <salmonik@tuta.io> | 2026-11-04 19:09:31 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-11-04 19:09:31 +0100 |
| commit | c15a74d39f87c73a35ca420450e2876db2c37deb (patch) | |
| tree | 288cfd29e66d64dcbb58418e657dec9773648a16 | |
| parent | Chams: fix the flat viewmodel, glow outline and fullbright styles (diff) | |
| download | hl2h-c15a74d39f87c73a35ca420450e2876db2c37deb.tar.gz hl2h-c15a74d39f87c73a35ca420450e2876db2c37deb.zip | |
Chams: use the model solid shader for flat, drop vgui/white
vgui/white is an UnlitGeneric with $vertexcolor/$vertexalpha, no basetexture
and no $model, so it renders nothing on model vertices; Flat was invisible on
the viewmodel and would be invisible on NPCs too. Flat now uses the solid
model shader with the FLAT flag. Remove the vgui/white probe.
| -rw-r--r-- | CONTEXT.md | 21 | ||||
| -rw-r--r-- | src/studio.cpp | 14 |
2 files changed, 12 insertions, 23 deletions
| @@ -295,17 +295,16 @@ vocabulary / decisions. | |||
| 295 | `IMaterial::SetMaterialVarFlag` (slot 29); colours use `$color`/`$color2` | 295 | `IMaterial::SetMaterialVarFlag` (slot 29); colours use `$color`/`$color2` |
| 296 | (IMaterialVar slot 11, SetVecValue 3-float slot 11) and `ColorModulate` | 296 | (IMaterialVar slot 11, SetVecValue 3-float slot 11) and `ColorModulate` |
| 297 | (slot 28). Shared materials are restored after each draw. | 297 | (slot 28). Shared materials are restored after each draw. |
| 298 | - Styles are built from the resident materials and material flags: | 298 | - Styles are built from `debug/debugtranslucentsinglecolor` (UnlitGeneric, |
| 299 | 0 Flat (`vgui/white` with FLAT on NPCs; the solid model shader with FLAT on | 299 | `$color`) and material flags: |
| 300 | the viewmodel, because VGUI materials do not draw skinned models), | 300 | 0 Flat (solid + FLAT), 1 Wireframe (`debug/debugwireframe`), 2 Additive |
| 301 | 1 Wireframe (`debug/debugwireframe`), 2 Additive | 301 | (+ ADDITIVE), 3 Solid, 4 White (colour forced white), 5 Fullbright |
| 302 | (`debug/debugtranslucentsinglecolor` + ADDITIVE), 3 Solid, 4 White (solid, | 302 | (ADDITIVE|SELFILLUM with the colour lifted toward white), 6 Glow outline |
| 303 | colour forced white), 5 Fullbright (solid + ADDITIVE|SELFILLUM with the | 303 | (solid plus a `debug/debugwireframe` contour pass drawn with ZNEARER |
| 304 | colour lifted toward white), 6 Glow outline (solid plus a | 304 | (1 << 10) and a brightened colour so the base cannot bury it). |
| 305 | `debug/debugwireframe` contour pass drawn with ZNEARER (1 << 10) and a | 305 | `vgui/white` is vertex-colour based and has no `$model`/`$basetexture`, so it |
| 306 | brightened colour so the base cannot bury it). `models/debug/debugwhite` is | 306 | is never used for chams; `models/debug/debugwhite` is EP2-only and the old |
| 307 | EP2-only and the old VGUI additive material is invisible on NPCs; the styles | 307 | VGUI additive material was invisible on NPCs. |
| 308 | no longer depend on them. | ||
| 309 | - Style materials are preloaded from `outer_draw` (throttled) and cached; the | 308 | - Style materials are preloaded from `outer_draw` (throttled) and cached; the |
| 310 | render hook never calls FindMaterial itself. A missing style uses solid. | 309 | render hook never calls FindMaterial itself. A missing style uses solid. |
| 311 | - Feature is off by default. Config sections: `[chams]` (active/bind), | 310 | - Feature is off by default. Config sections: `[chams]` (active/bind), |
diff --git a/src/studio.cpp b/src/studio.cpp index 301e781..4941142 100644 --- a/src/studio.cpp +++ b/src/studio.cpp | |||
| @@ -208,8 +208,8 @@ const char *chams_material_name(int idx) { | |||
| 208 | case 3: | 208 | case 3: |
| 209 | case 4: | 209 | case 4: |
| 210 | case 5: | 210 | case 5: |
| 211 | case 6: return "debug/debugtranslucentsinglecolor"; | 211 | case 6: |
| 212 | default: return "vgui/white"; // models/debug/debugwhite is EP2-only | 212 | default: return "debug/debugtranslucentsinglecolor"; |
| 213 | } | 213 | } |
| 214 | } | 214 | } |
| 215 | 215 | ||
| @@ -300,10 +300,6 @@ void hkdModelExecute(void *self, const void *state, const void *info, | |||
| 300 | if (style < 0) style = 0; | 300 | if (style < 0) style = 0; |
| 301 | if (style > 6) style = 6; | 301 | if (style > 6) style = 6; |
| 302 | void *mat = style_material(style); | 302 | void *mat = style_material(style); |
| 303 | // vgui/white (Flat) does not draw skinned models, so the viewmodel | ||
| 304 | // uses the solid model shader with the same FLAT flag. | ||
| 305 | if (is_vm && style == 0) | ||
| 306 | mat = viewmodel_material(); | ||
| 307 | if (!mat) | 303 | if (!mat) |
| 308 | return false; | 304 | return false; |
| 309 | bool white = style == 4; | 305 | bool white = style == 4; |
| @@ -367,16 +363,10 @@ static double chams_now() { | |||
| 367 | // the style VMTs. The render hook only reads the cached pointers. | 363 | // the style VMTs. The render hook only reads the cached pointers. |
| 368 | void chams_preload() { | 364 | void chams_preload() { |
| 369 | static double last = 0.0; | 365 | static double last = 0.0; |
| 370 | static bool probed = false; | ||
| 371 | double now = chams_now(); | 366 | double now = chams_now(); |
| 372 | if (now - last < 1.5) | 367 | if (now - last < 1.5) |
| 373 | return; | 368 | return; |
| 374 | last = now; | 369 | last = now; |
| 375 | if (!probed) { | ||
| 376 | probed = true; | ||
| 377 | void *probe = world_find_material("vgui/white"); | ||
| 378 | logf("chams: probe vgui/white = %p", probe); | ||
| 379 | } | ||
| 380 | for (int i = 0; i < 7; i++) { | 370 | for (int i = 0; i < 7; i++) { |
| 381 | if (g_style_mats[i]) | 371 | if (g_style_mats[i]) |
| 382 | continue; | 372 | continue; |
