Fix default palette for voxel BGRA slab data and support translated 8-bit slab data in true color mode

This commit is contained in:
Magnus Norddahl 2017-03-11 18:31:53 +01:00 committed by nashmuhandes
parent 447e0b0c0d
commit 2b9a970402
3 changed files with 9 additions and 6 deletions

View file

@ -400,7 +400,9 @@ FVoxel::~FVoxel()
void FVoxel::CreateBgraSlabData() void FVoxel::CreateBgraSlabData()
{ {
assert(Palette != NULL); uint8_t *palette = Palette;
if (palette == nullptr)
palette = (uint8_t *)GPalette.BaseColors;
for (int i = 0; i < NumMips; ++i) for (int i = 0; i < NumMips; ++i)
{ {
@ -423,9 +425,9 @@ void FVoxel::CreateBgraSlabData()
{ {
int colorIndex = src->col[j]; int colorIndex = src->col[j];
uint32_t red = (Palette[colorIndex * 3 + 0] << 2) | (Palette[colorIndex * 3 + 0] >> 4); uint32_t red = (palette[colorIndex * 3 + 0] << 2) | (palette[colorIndex * 3 + 0] >> 4);
uint32_t green = (Palette[colorIndex * 3 + 1] << 2) | (Palette[colorIndex * 3 + 1] >> 4); uint32_t green = (palette[colorIndex * 3 + 1] << 2) | (palette[colorIndex * 3 + 1] >> 4);
uint32_t blue = (Palette[colorIndex * 3 + 2] << 2) | (Palette[colorIndex * 3 + 2] >> 4); uint32_t blue = (palette[colorIndex * 3 + 2] << 2) | (palette[colorIndex * 3 + 2] >> 4);
dest->col[j] = 0xff000000 | (red << 16) | (green << 8) | blue; dest->col[j] = 0xff000000 | (red << 16) | (green << 8) | blue;
} }

View file

@ -532,8 +532,7 @@ namespace swrenderer
} }
const uint8_t *columnColors = col; const uint8_t *columnColors = col;
bool bgra = viewport->RenderTarget->IsBgra(); if (!drawerargs.DrawerNeedsPalInput() && viewport->RenderTarget->IsBgra())
if (bgra)
{ {
// The true color slab data array is identical, except its using uint32 instead of uint8. // The true color slab data array is identical, except its using uint32 instead of uint8.
// //

View file

@ -53,6 +53,8 @@ namespace swrenderer
uint32_t DynamicLight() const { return dynlightcolor; } uint32_t DynamicLight() const { return dynlightcolor; }
bool DrawerNeedsPalInput() const { return drawer_needs_pal_input; }
private: private:
bool SetBlendFunc(int op, fixed_t fglevel, fixed_t bglevel, int flags); bool SetBlendFunc(int op, fixed_t fglevel, fixed_t bglevel, int flags);
static fixed_t GetAlpha(int type, fixed_t alpha); static fixed_t GetAlpha(int type, fixed_t alpha);