Image in sprite part 2

This commit is contained in:
Lactozilla 2023-11-02 20:24:40 -03:00
parent dff710c9bc
commit b98f77bcdb
10 changed files with 231 additions and 202 deletions

View file

@ -59,37 +59,27 @@ INT16 *hicolormaps; // test a 32k colormap remaps high -> high
UINT32 ASTBlendPixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alpha)
{
RGBA_t output;
INT16 fullalpha = (alpha - (0xFF - foreground.s.alpha));
#define clamp(c) max(min((c), 0xFF), 0x00)
INT16 fullalpha = clamp(((INT16)foreground.s.alpha) - (0xFF - alpha));
if (style == AST_TRANSLUCENT)
{
if (fullalpha <= 0)
output.rgba = background.rgba;
else
{
if (fullalpha >= 0xFF)
fullalpha = 0xFF;
alpha = (UINT8)fullalpha;
UINT8 beta = 0xFF - alpha;
output.s.red = ((background.s.red * beta) + (foreground.s.red * alpha)) / 0xFF;
output.s.green = ((background.s.green * beta) + (foreground.s.green * alpha)) / 0xFF;
output.s.blue = ((background.s.blue * beta) + (foreground.s.blue * alpha)) / 0xFF;
output.s.alpha = clamp(((INT16)background.s.alpha) + fullalpha);
}
UINT8 beta = 0xFF - fullalpha;
output.s.red = ((background.s.red * beta) + (foreground.s.red * fullalpha)) / 0xFF;
output.s.green = ((background.s.green * beta) + (foreground.s.green * fullalpha)) / 0xFF;
output.s.blue = ((background.s.blue * beta) + (foreground.s.blue * fullalpha)) / 0xFF;
output.s.alpha = clamp(((INT16)background.s.alpha) + fullalpha);
}
else
{
float falpha = ((float)alpha / 255.0f);
float falpha = ((float)fullalpha / 255.0f);
float fr = ((float)foreground.s.red * falpha);
float fg = ((float)foreground.s.green * falpha);
float fb = ((float)foreground.s.blue * falpha);
if (background.s.alpha == 0x00)
output.s.alpha = clamp(fullalpha);
else
output.s.alpha = 0xFF;
output.s.alpha = clamp(((INT16)background.s.alpha) + fullalpha);
if (style == AST_ADD)
{
@ -119,8 +109,17 @@ UINT32 ASTBlendPixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alph
output.s.blue = clamp((int)(background.s.blue * fb));
}
// just copy the pixel
else if (style == AST_COPY)
output.rgba = foreground.rgba;
else
{
if (foreground.s.alpha == 0x00)
output.rgba = background.rgba;
else
{
if (foreground.s.alpha != 0x00)
foreground.s.alpha = 0xFF;
output.rgba = foreground.rgba;
}
}
}
#undef clamp
return output.rgba;

View file

@ -66,8 +66,6 @@ lighttable_t *dc_colormap;
INT32 dc_x = 0, dc_yl = 0, dc_yh = 0;
fixed_t dc_iscale, dc_texturemid;
UINT8 dc_hires; // under MSVC boolean is a byte, while on other systems, it a bit,
// soo lets make it a byte on all system for the ASM code
UINT8 *dc_source;
// -----------------------
@ -81,6 +79,8 @@ UINT8 *blendtables[NUMBLENDMAPS];
/** \brief R_DrawTransColumn uses this
*/
UINT8 *dc_transmap; // one of the translucency tables
UINT8 dc_opacity;
UINT8 dc_blendmode;
// ----------------------
// translation stuff here
@ -380,6 +380,17 @@ boolean R_BlendLevelVisible(INT32 blendmode, INT32 alphalevel)
return (alphalevel < BlendTab_Count[BlendTab_FromStyle[blendmode]]);
}
UINT8 R_GetOpacityFromAlphaLevel(INT32 alphalevel)
{
int alpha = (int)((float)(9 - alphalevel) * (255 / 9.0));
if (alpha < 0)
return 0;
else if (alpha > 255)
return 255;
else
return (UINT8)alpha;
}
// Define for getting accurate color brightness readings according to how the human eye sees them.
// https://en.wikipedia.org/wiki/Relative_luminance
// 0.2126 to red

View file

@ -32,15 +32,15 @@ extern UINT8 *topleft;
extern lighttable_t *dc_colormap;
extern INT32 dc_x, dc_yl, dc_yh;
extern fixed_t dc_iscale, dc_texturemid;
extern UINT8 dc_hires;
extern UINT8 *dc_source; // first pixel in a column
// translucency stuff here
extern UINT8 *dc_transmap;
extern UINT8 dc_opacity;
extern UINT8 dc_blendmode;
// translation stuff here
extern UINT8 *dc_translation;
extern struct r_lightlist_s *dc_lightlist;
@ -62,6 +62,7 @@ extern INT32 ds_waterofs, ds_bgofs;
extern UINT16 ds_flatwidth, ds_flatheight;
extern boolean ds_powersoftwo, ds_solidcolor;
extern UINT32 ds_fillcolor;
extern UINT8 *ds_source;
extern UINT8 *ds_transmap;
@ -146,6 +147,8 @@ UINT8 *R_GetBlendTable(int style, INT32 alphalevel);
boolean R_BlendLevelVisible(INT32 blendmode, INT32 alphalevel);
UINT8 R_GetOpacityFromAlphaLevel(INT32 alphalevel);
// Color ramp modification should force a recache
extern UINT8 skincolor_modified[];

