diff options
| author | salmonik <salmonik@tuta.io> | 2026-11-04 14:11:40 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-11-04 14:11:40 +0100 |
| commit | 592b865ca5c98d1df2153ea5b77f67aa8a76db60 (patch) | |
| tree | 4fb957603dba3bc57d316168f074410bdef3e70f /src/hl2h.cpp | |
| parent | Gamma: clamp slider to the engine's 2.6 cap, defer readback (diff) | |
| download | hl2h-592b865ca5c98d1df2153ea5b77f67aa8a76db60.tar.gz hl2h-592b865ca5c98d1df2153ea5b77f67aa8a76db60.zip | |
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.
Diffstat (limited to 'src/hl2h.cpp')
| -rw-r--r-- | src/hl2h.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
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) { | |||
| 698 | pending_gamma % 10, got); | 698 | pending_gamma % 10, got); |
| 699 | pending_gamma = -1; | 699 | pending_gamma = -1; |
| 700 | } | 700 | } |
| 701 | // In-engine brightness for HDR maps. Unlike mat_monitorgamma this does not | ||
| 702 | // depend on the window system applying a gamma ramp. | ||
| 703 | static int last_tonemap = 0; | ||
| 704 | static int pending_tonemap = -1; | ||
| 705 | if (g_tonemap != last_tonemap) { | ||
| 706 | char cmd[64]; | ||
| 707 | if (g_tonemap == 0) | ||
| 708 | snprintf(cmd, sizeof(cmd), "mat_force_tonemap_scale 0"); | ||
| 709 | else | ||
| 710 | snprintf(cmd, sizeof(cmd), "mat_force_tonemap_scale %d.%d", | ||
| 711 | g_tonemap / 10, g_tonemap % 10); | ||
| 712 | console_cmd(cmd); | ||
| 713 | pending_tonemap = g_tonemap; | ||
| 714 | last_tonemap = g_tonemap; | ||
| 715 | } | ||
| 716 | if (pending_tonemap >= 0) { | ||
| 717 | float got = -1.0f; | ||
| 718 | if (g_iface.cvar) { | ||
| 719 | using FindFn = void *(*)(void *, const char *); | ||
| 720 | void *v = vfunc<FindFn>(g_iface.cvar, 12)(g_iface.cvar, | ||
| 721 | "mat_force_tonemap_scale"); | ||
| 722 | if (v) | ||
| 723 | got = *(float *)((uintptr_t)v + 0x2c); | ||
| 724 | } | ||
| 725 | logf("view: tonemap request %d.%d, cvar reports %.2f", | ||
| 726 | pending_tonemap / 10, pending_tonemap % 10, got); | ||
| 727 | pending_tonemap = -1; | ||
| 728 | } | ||
| 701 | } | 729 | } |
| 702 | 730 | ||
| 703 | // --------------------------------------------------------------------------- | 731 | // --------------------------------------------------------------------------- |
