diff options
| author | salmonik <salmonik@tuta.io> | 2026-11-04 11:42:02 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-11-04 11:42:02 +0100 |
| commit | 0bca7df8b5347702c4a0e0a45226fa8ac0ebbef7 (patch) | |
| tree | 6824eaa2a1fd61522da8a07ef166c3bc9025bcfe /src | |
| parent | Props: disable StudioRender hooks, fix m_clrRender offset (diff) | |
| download | hl2h-0bca7df8b5347702c4a0e0a45226fa8ac0ebbef7.tar.gz hl2h-0bca7df8b5347702c4a0e0a45226fa8ac0ebbef7.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/studio.cpp | 30 |
1 files changed, 11 insertions, 19 deletions
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) { | |||
| 89 | strncmp(name, "props_", 6) == 0; | 89 | strncmp(name, "props_", 6) == 0; |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | int g_color_logs = 0; | ||
| 93 | |||
| 92 | void hook_set_color(void *self, const float *color) { | 94 | void hook_set_color(void *self, const float *color) { |
| 95 | if (g_color_logs < 10) { | ||
| 96 | g_color_logs++; | ||
| 97 | logf("studio: SetColorModulation depth=%d color=%.2f,%.2f,%.2f", | ||
| 98 | g_prop_depth, color ? color[0] : 0.0f, color ? color[1] : 0.0f, | ||
| 99 | color ? color[2] : 0.0f); | ||
| 100 | } | ||
| 93 | if (g_prop_depth > 0 && prop_tint_on()) { | 101 | if (g_prop_depth > 0 && prop_tint_on()) { |
| 94 | float c[4]; | 102 | float c[4]; |
| 95 | prop_color(c); | 103 | prop_color(c); |
| @@ -107,12 +115,6 @@ void hook_set_alpha(void *self, float alpha) { | |||
| 107 | g_orig_set_alpha(self, alpha); | 115 | g_orig_set_alpha(self, alpha); |
| 108 | } | 116 | } |
| 109 | 117 | ||
| 110 | void force_prop_color(void *self) { | ||
| 111 | float c[4]; | ||
| 112 | prop_color(c); | ||
| 113 | g_orig_set_color(self, c); | ||
| 114 | g_orig_set_alpha(self, 1.0f); | ||
| 115 | } | ||
| 116 | 118 | ||
| 117 | void hook_draw_model(void *self, void *results, void *info, void *bone, | 119 | void hook_draw_model(void *self, void *results, void *info, void *bone, |
| 118 | void *flex, void *flex_delayed, int flags) { | 120 | void *flex, void *flex_delayed, int flags) { |
| @@ -123,10 +125,8 @@ void hook_draw_model(void *self, void *results, void *info, void *bone, | |||
| 123 | logf("studio: DrawModel model=\"%s\" prop=%d", model ? model : "?", | 125 | logf("studio: DrawModel model=\"%s\" prop=%d", model ? model : "?", |
| 124 | (int)prop); | 126 | (int)prop); |
| 125 | } | 127 | } |
| 126 | if (prop) { | 128 | if (prop) |
| 127 | force_prop_color(self); | ||
| 128 | g_prop_depth++; | 129 | g_prop_depth++; |
| 129 | } | ||
| 130 | g_orig_draw_model(self, results, info, bone, flex, flex_delayed, flags); | 130 | g_orig_draw_model(self, results, info, bone, flex, flex_delayed, flags); |
| 131 | if (prop) | 131 | if (prop) |
| 132 | g_prop_depth--; | 132 | g_prop_depth--; |
| @@ -141,10 +141,8 @@ void hook_draw_array(void *self, void *info, int count, void *instances, | |||
| 141 | logf("studio: DrawModelArray count=%d model=\"%s\" prop=%d", count, | 141 | logf("studio: DrawModelArray count=%d model=\"%s\" prop=%d", count, |
| 142 | model ? model : "?", (int)prop); | 142 | model ? model : "?", (int)prop); |
| 143 | } | 143 | } |
| 144 | if (prop) { | 144 | if (prop) |
| 145 | force_prop_color(self); | ||
| 146 | g_prop_depth++; | 145 | g_prop_depth++; |
| 147 | } | ||
| 148 | g_orig_draw_array(self, info, count, instances, stride, flags); | 146 | g_orig_draw_array(self, info, count, instances, stride, flags); |
| 149 | if (prop) | 147 | if (prop) |
| 150 | g_prop_depth--; | 148 | g_prop_depth--; |
| @@ -163,10 +161,8 @@ void hook_draw_static_prop(void *self, void *info, void *model_to_world, | |||
| 163 | if (g_static_calls == 500) | 161 | if (g_static_calls == 500) |
| 164 | logf("studio: static draws=%d prop_draws=%d", g_static_calls, | 162 | logf("studio: static draws=%d prop_draws=%d", g_static_calls, |
| 165 | g_static_props); | 163 | g_static_props); |
| 166 | if (prop) { | 164 | if (prop) |
| 167 | force_prop_color(self); | ||
| 168 | g_prop_depth++; | 165 | g_prop_depth++; |
| 169 | } | ||
| 170 | g_orig_draw_static(self, info, model_to_world, flags); | 166 | g_orig_draw_static(self, info, model_to_world, flags); |
| 171 | if (prop) | 167 | if (prop) |
| 172 | g_prop_depth--; | 168 | g_prop_depth--; |
| @@ -201,10 +197,6 @@ void studio_props_init() { | |||
| 201 | if (g_install_tried) | 197 | if (g_install_tried) |
| 202 | return; | 198 | return; |
| 203 | g_install_tried = true; | 199 | g_install_tried = true; |
| 204 | // Disabled: replacing IStudioRender draw/setter entries corrupted material | ||
| 205 | // state (error-material props, bad reference counts, crash). Prop tint uses | ||
| 206 | // the entity render colour path in esp.cpp instead. | ||
| 207 | return; | ||
| 208 | 200 | ||
| 209 | std::string path = loaded_module_path("studiorender"); | 201 | std::string path = loaded_module_path("studiorender"); |
| 210 | void *h = nullptr; | 202 | void *h = nullptr; |
