if (r_timereport_active)
R_TimeReport("skystartframe");
+ // TODO: move after depth pass or opaque pass
if (cl.csqc_vidvars.drawworld)
{
// don't let sound skip if going slow
if (r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->DrawSky)
{
+ // TODO: call DrawSky only if visible?
r_refdef.scene.worldmodel->DrawSky(r_refdef.scene.worldentity);
if (r_timereport_active)
R_TimeReport("worldsky");
if (R_DrawBrushModelsSky() && r_timereport_active)
R_TimeReport("bmodelsky");
+ // TODO: skip it if sky is not visible
if (skyrendermasked && skyrenderlater)
{
// we have to force off the water clipping plane while rendering sky
rsurface.lightmaptexture = NULL;
rsurface.deluxemaptexture = NULL;
rsurface.uselightmaptexture = false;
- // simply scan ahead until we find a different texture or lightmap state
- for (;j < numsurfaces && texture == surfacelist[j]->texture;j++)
+ // simply scan ahead until we find a different texture state on prepass
+ // or draw it all(pre-filtered) on depth pass
+ if(depthonly)
+ j = numsurfaces;
+ else for (;j < numsurfaces && texture == surfacelist[j]->texture;j++)
;
}
else
if (model == NULL)
return;
+ // Reallocate buffer if too small
if (r_maxsurfacelist < model->num_surfaces)
{
r_maxsurfacelist = model->num_surfaces;
if (ent == r_refdef.scene.worldentity)
{
// for the world entity, check surfacevisible
- for (i = model->submodelsurfaces_start;i < model->submodelsurfaces_end;i++)
+ if(!depthonly) for (i = model->submodelsurfaces_start;i < model->submodelsurfaces_end;i++)
{
j = model->modelsurfaces_sorted[i];
if (r_refdef.viewcache.world_surfacevisible[j])
r_surfacelist[numsurfacelist++] = surfaces + j;
}
+ else for (i = model->submodelsurfaces_start;i < model->submodelsurfaces_end;i++)
+ {
+ j = model->modelsurfaces_sorted[i];
+ if (r_refdef.viewcache.world_surfacevisible[j] && !(surfaces[j].texture->currentmaterialflags & (MATERIALFLAG_NODEPTHTEST | MATERIALFLAG_BLENDED | MATERIALFLAG_ALPHATEST)) && !(r_fb.water.renderingscene && (surfaces[j].texture->currentmaterialflags & (MATERIALFLAG_WATERSHADER | MATERIALFLAG_REFLECTION))))
+ r_surfacelist[numsurfacelist++] = surfaces + j;
+ }
// don't do anything if there were no surfaces added (none of the world entity is visible)
if (!numsurfacelist)