mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 08:52:00 +00:00
Tints: Add blending modes Screen, Overlay, and Hard Light, as opposed to the default Multiply. This value is encoded in bits 6 and 7 of the "flags" parameter. In other words, calculate your flags besides these modes, then bitwise OR the resulting value with:
0 - Multiply 64 - Screen 128 - Overlay 192 - Hard Light Note: These will likely look terrible when combined with the Colorize flag, because of the nature of the Colorize flag. git-svn-id: https://svn.eduke32.com/eduke32@5146 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
09a26dc24f
commit
40d6aef7fc
4 changed files with 70 additions and 4 deletions
|
@ -90,7 +90,16 @@ enum
|
|||
HICTINT_APPLYOVERPALSWAP = 16,
|
||||
HICTINT_APPLYOVERALTPAL = 32,
|
||||
|
||||
HICEFFECTMASK = (1|2|4|8|16|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_PRECOMPUTED = HICTINT_COLORIZE | HICTINT_BLENDMASK,
|
||||
|
||||
HICEFFECTMASK = 255, // XXX: Xcalloc() based on this value, why?
|
||||
};
|
||||
|
||||
#define GRAYSCALE_COEFF_RED 0.3
|
||||
|
|
|
@ -654,6 +654,25 @@ static int32_t daskinloader(int32_t filh, intptr_t *fptr, int32_t *bpl, int32_t
|
|||
tcol.r = min((int32_t)(tcol.r)*r/64,255);
|
||||
}
|
||||
|
||||
switch (effect & HICTINT_BLENDMASK)
|
||||
{
|
||||
case HICTINT_BLEND_SCREEN:
|
||||
tcol.b = 255 - (((255 - tcol.b) * (255 - b)) >> 8);
|
||||
tcol.g = 255 - (((255 - tcol.g) * (255 - g)) >> 8);
|
||||
tcol.r = 255 - (((255 - tcol.r) * (255 - r)) >> 8);
|
||||
break;
|
||||
case HICTINT_BLEND_OVERLAY:
|
||||
tcol.b = tcol.b < 128 ? (tcol.b * b) >> 7 : 255 - (((255 - tcol.b) * (255 - b)) >> 7);
|
||||
tcol.g = tcol.g < 128 ? (tcol.g * g) >> 7 : 255 - (((255 - tcol.g) * (255 - g)) >> 7);
|
||||
tcol.r = tcol.r < 128 ? (tcol.r * r) >> 7 : 255 - (((255 - tcol.r) * (255 - r)) >> 7);
|
||||
break;
|
||||
case HICTINT_BLEND_HARDLIGHT:
|
||||
tcol.b = b < 128 ? (tcol.b * b) >> 7 : 255 - (((255 - tcol.b) * (255 - b)) >> 7);
|
||||
tcol.g = g < 128 ? (tcol.g * g) >> 7 : 255 - (((255 - tcol.g) * (255 - g)) >> 7);
|
||||
tcol.r = r < 128 ? (tcol.r * r) >> 7 : 255 - (((255 - tcol.r) * (255 - r)) >> 7);
|
||||
break;
|
||||
}
|
||||
|
||||
rpptr[x].b = tcol.b;
|
||||
rpptr[x].g = tcol.g;
|
||||
rpptr[x].r = tcol.r;
|
||||
|
@ -2101,7 +2120,7 @@ static int32_t polymost_md3draw(md3model_t *m, const tspritetype *tspr)
|
|||
bglEnable(GL_TEXTURE_2D);
|
||||
|
||||
pc[0] = pc[1] = pc[2] = ((float)(numshades-min(max((globalshade * shadescale)+m->shadeoff,0),numshades)))/((float)numshades);
|
||||
if (!(hictinting[globalpal].f & HICTINT_COLORIZE))
|
||||
if (!(hictinting[globalpal].f & HICTINT_PRECOMPUTED))
|
||||
{
|
||||
if (!(m->flags&1))
|
||||
{
|
||||
|
|
|
@ -4188,7 +4188,7 @@ static void polymer_drawmdsprite(tspritetype *tspr)
|
|||
|
||||
// If that palette has a highpalookup, we'll never use tinting. We might use
|
||||
// alternate skins if they exist later, though.
|
||||
if (!usinghighpal && !(hictinting[tspr->pal].f & HICTINT_COLORIZE))
|
||||
if (!usinghighpal && !(hictinting[tspr->pal].f & HICTINT_PRECOMPUTED))
|
||||
{
|
||||
if (!(m->flags&1))
|
||||
hictinting_apply_ub(color, tspr->pal);
|
||||
|
|
|
@ -912,6 +912,25 @@ void gloadtile_art(int32_t dapic, int32_t dapal, int32_t tintpalnum, int32_t das
|
|||
wpptr->g = min((int32_t)((wpptr->g) * g) >> 6, 255);
|
||||
wpptr->r = min((int32_t)((wpptr->r) * r) >> 6, 255);
|
||||
}
|
||||
|
||||
switch (effect & HICTINT_BLENDMASK)
|
||||
{
|
||||
case HICTINT_BLEND_SCREEN:
|
||||
wpptr->b = 255 - (((255 - wpptr->b) * (255 - b)) >> 8);
|
||||
wpptr->g = 255 - (((255 - wpptr->g) * (255 - g)) >> 8);
|
||||
wpptr->r = 255 - (((255 - wpptr->r) * (255 - r)) >> 8);
|
||||
break;
|
||||
case HICTINT_BLEND_OVERLAY:
|
||||
wpptr->b = wpptr->b < 128 ? (wpptr->b * b) >> 7 : 255 - (((255 - wpptr->b) * (255 - b)) >> 7);
|
||||
wpptr->g = wpptr->g < 128 ? (wpptr->g * g) >> 7 : 255 - (((255 - wpptr->g) * (255 - g)) >> 7);
|
||||
wpptr->r = wpptr->r < 128 ? (wpptr->r * r) >> 7 : 255 - (((255 - wpptr->r) * (255 - r)) >> 7);
|
||||
break;
|
||||
case HICTINT_BLEND_HARDLIGHT:
|
||||
wpptr->b = b < 128 ? (wpptr->b * b) >> 7 : 255 - (((255 - wpptr->b) * (255 - b)) >> 7);
|
||||
wpptr->g = g < 128 ? (wpptr->g * g) >> 7 : 255 - (((255 - wpptr->g) * (255 - g)) >> 7);
|
||||
wpptr->r = r < 128 ? (wpptr->r * r) >> 7 : 255 - (((255 - wpptr->r) * (255 - r)) >> 7);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1136,6 +1155,25 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp
|
|||
tcol.r = min((int32_t)((tcol.r) * b) >> 6, 255);
|
||||
}
|
||||
|
||||
switch (effect & HICTINT_BLENDMASK)
|
||||
{
|
||||
case HICTINT_BLEND_SCREEN:
|
||||
tcol.b = 255 - (((255 - tcol.b) * (255 - r)) >> 8);
|
||||
tcol.g = 255 - (((255 - tcol.g) * (255 - g)) >> 8);
|
||||
tcol.r = 255 - (((255 - tcol.r) * (255 - b)) >> 8);
|
||||
break;
|
||||
case HICTINT_BLEND_OVERLAY:
|
||||
tcol.b = tcol.b < 128 ? (tcol.b * r) >> 7 : 255 - (((255 - tcol.b) * (255 - r)) >> 7);
|
||||
tcol.g = tcol.g < 128 ? (tcol.g * g) >> 7 : 255 - (((255 - tcol.g) * (255 - g)) >> 7);
|
||||
tcol.r = tcol.r < 128 ? (tcol.r * b) >> 7 : 255 - (((255 - tcol.r) * (255 - b)) >> 7);
|
||||
break;
|
||||
case HICTINT_BLEND_HARDLIGHT:
|
||||
tcol.b = r < 128 ? (tcol.b * r) >> 7 : 255 - (((255 - tcol.b) * (255 - r)) >> 7);
|
||||
tcol.g = g < 128 ? (tcol.g * g) >> 7 : 255 - (((255 - tcol.g) * (255 - g)) >> 7);
|
||||
tcol.r = b < 128 ? (tcol.r * b) >> 7 : 255 - (((255 - tcol.r) * (255 - b)) >> 7);
|
||||
break;
|
||||
}
|
||||
|
||||
rpptr[x] = tcol;
|
||||
}
|
||||
}
|
||||
|
@ -1526,7 +1564,7 @@ static void drawpoly(vec2f_t const * const dpxy, int32_t const n, int32_t method
|
|||
// tinting happens only to hightile textures, and only if the texture we're
|
||||
// rendering isn't for the same palette as what we asked for
|
||||
|
||||
if (!(hictinting[globalpal].f & HICTINT_COLORIZE))
|
||||
if (!(hictinting[globalpal].f & HICTINT_PRECOMPUTED))
|
||||
{
|
||||
if (pth && (pth->flags & PTH_HIGHTILE))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue