From 592b865ca5c98d1df2153ea5b77f67aa8a76db60 Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 4 Nov 2026 14:11:40 +0100 Subject: Add HDR tonemap brightness slider The engine applies mat_monitorgamma (SDL receives changing ramp midpoints), but Wayland/XWayland compositors discard the window gamma ramp, so the gamma slider has no visible effect there. Add an in-engine brightness control that does not depend on the window system: mat_force_tonemap_scale, exposed as "HDR brightness" (x10, 0 = automatic). Drop the temporary SDL gamma ramp diagnostic. --- src/hl2h.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/hl2h.cpp') diff --git a/src/hl2h.cpp b/src/hl2h.cpp index 1fc7096..a037bac 100644 --- a/src/hl2h.cpp +++ b/src/hl2h.cpp @@ -698,6 +698,34 @@ static void view_settings_apply(void *ent) { 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. + static int last_tonemap = 0; + static int pending_tonemap = -1; + if (g_tonemap != last_tonemap) { + char cmd[64]; + if (g_tonemap == 0) + snprintf(cmd, sizeof(cmd), "mat_force_tonemap_scale 0"); + else + snprintf(cmd, sizeof(cmd), "mat_force_tonemap_scale %d.%d", + g_tonemap / 10, g_tonemap % 10); + console_cmd(cmd); + pending_tonemap = g_tonemap; + last_tonemap = g_tonemap; + } + if (pending_tonemap >= 0) { + 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_force_tonemap_scale"); + if (v) + got = *(float *)((uintptr_t)v + 0x2c); + } + logf("view: tonemap request %d.%d, cvar reports %.2f", + pending_tonemap / 10, pending_tonemap % 10, got); + pending_tonemap = -1; + } } // --------------------------------------------------------------------------- -- cgit v1.2.3