View file

@ -51,7 +51,7 @@ void R_DrawColumn_8(void)
// Determine scaling, which is the only mapping to be done.
fracstep = dc_iscale;
//frac = dc_texturemid + (dc_yl - centery)*fracstep;
frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires);
frac = dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep);
// Inner loop that does the actual texture mapping, e.g. a DDA-like scaling.
// This is as fast as it gets.
@ -134,7 +134,7 @@ void R_Draw2sMultiPatchColumn_8(void)
// Determine scaling, which is the only mapping to be done.
fracstep = dc_iscale;
//frac = dc_texturemid + (dc_yl - centery)*fracstep;
frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires);
frac = dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep);
// Inner loop that does the actual texture mapping, e.g. a DDA-like scaling.
// This is as fast as it gets.
@ -230,7 +230,7 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void)
// Determine scaling, which is the only mapping to be done.
fracstep = dc_iscale;
//frac = dc_texturemid + (dc_yl - centery)*fracstep;
frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires);
frac = dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep);
// Inner loop that does the actual texture mapping, e.g. a DDA-like scaling.
// This is as fast as it gets.
@ -327,7 +327,7 @@ void R_DrawShadeColumn_8(void)
// Looks familiar.
fracstep = dc_iscale;
//frac = dc_texturemid + (dc_yl - centery)*fracstep;
frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires);
frac = dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep);
// Here we do an additional index re-mapping.
do
@ -366,7 +366,7 @@ void R_DrawTranslucentColumn_8(void)
// Looks familiar.
fracstep = dc_iscale;
//frac = dc_texturemid + (dc_yl - centery)*fracstep;
frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires);
frac = dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep);
// Inner loop that does the actual texture mapping, e.g. a DDA-like scaling.
// This is as fast as it gets.
@ -471,7 +471,7 @@ void R_DrawTranslatedTranslucentColumn_8(void)
// Looks familiar.
fracstep = dc_iscale;
//frac = dc_texturemid + (dc_yl - centery)*fracstep;
frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires);
frac = dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep);
// Inner loop that does the actual texture mapping, e.g. a DDA-like scaling.
// This is as fast as it gets.
@ -547,7 +547,7 @@ void R_DrawTranslatedColumn_8(void)
// Looks familiar.
fracstep = dc_iscale;
//frac = dc_texturemid + (dc_yl-centery)*fracstep;
frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires);
frac = dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep);
// Here we do an additional index re-mapping.
do

View file

