void RSurf_ActiveCustomEntity(const matrix4x4_t *matrix, const matrix4x4_t *inversematrix, int entflags, double shadertime, float r, float g, float b, float a, int numvertices, const float *vertex3f, const float *texcoord2f, const float *normal3f, const float *svector3f, const float *tvector3f, const float *color4f, int numtriangles, const int *element3i, const unsigned short *element3s, qboolean wantnormals, qboolean wanttangents)
{
rsurface.entity = r_refdef.scene.worldentity;
+ 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;
+ }
rsurface.skeleton = NULL;
rsurface.ent_skinnum = 0;
rsurface.ent_qwskin = -1;
texture.specularscalemod = 1;
texture.specularpowermod = 1;
texture.transparentsort = TRANSPARENTSORT_DISTANCE;
- // WHEN ADDING DEFAULTS HERE, REMEMBER TO PUT DEFAULTS IN ALL LOADERS
- // JUST GREP FOR "specularscalemod = 1".
-
- for (q = 0; q < 3; q++)
- {
- texture.render_glowmod[q] = r_refdef.view.colorscale * r_hdr_glowintensity.value;
- texture.render_modellight_lightdir[q] = q == 2;
- texture.render_modellight_ambient[q] = r_refdef.view.colorscale * r_refdef.scene.ambientintensity;
- texture.render_modellight_diffuse[q] = r_refdef.view.colorscale;
- texture.render_modellight_specular[q] = r_refdef.view.colorscale;
- texture.render_lightmap_ambient[q] = r_refdef.view.colorscale * r_refdef.scene.ambientintensity;
- texture.render_lightmap_diffuse[q] = r_refdef.view.colorscale * r_refdef.scene.lightmapintensity;
- texture.render_lightmap_specular[q] = r_refdef.view.colorscale;
- texture.render_rtlight_diffuse[q] = r_refdef.view.colorscale;
- texture.render_rtlight_specular[q] = r_refdef.view.colorscale;
- }
- texture.currentalpha = 1.0f;
-
- surface.texture = &texture;
- surface.num_triangles = numtriangles;
- surface.num_firsttriangle = firsttriangle;
- surface.num_vertices = numvertices;
- surface.num_firstvertex = firstvertex;
- // now render it
- rsurface.texture = R_GetCurrentTexture(surface.texture);
- rsurface.lightmaptexture = NULL;
- rsurface.deluxemaptexture = NULL;
- rsurface.uselightmaptexture = false;
- R_DrawModelTextureSurfaceList(1, &surfacelist, writedepth, prepass, ui);
+ R_DrawCustomSurface_Texture(&texture, texmatrix, materialflags, firstvertex, numvertices, firsttriangle, numtriangles, writedepth, prepass, ui);
}
void R_DrawCustomSurface_Texture(texture_t *texture, const matrix4x4_t *texmatrix, int materialflags, int firstvertex, int numvertices, int firsttriangle, int numtriangles, qboolean writedepth, qboolean prepass, qboolean ui)