cvar_t r_equalize_entities_by = {CVAR_SAVE, "r_equalize_entities_by", "0.7", "light equalizing: exponent of dynamics compression (0 = no compression, 1 = full compression)"};
cvar_t r_equalize_entities_to = {CVAR_SAVE, "r_equalize_entities_to", "0.8", "light equalizing: target light level"};
-cvar_t r_animcache = {CVAR_SAVE, "r_animcache", "1", "cache animation frames to save CPU usage, primarily optimizes shadows and reflections"};
-
cvar_t r_depthfirst = {CVAR_SAVE, "r_depthfirst", "0", "renders a depth-only version of the scene before normal rendering begins to eliminate overdraw, values: 0 = off, 1 = world depth, 2 = world and model depth"};
cvar_t r_useinfinitefarclip = {CVAR_SAVE, "r_useinfinitefarclip", "1", "enables use of a special kind of projection matrix that has an extremely large farclip"};
cvar_t r_farclip_base = {0, "r_farclip_base", "65536", "farclip (furthest visible distance) for rendering when r_useinfinitefarclip is 0"};
cvar_t r_track_sprites_scaleh = {CVAR_SAVE, "r_track_sprites_scaleh", "1", "height scaling of tracked sprites"};
cvar_t r_glsl_saturation = {CVAR_SAVE, "r_glsl_saturation", "1", "saturation multiplier (only working in glsl!)"};
+cvar_t r_framedatasize = {CVAR_SAVE, "r_framedatasize", "1", "size of renderer data cache used during one frame (for skeletal animation caching, light processing, etc)"};
+
extern cvar_t v_glslgamma;
extern qboolean v_flipped_state;
break;
}
+ R_AnimCache_Free();
+ R_FrameData_Reset();
+
r_numqueries = 0;
r_maxqueries = 0;
memset(r_queries, 0, sizeof(r_queries));
extern rtexture_t *loadingscreentexture;
void gl_main_shutdown(void)
{
+ R_AnimCache_Free();
+ R_FrameData_Reset();
+
R_Main_FreeViewCache();
if (r_maxqueries)
CL_ParseEntityLump(cl.worldmodel->brush.entities);
}
R_Main_FreeViewCache();
+
+ R_FrameData_Reset();
}
void GL_Main_Init(void)
Cvar_RegisterVariable(&r_equalize_entities_minambient);
Cvar_RegisterVariable(&r_equalize_entities_by);
Cvar_RegisterVariable(&r_equalize_entities_to);
- Cvar_RegisterVariable(&r_animcache);
Cvar_RegisterVariable(&r_depthfirst);
Cvar_RegisterVariable(&r_useinfinitefarclip);
Cvar_RegisterVariable(&r_farclip_base);
Cvar_RegisterVariable(&r_test);
Cvar_RegisterVariable(&r_batchmode);
Cvar_RegisterVariable(&r_glsl_saturation);
+ Cvar_RegisterVariable(&r_framedatasize);
if (gamemode == GAME_NEHAHRA || gamemode == GAME_TENEBRAE)
Cvar_SetValue("r_fullbrights", 0);
R_RegisterModule("GL_Main", gl_main_start, gl_main_shutdown, gl_main_newmap);
//==================================================================================
+// LordHavoc: this stores temporary data used within the same frame
+
+qboolean r_framedata_failed;
+static size_t r_framedata_size;
+static size_t r_framedata_current;
+static void *r_framedata_base;
+
+void R_FrameData_Reset(void)
+{
+ if (r_framedata_base);
+ Mem_Free(r_framedata_base);
+ r_framedata_base = NULL;
+ r_framedata_size = 0;
+ r_framedata_current = 0;
+}
+
+void R_FrameData_NewFrame(void)
+{
+ size_t wantedsize;
+ if (r_framedata_failed)
+ Cvar_SetValueQuick(&r_framedatasize, r_framedatasize.value * 1.25f);
+ wantedsize = (size_t)(r_framedatasize.value * 1024*1024);
+ wantedsize = bound(65536, wantedsize, 128*1024*1024);
+ if (r_framedata_size < wantedsize)
+ {
+ r_framedata_size = wantedsize;
+ if (!r_framedata_base)
+ r_framedata_base = Mem_Alloc(r_main_mempool, r_framedata_size);
+ }
+ r_framedata_current = 0;
+ r_framedata_failed = false;
+}
+
+void *R_FrameData_Alloc(size_t size)
+{
+ void *data;
+
+ // align to 16 byte boundary
+ size = (size + 15) & ~15;
+ data = r_framedata_base + r_framedata_current;
+ r_framedata_current += size;
+
+ // check overflow
+ if (r_framedata_current > r_framedata_size)
+ r_framedata_failed = true;
+
+ // return NULL on everything after a failure
+ if (r_framedata_failed)
+ return NULL;
+
+ return data;
+}
+
+void *R_FrameData_Store(size_t size, void *data)
+{
+ void *d = R_FrameData_Alloc(size);
+ if (d)
+ memcpy(d, data, size);
+ return d;
+}
+
+//==================================================================================
+
// LordHavoc: animcache written by Echon, refactored and reformatted by me
/**
float *normal3f;
float *svector3f;
float *tvector3f;
- int maxvertices;
- qboolean wantnormals;
- qboolean wanttangents;
}
r_animcache_entity_t;
void R_AnimCache_Free(void)
{
- int idx;
- for (idx=0 ; idx<r_animcachestate.maxindex ; idx++)
- {
- r_animcachestate.entity[idx].maxvertices = 0;
- Mem_Free(r_animcachestate.entity[idx].vertex3f);
- r_animcachestate.entity[idx].vertex3f = NULL;
- r_animcachestate.entity[idx].normal3f = NULL;
- r_animcachestate.entity[idx].svector3f = NULL;
- r_animcachestate.entity[idx].tvector3f = NULL;
- }
- r_animcachestate.currentindex = 0;
- r_animcachestate.maxindex = 0;
+ memset(&r_animcachestate, 0, sizeof(r_animcachestate));
}
-void R_AnimCache_ResizeEntityCache(const int cacheIdx, const int numvertices)
-{
- int arraySize;
- float *base;
- r_animcache_entity_t *cache = &r_animcachestate.entity[cacheIdx];
-
- if (cache->maxvertices >= numvertices)
- return;
-
- // Release existing memory
- if (cache->vertex3f)
- Mem_Free(cache->vertex3f);
-
- // Pad by 1024 verts
- cache->maxvertices = (numvertices + 1023) & ~1023;
- arraySize = cache->maxvertices * 3;
-
- // Allocate, even if we don't need this memory in this instance it will get ignored and potentially used later
- base = (float *)Mem_Alloc(r_main_mempool, arraySize * sizeof(float) * 4);
- r_animcachestate.entity[cacheIdx].vertex3f = base;
- r_animcachestate.entity[cacheIdx].normal3f = base + arraySize;
- r_animcachestate.entity[cacheIdx].svector3f = base + arraySize*2;
- r_animcachestate.entity[cacheIdx].tvector3f = base + arraySize*3;
-
-// Con_Printf("allocated cache for %i (%f KB)\n", cacheIdx, (arraySize*sizeof(float)*4)/1024.0f);
-}
-
-void R_AnimCache_NewFrame(void)
+void R_AnimCache_ClearCache(void)
{
int i;
+ entity_render_t *ent;
- if (r_animcache.integer && r_drawentities.integer)
- r_animcachestate.maxindex = sizeof(r_animcachestate.entity) / sizeof(r_animcachestate.entity[0]);
- else if (r_animcachestate.maxindex)
- R_AnimCache_Free();
-
+ r_animcachestate.maxindex = sizeof(r_animcachestate.entity) / sizeof(r_animcachestate.entity[0]);
r_animcachestate.currentindex = 0;
for (i = 0;i < r_refdef.scene.numentities;i++)
- r_refdef.scene.entities[i]->animcacheindex = -1;
+ {
+ ent = r_refdef.scene.entities[i];
+ ent->animcacheindex = -1;
+ }
}
qboolean R_AnimCache_GetEntity(entity_render_t *ent, qboolean wantnormals, qboolean wanttangents)
{
dp_model_t *model = ent->model;
r_animcache_entity_t *c;
+ int numvertices;
// see if it's already cached this frame
if (ent->animcacheindex >= 0)
{
// add normals/tangents if needed
- c = r_animcachestate.entity + ent->animcacheindex;
- if (c->wantnormals)
- wantnormals = false;
- if (c->wanttangents)
- wanttangents = false;
if (wantnormals || wanttangents)
- model->AnimateVertices(model, ent->frameblend, ent->skeleton, NULL, wantnormals ? c->normal3f : NULL, wanttangents ? c->svector3f : NULL, wanttangents ? c->tvector3f : NULL);
+ {
+ c = r_animcachestate.entity + ent->animcacheindex;
+ if (c->normal3f)
+ wantnormals = false;
+ if (c->svector3f)
+ wanttangents = false;
+ if (wantnormals || wanttangents)
+ {
+ numvertices = model->surfmesh.num_vertices;
+ if (wantnormals)
+ c->normal3f = R_FrameData_Alloc(sizeof(float[3])*numvertices);
+ if (wanttangents)
+ {
+ c->svector3f = R_FrameData_Alloc(sizeof(float[3])*numvertices);
+ c->tvector3f = R_FrameData_Alloc(sizeof(float[3])*numvertices);
+ }
+ if (!r_framedata_failed)
+ model->AnimateVertices(model, ent->frameblend, ent->skeleton, NULL, wantnormals ? c->normal3f : NULL, wanttangents ? c->svector3f : NULL, wanttangents ? c->tvector3f : NULL);
+ }
+ }
}
else
{
// see if this ent is worth caching
if (r_animcachestate.maxindex <= r_animcachestate.currentindex)
return false;
- if (!model || !model->Draw || !model->surfmesh.isanimated || !model->AnimateVertices || (ent->frameblend[0].lerp == 1 && ent->frameblend[0].subframe == 0))
+ if (!model || !model->Draw || !model->surfmesh.isanimated || !model->AnimateVertices || (ent->frameblend[0].lerp == 1 && ent->frameblend[0].subframe == 0 && !ent->skeleton))
return false;
- // assign it a cache entry and make sure the arrays are big enough
- R_AnimCache_ResizeEntityCache(r_animcachestate.currentindex, model->surfmesh.num_vertices);
+ // assign it a cache entry and get some temp memory
ent->animcacheindex = r_animcachestate.currentindex++;
c = r_animcachestate.entity + ent->animcacheindex;
- c->wantnormals = wantnormals;
- c->wanttangents = wanttangents;
- model->AnimateVertices(model, ent->frameblend, ent->skeleton, c->vertex3f, wantnormals ? c->normal3f : NULL, wanttangents ? c->svector3f : NULL, wanttangents ? c->tvector3f : NULL);
+ numvertices = model->surfmesh.num_vertices;
+ memset(c, 0, sizeof(*c));
+ c->vertex3f = R_FrameData_Alloc(sizeof(float[3])*numvertices);
+ if (wantnormals)
+ c->normal3f = R_FrameData_Alloc(sizeof(float[3])*numvertices);
+ if (wanttangents)
+ {
+ c->svector3f = R_FrameData_Alloc(sizeof(float[3])*numvertices);
+ c->tvector3f = R_FrameData_Alloc(sizeof(float[3])*numvertices);
+ }
+ if (!r_framedata_failed)
+ model->AnimateVertices(model, ent->frameblend, ent->skeleton, c->vertex3f, c->normal3f, c->svector3f, c->tvector3f);
}
- return true;
+ return !r_framedata_failed;
}
void R_AnimCache_CacheVisibleEntities(void)
{
int i;
+ entity_render_t *ent;
qboolean wantnormals = !r_showsurfaces.integer;
qboolean wanttangents = !r_showsurfaces.integer;
- if (!r_animcachestate.maxindex)
- return;
-
switch(vid.renderpath)
{
case RENDERPATH_GL20:
break;
}
- // TODO: thread this?
+ // TODO: thread this
for (i = 0;i < r_refdef.scene.numentities;i++)
{
if (!r_refdef.viewcache.entityvisible[i])
continue;
- R_AnimCache_GetEntity(r_refdef.scene.entities[i], wantnormals, wanttangents);
+ ent = r_refdef.scene.entities[i];
+ if (ent->animcacheindex >= 0)
+ continue;
+ R_AnimCache_GetEntity(ent, wantnormals, wanttangents);
}
}
r_frame++; // used only by R_GetCurrentTexture
rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveWorldEntity/RSurf_ActiveModelEntity
- R_AnimCache_NewFrame();
+ R_AnimCache_ClearCache();
+ R_FrameData_NewFrame();
if (r_refdef.view.isoverlay)
{
}
R_AnimCache_CacheVisibleEntities();
+ R_PrepareRTLights();
if (r_depthfirst.integer >= 1 && cl.csqc_vidvars.drawworld && r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->DrawDepth)
{
tris = R_Shadow_ConstructShadowVolume_ZFail(numverts, numtris, elements, neighbors, invertex3f, &outverts, shadowelements, shadowvertex3f, projectorigin, projectdirection, projectdistance, nummarktris, marktris);
Mod_ShadowMesh_AddMesh(r_main_mempool, r_shadow_compilingrtlight->static_meshchain_shadow_zfail, NULL, NULL, NULL, shadowvertex3f, NULL, NULL, NULL, NULL, tris, shadowelements);
}
+ else if (r_shadow_rendermode == R_SHADOW_RENDERMODE_VISIBLEVOLUMES)
+ {
+ tris = R_Shadow_ConstructShadowVolume_ZFail(numverts, numtris, elements, neighbors, invertex3f, &outverts, shadowelements, shadowvertex3f, projectorigin, projectdirection, projectdistance, nummarktris, marktris);
+ R_Mesh_VertexPointer(shadowvertex3f, 0, 0);
+ R_Mesh_Draw(0, outverts, 0, tris, shadowelements, NULL, 0, 0);
+ }
else
{
// decide which type of shadow to generate and set stencil mode
{
// this variable must be set for the CompileShadowVolume/CompileShadowMap code
r_shadow_compilingrtlight = rtlight;
- R_Shadow_EnlargeLeafSurfaceTrisBuffer(model->brush.num_leafs, model->num_surfaces, model->brush.shadowmesh ? model->brush.shadowmesh->numtriangles : model->surfmesh.num_triangles, model->surfmesh.num_triangles);
- model->GetLightInfo(ent, rtlight->shadoworigin, rtlight->radius, rtlight->cullmins, rtlight->cullmaxs, r_shadow_buffer_leaflist, r_shadow_buffer_leafpvs, &numleafs, r_shadow_buffer_surfacelist, r_shadow_buffer_surfacepvs, &numsurfaces, r_shadow_buffer_shadowtrispvs, r_shadow_buffer_lighttrispvs, r_shadow_buffer_visitingleafpvs);
+ model->GetLightInfo(ent, rtlight->shadoworigin, rtlight->radius, rtlight->cullmins, rtlight->cullmaxs, r_shadow_buffer_leaflist, r_shadow_buffer_leafpvs, &numleafs, r_shadow_buffer_surfacelist, r_shadow_buffer_surfacepvs, &numsurfaces, r_shadow_buffer_shadowtrispvs, r_shadow_buffer_lighttrispvs, r_shadow_buffer_visitingleafpvs, 0, NULL);
numleafpvsbytes = (model->brush.num_leafs + 7) >> 3;
numshadowtrispvsbytes = ((model->brush.shadowmesh ? model->brush.shadowmesh->numtriangles : model->surfmesh.num_triangles) + 7) >> 3;
numlighttrispvsbytes = (model->surfmesh.num_triangles + 7) >> 3;
int i, j;
mplane_t plane;
// reset the count of frustum planes
- // see rsurface.rtlight_frustumplanes definition for how much this array
+ // see rtlight->cached_frustumplanes definition for how much this array
// can hold
- rsurface.rtlight_numfrustumplanes = 0;
+ rtlight->cached_numfrustumplanes = 0;
// haven't implemented a culling path for ortho rendering
if (!r_refdef.view.useperspective)
break;
if (i == 4)
for (i = 0;i < 4;i++)
- rsurface.rtlight_frustumplanes[rsurface.rtlight_numfrustumplanes++] = r_refdef.view.frustum[i];
+ rtlight->cached_frustumplanes[rtlight->cached_numfrustumplanes++] = r_refdef.view.frustum[i];
return;
}
if (PlaneDiff(rtlight->shadoworigin, &r_refdef.view.frustum[i]) < -0.03125)
continue;
// copy the plane
- rsurface.rtlight_frustumplanes[rsurface.rtlight_numfrustumplanes++] = r_refdef.view.frustum[i];
+ rtlight->cached_frustumplanes[rtlight->cached_numfrustumplanes++] = r_refdef.view.frustum[i];
}
// if all the standard frustum planes were accepted, the light is onscreen
// otherwise we need to generate some more planes below...
- if (rsurface.rtlight_numfrustumplanes < 4)
+ if (rtlight->cached_numfrustumplanes < 4)
{
// at least one of the stock frustum planes failed, so we need to
// create one or two custom planes to enclose the light origin
// we have created a valid plane, compute extra info
PlaneClassify(&plane);
// copy the plane
- rsurface.rtlight_frustumplanes[rsurface.rtlight_numfrustumplanes++] = plane;
+ rtlight->cached_frustumplanes[rtlight->cached_numfrustumplanes++] = plane;
#if 1
// if we've found 5 frustum planes then we have constructed a
// proper split-side case and do not need to keep searching for
// planes to enclose the light origin
- if (rsurface.rtlight_numfrustumplanes == 5)
+ if (rtlight->cached_numfrustumplanes == 5)
break;
#endif
}
#endif
#if 0
- for (i = 0;i < rsurface.rtlight_numfrustumplanes;i++)
+ for (i = 0;i < rtlight->cached_numfrustumplanes;i++)
{
- plane = rsurface.rtlight_frustumplanes[i];
+ plane = rtlight->cached_frustumplanes[i];
Con_Printf("light %p plane #%i %f %f %f : %f (%f %f %f %f %f)\n", rtlight, i, plane.normal[0], plane.normal[1], plane.normal[2], plane.dist, PlaneDiff(r_refdef.view.frustumcorner[0], &plane), PlaneDiff(r_refdef.view.frustumcorner[1], &plane), PlaneDiff(r_refdef.view.frustumcorner[2], &plane), PlaneDiff(r_refdef.view.frustumcorner[3], &plane), PlaneDiff(rtlight->shadoworigin, &plane));
}
#endif
VectorSubtract(plane.normal, rtlight->shadoworigin, plane.normal);
plane.dist = VectorNormalizeLength(plane.normal);
plane.dist += DotProduct(plane.normal, rtlight->shadoworigin);
- rsurface.rtlight_frustumplanes[rsurface.rtlight_numfrustumplanes++] = plane;
+ rtlight->cached_frustumplanes[rtlight->cached_numfrustumplanes++] = plane;
}
}
#endif
{
VectorClear(plane.normal);
plane.normal[i >> 1] = (i & 1) ? -1 : 1;
- plane.dist = (i & 1) ? -rsurface.rtlight_cullmaxs[i >> 1] : rsurface.rtlight_cullmins[i >> 1];
- rsurface.rtlight_frustumplanes[rsurface.rtlight_numfrustumplanes++] = plane;
+ plane.dist = (i & 1) ? -rtlight->cached_cullmaxs[i >> 1] : rtlight->cached_cullmins[i >> 1];
+ rtlight->cached_frustumplanes[rtlight->cached_numfrustumplanes++] = plane;
}
#endif
vec_t bestdist;
// reduce all plane distances to tightly fit the rtlight cull box, which
// is in worldspace
- VectorSet(points[0], rsurface.rtlight_cullmins[0], rsurface.rtlight_cullmins[1], rsurface.rtlight_cullmins[2]);
- VectorSet(points[1], rsurface.rtlight_cullmaxs[0], rsurface.rtlight_cullmins[1], rsurface.rtlight_cullmins[2]);
- VectorSet(points[2], rsurface.rtlight_cullmins[0], rsurface.rtlight_cullmaxs[1], rsurface.rtlight_cullmins[2]);
- VectorSet(points[3], rsurface.rtlight_cullmaxs[0], rsurface.rtlight_cullmaxs[1], rsurface.rtlight_cullmins[2]);
- VectorSet(points[4], rsurface.rtlight_cullmins[0], rsurface.rtlight_cullmins[1], rsurface.rtlight_cullmaxs[2]);
- VectorSet(points[5], rsurface.rtlight_cullmaxs[0], rsurface.rtlight_cullmins[1], rsurface.rtlight_cullmaxs[2]);
- VectorSet(points[6], rsurface.rtlight_cullmins[0], rsurface.rtlight_cullmaxs[1], rsurface.rtlight_cullmaxs[2]);
- VectorSet(points[7], rsurface.rtlight_cullmaxs[0], rsurface.rtlight_cullmaxs[1], rsurface.rtlight_cullmaxs[2]);
- oldnum = rsurface.rtlight_numfrustumplanes;
- rsurface.rtlight_numfrustumplanes = 0;
+ VectorSet(points[0], rtlight->cached_cullmins[0], rtlight->cached_cullmins[1], rtlight->cached_cullmins[2]);
+ VectorSet(points[1], rtlight->cached_cullmaxs[0], rtlight->cached_cullmins[1], rtlight->cached_cullmins[2]);
+ VectorSet(points[2], rtlight->cached_cullmins[0], rtlight->cached_cullmaxs[1], rtlight->cached_cullmins[2]);
+ VectorSet(points[3], rtlight->cached_cullmaxs[0], rtlight->cached_cullmaxs[1], rtlight->cached_cullmins[2]);
+ VectorSet(points[4], rtlight->cached_cullmins[0], rtlight->cached_cullmins[1], rtlight->cached_cullmaxs[2]);
+ VectorSet(points[5], rtlight->cached_cullmaxs[0], rtlight->cached_cullmins[1], rtlight->cached_cullmaxs[2]);
+ VectorSet(points[6], rtlight->cached_cullmins[0], rtlight->cached_cullmaxs[1], rtlight->cached_cullmaxs[2]);
+ VectorSet(points[7], rtlight->cached_cullmaxs[0], rtlight->cached_cullmaxs[1], rtlight->cached_cullmaxs[2]);
+ oldnum = rtlight->cached_numfrustumplanes;
+ rtlight->cached_numfrustumplanes = 0;
for (j = 0;j < oldnum;j++)
{
// find the nearest point on the box to this plane
- bestdist = DotProduct(rsurface.rtlight_frustumplanes[j].normal, points[0]);
+ bestdist = DotProduct(rtlight->cached_frustumplanes[j].normal, points[0]);
for (i = 1;i < 8;i++)
{
- dist = DotProduct(rsurface.rtlight_frustumplanes[j].normal, points[i]);
+ dist = DotProduct(rtlight->cached_frustumplanes[j].normal, points[i]);
if (bestdist > dist)
bestdist = dist;
}
- Con_Printf("light %p %splane #%i %f %f %f : %f < %f\n", rtlight, rsurface.rtlight_frustumplanes[j].dist < bestdist + 0.03125 ? "^2" : "^1", j, rsurface.rtlight_frustumplanes[j].normal[0], rsurface.rtlight_frustumplanes[j].normal[1], rsurface.rtlight_frustumplanes[j].normal[2], rsurface.rtlight_frustumplanes[j].dist, bestdist);
+ Con_Printf("light %p %splane #%i %f %f %f : %f < %f\n", rtlight, rtlight->cached_frustumplanes[j].dist < bestdist + 0.03125 ? "^2" : "^1", j, rtlight->cached_frustumplanes[j].normal[0], rtlight->cached_frustumplanes[j].normal[1], rtlight->cached_frustumplanes[j].normal[2], rtlight->cached_frustumplanes[j].dist, bestdist);
// if the nearest point is near or behind the plane, we want this
// plane, otherwise the plane is useless as it won't cull anything
- if (rsurface.rtlight_frustumplanes[j].dist < bestdist + 0.03125)
+ if (rtlight->cached_frustumplanes[j].dist < bestdist + 0.03125)
{
- PlaneClassify(&rsurface.rtlight_frustumplanes[j]);
- rsurface.rtlight_frustumplanes[rsurface.rtlight_numfrustumplanes++] = rsurface.rtlight_frustumplanes[j];
+ PlaneClassify(&rtlight->cached_frustumplanes[j]);
+ rtlight->cached_frustumplanes[rtlight->cached_numfrustumplanes++] = rtlight->cached_frustumplanes[j];
}
}
}
CHECKGLERROR
}
else if (r_refdef.scene.worldentity->model)
- r_refdef.scene.worldmodel->DrawShadowMap(r_shadow_shadowmapside, r_refdef.scene.worldentity, rsurface.rtlight->shadoworigin, NULL, rsurface.rtlight->radius, numsurfaces, surfacelist, surfacesides, rsurface.rtlight_cullmins, rsurface.rtlight_cullmaxs);
+ r_refdef.scene.worldmodel->DrawShadowMap(r_shadow_shadowmapside, r_refdef.scene.worldentity, rsurface.rtlight->shadoworigin, NULL, rsurface.rtlight->radius, numsurfaces, surfacelist, surfacesides, rsurface.rtlight->cached_cullmins, rsurface.rtlight->cached_cullmaxs);
rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveWorldEntity/RSurf_ActiveModelEntity
}
void R_Shadow_DrawWorldShadow_ShadowVolume(int numsurfaces, int *surfacelist, const unsigned char *trispvs)
{
- qboolean zpass;
+ qboolean zpass = false;
shadowmesh_t *mesh;
int t, tend;
int surfacelistindex;
if (rsurface.rtlight->compiled && r_shadow_realtime_world_compile.integer && r_shadow_realtime_world_compileshadow.integer)
{
CHECKGLERROR
- zpass = R_Shadow_UseZPass(r_refdef.scene.worldmodel->normalmins, r_refdef.scene.worldmodel->normalmaxs);
- R_Shadow_RenderMode_StencilShadowVolumes(zpass);
+ if (r_shadow_rendermode != R_SHADOW_RENDERMODE_VISIBLEVOLUMES)
+ {
+ zpass = R_Shadow_UseZPass(r_refdef.scene.worldmodel->normalmins, r_refdef.scene.worldmodel->normalmaxs);
+ R_Shadow_RenderMode_StencilShadowVolumes(zpass);
+ }
mesh = zpass ? rsurface.rtlight->static_meshchain_shadow_zpass : rsurface.rtlight->static_meshchain_shadow_zfail;
for (;mesh;mesh = mesh->next)
{
R_Shadow_VolumeFromList(r_refdef.scene.worldmodel->brush.shadowmesh->numverts, r_refdef.scene.worldmodel->brush.shadowmesh->numtriangles, r_refdef.scene.worldmodel->brush.shadowmesh->vertex3f, r_refdef.scene.worldmodel->brush.shadowmesh->element3i, r_refdef.scene.worldmodel->brush.shadowmesh->neighbor3i, rsurface.rtlight->shadoworigin, NULL, rsurface.rtlight->radius + r_refdef.scene.worldmodel->radius*2 + r_shadow_projectdistance.value, numshadowmark, shadowmarklist, r_refdef.scene.worldmodel->normalmins, r_refdef.scene.worldmodel->normalmaxs);
}
else if (numsurfaces)
- r_refdef.scene.worldmodel->DrawShadowVolume(r_refdef.scene.worldentity, rsurface.rtlight->shadoworigin, NULL, rsurface.rtlight->radius, numsurfaces, surfacelist, rsurface.rtlight_cullmins, rsurface.rtlight_cullmaxs);
+ r_refdef.scene.worldmodel->DrawShadowVolume(r_refdef.scene.worldentity, rsurface.rtlight->shadoworigin, NULL, rsurface.rtlight->radius, numsurfaces, surfacelist, rsurface.rtlight->cached_cullmins, rsurface.rtlight->cached_cullmaxs);
rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveWorldEntity/RSurf_ActiveModelEntity
}
rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveWorldEntity/RSurf_ActiveModelEntity
}
-void R_DrawRTLight(rtlight_t *rtlight, qboolean visible)
+void R_CacheRTLight(rtlight_t *rtlight)
{
int i;
float f;
int numshadowentities;
int numshadowentities_noselfshadow;
static entity_render_t *lightentities[MAX_EDICTS];
+ static entity_render_t *lightentities_noselfshadow[MAX_EDICTS];
static entity_render_t *shadowentities[MAX_EDICTS];
- static unsigned char entitysides[MAX_EDICTS];
- int lightentities_noselfshadow;
- int shadowentities_noselfshadow;
- vec3_t nearestpoint;
- vec_t distance;
- qboolean castshadows;
- int lodlinear;
+ static entity_render_t *shadowentities_noselfshadow[MAX_EDICTS];
+
+ rtlight->draw = false;
// skip lights that don't light because of ambientscale+diffusescale+specularscale being 0 (corona only lights)
// skip lights that are basically invisible (color 0 0 0)
if (R_CullBox(rtlight->cullmins, rtlight->cullmaxs))
return;
- VectorCopy(rtlight->cullmins, rsurface.rtlight_cullmins);
- VectorCopy(rtlight->cullmaxs, rsurface.rtlight_cullmaxs);
+ VectorCopy(rtlight->cullmins, rtlight->cached_cullmins);
+ VectorCopy(rtlight->cullmaxs, rtlight->cached_cullmaxs);
+
+ R_Shadow_ComputeShadowCasterCullingPlanes(rtlight);
if (rtlight->compiled && r_shadow_realtime_world_compile.integer)
{
{
// dynamic light, world available and can receive realtime lighting
// calculate lit surfaces and leafs
- R_Shadow_EnlargeLeafSurfaceTrisBuffer(r_refdef.scene.worldmodel->brush.num_leafs, r_refdef.scene.worldmodel->num_surfaces, r_refdef.scene.worldmodel->brush.shadowmesh ? r_refdef.scene.worldmodel->brush.shadowmesh->numtriangles : r_refdef.scene.worldmodel->surfmesh.num_triangles, r_refdef.scene.worldmodel->surfmesh.num_triangles);
- r_refdef.scene.worldmodel->GetLightInfo(r_refdef.scene.worldentity, rtlight->shadoworigin, rtlight->radius, rsurface.rtlight_cullmins, rsurface.rtlight_cullmaxs, r_shadow_buffer_leaflist, r_shadow_buffer_leafpvs, &numleafs, r_shadow_buffer_surfacelist, r_shadow_buffer_surfacepvs, &numsurfaces, r_shadow_buffer_shadowtrispvs, r_shadow_buffer_lighttrispvs, r_shadow_buffer_visitingleafpvs);
+ r_refdef.scene.worldmodel->GetLightInfo(r_refdef.scene.worldentity, rtlight->shadoworigin, rtlight->radius, rtlight->cached_cullmins, rtlight->cached_cullmaxs, r_shadow_buffer_leaflist, r_shadow_buffer_leafpvs, &numleafs, r_shadow_buffer_surfacelist, r_shadow_buffer_surfacepvs, &numsurfaces, r_shadow_buffer_shadowtrispvs, r_shadow_buffer_lighttrispvs, r_shadow_buffer_visitingleafpvs, rtlight->cached_numfrustumplanes, rtlight->cached_frustumplanes);
+ R_Shadow_ComputeShadowCasterCullingPlanes(rtlight);
leaflist = r_shadow_buffer_leaflist;
leafpvs = r_shadow_buffer_leafpvs;
surfacelist = r_shadow_buffer_surfacelist;
shadowtrispvs = r_shadow_buffer_shadowtrispvs;
lighttrispvs = r_shadow_buffer_lighttrispvs;
// if the reduced leaf bounds are offscreen, skip it
- if (R_CullBox(rsurface.rtlight_cullmins, rsurface.rtlight_cullmaxs))
+ if (R_CullBox(rtlight->cached_cullmins, rtlight->cached_cullmaxs))
return;
}
else
if (i == numleafs)
return;
}
- // set up a scissor rectangle for this light
- if (R_Shadow_ScissorForBBox(rsurface.rtlight_cullmins, rsurface.rtlight_cullmaxs))
- return;
-
- R_Shadow_ComputeShadowCasterCullingPlanes(rtlight);
// make a list of lit entities and shadow casting entities
numlightentities = 0;
numlightentities_noselfshadow = 0;
- lightentities_noselfshadow = sizeof(lightentities)/sizeof(lightentities[0]) - 1;
numshadowentities = 0;
numshadowentities_noselfshadow = 0;
- shadowentities_noselfshadow = sizeof(shadowentities)/sizeof(shadowentities[0]) - 1;
// add dynamic entities that are lit by the light
if (r_drawentities.integer)
dp_model_t *model;
entity_render_t *ent = r_refdef.scene.entities[i];
vec3_t org;
- if (!BoxesOverlap(ent->mins, ent->maxs, rsurface.rtlight_cullmins, rsurface.rtlight_cullmaxs))
+ if (!BoxesOverlap(ent->mins, ent->maxs, rtlight->cached_cullmins, rtlight->cached_cullmaxs))
continue;
// skip the object entirely if it is not within the valid
// shadow-casting region (which includes the lit region)
- if (R_CullBoxCustomPlanes(ent->mins, ent->maxs, rsurface.rtlight_numfrustumplanes, rsurface.rtlight_frustumplanes))
+ if (R_CullBoxCustomPlanes(ent->mins, ent->maxs, rtlight->cached_numfrustumplanes, rtlight->cached_frustumplanes))
continue;
if (!(model = ent->model))
continue;
if (r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->brush.BoxTouchingLeafPVS && !r_refdef.scene.worldmodel->brush.BoxTouchingLeafPVS(r_refdef.scene.worldmodel, leafpvs, ent->mins, ent->maxs))
continue;
if (ent->flags & RENDER_NOSELFSHADOW)
- lightentities[lightentities_noselfshadow - numlightentities_noselfshadow++] = ent;
+ lightentities_noselfshadow[numlightentities_noselfshadow++] = ent;
else
lightentities[numlightentities++] = ent;
// since it is lit, it probably also casts a shadow...
// RENDER_NOSELFSHADOW entities such as the gun
// (very weird, but keeps the player shadow off the gun)
if (ent->flags & (RENDER_NOSELFSHADOW | RENDER_EXTERIORMODEL))
- shadowentities[shadowentities_noselfshadow - numshadowentities_noselfshadow++] = ent;
+ shadowentities_noselfshadow[numshadowentities_noselfshadow++] = ent;
else
shadowentities[numshadowentities++] = ent;
}
if ((ent->flags & RENDER_SHADOW) && model->DrawShadowVolume && VectorDistance2(org, rtlight->shadoworigin) > 0.1)
{
if (ent->flags & (RENDER_NOSELFSHADOW | RENDER_EXTERIORMODEL))
- shadowentities[shadowentities_noselfshadow - numshadowentities_noselfshadow++] = ent;
+ shadowentities_noselfshadow[numshadowentities_noselfshadow++] = ent;
else
shadowentities[numshadowentities++] = ent;
}
if (numsurfaces + numlightentities + numlightentities_noselfshadow == 0)
return;
+ // count this light in the r_speeds
+ r_refdef.stats.lights++;
+
+ // flag it as worth drawing later
+ rtlight->draw = true;
+
+ // cache all the animated entities that cast a shadow but are not visible
+ for (i = 0;i < numshadowentities;i++)
+ if (shadowentities[i]->animcacheindex < 0)
+ R_AnimCache_GetEntity(shadowentities[i], false, false);
+ for (i = 0;i < numshadowentities_noselfshadow;i++)
+ if (shadowentities_noselfshadow[i]->animcacheindex < 0)
+ R_AnimCache_GetEntity(shadowentities_noselfshadow[i], false, false);
+
+ // allocate some temporary memory for rendering this light later in the frame
+ // reusable buffers need to be copied, static data can be used as-is
+ rtlight->cached_numlightentities = numlightentities;
+ rtlight->cached_numlightentities_noselfshadow = numlightentities_noselfshadow;
+ rtlight->cached_numshadowentities = numshadowentities;
+ rtlight->cached_numshadowentities_noselfshadow = numshadowentities_noselfshadow;
+ rtlight->cached_numsurfaces = numsurfaces;
+ rtlight->cached_lightentities = (entity_render_t**)R_FrameData_Store(numlightentities*sizeof(entity_render_t*), (void*)lightentities);
+ rtlight->cached_lightentities_noselfshadow = (entity_render_t**)R_FrameData_Store(numlightentities_noselfshadow*sizeof(entity_render_t*), (void*)lightentities_noselfshadow);
+ rtlight->cached_shadowentities = (entity_render_t**)R_FrameData_Store(numshadowentities*sizeof(entity_render_t*), (void*)shadowentities);
+ rtlight->cached_shadowentities_noselfshadow = (entity_render_t**)R_FrameData_Store(numshadowentities_noselfshadow*sizeof(entity_render_t *), (void*)shadowentities_noselfshadow);
+ if (shadowtrispvs == r_shadow_buffer_shadowtrispvs)
+ {
+ rtlight->cached_shadowtrispvs = (unsigned char *)R_FrameData_Store(r_refdef.scene.worldmodel->brush.shadowmesh ? r_refdef.scene.worldmodel->brush.shadowmesh->numtriangles : r_refdef.scene.worldmodel->surfmesh.num_triangles, shadowtrispvs);
+ rtlight->cached_lighttrispvs = (unsigned char *)R_FrameData_Store(r_refdef.scene.worldmodel->surfmesh.num_triangles, lighttrispvs);
+ rtlight->cached_surfacelist = (int*)R_FrameData_Store(numsurfaces*sizeof(int), (void*)surfacelist);
+ }
+ else
+ {
+ // compiled light data
+ rtlight->cached_shadowtrispvs = shadowtrispvs;
+ rtlight->cached_lighttrispvs = lighttrispvs;
+ rtlight->cached_surfacelist = surfacelist;
+ }
+}
+
+void R_DrawRTLight(rtlight_t *rtlight, qboolean visible)
+{
+ int i;
+ int numsurfaces;
+ unsigned char *shadowtrispvs, *lighttrispvs, *surfacesides;
+ int numlightentities;
+ int numlightentities_noselfshadow;
+ int numshadowentities;
+ int numshadowentities_noselfshadow;
+ entity_render_t **lightentities;
+ entity_render_t **lightentities_noselfshadow;
+ entity_render_t **shadowentities;
+ entity_render_t **shadowentities_noselfshadow;
+ int *surfacelist;
+ static unsigned char entitysides[MAX_EDICTS];
+ static unsigned char entitysides_noselfshadow[MAX_EDICTS];
+ vec3_t nearestpoint;
+ vec_t distance;
+ qboolean castshadows;
+ int lodlinear;
+
+ // check if we cached this light this frame (meaning it is worth drawing)
+ if (!rtlight->draw)
+ return;
+
+ // if R_FrameData_Store ran out of space we skip anything dependent on it
+ if (r_framedata_failed)
+ return;
+
+ numlightentities = rtlight->cached_numlightentities;
+ numlightentities_noselfshadow = rtlight->cached_numlightentities_noselfshadow;
+ numshadowentities = rtlight->cached_numshadowentities;
+ numshadowentities_noselfshadow = rtlight->cached_numshadowentities_noselfshadow;
+ numsurfaces = rtlight->cached_numsurfaces;
+ lightentities = rtlight->cached_lightentities;
+ lightentities_noselfshadow = rtlight->cached_lightentities_noselfshadow;
+ shadowentities = rtlight->cached_shadowentities;
+ shadowentities_noselfshadow = rtlight->cached_shadowentities_noselfshadow;
+ shadowtrispvs = rtlight->cached_shadowtrispvs;
+ lighttrispvs = rtlight->cached_lighttrispvs;
+ surfacelist = rtlight->cached_surfacelist;
+
+ // set up a scissor rectangle for this light
+ if (R_Shadow_ScissorForBBox(rtlight->cached_cullmins, rtlight->cached_cullmaxs))
+ return;
+
// don't let sound skip if going slow
if (r_refdef.scene.extraupdate)
S_ExtraUpdate ();
// make this the active rtlight for rendering purposes
R_Shadow_RenderMode_ActiveLight(rtlight);
- // count this light in the r_speeds
- r_refdef.stats.lights++;
if (r_showshadowvolumes.integer && r_refdef.view.showdebug && numsurfaces + numshadowentities + numshadowentities_noselfshadow && rtlight->shadow && (rtlight->isstatic ? r_refdef.scene.rtworldshadows : r_refdef.scene.rtdlightshadows))
{
for (i = 0;i < numshadowentities;i++)
R_Shadow_DrawEntityShadow(shadowentities[i]);
for (i = 0;i < numshadowentities_noselfshadow;i++)
- R_Shadow_DrawEntityShadow(shadowentities[shadowentities_noselfshadow - i]);
+ R_Shadow_DrawEntityShadow(shadowentities_noselfshadow[i]);
+ R_Shadow_RenderMode_VisibleLighting(false, false);
}
if (r_showlighting.integer && r_refdef.view.showdebug && numsurfaces + numlightentities + numlightentities_noselfshadow)
for (i = 0;i < numlightentities;i++)
R_Shadow_DrawEntityLight(lightentities[i]);
for (i = 0;i < numlightentities_noselfshadow;i++)
- R_Shadow_DrawEntityLight(lightentities[lightentities_noselfshadow - i]);
+ R_Shadow_DrawEntityLight(lightentities_noselfshadow[i]);
}
castshadows = numsurfaces + numshadowentities + numshadowentities_noselfshadow > 0 && rtlight->shadow && (rtlight->isstatic ? r_refdef.scene.rtworldshadows : r_refdef.scene.rtdlightshadows);
borderbias = r_shadow_shadowmapborder / (float)(size - r_shadow_shadowmapborder);
+ surfacesides = NULL;
if (numsurfaces)
{
if (rtlight->compiled && r_shadow_realtime_world_compile.integer && r_shadow_realtime_world_compileshadow.integer)
}
else
{
+ surfacesides = r_shadow_buffer_surfacesides;
for(i = 0;i < numsurfaces;i++)
{
msurface_t *surface = r_refdef.scene.worldmodel->data_surfaces + surfacelist[i];
receivermask |= R_Shadow_CalcEntitySideMask(lightentities[i], &rtlight->matrix_worldtolight, &radiustolight, borderbias);
if (receivermask < 0x3F)
for(i = 0; i < numlightentities_noselfshadow;i++)
- receivermask |= R_Shadow_CalcEntitySideMask(lightentities[lightentities_noselfshadow - i], &rtlight->matrix_worldtolight, &radiustolight, borderbias);
+ receivermask |= R_Shadow_CalcEntitySideMask(lightentities_noselfshadow[i], &rtlight->matrix_worldtolight, &radiustolight, borderbias);
}
receivermask &= R_Shadow_CullFrustumSides(rtlight, size, r_shadow_shadowmapborder);
for (i = 0;i < numshadowentities;i++)
castermask |= (entitysides[i] = R_Shadow_CalcEntitySideMask(shadowentities[i], &rtlight->matrix_worldtolight, &radiustolight, borderbias));
for (i = 0;i < numshadowentities_noselfshadow;i++)
- castermask |= (entitysides[shadowentities_noselfshadow - i] = R_Shadow_CalcEntitySideMask(shadowentities[shadowentities_noselfshadow - i], &rtlight->matrix_worldtolight, &radiustolight, borderbias));
+ castermask |= (entitysides_noselfshadow[i] = R_Shadow_CalcEntitySideMask(shadowentities_noselfshadow[i], &rtlight->matrix_worldtolight, &radiustolight, borderbias));
}
//Con_Printf("distance %f lodlinear %i (lod %i) size %i\n", distance, lodlinear, r_shadow_shadowmaplod, size);
// draw lighting in the unmasked areas
R_Shadow_RenderMode_Lighting(false, false, true);
for (i = 0;i < numlightentities_noselfshadow;i++)
- R_Shadow_DrawEntityLight(lightentities[lightentities_noselfshadow - i]);
+ R_Shadow_DrawEntityLight(lightentities_noselfshadow[i]);
}
// render shadow casters into 6 sided depth texture
for (side = 0;side < 6;side++) if ((receivermask & castermask) & (1 << side))
{
R_Shadow_RenderMode_ShadowMap(side, false, size);
- for (i = 0;i < numshadowentities_noselfshadow;i++) if (entitysides[shadowentities_noselfshadow - i] & (1 << side))
- R_Shadow_DrawEntityShadow(shadowentities[shadowentities_noselfshadow - i]);
+ for (i = 0;i < numshadowentities_noselfshadow;i++) if (entitysides_noselfshadow[i] & (1 << side))
+ R_Shadow_DrawEntityShadow(shadowentities_noselfshadow[i]);
}
}
GL_Scissor(r_shadow_lightscissor[0], r_shadow_lightscissor[1], r_shadow_lightscissor[2], r_shadow_lightscissor[3]);
R_Shadow_ClearStencil();
- if (numsurfaces + numshadowentities)
- {
- if (numsurfaces)
- R_Shadow_DrawWorldShadow_ShadowVolume(numsurfaces, surfacelist, shadowtrispvs);
- for (i = 0;i < numshadowentities;i++)
- R_Shadow_DrawEntityShadow(shadowentities[i]);
- }
+ if (numsurfaces)
+ R_Shadow_DrawWorldShadow_ShadowVolume(numsurfaces, surfacelist, shadowtrispvs);
+ for (i = 0;i < numshadowentities;i++)
+ R_Shadow_DrawEntityShadow(shadowentities[i]);
- if (numlightentities_noselfshadow)
- {
- // draw lighting in the unmasked areas
- R_Shadow_RenderMode_Lighting(true, false, false);
- for (i = 0;i < numlightentities_noselfshadow;i++)
- R_Shadow_DrawEntityLight(lightentities[lightentities_noselfshadow - i]);
+ // draw lighting in the unmasked areas
+ R_Shadow_RenderMode_Lighting(true, false, false);
+ for (i = 0;i < numlightentities_noselfshadow;i++)
+ R_Shadow_DrawEntityLight(lightentities_noselfshadow[i]);
- // optionally draw the illuminated areas
- // for performance analysis by level designers
- if (r_showlighting.integer && r_refdef.view.showdebug)
- {
- R_Shadow_RenderMode_VisibleLighting(!r_showdisabledepthtest.integer, false);
- for (i = 0;i < numlightentities_noselfshadow;i++)
- R_Shadow_DrawEntityLight(lightentities[lightentities_noselfshadow - i]);
- }
- for (i = 0;i < numshadowentities_noselfshadow;i++)
- R_Shadow_DrawEntityShadow(shadowentities[shadowentities_noselfshadow - i]);
- }
+ for (i = 0;i < numshadowentities_noselfshadow;i++)
+ R_Shadow_DrawEntityShadow(shadowentities_noselfshadow[i]);
- if (numsurfaces + numlightentities)
- {
- // draw lighting in the unmasked areas
- R_Shadow_RenderMode_Lighting(true, false, false);
- if (numsurfaces)
- R_Shadow_DrawWorldLight(numsurfaces, surfacelist, lighttrispvs);
- for (i = 0;i < numlightentities;i++)
- R_Shadow_DrawEntityLight(lightentities[i]);
- }
+ // draw lighting in the unmasked areas
+ R_Shadow_RenderMode_Lighting(true, false, false);
+ if (numsurfaces)
+ R_Shadow_DrawWorldLight(numsurfaces, surfacelist, lighttrispvs);
+ for (i = 0;i < numlightentities;i++)
+ R_Shadow_DrawEntityLight(lightentities[i]);
}
else
{
for (i = 0;i < numlightentities;i++)
R_Shadow_DrawEntityLight(lightentities[i]);
for (i = 0;i < numlightentities_noselfshadow;i++)
- R_Shadow_DrawEntityLight(lightentities[lightentities_noselfshadow - i]);
+ R_Shadow_DrawEntityLight(lightentities_noselfshadow[i]);
+ }
+}
+
+void R_PrepareRTLights(void)
+{
+ int flag;
+ int lnum;
+ size_t lightindex;
+ dlight_t *light;
+ size_t range;
+ float f;
+
+ R_Shadow_EnlargeLeafSurfaceTrisBuffer(r_refdef.scene.worldmodel->brush.num_leafs, r_refdef.scene.worldmodel->num_surfaces, r_refdef.scene.worldmodel->brush.shadowmesh ? r_refdef.scene.worldmodel->brush.shadowmesh->numtriangles : r_refdef.scene.worldmodel->surfmesh.num_triangles, r_refdef.scene.worldmodel->surfmesh.num_triangles);
+
+ flag = r_refdef.scene.rtworld ? LIGHTFLAG_REALTIMEMODE : LIGHTFLAG_NORMALMODE;
+ if (r_shadow_debuglight.integer >= 0)
+ {
+ lightindex = r_shadow_debuglight.integer;
+ light = (dlight_t *) Mem_ExpandableArray_RecordAtIndex(&r_shadow_worldlightsarray, lightindex);
+ if (light && (light->flags & flag))
+ R_CacheRTLight(&light->rtlight);
+ }
+ else
+ {
+ range = Mem_ExpandableArray_IndexRange(&r_shadow_worldlightsarray); // checked
+ for (lightindex = 0;lightindex < range;lightindex++)
+ {
+ light = (dlight_t *) Mem_ExpandableArray_RecordAtIndex(&r_shadow_worldlightsarray, lightindex);
+ if (light && (light->flags & flag))
+ R_CacheRTLight(&light->rtlight);
+ }
+ }
+ if (r_refdef.scene.rtdlight)
+ {
+ for (lnum = 0;lnum < r_refdef.scene.numlights;lnum++)
+ R_CacheRTLight(r_refdef.scene.lights[lnum]);
+ }
+ else if(gl_flashblend.integer)
+ {
+ for (lnum = 0;lnum < r_refdef.scene.numlights;lnum++)
+ {
+ rtlight_t *rtlight = r_refdef.scene.lights[lnum];
+ f = (rtlight->style >= 0 ? r_refdef.scene.lightstylevalue[rtlight->style] : 1) * r_shadow_lightintensityscale.value;
+ VectorScale(rtlight->color, f, rtlight->currentcolor);
+ }
}
}