From 9c4455af43da34127864b09ad2a3d3e996c9dce1 Mon Sep 17 00:00:00 2001 From: salmonik Date: Tue, 3 Nov 2026 23:58:59 +0100 Subject: World: replace skybox changer with a PNG skybox image sv_skyname did not take effect at runtime in this build, so the Skybox card now replaces the skybox materials' textures with /skybox.png. The PNG is decoded through libpng16's simplified API (dlopen'ed, so no new link dependency) and uploaded with IMaterialSystem::CreateTextureFromBits as an RGBA8888 texture. IMaterialVar::SetTextureValue assigns it to $basetexture and the HDR variants for every material in the SkyBox textures group (all six faces get the same image). Original textures are recorded per material/var (texture pointer plus string fallback) and restored when the feature is off. Records survive level changes so a reused sky material is still restorable; the override is re-applied to a new map automatically. The card shows the image path and has a Reload image button; a missing/unreadable PNG raises an error toast. --- CONTEXT.md | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'CONTEXT.md') diff --git a/CONTEXT.md b/CONTEXT.md index f2b091a..a490403 100644 --- a/CONTEXT.md +++ b/CONTEXT.md @@ -358,20 +358,25 @@ vocabulary / decisions. - End is clamped above Start. Re-applied on level change via `fog_invalidate()`. Saved as `[fog] active/bind/r/g/b/start/end/skybox/disable`. -### Skybox changer - -- `sv_skyname ` through `ClientCmd`, the same mechanism the stock - `skybox_swapper` entity uses. Choice list is the HL2 skybox set from the - game's VPK (no episode-only skies, so a selected sky always exists). -- Before the first override of a map, the map's own sky is captured by - scanning loaded materials in the `SkyBox textures` group and parsing - `skybox/(_hdr|_ldr)?(rt|bk|lf|ft|up|dn)`. Disabling the feature (or - choosing "Map default") restores that name; a level change also restores it - naturally, so `skybox_invalidate()` just drops the captured state. -- Changing the sky invalidates the world tint so the freshly loaded sky - materials get the sky colour. -- Saved as `[skybox] active/bind/choice`. The GUI uses a `CK_CHOICE` - control (value box with `<`/`>` hit zones). +### Skybox image + +- Replaces the map skybox with `/skybox.png` (same directory as + the INI). Not `sv_skyname`: that did not take effect at runtime in this + build, so the skybox card now works on materials instead. +- PNG is decoded with libpng16's simplified API (`dlopen`ed, no link + dependency); the RGBA pixels become an `ITexture` via + `IMaterialSystem::CreateTextureFromBits` (RGBA8888, one mip). +- The texture is assigned with `IMaterialVar::SetTextureValue` to + `$basetexture`, plus `$hdrbasetexture` / `$hdrcompressedtexture` when those + vars exist, on every material in the `SkyBox textures` group or named + `skybox/*`. The same image is mapped onto all six faces. +- Original textures are recorded per material/var (texture pointer plus the + string as a fallback) and restored when the feature is disabled. Records + survive level changes so a reused sky material can still be restored; the + override is re-applied to the new map automatically. +- The card shows the image path and has a Reload image button. A missing or + unreadable PNG raises an error toast; the image is only re-read on Reload. +- Saved as `[skybox] active/bind`. ## Logging -- cgit v1.2.3