dynamic light speedup, patch from Eric Wasylishen, based on an earlier work by MH.

git-svn-id: http://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@933 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
sezero 2014-07-12 07:01:58 +00:00
parent 93cff46ed7
commit e78f6bb02c
3 changed files with 20 additions and 9 deletions

View file

@ -286,7 +286,7 @@ int R_LightPoint (vec3_t p);
void GL_SubdivideSurface (msurface_t *fa);
void R_BuildLightMap (msurface_t *surf, byte *dest, int stride);
void R_RenderDynamicLightmaps (msurface_t *fa);
void R_UploadLightmap (int lmap);
void R_UploadLightmaps ();
void R_DrawTextureChains_ShowTris (void);
void R_DrawBrushModel_ShowTris (entity_t *e);

View file

@ -207,7 +207,6 @@ void R_DrawSequentialPoly (msurface_t *s)
R_RenderDynamicLightmaps (s);
GL_Bind (lightmap_textures[s->lightmaptexturenum]);
R_UploadLightmap(s->lightmaptexturenum);
if (!gl_overbright.value)
{
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
@ -317,7 +316,6 @@ void R_DrawSequentialPoly (msurface_t *s)
GL_EnableMultitexture(); // selects TEXTURE1
GL_Bind (lightmap_textures[s->lightmaptexturenum]);
R_RenderDynamicLightmaps (s);
R_UploadLightmap(s->lightmaptexturenum);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT);
@ -355,7 +353,6 @@ void R_DrawSequentialPoly (msurface_t *s)
//second pass -- lightmap with black fog, modulate blended
R_RenderDynamicLightmaps (s);
GL_Bind (lightmap_textures[s->lightmaptexturenum]);
R_UploadLightmap(s->lightmaptexturenum);
glDepthMask (GL_FALSE);
glEnable (GL_BLEND);
glBlendFunc(GL_DST_COLOR, GL_SRC_COLOR); //2x modulate
@ -398,7 +395,6 @@ void R_DrawSequentialPoly (msurface_t *s)
GL_EnableMultitexture(); // selects TEXTURE1
GL_Bind (lightmap_textures[s->lightmaptexturenum]);
R_RenderDynamicLightmaps (s);
R_UploadLightmap(s->lightmaptexturenum);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBegin(GL_POLYGON);
v = s->polys->verts[0];
@ -430,7 +426,6 @@ void R_DrawSequentialPoly (msurface_t *s)
//second pass -- lightmap with black fog, modulate blended
R_RenderDynamicLightmaps (s);
GL_Bind (lightmap_textures[s->lightmaptexturenum]);
R_UploadLightmap(s->lightmaptexturenum);
glDepthMask (GL_FALSE);
glEnable (GL_BLEND);
glBlendFunc (GL_ZERO, GL_SRC_COLOR); //modulate
@ -1150,7 +1145,7 @@ R_UploadLightmap -- johnfitz -- uploads the modified lightmap to opengl if neces
assumes lightmap texture is already bound
===============
*/
void R_UploadLightmap(int lmap)
static void R_UploadLightmap(int lmap)
{
glRect_t *theRect;
@ -1170,6 +1165,20 @@ void R_UploadLightmap(int lmap)
rs_dynamiclightmaps++;
}
void R_UploadLightmaps (void)
{
int lmap;
for (lmap = 0; lmap < MAX_LIGHTMAPS; lmap++)
{
if (!lightmap_modified[lmap])
continue;
GL_Bind (lightmap_textures[lmap]);
R_UploadLightmap(lmap);
}
}
/*
================
R_RebuildAllLightmaps -- johnfitz -- called when gl_overbright gets toggled

View file

@ -373,7 +373,6 @@ void R_DrawTextureChains_Multitexture (void)
}
R_RenderDynamicLightmaps (s);
GL_Bind (lightmap_textures[s->lightmaptexturenum]);
R_UploadLightmap(s->lightmaptexturenum);
glBegin(GL_POLYGON);
v = s->polys->verts[0];
for (j=0 ; j<s->polys->numverts ; j++, v+= VERTEXSIZE)
@ -587,7 +586,6 @@ void R_DrawLightmapChains (void)
continue;
GL_Bind (lightmap_textures[i]);
R_UploadLightmap(i);
for (p = lightmap_polys[i]; p; p=p->chain)
{
glBegin (GL_POLYGON);
@ -613,6 +611,10 @@ void R_DrawWorld (void)
if (!r_drawworld_cheatsafe)
return;
// mh dynamic lightmap speedup: upload all modified lightmaps from the last
// frame in a single batch
R_UploadLightmaps ();
if (r_drawflat_cheatsafe)
{
glDisable (GL_TEXTURE_2D);