From ea4b9d1f6de4c0c781a48999e793a5bf976c2b38 Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 4 Nov 2026 19:17:12 +0100 Subject: Chams: keep additive viewmodel visible on bright backgrounds Viewmodels are collated as RENDER_GROUP_VIEW_MODEL_OPAQUE, so an additive forced material can vanish against a bright sky/wall (additive adds nothing to an already-bright surface). Draw a dim opaque solid base before the additive viewmodel pass so the first-person model always has a visible silhouette; the additive layer still provides the glow. --- src/studio.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/studio.cpp') diff --git a/src/studio.cpp b/src/studio.cpp index 4941142..bee6db5 100644 --- a/src/studio.cpp +++ b/src/studio.cpp @@ -313,6 +313,18 @@ void hkdModelExecute(void *self, const void *state, const void *info, brgb[i] = rgb[i] + (255 - rgb[i]) / 2; use_rgb = brgb; } + // Additive blending vanishes against bright backgrounds (sky, + // white walls, strong fog), which made the viewmodel disappear in + // some places. Lay down a dim opaque base first so the first-person + // model always has a visible silhouette; the additive pass still + // adds the glow on top. + if (is_vm && (style == 2 || style == 5)) { + int drgb[3] = {rgb[0] / 2, rgb[1] / 2, rgb[2] / 2}; + chams_apply(mat, ignorez, 3, false, drgb, false); + g_force_override(self, mat, 0 /* OVERRIDE_NORMAL */); + g_orig_model_exec(self, state, info, bone); + chams_reset(mat); + } chams_apply(mat, ignorez, style, white, use_rgb, false); g_force_override(self, mat, 0 /* OVERRIDE_NORMAL */); g_orig_model_exec(self, state, info, bone); -- cgit v1.2.3