mirror of
https://git.code.sf.net/p/quake/newtree
synced 2025-05-31 17:21:46 +00:00
Performance tweaks to Alias model rendering in GL. I get 0.5fps out of it
in overkill, but every little bit counts. :)
This commit is contained in:
parent
c316ae0069
commit
3a2389c3dc
1 changed files with 64 additions and 61 deletions
|
@ -385,6 +385,13 @@ GL_DrawAliasFrame (aliashdr_t *paliashdr, int posenum, qboolean fb)
|
||||||
if (modelalpha != 1.0)
|
if (modelalpha != 1.0)
|
||||||
glDepthMask (GL_FALSE);
|
glDepthMask (GL_FALSE);
|
||||||
|
|
||||||
|
if (fb) { // don't do this in the loop, it doesn't change
|
||||||
|
if (lighthalf)
|
||||||
|
glColor4f (0.5, 0.5, 0.5, modelalpha);
|
||||||
|
else
|
||||||
|
glColor4f (1, 1, 1, modelalpha);
|
||||||
|
}
|
||||||
|
|
||||||
while ((count = *order++)) {
|
while ((count = *order++)) {
|
||||||
// get the vertex count and primitive type
|
// get the vertex count and primitive type
|
||||||
if (count < 0) {
|
if (count < 0) {
|
||||||
|
@ -399,9 +406,7 @@ GL_DrawAliasFrame (aliashdr_t *paliashdr, int posenum, qboolean fb)
|
||||||
glTexCoord2f (((float *) order)[0], ((float *) order)[1]);
|
glTexCoord2f (((float *) order)[0], ((float *) order)[1]);
|
||||||
order += 2;
|
order += 2;
|
||||||
|
|
||||||
if (fb) {
|
if (!fb) {
|
||||||
glColor4f (1, 1, 1, modelalpha);
|
|
||||||
} else {
|
|
||||||
// normals and vertexes come from the frame list
|
// normals and vertexes come from the frame list
|
||||||
l = shadedots[verts->lightnormalindex] * shadelight;
|
l = shadedots[verts->lightnormalindex] * shadelight;
|
||||||
|
|
||||||
|
@ -419,6 +424,7 @@ GL_DrawAliasFrame (aliashdr_t *paliashdr, int posenum, qboolean fb)
|
||||||
|
|
||||||
if (modelalpha != 1.0)
|
if (modelalpha != 1.0)
|
||||||
glDepthMask (GL_TRUE);
|
glDepthMask (GL_TRUE);
|
||||||
|
|
||||||
glColor3ubv (lighthalf_v);
|
glColor3ubv (lighthalf_v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -430,12 +436,12 @@ GL_DrawAliasFrame (aliashdr_t *paliashdr, int posenum, qboolean fb)
|
||||||
void
|
void
|
||||||
GL_DrawAliasBlendedFrame (aliashdr_t *paliashdr, int pose1, int pose2, float blend, qboolean fb)
|
GL_DrawAliasBlendedFrame (aliashdr_t *paliashdr, int pose1, int pose2, float blend, qboolean fb)
|
||||||
{
|
{
|
||||||
float l;
|
float light;
|
||||||
trivertx_t *verts1;
|
float lerp;
|
||||||
trivertx_t *verts2;
|
trivertx_t *verts1;
|
||||||
int *order;
|
trivertx_t *verts2;
|
||||||
int count;
|
int *order;
|
||||||
vec3_t d;
|
int count;
|
||||||
|
|
||||||
lastposenum0 = pose1;
|
lastposenum0 = pose1;
|
||||||
lastposenum = pose2;
|
lastposenum = pose2;
|
||||||
|
@ -451,8 +457,15 @@ GL_DrawAliasBlendedFrame (aliashdr_t *paliashdr, int pose1, int pose2, float ble
|
||||||
if (modelalpha != 1.0)
|
if (modelalpha != 1.0)
|
||||||
glDepthMask (GL_FALSE);
|
glDepthMask (GL_FALSE);
|
||||||
|
|
||||||
while ((count = *order++)) {
|
if (fb) { // don't do this in the loop, it doesn't change
|
||||||
// get the vertex count and primitive type
|
if (lighthalf)
|
||||||
|
glColor4f (0.5, 0.5, 0.5, modelalpha);
|
||||||
|
else
|
||||||
|
glColor4f (1, 1, 1, modelalpha);
|
||||||
|
}
|
||||||
|
|
||||||
|
lerp = 1 - blend;
|
||||||
|
while ((count = *order++)) { // get the vertex count and primitive type
|
||||||
|
|
||||||
if (count < 0) {
|
if (count < 0) {
|
||||||
count = -count;
|
count = -count;
|
||||||
|
@ -466,23 +479,19 @@ GL_DrawAliasBlendedFrame (aliashdr_t *paliashdr, int pose1, int pose2, float ble
|
||||||
glTexCoord2f (((float *) order)[0], ((float *) order)[1]);
|
glTexCoord2f (((float *) order)[0], ((float *) order)[1]);
|
||||||
order += 2;
|
order += 2;
|
||||||
|
|
||||||
if (fb) {
|
if (!fb) {
|
||||||
glColor4f (1, 1, 1, modelalpha);
|
|
||||||
} else {
|
|
||||||
// normals and vertexes come from the frame list
|
// normals and vertexes come from the frame list
|
||||||
// blend the light intensity from the two frames together
|
// blend the light intensity from the two frames together
|
||||||
d[0] = shadedots[verts2->lightnormalindex] - shadedots[verts1->lightnormalindex];
|
light = shadelight * ((shadedots[verts1->lightnormalindex] * lerp)
|
||||||
|
+ (shadedots[verts2->lightnormalindex] * blend));
|
||||||
l = shadelight * (shadedots[verts1->lightnormalindex] + (blend * d[0]));
|
glColor4f (shadecolor[0] * light, shadecolor[1] * light,
|
||||||
glColor4f (shadecolor[0] * l, shadecolor[1] * l, shadecolor[2] * l, modelalpha);
|
shadecolor[2] * light, modelalpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
VectorSubtract (verts2->v, verts1->v, d);
|
|
||||||
|
|
||||||
// blend the vertex positions from each frame together
|
// blend the vertex positions from each frame together
|
||||||
glVertex3f (verts1->v[0] + (blend * d[0]),
|
glVertex3f ((verts1->v[0] * lerp) + (verts2->v[0] * blend),
|
||||||
verts1->v[1] + (blend * d[1]),
|
(verts1->v[1] * lerp) + (verts2->v[1] * blend),
|
||||||
verts1->v[2] + (blend * d[2]));
|
(verts1->v[2] * lerp) + (verts2->v[2] * blend));
|
||||||
|
|
||||||
verts1++;
|
verts1++;
|
||||||
verts2++;
|
verts2++;
|
||||||
|
@ -562,12 +571,14 @@ void
|
||||||
GL_DrawAliasBlendedShadow (aliashdr_t *paliashdr, int pose1, int pose2, entity_t *e)
|
GL_DrawAliasBlendedShadow (aliashdr_t *paliashdr, int pose1, int pose2, entity_t *e)
|
||||||
{
|
{
|
||||||
trivertx_t *verts1, *verts2;
|
trivertx_t *verts1, *verts2;
|
||||||
vec3_t point1, point2, d;
|
float lerp;
|
||||||
|
vec3_t point1, point2;
|
||||||
int *order, count;
|
int *order, count;
|
||||||
float height, lheight, blend;
|
float height, lheight, blend;
|
||||||
|
|
||||||
blend = (realtime - e->frame_start_time) / e->frame_interval;
|
blend = (realtime - e->frame_start_time) / e->frame_interval;
|
||||||
blend = min (blend, 1);
|
blend = min (blend, 1);
|
||||||
|
lerp = 1 - blend;
|
||||||
|
|
||||||
lheight = e->origin[2] - lightspot[2];
|
lheight = e->origin[2] - lightspot[2];
|
||||||
height = -lheight + 1.0;
|
height = -lheight + 1.0;
|
||||||
|
@ -606,9 +617,9 @@ GL_DrawAliasBlendedShadow (aliashdr_t *paliashdr, int pose1, int pose2, entity_t
|
||||||
point2[0] -= shadevector[0] * (point2[2] + lheight);
|
point2[0] -= shadevector[0] * (point2[2] + lheight);
|
||||||
point2[1] -= shadevector[1] * (point2[2] + lheight);
|
point2[1] -= shadevector[1] * (point2[2] + lheight);
|
||||||
|
|
||||||
VectorSubtract (point2, point1, d);
|
glVertex3f ((point1[0] * lerp) + (point2[0] * blend),
|
||||||
|
(point1[1] * lerp) + (point2[1] * blend),
|
||||||
glVertex3f (point1[0] + (blend * d[0]), point1[1] + (blend * d[1]), height);
|
height);
|
||||||
|
|
||||||
verts1++;
|
verts1++;
|
||||||
verts2++;
|
verts2++;
|
||||||
|
@ -719,10 +730,10 @@ R_DrawAliasModel (entity_t *e)
|
||||||
aliashdr_t *paliashdr;
|
aliashdr_t *paliashdr;
|
||||||
float an;
|
float an;
|
||||||
int anim;
|
int anim;
|
||||||
qboolean torch = false;
|
|
||||||
int texture;
|
int texture;
|
||||||
int fb_texture = 0;
|
int fb_texture = 0;
|
||||||
int skinnum;
|
int skinnum;
|
||||||
|
qboolean modelIsFullbright = false;
|
||||||
|
|
||||||
clmodel = currententity->model;
|
clmodel = currententity->model;
|
||||||
|
|
||||||
|
@ -772,17 +783,15 @@ R_DrawAliasModel (entity_t *e)
|
||||||
// clamp lighting so it doesn't overbright as much
|
// clamp lighting so it doesn't overbright as much
|
||||||
shadelight = min (shadelight, 100);
|
shadelight = min (shadelight, 100);
|
||||||
|
|
||||||
// ZOID: never allow players to go totally black
|
// never allow players to go totally black
|
||||||
if (strequal (clmodel->name, "progs/player.mdl")) {
|
if (strequal (clmodel->name, "progs/player.mdl")) {
|
||||||
shadelight = max (shadelight, 8);
|
shadelight = max (shadelight, 8);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strnequal (clmodel->name, "progs/flame", 11)) {
|
if (strnequal (clmodel->name, "progs/flame", 11)
|
||||||
torch = true;
|
|| strnequal (clmodel->name, "progs/bolt", 10)) {
|
||||||
if (!gl_fb_models->int_val) { // make torches full brightness anyway
|
modelIsFullbright = true;
|
||||||
shadelight = 256;
|
shadelight = 256; // make certain models full brightness always
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
shadedots = r_avertexnormal_dots[((int) (e->angles[1] * (SHADEDOT_QUANT / 360.0))) & (SHADEDOT_QUANT - 1)];
|
shadedots = r_avertexnormal_dots[((int) (e->angles[1] * (SHADEDOT_QUANT / 360.0))) & (SHADEDOT_QUANT - 1)];
|
||||||
|
@ -794,16 +803,12 @@ R_DrawAliasModel (entity_t *e)
|
||||||
shadevector[2] = 1;
|
shadevector[2] = 1;
|
||||||
VectorNormalize (shadevector);
|
VectorNormalize (shadevector);
|
||||||
|
|
||||||
//
|
|
||||||
// locate the proper data
|
// locate the proper data
|
||||||
//
|
|
||||||
paliashdr = (aliashdr_t *) Mod_Extradata (currententity->model);
|
paliashdr = (aliashdr_t *) Mod_Extradata (currententity->model);
|
||||||
|
|
||||||
c_alias_polys += paliashdr->mdl.numtris;
|
c_alias_polys += paliashdr->mdl.numtris;
|
||||||
|
|
||||||
//
|
|
||||||
// draw all the triangles
|
// draw all the triangles
|
||||||
//
|
|
||||||
|
|
||||||
glPushMatrix ();
|
glPushMatrix ();
|
||||||
R_RotateForEntity (e);
|
R_RotateForEntity (e);
|
||||||
|
@ -832,7 +837,7 @@ R_DrawAliasModel (entity_t *e)
|
||||||
}
|
}
|
||||||
|
|
||||||
texture = paliashdr->gl_texturenum[skinnum][anim];
|
texture = paliashdr->gl_texturenum[skinnum][anim];
|
||||||
if (gl_fb_models->int_val)
|
if (gl_fb_models->int_val && !modelIsFullbright)
|
||||||
fb_texture = paliashdr->gl_fb_texturenum[skinnum][anim];
|
fb_texture = paliashdr->gl_fb_texturenum[skinnum][anim];
|
||||||
|
|
||||||
// we can't dynamically colormap textures, so they are cached
|
// we can't dynamically colormap textures, so they are cached
|
||||||
|
@ -885,12 +890,10 @@ R_DrawAliasModel (entity_t *e)
|
||||||
|
|
||||||
if (r_shadows->int_val) {
|
if (r_shadows->int_val) {
|
||||||
// torches, grenades, and lightning bolts do not have shadows
|
// torches, grenades, and lightning bolts do not have shadows
|
||||||
if (torch)
|
if (modelIsFullbright)
|
||||||
return;
|
return;
|
||||||
if (strequal (clmodel->name, "progs/grenade.mdl"))
|
if (strequal (clmodel->name, "progs/grenade.mdl"))
|
||||||
return;
|
return;
|
||||||
if (strnequal (clmodel->name, "progs/bolt", 10))
|
|
||||||
return;
|
|
||||||
|
|
||||||
glPushMatrix ();
|
glPushMatrix ();
|
||||||
R_RotateForEntity (e);
|
R_RotateForEntity (e);
|
||||||
|
@ -913,38 +916,40 @@ R_DrawAliasModel (entity_t *e)
|
||||||
//==================================================================================
|
//==================================================================================
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=============
|
R_ShowNearestLoc
|
||||||
R_ShowNearestLoc
|
|
||||||
=============
|
Display the nearest symbolic location (.loc files)
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
R_ShowNearestLoc (void)
|
R_ShowNearestLoc (void)
|
||||||
{
|
{
|
||||||
location_t *nearloc;
|
location_t *nearloc;
|
||||||
vec3_t trueloc;
|
vec3_t trueloc;
|
||||||
dlight_t *dl;
|
dlight_t *dl;
|
||||||
|
|
||||||
if (r_drawentities->int_val)
|
if (r_drawentities->int_val)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
nearloc = locs_find (cl.simorg);
|
nearloc = locs_find (cl.simorg);
|
||||||
|
|
||||||
if (nearloc) {
|
if (nearloc) {
|
||||||
dl = CL_AllocDlight (4096);
|
dl = CL_AllocDlight (4096);
|
||||||
VectorCopy (nearloc->loc, dl->origin);
|
VectorCopy (nearloc->loc, dl->origin);
|
||||||
dl->radius = 200;
|
dl->radius = 200;
|
||||||
dl->die = cl.time + 0.1;
|
dl->die = cl.time + 0.1;
|
||||||
dl->color[0]=0;
|
dl->color[0] = 0;
|
||||||
dl->color[1]=1;
|
dl->color[1] = 1;
|
||||||
dl->color[2]=0;
|
dl->color[2] = 0;
|
||||||
|
|
||||||
VectorCopy(nearloc->loc,trueloc);
|
VectorCopy (nearloc->loc, trueloc);
|
||||||
R_RunSpikeEffect(trueloc,7);
|
R_RunSpikeEffect (trueloc, 7);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=============
|
R_DrawEntitiesOnList
|
||||||
R_DrawEntitiesOnList
|
|
||||||
=============
|
Draw all the entities we have information on.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
R_DrawEntitiesOnList (void)
|
R_DrawEntitiesOnList (void)
|
||||||
|
@ -1125,9 +1130,7 @@ R_SetupGL (void)
|
||||||
extern int glwidth, glheight;
|
extern int glwidth, glheight;
|
||||||
int x, x2, y2, y, w, h;
|
int x, x2, y2, y, w, h;
|
||||||
|
|
||||||
//
|
|
||||||
// set up viewpoint
|
// set up viewpoint
|
||||||
//
|
|
||||||
glMatrixMode (GL_PROJECTION);
|
glMatrixMode (GL_PROJECTION);
|
||||||
glLoadIdentity ();
|
glLoadIdentity ();
|
||||||
x = r_refdef.vrect.x * glwidth / vid.width;
|
x = r_refdef.vrect.x * glwidth / vid.width;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue