Skip to content

Commit 2020fd4

Browse files
committed
Let dynamic lights render with r_depthShaders 0
This allows identifying problems with the depth-based light culling.
1 parent 0d0e60b commit 2020fd4

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

src/engine/renderer/tr_backend.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1212,10 +1212,22 @@ void RB_RunVisTests( )
12121212

12131213
static void RenderDepthTiles()
12141214
{
1215-
// 1st step
12161215
GL_State( GLS_DEPTHTEST_DISABLE );
12171216
GL_Cull( CT_TWO_SIDED );
12181217

1218+
if ( !r_depthShaders.Get() )
1219+
{
1220+
// put max range so depth-based planes will always pass in lighttile
1221+
// setting to 99999 worked on my machines but is technically not allowed by the spec
1222+
// ARB_color_buffer_float lets you set values outside of [0, 1] but we use
1223+
// a different extension ARB_texture_float to get float color buffer
1224+
R_BindFBO( tr.depthtile2FBO );
1225+
glClearColor( /*max*/ 99999.f, /*min*/ 0.0f, 0.0f, 0.0f );
1226+
glClear( GL_COLOR_BUFFER_BIT );
1227+
return;
1228+
}
1229+
1230+
// 1st step
12191231
R_BindFBO( tr.depthtile1FBO );
12201232
GL_Viewport( 0, 0, tr.depthtile1FBO->width, tr.depthtile1FBO->height );
12211233
GL_Scissor( 0, 0, tr.depthtile1FBO->width, tr.depthtile1FBO->height );

src/engine/renderer/tr_local.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2683,6 +2683,7 @@ enum
26832683
extern Cvar::Modified<Cvar::Cvar<std::string>> r_textureMode;
26842684
extern cvar_t *r_offsetFactor;
26852685
extern cvar_t *r_offsetUnits;
2686+
extern Cvar::Cvar<bool> r_depthShaders;
26862687

26872688
extern cvar_t *r_physicalMapping;
26882689
extern cvar_t *r_specularExponentMin;

src/engine/renderer/tr_shader.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,8 @@ static Cvar::Cvar<float> r_portalDefaultRange(
8383
"r_portalDefaultRange", "Default portal range", Cvar::NONE, 1024);
8484

8585
// This can be turned off to debug problems with depth shaders.
86-
// Almost everything can be rendered correctly without them, except real-time lights
87-
// (since light tiles are populated using the depth buffer).
88-
static Cvar::Cvar<bool> r_depthShaders(
86+
// Things should generally render identically (albeit slower) without them.
87+
Cvar::Cvar<bool> r_depthShaders(
8988
"r_depthShaders", "use depth pre-pass shaders", Cvar::CHEAT, true);
9089

9190
/*

0 commit comments

Comments
 (0)