@ -22,13 +22,7 @@
void R_DrawColumn_8_RGBA(void)
{
INT32 count;
register UINT8 *dest;
register fixed_t frac;
fixed_t fracstep;
count = dc_yh - dc_yl;
INT32 count = dc_yh - dc_yl;
if (count < 0) // Zero length, column does not exceed a pixel.
return;
@ -37,27 +31,29 @@ INT32 count;
return;
#endif
// Framebuffer destination address.
// Use ylookup LUT to avoid multiply with ScreenWidth.
// Use columnofs LUT for subwindows?
//dest = ylookup[dc_yl] + columnofs[dc_x];
dest = &topleft[dc_yl*vid.width + dc_x];
UINT8 *dest = &topleft[dc_yl*vid.width + dc_x];
count++;
// Determine scaling, which is the only mapping to be done.
fracstep = dc_iscale;
//frac = dc_texturemid + (dc_yl - centery)*fracstep;
frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires);
fixed_t fracstep = dc_iscale;
fixed_t frac = dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep);
// Inner loop that does the actual texture mapping, e.g. a DDA-like scaling.
// This is as fast as it gets.
{
register const RGBA_t *source = (RGBA_t *)dc_source;
register const lighttable_t *colormap = dc_colormap;
register INT32 heightmask = dc_texheight-1;
RGBA_t color;
const RGBA_t *source = (RGBA_t *)dc_source;
const lighttable_t *colormap = dc_colormap;
INT32 heightmask = dc_texheight-1;
RGBA_t ocolor, color;
UINT8 idx;
#define GET_COLOR(f) \
ocolor = source[f]; \
idx = colormap[GetColorLUT(&r_colorlookup, ocolor.s.red, ocolor.s.green, ocolor.s.blue)]; \
color = pMasterPalette[idx]
if (dc_texheight & heightmask) // not a power of 2 -- killough
{
heightmask++;
@ -74,7 +70,7 @@ INT32 count;
// Re-map color indices from wall texture column
// using a lighting/special effects LUT.
// heightmask is the Tutti-Frutti fix
color = source[frac>>FRACBITS];
GET_COLOR(frac>>FRACBITS);
*dest = colormap[GetColorLUT(&r_colorlookup, color.s.red, color.s.green, color.s.blue)];
dest += vid.width;
@ -92,33 +88,39 @@ INT32 count;
{
while ((count -= 2) >= 0) // texture height is a power of 2
{
color = source[(frac>>FRACBITS) & heightmask];
GET_COLOR((frac>>FRACBITS) & heightmask);
*dest = colormap[GetColorLUT(&r_colorlookup, color.s.red, color.s.green, color.s.blue)];
dest += vid.width;
frac += fracstep;
color = source[(frac>>FRACBITS) & heightmask];
GET_COLOR((frac>>FRACBITS) & heightmask);
*dest = colormap[GetColorLUT(&r_colorlookup, color.s.red, color.s.green, color.s.blue)];
dest += vid.width;
frac += fracstep;
}
if (count & 1)
{
color = source[(frac>>FRACBITS) & heightmask];
GET_COLOR((frac>>FRACBITS) & heightmask);
*dest = colormap[GetColorLUT(&r_colorlookup, color.s.red, color.s.green, color.s.blue)];
}
}
#undef GET_COLOR
}
}
static UINT32 BlendPixel(RGBA_t background, RGBA_t foreground)
{
UINT8 beta = 0xFF - foreground.s.alpha;
RGBA_t output;
output.s.red = ((background.s.red * beta) + (foreground.s.red * foreground.s.alpha)) / 0xFF;
output.s.green = ((background.s.green * beta) + (foreground.s.green * foreground.s.alpha)) / 0xFF;
output.s.blue = ((background.s.blue * beta) + (foreground.s.blue * foreground.s.alpha)) / 0xFF;
return output.rgba;
}
void R_DrawBlendedColumn_8_RGBA(void)
{
INT32 count;
register UINT8 *dest;
register fixed_t frac;
fixed_t fracstep;
count = dc_yh - dc_yl;
INT32 count = dc_yh - dc_yl;
if (count < 0) // Zero length, column does not exceed a pixel.
return;
@ -127,27 +129,31 @@ INT32 count;
return;
#endif
// Framebuffer destination address.
// Use ylookup LUT to avoid multiply with ScreenWidth.
// Use columnofs LUT for subwindows?
//dest = ylookup[dc_yl] + columnofs[dc_x];
dest = &topleft[dc_yl*vid.width + dc_x];
UINT8 *dest = &topleft[dc_yl*vid.width + dc_x];
count++;
// Determine scaling, which is the only mapping to be done.
fracstep = dc_iscale;
//frac = dc_texturemid + (dc_yl - centery)*fracstep;
frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires);
fixed_t fracstep = dc_iscale;
fixed_t frac = dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep);
// Inner loop that does the actual texture mapping, e.g. a DDA-like scaling.
// This is as fast as it gets.
{
register const RGBA_t *source = (RGBA_t *)dc_source;
register const lighttable_t *colormap = dc_colormap;
register INT32 heightmask = dc_texheight-1;
RGBA_t color;
const RGBA_t *source = (RGBA_t *)dc_source;
const lighttable_t *colormap = dc_colormap;
INT32 heightmask = dc_texheight-1;
RGBA_t ocolor, color;
UINT8 idx;
#define GET_COLOR(f) \
ocolor = source[f]; \
idx = colormap[GetColorLUT(&r_colorlookup, ocolor.s.red, ocolor.s.green, ocolor.s.blue)]; \
color = pMasterPalette[idx]; \
color.s.alpha = ocolor.s.alpha; \
color.rgba = BlendPixel(pMasterPalette[*dest], color)
if (dc_texheight & heightmask) // not a power of 2 -- killough
{
heightmask++;
@ -164,8 +170,8 @@ INT32 count;
// Re-map color indices from wall texture column
// using a lighting/special effects LUT.
// heightmask is the Tutti-Frutti fix
color.rgba = ASTBlendPixel(pMasterPalette[*dest], source[frac>>FRACBITS], AST_TRANSLUCENT, 255);
*dest = colormap[GetColorLUT(&r_colorlookup, color.s.red, color.s.green, color.s.blue)];
GET_COLOR(frac>>FRACBITS);
*dest = GetColorLUT(&r_colorlookup, color.s.red, color.s.green, color.s.blue);
dest += vid.width;
// Avoid overflow.
@ -182,65 +188,69 @@ INT32 count;
{
while ((count -= 2) >= 0) // texture height is a power of 2
{
color.rgba = ASTBlendPixel(pMasterPalette[*dest], source[frac>>FRACBITS], AST_TRANSLUCENT, 255);
*dest = colormap[GetColorLUT(&r_colorlookup, color.s.red, color.s.green, color.s.blue)];
GET_COLOR((frac>>FRACBITS) & heightmask);
*dest = GetColorLUT(&r_colorlookup, color.s.red, color.s.green, color.s.blue);
dest += vid.width;
frac += fracstep;
color.rgba = ASTBlendPixel(pMasterPalette[*dest], source[frac>>FRACBITS], AST_TRANSLUCENT, 255);
*dest = colormap[GetColorLUT(&r_colorlookup, color.s.red, color.s.green, color.s.blue)];
GET_COLOR((frac>>FRACBITS) & heightmask);
*dest = GetColorLUT(&r_colorlookup, color.s.red, color.s.green, color.s.blue);
dest += vid.width;
frac += fracstep;
}
if (count & 1)
{
color.rgba = ASTBlendPixel(pMasterPalette[*dest], source[frac>>FRACBITS], AST_TRANSLUCENT, 255);
*dest = colormap[GetColorLUT(&r_colorlookup, color.s.red, color.s.green, color.s.blue)];
GET_COLOR((frac>>FRACBITS) & heightmask);
*dest = GetColorLUT(&r_colorlookup, color.s.red, color.s.green, color.s.blue);
}
}
#undef GET_COLOR
}
}
void R_DrawTranslucentColumn_8_RGBA(void)
{
register INT32 count;
register UINT8 *dest;
register fixed_t frac, fracstep;
count = dc_yh - dc_yl + 1;
if (count <= 0) // Zero length, column does not exceed a pixel.
INT32 count = dc_yh - dc_yl;
if (count < 0) // Zero length, column does not exceed a pixel.
return;
#ifdef RANGECHECK
if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height)
I_Error("R_DrawTranslucentColumn_8: %d to %d at %d", dc_yl, dc_yh, dc_x);
return;
#endif
// FIXME. As above.
//dest = ylookup[dc_yl] + columnofs[dc_x];
dest = &topleft[dc_yl*vid.width + dc_x];
UINT8 *dest = &topleft[dc_yl*vid.width + dc_x];
// Looks familiar.
fracstep = dc_iscale;
//frac = dc_texturemid + (dc_yl - centery)*fracstep;
frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires);
count++;
// Determine scaling, which is the only mapping to be done.
fixed_t fracstep = dc_iscale;
fixed_t frac = dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep);
// Inner loop that does the actual texture mapping, e.g. a DDA-like scaling.
// This is as fast as it gets.
{
register const RGBA_t *source = (RGBA_t *)dc_source;
register const UINT8 *transmap = dc_transmap;
register const lighttable_t *colormap = dc_colormap;
register INT32 heightmask = dc_texheight - 1;
RGBA_t color;
if (dc_texheight & heightmask)
const RGBA_t *source = (RGBA_t *)dc_source;
const lighttable_t *colormap = dc_colormap;
INT32 heightmask = dc_texheight-1;
RGBA_t ocolor, color;
UINT8 idx;
#define GET_COLOR(f) \
ocolor = source[f]; \
idx = colormap[GetColorLUT(&r_colorlookup, ocolor.s.red, ocolor.s.green, ocolor.s.blue)]; \
color = pMasterPalette[idx]; \
color.s.alpha = ocolor.s.alpha; \
color.rgba = ASTBlendPixel(pMasterPalette[*dest], color, dc_blendmode, dc_opacity)
if (dc_texheight & heightmask) // not a power of 2 -- killough
{
heightmask++;
heightmask <<= FRACBITS;
if (frac < 0)
while ((frac += heightmask) < 0)
;
while ((frac += heightmask) < 0);
else
while (frac >= heightmask)
frac -= heightmask;
@ -248,35 +258,43 @@ register INT32 count;
do
{
// Re-map color indices from wall texture column
// using a lighting/special effects LUT.
// using a lighting/special effects LUT.
// heightmask is the Tutti-Frutti fix
color = source[frac>>FRACBITS];
*dest = *(transmap + (colormap[GetColorLUT(&r_colorlookup, color.s.red, color.s.green, color.s.blue)]<<8) + (*dest));
GET_COLOR(frac >> FRACBITS);
*dest = GetColorLUT(&r_colorlookup, color.s.red, color.s.green, color.s.blue);
dest += vid.width;
if ((frac += fracstep) >= heightmask)
// Avoid overflow.
if (fracstep > 0x7FFFFFFF - frac)
frac += fracstep - heightmask;
else
frac += fracstep;
while (frac >= heightmask)
frac -= heightmask;
}
while (--count);
} while (--count);
}
else
{
while ((count -= 2) >= 0) // texture height is a power of 2
{
color = source[(frac>>FRACBITS) & heightmask];
*dest = *(transmap + (colormap[GetColorLUT(&r_colorlookup, color.s.red, color.s.green, color.s.blue)]<<8) + (*dest));
GET_COLOR((frac>>FRACBITS) & heightmask);
*dest = GetColorLUT(&r_colorlookup, color.s.red, color.s.green, color.s.blue);
dest += vid.width;
frac += fracstep;
color = source[(frac>>FRACBITS) & heightmask];
*dest = *(transmap + (colormap[GetColorLUT(&r_colorlookup, color.s.red, color.s.green, color.s.blue)]<<8) + (*dest));
GET_COLOR((frac>>FRACBITS) & heightmask);
*dest = GetColorLUT(&r_colorlookup, color.s.red, color.s.green, color.s.blue);
dest += vid.width;
frac += fracstep;
}
if (count & 1)
{
color = source[(frac>>FRACBITS) & heightmask];
*dest = *(transmap + (colormap[GetColorLUT(&r_colorlookup, color.s.red, color.s.green, color.s.blue)]<<8) + (*dest));
GET_COLOR((frac>>FRACBITS) & heightmask);
*dest = GetColorLUT(&r_colorlookup, color.s.red, color.s.green, color.s.blue);
}
}
#undef GET_COLOR
}
}

