mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-27 20:20:40 +00:00
- moved hictinting data into the lookup tables.
This commit is contained in:
parent
594ec6626c
commit
1bc744b77b
18 changed files with 150 additions and 246 deletions
|
@ -730,7 +730,6 @@ set (PCH_SOURCES
|
|||
build/src/defs.cpp
|
||||
build/src/engine.cpp
|
||||
build/src/hash.cpp
|
||||
build/src/hightile.cpp
|
||||
build/src/mdsprite.cpp
|
||||
build/src/mhk.cpp
|
||||
build/src/palette.cpp
|
||||
|
|
|
@ -2924,38 +2924,38 @@ void UpdateDacs(int nPalette, bool bNoTint)
|
|||
if (videoGetRenderMode() >= REND_POLYMOST)
|
||||
{
|
||||
gLastPal = 0;
|
||||
polytint_t *tint = &hictinting[MAXPALOOKUPS-1];
|
||||
auto &tint = lookups.tables[MAXPALOOKUPS-1];
|
||||
int nRed = 0;
|
||||
int nGreen = 0;
|
||||
int nBlue = 0;
|
||||
tint->f = 0;
|
||||
tint.tintFlags = 0;
|
||||
switch (nPalette)
|
||||
{
|
||||
case 0:
|
||||
default:
|
||||
tint->tint.r = 255;
|
||||
tint->tint.g = 255;
|
||||
tint->tint.b = 255;
|
||||
tint.tintColor.r = 255;
|
||||
tint.tintColor.g = 255;
|
||||
tint.tintColor.b = 255;
|
||||
break;
|
||||
case 1:
|
||||
tint->tint.r = 132;
|
||||
tint->tint.g = 164;
|
||||
tint->tint.b = 255;
|
||||
tint.tintColor.r = 132;
|
||||
tint.tintColor.g = 164;
|
||||
tint.tintColor.b = 255;
|
||||
break;
|
||||
case 2:
|
||||
tint->tint.r = 255;
|
||||
tint->tint.g = 126;
|
||||
tint->tint.b = 105;
|
||||
tint.tintColor.r = 255;
|
||||
tint.tintColor.g = 126;
|
||||
tint.tintColor.b = 105;
|
||||
break;
|
||||
case 3:
|
||||
tint->tint.r = 162;
|
||||
tint->tint.g = 186;
|
||||
tint->tint.b = 15;
|
||||
tint.tintColor.r = 162;
|
||||
tint.tintColor.g = 186;
|
||||
tint.tintColor.b = 15;
|
||||
break;
|
||||
case 4:
|
||||
tint->tint.r = 255;
|
||||
tint->tint.g = 255;
|
||||
tint->tint.b = 255;
|
||||
tint.tintColor.r = 255;
|
||||
tint.tintColor.g = 255;
|
||||
tint.tintColor.b = 255;
|
||||
break;
|
||||
}
|
||||
if (!bNoTint)
|
||||
|
|
|
@ -1128,8 +1128,6 @@ extern int32_t r_rortexture;
|
|||
extern int32_t r_rortexturerange;
|
||||
extern int32_t r_rorphase;
|
||||
|
||||
void hicinit(void);
|
||||
void hicsetpalettetint(int32_t palnum, int r, int g, int b, int sr, int sg, int sb, polytintflags_t effect);
|
||||
// flags bitset: 1 = don't compress
|
||||
int32_t Ptile2tile(int32_t tile, int32_t palette) ATTRIBUTE((pure));
|
||||
int32_t md_loadmodel(const char *fn);
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
#ifndef HIGHTILE_PRIV_H
|
||||
#define HIGHTILE_PRIV_H
|
||||
|
||||
#include "palentry.h"
|
||||
|
||||
typedef struct {
|
||||
polytintflags_t f;
|
||||
PalEntry tint;
|
||||
PalEntry shade;
|
||||
} polytint_t;
|
||||
|
||||
extern polytint_t hictinting[MAXPALOOKUPS];
|
||||
|
||||
|
||||
// replacement flags
|
||||
enum
|
||||
{
|
||||
HICR_FORCEFILTER = 2,
|
||||
};
|
||||
|
||||
// hictinting[].f / gloadtile_hi() and mdloadskin() <effect> arg bits
|
||||
enum
|
||||
{
|
||||
HICTINT_GRAYSCALE = 1,
|
||||
HICTINT_INVERT = 2,
|
||||
HICTINT_COLORIZE = 4,
|
||||
HICTINT_USEONART = 8,
|
||||
HICTINT_APPLYOVERPALSWAP = 16,
|
||||
HICTINT_APPLYOVERALTPAL = 32,
|
||||
|
||||
HICTINT_BLEND_MULTIPLY = 0<<6,
|
||||
HICTINT_BLEND_SCREEN = 1<<6,
|
||||
HICTINT_BLEND_OVERLAY = 2<<6,
|
||||
HICTINT_BLEND_HARDLIGHT = 3<<6,
|
||||
|
||||
HICTINT_BLENDMASK = 64|128,
|
||||
HICTINT_ALWAYSUSEART = 256,
|
||||
HICTINT_PRECOMPUTED = HICTINT_COLORIZE | HICTINT_BLENDMASK,
|
||||
HICTINT_ENABLE = 32768
|
||||
};
|
||||
|
||||
#endif
|
|
@ -2,7 +2,7 @@
|
|||
# define mdsprite_h_
|
||||
|
||||
#ifdef USE_OPENGL
|
||||
#include "hightile.h"
|
||||
#include "palette.h"
|
||||
#include "gl_hwtexture.h"
|
||||
|
||||
#if defined(_M_IX86) || defined(_M_AMD64) || defined(__i386) || defined(__x86_64)
|
||||
|
|
|
@ -28,6 +28,27 @@
|
|||
#define NORMALPAL (MAXPALOOKUPS - 4)
|
||||
#define BRIGHTPAL (MAXPALOOKUPS)
|
||||
|
||||
// fixme: should use the flags from the PRSFlags enum directly
|
||||
enum
|
||||
{
|
||||
TINTF_GRAYSCALE = 1,
|
||||
TINTF_INVERT = 2,
|
||||
TINTF_COLORIZE = 4,
|
||||
TINTF_USEONART = 8,
|
||||
TINTF_APPLYOVERPALSWAP = 16,
|
||||
TINTF_APPLYOVERALTPAL = 32,
|
||||
|
||||
TINTF_BLEND_MULTIPLY = 0 << 6,
|
||||
TINTF_BLEND_SCREEN = 1 << 6,
|
||||
TINTF_BLEND_OVERLAY = 2 << 6,
|
||||
TINTF_BLEND_HARDLIGHT = 3 << 6,
|
||||
|
||||
TINTF_BLENDMASK = 64 | 128,
|
||||
TINTF_ALWAYSUSEART = 256,
|
||||
TINTF_PRECOMPUTED = TINTF_COLORIZE | TINTF_BLENDMASK,
|
||||
TINTF_ENABLE = 32768
|
||||
};
|
||||
|
||||
struct LookupTable
|
||||
{
|
||||
FString Shades;
|
||||
|
@ -35,6 +56,10 @@ struct LookupTable
|
|||
float Visibility = 0;
|
||||
bool hasBrightmap = false;
|
||||
bool noFloorPal = false;
|
||||
|
||||
int tintFlags = 0;
|
||||
PalEntry tintColor = 0xffffff;
|
||||
PalEntry tintShade = 0;
|
||||
};
|
||||
|
||||
struct LookupTableInfo
|
||||
|
@ -84,6 +109,9 @@ struct LookupTableInfo
|
|||
return tables[num].noFloorPal;
|
||||
}
|
||||
|
||||
void setPaletteTint(int palnum, int r, int g, int b, int sr, int sg, int sb, int flags);
|
||||
|
||||
|
||||
};
|
||||
|
||||
extern LookupTableInfo lookups;
|
||||
|
@ -130,17 +158,13 @@ inline void videoFadePalette(uint8_t r, uint8_t g, uint8_t b, uint8_t offset)
|
|||
}
|
||||
|
||||
|
||||
#ifdef USE_OPENGL
|
||||
void videoTintBlood(int32_t r, int32_t g, int32_t b);
|
||||
#endif
|
||||
|
||||
extern int32_t globalpal;
|
||||
extern int32_t globalblend;
|
||||
extern void paletteLoadFromDisk(void);
|
||||
|
||||
|
||||
#ifdef USE_OPENGL
|
||||
|
||||
typedef struct glblenddef_
|
||||
{
|
||||
float alpha;
|
||||
|
@ -160,5 +184,3 @@ extern void SetRenderStyleFromBlend(uint8_t enable, uint8_t blend, uint8_t def);
|
|||
float GetAlphaFromBlend(uint32_t maskprops, uint32_t blend);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
|
||||
#include "baselayer.h" // glinfo
|
||||
#include "hightile.h"
|
||||
#include "mdsprite.h"
|
||||
|
||||
void Polymost_CacheHitList(uint8_t* hash);
|
||||
|
|
|
@ -19,10 +19,6 @@
|
|||
#include "gamecontrol.h"
|
||||
#include "palettecontainer.h"
|
||||
|
||||
#ifdef USE_OPENGL
|
||||
# include "hightile.h"
|
||||
#endif
|
||||
|
||||
enum scripttoken_t
|
||||
{
|
||||
T_INCLUDE = 0,
|
||||
|
@ -384,9 +380,7 @@ static int32_t defsparser(scriptfile *script)
|
|||
if (scriptfile_getnumber(script,&g)) break;
|
||||
if (scriptfile_getnumber(script,&b)) break;
|
||||
if (scriptfile_getnumber(script,&f)) break; //effects
|
||||
#ifdef USE_OPENGL
|
||||
hicsetpalettetint(pal,r,g,b,0,0,0,f);
|
||||
#endif
|
||||
lookups.setPaletteTint(pal,r,g,b,0,0,0,f);
|
||||
}
|
||||
break;
|
||||
case T_ALPHAHACK:
|
||||
|
@ -1488,10 +1482,6 @@ static int32_t defsparser(scriptfile *script)
|
|||
scriptfile_getstring(script,&skinfn); break; //skin filename
|
||||
case T_SURF:
|
||||
scriptfile_getnumber(script,&surfnum); break;
|
||||
#ifdef USE_OPENGL
|
||||
case T_FORCEFILTER:
|
||||
flags |= HICR_FORCEFILTER; break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1827,10 +1817,6 @@ static int32_t defsparser(scriptfile *script)
|
|||
scriptfile_getstring(script,&fn[4]); break;
|
||||
case T_BOTTOM:
|
||||
scriptfile_getstring(script,&fn[5]); break;
|
||||
#ifdef USE_OPENGL
|
||||
case T_FORCEFILTER:
|
||||
flags |= HICR_FORCEFILTER; break;
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1949,9 +1935,7 @@ static int32_t defsparser(scriptfile *script)
|
|||
break;
|
||||
}
|
||||
|
||||
#ifdef USE_OPENGL
|
||||
hicsetpalettetint(pal,red,green,blue,shadered,shadegreen,shadeblue,flags);
|
||||
#endif
|
||||
lookups.setPaletteTint(pal,red,green,blue,shadered,shadegreen,shadeblue,flags);
|
||||
}
|
||||
break;
|
||||
case T_MAKEPALOOKUP:
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
#include "earcut.hpp"
|
||||
|
||||
#ifdef USE_OPENGL
|
||||
# include "hightile.h"
|
||||
# include "mdsprite.h"
|
||||
# include "polymost.h"
|
||||
#include "v_video.h"
|
||||
|
@ -2115,14 +2114,11 @@ int32_t enginePostInit(void)
|
|||
|
||||
void engineUnInit(void)
|
||||
{
|
||||
#ifdef USE_OPENGL
|
||||
polymost_glreset();
|
||||
hicinit();
|
||||
freeallmodels();
|
||||
# ifdef POLYMER
|
||||
polymer_uninit();
|
||||
# endif
|
||||
#endif
|
||||
|
||||
TileFiles.CloseAll();
|
||||
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
/*
|
||||
* High-colour textures support for Polymost
|
||||
* by Jonathon Fowler
|
||||
* See the included license file "BUILDLIC.TXT" for license info.
|
||||
*/
|
||||
|
||||
#include "build.h"
|
||||
#include "compat.h"
|
||||
#include "hightile.h"
|
||||
#include "baselayer.h"
|
||||
|
||||
|
||||
polytint_t hictinting[MAXPALOOKUPS];
|
||||
|
||||
|
||||
//
|
||||
// hicinit()
|
||||
// Initialize the high-colour stuff to default.
|
||||
//
|
||||
void hicinit(void)
|
||||
{
|
||||
int32_t i;
|
||||
|
||||
for (i=0; i<MAXPALOOKUPS; i++) // all tints should be 100%
|
||||
{
|
||||
polytint_t & tint = hictinting[i];
|
||||
tint.tint = 0xffffff;
|
||||
tint.f = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// hicsetpalettetint(pal,r,g,b,sr,sg,sb,effect)
|
||||
// The tinting values represent a mechanism for emulating the effect of global sector
|
||||
// palette shifts on true-colour textures and only true-colour textures.
|
||||
// effect bitset: 1 = greyscale, 2 = invert
|
||||
//
|
||||
void hicsetpalettetint(int32_t palnum, int r, int g, int b, int sr, int sg, int sb, polytintflags_t effect)
|
||||
{
|
||||
if ((uint32_t)palnum >= (uint32_t)MAXPALOOKUPS) return;
|
||||
|
||||
polytint_t & tint = hictinting[palnum];
|
||||
tint.tint.r = (uint8_t)r;
|
||||
tint.tint.g = (uint8_t)g;
|
||||
tint.tint.b = (uint8_t)b;
|
||||
tint.shade.r = (uint8_t)sr;
|
||||
tint.shade.g = (uint8_t)sg;
|
||||
tint.shade.b = (uint8_t)sb;
|
||||
tint.f = effect|HICTINT_ENABLE;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -7,7 +7,6 @@
|
|||
#include "pragmas.h"
|
||||
#include "baselayer.h"
|
||||
#include "engine_priv.h"
|
||||
#include "hightile.h"
|
||||
#include "polymost.h"
|
||||
#include "mdsprite.h"
|
||||
|
||||
|
|
|
@ -70,9 +70,7 @@ void paletteLoadFromDisk(void)
|
|||
if (!fil.isOpen())
|
||||
return;
|
||||
|
||||
|
||||
// PALETTE_MAIN
|
||||
|
||||
// Base palette
|
||||
uint8_t palette[768];
|
||||
if (768 != fil.Read(palette, 768))
|
||||
return;
|
||||
|
@ -83,43 +81,25 @@ void paletteLoadFromDisk(void)
|
|||
paletteSetColorTable(0, palette, false, false);
|
||||
paletteloaded |= PALETTE_MAIN;
|
||||
|
||||
// PALETTE_SHADES
|
||||
numshades = fil.ReadInt16();
|
||||
|
||||
if (numshades <= 1)
|
||||
// LameDuke and Witchaven use an older variant.
|
||||
if (fil.GetLength() == 41600)
|
||||
{
|
||||
Printf("Warning: Invalid number of shades in \"palette.dat\"!\n");
|
||||
numshades = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
#if 0
|
||||
// Reminder: Witchaven's shade table has no index and no easy means to autodetect.
|
||||
if (numshades == 0 && (g_gameType & GAMEFLAG_WITCHAVEN))
|
||||
{
|
||||
numshades = 32;
|
||||
fil.Seek(-2, FileReader::SeekCur);
|
||||
numshades = 32;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
// LameDuke's is yet another variant.
|
||||
if (numshades >= 256)
|
||||
// Shade tables
|
||||
numshades = fil.ReadInt16();
|
||||
|
||||
if (numshades <= 1)
|
||||
{
|
||||
uint16_t temp = fil.ReadUInt16();
|
||||
if (temp == 770 || numshades > 256) // 02 03
|
||||
{
|
||||
fil.Seek(-4, FileReader::SeekCur);
|
||||
numshades = 32;
|
||||
}
|
||||
else
|
||||
{
|
||||
fil.Seek(-2, FileReader::SeekCur);
|
||||
}
|
||||
Printf("Warning: Invalid number of shades in \"palette.dat\"!\n");
|
||||
numshades = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Read base shade table (lookuptables 0).
|
||||
int length = numshades * 256;
|
||||
auto buffer = fil.Read(length);
|
||||
|
@ -394,6 +374,31 @@ void LookupTableInfo::makeTable(int palnum, const uint8_t *remapbuf, int r, int
|
|||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// hicsetpalettetint(pal,r,g,b,sr,sg,sb,effect)
|
||||
// The tinting values represent a mechanism for emulating the effect of global sector
|
||||
// palette shifts on true-colour textures and only true-colour textures.
|
||||
// effect bitset: 1 = greyscale, 2 = invert
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void LookupTableInfo::setPaletteTint(int palnum, int r, int g, int b, int sr, int sg, int sb, int flags)
|
||||
{
|
||||
if ((unsigned)palnum >= MAXPALOOKUPS) return;
|
||||
|
||||
auto &lookup = tables[palnum];
|
||||
lookup.tintColor = PalEntry(r, g, b);
|
||||
lookup.tintShade = PalEntry(sr, sg, sb);
|
||||
lookup.tintFlags = flags | TINTF_ENABLE;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void videoSetPalette(int dabrightness, int palid, ESetPalFlags flags)
|
||||
{
|
||||
curbasepal = (GPalette.GetTranslation(Translation_BasePalettes, palid) == nullptr)? 0 : palid;
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include "pragmas.h"
|
||||
#include "baselayer.h"
|
||||
#include "engine_priv.h"
|
||||
#include "hightile.h"
|
||||
#include "polymost.h"
|
||||
#include "mdsprite.h"
|
||||
#include "v_video.h"
|
||||
|
@ -1085,9 +1084,9 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
|
|||
|
||||
pc[0] = pc[1] = pc[2] = 1.f;
|
||||
|
||||
auto& h = hictinting[globalpal];
|
||||
if (h.f & (HICTINT_USEONART|HICTINT_ALWAYSUSEART))
|
||||
GLInterface.SetTinting(h.f, h.tint, h.tint);
|
||||
auto& h = lookups.tables[globalpal];
|
||||
if (h.tintFlags & (TINTF_USEONART|TINTF_ALWAYSUSEART))
|
||||
GLInterface.SetTinting(h.tintFlags, h.tintColor, h.tintColor);
|
||||
else
|
||||
GLInterface.SetTinting(-1, 0xffffff, 0xffffff);
|
||||
|
||||
|
|
|
@ -671,28 +671,28 @@ void G_DisplayRest(int32_t smoothratio)
|
|||
// this takes care of fullscreen tint for OpenGL
|
||||
if (videoGetRenderMode() >= REND_POLYMOST)
|
||||
{
|
||||
polytint_t & fstint = hictinting[MAXPALOOKUPS-1];
|
||||
auto & fstint = lookups.tables[MAXPALOOKUPS-1];
|
||||
|
||||
if (pp->palette == WATERPAL)
|
||||
{
|
||||
fstint.tint.r = 224;
|
||||
fstint.tint.g = 192;
|
||||
fstint.tint.b = 255;
|
||||
fstint.f = 0;
|
||||
fstint.tintColor.r = 224;
|
||||
fstint.tintColor.g = 192;
|
||||
fstint.tintColor.b = 255;
|
||||
fstint.tintFlags = 0;
|
||||
}
|
||||
else if (pp->palette == SLIMEPAL)
|
||||
{
|
||||
fstint.tint.r = 208;
|
||||
fstint.tint.g = 255;
|
||||
fstint.tint.b = 192;
|
||||
fstint.f = 0;
|
||||
fstint.tintColor.r = 208;
|
||||
fstint.tintColor.g = 255;
|
||||
fstint.tintColor.b = 192;
|
||||
fstint.tintFlags = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
fstint.tint.r = 255;
|
||||
fstint.tint.g = 255;
|
||||
fstint.tint.b = 255;
|
||||
fstint.f = 0;
|
||||
fstint.tintColor.r = 255;
|
||||
fstint.tintColor.g = 255;
|
||||
fstint.tintColor.b = 255;
|
||||
fstint.tintFlags = 0;
|
||||
}
|
||||
}
|
||||
#endif // USE_OPENGL
|
||||
|
|
|
@ -29,14 +29,14 @@ enum PRSFlags
|
|||
RF_FogDisabled = 128,
|
||||
RF_MapFog = 256, // RRRA E2L1.
|
||||
|
||||
RF_HICTINT_Grayscale = 0x10000,
|
||||
RF_HICTINT_Invert = 0x20000,
|
||||
RF_HICTINT_Colorize = 0x40000,
|
||||
RF_HICTINT_BLEND_Screen = 0x80000,
|
||||
RF_HICTINT_BLEND_Overlay = 0x100000,
|
||||
RF_HICTINT_BLEND_Hardlight = 0x200000,
|
||||
RF_HICTINT_BLENDMASK = RF_HICTINT_BLEND_Screen | RF_HICTINT_BLEND_Overlay | RF_HICTINT_BLEND_Hardlight,
|
||||
RF_HICTINT_MASK = 0x3f0000,
|
||||
RF_TINT_Grayscale = 0x10000,
|
||||
RF_TINT_Invert = 0x20000,
|
||||
RF_TINT_Colorize = 0x40000,
|
||||
RF_TINT_BLEND_Screen = 0x80000,
|
||||
RF_TINT_BLEND_Overlay = 0x100000,
|
||||
RF_TINT_BLEND_Hardlight = 0x200000,
|
||||
RF_TINT_BLENDMASK = RF_TINT_BLEND_Screen | RF_TINT_BLEND_Overlay | RF_TINT_BLEND_Hardlight,
|
||||
RF_TINT_MASK = 0x3f0000,
|
||||
|
||||
STF_BLEND = 1,
|
||||
STF_COLORMASK = 2,
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
|
||||
#include "palette.h"
|
||||
#include "build.h"
|
||||
#include "hightile.h"
|
||||
#include "polymost.h"
|
||||
#include "textures.h"
|
||||
#include "bitmap.h"
|
||||
|
@ -89,7 +88,7 @@ TexturePick PickTexture(int tilenum, int basepal, int palette)
|
|||
int usepalswap = fixpalswap >= 0 ? fixpalswap : palette;
|
||||
auto& h = hictinting[palette];
|
||||
auto tex = TileFiles.tiles[tilenum];
|
||||
auto rep = (hw_hightile && !(h.f & HICTINT_ALWAYSUSEART)) ? TileFiles.FindReplacement(tilenum, usepalswap) : nullptr;
|
||||
auto rep = (hw_hightile && !(h.tintFlags & TINTF_ALWAYSUSEART)) ? TileFiles.FindReplacement(tilenum, usepalswap) : nullptr;
|
||||
// Canvas textures must be treated like hightile replacements in the following code.
|
||||
bool truecolor = rep || tex->GetUseType() == FGameTexture::Canvas;
|
||||
bool applytint = false;
|
||||
|
@ -107,22 +106,22 @@ TexturePick PickTexture(int tilenum, int basepal, int palette)
|
|||
{
|
||||
tex = rep->faces[0];
|
||||
}
|
||||
if (!rep || rep->palnum != palette || (h.f & HICTINT_APPLYOVERALTPAL)) applytint = true;
|
||||
if (!rep || rep->palnum != palette || (h.tintFlags & TINTF_APPLYOVERALTPAL)) applytint = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Tinting is not used on indexed textures, unless explicitly requested
|
||||
if (h.f & (HICTINT_ALWAYSUSEART | HICTINT_USEONART))
|
||||
if (h.tintFlags & (TINTF_ALWAYSUSEART | TINTF_USEONART))
|
||||
{
|
||||
applytint = true;
|
||||
if (!(h.f & HICTINT_APPLYOVERPALSWAP)) usepalswap = 0;
|
||||
if (!(h.tintFlags & TINTF_APPLYOVERPALSWAP)) usepalswap = 0;
|
||||
}
|
||||
pick.translation = TRANSLATION(usepalette + 1, usepalswap);
|
||||
}
|
||||
pick.texture = tex;
|
||||
if (applytint && h.f)
|
||||
if (applytint && h.tintFlags)
|
||||
{
|
||||
pick.tintFlags = h.f;
|
||||
pick.tintFlags = h.tintFlags;
|
||||
pick.tintColor = h.tint;
|
||||
}
|
||||
return pick;
|
||||
|
@ -149,26 +148,26 @@ bool GLInstance::SetTextureInternal(int picnum, FGameTexture* tex, int paletteid
|
|||
|
||||
GLInterface.SetBasepalTint(0xffffff);
|
||||
|
||||
auto& h = hictinting[palette];
|
||||
auto& h = lookups.tables[palette];
|
||||
bool applytint = false;
|
||||
// Canvas textures must be treated like hightile replacements in the following code.
|
||||
if (picnum < 0) picnum = TileFiles.GetTileIndex(tex); // Allow getting replacements also when the texture is not passed by its tile number.
|
||||
auto rep = (picnum >= 0 && hw_hightile && !(h.f & HICTINT_ALWAYSUSEART)) ? TileFiles.FindReplacement(picnum, palette) : nullptr;
|
||||
auto rep = (picnum >= 0 && hw_hightile && !(h.tintFlags & TINTF_ALWAYSUSEART)) ? TileFiles.FindReplacement(picnum, palette) : 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 = hictinting[MAXPALOOKUPS - 1];
|
||||
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.)
|
||||
GLInterface.SetBasepalTint(hh.tint);
|
||||
GLInterface.SetBasepalTint(hh.tintColor);
|
||||
}
|
||||
|
||||
if (rep)
|
||||
{
|
||||
tex = rep->faces[0];
|
||||
}
|
||||
if (!rep || rep->palnum != palette || (h.f & HICTINT_APPLYOVERALTPAL)) applytint = true;
|
||||
if (!rep || rep->palnum != palette || (h.tintFlags & TINTF_APPLYOVERALTPAL)) applytint = true;
|
||||
TextureType = TT_HICREPLACE;
|
||||
bindflags = CTF_Upscale;
|
||||
}
|
||||
|
@ -178,10 +177,10 @@ bool GLInstance::SetTextureInternal(int picnum, FGameTexture* tex, int paletteid
|
|||
if (TextureType == TT_TRUECOLOR)
|
||||
{
|
||||
// Tinting is not used on indexed textures
|
||||
if (h.f & (HICTINT_ALWAYSUSEART | HICTINT_USEONART))
|
||||
if (h.tintFlags & (TINTF_ALWAYSUSEART | TINTF_USEONART))
|
||||
{
|
||||
applytint = true;
|
||||
if (!(h.f & HICTINT_APPLYOVERPALSWAP)) usepalswap = 0;
|
||||
if (!(h.tintFlags & TINTF_APPLYOVERPALSWAP)) usepalswap = 0;
|
||||
}
|
||||
lookuppal = TRANSLATION(usepalette + Translation_Remap, usepalswap);
|
||||
bindflags = CTF_Upscale;
|
||||
|
@ -190,8 +189,8 @@ bool GLInstance::SetTextureInternal(int picnum, FGameTexture* tex, int paletteid
|
|||
}
|
||||
|
||||
// This is intentionally the same value for both parameters. The shader does not use the same uniform for modulation and overlay colors.
|
||||
if (applytint && h.f)
|
||||
GLInterface.SetTinting(h.f, h.tint, h.tint);
|
||||
if (applytint && h.tintFlags)
|
||||
GLInterface.SetTinting(h.tintFlags, h.tintColor, h.tintColor);
|
||||
else GLInterface.SetTinting(-1, 0xffffff, 0xffffff);
|
||||
|
||||
|
||||
|
|
|
@ -666,28 +666,28 @@ void G_DisplayRest(int32_t smoothratio)
|
|||
// this takes care of fullscreen tint for OpenGL
|
||||
if (videoGetRenderMode() >= REND_POLYMOST)
|
||||
{
|
||||
polytint_t & fstint = hictinting[MAXPALOOKUPS-1];
|
||||
auto & fstint = lookups.tables[MAXPALOOKUPS-1];
|
||||
|
||||
if (pp->palette == WATERPAL)
|
||||
{
|
||||
fstint.tint.r = 224;
|
||||
fstint.tint.g = 192;
|
||||
fstint.tint.b = 255;
|
||||
fstint.f = 0;
|
||||
fstint.tintColor.r = 224;
|
||||
fstint.tintColor.g = 192;
|
||||
fstint.tintColor.b = 255;
|
||||
fstint.tintFlags = 0;
|
||||
}
|
||||
else if (pp->palette == SLIMEPAL)
|
||||
{
|
||||
fstint.tint.r = 208;
|
||||
fstint.tint.g = 255;
|
||||
fstint.tint.b = 192;
|
||||
fstint.f = 0;
|
||||
fstint.tintColor.r = 208;
|
||||
fstint.tintColor.g = 255;
|
||||
fstint.tintColor.b = 192;
|
||||
fstint.tintFlags = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
fstint.tint.r = 255;
|
||||
fstint.tint.g = 255;
|
||||
fstint.tint.b = 255;
|
||||
fstint.f = 0;
|
||||
fstint.tintColor.r = 255;
|
||||
fstint.tintColor.g = 255;
|
||||
fstint.tintColor.b = 255;
|
||||
fstint.tintFlags = 0;
|
||||
}
|
||||
}
|
||||
palaccum_add(&tint, &pp->pals, pp->pals.f);
|
||||
|
|
|
@ -10,13 +10,13 @@ const int RF_ShadeInterpolate = 64;
|
|||
const int RF_FogDisabled = 128;
|
||||
const int RF_MapFog = 256;
|
||||
|
||||
const int RF_HICTINT_Grayscale = 0x1;
|
||||
const int RF_HICTINT_Invert = 0x2;
|
||||
const int RF_HICTINT_Colorize = 0x4;
|
||||
const int RF_HICTINT_BLEND_Screen = 64;
|
||||
const int RF_HICTINT_BLEND_Overlay = 128;
|
||||
const int RF_HICTINT_BLEND_Hardlight = 192;
|
||||
const int RF_HICTINT_BLENDMASK = RF_HICTINT_BLEND_Screen | RF_HICTINT_BLEND_Overlay | RF_HICTINT_BLEND_Hardlight;
|
||||
const int RF_TINT_Grayscale = 0x1;
|
||||
const int RF_TINT_Invert = 0x2;
|
||||
const int RF_TINT_Colorize = 0x4;
|
||||
const int RF_TINT_BLEND_Screen = 64;
|
||||
const int RF_TINT_BLEND_Overlay = 128;
|
||||
const int RF_TINT_BLEND_Hardlight = 192;
|
||||
const int RF_TINT_BLENDMASK = RF_TINT_BLEND_Screen | RF_TINT_BLEND_Overlay | RF_TINT_BLEND_Hardlight;
|
||||
|
||||
|
||||
//s_texture points to an indexed color texture
|
||||
|
@ -89,13 +89,13 @@ float grayscale(vec4 color)
|
|||
vec4 convertColor(vec4 color)
|
||||
{
|
||||
int effect = u_tintFlags;
|
||||
if ((effect & RF_HICTINT_Grayscale) != 0)
|
||||
if ((effect & RF_TINT_Grayscale) != 0)
|
||||
{
|
||||
float g = grayscale(color);
|
||||
color = vec4(g, g, g, color.a);
|
||||
}
|
||||
|
||||
if ((effect & RF_HICTINT_Invert) != 0)
|
||||
if ((effect & RF_TINT_Invert) != 0)
|
||||
{
|
||||
color = vec4(1.0 - color.r, 1.0 - color.g, 1.0 - color.b, color.a);
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ vec4 convertColor(vec4 color)
|
|||
vec3 tcol = color.rgb * 255.0; // * 255.0 to make it easier to reuse the integer math.
|
||||
|
||||
// Much of this looks quite broken by design. Why is this effectively multplied by 4 if the flag is set...? :(
|
||||
if ((effect & RF_HICTINT_Colorize) != 0)
|
||||
if ((effect & RF_TINT_Colorize) != 0)
|
||||
{
|
||||
tcol.r = min(((tcol.b) * u_tintModulate.r)* 4, 255.0);
|
||||
tcol.g = min(((tcol.g) * u_tintModulate.g)* 4, 255.0);
|
||||
|
@ -117,19 +117,19 @@ vec4 convertColor(vec4 color)
|
|||
}
|
||||
|
||||
vec4 ov = u_tintOverlay * 255.0;
|
||||
switch (effect & RF_HICTINT_BLENDMASK)
|
||||
switch (effect & RF_TINT_BLENDMASK)
|
||||
{
|
||||
case RF_HICTINT_BLEND_Screen:
|
||||
case RF_TINT_BLEND_Screen:
|
||||
tcol.r = 255.0 - (((255.0 - tcol.r) * (255.0 - ov.r)) / 256.0);
|
||||
tcol.g = 255.0 - (((255.0 - tcol.g) * (255.0 - ov.g)) / 256.0);
|
||||
tcol.b = 255.0 - (((255.0 - tcol.b) * (255.0 - ov.b)) / 256.0);
|
||||
break;
|
||||
case RF_HICTINT_BLEND_Overlay:
|
||||
case RF_TINT_BLEND_Overlay:
|
||||
tcol.r = tcol.b < 128.0? (tcol.r * ov.r) / 128.0 : 255.0 - (((255.0 - tcol.r) * (255.0 - ov.r)) / 128.0);
|
||||
tcol.g = tcol.g < 128.0? (tcol.g * ov.g) / 128.0 : 255.0 - (((255.0 - tcol.g) * (255.0 - ov.g)) / 128.0);
|
||||
tcol.b = tcol.r < 128.0? (tcol.b * ov.b) / 128.0 : 255.0 - (((255.0 - tcol.b) * (255.0 - ov.b)) / 128.0);
|
||||
break;
|
||||
case RF_HICTINT_BLEND_Hardlight:
|
||||
case RF_TINT_BLEND_Hardlight:
|
||||
tcol.r = ov.r < 128.0 ? (tcol.r * ov.r) / 128.0 : 255.0 - (((255.0 - tcol.r) * (255.0 - ov.r)) / 128.0);
|
||||
tcol.g = ov.g < 128.0 ? (tcol.g * ov.g) / 128.0 : 255.0 - (((255.0 - tcol.g) * (255.0 - ov.g)) / 128.0);
|
||||
tcol.b = ov.b < 128.0 ? (tcol.b * ov.b) / 128.0 : 255.0 - (((255.0 - tcol.b) * (255.0 - ov.b)) / 128.0);
|
||||
|
|
Loading…
Reference in a new issue