+ if (r != 1.0f || g != 1.0f || b != 1.0f || a != 1.0f) {
+ // HACK to provide a valid entity with modded colors to R_GetCurrentTexture.
+ // A better approach could be making this copy only once per frame.
+ static entity_render_t custom_entity;
+ int q;
+ custom_entity = *rsurface.entity;
+ for (q = 0; q < 3; ++q) {
+ float colormod = q == 0 ? r : q == 1 ? g : b;
+ custom_entity.render_fullbright[q] *= colormod;
+ custom_entity.render_modellight_ambient[q] *= colormod;
+ custom_entity.render_modellight_diffuse[q] *= colormod;
+ custom_entity.render_lightmap_ambient[q] *= colormod;
+ custom_entity.render_lightmap_diffuse[q] *= colormod;
+ custom_entity.render_rtlight_diffuse[q] *= colormod;
+ }
+ custom_entity.alpha *= a;
+ rsurface.entity = &custom_entity;
+ }