View file

@ -637,8 +637,7 @@ static void R_DrawSkyPlane(visplane_t *pl)
{
INT32 texture = texturetranslation[skytexture];
// Reset column drawer function (note: couldn't we just call walldrawerfunc directly?)
// (that is, unless we'll need to switch drawers in future for some reason)
// Reset column drawer function
colfunc = colfuncs[BASEDRAWFUNC];
dc_iscale = skyscale;

View file

@ -424,7 +424,7 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr
ds_transmap = vis->transmap;
// Determine which R_DrawWhatever to use
boolean source_rgba = patch->format == PATCH_FORMAT_RGBA;
boolean source_rgba = vis->patch->format == PATCH_FORMAT_RGBA;
// Solid color
if (ds_solidcolor)

View file

@ -842,13 +842,9 @@ static void R_DrawVisSprite(vissprite_t *vis)
source_paletted = patch->format == PATCH_FORMAT_PALETTE;
if (!source_paletted)
{
InitColorLUT(&r_colorlookup, pMasterPalette, false);
}
else
{
dc_translation = R_GetSpriteTranslation(vis);
}
colfunc = colfuncs[BASEDRAWFUNC]; // hack: this isn't resetting properly somewhere.
dc_colormap = vis->colormap;
@ -874,10 +870,13 @@ static void R_DrawVisSprite(vissprite_t *vis)
}
else
{
if (vis->transmap)
boolean use_translucency = !(vis->blendmode == AST_TRANSLUCENT && vis->opacity == 255);
if (use_translucency)
{
colfunc = colfuncs_rgba[COLDRAWFUNC_TRANSLU];
dc_transmap = vis->transmap; //Fab : 29-04-98: translucency table
dc_blendmode = vis->blendmode;
dc_opacity = (dc_blendmode == AST_COPY || dc_blendmode == AST_OVERLAY) ? 255 : vis->opacity;
}
else
colfunc = colfuncs_rgba[BASEDRAWFUNC];
@ -1004,7 +1003,6 @@ static void R_DrawVisSprite(vissprite_t *vis)
}
colfunc = colfuncs[BASEDRAWFUNC];
dc_hires = 0;
vis->x1 = x1;
vis->x2 = x2;
@ -2287,10 +2285,18 @@ static void R_ProjectSprite(mobj_t *thing)
vis->scale += FixedMul(scalestep, spriteyscale) * (vis->x1 - x1);
}
if ((blendmode != AST_COPY) && cv_translucency.value)
if (cv_translucency.value)
{
vis->blendmode = blendmode;
vis->opacity = R_GetOpacityFromAlphaLevel(trans);
vis->transmap = R_GetBlendTable(blendmode, trans);
}
else
{
vis->blendmode = AST_COPY;
vis->opacity = 255;
vis->transmap = NULL;
}
if (R_ThingIsFullBright(oldthing) || oldthing->flags2 & MF2_SHADOW || thing->flags2 & MF2_SHADOW)
vis->cut |= SC_FULLBRIGHT;

