From 3712cb761b937e6d3df8c1dbc10e1fde6e08e29d Mon Sep 17 00:00:00 2001 From: "V. Shirokii" Date: Sat, 20 Jul 2024 13:54:16 +0100 Subject: [PATCH] Export skyvis polygons Fix sky not being rendered when skyportals are not visible --- src/common/rendering/rt/rt_main.cpp | 1 + src/rendering/hwrenderer/scene/hw_portal.cpp | 21 ++++++++++++++++++++ src/rendering/hwrenderer/scene/hw_sky.cpp | 7 +++++++ 3 files changed, 29 insertions(+) diff --git a/src/common/rendering/rt/rt_main.cpp b/src/common/rendering/rt/rt_main.cpp index d4c5341ac..d3bf55a41 100644 --- a/src/common/rendering/rt/rt_main.cpp +++ b/src/common/rendering/rt/rt_main.cpp @@ -153,6 +153,7 @@ namespace cvar RT_CVAR( rt_sky, 100.f, "sky intensity") RT_CVAR( rt_sky_saturation, 1.f, "sky saturation") RT_CVAR( rt_sky_stretch, 1.2f, "how much to stretch the sky sphere along the vertical axis") + RT_CVAR( rt_sky_always, true, "always submit sky geometry (even if it's not visible in primary view)") // RT_CVAR( rt_sun, 7000.f, "sun intensity") // RT_CVAR( rt_sun_diameter, 0.5f, "sun angular diameter in degrees") diff --git a/src/rendering/hwrenderer/scene/hw_portal.cpp b/src/rendering/hwrenderer/scene/hw_portal.cpp index 9b4f65aa1..b55eef062 100644 --- a/src/rendering/hwrenderer/scene/hw_portal.cpp +++ b/src/rendering/hwrenderer/scene/hw_portal.cpp @@ -44,6 +44,10 @@ EXTERN_CVAR(Int, r_mirror_recursions) EXTERN_CVAR(Bool, gl_portals) +namespace cvar +{ +EXTERN_CVAR( Bool, rt_sky_always ) +} void SetPlaneTextureRotation(FRenderState& state, HWSectorPlane* plane, FGameTexture* texture); @@ -95,6 +99,20 @@ void FPortalSceneState::EndFrame(HWDrawInfo *di, FRenderState &state) indent += " "; } +#if HAVE_RT + // no sky walls/floor/ceiling visible... emulate it :( + if( di->Portals.size() == 0 ) + { + if( cvar::rt_sky_always ) + { + HWSkyInfo skyinfo{}; + skyinfo.init( di, nullptr, sector_t::ceiling, 0, 0 ); + auto emulated_skyportal = HWSkyPortal{ screen->mSkyData, &portalState, &skyinfo }; + RenderPortal( &emulated_skyportal, state, true, di ); + } + } + else +#endif while (di->Portals.Pop(p) && p) { if (gl_portalinfo) @@ -227,6 +245,9 @@ void HWPortal::DrawPortalStencil(FRenderState &state, int pass) for (unsigned int i = 0; i < mPrimIndices.Size(); i += 2) { + auto rtexp = rtstate.push_type( + RT_IsWallExportable( lines[ i / 2 ].seg ) ? RtPrim::ExportMap : RtPrim::Identity ); + state.Draw(DT_TriangleFan, mPrimIndices[i], mPrimIndices[i + 1], i == 0); } if (NeedCap() && lines.Size() > 1) diff --git a/src/rendering/hwrenderer/scene/hw_sky.cpp b/src/rendering/hwrenderer/scene/hw_sky.cpp index dfa954530..498ca3f36 100644 --- a/src/rendering/hwrenderer/scene/hw_sky.cpp +++ b/src/rendering/hwrenderer/scene/hw_sky.cpp @@ -45,6 +45,13 @@ CVAR(Bool,gl_noskyboxes, false, 0) FTextureID GetSkyTexture(sector_t* sec, int plane, int second) { +#if HAVE_RT + if( !sec ) + { + return second ? level.skytexture2 : level.skytexture1; + } +#endif + auto tex = sec->planes[plane].skytexture[second]; if (tex.isValid()) return tex; return second ? sec->Level->skytexture2 : sec->Level->skytexture1;