From 9df2102805ac6458de79cb4a8abdf30ce79dd845 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Sun, 2 Jul 2023 20:31:45 +0200 Subject: [PATCH] Fix weather TD occlusion Weather top down occlusion rendering now working again and correct usage of R_NewFrameSync(). --- codemp/rd-rend2/tr_backend.cpp | 1 + codemp/rd-rend2/tr_bsp.cpp | 1 - codemp/rd-rend2/tr_weather.cpp | 43 +++++++--------------------------- 3 files changed, 10 insertions(+), 35 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index fee052422e..65c19308ff 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -2164,6 +2164,7 @@ static void RB_UpdateCameraConstants(gpuFrame_t *frame) { for (int i = 0; i < tr.numCachedViewParms; i++) { + backEnd.viewParms = tr.cachedViewParms[i]; const float zmax = tr.cachedViewParms[i].zFar; const float zmin = tr.cachedViewParms[i].zNear; diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index ea9dc9e92c..a573fe316c 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3295,7 +3295,6 @@ static void R_RenderAllCubemaps() { R_IssuePendingRenderCommands(); R_InitNextFrame(); - R_NewFrameSync(); GLenum cubemapFormat = GL_RGBA8; if (r_hdr->integer) diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index 3669cb3ce1..aa6d4a1027 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -126,7 +126,6 @@ namespace { R_IssuePendingRenderCommands(); R_InitNextFrame(); - R_NewFrameSync(); RE_BeginFrame(STEREO_CENTER); vec3_t mapSize; @@ -146,29 +145,13 @@ namespace VectorMA(tr.world->bmodels[0].bounds[1], 0.5f, mapSize, viewOrigin); viewOrigin[2] = tr.world->bmodels[0].bounds[1][2]; - ri.Printf(PRINT_ALL, "Rendering weather depth from (%.f %.f %.f)\n", - viewOrigin[0], viewOrigin[1], viewOrigin[2]); - orientationr_t orientation; R_SetOrientationOriginAndAxis(orientation, viewOrigin, forward, left, up); - - refdef_t refdef = {}; - VectorCopy(orientation.origin, refdef.vieworg); - for (int i = 0; i < 3; ++i) - VectorCopy(orientation.axis[i], refdef.viewaxis[i]); - - tr.refdef.rdflags = tr.refdef.rdflags & ~RDF_SKYBOXPORTAL; - tr.skyPortalEntities = 0; const vec3_t viewBounds[2] = { { 0.0f, -halfMapSize[1], -halfMapSize[0] }, { halfMapSize[2] * 2.0f, halfMapSize[1], halfMapSize[0] } }; - ri.Printf( - PRINT_ALL, - "Weather view bounds (%f %f %f) (%f %f %f)\n", - viewBounds[0][0], viewBounds[0][1], viewBounds[0][2], - viewBounds[1][0], viewBounds[1][1], viewBounds[1][2]); R_SetupViewParmsForOrthoRendering( tr.weatherDepthFbo->width, @@ -360,23 +343,11 @@ namespace qglDisable(GL_DEPTH_CLAMP); } + RE_BeginFrame(STEREO_CENTER); + if (tr.weatherSystem->numWeatherBrushes > 0) tr.viewParms.flags |= VPF_NOCLEAR; - const int firstDrawSurf = tr.refdef.numDrawSurfs; - - tr.refdef.x = refdef.x; - tr.refdef.y = refdef.y; - tr.refdef.width = refdef.width; - tr.refdef.height = refdef.height; - tr.refdef.fov_x = refdef.fov_x; - tr.refdef.fov_y = refdef.fov_y; - - VectorCopy(refdef.vieworg, tr.refdef.vieworg); - VectorCopy(refdef.viewaxis[0], tr.refdef.viewaxis[0]); - VectorCopy(refdef.viewaxis[1], tr.refdef.viewaxis[1]); - VectorCopy(refdef.viewaxis[2], tr.refdef.viewaxis[2]); - tr.refdef.numDrawSurfs = 0; tr.refdef.drawSurfs = backEndData->drawSurfs; @@ -386,6 +357,11 @@ namespace tr.refdef.num_dlights = 0; tr.refdef.dlights = backEndData->dlights; + tr.refdef.fistDrawSurf = 0; + + tr.skyPortalEntities = 0; + + tr.viewParms.targetFbo = tr.weatherDepthFbo; tr.viewParms.currentViewParm = 0; Com_Memcpy(&tr.cachedViewParms[0], &tr.viewParms, sizeof(viewParms_t)); tr.numCachedViewParms = 1; @@ -393,12 +369,11 @@ namespace RB_UpdateConstants(&tr.refdef); R_GenerateDrawSurfs(&tr.viewParms, &tr.refdef); - R_SortAndSubmitDrawSurfs( - tr.refdef.drawSurfs + firstDrawSurf, - tr.refdef.numDrawSurfs - firstDrawSurf); + R_SortAndSubmitDrawSurfs(tr.refdef.drawSurfs, tr.refdef.numDrawSurfs); R_IssuePendingRenderCommands(); tr.refdef.numDrawSurfs = 0; + tr.numCachedViewParms = 0; RE_EndScene();