New def tokens for "tint": "shadered" or "sr", "shadeblue" or "sb", "shadegreen" or "sg"

tint { pal <pal> shadered <0-255> shadegreen <0-255> shadeblue <0-255> }

Make shade apply a tint based on the RGB.
Default values for shade are zero (black).

Patch from Fox.

git-svn-id: https://svn.eduke32.com/eduke32@6557 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2017-12-12 05:13:58 +00:00
parent 756fa2bbd8
commit ae47d2f11d
6 changed files with 50 additions and 27 deletions

View file

@ -1325,7 +1325,7 @@ extern int32_t glrendmode;
#endif #endif
void hicinit(void); void hicinit(void);
void hicsetpalettetint(int32_t palnum, char r, char g, char b, polytintflags_t effect); void hicsetpalettetint(int32_t palnum, char r, char g, char b, char sr, char sg, char sb, polytintflags_t effect);
// flags bitset: 1 = don't compress // flags bitset: 1 = don't compress
int32_t hicsetsubsttex(int32_t picnum, int32_t palnum, const char *filen, float alphacut, int32_t hicsetsubsttex(int32_t picnum, int32_t palnum, const char *filen, float alphacut,
float xscale, float yscale, float specpower, float specfactor, char flags); float xscale, float yscale, float specpower, float specfactor, char flags);

View file

