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
This commit is contained in:
TimeServ 2006-06-08 06:24:07 +00:00
parent 7830dc402a
commit bded857feb
6 changed files with 69 additions and 28 deletions

View file

@ -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,8 +1747,15 @@ void R_DrawGAliasModel (entity_t *e)
if (ambientlight[i] < 8)
ambientlight[i] = shadelight[i] = 8;
}
}
if (clmodel->engineflags & MDLF_FLAME)
{
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)
@ -1757,16 +1764,18 @@ void R_DrawGAliasModel (entity_t *e)
shadelight[i] /= 200.0/255;
ambientlight[i] /= 200.0/255;
}
}
if ((e->drawflags & MLS_MASKIN) == MLS_ABSLIGHT)
{
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);

View file

@ -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;

View file

@ -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
//============================================================================
/*

View file

@ -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"},

View file

@ -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;

View file

@ -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;