From cc06dab406a0086ddcb9e4ced3759614f65e069e Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 4 Nov 2026 11:49:32 +0100 Subject: Props: remove studio diagnostics; document the prop tint path Drop the temporary DrawModel/SetColor logs now that the prop tint works, and document the IStudioRender hook layout, the short model-name format used for prop detection, the SetColor-before-DrawModel ordering, and why prop materials cannot be tinted directly. --- CONTEXT.md | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'CONTEXT.md') diff --git a/CONTEXT.md b/CONTEXT.md index 5eca9f8..2199be6 100644 --- a/CONTEXT.md +++ b/CONTEXT.md @@ -329,11 +329,27 @@ vocabulary / decisions. 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), to - `SkyBox textures` (or names containing `sky`), and to prop materials whose - name starts with `models/props` (static props and prop_physics share those - model materials; NPC/player/weapon materials are excluded). Lightmaps are - not touched. + `GetTextureGroupName()` is `World textures` (sky names excluded) and to + `SkyBox textures` (or names containing `sky`). Lightmaps are not touched. +- Props are NOT tinted through their materials: VertexLitGeneric materials get + their colour modulation from `IStudioRender`, which the engine sets per + model draw (white), so the material var is overridden. `src/studio.cpp` + hooks the `VStudioRender025` interface object instead: + `SetColorModulation`/`SetAlphaModulation` (slots 27/28), `DrawModel` (29), + `DrawModelStaticProp` (30) and `DrawModelArray` (46), all checked against + `CStudioRenderContext`'s vtable in `studiorender.so`. + `DrawModel` checks `DrawModelInfo_t::m_pStudioHdr->name`; note the name is + the short form with Windows separators (`props_junk\wood_crate002a.mdl`, + no `models/` prefix), so prop detection matches `props/`, `props\` and + `props_` after stripping `models/` (excluding `props_skybox`). For a prop it + sets the prop colour right before calling the original draw; setting the + colour from a flag inside the draw does not work because the engine calls + `SetColorModulation(1,1,1)` *before* `DrawModel`. + Do not force `SetAlphaModulation` there: the earlier attempt produced + error-material props and a material-system crash. +- `prop_tint_update()` also writes `m_clrRender` on prop entities (dynamic + props) as a secondary path; the netvar resolver rejects offset 0 (an + embedded-table false positive) and only accepts 0x20..0x2000. - 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. -- cgit v1.2.3