@ -21,6 +21,7 @@ typedef struct hicreplc_t {
typedef struct { typedef struct {
polytintflags_t f; polytintflags_t f;
uint8_t r, g, b; uint8_t r, g, b;
uint8_t sr, sg, sb;
} polytint_t; } polytint_t;
extern polytint_t hictinting[MAXPALOOKUPS]; extern polytint_t hictinting[MAXPALOOKUPS];

View file

@ -384,17 +384,18 @@ static int32_t osdfunc_setrendermode(osdfuncparm_t const * const parm)
#ifdef DEBUGGINGAIDS #ifdef DEBUGGINGAIDS
static int32_t osdcmd_hicsetpalettetint(osdfuncparm_t const * const parm) static int32_t osdcmd_hicsetpalettetint(osdfuncparm_t const * const parm)
{ {
int32_t pal, cols[3], eff; int32_t parms[8];
if (parm->numparms != 5) return OSDCMD_SHOWHELP; if (parm->numparms < 1 || (int32_t)ARRAY_SIZE(parms) < parm->numparms) return OSDCMD_SHOWHELP;
pal = Batol(parm->parms[0]); size_t i;
cols[0] = Batol(parm->parms[1]); for (i = 0; (int32_t)i < parm->numparms; ++i)
cols[1] = Batol(parm->parms[2]); parms[i] = Batol(parm->parms[i]);
cols[2] = Batol(parm->parms[3]); for (; i < ARRAY_SIZE(parms); ++i)
eff = Batol(parm->parms[4]); parms[i] = 0;
hicsetpalettetint(pal,cols[0],cols[1],cols[2],eff); // order is intentional
hicsetpalettetint(parms[0],parms[1],parms[2],parms[3],parms[5],parms[6],parms[7],parms[4]);
return OSDCMD_OK; return OSDCMD_OK;
} }

View file

@ -117,6 +117,7 @@ enum scripttoken_t
T_SRC_ALPHA, T_ONE_MINUS_SRC_ALPHA, T_SRC_ALPHA, T_ONE_MINUS_SRC_ALPHA,
T_DST_ALPHA, T_ONE_MINUS_DST_ALPHA, T_DST_ALPHA, T_ONE_MINUS_DST_ALPHA,
T_DST_COLOR, T_ONE_MINUS_DST_COLOR, T_DST_COLOR, T_ONE_MINUS_DST_COLOR,
T_SHADERED, T_SHADEGREEN, T_SHADEBLUE,
}; };
static int32_t lastmodelid = -1, lastvoxid = -1, modelskin = -1, lastmodelskin = -1, seenframe = 0; static int32_t lastmodelid = -1, lastvoxid = -1, modelskin = -1, lastmodelskin = -1, seenframe = 0;
@ -495,15 +496,18 @@ static int32_t defsparser(scriptfile *script)
break; break;
case T_DEFINETINT: case T_DEFINETINT:
{ {
int32_t pal, r,g,b,f; int32_t pal, r,g,b,sr,sg,sb,f;
if (scriptfile_getsymbol(script,&pal)) break; if (scriptfile_getsymbol(script,&pal)) break;
if (scriptfile_getnumber(script,&r)) break; if (scriptfile_getnumber(script,&r)) break;
if (scriptfile_getnumber(script,&g)) break; if (scriptfile_getnumber(script,&g)) break;
if (scriptfile_getnumber(script,&b)) break; if (scriptfile_getnumber(script,&b)) break;
if (scriptfile_getnumber(script,&sr)) break;
if (scriptfile_getnumber(script,&sg)) break;
if (scriptfile_getnumber(script,&sb)) break;
if (scriptfile_getnumber(script,&f)) break; //effects if (scriptfile_getnumber(script,&f)) break; //effects
#ifdef USE_OPENGL #ifdef USE_OPENGL
hicsetpalettetint(pal,r,g,b,f); hicsetpalettetint(pal,r,g,b,sr,sg,sb,f);
#endif #endif
} }
break; break;
@ -2047,16 +2051,19 @@ static int32_t defsparser(scriptfile *script)
case T_TINT: case T_TINT:
{ {
char *tinttokptr = script->ltextptr; char *tinttokptr = script->ltextptr;
int32_t red=255, green=255, blue=255, pal=-1, flags=0; int32_t red=255, green=255, blue=255, shadered=0, shadegreen=0, shadeblue=0, pal=-1, flags=0;
char *tintend; char *tintend;
static const tokenlist tinttokens[] = static const tokenlist tinttokens[] =
{ {
{ "pal", T_PAL }, { "pal", T_PAL },
{ "red", T_RED },{ "r", T_RED }, { "red", T_RED },{ "r", T_RED },
{ "green", T_GREEN },{ "g", T_GREEN }, { "green", T_GREEN },{ "g", T_GREEN },
{ "blue", T_BLUE },{ "b", T_BLUE }, { "blue", T_BLUE },{ "b", T_BLUE },
{ "flags", T_FLAGS } { "shadered", T_SHADERED },{ "sr", T_SHADERED },
{ "shadegreen", T_SHADEGREEN },{ "sg", T_SHADEGREEN },
{ "shadeblue", T_SHADEBLUE },{ "sb", T_SHADEBLUE },
{ "flags", T_FLAGS }
}; };
if (scriptfile_getbraces(script,&tintend)) break; if (scriptfile_getbraces(script,&tintend)) break;
@ -2065,15 +2072,21 @@ static int32_t defsparser(scriptfile *script)
switch (getatoken(script,tinttokens,ARRAY_SIZE(tinttokens))) switch (getatoken(script,tinttokens,ARRAY_SIZE(tinttokens)))
{ {
case T_PAL: case T_PAL:
scriptfile_getsymbol(script,&pal); break; scriptfile_getsymbol(script,&pal); break;
case T_RED: case T_RED:
scriptfile_getnumber(script,&red); red = min(255,max(0,red)); break; scriptfile_getnumber(script,&red); red = min(255,max(0,red)); break;
case T_GREEN: case T_GREEN:
scriptfile_getnumber(script,&green); green = min(255,max(0,green)); break; scriptfile_getnumber(script,&green); green = min(255,max(0,green)); break;
case T_BLUE: case T_BLUE:
scriptfile_getnumber(script,&blue); blue = min(255,max(0,blue)); break; scriptfile_getnumber(script,&blue); blue = min(255,max(0,blue)); break;
case T_SHADERED:
scriptfile_getnumber(script,&shadered); shadered = min(255,max(0,shadered)); break;
case T_SHADEGREEN:
scriptfile_getnumber(script,&shadegreen); shadegreen = min(255,max(0,shadegreen)); break;
case T_SHADEBLUE:
scriptfile_getnumber(script,&shadeblue); shadeblue = min(255,max(0,shadeblue)); break;
case T_FLAGS: case T_FLAGS:
scriptfile_getsymbol(script,&flags); break; scriptfile_getsymbol(script,&flags); break;
} }
} }
@ -2085,7 +2098,7 @@ static int32_t defsparser(scriptfile *script)
} }
#ifdef USE_OPENGL #ifdef USE_OPENGL
hicsetpalettetint(pal,red,green,blue,flags); hicsetpalettetint(pal,red,green,blue,shadered,shadegreen,shadeblue,flags);
#endif #endif
} }
break; break;

