- added lookup for brightmap palettes.

This commit is contained in:
Christoph Oelckers 2019-10-18 12:11:53 +02:00
parent 530a9944f7
commit 542994cc20
2 changed files with 29 additions and 5 deletions

View file

@ -214,7 +214,6 @@ bool GLInstance::SetTexture(FTexture* tex, int palette, int method, int samplero
} }
else if (TextureType == TT_TRUECOLOR) else if (TextureType == TT_TRUECOLOR)
{ {
// Todo: brightmaps for true color tiles
lookuppal = palmanager.LookupPalette(usepalette, usepalswap, true); lookuppal = palmanager.LookupPalette(usepalette, usepalswap, true);
if (lookuppal >= 0) if (lookuppal >= 0)
{ {

View file

@ -261,18 +261,43 @@ int PaletteManager::LookupPalette(int palette, int palswap, bool brightmap)
{ {
int realpal = palettemap[palette]; int realpal = palettemap[palette];
int realswap = palswapmap[palswap]; int realswap = palswapmap[palswap];
int combined = realpal * 0x10000 + realswap; int combined = (brightmap? 0x1000000 : 0) + realpal * 0x10000 + realswap;
int* combinedindex = swappedpalmap.CheckKey(combined); int* combinedindex = swappedpalmap.CheckKey(combined);
if (combinedindex) return *combinedindex; if (combinedindex) return *combinedindex;
PaletteData* paldata = &palettes[realpal]; PaletteData* paldata = &palettes[realpal];
PalswapData* swapdata = &palswaps[realswap]; PalswapData* swapdata = &palswaps[realswap];
PalEntry swappedpalette[256]; PalEntry swappedpalette[256];
for (int i = 0; i < 256; i++) if (!brightmap)
{
for (int i = 0; i < 255; i++)
{ {
int swapi = swapdata->lookup[i]; int swapi = swapdata->lookup[i];
swappedpalette[i] = paldata->colors[swapi]; swappedpalette[i] = paldata->colors[swapi];
swappedpalette[i].a = 255;
} }
}
else
{
bool found = false;
memset(swappedpalette, 0, sizeof(swappedpalette));
for (int i = 0; i < 255; i++)
{
int swapi = swapdata->lookup[i];
auto swapc = paldata->colors[swapi];
if (swapc.a)
{
found = true;
swappedpalette[i] = 0xffffffff;
}
}
if (!found)
{
swappedpalmap.Insert(combined, -1);
return -1;
}
}
swappedpalette[255] = 0;
int palid = FindPalette((uint8_t*)swappedpalette); int palid = FindPalette((uint8_t*)swappedpalette);
swappedpalmap.Insert(combined, palid); swappedpalmap.Insert(combined, palid);
return palid; return palid;