From 35bbdf5ee97961ecca7cda2c3ad98aed558ace60 Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 4 Nov 2026 14:15:49 +0100 Subject: Remove gamma slider; keep HDR brightness Wayland/XWayland discards window gamma ramps, so mat_monitorgamma could not work on the development setup. Drop the slider, config key and readback. Keep the in-engine HDR tonemap brightness and document that Fullbright turns tonemapping off. --- CONTEXT.md | 22 ++++++++++------------ src/gui.cpp | 25 +++---------------------- src/hl2h.cpp | 32 ++++---------------------------- src/hl2h.h | 1 - src/menu.cpp | 11 ++--------- 5 files changed, 19 insertions(+), 72 deletions(-) diff --git a/CONTEXT.md b/CONTEXT.md index e0af84a..5c91b5c 100644 --- a/CONTEXT.md +++ b/CONTEXT.md @@ -21,7 +21,7 @@ covers ESP, aimbot, triggerbot and silent aim. - `HL2H_NO_SERVER=1` — disable server-side health reads. - Config: `$XDG_CONFIG_HOME/hl2hake/config`, falling back to `~/.config/hl2hake/config`. Plain INI, saved on every change. New sections: - `[view]` (camera FOV, viewmodel FOV, gamma x10) and `[movement]` + `[view]` (camera FOV, viewmodel FOV, HDR brightness) and `[movement]` (crouch-jump, edge jump). ## Runtime architecture @@ -237,19 +237,17 @@ vocabulary / decisions. client netvar every tick. The camera slider is 40..140 (stock 75) and the viewmodel slider 20..120 (stock 54); 0 is not allowed (old configs with 0 migrate to the stock value). -- `viewmodel_fov` and `mat_monitorgamma` are client cvars; applied through - `ClientCmd` when their slider changes. Gamma is stored as x10 - (`[view] gamma=22` = 2.2) and the slider stops at 26 because the engine - clamps `mat_monitorgamma` at 2.6. The value is read back through - `ICvar::FindVar` on the next tick (ClientCmd is queued) and logged. The - engine does apply the ramp (`SDL_SetWindowGammaRamp` was called with - changing midpoints), but a Wayland/XWayland compositor discards it, so on - this setup the slider has no visible effect. +- `viewmodel_fov` is a client cvar, applied through `ClientCmd` when its + slider changes. - `HDR brightness` (`[view] tonemap`, x10, 0 = automatic) sets `mat_force_tonemap_scale`. This is in-engine tonemapping for HDR maps and - does not depend on the window system applying a gamma ramp; 10 = 1.0. - Both live in the always-on `Camera / display` card - (`[view] fov/vmfov/gamma/tonemap`). + does not depend on the window system; 10 = 1.0. It has no visible effect + while Fullbright is on (fullbright bypasses tonemapping). +- `mat_monitorgamma` was tried and removed: the engine applies the ramp (SDL + receives changing midpoints), but Wayland/XWayland compositors discard + window gamma ramps, so the slider did nothing on the development setup. +- Both controls live in the always-on `Camera / display` card + (`[view] fov/vmfov/tonemap`). ## Map transitions diff --git a/src/gui.cpp b/src/gui.cpp index 83dc0a5..59c4364 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -411,20 +411,17 @@ static void build_cards() { g_ctrls[g_nctrl - 1].zero_unlimited = true; int view = add_card(2, nullptr, "Camera / display", - "Camera FOV, viewmodel FOV and monitor gamma.", true); + "Camera FOV, viewmodel FOV and HDR brightness.", true); add_slider(view, "Camera FOV", "World camera field of view (40-140; stock 75).", 40, 140, &g_fov_camera); add_slider(view, "Viewmodel FOV", "Weapon model field of view (20-120; stock 54).", 20, 120, &g_fov_viewmodel); - add_slider(view, "Gamma x10", - "mat_monitorgamma x10: 16 = 1.6, 26 = 2.6 (engine max), stock " - "is 22. Uses the OS gamma ramp; some compositors ignore it.", - 16, 26, &g_gamma); add_slider(view, "HDR brightness", "mat_force_tonemap_scale x10 (0 = automatic). In-engine " - "brightness for HDR maps; 10 = 1.0.", + "brightness for HDR maps; 10 = 1.0. No effect while Fullbright " + "is on.", 0, 30, &g_tonemap); add_card(2, &g_fullbright, "Fullbright", @@ -2245,22 +2242,6 @@ SDL_WarpMouseGlobal(int x, int y) { real_warp_global(x, y); } -// Diagnostic: tell whether mat_monitorgamma reaches the SDL gamma ramp at all. -static int (*real_set_gamma_ramp)(void *, const unsigned short *, - const unsigned short *, - const unsigned short *) = nullptr; - -extern "C" __attribute__((visibility("default"))) int -SDL_SetWindowGammaRamp(void *window, const unsigned short *r, - const unsigned short *g, const unsigned short *b) { - if (!real_set_gamma_ramp) - real_set_gamma_ramp = (int (*)(void *, const unsigned short *, - const unsigned short *, - const unsigned short *))dlsym( - RTLD_NEXT, "SDL_SetWindowGammaRamp"); - return real_set_gamma_ramp ? real_set_gamma_ramp(window, r, g, b) : -1; -} - static unsigned int (*real_get_rel_mouse)(int *, int *) = nullptr; static int (*real_poll_event)(void *) = nullptr; diff --git a/src/hl2h.cpp b/src/hl2h.cpp index a037bac..ca7ee85 100644 --- a/src/hl2h.cpp +++ b/src/hl2h.cpp @@ -655,13 +655,13 @@ static void install_uniform_random_hook() { } // --------------------------------------------------------------------------- -// camera / viewmodel FOV and gamma +// camera / viewmodel FOV and HDR brightness // --------------------------------------------------------------------------- // // The rendered camera FOV is derived from C_BasePlayer::m_iDefaultFOV every // frame (CViewRender::OnRenderStart copies it into default_fov), so writing // the client netvar is enough and needs no server command. The viewmodel FOV -// and monitor gamma are plain client cvars. +// is a plain client cvar. static void view_settings_apply(void *ent) { if (g_net.default_fov >= 0 && ent) @@ -673,33 +673,9 @@ static void view_settings_apply(void *ent) { console_cmd(cmd); last_vm = g_fov_viewmodel; } - static int last_gamma = 22; - static int pending_gamma = -1; - if (g_gamma != last_gamma) { - char cmd[48]; - snprintf(cmd, sizeof(cmd), "mat_monitorgamma %d.%d", g_gamma / 10, - g_gamma % 10); - console_cmd(cmd); - pending_gamma = g_gamma; - last_gamma = g_gamma; - } - if (pending_gamma >= 0) { - // ClientCmd is queued, so read the cvar on the next tick to see the value - // the engine actually accepted (it clamps mat_monitorgamma at 2.6). - float got = -1.0f; - if (g_iface.cvar) { - using FindFn = void *(*)(void *, const char *); - void *v = vfunc(g_iface.cvar, 12)(g_iface.cvar, - "mat_monitorgamma"); - if (v) - got = *(float *)((uintptr_t)v + 0x2c); // ConVar m_Value.f - } - logf("view: gamma request %d.%d, cvar reports %.2f", pending_gamma / 10, - pending_gamma % 10, got); - pending_gamma = -1; - } // In-engine brightness for HDR maps. Unlike mat_monitorgamma this does not - // depend on the window system applying a gamma ramp. + // depend on the window system applying a gamma ramp. Fullbright bypasses + // tonemapping, so the slider only has a visible effect while it is off. static int last_tonemap = 0; static int pending_tonemap = -1; if (g_tonemap != last_tonemap) { diff --git a/src/hl2h.h b/src/hl2h.h index a050feb..f1e72be 100644 --- a/src/hl2h.h +++ b/src/hl2h.h @@ -248,7 +248,6 @@ extern bool g_auto_crouchjump; extern bool g_edge_jump; extern int g_fov_camera; extern int g_fov_viewmodel; -extern int g_gamma; extern int g_tonemap; extern int g_esp_col_hostile[3]; extern int g_esp_col_neutral[3]; diff --git a/src/menu.cpp b/src/menu.cpp index 033c0f9..020d2c5 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -81,7 +81,6 @@ bool g_auto_crouchjump = false; bool g_edge_jump = false; int g_fov_camera = 75; // HL2's stock camera FOV int g_fov_viewmodel = 54; // HL2's stock viewmodel FOV -int g_gamma = 22; // mat_monitorgamma x10, stock 2.2 int g_tonemap = 0; // mat_force_tonemap_scale x10, 0 = automatic int g_esp_col_hostile[3] = {255, 60, 60}; int g_esp_col_neutral[3] = {220, 220, 220}; @@ -249,8 +248,8 @@ void config_save() { g_esp_col_neutral[0], g_esp_col_neutral[1], g_esp_col_neutral[2], g_esp_col_friendly[0], g_esp_col_friendly[1], g_esp_col_friendly[2]); - fprintf(f, "[view]\nfov=%d\nvmfov=%d\ngamma=%d\ntonemap=%d\n", - g_fov_camera, g_fov_viewmodel, g_gamma, g_tonemap); + fprintf(f, "[view]\nfov=%d\nvmfov=%d\ntonemap=%d\n", g_fov_camera, + g_fov_viewmodel, g_tonemap); fprintf(f, "[movement]\ncrouchjump=%d\nedgejump=%d\n", (int)g_auto_crouchjump, (int)g_edge_jump); gui_config_write(f); @@ -405,11 +404,6 @@ static bool config_load() { lo = 20; hi = 120; stock = 54; - } else if (strcmp(key, "gamma") == 0) { - dst = &g_gamma; - lo = 16; - hi = 26; // the engine clamps mat_monitorgamma at 2.6 - stock = 22; } else if (strcmp(key, "tonemap") == 0) { dst = &g_tonemap; lo = 0; @@ -610,7 +604,6 @@ void config_reset_defaults() { g_edge_jump = false; g_fov_camera = 75; g_fov_viewmodel = 54; - g_gamma = 22; g_tonemap = 0; g_esp_col_hostile[0] = 255; g_esp_col_hostile[1] = 60; -- cgit v1.2.3