From 0cbcbfc14997eff39e0c76acf30c48b851ed1f62 Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 4 Nov 2026 22:09:14 +0100 Subject: Chams: working alpha via RenderView blend and a custom VMT Testing on :99 showed the material $alpha path is a dead end: UnlitGeneric takes translucency from the base texture/vertex alpha, and the debug materials have neither. Follow Amalgam: apply alpha with IVRenderView::SetBlend (VEngineRenderView014 slot 4) around the model draw, saving/restoring it. To have something translucent to blend, write a tiny UnlitGeneric VMT with $model 1 + $translucent 1 + a white base texture to //materials/hl2hake/translucent.vmt (plus a custom/ copy). It is written by a preload constructor so it exists before the material system scans its search paths, then loaded once with FindMaterial. Styles 0/3/4/6 use it when the colour alpha is below 255. Also: - Visible wireframe + through-wall: fill the visible silhouette first so the through-wall pass cannot show in the wireframe gaps, then draw a brightened contour. Style 6 is now "Solid + contour" (recolour + visible edges). - find_modules builds local snapshots and publishes them under a mutex; the setup thread and the server retry could reset the shared vectors live and crash at startup. Verified on :99: Solid + alpha 64 renders a see-through viewmodel, Solid + contour shows a blue fill with bright blue contours, Additive is a translucent coloured glow and Fullbright is a white additive glow. --- src/modules.cpp | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'src/modules.cpp') diff --git a/src/modules.cpp b/src/modules.cpp index b832694..7a82028 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -1,8 +1,11 @@ // modules.cpp — /proc/self/maps parsing and module discovery #include "hl2h.h" #include +#include #include +static std::mutex g_modules_mutex; + static bool basename_is(const char *path, const char *base) { size_t pl = strlen(path), bl = strlen(base); if (pl < bl || strcmp(path + pl - bl, base) != 0) @@ -11,9 +14,7 @@ static bool basename_is(const char *path, const char *base) { } void find_modules() { - g_client = Module(); - g_engine = Module(); - g_server = Module(); + Module client, engine, server; FILE *f = fopen("/proc/self/maps", "r"); if (!f) return; @@ -41,19 +42,19 @@ void find_modules() { memcpy(clean, path, pl); clean[pl] = 0; if (basename_is(clean, "client.so")) - m = &g_client; + m = &client; else if (basename_is(clean, "engine.so")) - m = &g_engine; + m = &engine; else if (basename_is(clean, "server.so")) - m = &g_server; + m = &server; } else { // anon: absorb only as .bss tail after a file-backed range - if (g_client.valid() && g_client.ranges.back().file && - lo == g_client.ranges.back().hi && hi - lo <= 0x1000000) - m = &g_client; - else if (g_engine.valid() && g_engine.ranges.back().file && - lo == g_engine.ranges.back().hi && hi - lo <= 0x1000000) - m = &g_engine; + if (client.valid() && client.ranges.back().file && + lo == client.ranges.back().hi && hi - lo <= 0x1000000) + m = &client; + else if (engine.valid() && engine.ranges.back().file && + lo == engine.ranges.back().hi && hi - lo <= 0x1000000) + m = &engine; } if (!m) continue; @@ -71,6 +72,16 @@ void find_modules() { } } fclose(f); + // setup_thread and resolve_server_netvars can both call this; the old code + // reset the shared Module globals and reallocated their vectors live, which + // crashed under the startup thread. Publish complete snapshots instead. + std::lock_guard lock(g_modules_mutex); + if (client.valid()) + g_client = std::move(client); + if (engine.valid()) + g_engine = std::move(engine); + if (server.valid()) + g_server = std::move(server); } // --------------------------------------------------------------------------- -- cgit v1.2.3