From 0cbcbfc14997eff39e0c76acf30c48b851ed1f62 Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 4 Nov 2026 22:09:14 +0100 Subject: Chams: working alpha via RenderView blend and a custom VMT Testing on :99 showed the material $alpha path is a dead end: UnlitGeneric takes translucency from the base texture/vertex alpha, and the debug materials have neither. Follow Amalgam: apply alpha with IVRenderView::SetBlend (VEngineRenderView014 slot 4) around the model draw, saving/restoring it. To have something translucent to blend, write a tiny UnlitGeneric VMT with $model 1 + $translucent 1 + a white base texture to //materials/hl2hake/translucent.vmt (plus a custom/ copy). It is written by a preload constructor so it exists before the material system scans its search paths, then loaded once with FindMaterial. Styles 0/3/4/6 use it when the colour alpha is below 255. Also: - Visible wireframe + through-wall: fill the visible silhouette first so the through-wall pass cannot show in the wireframe gaps, then draw a brightened contour. Style 6 is now "Solid + contour" (recolour + visible edges). - find_modules builds local snapshots and publishes them under a mutex; the setup thread and the server retry could reset the shared vectors live and crash at startup. Verified on :99: Solid + alpha 64 renders a see-through viewmodel, Solid + contour shows a blue fill with bright blue contours, Additive is a translucent coloured glow and Fullbright is a white additive glow. --- CONTEXT.md | 46 +++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 15 deletions(-) (limited to 'CONTEXT.md') diff --git a/CONTEXT.md b/CONTEXT.md index 5b96c33..1e860bf 100644 --- a/CONTEXT.md +++ b/CONTEXT.md @@ -27,7 +27,10 @@ covers ESP, aimbot, triggerbot and silent aim. ## Runtime architecture - Modules from `/proc/self/maps`: `client.so`, `engine.so`, `server.so`. - PROT_NONE ranges excluded; file-backed bss tails merged. + PROT_NONE ranges excluded; file-backed bss tails merged. The scan builds + local Module snapshots and publishes them under a mutex, because the setup + thread and the server-netvar retry can call it concurrently (resetting the + shared vectors live used to crash at startup). - Calling convention: cdecl (i386); `this` is the first stack argument. - Hooks (copy-and-swap vtable, 256 slots): - `CHLClient` slot 21 `CreateMove`; slot 35 `FrameStageNotify`. @@ -294,30 +297,43 @@ vocabulary / decisions. alpha only. The through-wall pass uses `MATERIAL_VAR_IGNOREZ` (1 << 15) through `IMaterial::SetMaterialVarFlag` (slot 29); colours use `$color`/`$color2` (IMaterialVar slot 11, SetVecValue 3-float slot 11) and - `ColorModulate` (slot 28). `$alpha` is set through IMaterialVar slot 3 - (SetFloatValue). Shared materials are restored after each draw. + `ColorModulate` (slot 28). Alpha is applied with + `IVRenderView::SetBlend` (`VEngineRenderView014` slot 4, saved/restored + around the passes) — model draws take their final alpha from the render + view, not from material `$alpha`. `$alpha`/`AlphaModulate` are still set for + completeness. Shared materials are restored after each draw. - The GUI colour picker (`add_color_alpha`) has an alpha bar, checkerboard preview and `#RRGGBBAA` readout; plain `add_color` keeps the old opaque three-component behaviour. Chams colours are four ints (r, g, b, a). -- **Alpha is stored but has no visual effect yet.** The usable model - materials are opaque: `debug/debugtranslucentsinglecolor` has no - `$translucent`, and toggling `MATERIAL_VAR_TRANSLUCENT` (1 << 21) or - rebuilding the state snapshot does not change the static shader combo. - `debug/debugtranslucentvertexcolor`/`debug/debughitbox` are translucent but - need vertex colours and render nothing on skinned models. A custom VMT with - `$model 1` + `$translucent 1` (or a white basetexture) is needed to make the - alpha control real. +- Alpha needs a translucent model material, so the mod writes a tiny VMT: + `//materials/hl2hake/translucent.vmt` (and a copy under + `custom/hl2hake/...`): `UnlitGeneric` with `$basetexture sprites/white`, + `$color`, `$model 1`, `$translucent 1`, `$nocull 1`. It is written from a + preload constructor (so it exists before the material system scans) and + loaded with `FindMaterial`; styles 0/3/4/6 switch to it when the colour + alpha is below 255. The base-game `debugtranslucentsinglecolor` has no + `$translucent` and cannot do alpha; `debugtranslucentvertexcolor` and + `debug/debughitbox` need vertex colours and draw nothing on skinned models. - Styles: 0 Flat (`debug/debugtranslucentsinglecolor` + FLAT), 1 Wireframe - (`debug/debugwireframe`), 2 Additive + (`debug/debugwireframe`, brightened tint), 2 Additive (`debug/debugtranslucentmodelhulls`, whose VMT has `$additive 1` + `$color`; the ADDITIVE flag on the solid material did nothing), 3 Solid, 4 White (solid, colour forced white), 5 Fullbright (the additive material, colour - forced white, giving a white-hot glow), 6 Glow outline (solid plus a - `debug/debugwireframe` contour pass drawn with ZNEARER (1 << 10) and a - brightened colour so the base cannot bury it). + forced white, giving a white-hot glow), 6 Solid + contour (solid fill plus + a `debug/debugwireframe` contour pass drawn with ZNEARER (1 << 10) and a + brightened colour, so the entity is recoloured while its edges stay + readable). Style 6 is the requested "recolour the whole entity but show its + contours" look. `vgui/white` is vertex-colour based and has no `$model`/`$basetexture`, so it is never used for chams; `models/debug/debugwhite` is EP2-only and the old VGUI additive material was invisible on NPCs. +- Through-wall + visible wireframe: a wireframe visible pass leaves gaps, so + the through-wall fill showed inside the visible silhouette. When both passes + are on and the visible style is Wireframe, a solid fill of the visible + colour is drawn first, then the brightened wireframe contour. (The proper + alternative is stencil: visible writes stencil 1, through-wall tests + stencil == 0, as Amalgam does; the fill is simpler and gives the + solid+contour look.) - Style materials are preloaded from `outer_draw` (throttled) and cached; the render hook never calls FindMaterial itself. A missing style uses solid. `FindMaterial` can return an unreferenced material, so each cached material -- cgit v1.2.3