From c2799187559cb7fcddd24318e72fc0656c67116f Mon Sep 17 00:00:00 2001 From: havoc Date: Sun, 11 Sep 2005 11:48:17 +0000 Subject: [PATCH] rewrote colormapping handling to store colormap_pantscolor and colormap_shirtcolor in entity_render_t rather than having the annoying palette lookups in the renderer, while doing this I removed support for fullbright rendering of colormap colors 14 and 15 (this shouldn't really affect anyone, stock quake did not even let you use these colors, and they're ugly colors anyway :) rewrote portions of surface renderer again, to improve readability and overbright handling, this shouldn't change anything visually git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5720 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_main.c | 36 ++++- client.h | 5 +- gl_rmain.c | 368 ++++++++++++++++++++----------------------------- gl_rsurf.c | 32 +---- model_shared.h | 11 +- r_shadow.c | 24 +++- 6 files changed, 217 insertions(+), 259 deletions(-) diff --git a/cl_main.c b/cl_main.c index 16c8a2cc..9436dbeb 100644 --- a/cl_main.c +++ b/cl_main.c @@ -588,14 +588,46 @@ void CL_LinkNetworkEntity(entity_t *e) e->render.scale = e->state_current.scale * (1.0f / 16.0f); // FIXME: interpolate? e->render.flags = e->state_current.flags; e->render.effects = e->state_current.effects; + VectorScale(e->state_current.colormod, (1.0f / 32.0f), e->render.colormod); if (e->state_current.flags & RENDER_COLORMAPPED) + { + int cb; + qbyte *cbcolor; e->render.colormap = e->state_current.colormap; - else if (cl.scores != NULL && e->state_current.colormap) + cb = (e->render.colormap & 0xF) << 4;cb += (cb >= 128 && cb < 224) ? 4 : 12; + cbcolor = (qbyte *) (&palette_complete[cb]); + e->render.colormap_pantscolor[0] = cbcolor[0] * (1.0f / 255.0f) * e->render.colormod[0]; + e->render.colormap_pantscolor[1] = cbcolor[1] * (1.0f / 255.0f) * e->render.colormod[1]; + e->render.colormap_pantscolor[2] = cbcolor[2] * (1.0f / 255.0f) * e->render.colormod[2]; + cb = (e->render.colormap & 0xF0);cb += (cb >= 128 && cb < 224) ? 4 : 12; + cbcolor = (qbyte *) (&palette_complete[cb]); + e->render.colormap_shirtcolor[0] = cbcolor[0] * (1.0f / 255.0f) * e->render.colormod[0]; + e->render.colormap_shirtcolor[1] = cbcolor[1] * (1.0f / 255.0f) * e->render.colormod[1]; + e->render.colormap_shirtcolor[2] = cbcolor[2] * (1.0f / 255.0f) * e->render.colormod[2]; + } + else if (e->state_current.colormap && cl.scores != NULL) + { + int cb; + qbyte *cbcolor; e->render.colormap = cl.scores[e->state_current.colormap - 1].colors; // color it + cb = (e->render.colormap & 0xF) << 4;cb += (cb >= 128 && cb < 224) ? 4 : 12; + cbcolor = (qbyte *) (&palette_complete[cb]); + e->render.colormap_pantscolor[0] = cbcolor[0] * (1.0f / 255.0f) * e->render.colormod[0]; + e->render.colormap_pantscolor[1] = cbcolor[1] * (1.0f / 255.0f) * e->render.colormod[1]; + e->render.colormap_pantscolor[2] = cbcolor[2] * (1.0f / 255.0f) * e->render.colormod[2]; + cb = (e->render.colormap & 0xF0);cb += (cb >= 128 && cb < 224) ? 4 : 12; + cbcolor = (qbyte *) (&palette_complete[cb]); + e->render.colormap_shirtcolor[0] = cbcolor[0] * (1.0f / 255.0f) * e->render.colormod[0]; + e->render.colormap_shirtcolor[1] = cbcolor[1] * (1.0f / 255.0f) * e->render.colormod[1]; + e->render.colormap_shirtcolor[2] = cbcolor[2] * (1.0f / 255.0f) * e->render.colormod[2]; + } else + { e->render.colormap = -1; // no special coloring + VectorClear(e->render.colormap_pantscolor); + VectorClear(e->render.colormap_shirtcolor); + } e->render.skinnum = e->state_current.skin; - VectorScale(e->state_current.colormod, (1.0f / 32.0f), e->render.colormod); if (e->render.flags & RENDER_VIEWMODEL && !e->state_current.tagentity) { if (!r_drawviewmodel.integer || chase_active.integer || envmap) diff --git a/client.h b/client.h index c50db411..2da0549c 100644 --- a/client.h +++ b/client.h @@ -243,8 +243,11 @@ typedef struct entity_render_s model_t *model; // current uninterpolated animation frame (for things which do not use interpolation) int frame; - // entity shirt and pants colors + // entity shirt and pants colors (-1 if not colormapped) int colormap; + // literal colors for renderer + vec3_t colormap_pantscolor; + vec3_t colormap_shirtcolor; // light, particles, etc int effects; // for Alias models diff --git a/gl_rmain.c b/gl_rmain.c index 88b006f9..14d17f72 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -1354,7 +1354,7 @@ void R_Mesh_AddBrushMeshFromPlanes(rmesh_t *mesh, int numplanes, mplane_t *plane } } -void R_Texture_AddLayer(texture_t *t, qboolean depthmask, int blendfunc1, int blendfunc2, texturelayertype_t type, rtexture_t *texture, matrix4x4_t *matrix, float r, float g, float b, float a, int texrgbscale) +void R_Texture_AddLayer(texture_t *t, qboolean depthmask, int blendfunc1, int blendfunc2, texturelayertype_t type, rtexture_t *texture, matrix4x4_t *matrix, float r, float g, float b, float a) { texturelayer_t *layer; layer = t->currentlayers + t->currentnumlayers++; @@ -1368,14 +1368,13 @@ void R_Texture_AddLayer(texture_t *t, qboolean depthmask, int blendfunc1, int bl layer->color[1] = g; layer->color[2] = b; layer->color[3] = a; - layer->texrgbscale = texrgbscale; } void R_UpdateTextureInfo(const entity_render_t *ent, texture_t *t) { // FIXME: identify models using a better check than ent->model->brush.shadowmesh //int lightmode = ((ent->effects & EF_FULLBRIGHT) || ent->model->brush.shadowmesh) ? 0 : 2; - vec4_t currentcolorbase; + float currentalpha; { texture_t *texture = t; @@ -1400,17 +1399,14 @@ void R_UpdateTextureInfo(const entity_render_t *ent, texture_t *t) } t->currentmaterialflags = t->basematerialflags; - currentcolorbase[0] = ent->colormod[0]; - currentcolorbase[1] = ent->colormod[1]; - currentcolorbase[2] = ent->colormod[2]; - currentcolorbase[3] = ent->alpha; + currentalpha = ent->alpha; if (t->basematerialflags & MATERIALFLAG_WATERALPHA) - currentcolorbase[3] *= r_wateralpha.value; + currentalpha *= r_wateralpha.value; if (!(ent->flags & RENDER_LIGHT)) t->currentmaterialflags |= MATERIALFLAG_FULLBRIGHT; if (ent->effects & EF_ADDITIVE) t->currentmaterialflags |= MATERIALFLAG_ADD | MATERIALFLAG_TRANSPARENT; - else if (currentcolorbase[3] < 1) + else if (currentalpha < 1) t->currentmaterialflags |= MATERIALFLAG_ALPHA | MATERIALFLAG_TRANSPARENT; if (ent->effects & EF_NODEPTHTEST) t->currentmaterialflags |= MATERIALFLAG_NODEPTHTEST; @@ -1421,191 +1417,100 @@ void R_UpdateTextureInfo(const entity_render_t *ent, texture_t *t) t->currentnumlayers = 0; if (!(t->currentmaterialflags & MATERIALFLAG_NODRAW)) { - int blendfunc1, blendfunc2, depthmask; - if (t->currentmaterialflags & MATERIALFLAG_ADD) - { - blendfunc1 = GL_SRC_ALPHA; - blendfunc2 = GL_ONE; - depthmask = false; - } - else if (t->currentmaterialflags & MATERIALFLAG_ALPHA) - { - blendfunc1 = GL_SRC_ALPHA; - blendfunc2 = GL_ONE_MINUS_SRC_ALPHA; - depthmask = false; - } - else - { - blendfunc1 = GL_ONE; - blendfunc2 = GL_ZERO; - depthmask = true; - } if (gl_lightmaps.integer) - R_Texture_AddLayer(t, depthmask, blendfunc1, blendfunc2, TEXTURELAYERTYPE_LIGHTMAP, r_texture_white, &r_identitymatrix, 1, 1, 1, 1, 1); + R_Texture_AddLayer(t, true, GL_ONE, GL_ZERO, TEXTURELAYERTYPE_LITTEXTURE_MULTIPASS, r_texture_white, &r_identitymatrix, 1, 1, 1, 1); else if (t->currentmaterialflags & MATERIALFLAG_SKY) { // transparent sky would be ridiculous if (!(t->currentmaterialflags & MATERIALFLAG_TRANSPARENT)) - R_Texture_AddLayer(t, depthmask, blendfunc1, blendfunc2, TEXTURELAYERTYPE_SKY, r_texture_white, &r_identitymatrix, fogcolor[0], fogcolor[1], fogcolor[2], 1, 1); + R_Texture_AddLayer(t, true, GL_ONE, GL_ZERO, TEXTURELAYERTYPE_SKY, r_texture_white, &r_identitymatrix, fogcolor[0], fogcolor[1], fogcolor[2], 1); } - else if (t->currentmaterialflags & (MATERIALFLAG_WATER | MATERIALFLAG_WALL)) + else { - int type; - float colorscale, r, g, b; - rtexture_t *currentbasetexture; - int layerflags = 0; - if (fogenabled && (t->currentmaterialflags & MATERIALFLAG_TRANSPARENT)) - layerflags |= TEXTURELAYERFLAG_FOGDARKEN; - colorscale = 2; - // q3bsp has no lightmap updates, so the lightstylevalue that - // would normally be baked into the lightmaptexture must be - // applied to the color - if (!(t->currentmaterialflags & MATERIALFLAG_FULLBRIGHT) && ent->model->type == mod_brushq3) - colorscale *= d_lightstylevalue[0] * (1.0f / 256.0f); - r = currentcolorbase[0] * colorscale; - g = currentcolorbase[1] * colorscale; - b = currentcolorbase[2] * colorscale; - // transparent and fullbright are not affected by r_lightmapintensity - if (!(t->currentmaterialflags & (MATERIALFLAG_TRANSPARENT | MATERIALFLAG_FULLBRIGHT))) + int blendfunc1, blendfunc2, depthmask; + if (t->currentmaterialflags & MATERIALFLAG_ADD) { - r *= r_lightmapintensity; - g *= r_lightmapintensity; - b *= r_lightmapintensity; + blendfunc1 = GL_SRC_ALPHA; + blendfunc2 = GL_ONE; + depthmask = false; } - currentbasetexture = (ent->colormap >= 0 && t->skin.merged) ? t->skin.merged : t->skin.base; - if (!(t->currentmaterialflags & MATERIALFLAG_FULLBRIGHT) && r_textureunits.integer >= 2 && gl_combine.integer) + else if (t->currentmaterialflags & MATERIALFLAG_ALPHA) { - if ((r > 2 || g > 2 || b > 2) && gl_combine.integer) - R_Texture_AddLayer(t, depthmask, blendfunc1, blendfunc2, TEXTURELAYERTYPE_LIGHTMAP_DOUBLEMODULATE_TEXTURE, currentbasetexture, &t->currenttexmatrix, r * 0.25f, g * 0.25f, b * 0.25f, currentcolorbase[3], 4); - else if ((r > 1 || g > 1 || b > 1) && gl_combine.integer) - R_Texture_AddLayer(t, depthmask, blendfunc1, blendfunc2, TEXTURELAYERTYPE_LIGHTMAP_DOUBLEMODULATE_TEXTURE, currentbasetexture, &t->currenttexmatrix, r * 0.5f, g * 0.5f, b * 0.5f, currentcolorbase[3], 2); - else - R_Texture_AddLayer(t, depthmask, blendfunc1, blendfunc2, TEXTURELAYERTYPE_LIGHTMAP_DOUBLEMODULATE_TEXTURE, currentbasetexture, &t->currenttexmatrix, r, g, b, currentcolorbase[3], 1); - } - else if ((t->currentmaterialflags & (MATERIALFLAG_FULLBRIGHT | MATERIALFLAG_TRANSPARENT)) == 0) - { - R_Texture_AddLayer(t, true, GL_ONE, GL_ZERO, TEXTURELAYERTYPE_LIGHTMAP, r_texture_white, &r_identitymatrix, 1, 1, 1, 1, 1); - if (r > 1 || g > 1 || b > 1) - R_Texture_AddLayer(t, false, GL_DST_COLOR, GL_SRC_COLOR, TEXTURELAYERTYPE_TEXTURE, currentbasetexture, &t->currenttexmatrix, r * 0.5f, g * 0.5f, b * 0.5f, currentcolorbase[3], 1); - else - R_Texture_AddLayer(t, false, GL_ZERO, GL_SRC_COLOR, TEXTURELAYERTYPE_TEXTURE, currentbasetexture, &t->currenttexmatrix, r, g, b, currentcolorbase[3], 1); + blendfunc1 = GL_SRC_ALPHA; + blendfunc2 = GL_ONE_MINUS_SRC_ALPHA; + depthmask = false; } else { - if (t->currentmaterialflags & MATERIALFLAG_FULLBRIGHT) - { - type = TEXTURELAYERTYPE_TEXTURE; - r *= 0.5f; - g *= 0.5f; - b *= 0.5f; - } - else - type = TEXTURELAYERTYPE_VERTEXTEXTURE; - if ((r > 2 || g > 2 || b > 2) && gl_combine.integer) - R_Texture_AddLayer(t, depthmask, blendfunc1, blendfunc2, type, currentbasetexture, &t->currenttexmatrix, r * 0.25f, g * 0.25f, b * 0.25f, currentcolorbase[3], 4); - else if ((r > 1 || g > 1 || b > 1) && gl_combine.integer) - R_Texture_AddLayer(t, depthmask, blendfunc1, blendfunc2, type, currentbasetexture, &t->currenttexmatrix, r * 0.5f, g * 0.5f, b * 0.5f, currentcolorbase[3], 2); - else - R_Texture_AddLayer(t, depthmask, blendfunc1, blendfunc2, type, currentbasetexture, &t->currenttexmatrix, r, g, b, currentcolorbase[3], 1); + blendfunc1 = GL_ONE; + blendfunc2 = GL_ZERO; + depthmask = true; } - if (ent->colormap >= 0 && t->skin.pants) + if (t->currentmaterialflags & (MATERIALFLAG_WATER | MATERIALFLAG_WALL)) { - int cb; - qbyte *cbcolor; - // 128-224 are backwards ranges - cb = (ent->colormap & 0xF) << 4;cb += (cb >= 128 && cb < 224) ? 4 : 12; - cbcolor = (qbyte *) (&palette_complete[cb]); - r = cbcolor[0] * (1.0f / 255.0f) * currentcolorbase[0] * colorscale; - g = cbcolor[1] * (1.0f / 255.0f) * currentcolorbase[1] * colorscale; - b = cbcolor[2] * (1.0f / 255.0f) * currentcolorbase[2] * colorscale; - // transparent and fullbright are not affected by r_lightmapintensity - if ((cb >= 224) || (t->currentmaterialflags & MATERIALFLAG_FULLBRIGHT)) + rtexture_t *currentbasetexture; + int layerflags = 0; + if (fogenabled && (t->currentmaterialflags & MATERIALFLAG_TRANSPARENT)) + layerflags |= TEXTURELAYERFLAG_FOGDARKEN; + currentbasetexture = (ent->colormap < 0 && t->skin.merged) ? t->skin.merged : t->skin.base; + if (t->currentmaterialflags & MATERIALFLAG_FULLBRIGHT) { - type = TEXTURELAYERTYPE_TEXTURE; - r *= 0.5f; - g *= 0.5f; - b *= 0.5f; + R_Texture_AddLayer(t, depthmask, blendfunc1, blendfunc2, TEXTURELAYERTYPE_TEXTURE, currentbasetexture, &t->currenttexmatrix, ent->colormod[0], ent->colormod[1], ent->colormod[2], currentalpha); + if (ent->colormap >= 0 && t->skin.pants) + R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_TEXTURE, t->skin.pants, &t->currenttexmatrix, ent->colormap_pantscolor[0], ent->colormap_pantscolor[1], ent->colormap_pantscolor[2], currentalpha); + if (ent->colormap >= 0 && t->skin.shirt) + R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_TEXTURE, t->skin.shirt, &t->currenttexmatrix, ent->colormap_shirtcolor[0], ent->colormap_shirtcolor[1], ent->colormap_shirtcolor[2], currentalpha); } else { - type = TEXTURELAYERTYPE_VERTEXTEXTURE; - if (!(t->currentmaterialflags & (MATERIALFLAG_TRANSPARENT | MATERIALFLAG_FULLBRIGHT))) + float colorscale; + colorscale = 2; + // q3bsp has no lightmap updates, so the lightstylevalue that + // would normally be baked into the lightmaptexture must be + // applied to the color + if (ent->model->type == mod_brushq3) + colorscale *= d_lightstylevalue[0] * (1.0f / 256.0f); + // transparent and fullbright are not affected by r_lightmapintensity + if (!(t->currentmaterialflags & MATERIALFLAG_TRANSPARENT)) + colorscale *= r_lightmapintensity; + if (r_textureunits.integer >= 2 && gl_combine.integer) + R_Texture_AddLayer(t, depthmask, blendfunc1, blendfunc2, TEXTURELAYERTYPE_LITTEXTURE_COMBINE, currentbasetexture, &t->currenttexmatrix, ent->colormod[0] * colorscale, ent->colormod[1] * colorscale, ent->colormod[2] * colorscale, currentalpha); + else if ((t->currentmaterialflags & MATERIALFLAG_TRANSPARENT) == 0) + R_Texture_AddLayer(t, true, GL_ONE, GL_ZERO, TEXTURELAYERTYPE_LITTEXTURE_MULTIPASS, currentbasetexture, &t->currenttexmatrix, ent->colormod[0] * colorscale * 0.5f, ent->colormod[1] * colorscale * 0.5f, ent->colormod[2] * colorscale * 0.5f, currentalpha); + else + R_Texture_AddLayer(t, depthmask, blendfunc1, blendfunc2, TEXTURELAYERTYPE_LITTEXTURE_VERTEX, currentbasetexture, &t->currenttexmatrix, ent->colormod[0] * colorscale, ent->colormod[1] * colorscale, ent->colormod[2] * colorscale, currentalpha); + if (r_ambient.value >= (1.0f/64.0f)) + R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_TEXTURE, currentbasetexture, &t->currenttexmatrix, ent->colormod[0] * r_ambient.value * (1.0f / 64.0f), ent->colormod[1] * r_ambient.value * (1.0f / 64.0f), ent->colormod[2] * r_ambient.value * (1.0f / 64.0f), currentalpha); + if (ent->colormap >= 0 && t->skin.pants) { - r *= r_lightmapintensity; - g *= r_lightmapintensity; - b *= r_lightmapintensity; + R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_LITTEXTURE_VERTEX, t->skin.pants, &t->currenttexmatrix, ent->colormap_pantscolor[0] * colorscale, ent->colormap_pantscolor[1] * colorscale, ent->colormap_pantscolor[2] * colorscale, currentalpha); + if (r_ambient.value >= (1.0f/64.0f)) + R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_TEXTURE, t->skin.pants, &t->currenttexmatrix, ent->colormap_pantscolor[0] * r_ambient.value * (1.0f / 64.0f), ent->colormap_pantscolor[1] * r_ambient.value * (1.0f / 64.0f), ent->colormap_pantscolor[2] * r_ambient.value * (1.0f / 64.0f), currentalpha); } - } - if ((r > 2 || g > 2 || b > 2) && gl_combine.integer) - R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, type, t->skin.pants, &t->currenttexmatrix, r * 0.25f, g * 0.25f, b * 0.25f, currentcolorbase[3], 4); - else if ((r > 1 || g > 1 || b > 1) && gl_combine.integer) - R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, type, t->skin.pants, &t->currenttexmatrix, r * 0.5f, g * 0.5f, b * 0.5f, currentcolorbase[3], 2); - else - R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, type, t->skin.pants, &t->currenttexmatrix, r, g, b, currentcolorbase[3], 1); - } - if (ent->colormap >= 0 && t->skin.shirt) - { - int cb; - qbyte *cbcolor; - // 128-224 are backwards ranges - cb = (ent->colormap & 0xF0);cb += (cb >= 128 && cb < 224) ? 4 : 12; - cbcolor = (qbyte *) (&palette_complete[cb]); - r = cbcolor[0] * (1.0f / 255.0f) * currentcolorbase[0] * colorscale; - g = cbcolor[1] * (1.0f / 255.0f) * currentcolorbase[1] * colorscale; - b = cbcolor[2] * (1.0f / 255.0f) * currentcolorbase[2] * colorscale; - // transparent and fullbright are not affected by r_lightmapintensity - if ((cb >= 224) || (t->currentmaterialflags & MATERIALFLAG_FULLBRIGHT)) - { - type = TEXTURELAYERTYPE_TEXTURE; - r *= 0.5f; - g *= 0.5f; - b *= 0.5f; - } - else - { - type = TEXTURELAYERTYPE_VERTEXTEXTURE; - if (!(t->currentmaterialflags & (MATERIALFLAG_TRANSPARENT | MATERIALFLAG_FULLBRIGHT))) + if (ent->colormap >= 0 && t->skin.shirt) { - r *= r_lightmapintensity; - g *= r_lightmapintensity; - b *= r_lightmapintensity; + R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_LITTEXTURE_VERTEX, t->skin.shirt, &t->currenttexmatrix, ent->colormap_shirtcolor[0] * colorscale, ent->colormap_shirtcolor[1] * colorscale, ent->colormap_shirtcolor[2] * colorscale, currentalpha); + if (r_ambient.value >= (1.0f/64.0f)) + R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_TEXTURE, t->skin.shirt, &t->currenttexmatrix, ent->colormap_shirtcolor[0] * r_ambient.value * (1.0f / 64.0f), ent->colormap_shirtcolor[1] * r_ambient.value * (1.0f / 64.0f), ent->colormap_shirtcolor[2] * r_ambient.value * (1.0f / 64.0f), currentalpha); } } - if ((r > 2 || g > 2 || b > 2) && gl_combine.integer) - R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, type, t->skin.shirt, &t->currenttexmatrix, r * 0.25f, g * 0.25f, b * 0.25f, currentcolorbase[3], 4); - else if ((r > 1 || g > 1 || b > 1) && gl_combine.integer) - R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, type, t->skin.shirt, &t->currenttexmatrix, r * 0.5f, g * 0.5f, b * 0.5f, currentcolorbase[3], 2); - else - R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, type, t->skin.shirt, &t->currenttexmatrix, r, g, b, currentcolorbase[3], 1); - } - if (r_ambient.value >= (1.0f/64.0f)) - { - r = currentcolorbase[0] * colorscale * r_ambient.value * (1.0f / 64.0f); - g = currentcolorbase[1] * colorscale * r_ambient.value * (1.0f / 64.0f); - b = currentcolorbase[2] * colorscale * r_ambient.value * (1.0f / 64.0f); - if ((r > 2 || g > 2 || b > 2) && gl_combine.integer) - R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_TEXTURE, currentbasetexture, &t->currenttexmatrix, r * 0.25f, g * 0.25f, b * 0.25f, currentcolorbase[3], 4); - else if ((r > 1 || g > 1 || b > 1) && gl_combine.integer) - R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_TEXTURE, currentbasetexture, &t->currenttexmatrix, r * 0.5f, g * 0.5f, b * 0.5f, currentcolorbase[3], 2); - else - R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_TEXTURE, currentbasetexture, &t->currenttexmatrix, r, g, b, currentcolorbase[3], 1); - } - if (t->skin.glow != NULL) - R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_TEXTURE, t->skin.glow, &t->currenttexmatrix, 1, 1, 1, currentcolorbase[3], 1); - if (fogenabled && !(t->currentmaterialflags & MATERIALFLAG_ADD)) - { - // if this is opaque use alpha blend which will darken the earlier - // passes cheaply. - // - // if this is an alpha blended material, all the earlier passes - // were darkened by fog already, so we only need to add the fog - // color ontop through the fog mask texture - // - // if this is an additive blended material, all the earlier passes - // were darkened by fog already, and we should not add fog color - // (because the background was not darkened, there is no fog color - // that was lost behind it). - R_Texture_AddLayer(t, false, GL_SRC_ALPHA, (t->currentmaterialflags & MATERIALFLAG_TRANSPARENT) ? GL_ONE : GL_ONE_MINUS_SRC_ALPHA, TEXTURELAYERTYPE_FOG, t->skin.fog, &r_identitymatrix, fogcolor[0], fogcolor[1], fogcolor[2], currentcolorbase[3], 1); + if (t->skin.glow != NULL) + R_Texture_AddLayer(t, false, GL_SRC_ALPHA, GL_ONE, TEXTURELAYERTYPE_TEXTURE, t->skin.glow, &t->currenttexmatrix, 1, 1, 1, currentalpha); + if (fogenabled && !(t->currentmaterialflags & MATERIALFLAG_ADD)) + { + // if this is opaque use alpha blend which will darken the earlier + // passes cheaply. + // + // if this is an alpha blended material, all the earlier passes + // were darkened by fog already, so we only need to add the fog + // color ontop through the fog mask texture + // + // if this is an additive blended material, all the earlier passes + // were darkened by fog already, and we should not add fog color + // (because the background was not darkened, there is no fog color + // that was lost behind it). + R_Texture_AddLayer(t, false, GL_SRC_ALPHA, (t->currentmaterialflags & MATERIALFLAG_TRANSPARENT) ? GL_ONE : GL_ONE_MINUS_SRC_ALPHA, TEXTURELAYERTYPE_FOG, t->skin.fog, &r_identitymatrix, fogcolor[0], fogcolor[1], fogcolor[2], currentalpha); + } } } } @@ -1845,30 +1750,6 @@ static void R_DrawTextureSurfaceList(const entity_render_t *ent, texture_t *text c_faces += texturenumsurfaces; // FIXME: identify models using a better check than ent->model->brush.shadowmesh lightmode = ((ent->effects & EF_FULLBRIGHT) || ent->model->brush.shadowmesh) ? 0 : 2; - // gl_lightmaps debugging mode skips normal texturing - if (gl_lightmaps.integer) - { - GL_BlendFunc(GL_ONE, GL_ZERO); - GL_DepthMask(true); - GL_DepthTest(true); - qglDisable(GL_CULL_FACE); - GL_Color(1, 1, 1, 1); - memset(&m, 0, sizeof(m)); - R_Mesh_State(&m); - for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++) - { - surface = texturesurfacelist[texturesurfaceindex]; - R_Mesh_TexBind(0, R_GetTexture(surface->lightmaptexture)); - R_Mesh_TexCoordPointer(0, 2, surface->groupmesh->data_texcoordlightmap2f); - RSurf_SetVertexPointer(ent, texture, surface, modelorg); - RSurf_SetColorPointer(ent, surface, modelorg, 1, 1, 1, 1, lightmode ? lightmode : !surface->lightmaptexture, false, false); - GL_LockArrays(surface->num_firstvertex, surface->num_vertices); - R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle)); - GL_LockArrays(0, 0); - } - qglEnable(GL_CULL_FACE); - return; - } GL_DepthTest(!(texture->currentmaterialflags & MATERIALFLAG_NODEPTHTEST)); if (texture->textureflags & Q3TEXTUREFLAG_TWOSIDED) qglDisable(GL_CULL_FACE); @@ -1878,10 +1759,28 @@ static void R_DrawTextureSurfaceList(const entity_render_t *ent, texture_t *text texturelayer_t *layer; for (layerindex = 0, layer = texture->currentlayers;layerindex < texture->currentnumlayers;layerindex++, layer++) { + vec4_t layercolor; + int layertexrgbscale; GL_DepthMask(layer->depthmask); GL_BlendFunc(layer->blendfunc1, layer->blendfunc2); - GL_Color(layer->color[0], layer->color[1], layer->color[2], layer->color[3]); - applycolor = layer->color[0] != 1 || layer->color[1] != 1 || layer->color[2] != 1 || layer->color[3] != 1; + if ((layer->color[0] > 2 || layer->color[1] > 2 || layer->color[2] > 2) && (gl_combine.integer || layer->depthmask)) + { + layertexrgbscale = 4; + VectorScale(layer->color, 0.25f, layercolor); + } + else if ((layer->color[0] > 1 || layer->color[1] > 1 || layer->color[2] > 1) && (gl_combine.integer || layer->depthmask)) + { + layertexrgbscale = 2; + VectorScale(layer->color, 0.5f, layercolor); + } + else + { + layertexrgbscale = 1; + VectorScale(layer->color, 1.0f, layercolor); + } + layercolor[3] = layer->color[3]; + GL_Color(layercolor[0], layercolor[1], layercolor[2], layercolor[3]); + applycolor = layercolor[0] != 1 || layercolor[1] != 1 || layercolor[2] != 1 || layercolor[3] != 1; switch (layer->type) { case TEXTURELAYERTYPE_SKY: @@ -1893,7 +1792,7 @@ static void R_DrawTextureSurfaceList(const entity_render_t *ent, texture_t *text R_Sky(); // restore entity matrix and GL_Color R_Mesh_Matrix(&ent->matrix); - GL_Color(layer->color[0], layer->color[1], layer->color[2], layer->color[3]); + GL_Color(layercolor[0], layercolor[1], layercolor[2], layercolor[3]); } } // LordHavoc: HalfLife maps have freaky skypolys... @@ -1926,11 +1825,11 @@ static void R_DrawTextureSurfaceList(const entity_render_t *ent, texture_t *text GL_ColorMask(r_refdef.colormask[0], r_refdef.colormask[1], r_refdef.colormask[2], 1); } break; - case TEXTURELAYERTYPE_LIGHTMAP_DOUBLEMODULATE_TEXTURE: + case TEXTURELAYERTYPE_LITTEXTURE_COMBINE: memset(&m, 0, sizeof(m)); m.tex[1] = R_GetTexture(layer->texture); m.texmatrix[1] = layer->texmatrix; - m.texrgbscale[1] = layer->texrgbscale; + m.texrgbscale[1] = layertexrgbscale; m.pointer_color = varray_color4f; R_Mesh_State(&m); for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++) @@ -1942,25 +1841,29 @@ static void R_DrawTextureSurfaceList(const entity_render_t *ent, texture_t *text if (lightmode == 2) { R_Mesh_TexBind(0, R_GetTexture(r_texture_white)); - RSurf_SetColorPointer(ent, surface, modelorg, layer->color[0], layer->color[1], layer->color[2], layer->color[3], 2, applycolor, layer->flags & TEXTURELAYERFLAG_FOGDARKEN); + RSurf_SetColorPointer(ent, surface, modelorg, layercolor[0], layercolor[1], layercolor[2], layercolor[3], 2, applycolor, layer->flags & TEXTURELAYERFLAG_FOGDARKEN); } else if (surface->lightmaptexture) { R_Mesh_TexBind(0, R_GetTexture(surface->lightmaptexture)); - RSurf_SetColorPointer(ent, surface, modelorg, layer->color[0], layer->color[1], layer->color[2], layer->color[3], 0, applycolor, layer->flags & TEXTURELAYERFLAG_FOGDARKEN); + RSurf_SetColorPointer(ent, surface, modelorg, layercolor[0], layercolor[1], layercolor[2], layercolor[3], 0, applycolor, layer->flags & TEXTURELAYERFLAG_FOGDARKEN); } else { R_Mesh_TexBind(0, R_GetTexture(r_texture_white)); - RSurf_SetColorPointer(ent, surface, modelorg, layer->color[0], layer->color[1], layer->color[2], layer->color[3], 1, applycolor, layer->flags & TEXTURELAYERFLAG_FOGDARKEN); + RSurf_SetColorPointer(ent, surface, modelorg, layercolor[0], layercolor[1], layercolor[2], layercolor[3], 1, applycolor, layer->flags & TEXTURELAYERFLAG_FOGDARKEN); } GL_LockArrays(surface->num_firstvertex, surface->num_vertices); R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle)); GL_LockArrays(0, 0); } break; - case TEXTURELAYERTYPE_LIGHTMAP: + case TEXTURELAYERTYPE_LITTEXTURE_MULTIPASS: memset(&m, 0, sizeof(m)); + m.tex[0] = R_GetTexture(layer->texture); + m.texmatrix[0] = layer->texmatrix; + m.pointer_color = varray_color4f; + m.texrgbscale[0] = layertexrgbscale; R_Mesh_State(&m); for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++) { @@ -1970,7 +1873,7 @@ static void R_DrawTextureSurfaceList(const entity_render_t *ent, texture_t *text if (lightmode == 2) { R_Mesh_TexBind(0, R_GetTexture(r_texture_white)); - RSurf_SetColorPointer(ent, surface, modelorg, layer->color[0], layer->color[1], layer->color[2], layer->color[3], 2, applycolor, false); + RSurf_SetColorPointer(ent, surface, modelorg, 1, 1, 1, 1, 2, false, false); } else if (surface->lightmaptexture) { @@ -1980,27 +1883,43 @@ static void R_DrawTextureSurfaceList(const entity_render_t *ent, texture_t *text else { R_Mesh_TexBind(0, R_GetTexture(r_texture_white)); - // TODO: use a specialized RSurf_SetColorPointer - RSurf_SetColorPointer(ent, surface, modelorg, layer->color[0], layer->color[1], layer->color[2], layer->color[3], 1, applycolor, false); + RSurf_SetColorPointer(ent, surface, modelorg, 1, 1, 1, 1, 1, false, false); } GL_LockArrays(surface->num_firstvertex, surface->num_vertices); R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle)); GL_LockArrays(0, 0); } + GL_BlendFunc(GL_DST_COLOR, GL_SRC_COLOR); + memset(&m, 0, sizeof(m)); + m.tex[0] = R_GetTexture(layer->texture); + m.texmatrix[0] = layer->texmatrix; + m.pointer_color = varray_color4f; + m.texrgbscale[0] = layertexrgbscale; + R_Mesh_State(&m); + for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++) + { + surface = texturesurfacelist[texturesurfaceindex]; + RSurf_SetVertexPointer(ent, texture, surface, modelorg); + R_Mesh_TexCoordPointer(0, 2, surface->groupmesh->data_texcoordtexture2f); + RSurf_SetColorPointer(ent, surface, modelorg, layercolor[0], layercolor[1], layercolor[2], layercolor[3], 0, applycolor, layer->flags & TEXTURELAYERFLAG_FOGDARKEN); + GL_LockArrays(surface->num_firstvertex, surface->num_vertices); + R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle)); + GL_LockArrays(0, 0); + } break; - case TEXTURELAYERTYPE_VERTEXTEXTURE: + case TEXTURELAYERTYPE_LITTEXTURE_VERTEX: memset(&m, 0, sizeof(m)); m.tex[0] = R_GetTexture(layer->texture); m.texmatrix[0] = layer->texmatrix; + m.texrgbscale[0] = layertexrgbscale; m.pointer_color = varray_color4f; - m.texrgbscale[0] = layer->texrgbscale; R_Mesh_State(&m); for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++) { surface = texturesurfacelist[texturesurfaceindex]; RSurf_SetVertexPointer(ent, texture, surface, modelorg); R_Mesh_TexCoordPointer(0, 2, surface->groupmesh->data_texcoordtexture2f); - RSurf_SetColorPointer(ent, surface, modelorg, layer->color[0], layer->color[1], layer->color[2], layer->color[3], lightmode ? lightmode : 1, applycolor, layer->flags & TEXTURELAYERFLAG_FOGDARKEN); + RSurf_SetColorPointer(ent, surface, modelorg, layercolor[0], layercolor[1], layercolor[2], layercolor[3], lightmode ? lightmode : 1, applycolor, layer->flags & TEXTURELAYERFLAG_FOGDARKEN); GL_LockArrays(surface->num_firstvertex, surface->num_vertices); R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle)); GL_LockArrays(0, 0); @@ -2011,14 +1930,14 @@ static void R_DrawTextureSurfaceList(const entity_render_t *ent, texture_t *text m.tex[0] = R_GetTexture(layer->texture); m.texmatrix[0] = layer->texmatrix; m.pointer_color = varray_color4f; - m.texrgbscale[0] = layer->texrgbscale; + m.texrgbscale[0] = layertexrgbscale; R_Mesh_State(&m); for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++) { surface = texturesurfacelist[texturesurfaceindex]; RSurf_SetVertexPointer(ent, texture, surface, modelorg); R_Mesh_TexCoordPointer(0, 2, surface->groupmesh->data_texcoordtexture2f); - RSurf_SetColorPointer(ent, surface, modelorg, layer->color[0], layer->color[1], layer->color[2], layer->color[3], 0, applycolor, layer->flags & TEXTURELAYERFLAG_FOGDARKEN); + RSurf_SetColorPointer(ent, surface, modelorg, layercolor[0], layercolor[1], layercolor[2], layercolor[3], 0, applycolor, layer->flags & TEXTURELAYERFLAG_FOGDARKEN); GL_LockArrays(surface->num_firstvertex, surface->num_vertices); R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle)); GL_LockArrays(0, 0); @@ -2046,10 +1965,10 @@ static void R_DrawTextureSurfaceList(const entity_render_t *ent, texture_t *text { VectorSubtract(v, modelorg, diff); f = exp(fogdensity/DotProduct(diff, diff)); - c[0] = layer->color[0]; - c[1] = layer->color[1]; - c[2] = layer->color[2]; - c[3] = f * layer->color[3]; + c[0] = layercolor[0]; + c[1] = layercolor[1]; + c[2] = layercolor[2]; + c[3] = f * layercolor[3]; } GL_LockArrays(surface->num_firstvertex, surface->num_vertices); R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle)); @@ -2059,6 +1978,25 @@ static void R_DrawTextureSurfaceList(const entity_render_t *ent, texture_t *text default: Con_Printf("R_DrawTextureSurfaceList: unknown layer type %i\n", layer->type); } + // if trying to do overbright on first pass of an opaque surface + // when combine is not supported, brighten as a post process + if (layertexrgbscale > 1 && !gl_combine.integer && layer->depthmask) + { + int scale; + GL_BlendFunc(GL_DST_COLOR, GL_SRC_COLOR); + GL_Color(1, 1, 1, 1); + memset(&m, 0, sizeof(m)); + R_Mesh_State(&m); + for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++) + { + surface = texturesurfacelist[texturesurfaceindex]; + RSurf_SetVertexPointer(ent, texture, surface, modelorg); + GL_LockArrays(surface->num_firstvertex, surface->num_vertices); + for (scale = 1;scale < layertexrgbscale;scale <<= 1) + R_Mesh_Draw(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, (surface->groupmesh->data_element3i + 3 * surface->num_firsttriangle)); + GL_LockArrays(0, 0); + } + } } } if (texture->textureflags & Q3TEXTUREFLAG_TWOSIDED) diff --git a/gl_rsurf.c b/gl_rsurf.c index ab54df99..cff28d66 100644 --- a/gl_rsurf.c +++ b/gl_rsurf.c @@ -736,7 +736,7 @@ void R_Q1BSP_DrawShadowVolume(entity_render_t *ent, vec3_t relativelightorigin, #define RSURF_MAX_BATCHSURFACES 1024 -void R_Q1BSP_DrawLight(entity_render_t *ent, float *lightcolorbase, int numsurfaces, const int *surfacelist) +void R_Q1BSP_DrawLight(entity_render_t *ent, float *lightcolorbase, float *lightcolorpants, float *lightcolorshirt, int numsurfaces, const int *surfacelist) { model_t *model = ent->model; msurface_t *surface; @@ -745,13 +745,14 @@ void R_Q1BSP_DrawLight(entity_render_t *ent, float *lightcolorbase, int numsurfa msurface_t *batchsurfacelist[RSURF_MAX_BATCHSURFACES]; vec3_t modelorg; texture_t *tex; - vec3_t lightcolorpants, lightcolorshirt; rtexture_t *basetexture = NULL; rtexture_t *glosstexture = NULL; float specularscale = 0; qboolean skip; if (r_drawcollisionbrushes.integer >= 2) return; + if (VectorLength2(lightcolorbase) + VectorLength2(lightcolorpants) + VectorLength2(lightcolorshirt) < 0.0001) + return; R_UpdateAllTextureInfo(ent); Matrix4x4_Transform(&ent->inversematrix, r_vieworigin, modelorg); tex = NULL; @@ -798,32 +799,7 @@ void R_Q1BSP_DrawLight(entity_render_t *ent, float *lightcolorbase, int numsurfa specularscale = r_shadow_rtlight->specularscale * r_shadow_gloss2intensity.value; } } - VectorClear(lightcolorpants); - VectorClear(lightcolorshirt); - if (ent->colormap >= 0) - { - // 128-224 are backwards ranges - int b = (ent->colormap & 0xF) << 4;b += (b >= 128 && b < 224) ? 4 : 12; - if (texture->skin.pants && b < 224) - { - qbyte *bcolor = (qbyte *) (&palette_complete[b]); - lightcolorpants[0] = lightcolorbase[0] * bcolor[0] * (1.0f / 255.0f); - lightcolorpants[1] = lightcolorbase[1] * bcolor[1] * (1.0f / 255.0f); - lightcolorpants[2] = lightcolorbase[2] * bcolor[2] * (1.0f / 255.0f); - } - // 128-224 are backwards ranges - b = (ent->colormap & 0xF0);b += (b >= 128 && b < 224) ? 4 : 12; - if (texture->skin.shirt && b < 224) - { - qbyte *bcolor = (qbyte *) (&palette_complete[b]); - lightcolorshirt[0] = lightcolorbase[0] * bcolor[0] * (1.0f / 255.0f); - lightcolorshirt[1] = lightcolorbase[1] * bcolor[1] * (1.0f / 255.0f); - lightcolorshirt[2] = lightcolorbase[2] * bcolor[2] * (1.0f / 255.0f); - } - basetexture = texture->skin.base; - } - else - basetexture = texture->skin.merged ? texture->skin.merged : texture->skin.base; + basetexture = (ent->colormap < 0 && texture->skin.merged) ? texture->skin.merged : texture->skin.base; if ((r_shadow_rtlight->ambientscale + r_shadow_rtlight->diffusescale) * (VectorLength2(lightcolorbase) + VectorLength2(lightcolorpants) + VectorLength2(lightcolorshirt)) + specularscale * VectorLength2(lightcolorbase) < (1.0f / 1048576.0f)) skip = true; } diff --git a/model_shared.h b/model_shared.h index cbb6b818..3d76921e 100644 --- a/model_shared.h +++ b/model_shared.h @@ -145,10 +145,10 @@ typedef enum texturelayertype_e { TEXTURELAYERTYPE_INVALID, TEXTURELAYERTYPE_SKY, - TEXTURELAYERTYPE_LIGHTMAP_DOUBLEMODULATE_TEXTURE, - TEXTURELAYERTYPE_LIGHTMAP, + TEXTURELAYERTYPE_LITTEXTURE_COMBINE, + TEXTURELAYERTYPE_LITTEXTURE_MULTIPASS, + TEXTURELAYERTYPE_LITTEXTURE_VERTEX, TEXTURELAYERTYPE_TEXTURE, - TEXTURELAYERTYPE_VERTEXTEXTURE, TEXTURELAYERTYPE_FOG, } texturelayertype_t; @@ -172,7 +172,6 @@ typedef struct texturelayer_s rtexture_t *texture; matrix4x4_t texmatrix; vec4_t color; - int texrgbscale; int flags; } texturelayer_t; @@ -555,7 +554,7 @@ typedef struct model_s // draw a shadow volume for the model based on light source void(*DrawShadowVolume)(struct entity_render_s *ent, vec3_t relativelightorigin, float lightradius, int numsurfaces, const int *surfacelist, const vec3_t lightmins, const vec3_t lightmaxs); // draw the lighting on a model (through stencil) - void(*DrawLight)(struct entity_render_s *ent, float *lightcolor, int numsurfaces, const int *surfacelist); + void(*DrawLight)(struct entity_render_s *ent, vec3_t lightcolorbase, vec3_t lightcolorpants, vec3_t lightcolorshirt, int numsurfaces, const int *surfacelist); // trace a box against this model void (*TraceBox)(struct model_s *model, int frame, struct trace_s *trace, const vec3_t boxstartmins, const vec3_t boxstartmaxs, const vec3_t boxendmins, const vec3_t boxendmaxs, int hitsupercontentsmask); // fields belonging to some types of model @@ -657,7 +656,7 @@ void R_Q1BSP_Draw(struct entity_render_s *ent); void R_Q1BSP_GetLightInfo(struct entity_render_s *ent, vec3_t relativelightorigin, float lightradius, vec3_t outmins, vec3_t outmaxs, int *outleaflist, qbyte *outleafpvs, int *outnumleafspointer, int *outsurfacelist, qbyte *outsurfacepvs, int *outnumsurfacespointer); void R_Q1BSP_CompileShadowVolume(struct entity_render_s *ent, vec3_t relativelightorigin, float lightradius, int numsurfaces, const int *surfacelist); void R_Q1BSP_DrawShadowVolume(struct entity_render_s *ent, vec3_t relativelightorigin, float lightradius, int numsurfaces, const int *surfacelist, const vec3_t lightmins, const vec3_t lightmaxs); -void R_Q1BSP_DrawLight(struct entity_render_s *ent, float *lightcolor, int numsurfaces, const int *surfacelist); +void R_Q1BSP_DrawLight(struct entity_render_s *ent, vec3_t lightcolorbase, vec3_t lightcolorpants, vec3_t lightcolorshirt, int numsurfaces, const int *surfacelist); // alias models struct frameblend_s; diff --git a/r_shadow.c b/r_shadow.c index 59d72996..392d1f49 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -1069,7 +1069,11 @@ static matrix4x4_t r_shadow_entitytoattenuationxyz; // this transforms only the Z to S, and T is always 0.5 static matrix4x4_t r_shadow_entitytoattenuationz; // rtlight->color * r_dlightstylevalue[rtlight->style] / 256 * r_shadow_lightintensityscale.value * ent->colormod * ent->alpha -static vec3_t r_shadow_entitylightcolor; +static vec3_t r_shadow_entitylightcolorbase; +// rtlight->color * r_dlightstylevalue[rtlight->style] / 256 * r_shadow_lightintensityscale.value * ent->colormap_pantscolor * ent->alpha +static vec3_t r_shadow_entitylightcolorpants; +// rtlight->color * r_dlightstylevalue[rtlight->style] / 256 * r_shadow_lightintensityscale.value * ent->colormap_shirtcolor * ent->alpha +static vec3_t r_shadow_entitylightcolorshirt; static int r_shadow_lightpermutation; static int r_shadow_lightprog; @@ -2713,12 +2717,18 @@ void R_Shadow_DrawEntityShadow(entity_render_t *ent, rtlight_t *rtlight, int num } } -void R_Shadow_DrawEntityLight(entity_render_t *ent, rtlight_t *rtlight, vec3_t lightcolorbase, int numsurfaces, int *surfacelist) +void R_Shadow_DrawEntityLight(entity_render_t *ent, rtlight_t *rtlight, vec3_t lightcolor, int numsurfaces, int *surfacelist) { // set up properties for rendering light onto this entity - r_shadow_entitylightcolor[0] = lightcolorbase[0] * ent->colormod[0] * ent->alpha; - r_shadow_entitylightcolor[1] = lightcolorbase[1] * ent->colormod[1] * ent->alpha; - r_shadow_entitylightcolor[2] = lightcolorbase[2] * ent->colormod[2] * ent->alpha; + r_shadow_entitylightcolorbase[0] = lightcolor[0] * ent->colormod[0] * ent->alpha; + r_shadow_entitylightcolorbase[1] = lightcolor[1] * ent->colormod[1] * ent->alpha; + r_shadow_entitylightcolorbase[2] = lightcolor[2] * ent->colormod[2] * ent->alpha; + r_shadow_entitylightcolorpants[0] = lightcolor[0] * ent->colormap_pantscolor[0] * ent->alpha; + r_shadow_entitylightcolorpants[1] = lightcolor[1] * ent->colormap_pantscolor[1] * ent->alpha; + r_shadow_entitylightcolorpants[2] = lightcolor[2] * ent->colormap_pantscolor[2] * ent->alpha; + r_shadow_entitylightcolorshirt[0] = lightcolor[0] * ent->colormap_shirtcolor[0] * ent->alpha; + r_shadow_entitylightcolorshirt[1] = lightcolor[1] * ent->colormap_shirtcolor[1] * ent->alpha; + r_shadow_entitylightcolorshirt[2] = lightcolor[2] * ent->colormap_shirtcolor[2] * ent->alpha; Matrix4x4_Concat(&r_shadow_entitytolight, &rtlight->matrix_worldtolight, &ent->matrix); Matrix4x4_Concat(&r_shadow_entitytoattenuationxyz, &matrix_attenuationxyz, &r_shadow_entitytolight); Matrix4x4_Concat(&r_shadow_entitytoattenuationz, &matrix_attenuationz, &r_shadow_entitytolight); @@ -2736,9 +2746,9 @@ void R_Shadow_DrawEntityLight(entity_render_t *ent, rtlight_t *rtlight, vec3_t l } } if (ent == r_refdef.worldentity) - ent->model->DrawLight(ent, r_shadow_entitylightcolor, numsurfaces, surfacelist); + ent->model->DrawLight(ent, r_shadow_entitylightcolorbase, r_shadow_entitylightcolorpants, r_shadow_entitylightcolorshirt, numsurfaces, surfacelist); else - ent->model->DrawLight(ent, r_shadow_entitylightcolor, ent->model->nummodelsurfaces, ent->model->surfacelist); + ent->model->DrawLight(ent, r_shadow_entitylightcolorbase, r_shadow_entitylightcolorpants, r_shadow_entitylightcolorshirt, ent->model->nummodelsurfaces, ent->model->surfacelist); } void R_DrawRTLight(rtlight_t *rtlight, qboolean visible) -- 2.39.2