diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index 3896fcc36..b04d84267 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -37,7 +37,7 @@ static_assert(sizeof(vec3d_t) == sizeof(double) * 3); int skiptile = -1; -FGameTexture* GetSkyTexture(int basetile, int lognumtiles, const int16_t* tilemap); +FGameTexture* GetSkyTexture(int basetile, int lognumtiles, const int16_t* tilemap, int remap = 0); int checkTranslucentReplacement(FTextureID picnum, int pal); diff --git a/source/core/rendering/scene/hw_sky.cpp b/source/core/rendering/scene/hw_sky.cpp index a7792fac2..4dda69ac6 100644 --- a/source/core/rendering/scene/hw_sky.cpp +++ b/source/core/rendering/scene/hw_sky.cpp @@ -31,7 +31,7 @@ #include "cmdlib.h" CVAR(Bool,gl_noskyboxes, false, 0) -FGameTexture* GetSkyTexture(int basetile, int lognumtiles, const int16_t* tilemap); +FGameTexture* GetSkyTexture(int basetile, int lognumtiles, const int16_t* tilemap, int remap); //========================================================================== // @@ -49,8 +49,11 @@ void initSkyInfo(HWDrawInfo *di, HWSkyInfo* sky, sectortype* sector, int plane, // todo: check for skybox replacement. if (!skytex) { + int palette = plane == plane_ceiling ? sector->ceilingpal : sector->floorpal; + int remap = TRANSLATION(Translation_Remap + curbasepal, palette); + int16_t const* dapskyoff = getpsky(picnum, &dapyscale, &dapskybits, &dapyoffs, &daptileyscale); - skytex = GetSkyTexture(picnum, dapskybits, dapskyoff); + skytex = GetSkyTexture(picnum, dapskybits, dapskyoff, remap); realskybits = dapskybits; if (skytex) dapskybits = 0; else skytex = tileGetTexture(picnum); diff --git a/source/core/rendering/scene/hw_skyportal.cpp b/source/core/rendering/scene/hw_skyportal.cpp index 1bb5f382e..c17eb0e11 100644 --- a/source/core/rendering/scene/hw_skyportal.cpp +++ b/source/core/rendering/scene/hw_skyportal.cpp @@ -67,12 +67,18 @@ void HWSkyPortal::DrawContents(HWDrawInfo *di, FRenderState &state) auto& textureMatrix = state.mTextureMatrix; auto texskyoffset = tex->GetSkyOffset() + origin->y_offset + skyoffsettest; + int repeat_fac = 1; + if (texh <= 192) + { + repeat_fac = 384 / texh; + texh *= repeat_fac; + } modelMatrix.loadIdentity(); modelMatrix.rotate(-180.0f + origin->x_offset, 0.f, 1.f, 0.f); - modelMatrix.translate(0.f, -40 + texskyoffset + (tex->GetTexelHeight() - 300) / 2 * skyoffsetfactor, 0.f); + modelMatrix.translate(0.f, -40 + texskyoffset + (texh - 300) / 2 * skyoffsetfactor, 0.f); //modelMatrix.scale(1.f, 0.8f * 1.17f, 1.f); textureMatrix.loadIdentity(); - textureMatrix.scale(-1.f, 0.5, 1.f); + textureMatrix.scale(-1.f, 0.5*repeat_fac, 1.f); textureMatrix.translate(1.f, 0/*origin->y_offset / texh*/, 1.f); vertexBuffer->RenderDome(state, origin->texture, FSkyVertexBuffer::SKYMODE_MAINLAYER); } diff --git a/source/core/textures/skytexture.cpp b/source/core/textures/skytexture.cpp index 7dbde726a..f9e178b77 100644 --- a/source/core/textures/skytexture.cpp +++ b/source/core/textures/skytexture.cpp @@ -41,7 +41,7 @@ #include "texturemanager.h" #include "buildtiles.h" -FGameTexture* GetSkyTexture(int basetile, int lognumtiles, const int16_t *tilemap) +FGameTexture* GetSkyTexture(int basetile, int lognumtiles, const int16_t *tilemap, int remap) { char synthname[60]; @@ -70,6 +70,7 @@ FGameTexture* GetSkyTexture(int basetile, int lognumtiles, const int16_t *tilema if (!tex || !tex->isValid() || tex->GetTexture() == 0) return nullptr; build[i].TexImage = static_cast(tex->GetTexture()); build[i].OriginX = tilewidth * i; + build[i].Translation = GPalette.GetTranslation(GetTranslationType(remap), GetTranslationIndex(remap)); } auto tt = MakeGameTexture(new FImageTexture(new FMultiPatchTexture(tilewidth*numtiles, tileHeight(basetile), build, false, false)), synthname, ETextureType::Override); TexMan.AddGameTexture(tt, true);