From 1f7c91905f69baba0aca8265c84deaba2ddac98a Mon Sep 17 00:00:00 2001 From: salmonik Date: Tue, 3 Nov 2026 23:21:13 +0100 Subject: World: add world/sky material colour modulation Port Amalgam's modulation approach: obtain IMaterialSystem from the already loaded materialsystem.so (VMaterialSystem080) and walk materials with FirstMaterial/NextMaterial/GetMaterial. ColorModulate the "World textures" group (sky names excluded) and the "SkyBox textures"/sky-named group. The walk runs only when the enabled groups or colours change, restores white when disabled, and re-applies after level changes. Before touching materials, GetNumMaterials() and the first material's name/group are sanity-checked so a wrong vtable slot logs and aborts instead of walking garbage. GUI: "World tint" card with world/sky toggles and RGB sliders; config section [worldtint]. --- src/menu.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'src/menu.cpp') diff --git a/src/menu.cpp b/src/menu.cpp index 9a249f8..6a7ffe5 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -46,6 +46,11 @@ FeatureState g_triggerbot{true, 603}; // default Mouse4 FeatureState g_silentaim{true, 602}; // default Mouse3 FeatureState g_item_esp{true, 0}; // valuable item tags, always-on by default FeatureState g_fullbright{false, 0}; // mat_fullbright world lighting +FeatureState g_world_tint{false, 0}; // material colour modulation +bool g_tint_world_on = true; +bool g_tint_sky_on = true; +int g_tint_world_rgb[3] = {255, 255, 255}; +int g_tint_sky_rgb[3] = {255, 255, 255}; bool g_item_health = true; bool g_item_ammo = true; bool g_item_armor = true; @@ -187,6 +192,12 @@ void config_save() { g_silentaim.bind, g_silent_fov); fprintf(f, "[fullbright]\nactive=%d\nbind=%d\n", g_fullbright.active, g_fullbright.bind); + fprintf(f, "[worldtint]\nactive=%d\nbind=%d\nworld=%d\nsky=%d\n" + "wr=%d\nwg=%d\nwb=%d\nsr=%d\nsg=%d\nsb=%d\n", + g_world_tint.active, g_world_tint.bind, (int)g_tint_world_on, + (int)g_tint_sky_on, g_tint_world_rgb[0], g_tint_world_rgb[1], + g_tint_world_rgb[2], g_tint_sky_rgb[0], g_tint_sky_rgb[1], + g_tint_sky_rgb[2]); fprintf(f, "[items]\nactive=%d\nbind=%d\nhealth=%d\nammo=%d\n" "armor=%d\nweapons=%d\ncrates=%d\ndistance=%d\nmax_dist=%d\n", g_item_esp.active, g_item_esp.bind, (int)g_item_health, @@ -220,7 +231,8 @@ static bool config_load() { char line[256]; FeatureState *cur = nullptr; bool in_esp = false, in_bhop = false, in_aim = false, in_silent = false, - in_jumpbug = false, in_spread = false, in_items = false; + in_jumpbug = false, in_spread = false, in_items = false, + in_tint = false; while (fgets(line, sizeof(line), f)) { line[strcspn(line, "\r\n")] = 0; if (line[0] == '[') { @@ -240,6 +252,8 @@ static bool config_load() { cur = &g_item_esp; else if (strstr(line, "[fullbright]")) cur = &g_fullbright; + else if (strstr(line, "[worldtint]")) + cur = &g_world_tint; else if (strstr(line, "[aimbot]")) cur = &g_aimbot; else if (strstr(line, "[triggerbot]")) @@ -255,6 +269,7 @@ static bool config_load() { in_jumpbug = (cur == &g_jumpbug); in_spread = (cur == &g_spread); in_items = (cur == &g_item_esp); + in_tint = (cur == &g_world_tint); } else if (cur) { char *eq = strchr(line, '='); if (!eq) @@ -325,6 +340,25 @@ static bool config_load() { if (v > 180) v = 180; g_silent_fov = v; } + if (in_tint) { + if (strcmp(key, "world") == 0) + g_tint_world_on = atoi(val) != 0; + else if (strcmp(key, "sky") == 0) + g_tint_sky_on = atoi(val) != 0; + else if (strcmp(key, "wr") == 0 || strcmp(key, "wg") == 0 || + strcmp(key, "wb") == 0) { + int v = atoi(val); + if (v < 0) v = 0; + if (v > 255) v = 255; + g_tint_world_rgb[key[1] == 'r' ? 0 : key[1] == 'g' ? 1 : 2] = v; + } else if (strcmp(key, "sr") == 0 || strcmp(key, "sg") == 0 || + strcmp(key, "sb") == 0) { + int v = atoi(val); + if (v < 0) v = 0; + if (v > 255) v = 255; + g_tint_sky_rgb[key[1] == 'r' ? 0 : key[1] == 'g' ? 1 : 2] = v; + } + } if (in_esp) { if (strcmp(key, "neutral") == 0) g_esp_opt[ESP_OPT_SHOW_NEUTRAL] = atoi(val) != 0; @@ -378,6 +412,11 @@ void config_reset_defaults() { g_esp_opt[i] = true; g_item_esp = {true, 0}; g_fullbright = {false, 0}; + g_world_tint = {false, 0}; + g_tint_world_on = true; + g_tint_sky_on = true; + g_tint_world_rgb[0] = g_tint_world_rgb[1] = g_tint_world_rgb[2] = 255; + g_tint_sky_rgb[0] = g_tint_sky_rgb[1] = g_tint_sky_rgb[2] = 255; g_item_health = true; g_item_ammo = true; g_item_armor = true; @@ -495,7 +534,7 @@ static FeatureState *feature_state(int feature) { static FeatureState *feats[FEAT_COUNT] = { &g_bhop, &g_abh, &g_esp, &g_aimbot, &g_triggerbot, &g_silentaim, &g_jumpbug, &g_melee, &g_spread, &g_item_esp, - &g_fullbright}; + &g_fullbright, &g_world_tint}; if (feature < 0 || feature >= FEAT_COUNT) return nullptr; return feats[feature]; @@ -701,6 +740,7 @@ void fullbright_update() { void outer_draw() { poll_keyboard(); fullbright_update(); + world_tint_update(); gui_handle_input(); // HL2H_DRAW_TEST=1 draws a probe rect without needing the GUI open static bool draw_test = getenv("HL2H_DRAW_TEST") != nullptr; @@ -721,6 +761,7 @@ void outer_draw() { if (le != last_local) { last_local = le; font_reset = true; + world_tint_invalidate(); } } if (font_reset && g_font) { -- cgit v1.2.3