Skip to content

Commit

Permalink
Export skyvis polygons
Browse files Browse the repository at this point in the history
Fix sky not being rendered when skyportals are not visible
  • Loading branch information
vs-shirokii committed Jul 20, 2024
1 parent 9773c7d commit 3712cb7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/common/rendering/rt/rt_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
21 changes: 21 additions & 0 deletions src/rendering/hwrenderer/scene/hw_portal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions src/rendering/hwrenderer/scene/hw_sky.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3712cb7

Please sign in to comment.