mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-02-15 16:51:28 +00:00
Merge branch 'master' of https://github.com/coelckers/gzdoom into lightmaps2
This commit is contained in:
commit
635a279186
4 changed files with 30 additions and 9 deletions
|
@ -570,6 +570,32 @@ void RecordTextureColors (FImageSource *pic, uint32_t *usedcolors)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// RecordLuminosity
|
||||||
|
//
|
||||||
|
// Records minimum and maximum luminosity of a texture.
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
static void RecordLuminosity(FImageSource* pic, int* minlum, int* maxlum)
|
||||||
|
{
|
||||||
|
auto bitmap = pic->GetCachedBitmap(nullptr, FImageSource::normal);
|
||||||
|
auto pixels = bitmap.GetPixels();
|
||||||
|
auto size = pic->GetWidth() * pic->GetHeight();
|
||||||
|
|
||||||
|
for (int x = 0; x < size; x++)
|
||||||
|
{
|
||||||
|
int xx = x * 4;
|
||||||
|
if (pixels[xx + 3] > 0)
|
||||||
|
{
|
||||||
|
int lum = Luminance(pixels[xx + 2], pixels[xx + 1], pixels[xx]);
|
||||||
|
if (lum < *minlum) *minlum = lum;
|
||||||
|
if (lum > *maxlum) *maxlum = lum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// RecordAllTextureColors
|
// RecordAllTextureColors
|
||||||
|
@ -969,27 +995,22 @@ int FFont::GetMaxAscender(const uint8_t* string) const
|
||||||
void FFont::LoadTranslations()
|
void FFont::LoadTranslations()
|
||||||
{
|
{
|
||||||
unsigned int count = min<unsigned>(Chars.Size(), LastChar - FirstChar + 1);
|
unsigned int count = min<unsigned>(Chars.Size(), LastChar - FirstChar + 1);
|
||||||
uint32_t usedcolors[256] = {};
|
|
||||||
TArray<double> Luminosity;
|
|
||||||
|
|
||||||
if (count == 0) return;
|
if (count == 0) return;
|
||||||
|
int minlum = 255, maxlum = 0;
|
||||||
for (unsigned int i = 0; i < count; i++)
|
for (unsigned int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
if (Chars[i].OriginalPic)
|
if (Chars[i].OriginalPic)
|
||||||
{
|
{
|
||||||
auto pic = Chars[i].OriginalPic->GetTexture()->GetImage();
|
auto pic = Chars[i].OriginalPic->GetTexture()->GetImage();
|
||||||
if (pic) RecordTextureColors(pic, usedcolors);
|
RecordLuminosity(pic, &minlum, &maxlum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int minlum = 0, maxlum = 0;
|
|
||||||
GetLuminosity (usedcolors, Luminosity, &minlum, &maxlum);
|
|
||||||
if (MinLum >= 0 && MinLum < minlum) minlum = MinLum;
|
if (MinLum >= 0 && MinLum < minlum) minlum = MinLum;
|
||||||
if (MaxLum > maxlum) maxlum = MaxLum;
|
if (MaxLum > maxlum) maxlum = MaxLum;
|
||||||
|
|
||||||
// Here we can set everything to a luminosity translation.
|
// Here we can set everything to a luminosity translation.
|
||||||
|
|
||||||
// Create different translations for different color ranges
|
|
||||||
Translations.Resize(NumTextColors);
|
Translations.Resize(NumTextColors);
|
||||||
for (int i = 0; i < NumTextColors; i++)
|
for (int i = 0; i < NumTextColors; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -527,7 +527,7 @@ void FSingleLumpFont::FixupPalette (uint8_t *identity, const PalEntry *palette,
|
||||||
double minlum = 100000000.0;
|
double minlum = 100000000.0;
|
||||||
|
|
||||||
identity[0] = 0;
|
identity[0] = 0;
|
||||||
palette += 3; // Skip the transparent color
|
palette++; // Skip the transparent color
|
||||||
|
|
||||||
for (int i = 1; i < ActiveColors; ++i, palette ++)
|
for (int i = 1; i < ActiveColors; ++i, palette ++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -976,6 +976,7 @@ void HWSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
|
||||||
}
|
}
|
||||||
|
|
||||||
depth = (float)((x - vp.Pos.X) * vp.TanCos + (y - vp.Pos.Y) * vp.TanSin);
|
depth = (float)((x - vp.Pos.X) * vp.TanCos + (y - vp.Pos.Y) * vp.TanSin);
|
||||||
|
if (isSpriteShadow) depth += 1.f/65536.f; // always sort shadows behind the sprite.
|
||||||
|
|
||||||
// light calculation
|
// light calculation
|
||||||
|
|
||||||
|
|
|
@ -521,7 +521,6 @@ ExpEmit FxActionSpecialCall::Emit(VMFunctionBuilder *build)
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
|
|
||||||
// Call the BuiltinCallLineSpecial function to perform the desired special.
|
// Call the BuiltinCallLineSpecial function to perform the desired special.
|
||||||
static uint8_t reginfo[] = { REGT_INT, REGT_POINTER, REGT_INT, REGT_INT, REGT_INT, REGT_INT, REGT_INT };
|
|
||||||
auto sym = FindBuiltinFunction(NAME_BuiltinCallLineSpecial);
|
auto sym = FindBuiltinFunction(NAME_BuiltinCallLineSpecial);
|
||||||
|
|
||||||
assert(sym);
|
assert(sym);
|
||||||
|
|
Loading…
Reference in a new issue