From d2a702dd2a819bf35f9bd82cc64d4fa668e53bc5 Mon Sep 17 00:00:00 2001 From: havoc Date: Fri, 18 Jan 2008 11:45:39 +0000 Subject: [PATCH] disable water clipping plane while rendering sky, this fixes the "black sky" bug in reflection/refraction rendering git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7974 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_rmain.c | 9 ++++++--- r_shadow.c | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/gl_rmain.c b/gl_rmain.c index 64b031dc..04ecb0ad 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -2565,7 +2565,7 @@ void R_View_Update(void) R_View_UpdateEntityVisible(); } -void R_SetupView(void) +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); @@ -2576,7 +2576,7 @@ void R_SetupView(void) GL_SetupView_Orientation_FromEntity(&r_refdef.view.matrix); - if (r_refdef.view.useclipplane) + if (r_refdef.view.useclipplane && allowwaterclippingplane) { // LordHavoc: couldn't figure out how to make this approach the vec_t dist = r_refdef.view.clipplane.dist - r_water_clippingplanebias.value; @@ -2631,7 +2631,7 @@ void R_ResetViewRendering3D(void) // GL is weird because it's bottom to top, r_refdef.view.y is top to bottom qglViewport(r_refdef.view.x, vid.height - (r_refdef.view.y + r_refdef.view.height), r_refdef.view.width, r_refdef.view.height);CHECKGLERROR - R_SetupView(); + R_SetupView(true); GL_Scissor(r_refdef.view.x, r_refdef.view.y, r_refdef.view.width, r_refdef.view.height); GL_Color(1, 1, 1, 1); GL_ColorMask(r_refdef.view.colormask[0], r_refdef.view.colormask[1], r_refdef.view.colormask[2], 1); @@ -5570,7 +5570,10 @@ static void R_DrawTextureSurfaceList_Sky(int texturenumsurfaces, msurface_t **te if (skyrendernow) { skyrendernow = false; + // we have to force off the water clipping plane while rendering sky + R_SetupView(false); R_Sky(); + R_SetupView(true); // restore entity matrix R_Mesh_Matrix(&rsurface.matrix); } diff --git a/r_shadow.c b/r_shadow.c index 6b047852..6f9fea6d 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -3162,7 +3162,7 @@ void R_ShadowVolumeLighting(qboolean visible) R_Shadow_RenderMode_End(); } -extern void R_SetupView(void); +extern void R_SetupView(qboolean allowwaterclippingplane); extern cvar_t r_shadows_throwdistance; void R_DrawModelShadows(void) { @@ -3244,7 +3244,7 @@ void R_DrawModelShadows(void) R_Mesh_Draw(0, 4, 2, polygonelements, 0, 0); // restoring the perspective view is done by R_RenderScene - //R_SetupView(); + //R_SetupView(true); // restore other state to normal R_Shadow_RenderMode_End(); -- 2.39.2