From 0bca7df8b5347702c4a0e0a45226fa8ac0ebbef7 Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 4 Nov 2026 11:42:02 +0100 Subject: Props: only substitute colour during studio draws (no forced set) The forced SetColorModulation/SetAlphaModulation calls before DrawModel are what turned matched props into the error material and destabilised the material system. Mirror Amalgam instead: set a "drawing a prop" flag around the original draw and only substitute the colour when the engine itself calls SetColorModulation during that draw. Log those calls for the first few draws to see whether the engine applies modulation inside DrawModel at all. --- src/studio.cpp | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) (limited to 'src/studio.cpp') diff --git a/src/studio.cpp b/src/studio.cpp index c63ddab..110ce74 100644 --- a/src/studio.cpp +++ b/src/studio.cpp @@ -89,7 +89,15 @@ bool is_prop_model(const char *name) { strncmp(name, "props_", 6) == 0; } +int g_color_logs = 0; + void hook_set_color(void *self, const float *color) { + if (g_color_logs < 10) { + g_color_logs++; + logf("studio: SetColorModulation depth=%d color=%.2f,%.2f,%.2f", + g_prop_depth, color ? color[0] : 0.0f, color ? color[1] : 0.0f, + color ? color[2] : 0.0f); + } if (g_prop_depth > 0 && prop_tint_on()) { float c[4]; prop_color(c); @@ -107,12 +115,6 @@ void hook_set_alpha(void *self, float alpha) { g_orig_set_alpha(self, alpha); } -void force_prop_color(void *self) { - float c[4]; - prop_color(c); - g_orig_set_color(self, c); - g_orig_set_alpha(self, 1.0f); -} void hook_draw_model(void *self, void *results, void *info, void *bone, void *flex, void *flex_delayed, int flags) { @@ -123,10 +125,8 @@ void hook_draw_model(void *self, void *results, void *info, void *bone, logf("studio: DrawModel model=\"%s\" prop=%d", model ? model : "?", (int)prop); } - if (prop) { - force_prop_color(self); + if (prop) g_prop_depth++; - } g_orig_draw_model(self, results, info, bone, flex, flex_delayed, flags); if (prop) g_prop_depth--; @@ -141,10 +141,8 @@ void hook_draw_array(void *self, void *info, int count, void *instances, logf("studio: DrawModelArray count=%d model=\"%s\" prop=%d", count, model ? model : "?", (int)prop); } - if (prop) { - force_prop_color(self); + if (prop) g_prop_depth++; - } g_orig_draw_array(self, info, count, instances, stride, flags); if (prop) g_prop_depth--; @@ -163,10 +161,8 @@ void hook_draw_static_prop(void *self, void *info, void *model_to_world, if (g_static_calls == 500) logf("studio: static draws=%d prop_draws=%d", g_static_calls, g_static_props); - if (prop) { - force_prop_color(self); + if (prop) g_prop_depth++; - } g_orig_draw_static(self, info, model_to_world, flags); if (prop) g_prop_depth--; @@ -201,10 +197,6 @@ void studio_props_init() { if (g_install_tried) return; g_install_tried = true; - // Disabled: replacing IStudioRender draw/setter entries corrupted material - // state (error-material props, bad reference counts, crash). Prop tint uses - // the entity render colour path in esp.cpp instead. - return; std::string path = loaded_module_path("studiorender"); void *h = nullptr; -- cgit v1.2.3