diff --git a/source/common/rendering/hwrenderer/data/hw_skydome.cpp b/source/common/rendering/hwrenderer/data/hw_skydome.cpp index 9bbe5787f..8734b352c 100644 --- a/source/common/rendering/hwrenderer/data/hw_skydome.cpp +++ b/source/common/rendering/hwrenderer/data/hw_skydome.cpp @@ -455,7 +455,7 @@ void FSkyVertexBuffer::RenderRow(FRenderState& state, EDrawType prim, int row, T // //----------------------------------------------------------------------------- -void FSkyVertexBuffer::RenderDome(FRenderState& state, FGameTexture* tex, int mode, bool which) +void FSkyVertexBuffer::RenderDome(FRenderState& state, FGameTexture* tex, int mode, bool which, PalEntry color) { auto& primStart = which ? mPrimStartBuild : mPrimStartDoom; if (tex && tex->isValid()) @@ -471,6 +471,13 @@ void FSkyVertexBuffer::RenderDome(FRenderState& state, FGameTexture* tex, int mo if (mode == FSkyVertexBuffer::SKYMODE_MAINLAYER && tex != nullptr) { auto& col = R_GetSkyCapColor(tex); + col.first.r = col.first.r * color.r / 255; + col.first.g = col.first.g * color.g / 255; + col.first.b = col.first.b * color.b / 255; + col.second.r = col.second.r * color.r / 255; + col.second.g = col.second.g * color.g / 255; + col.second.b = col.second.b * color.b / 255; + state.SetObjectColor(col.first); state.EnableTexture(false); RenderRow(state, DT_TriangleFan, 0, primStart); @@ -497,13 +504,13 @@ void FSkyVertexBuffer::RenderDome(FRenderState& state, FGameTexture* tex, int mo // //----------------------------------------------------------------------------- -void FSkyVertexBuffer::RenderDome(FRenderState& state, FGameTexture* tex, float x_offset, float y_offset, bool mirror, int mode, bool tiled, float xscale, float yscale) +void FSkyVertexBuffer::RenderDome(FRenderState& state, FGameTexture* tex, float x_offset, float y_offset, bool mirror, int mode, bool tiled, float xscale, float yscale, PalEntry color) { if (tex) { SetupMatrices(tex, x_offset, y_offset, mirror, mode, state.mModelMatrix, state.mTextureMatrix, tiled, xscale, yscale); } - RenderDome(state, tex, mode, false); + RenderDome(state, tex, mode, false, color); } @@ -513,10 +520,11 @@ void FSkyVertexBuffer::RenderDome(FRenderState& state, FGameTexture* tex, float // //----------------------------------------------------------------------------- -void FSkyVertexBuffer::RenderBox(FRenderState& state, FSkyBox* tex, float x_offset, bool sky2, float stretch, const FVector3& skyrotatevector, const FVector3& skyrotatevector2) +void FSkyVertexBuffer::RenderBox(FRenderState& state, FSkyBox* tex, float x_offset, bool sky2, float stretch, const FVector3& skyrotatevector, const FVector3& skyrotatevector2, PalEntry color) { int faces; + state.SetObjectColor(color); state.EnableModelMatrix(true); state.mModelMatrix.loadIdentity(); state.mModelMatrix.scale(1, 1 / stretch, 1); // Undo the map's vertical scaling as skyboxes are true cubes. diff --git a/source/common/rendering/hwrenderer/data/hw_skydome.h b/source/common/rendering/hwrenderer/data/hw_skydome.h index 71ad85a08..213394c32 100644 --- a/source/common/rendering/hwrenderer/data/hw_skydome.h +++ b/source/common/rendering/hwrenderer/data/hw_skydome.h @@ -90,8 +90,8 @@ public: } void RenderRow(FRenderState& state, EDrawType prim, int row, TArray& mPrimStart, bool apply = true); - void RenderDome(FRenderState& state, FGameTexture* tex, int mode, bool which); - void RenderDome(FRenderState& state, FGameTexture* tex, float x_offset, float y_offset, bool mirror, int mode, bool tiled, float xscale = 0, float yscale = 0); - void RenderBox(FRenderState& state, FSkyBox* tex, float x_offset, bool sky2, float stretch, const FVector3& skyrotatevector, const FVector3& skyrotatevector2); + void RenderDome(FRenderState& state, FGameTexture* tex, int mode, bool which, PalEntry color = 0xffffffff); + void RenderDome(FRenderState& state, FGameTexture* tex, float x_offset, float y_offset, bool mirror, int mode, bool tiled, float xscale = 0, float yscale = 0, PalEntry color = 0xffffffff); + void RenderBox(FRenderState& state, FSkyBox* tex, float x_offset, bool sky2, float stretch, const FVector3& skyrotatevector, const FVector3& skyrotatevector2, PalEntry color = 0xffffffff); }; diff --git a/source/core/rendering/scene/hw_sky.cpp b/source/core/rendering/scene/hw_sky.cpp index 5174f8602..949e09389 100644 --- a/source/core/rendering/scene/hw_sky.cpp +++ b/source/core/rendering/scene/hw_sky.cpp @@ -88,7 +88,7 @@ void initSkyInfo(HWDrawInfo *di, HWSkyInfo* sky, sectortype* sector, int plane) pe.a = 230; sky->fadecolor = pe; - sky->shade = 0;// clamp(plane == plane_ceiling ? sector->ceilingshade : sector->floorshade, 0, numshades - 1); + sky->shade = clamp(plane == plane_ceiling ? sector->ceilingshade : sector->floorshade, 0, numshades - 1); sky->texture = skytex; } @@ -119,12 +119,10 @@ void HWWall::SkyPlane(HWDrawInfo *di, sectortype *sector, int plane, bool allowr } else { - ptype = PORTALTYPE_SKY; HWSkyInfo skyinfo; initSkyInfo(di, &skyinfo, sector, plane); - ptype = PORTALTYPE_SKY; sky = &skyinfo; - PutPortal(di, ptype, plane); + PutPortal(di, PORTALTYPE_SKY, plane); } } diff --git a/source/core/rendering/scene/hw_skyportal.cpp b/source/core/rendering/scene/hw_skyportal.cpp index 29126dc5e..0d012af32 100644 --- a/source/core/rendering/scene/hw_skyportal.cpp +++ b/source/core/rendering/scene/hw_skyportal.cpp @@ -45,6 +45,7 @@ void HWSkyPortal::DrawContents(HWDrawInfo *di, FRenderState &state) state.AlphaFunc(Alpha_GEqual, 0.f); state.SetRenderStyle(STYLE_Translucent); bool oldClamp = state.SetDepthClamp(true); + auto color = shadeToLight(origin->shade); di->SetupView(state, 0, 0, 0, !!(mState->MirrorFlag & 1), !!(mState->PlaneMirrorFlag & 1)); @@ -53,7 +54,7 @@ void HWSkyPortal::DrawContents(HWDrawInfo *di, FRenderState &state) auto skybox = origin->texture ? dynamic_cast(origin->texture->GetTexture()) : nullptr; if (skybox) { - vertexBuffer->RenderBox(state, skybox, origin->x_offset, false, /*di->Level->info->pixelstretch*/1, { 0, 0, 1 }, { 0, 0, 1 }); + vertexBuffer->RenderBox(state, skybox, origin->x_offset, false, /*di->Level->info->pixelstretch*/1, { 0, 0, 1 }, { 0, 0, 1 }, color); } else if (!origin->cloudy) { @@ -77,12 +78,12 @@ void HWSkyPortal::DrawContents(HWDrawInfo *di, FRenderState &state) textureMatrix.loadIdentity(); state.EnableTextureMatrix(true); textureMatrix.scale(1.f, repeat_fac, 1.f); - vertexBuffer->RenderDome(state, origin->texture, FSkyVertexBuffer::SKYMODE_MAINLAYER, true); + vertexBuffer->RenderDome(state, origin->texture, FSkyVertexBuffer::SKYMODE_MAINLAYER, true, 0, 0, color); state.EnableTextureMatrix(false); } else { - vertexBuffer->RenderDome(state, origin->texture, -origin->x_offset, origin->y_offset, false, FSkyVertexBuffer::SKYMODE_MAINLAYER, true); + vertexBuffer->RenderDome(state, origin->texture, -origin->x_offset, origin->y_offset, false, FSkyVertexBuffer::SKYMODE_MAINLAYER, true, 0, 0, color); } state.SetTextureMode(TM_NORMAL); if (origin->fadecolor & 0xffffff)