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]. --- CONTEXT.md | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'CONTEXT.md') diff --git a/CONTEXT.md b/CONTEXT.md index fb97636..ce4a02e 100644 --- a/CONTEXT.md +++ b/CONTEXT.md @@ -295,14 +295,33 @@ vocabulary / decisions. - Visuals card with the usual Active + Bind. Unbound and Active means always on; a bind makes it a hold-to-brighten key. -- Applies the client `mat_fullbright` cvar to 1/0 through `VEngineCvar004` - (`FindVar` slot 12, `ConVar::SetValue(int)` slot 11), which bypasses the - console cheat gate. No server-side writes. +- Applies the client `mat_fullbright` cvar to 1/0 through + `IVEngineClient::ClientCmd` (slot 7), which bypasses the console cheat gate + and avoids the crashing direct `ConVar` vtable path. No server-side writes. - Re-applied after map loads/respawns (`fullbright_invalidate` on local entity change) and saved as `[fullbright] active/bind`. - `fullbright: on/off` is logged; a missing cvar interface raises an error toast instead of failing silently. +### World tint (material colour modulation) + +- Same idea as Amalgam's world modulation: find `IMaterialSystem` in the + already-loaded `materialsystem.so` and walk every material with + `FirstMaterial` / `NextMaterial` / `GetMaterial`. +- `IMaterial::ColorModulate(r,g,b)` is applied to materials whose + `GetTextureGroupName()` is `World textures` (sky names excluded) and to + `SkyBox textures` (or names containing `sky`). Lightmaps are not touched. +- Slot map (2013 SDK layout, registered under `VMaterialSystem080`): + `IMaterialSystem` 73/74/75/76/77 = First/Next/Invalid/Get/GetNumMaterials; + `IMaterial` 0/1/28 = GetName/GetTextureGroupName/ColorModulate. +- `src/world.cpp`; the walk runs only when the enabled groups or colours + change, and re-applies after level changes via `world_tint_invalidate()`. + Disabling restores white, so no reload is needed. +- Validation before any walk: `GetNumMaterials()` must return 1..200000; the + first material's name/group must be printable strings. A mismatch logs and + toasts instead of poking garbage. +- Saved as `[worldtint] active/bind/world/sky/wr..wb/sr..sb`. + ## Logging - `/tmp/hl2hake.log` is opened once at startup with `"w"` (so it only contains -- cgit v1.2.3