]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Fix the corona bug. The render bug only though.
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 23 Mar 2020 20:37:56 +0000 (20:37 +0000)
committerRudolf Polzer <divVerent@gmail.com>
Mon, 23 Mar 2020 20:51:46 +0000 (13:51 -0700)
This is done by reviving alphamod and colormod arguments of
RSurf_ActiveCustomEntity.

The current implementation is a bit rough and needlessly copies the
worldentity; the struct isn't huge though and it's only done when
actually colormodding (and thus only for coronas, r_editlights, a few
sprites and nomodels).

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12525 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=c1ae70566d016a8f85acb3d4293c5dbc53886a51

gl_rmain.c

index 93d575aac9bd0debb86d61fb5faffc4bcd196cbe..522cea20c8f9d6fca6eb4ec71d2608ff3ec667bc 100644 (file)
@@ -8676,6 +8676,24 @@ void RSurf_ActiveModelEntity(const entity_render_t *ent, qboolean wantnormals, q
 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;