View file

@ -190,7 +190,9 @@ typedef struct vissprite_s
lighttable_t *colormap; // for color translation and shadow draw
// maxbright frames as well
UINT8 *transmap; // for MF2_SHADOW sprites, which translucency table to use
UINT8 *transmap; // which translucency table to use
UINT8 opacity;
UINT8 blendmode;
INT32 mobjflags;

View file

@ -54,6 +54,8 @@ void (*colfuncs_rgba[COLDRAWFUNC_MAX])(void);
void (*spanfunc)(void);
void (*spanfuncs[SPANDRAWFUNC_MAX])(void);
void (*spanfuncs_npo2[SPANDRAWFUNC_MAX])(void);
void (*spanfuncs_rgba[SPANDRAWFUNC_MAX])(void);
void (*spanfuncs_npo2_rgba[SPANDRAWFUNC_MAX])(void);
// ------------------
// global video state
@ -96,9 +98,6 @@ UINT8 *scr_borderpatch; // flat used to fill the reduced view borders set at ST_
// =========================================================================
// Short and Tall sky drawer, for the current color mode
void (*walldrawerfunc)(void);
boolean R_486 = false;
boolean R_586 = false;
boolean R_MMX = false;
@ -109,79 +108,71 @@ boolean R_SSE2 = false;
void SCR_SetDrawFuncs(void)
{
//
// setup the right draw routines for either 8bpp or 16bpp
//
if (true)//vid.bpp == 1) //Always run in 8bpp. todo: remove all 16bpp code?
{
colfuncs[BASEDRAWFUNC] = R_DrawColumn_8;
spanfuncs[BASEDRAWFUNC] = R_DrawSpan_8;
colfuncs[BASEDRAWFUNC] = R_DrawColumn_8;
spanfuncs[BASEDRAWFUNC] = R_DrawSpan_8;
colfunc = colfuncs[BASEDRAWFUNC];
spanfunc = spanfuncs[BASEDRAWFUNC];
colfunc = colfuncs[BASEDRAWFUNC];
spanfunc = spanfuncs[BASEDRAWFUNC];
colfuncs[COLDRAWFUNC_TRANSLU] = R_DrawTranslucentColumn_8;
colfuncs[COLDRAWFUNC_MAPPED] = R_DrawTranslatedColumn_8;
colfuncs[COLDRAWFUNC_SHADE] = R_DrawShadeColumn_8;
colfuncs[COLDRAWFUNC_SHADOWED] = R_DrawColumnShadowed_8;
colfuncs[COLDRAWFUNC_TRANSLU_MAPPED] = R_DrawTranslatedTranslucentColumn_8;
colfuncs[COLDRAWFUNC_TWOSMULTIPATCH] = R_Draw2sMultiPatchColumn_8;
colfuncs[COLDRAWFUNC_TWOSMULTIPATCHTRANS] = R_Draw2sMultiPatchTranslucentColumn_8;
colfuncs[COLDRAWFUNC_FOG] = R_DrawFogColumn_8;
colfuncs[COLDRAWFUNC_TRANSLU] = R_DrawTranslucentColumn_8;
colfuncs[COLDRAWFUNC_MAPPED] = R_DrawTranslatedColumn_8;
colfuncs[COLDRAWFUNC_SHADE] = R_DrawShadeColumn_8;
colfuncs[COLDRAWFUNC_SHADOWED] = R_DrawColumnShadowed_8;
colfuncs[COLDRAWFUNC_TRANSLU_MAPPED] = R_DrawTranslatedTranslucentColumn_8;
colfuncs[COLDRAWFUNC_TWOSMULTIPATCH] = R_Draw2sMultiPatchColumn_8;
colfuncs[COLDRAWFUNC_TWOSMULTIPATCHTRANS] = R_Draw2sMultiPatchTranslucentColumn_8;
colfuncs[COLDRAWFUNC_FOG] = R_DrawFogColumn_8;
colfuncs_rgba[BASEDRAWFUNC] = R_DrawBlendedColumn_8_RGBA;
colfuncs_rgba[COLDRAWFUNC_TRANSLU] = R_DrawTranslucentColumn_8_RGBA;
colfuncs_rgba[COLDRAWFUNC_MAPPED] = R_DrawBlendedColumn_8_RGBA;
colfuncs_rgba[COLDRAWFUNC_TRANSLU_MAPPED] = R_DrawTranslucentColumn_8_RGBA;
colfuncs_rgba[BASEDRAWFUNC] = R_DrawBlendedColumn_8_RGBA;
colfuncs_rgba[COLDRAWFUNC_TRANSLU] = R_DrawTranslucentColumn_8_RGBA;
colfuncs_rgba[COLDRAWFUNC_MAPPED] = R_DrawBlendedColumn_8_RGBA;
colfuncs_rgba[COLDRAWFUNC_TRANSLU_MAPPED] = R_DrawTranslucentColumn_8_RGBA;
spanfuncs[SPANDRAWFUNC_TRANS] = R_DrawTranslucentSpan_8;
spanfuncs[SPANDRAWFUNC_TILTED] = R_DrawTiltedSpan_8;
spanfuncs[SPANDRAWFUNC_TILTEDTRANS] = R_DrawTiltedTranslucentSpan_8;
spanfuncs[SPANDRAWFUNC_SPLAT] = R_DrawSplat_8;
spanfuncs[SPANDRAWFUNC_TRANSSPLAT] = R_DrawTranslucentSplat_8;
spanfuncs[SPANDRAWFUNC_TILTEDSPLAT] = R_DrawTiltedSplat_8;
spanfuncs[SPANDRAWFUNC_SPRITE] = R_DrawFloorSprite_8;
spanfuncs[SPANDRAWFUNC_TRANSSPRITE] = R_DrawTranslucentFloorSprite_8;
spanfuncs[SPANDRAWFUNC_TILTEDSPRITE] = R_DrawTiltedFloorSprite_8;
spanfuncs[SPANDRAWFUNC_TILTEDTRANSSPRITE] = R_DrawTiltedTranslucentFloorSprite_8;
spanfuncs[SPANDRAWFUNC_WATER] = R_DrawWaterSpan_8;
spanfuncs[SPANDRAWFUNC_TILTEDWATER] = R_DrawTiltedWaterSpan_8;
spanfuncs[SPANDRAWFUNC_SOLID] = R_DrawSolidColorSpan_8;
spanfuncs[SPANDRAWFUNC_TRANSSOLID] = R_DrawTransSolidColorSpan_8;
spanfuncs[SPANDRAWFUNC_TILTEDSOLID] = R_DrawTiltedSolidColorSpan_8;
spanfuncs[SPANDRAWFUNC_TILTEDTRANSSOLID] = R_DrawTiltedTransSolidColorSpan_8;
spanfuncs[SPANDRAWFUNC_WATERSOLID] = R_DrawWaterSolidColorSpan_8;
spanfuncs[SPANDRAWFUNC_TILTEDWATERSOLID] = R_DrawTiltedWaterSolidColorSpan_8;
spanfuncs[SPANDRAWFUNC_FOG] = R_DrawFogSpan_8;
spanfuncs[SPANDRAWFUNC_TILTEDFOG] = R_DrawTiltedFogSpan_8;
spanfuncs[SPANDRAWFUNC_TRANS] = R_DrawTranslucentSpan_8;
spanfuncs[SPANDRAWFUNC_TILTED] = R_DrawTiltedSpan_8;
spanfuncs[SPANDRAWFUNC_TILTEDTRANS] = R_DrawTiltedTranslucentSpan_8;
spanfuncs[SPANDRAWFUNC_SPLAT] = R_DrawSplat_8;
spanfuncs[SPANDRAWFUNC_TRANSSPLAT] = R_DrawTranslucentSplat_8;
spanfuncs[SPANDRAWFUNC_TILTEDSPLAT] = R_DrawTiltedSplat_8;
spanfuncs[SPANDRAWFUNC_SPRITE] = R_DrawFloorSprite_8;
spanfuncs[SPANDRAWFUNC_TRANSSPRITE] = R_DrawTranslucentFloorSprite_8;
spanfuncs[SPANDRAWFUNC_TILTEDSPRITE] = R_DrawTiltedFloorSprite_8;
spanfuncs[SPANDRAWFUNC_TILTEDTRANSSPRITE] = R_DrawTiltedTranslucentFloorSprite_8;
spanfuncs[SPANDRAWFUNC_WATER] = R_DrawWaterSpan_8;
spanfuncs[SPANDRAWFUNC_TILTEDWATER] = R_DrawTiltedWaterSpan_8;
spanfuncs[SPANDRAWFUNC_SOLID] = R_DrawSolidColorSpan_8;
spanfuncs[SPANDRAWFUNC_TRANSSOLID] = R_DrawTransSolidColorSpan_8;
spanfuncs[SPANDRAWFUNC_TILTEDSOLID] = R_DrawTiltedSolidColorSpan_8;
spanfuncs[SPANDRAWFUNC_TILTEDTRANSSOLID] = R_DrawTiltedTransSolidColorSpan_8;
spanfuncs[SPANDRAWFUNC_WATERSOLID] = R_DrawWaterSolidColorSpan_8;
spanfuncs[SPANDRAWFUNC_TILTEDWATERSOLID] = R_DrawTiltedWaterSolidColorSpan_8;
spanfuncs[SPANDRAWFUNC_FOG] = R_DrawFogSpan_8;
spanfuncs[SPANDRAWFUNC_TILTEDFOG] = R_DrawTiltedFogSpan_8;
spanfuncs_rgba[SPANDRAWFUNC_SPRITE] = R_DrawFloorSprite_8_RGBA;
spanfuncs_rgba[SPANDRAWFUNC_TRANSSPRITE] = R_DrawTranslucentFloorSprite_8_RGBA;
spanfuncs_rgba[SPANDRAWFUNC_TILTEDSPRITE] = R_DrawTiltedFloorSprite_8_RGBA;
spanfuncs_rgba[SPANDRAWFUNC_TILTEDTRANSSPRITE] = R_DrawTiltedTranslucentFloorSprite_8_RGBA;
spanfuncs_rgba[SPANDRAWFUNC_SPRITE] = R_DrawFloorSprite_8_RGBA;
spanfuncs_rgba[SPANDRAWFUNC_TRANSSPRITE] = R_DrawTranslucentFloorSprite_8_RGBA;
spanfuncs_rgba[SPANDRAWFUNC_TILTEDSPRITE] = R_DrawTiltedFloorSprite_8_RGBA;
spanfuncs_rgba[SPANDRAWFUNC_TILTEDTRANSSPRITE] = R_DrawTiltedTranslucentFloorSprite_8_RGBA;
// Lactozilla: Non-powers-of-two
spanfuncs_npo2[BASEDRAWFUNC] = R_DrawSpan_NPO2_8;
spanfuncs_npo2[SPANDRAWFUNC_TRANS] = R_DrawTranslucentSpan_NPO2_8;
spanfuncs_npo2[SPANDRAWFUNC_TILTED] = R_DrawTiltedSpan_NPO2_8;
spanfuncs_npo2[SPANDRAWFUNC_TILTEDTRANS] = R_DrawTiltedTranslucentSpan_NPO2_8;
spanfuncs_npo2[SPANDRAWFUNC_SPLAT] = R_DrawSplat_NPO2_8;
spanfuncs_npo2[SPANDRAWFUNC_TRANSSPLAT] = R_DrawTranslucentSplat_NPO2_8;
spanfuncs_npo2[SPANDRAWFUNC_TILTEDSPLAT] = R_DrawTiltedSplat_NPO2_8;
spanfuncs_npo2[SPANDRAWFUNC_SPRITE] = R_DrawFloorSprite_NPO2_8;
spanfuncs_npo2[SPANDRAWFUNC_TRANSSPRITE] = R_DrawTranslucentFloorSprite_NPO2_8;
spanfuncs_npo2[SPANDRAWFUNC_TILTEDSPRITE] = R_DrawTiltedFloorSprite_NPO2_8;
spanfuncs_npo2[SPANDRAWFUNC_TILTEDTRANSSPRITE] = R_DrawTiltedTranslucentFloorSprite_NPO2_8;
spanfuncs_npo2[SPANDRAWFUNC_WATER] = R_DrawWaterSpan_NPO2_8;
spanfuncs_npo2[SPANDRAWFUNC_TILTEDWATER] = R_DrawTiltedWaterSpan_NPO2_8;
// Lactozilla: Non-powers-of-two
spanfuncs_npo2[BASEDRAWFUNC] = R_DrawSpan_NPO2_8;
spanfuncs_npo2[SPANDRAWFUNC_TRANS] = R_DrawTranslucentSpan_NPO2_8;
spanfuncs_npo2[SPANDRAWFUNC_TILTED] = R_DrawTiltedSpan_NPO2_8;
spanfuncs_npo2[SPANDRAWFUNC_TILTEDTRANS] = R_DrawTiltedTranslucentSpan_NPO2_8;
spanfuncs_npo2[SPANDRAWFUNC_SPLAT] = R_DrawSplat_NPO2_8;
spanfuncs_npo2[SPANDRAWFUNC_TRANSSPLAT] = R_DrawTranslucentSplat_NPO2_8;
spanfuncs_npo2[SPANDRAWFUNC_TILTEDSPLAT] = R_DrawTiltedSplat_NPO2_8;
spanfuncs_npo2[SPANDRAWFUNC_SPRITE] = R_DrawFloorSprite_NPO2_8;
spanfuncs_npo2[SPANDRAWFUNC_TRANSSPRITE] = R_DrawTranslucentFloorSprite_NPO2_8;
spanfuncs_npo2[SPANDRAWFUNC_TILTEDSPRITE] = R_DrawTiltedFloorSprite_NPO2_8;
spanfuncs_npo2[SPANDRAWFUNC_TILTEDTRANSSPRITE] = R_DrawTiltedTranslucentFloorSprite_NPO2_8;
spanfuncs_npo2[SPANDRAWFUNC_WATER] = R_DrawWaterSpan_NPO2_8;
spanfuncs_npo2[SPANDRAWFUNC_TILTEDWATER] = R_DrawTiltedWaterSpan_NPO2_8;
spanfuncs_npo2_rgba[SPANDRAWFUNC_SPRITE] = R_DrawFloorSprite_NPO2_8_RGBA;
spanfuncs_npo2_rgba[SPANDRAWFUNC_TRANSSPRITE] = R_DrawTranslucentFloorSprite_NPO2_8_RGBA;
spanfuncs_npo2_rgba[SPANDRAWFUNC_TILTEDSPRITE] = R_DrawTiltedFloorSprite_NPO2_8_RGBA;
spanfuncs_npo2_rgba[SPANDRAWFUNC_TILTEDTRANSSPRITE] = R_DrawTiltedTranslucentFloorSprite_NPO2_8_RGBA;
}
else
I_Error("unknown bytes per pixel mode %d\n", vid.bpp);
spanfuncs_npo2_rgba[SPANDRAWFUNC_SPRITE] = R_DrawFloorSprite_NPO2_8_RGBA;
spanfuncs_npo2_rgba[SPANDRAWFUNC_TRANSSPRITE] = R_DrawTranslucentFloorSprite_NPO2_8_RGBA;
spanfuncs_npo2_rgba[SPANDRAWFUNC_TILTEDSPRITE] = R_DrawTiltedFloorSprite_NPO2_8_RGBA;
spanfuncs_npo2_rgba[SPANDRAWFUNC_TILTEDTRANSSPRITE] = R_DrawTiltedTranslucentFloorSprite_NPO2_8_RGBA;
}
void SCR_SetMode(void)