]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
changed use of infinite farclip to depend on 32bpp modes instead of on
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 19 Mar 2008 02:24:09 +0000 (02:24 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 19 Mar 2008 02:24:09 +0000 (02:24 +0000)
whether shadows are enabled
added r_useinfinitefarclip cvar to allow disabling this otherwise forced
feature if it causes problems for anyone (was on for most users already)
optimized farclip math a little bit (use model->radius * 2 instead of
VectorDistance from corner to corner)

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8215 d7cf8633-e32d-0410-b094-e92efae38249

gl_rmain.c

index c503245a21117296c4780646b9781da62531fde7..8a622a7b30c665eda2d850e7e6f8401017ee24fa 100644 (file)
@@ -34,6 +34,7 @@ rtexturepool_t *r_main_texturepool;
 r_refdef_t r_refdef;
 
 cvar_t r_depthfirst = {CVAR_SAVE, "r_depthfirst", "1", "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_nearclip = {0, "r_nearclip", "1", "distance from camera of nearclip plane" };
 cvar_t r_showbboxes = {0, "r_showbboxes", "0", "shows bounding boxes of server entities, value controls opacity scaling (1 = 10%,  10 = 100%)"};
 cvar_t r_showsurfaces = {0, "r_showsurfaces", "0", "1 shows surfaces as different colors, or a value of 2 shows triangle draw order (for analyzing whether meshes are optimized for vertex cache)"};
@@ -2230,6 +2231,7 @@ void GL_Main_Init(void)
                Cvar_RegisterVariable (&gl_skyclip);
        }
        Cvar_RegisterVariable(&r_depthfirst);
+       Cvar_RegisterVariable(&r_useinfinitefarclip);
        Cvar_RegisterVariable(&r_nearclip);
        Cvar_RegisterVariable(&r_showbboxes);
        Cvar_RegisterVariable(&r_showsurfaces);
@@ -2763,7 +2765,7 @@ void R_SetupView(qboolean allowwaterclippingplane)
 {
        if (!r_refdef.view.useperspective)
                GL_SetupView_Mode_Ortho(-r_refdef.view.ortho_x, -r_refdef.view.ortho_y, r_refdef.view.ortho_x, r_refdef.view.ortho_y, -r_refdef.farclip, r_refdef.farclip);
-       else if (r_refdef.scene.rtworldshadows || r_refdef.scene.rtdlightshadows)
+       else if (gl_stencil && r_useinfinitefarclip.integer)
                GL_SetupView_Mode_PerspectiveInfiniteFarClip(r_refdef.view.frustum_x, r_refdef.view.frustum_y, r_refdef.nearclip);
        else
                GL_SetupView_Mode_Perspective(r_refdef.view.frustum_x, r_refdef.view.frustum_y, r_refdef.nearclip, r_refdef.farclip);
@@ -3532,7 +3534,7 @@ void R_UpdateVariables(void)
 
        r_refdef.farclip = 4096;
        if (r_refdef.scene.worldmodel)
-               r_refdef.farclip += VectorDistance(r_refdef.scene.worldmodel->normalmins, r_refdef.scene.worldmodel->normalmaxs);
+               r_refdef.farclip += r_refdef.scene.worldmodel->radius * 2;
        r_refdef.nearclip = bound (0.001f, r_nearclip.value, r_refdef.farclip - 1.0f);
 
        if (r_shadow_frontsidecasting.integer < 0 || r_shadow_frontsidecasting.integer > 1)