View file

@ -115,12 +115,12 @@ void hicinit(void)
// //
// hicsetpalettetint(pal,r,g,b,effect) // hicsetpalettetint(pal,r,g,b,sr,sg,sb,effect)
// The tinting values represent a mechanism for emulating the effect of global sector // The tinting values represent a mechanism for emulating the effect of global sector
// palette shifts on true-colour textures and only true-colour textures. // palette shifts on true-colour textures and only true-colour textures.
// effect bitset: 1 = greyscale, 2 = invert // effect bitset: 1 = greyscale, 2 = invert
// //
void hicsetpalettetint(int32_t palnum, char r, char g, char b, polytintflags_t effect) void hicsetpalettetint(int32_t palnum, char r, char g, char b, char sr, char sg, char sb, polytintflags_t effect)
{ {
if ((uint32_t)palnum >= (uint32_t)MAXPALOOKUPS) return; if ((uint32_t)palnum >= (uint32_t)MAXPALOOKUPS) return;
if (!hicinitcounter) hicinit(); if (!hicinitcounter) hicinit();
@ -129,6 +129,9 @@ void hicsetpalettetint(int32_t palnum, char r, char g, char b, polytintflags_t e
tint.r = r; tint.r = r;
tint.g = g; tint.g = g;
tint.b = b; tint.b = b;
tint.sr = sr;
tint.sg = sg;
tint.sb = sb;
tint.f = effect; tint.f = effect;
} }
@ -285,7 +288,7 @@ int32_t hicclearsubst(int32_t picnum, int32_t palnum)
#include "compat.h" #include "compat.h"
void hicsetpalettetint(int32_t palnum, char r, char g, char b, polytintflags_t effect) void hicsetpalettetint(int32_t palnum, char r, char g, char b, char sr, char sg, char sb, polytintflags_t effect)
{ {
UNREFERENCED_PARAMETER(palnum); UNREFERENCED_PARAMETER(palnum);
UNREFERENCED_PARAMETER(r); UNREFERENCED_PARAMETER(r);

View file

@ -1892,7 +1892,12 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32
pc[0] = pc[1] = pc[2] = 1.0f; pc[0] = pc[1] = pc[2] = 1.0f;
else else
#endif #endif
pc[0] = pc[1] = pc[2] = getshadefactor(globalshade); {
polytint_t const & tint = hictinting[globalpal];
pc[0] = (1.f-(tint.sr*(1.f/255.f)))*getshadefactor(globalshade)+(tint.sr*(1.f/255.f));
pc[1] = (1.f-(tint.sg*(1.f/255.f)))*getshadefactor(globalshade)+(tint.sg*(1.f/255.f));
pc[2] = (1.f-(tint.sb*(1.f/255.f)))*getshadefactor(globalshade)+(tint.sb*(1.f/255.f));
}
// spriteext full alpha control // spriteext full alpha control
pc[3] = float_trans(method & DAMETH_MASKPROPS, drawpoly_blend) * (1.f - drawpoly_alpha); pc[3] = float_trans(method & DAMETH_MASKPROPS, drawpoly_blend) * (1.f - drawpoly_alpha);