diff options
| author | salmonik <salmonik@tuta.io> | 2026-11-04 22:09:14 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-11-04 22:09:14 +0100 |
| commit | 0cbcbfc14997eff39e0c76acf30c48b851ed1f62 (patch) | |
| tree | 19a5b0996bdf9e096f79e9636ebb48b57e10e643 /CONTEXT.md | |
| parent | Chams: real additive material, addref cached materials (diff) | |
| download | hl2h-0cbcbfc14997eff39e0c76acf30c48b851ed1f62.tar.gz hl2h-0cbcbfc14997eff39e0c76acf30c48b851ed1f62.zip | |
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
<game>/<mod>/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.
Diffstat (limited to 'CONTEXT.md')
| -rw-r--r-- | CONTEXT.md | 46 |
1 files changed, 31 insertions, 15 deletions
| @@ -27,7 +27,10 @@ covers ESP, aimbot, triggerbot and silent aim. | |||
| 27 | ## Runtime architecture | 27 | ## Runtime architecture |
| 28 | 28 | ||
| 29 | - Modules from `/proc/self/maps`: `client.so`, `engine.so`, `server.so`. | 29 | - Modules from `/proc/self/maps`: `client.so`, `engine.so`, `server.so`. |
| 30 | PROT_NONE ranges excluded; file-backed bss tails merged. | 30 | PROT_NONE ranges excluded; file-backed bss tails merged. The scan builds |
| 31 | local Module snapshots and publishes them under a mutex, because the setup | ||
| 32 | thread and the server-netvar retry can call it concurrently (resetting the | ||
| 33 | shared vectors live used to crash at startup). | ||
| 31 | - Calling convention: cdecl (i386); `this` is the first stack argument. | 34 | - Calling convention: cdecl (i386); `this` is the first stack argument. |
| 32 | - Hooks (copy-and-swap vtable, 256 slots): | 35 | - Hooks (copy-and-swap vtable, 256 slots): |
| 33 | - `CHLClient` slot 21 `CreateMove`; slot 35 `FrameStageNotify`. | 36 | - `CHLClient` slot 21 `CreateMove`; slot 35 `FrameStageNotify`. |
| @@ -294,30 +297,43 @@ vocabulary / decisions. | |||
| 294 | alpha only. The through-wall pass uses `MATERIAL_VAR_IGNOREZ` (1 << 15) | 297 | alpha only. The through-wall pass uses `MATERIAL_VAR_IGNOREZ` (1 << 15) |
| 295 | through `IMaterial::SetMaterialVarFlag` (slot 29); colours use | 298 | through `IMaterial::SetMaterialVarFlag` (slot 29); colours use |
| 296 | `$color`/`$color2` (IMaterialVar slot 11, SetVecValue 3-float slot 11) and | 299 | `$color`/`$color2` (IMaterialVar slot 11, SetVecValue 3-float slot 11) and |
| 297 | `ColorModulate` (slot 28). `$alpha` is set through IMaterialVar slot 3 | 300 | `ColorModulate` (slot 28). Alpha is applied with |
| 298 | (SetFloatValue). Shared materials are restored after each draw. | 301 | `IVRenderView::SetBlend` (`VEngineRenderView014` slot 4, saved/restored |
| 302 | around the passes) — model draws take their final alpha from the render | ||
| 303 | view, not from material `$alpha`. `$alpha`/`AlphaModulate` are still set for | ||
| 304 | completeness. Shared materials are restored after each draw. | ||
| 299 | - The GUI colour picker (`add_color_alpha`) has an alpha bar, checkerboard | 305 | - The GUI colour picker (`add_color_alpha`) has an alpha bar, checkerboard |
| 300 | preview and `#RRGGBBAA` readout; plain `add_color` keeps the old opaque | 306 | preview and `#RRGGBBAA` readout; plain `add_color` keeps the old opaque |
| 301 | three-component behaviour. Chams colours are four ints (r, g, b, a). | 307 | three-component behaviour. Chams colours are four ints (r, g, b, a). |
| 302 | - **Alpha is stored but has no visual effect yet.** The usable model | 308 | - Alpha needs a translucent model material, so the mod writes a tiny VMT: |
| 303 | materials are opaque: `debug/debugtranslucentsinglecolor` has no | 309 | `<game>/<mod>/materials/hl2hake/translucent.vmt` (and a copy under |
| 304 | `$translucent`, and toggling `MATERIAL_VAR_TRANSLUCENT` (1 << 21) or | 310 | `custom/hl2hake/...`): `UnlitGeneric` with `$basetexture sprites/white`, |
| 305 | rebuilding the state snapshot does not change the static shader combo. | 311 | `$color`, `$model 1`, `$translucent 1`, `$nocull 1`. It is written from a |
| 306 | `debug/debugtranslucentvertexcolor`/`debug/debughitbox` are translucent but | 312 | preload constructor (so it exists before the material system scans) and |
| 307 | need vertex colours and render nothing on skinned models. A custom VMT with | 313 | loaded with `FindMaterial`; styles 0/3/4/6 switch to it when the colour |
| 308 | `$model 1` + `$translucent 1` (or a white basetexture) is needed to make the | 314 | alpha is below 255. The base-game `debugtranslucentsinglecolor` has no |
| 309 | alpha control real. | 315 | `$translucent` and cannot do alpha; `debugtranslucentvertexcolor` and |
| 316 | `debug/debughitbox` need vertex colours and draw nothing on skinned models. | ||
| 310 | - Styles: 0 Flat (`debug/debugtranslucentsinglecolor` + FLAT), 1 Wireframe | 317 | - Styles: 0 Flat (`debug/debugtranslucentsinglecolor` + FLAT), 1 Wireframe |
| 311 | (`debug/debugwireframe`), 2 Additive | 318 | (`debug/debugwireframe`, brightened tint), 2 Additive |
| 312 | (`debug/debugtranslucentmodelhulls`, whose VMT has `$additive 1` + `$color`; | 319 | (`debug/debugtranslucentmodelhulls`, whose VMT has `$additive 1` + `$color`; |
| 313 | the ADDITIVE flag on the solid material did nothing), 3 Solid, 4 White | 320 | the ADDITIVE flag on the solid material did nothing), 3 Solid, 4 White |
| 314 | (solid, colour forced white), 5 Fullbright (the additive material, colour | 321 | (solid, colour forced white), 5 Fullbright (the additive material, colour |
| 315 | forced white, giving a white-hot glow), 6 Glow outline (solid plus a | 322 | forced white, giving a white-hot glow), 6 Solid + contour (solid fill plus |
| 316 | `debug/debugwireframe` contour pass drawn with ZNEARER (1 << 10) and a | 323 | a `debug/debugwireframe` contour pass drawn with ZNEARER (1 << 10) and a |
| 317 | brightened colour so the base cannot bury it). | 324 | brightened colour, so the entity is recoloured while its edges stay |
| 325 | readable). Style 6 is the requested "recolour the whole entity but show its | ||
| 326 | contours" look. | ||
| 318 | `vgui/white` is vertex-colour based and has no `$model`/`$basetexture`, so it | 327 | `vgui/white` is vertex-colour based and has no `$model`/`$basetexture`, so it |
| 319 | is never used for chams; `models/debug/debugwhite` is EP2-only and the old | 328 | is never used for chams; `models/debug/debugwhite` is EP2-only and the old |
| 320 | VGUI additive material was invisible on NPCs. | 329 | VGUI additive material was invisible on NPCs. |
| 330 | - Through-wall + visible wireframe: a wireframe visible pass leaves gaps, so | ||
| 331 | the through-wall fill showed inside the visible silhouette. When both passes | ||
| 332 | are on and the visible style is Wireframe, a solid fill of the visible | ||
| 333 | colour is drawn first, then the brightened wireframe contour. (The proper | ||
| 334 | alternative is stencil: visible writes stencil 1, through-wall tests | ||
| 335 | stencil == 0, as Amalgam does; the fill is simpler and gives the | ||
| 336 | solid+contour look.) | ||
| 321 | - Style materials are preloaded from `outer_draw` (throttled) and cached; the | 337 | - Style materials are preloaded from `outer_draw` (throttled) and cached; the |
| 322 | render hook never calls FindMaterial itself. A missing style uses solid. | 338 | render hook never calls FindMaterial itself. A missing style uses solid. |
| 323 | `FindMaterial` can return an unreferenced material, so each cached material | 339 | `FindMaterial` can return an unreferenced material, so each cached material |
