Skip to content

Commit 5b5ded2

Browse files
committed
client: render: implemented getting PVS culling radius from engine, made culling more aggressive
1 parent c6b43fe commit 5b5ded2

File tree

5 files changed

+12
-3
lines changed

5 files changed

+12
-3
lines changed

client/render/gl_cvars.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ cvar_t *r_dof_change_time;
5050
cvar_t *r_dof_focal_length;
5151
cvar_t *r_dof_fstop;
5252
cvar_t *r_dof_debug;
53+
cvar_t *r_pvs_radius;
5354
cvar_t *r_allow_mirrors;
5455
cvar_t *r_allow_portals;
5556
cvar_t *r_allow_screens;
@@ -136,6 +137,7 @@ void R_InitializeConVars()
136137
r_nocull = CVAR_GET_POINTER("r_nocull");
137138
r_lockpvs = CVAR_GET_POINTER("r_lockpvs");
138139
r_lockfrustum = CVAR_GET_POINTER("r_lockfrustum");
140+
r_pvs_radius = CVAR_GET_POINTER("r_pvs_radius");
139141
r_wireframe = CVAR_GET_POINTER("gl_wireframe");
140142
r_lightmap = CVAR_GET_POINTER("r_lightmap");
141143
r_decals = CVAR_GET_POINTER("r_decals");

client/render/gl_cvars.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ extern cvar_t *r_novis;
4444
extern cvar_t *r_nocull;
4545
extern cvar_t *r_lockpvs;
4646
extern cvar_t *r_lockfrustum;
47+
extern cvar_t *r_pvs_radius;
4748
extern cvar_t *gl_hdr;
4849
extern cvar_t *r_tonemap;
4950
extern cvar_t *r_bloom;

client/render/gl_local.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ GNU General Public License for more details.
8383
#define SHADOW_SIZE 4096 // atlas size
8484

8585
#define WORLD_MATRIX 0 // must be 0 always
86-
#define REFPVS_RADIUS 2.0f // PVS radius for rendering
8786
#define Z_NEAR 4.0f
8887
#define Z_NEAR_LIGHT 0.1f
8988
#define BACKFACE_EPSILON 0.01f

client/render/gl_rmain.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,12 @@ const Vector gl_state_t :: GetModelOrigin( void )
182182
return transform.VectorITransform( RI->view.origin );
183183
}
184184

185+
float R_GetPVSRadius()
186+
{
187+
const float defaultPvsRadius = 2.0f; // formerly REFPVS_RADIUS
188+
return r_pvs_radius ? r_pvs_radius->value : defaultPvsRadius;
189+
}
190+
185191
/*
186192
===============
187193
GL_CacheState
@@ -421,7 +427,7 @@ static void R_SetupViewCache( const ref_viewpass_t *rvp )
421427
if( CVAR_TO_BOOL( r_novis ) || FBitSet( RI->params, RP_DRAW_OVERVIEW ) || ( !RI->view.leaf ))
422428
fullvis = true;
423429

424-
ENGINE_SET_PVS( RI->view.pvspoint, REFPVS_RADIUS, RI->view.pvsarray, mergevis, fullvis );
430+
ENGINE_SET_PVS( RI->view.pvspoint, R_GetPVSRadius(), RI->view.pvsarray, mergevis, fullvis);
425431
SetBits( RI->view.changed, RC_PVS_CHANGED );
426432
}
427433

client/render/gl_shadows.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,9 @@ static void R_ShadowPassSetupViewCache( CDynLight *pl, int split = 0 )
364364
RI->view.worldMatrix.CopyToArray( RI->glstate.modelviewMatrix );
365365

366366
// TODO optimize it with caching last view leaf
367+
const float pvsCullingRadius = 2.0f; // made it larger than default, to avoid disappearing shadows
367368
RI->view.pvspoint = pl->origin;
368-
ENGINE_SET_PVS( RI->view.pvspoint, REFPVS_RADIUS, RI->view.pvsarray, false, true );
369+
ENGINE_SET_PVS( RI->view.pvspoint, pvsCullingRadius, RI->view.pvsarray, false, true );
369370
R_MarkWorldVisibleFaces( worldmodel );
370371

371372
// add all studio models, mark visible bmodels

0 commit comments

Comments
 (0)