From bded857feb1205cc456477e36563cff898eab3d2 Mon Sep 17 00:00:00 2001 From: TimeServ Date: Thu, 8 Jun 2006 06:24:07 +0000 Subject: [PATCH] force flame models to render fullbright, very slight fps increase with r_shadows git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2320 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/gl/gl_alias.c | 53 +++++++++++++++++++++++------------------ engine/gl/gl_model.c | 11 ++++++++- engine/gl/gl_model.h | 3 ++- engine/server/pr_cmds.c | 1 + engine/sw/r_main.c | 18 ++++++++++++-- engine/sw/sw_model.c | 11 ++++++++- 6 files changed, 69 insertions(+), 28 deletions(-) diff --git a/engine/gl/gl_alias.c b/engine/gl/gl_alias.c index d8e0a92b2..c3e962655 100644 --- a/engine/gl/gl_alias.c +++ b/engine/gl/gl_alias.c @@ -341,7 +341,7 @@ static hashtable_t skincolourmapped; static vec3_t shadevector; static vec3_t shadelight, ambientlight; -static void R_LerpFrames(mesh_t *mesh, galiaspose_t *p1, galiaspose_t *p2, float lerp, qbyte alpha, float expand) +static void R_LerpFrames(mesh_t *mesh, galiaspose_t *p1, galiaspose_t *p2, float lerp, qbyte alpha, float expand, qboolean nolightdir) { extern cvar_t r_nolerp, r_nolightdir; float blerp = 1-lerp; @@ -360,7 +360,7 @@ static void R_LerpFrames(mesh_t *mesh, galiaspose_t *p1, galiaspose_t *p2, float { mesh->normals_array = (vec3_t*)((char *)p1 + p1->ofsnormals); mesh->xyz_array = p1v; - if (r_nolightdir.value) + if (r_nolightdir.value || nolightdir) { mesh->colors_array = NULL; } @@ -391,7 +391,7 @@ static void R_LerpFrames(mesh_t *mesh, galiaspose_t *p1, galiaspose_t *p2, float } else { - if (r_nolightdir.value) + if (r_nolightdir.value || nolightdir) { mesh->colors_array = NULL; for (i = 0; i < mesh->numvertexes; i++) @@ -786,7 +786,7 @@ static void R_GAliasApplyLighting(mesh_t *mesh, vec3_t org, vec3_t angles, float } } -static qboolean R_GAliasBuildMesh(mesh_t *mesh, galiasinfo_t *inf, int frame1, int frame2, float lerp, float alpha, float fg1time, float fg2time) +static qboolean R_GAliasBuildMesh(mesh_t *mesh, galiasinfo_t *inf, int frame1, int frame2, float lerp, float alpha, float fg1time, float fg2time, qboolean nolightdir) { galiasgroup_t *g1, *g2; @@ -963,7 +963,7 @@ static qboolean R_GAliasBuildMesh(mesh_t *mesh, galiasinfo_t *inf, int frame1, i R_LerpFrames(mesh, (galiaspose_t *)((char *)g1 + g1->poseofs + sizeof(galiaspose_t)*frame1), (galiaspose_t *)((char *)g2 + g2->poseofs + sizeof(galiaspose_t)*frame2), - 1-lerp, (qbyte)(alpha*255), currententity->fatness);//20*sin(cl.time)); + 1-lerp, (qbyte)(alpha*255), currententity->fatness, nolightdir); return true; //to allow the mesh to be dlighted. } @@ -1626,6 +1626,7 @@ void R_DrawGAliasModel (entity_t *e) float tmatrix[3][4]; qboolean needrecolour; + qboolean nolightdir; currententity = e; @@ -1714,6 +1715,7 @@ void R_DrawGAliasModel (entity_t *e) //MORE HUGE HACKS! WHEN WILL THEY CEASE! // clamp lighting so it doesn't overbright as much // ZOID: never allow players to go totally black + nolightdir = false; if (clmodel->engineflags & MDLF_PLAYER) { float fb = r_fullbrightSkins.value; @@ -1727,11 +1729,9 @@ void R_DrawGAliasModel (entity_t *e) if (fb >= 1 && r_fb_models.value) { - for (i = 0; i < 3; i++) - { - ambientlight[i] = 4096; - shadelight[i] = 4096; - } + ambientlight[0] = ambientlight[1] = ambientlight[2] = 4096; + shadelight[0] = shadelight[1] = shadelight[2] = 4096; + nolightdir = true; } else { @@ -1747,15 +1747,23 @@ void R_DrawGAliasModel (entity_t *e) if (ambientlight[i] < 8) ambientlight[i] = shadelight[i] = 8; } - } - for (i = 0; i < 3; i++) + if (clmodel->engineflags & MDLF_FLAME) { - if (ambientlight[i] > 128) - ambientlight[i] = 128; + shadelight[0] = shadelight[1] = shadelight[2] = 4096; + ambientlight[0] = ambientlight[1] = ambientlight[2] = 4096; + nolightdir = true; + } + else + { + for (i = 0; i < 3; i++) + { + if (ambientlight[i] > 128) + ambientlight[i] = 128; - shadelight[i] /= 200.0/255; - ambientlight[i] /= 200.0/255; + shadelight[i] /= 200.0/255; + ambientlight[i] /= 200.0/255; + } } if ((e->drawflags & MLS_MASKIN) == MLS_ABSLIGHT) @@ -1763,10 +1771,11 @@ void R_DrawGAliasModel (entity_t *e) shadelight[0] = shadelight[1] = shadelight[2] = e->abslight; ambientlight[0] = ambientlight[1] = ambientlight[2] = 0; } - if ((e->drawflags & MLS_MASKIN) == MLS_FULLBRIGHT || e->flags & Q2RF_FULLBRIGHT) + if ((e->drawflags & MLS_MASKIN) == MLS_FULLBRIGHT || (e->flags & Q2RF_FULLBRIGHT)) { shadelight[0] = shadelight[1] = shadelight[2] = 255; ambientlight[0] = ambientlight[1] = ambientlight[2] = 0; + nolightdir = true; } //#define SHOWLIGHTDIR @@ -1982,7 +1991,7 @@ void R_DrawGAliasModel (entity_t *e) memset(&mesh, 0, sizeof(mesh)); for(surfnum=0; inf; ((inf->nextsurf)?(inf = (galiasinfo_t*)((char *)inf + inf->nextsurf)):(inf=NULL)), surfnum++) { - needrecolour = R_GAliasBuildMesh(&mesh, inf, e->frame, e->oldframe, e->lerpfrac, e->shaderRGBAf[3], e->frame1time, e->frame2time); + needrecolour = R_GAliasBuildMesh(&mesh, inf, e->frame, e->oldframe, e->lerpfrac, e->shaderRGBAf[3], e->frame1time, e->frame2time, nolightdir); c_alias_polys += mesh.numindexes/3; @@ -2579,7 +2588,7 @@ void R_DrawGAliasModelLighting (entity_t *e, vec3_t lightpos, vec3_t colours, fl // qglDepthFunc(GL_ALWAYS); for(surfnum=0;inf;surfnum++) { - R_GAliasBuildMesh(&mesh, inf, e->frame, e->oldframe, e->lerpfrac, e->alpha, e->frame1time, e->frame2time); + R_GAliasBuildMesh(&mesh, inf, e->frame, e->oldframe, e->lerpfrac, e->alpha, e->frame1time, e->frame2time, false); mesh.colors_array = tempColours; tex = GL_ChooseSkin(inf, clmodel->name, surfnum, e); @@ -2631,9 +2640,7 @@ void R_DrawGAliasShadowVolume(entity_t *e, vec3_t lightpos, float radius) mesh_t mesh; vec3_t lightorg; - if (clmodel->engineflags & MDLF_FLAME) - return; - if (!strncmp (clmodel->name, "progs/bolt", 10)) + if (clmodel->engineflags & (MDLF_FLAME | MDLF_BOLT)) return; if (r_noaliasshadows.value) return; @@ -2655,7 +2662,7 @@ void R_DrawGAliasShadowVolume(entity_t *e, vec3_t lightpos, float radius) { if (inf->ofs_trineighbours) { - R_GAliasBuildMesh(&mesh, inf, e->frame, e->oldframe, e->lerpfrac, 1, e->frame1time, e->frame2time); + R_GAliasBuildMesh(&mesh, inf, e->frame, e->oldframe, e->lerpfrac, 1, e->frame1time, e->frame2time, true); R_CalcFacing(&mesh, lightorg); R_ProjectShadowVolume(&mesh, lightorg); R_DrawShadowVolume(&mesh); diff --git a/engine/gl/gl_model.c b/engine/gl/gl_model.c index fed854eb9..bf23ebb9a 100644 --- a/engine/gl/gl_model.c +++ b/engine/gl/gl_model.c @@ -516,8 +516,17 @@ couldntload: // set necessary engine flags for loading purposes if (!strcmp(mod->name, "progs/player.mdl")) mod->engineflags |= MDLF_PLAYER | MDLF_DOCRC; - else if (!strcmp(mod->name, "progs/flame.mdl") || !strcmp(mod->name, "progs/flame2.mdl")) + else if (!strcmp(mod->name, "progs/flame.mdl") || + !strcmp(mod->name, "progs/flame2.mdl")) mod->engineflags |= MDLF_FLAME; + else if (!strcmp(mod->name, "progs/bolt.mdl") || + !strcmp(mod->name, "progs/bolt2.mdl") || + !strcmp(mod->name, "progs/bolt3.mdl") || + !strcmp(mod->name, "progs/beam.mdl") || + !strcmp(mod->name, "models/stsunsf2.mdl") || + !strcmp(mod->name, "models/stsunsf1.mdl") || + !strcmp(mod->name, "models/stice.mdl")) + mod->engineflags |= MDLF_BOLT; else if (!strcmp(mod->name, "progs/eyes.mdl")) mod->engineflags |= MDLF_DOCRC; diff --git a/engine/gl/gl_model.h b/engine/gl/gl_model.h index dcfd5c0c6..1b770fa4d 100644 --- a/engine/gl/gl_model.h +++ b/engine/gl/gl_model.h @@ -808,9 +808,10 @@ typedef struct model_s #define MDLF_NODEFAULTTRAIL 0x02 #define MDLF_RGBLIGHTING 0x04 #define MDLF_PLAYER 0x08 // players have specific lighting values -#define MDLF_FLAME 0x10 // can be excluded with r_drawflame +#define MDLF_FLAME 0x10 // can be excluded with r_drawflame, fullbright render hack #define MDLF_DOCRC 0x20 // model needs CRC built #define MDLF_NEEDOVERBRIGHT 0x40 // only overbright these models with gl_overbright_all set +#define MDLF_BOLT 0x80 // doesn't produce shadows //============================================================================ /* diff --git a/engine/server/pr_cmds.c b/engine/server/pr_cmds.c index d867a6519..28a244cd2 100644 --- a/engine/server/pr_cmds.c +++ b/engine/server/pr_cmds.c @@ -6285,6 +6285,7 @@ lh_extension_t QSG_Extensions[] = { {"DP_EF_FULLBRIGHT"}, //Rerouted to hexen2 support. {"DP_EF_NODRAW"}, //implemented by sending it with no modelindex {"DP_EF_RED"}, + {"DP_ENT_COLORMOD"}, {"DP_ENT_EXTERIORMODELTOCLIENT"}, //only in dp6 currently {"DP_ENT_GLOW"}, {"DP_ENT_VIEWMODEL"}, diff --git a/engine/sw/r_main.c b/engine/sw/r_main.c index 58fd0f4eb..bea0c899c 100644 --- a/engine/sw/r_main.c +++ b/engine/sw/r_main.c @@ -773,7 +773,21 @@ void SWR_DrawEntitiesOnList (void) else org = currententity->origin; - if (fb >= 1 && r_fb_models.value) + if ((currententity->drawflags & MLS_MASKIN) == MLS_FULLBRIGHT + || (currententity->flags & Q2RF_FULLBRIGHT) + || (currententity->model->engineflags & MDLF_FLAME)) + { + lighting.ambientlight = 4096; + lighting.shadelight = 4096; + lighting.plightvec = lightvec; + } + else if ((currententity->drawflags & MLS_MASKIN) == MLS_ABSLIGHT) + { + lighting.shadelight = currententity->abslight; + lighting.ambientlight = 0; + lighting.plightvec = lightvec; + } + else if (fb >= 1 && r_fb_models.value) { lighting.ambientlight = 4096; lighting.shadelight = 4096; @@ -801,7 +815,7 @@ void SWR_DrawEntitiesOnList (void) lighting.ambientlight += add; } } - + // clamp lighting so it doesn't overbright as much if (lighting.ambientlight > 128) lighting.ambientlight = 128; diff --git a/engine/sw/sw_model.c b/engine/sw/sw_model.c index 148ef7c25..9d983eb0d 100644 --- a/engine/sw/sw_model.c +++ b/engine/sw/sw_model.c @@ -363,8 +363,17 @@ model_t *SWMod_LoadModel (model_t *mod, qboolean crash) { mod->engineflags |= MDLF_PLAYER | MDLF_DOCRC; } - else if (!strcmp(mod->name, "progs/flame.mdl") || !strcmp(mod->name, "progs/flame2.mdl")) + else if (!strcmp(mod->name, "progs/flame.mdl") || + !strcmp(mod->name, "progs/flame2.mdl")) mod->engineflags |= MDLF_FLAME; + else if (!strcmp(mod->name, "progs/bolt.mdl") || + !strcmp(mod->name, "progs/bolt2.mdl") || + !strcmp(mod->name, "progs/bolt3.mdl") || + !strcmp(mod->name, "progs/beam.mdl") || + !strcmp(mod->name, "models/stsunsf2.mdl") || + !strcmp(mod->name, "models/stsunsf1.mdl") || + !strcmp(mod->name, "models/stice.mdl")) + mod->engineflags |= MDLF_BOLT; else if (!strcmp(mod->name, "progs/eyes.mdl")) mod->engineflags |= MDLF_DOCRC;