From 2c57eb5da846f1971eaedc5bb000477efd7b1335 Mon Sep 17 00:00:00 2001 From: uis Date: Tue, 2 Jan 2024 21:21:08 +0300 Subject: [PATCH] Enable depth test for skybox --- gl_rmain.c | 44 ++++++++++++++++++++++++-------------------- r_sky.c | 2 +- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/gl_rmain.c b/gl_rmain.c index 7b2c7ac6..cfcb3927 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -7257,26 +7257,6 @@ void R_RenderScene(int fbo, rtexture_t *depthtexture, rtexture_t *colortexture) // don't let sound skip if going slow if (r_refdef.scene.extraupdate) S_ExtraUpdate (); - - if (r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->DrawSky) - { - 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"); - - if (skyrendermasked && skyrenderlater) - { - // we have to force off the water clipping plane while rendering sky - R_SetupView(false, fbo, depthtexture, colortexture); - R_Sky(); - R_SetupView(true, fbo, depthtexture, colortexture); - if (r_timereport_active) - R_TimeReport("sky"); - } } R_Shadow_PrepareModelShadows(); @@ -7330,6 +7310,30 @@ void R_RenderScene(int fbo, rtexture_t *depthtexture, rtexture_t *colortexture) if (r_refdef.scene.extraupdate) S_ExtraUpdate (); + if (cl.csqc_vidvars.drawworld) + { + // don't let sound skip if going slow + if (r_refdef.scene.worldmodel && r_refdef.scene.worldmodel->DrawSky) + { + 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"); + + if (skyrendermasked && skyrenderlater) + { + // we have to force off the water clipping plane while rendering sky + R_SetupView(false, fbo, depthtexture, colortexture); + R_Sky(); + R_SetupView(true, fbo, depthtexture, colortexture); + if (r_timereport_active) + R_TimeReport("sky"); + } + } + if ((r_shadows.integer == 1 || (r_shadows.integer > 0 && !shadowmapping)) && !r_shadows_drawafterrtlighting.integer && r_refdef.scene.lightmapintensity > 0) { R_ResetViewRendering3D(fbo, depthtexture, colortexture); diff --git a/r_sky.c b/r_sky.c index 17754782..ea884b98 100644 --- a/r_sky.c +++ b/r_sky.c @@ -308,7 +308,7 @@ static void R_SkyBox(void) RSurf_ActiveCustomEntity(&skymatrix, &skyinversematrix, 0, 0, 1, 1, 1, 1, 6*4, skyboxvertex3f, skyboxtexcoord2f, NULL, NULL, NULL, NULL, 6*2, skyboxelement3i, skyboxelement3s, false, false); for (i = 0;i < 6;i++) if(skyboxskinframe[i]) - R_DrawCustomSurface(skyboxskinframe[i], &identitymatrix, MATERIALFLAG_SKY | MATERIALFLAG_FULLBRIGHT | MATERIALFLAG_NOCULLFACE | MATERIALFLAG_NODEPTHTEST, i*4, 4, i*2, 2, false, false); + R_DrawCustomSurface(skyboxskinframe[i], &identitymatrix, MATERIALFLAG_SKY | MATERIALFLAG_FULLBRIGHT | MATERIALFLAG_NOCULLFACE, i*4, 4, i*2, 2, false, false); } #define skygridx 32 -- 2.39.2