diff --git a/source/core/defparser.cpp b/source/core/defparser.cpp index 18d0a7e814b..7a55068acbb 100644 --- a/source/core/defparser.cpp +++ b/source/core/defparser.cpp @@ -45,8 +45,8 @@ #include "mapinfo.h" #include "hw_voxels.h" -int tileSetHightileReplacement(int picnum, int palnum, const char* filename, float alphacut, float xscale, float yscale, float specpower, float specfactor); -int tileSetSkybox(int picnum, int palnum, FString* facenames); +int tileSetHightileReplacement(int picnum, int palnum, const char* filename, float alphacut, float xscale, float yscale, float specpower, float specfactor, bool indexed = false); +int tileSetSkybox(int picnum, int palnum, FString* facenames, bool indexed = false); void tileRemoveReplacement(int num); void AddUserMapHack(usermaphack_t&); @@ -135,7 +135,8 @@ static void parseTexturePaletteBlock(FScanner& sc, int tile) int pal = -1, xsiz = 0, ysiz = 0; FString fn; - double alphacut = -1.0, xscale = 1.0, yscale = 1.0, specpower = 1.0, specfactor = 1.0; + float alphacut = -1.0, xscale = 1.0, yscale = 1.0, specpower = 1.0, specfactor = 1.0; + bool indexed = false; if (!sc.GetNumber(pal, true)) return; @@ -151,6 +152,7 @@ static void parseTexturePaletteBlock(FScanner& sc, int tile) else if (sc.Compare({ "specfactor", "specularfactor", "parallaxbias" })) sc.GetFloat(specfactor, true); else if (sc.Compare("orig_sizex")) sc.GetNumber(xsiz, true); else if (sc.Compare("orig_sizey")) sc.GetNumber(ysiz, true); + else if (sc.Compare("indexed")) indexed = true; }; if ((unsigned)tile < MAXUSERTILES) @@ -167,7 +169,7 @@ static void parseTexturePaletteBlock(FScanner& sc, int tile) xscale = 1.0f / xscale; yscale = 1.0f / yscale; - tileSetHightileReplacement(tile, pal, fn, alphacut, xscale, yscale, specpower, specfactor); + tileSetHightileReplacement(tile, pal, fn, alphacut, xscale, yscale, specpower, specfactor, indexed); } } } @@ -485,6 +487,7 @@ void parseSkybox(FScanner& sc, FScriptPosition& pos) FString faces[6]; FScanner::SavedPos blockend; int tile = -1, pal = 0; + bool indexed = false; if (sc.StartBraces(&blockend)) return; while (!sc.FoundEndBrace(blockend)) @@ -498,10 +501,11 @@ void parseSkybox(FScanner& sc, FScriptPosition& pos) else if (sc.Compare({ "lt", "lf", "left" })) sc.GetString(faces[3]); else if (sc.Compare({ "up", "ceiling", "top", "ceil" })) sc.GetString(faces[4]); else if (sc.Compare({ "dn", "floor", "bottom", "down" })) sc.GetString(faces[5]); + else if (sc.Compare("indexed")) indexed = true; // skip over everything else. } if (tile < 0) pos.Message(MSG_ERROR, "skybox: missing tile number"); - else tileSetSkybox(tile, pal, faces); + else tileSetSkybox(tile, pal, faces, indexed); } //=========================================================================== diff --git a/source/core/textures/buildtiles.cpp b/source/core/textures/buildtiles.cpp index 5cd2b27c050..9b81e369128 100644 --- a/source/core/textures/buildtiles.cpp +++ b/source/core/textures/buildtiles.cpp @@ -60,7 +60,7 @@ enum BuildTiles TileFiles; -int tileSetHightileReplacement(int picnum, int palnum, const char* filename, float alphacut, float xscale, float yscale, float specpower, float specfactor); +int tileSetHightileReplacement(int picnum, int palnum, const char* filename, float alphacut, float xscale, float yscale, float specpower, float specfactor, bool indexed = false); //========================================================================== // diff --git a/source/core/textures/hightile.cpp b/source/core/textures/hightile.cpp index 6579c61122d..fa13f929ff7 100644 --- a/source/core/textures/hightile.cpp +++ b/source/core/textures/hightile.cpp @@ -59,6 +59,7 @@ struct HightileReplacement float alphacut, specpower, specfactor; uint16_t palnum; bool issky; + bool indexed; }; static TMap> tileReplacements; @@ -247,7 +248,7 @@ void PostLoadSetup() // //========================================================================== -int tileSetHightileReplacement(int picnum, int palnum, const char* filename, float alphacut, float xscale, float yscale, float specpower, float specfactor) +int tileSetHightileReplacement(int picnum, int palnum, const char* filename, float alphacut, float xscale, float yscale, float specpower, float specfactor, bool indexed) { if ((uint32_t)picnum >= (uint32_t)MAXTILES) return -1; if ((uint32_t)palnum >= (uint32_t)MAXPALOOKUPS) return -1; @@ -273,6 +274,7 @@ int tileSetHightileReplacement(int picnum, int palnum, const char* filename, flo replace.specpower = specpower; // currently unused replace.specfactor = specfactor; // currently unused replace.issky = 0; + replace.indexed = indexed; replace.palnum = (uint16_t)palnum; AddReplacement(picnum, replace); return 0; @@ -285,7 +287,7 @@ int tileSetHightileReplacement(int picnum, int palnum, const char* filename, flo // //========================================================================== -int tileSetSkybox(int picnum, int palnum, FString* facenames) +int tileSetSkybox(int picnum, int palnum, FString* facenames, bool indexed) { if ((uint32_t)picnum >= (uint32_t)MAXTILES) return -1; if ((uint32_t)palnum >= (uint32_t)MAXPALOOKUPS) return -1; @@ -316,6 +318,7 @@ int tileSetSkybox(int picnum, int palnum, FString* facenames) replace.image = MakeGameTexture(sbtex, "", ETextureType::Override); TexMan.AddGameTexture(replace.image, false); replace.issky = 1; + replace.indexed = indexed; replace.palnum = (uint16_t)palnum; AddReplacement(picnum, replace); return 0; @@ -347,21 +350,24 @@ bool PickTexture(FRenderState *state, FGameTexture* tex, int paletteid, TextureP auto rep = (hw_hightile && !(h.tintFlags & TINTF_ALWAYSUSEART)) ? FindReplacement(tex->GetID(), hipalswap, false) : nullptr; if (rep || tex->GetTexture()->isHardwareCanvas()) { - if (usepalette > 0) - { - // This is a global setting for the entire scene, so let's do it here, right at the start. (Fixme: Store this in a static table instead of reusing the same entry for all palettes.) - auto& hh = lookups.tables[MAXPALOOKUPS - 1]; - // This sets a tinting color for global palettes, e.g. water or slime - only used for hires replacements (also an option for low-resource hardware where duplicating the textures may be problematic.) - pick.basepalTint = hh.tintColor; - } - if (rep) { tex = rep->image; } - if (!rep || rep->palnum != hipalswap || (h.tintFlags & TINTF_APPLYOVERALTPAL)) - applytint = true; - pick.translation = 0; + if (!rep || !rep->indexed) + { + if (usepalette > 0) + { + // This is a global setting for the entire scene, so let's do it here, right at the start. (Fixme: Store this in a static table instead of reusing the same entry for all palettes.) + auto& hh = lookups.tables[MAXPALOOKUPS - 1]; + // This sets a tinting color for global palettes, e.g. water or slime - only used for hires replacements (also an option for low-resource hardware where duplicating the textures may be problematic.) + pick.basepalTint = hh.tintColor; + } + + if (!rep || rep->palnum != hipalswap || (h.tintFlags & TINTF_APPLYOVERALTPAL)) + applytint = true; + pick.translation = 0; + } } else {