- Set colormap light info using R_SetColorMapLight and R_SetDSColorMapLight rather than manually calculating it

- Move texture and span management into R_DrawMaskedColumn
This commit is contained in:
Magnus Norddahl 2016-12-17 22:34:36 +01:00 committed by Christoph Oelckers
parent 88942dcc68
commit 9ac7a07be6
8 changed files with 104 additions and 91 deletions

View file

@ -548,6 +548,11 @@ namespace swrenderer
dc_colormap = base_colormap + (GETPALOOKUP(light, shade) << COLORMAPSHIFT); dc_colormap = base_colormap + (GETPALOOKUP(light, shade) << COLORMAPSHIFT);
} }
void R_SetColorMapLight(FDynamicColormap *base_colormap, float light, int shade)
{
R_SetColorMapLight(base_colormap->Maps, light, shade);
}
void R_SetDSColorMapLight(lighttable_t *base_colormap, float light, int shade) void R_SetDSColorMapLight(lighttable_t *base_colormap, float light, int shade)
{ {
using namespace drawerargs; using namespace drawerargs;
@ -555,6 +560,11 @@ namespace swrenderer
ds_colormap = base_colormap + (GETPALOOKUP(light, shade) << COLORMAPSHIFT); ds_colormap = base_colormap + (GETPALOOKUP(light, shade) << COLORMAPSHIFT);
} }
void R_SetDSColorMapLight(FDynamicColormap *base_colormap, float light, int shade)
{
R_SetDSColorMapLight(base_colormap->Maps, light, shade);
}
void R_SetTranslationMap(lighttable_t *translation) void R_SetTranslationMap(lighttable_t *translation)
{ {
using namespace drawerargs; using namespace drawerargs;

View file

@ -192,7 +192,9 @@ namespace swrenderer
void R_DrawDoubleSkyCol4(uint32_t solid_top, uint32_t solid_bottom); void R_DrawDoubleSkyCol4(uint32_t solid_top, uint32_t solid_bottom);
void R_SetColorMapLight(lighttable_t *base_colormap, float light, int shade); void R_SetColorMapLight(lighttable_t *base_colormap, float light, int shade);
void R_SetColorMapLight(FDynamicColormap *base_colormap, float light, int shade);
void R_SetDSColorMapLight(lighttable_t *base_colormap, float light, int shade); void R_SetDSColorMapLight(lighttable_t *base_colormap, float light, int shade);
void R_SetDSColorMapLight(FDynamicColormap *base_colormap, float light, int shade);
void R_SetTranslationMap(lighttable_t *translation); void R_SetTranslationMap(lighttable_t *translation);
void R_SetupSpanBits(FTexture *tex); void R_SetupSpanBits(FTexture *tex);

View file

@ -85,6 +85,9 @@ extern bool r_dontmaplines;
// Change R_CalcTiltedLighting() when this changes. // Change R_CalcTiltedLighting() when this changes.
#define GETPALOOKUP(vis,shade) (clamp<int> (((shade)-FLOAT2FIXED(MIN(MAXLIGHTVIS,double(vis))))>>FRACBITS, 0, NUMCOLORMAPS-1)) #define GETPALOOKUP(vis,shade) (clamp<int> (((shade)-FLOAT2FIXED(MIN(MAXLIGHTVIS,double(vis))))>>FRACBITS, 0, NUMCOLORMAPS-1))
// Converts fixedlightlev into a shade value
#define FIXEDLIGHT2SHADE(lightlev) (((lightlev) >> COLORMAPSHIFT) << FRACBITS)
extern double GlobVis; extern double GlobVis;
void R_SetVisibility(double visibility); void R_SetVisibility(double visibility);

View file

@ -240,8 +240,7 @@ void R_MapPlane (int y, int x1)
if (plane_shade) if (plane_shade)
{ {
// Determine lighting based on the span's distance from the viewer. // Determine lighting based on the span's distance from the viewer.
ds_colormap = basecolormap->Maps + (GETPALOOKUP ( R_SetDSColorMapLight(basecolormap, GlobVis * fabs(CenterY - y), planeshade);
GlobVis * fabs(CenterY - y), planeshade) << COLORMAPSHIFT);
} }
ds_y = y; ds_y = y;
@ -1043,7 +1042,7 @@ void R_DrawSinglePlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske
R_SetupSpanBits(tex); R_SetupSpanBits(tex);
double xscale = pl->xform.xScale * tex->Scale.X; double xscale = pl->xform.xScale * tex->Scale.X;
double yscale = pl->xform.yScale * tex->Scale.Y; double yscale = pl->xform.yScale * tex->Scale.Y;
ds_source = tex->GetPixels (); R_SetSpanSource(tex);
basecolormap = pl->colormap; basecolormap = pl->colormap;
planeshade = LIGHT2SHADE(pl->lightlevel); planeshade = LIGHT2SHADE(pl->lightlevel);
@ -1405,12 +1404,13 @@ void R_DrawSkyPlane (visplane_t *pl)
bool fakefixed = false; bool fakefixed = false;
if (fixedcolormap) if (fixedcolormap)
{ {
dc_colormap = fixedcolormap; R_SetColorMapLight(fixedcolormap, 0, 0);
} }
else else
{ {
fakefixed = true; fakefixed = true;
fixedcolormap = dc_colormap = NormalLight.Maps; fixedcolormap = NormalLight.Maps;
R_SetColorMapLight(fixedcolormap, 0, 0);
} }
R_DrawSky (pl); R_DrawSky (pl);
@ -1484,12 +1484,21 @@ void R_DrawNormalPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t
planeheight = fabs(pl->height.Zat0() - ViewPos.Z); planeheight = fabs(pl->height.Zat0() - ViewPos.Z);
GlobVis = r_FloorVisibility / planeheight; GlobVis = r_FloorVisibility / planeheight;
ds_light = 0;
if (fixedlightlev >= 0) if (fixedlightlev >= 0)
ds_colormap = basecolormap->Maps + fixedlightlev, plane_shade = false; {
R_SetDSColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev));
plane_shade = false;
}
else if (fixedcolormap) else if (fixedcolormap)
ds_colormap = fixedcolormap, plane_shade = false; {
R_SetDSColorMapLight(fixedcolormap, 0, 0);
plane_shade = false;
}
else else
{
plane_shade = true; plane_shade = true;
}
if (spanfunc != R_FillSpan) if (spanfunc != R_FillSpan)
{ {
@ -1645,11 +1654,20 @@ void R_DrawTiltedPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t
planelightfloat = -planelightfloat; planelightfloat = -planelightfloat;
if (fixedlightlev >= 0) if (fixedlightlev >= 0)
ds_colormap = basecolormap->Maps + fixedlightlev, plane_shade = false; {
R_SetDSColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev));
plane_shade = false;
}
else if (fixedcolormap) else if (fixedcolormap)
ds_colormap = fixedcolormap, plane_shade = false; {
R_SetDSColorMapLight(fixedcolormap, 0, 0);
plane_shade = false;
}
else else
ds_colormap = basecolormap->Maps, plane_shade = true; {
R_SetDSColorMapLight(basecolormap, 0, 0);
plane_shade = true;
}
// Hack in support for 1 x Z and Z x 1 texture sizes // Hack in support for 1 x Z and Z x 1 texture sizes
if (ds_ybits == 0) if (ds_ybits == 0)

View file

@ -44,6 +44,7 @@
#include "r_plane.h" #include "r_plane.h"
#include "r_segs.h" #include "r_segs.h"
#include "r_3dfloors.h" #include "r_3dfloors.h"
#include "r_draw.h"
#include "v_palette.h" #include "v_palette.h"
#include "r_data/colormaps.h" #include "r_data/colormaps.h"
@ -53,6 +54,7 @@
CVAR(Bool, r_fogboundary, true, 0) CVAR(Bool, r_fogboundary, true, 0)
CVAR(Bool, r_drawmirrors, true, 0) CVAR(Bool, r_drawmirrors, true, 0)
EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor); EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor);
EXTERN_CVAR(Bool, r_mipmap)
namespace swrenderer namespace swrenderer
{ {
@ -156,7 +158,7 @@ static void BlastMaskedColumn (FTexture *tex, bool useRt)
// calculate lighting // calculate lighting
if (fixedcolormap == NULL && fixedlightlev < 0) if (fixedcolormap == NULL && fixedlightlev < 0)
{ {
dc_colormap = basecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); R_SetColorMapLight(basecolormap, rw_light, wallshade);
} }
dc_iscale = xs_Fix<16>::ToFix(MaskedSWall[dc_x] * MaskedScaleY); dc_iscale = xs_Fix<16>::ToFix(MaskedSWall[dc_x] * MaskedScaleY);
@ -174,9 +176,7 @@ static void BlastMaskedColumn (FTexture *tex, bool useRt)
// when forming multipatched textures (see r_data.c). // when forming multipatched textures (see r_data.c).
// draw the texture // draw the texture
const FTexture::Span *spans; R_DrawMaskedColumn(tex, maskedtexturecol[dc_x], useRt);
const BYTE *pixels = tex->GetColumn (maskedtexturecol[dc_x] >> FRACBITS, &spans);
R_DrawMaskedColumn(pixels, spans, useRt);
rw_light += rw_lightstep; rw_light += rw_lightstep;
spryscale += rw_scalestep; spryscale += rw_scalestep;
} }
@ -292,9 +292,9 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2)
rw_scalestep = ds->iscalestep; rw_scalestep = ds->iscalestep;
if (fixedlightlev >= 0) if (fixedlightlev >= 0)
dc_colormap = (r_fullbrightignoresectorcolor) ? (FullNormalLight.Maps + fixedlightlev) : (basecolormap->Maps + fixedlightlev); R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev));
else if (fixedcolormap != NULL) else if (fixedcolormap != NULL)
dc_colormap = fixedcolormap; R_SetColorMapLight(fixedcolormap, 0, 0);
// find positioning // find positioning
texheight = tex->GetScaledHeightDouble(); texheight = tex->GetScaledHeightDouble();
@ -440,7 +440,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2)
while (dc_x < stop) while (dc_x < stop)
{ {
rt_initcols(); rt_initcols(nullptr);
BlastMaskedColumn (tex, true); dc_x++; BlastMaskedColumn (tex, true); dc_x++;
BlastMaskedColumn (tex, true); dc_x++; BlastMaskedColumn (tex, true); dc_x++;
BlastMaskedColumn (tex, true); dc_x++; BlastMaskedColumn (tex, true); dc_x++;
@ -609,9 +609,9 @@ void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover)
} }
if (fixedlightlev >= 0) if (fixedlightlev >= 0)
dc_colormap = (r_fullbrightignoresectorcolor) ? (FullNormalLight.Maps + fixedlightlev) : (basecolormap->Maps + fixedlightlev); R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev));
else if (fixedcolormap != NULL) else if (fixedcolormap != NULL)
dc_colormap = fixedcolormap; R_SetColorMapLight(fixedcolormap, 0, 0);
WallC.sz1 = ds->sz1; WallC.sz1 = ds->sz1;
WallC.sz2 = ds->sz2; WallC.sz2 = ds->sz2;
@ -1061,9 +1061,9 @@ void R_RenderSegLoop ()
fixed_t xoffset = rw_offset; fixed_t xoffset = rw_offset;
if (fixedlightlev >= 0) if (fixedlightlev >= 0)
dc_colormap = (r_fullbrightignoresectorcolor) ? (FullNormalLight.Maps + fixedlightlev) : (basecolormap->Maps + fixedlightlev); R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev));
else if (fixedcolormap != NULL) else if (fixedcolormap != NULL)
dc_colormap = fixedcolormap; R_SetColorMapLight(fixedcolormap, 0, 0);
// clip wall to the floor and ceiling // clip wall to the floor and ceiling
for (x = x1; x < x2; ++x) for (x = x1; x < x2; ++x)
@ -2304,11 +2304,11 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper,
rw_light = rw_lightleft + (x1 - savecoord.sx1) * rw_lightstep; rw_light = rw_lightleft + (x1 - savecoord.sx1) * rw_lightstep;
if (fixedlightlev >= 0) if (fixedlightlev >= 0)
dc_colormap = (r_fullbrightignoresectorcolor) ? (FullNormalLight.Maps + fixedlightlev) : (usecolormap->Maps + fixedlightlev); R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : usecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev));
else if (fixedcolormap != NULL) else if (fixedcolormap != NULL)
dc_colormap = fixedcolormap; R_SetColorMapLight(fixedcolormap, 0, 0);
else if (!foggy && (decal->RenderFlags & RF_FULLBRIGHT)) else if (!foggy && (decal->RenderFlags & RF_FULLBRIGHT))
dc_colormap = (r_fullbrightignoresectorcolor) ? FullNormalLight.Maps : usecolormap->Maps; R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : usecolormap, 0, 0);
else else
calclighting = true; calclighting = true;
@ -2359,7 +2359,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper,
{ {
if (calclighting) if (calclighting)
{ // calculate lighting { // calculate lighting
dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); R_SetColorMapLight(usecolormap, rw_light, wallshade);
} }
R_WallSpriteColumn (false); R_WallSpriteColumn (false);
dc_x++; dc_x++;
@ -2369,9 +2369,9 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper,
{ {
if (calclighting) if (calclighting)
{ // calculate lighting { // calculate lighting
dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); R_SetColorMapLight(usecolormap, rw_light, wallshade);
} }
rt_initcols(); rt_initcols(nullptr);
for (int zz = 4; zz; --zz) for (int zz = 4; zz; --zz)
{ {
R_WallSpriteColumn (true); R_WallSpriteColumn (true);
@ -2384,7 +2384,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper,
{ {
if (calclighting) if (calclighting)
{ // calculate lighting { // calculate lighting
dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); R_SetColorMapLight(usecolormap, rw_light, wallshade);
} }
R_WallSpriteColumn (false); R_WallSpriteColumn (false);
dc_x++; dc_x++;

View file

@ -256,8 +256,23 @@ double sprtopscreen;
bool sprflipvert; bool sprflipvert;
void R_DrawMaskedColumn (const BYTE *column, const FTexture::Span *span, bool useRt) void R_DrawMaskedColumn (FTexture *tex, fixed_t col, bool useRt, bool unmasked)
{ {
const FTexture::Span *span;
const BYTE *column;
column = tex->GetColumn(col >> FRACBITS, &span);
FTexture::Span unmaskedSpan[2];
if (unmasked)
{
span = unmaskedSpan;
unmaskedSpan[0].TopOffset = 0;
unmaskedSpan[0].Length = tex->GetHeight();
unmaskedSpan[1].TopOffset = 0;
unmaskedSpan[1].Length = 0;
}
while (span->Length != 0) while (span->Length != 0)
{ {
const int length = span->Length; const int length = span->Length;
@ -377,8 +392,6 @@ static inline bool R_ClipSpriteColumnWithPortals(vissprite_t* spr)
// //
void R_DrawVisSprite (vissprite_t *vis) void R_DrawVisSprite (vissprite_t *vis)
{ {
const BYTE *pixels;
const FTexture::Span *spans;
fixed_t frac; fixed_t frac;
FTexture *tex; FTexture *tex;
int x2, stop4; int x2, stop4;
@ -392,7 +405,7 @@ void R_DrawVisSprite (vissprite_t *vis)
} }
fixed_t centeryfrac = FLOAT2FIXED(CenterY); fixed_t centeryfrac = FLOAT2FIXED(CenterY);
dc_colormap = vis->Style.colormap; R_SetColorMapLight(vis->Style.colormap, 0.0f, 0);
mode = R_SetPatchStyle (vis->Style.RenderStyle, vis->Style.Alpha, vis->Translation, vis->FillColor); mode = R_SetPatchStyle (vis->Style.RenderStyle, vis->Style.Alpha, vis->Translation, vis->FillColor);
@ -400,7 +413,7 @@ void R_DrawVisSprite (vissprite_t *vis)
{ // For shaded sprites, R_SetPatchStyle sets a dc_colormap to an alpha table, but { // For shaded sprites, R_SetPatchStyle sets a dc_colormap to an alpha table, but
// it is the brightest one. We need to get back to the proper light level for // it is the brightest one. We need to get back to the proper light level for
// this sprite. // this sprite.
dc_colormap += vis->ColormapNum << COLORMAPSHIFT; R_SetColorMapLight(dc_colormap, 0, vis->ColormapNum << FRACBITS);
} }
if (mode != DontDraw) if (mode != DontDraw)
@ -445,21 +458,19 @@ void R_DrawVisSprite (vissprite_t *vis)
{ {
while ((dc_x < stop4) && (dc_x & 3)) while ((dc_x < stop4) && (dc_x & 3))
{ {
pixels = tex->GetColumn (frac >> FRACBITS, &spans);
if (ispsprite || !R_ClipSpriteColumnWithPortals(vis)) if (ispsprite || !R_ClipSpriteColumnWithPortals(vis))
R_DrawMaskedColumn (pixels, spans, false); R_DrawMaskedColumn (tex, frac, false);
dc_x++; dc_x++;
frac += xiscale; frac += xiscale;
} }
while (dc_x < stop4) while (dc_x < stop4)
{ {
rt_initcols(); rt_initcols(nullptr);
for (int zz = 4; zz; --zz) for (int zz = 4; zz; --zz)
{ {
pixels = tex->GetColumn (frac >> FRACBITS, &spans);
if (ispsprite || !R_ClipSpriteColumnWithPortals(vis)) if (ispsprite || !R_ClipSpriteColumnWithPortals(vis))
R_DrawMaskedColumn (pixels, spans, true); R_DrawMaskedColumn (tex, frac, true);
dc_x++; dc_x++;
frac += xiscale; frac += xiscale;
} }
@ -468,9 +479,8 @@ void R_DrawVisSprite (vissprite_t *vis)
while (dc_x < x2) while (dc_x < x2)
{ {
pixels = tex->GetColumn (frac >> FRACBITS, &spans);
if (ispsprite || !R_ClipSpriteColumnWithPortals(vis)) if (ispsprite || !R_ClipSpriteColumnWithPortals(vis))
R_DrawMaskedColumn (pixels, spans, false); R_DrawMaskedColumn (tex, frac, false);
dc_x++; dc_x++;
frac += xiscale; frac += xiscale;
} }
@ -522,11 +532,11 @@ void R_DrawWallSprite(vissprite_t *spr)
rw_lightstep = float((GlobVis / spr->wallc.sz2 - rw_lightleft) / (spr->wallc.sx2 - spr->wallc.sx1)); rw_lightstep = float((GlobVis / spr->wallc.sz2 - rw_lightleft) / (spr->wallc.sx2 - spr->wallc.sx1));
rw_light = rw_lightleft + (x1 - spr->wallc.sx1) * rw_lightstep; rw_light = rw_lightleft + (x1 - spr->wallc.sx1) * rw_lightstep;
if (fixedlightlev >= 0) if (fixedlightlev >= 0)
dc_colormap = usecolormap->Maps + fixedlightlev; R_SetColorMapLight(usecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev));
else if (fixedcolormap != NULL) else if (fixedcolormap != NULL)
dc_colormap = fixedcolormap; R_SetColorMapLight(fixedcolormap, 0, 0);
else if (!foggy && (spr->renderflags & RF_FULLBRIGHT)) else if (!foggy && (spr->renderflags & RF_FULLBRIGHT))
dc_colormap = (r_fullbrightignoresectorcolor) ? FullNormalLight.Maps : usecolormap->Maps; R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : usecolormap, 0, 0);
else else
calclighting = true; calclighting = true;
@ -577,7 +587,7 @@ void R_DrawWallSprite(vissprite_t *spr)
{ {
if (calclighting) if (calclighting)
{ // calculate lighting { // calculate lighting
dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, shade) << COLORMAPSHIFT); R_SetColorMapLight(usecolormap, rw_light, shade);
} }
if (!R_ClipSpriteColumnWithPortals(spr)) if (!R_ClipSpriteColumnWithPortals(spr))
R_WallSpriteColumn(false); R_WallSpriteColumn(false);
@ -588,9 +598,9 @@ void R_DrawWallSprite(vissprite_t *spr)
{ {
if (calclighting) if (calclighting)
{ // calculate lighting { // calculate lighting
dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, shade) << COLORMAPSHIFT); R_SetColorMapLight(usecolormap, rw_light, shade);
} }
rt_initcols(); rt_initcols(nullptr);
for (int zz = 4; zz; --zz) for (int zz = 4; zz; --zz)
{ {
if (!R_ClipSpriteColumnWithPortals(spr)) if (!R_ClipSpriteColumnWithPortals(spr))
@ -604,7 +614,7 @@ void R_DrawWallSprite(vissprite_t *spr)
{ {
if (calclighting) if (calclighting)
{ // calculate lighting { // calculate lighting
dc_colormap = usecolormap->Maps + (GETPALOOKUP (rw_light, shade) << COLORMAPSHIFT); R_SetColorMapLight(usecolormap, rw_light, shade);
} }
if (!R_ClipSpriteColumnWithPortals(spr)) if (!R_ClipSpriteColumnWithPortals(spr))
R_WallSpriteColumn(false); R_WallSpriteColumn(false);
@ -624,11 +634,8 @@ void R_WallSpriteColumn (bool useRt)
else else
sprtopscreen = CenterY - dc_texturemid * spryscale; sprtopscreen = CenterY - dc_texturemid * spryscale;
const BYTE *column;
const FTexture::Span *spans;
column = WallSpriteTile->GetColumn (lwall[dc_x] >> FRACBITS, &spans);
dc_texturefrac = 0; dc_texturefrac = 0;
R_DrawMaskedColumn(column, spans, useRt); R_DrawMaskedColumn(WallSpriteTile, lwall[dc_x], useRt);
rw_light += rw_lightstep; rw_light += rw_lightstep;
} }
@ -638,7 +645,7 @@ void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop
int flags = 0; int flags = 0;
// Do setup for blending. // Do setup for blending.
dc_colormap = spr->Style.colormap; R_SetColorMapLight(spr->Style.colormap, 0.0f, 0);
mode = R_SetPatchStyle(spr->Style.RenderStyle, spr->Style.Alpha, spr->Translation, spr->FillColor); mode = R_SetPatchStyle(spr->Style.RenderStyle, spr->Style.Alpha, spr->Translation, spr->FillColor);
if (mode == DontDraw) if (mode == DontDraw)
@ -689,10 +696,7 @@ void R_DrawVisVoxel(vissprite_t *spr, int minslabz, int maxslabz, short *cliptop
} }
else else
{ {
unsigned int **tspan = &dc_ctspan[x & 3]; rt_span_coverage(x, span->Start, span->Stop - 1);
(*tspan)[0] = span->Start;
(*tspan)[1] = span->Stop - 1;
*tspan += 2;
} }
} }
if (!(flags & DVF_SPANSONLY) && (x & 3) == 3) if (!(flags & DVF_SPANSONLY) && (x & 3) == 3)
@ -2044,7 +2048,7 @@ void R_DrawSprite (vissprite_t *spr)
else else
{ // diminished light { // diminished light
spriteshade = LIGHT2SHADE(sec->lightlevel + r_actualextralight); spriteshade = LIGHT2SHADE(sec->lightlevel + r_actualextralight);
spr->Style.colormap = mybasecolormap->Maps + (GETPALOOKUP ( spr->Style.colormap = mybasecolormap->Maps + (GETPALOOKUP(
r_SpriteVisibility / MAX(MINZ, (double)spr->depth), spriteshade) << COLORMAPSHIFT); r_SpriteVisibility / MAX(MINZ, (double)spr->depth), spriteshade) << COLORMAPSHIFT);
} }
} }
@ -3237,12 +3241,12 @@ void R_CheckOffscreenBuffer(int width, int height, bool spansonly)
{ {
if (OffscreenColorBuffer == NULL) if (OffscreenColorBuffer == NULL)
{ {
OffscreenColorBuffer = new BYTE[width * height]; OffscreenColorBuffer = new BYTE[width * height * 4];
} }
else if (OffscreenBufferWidth != width || OffscreenBufferHeight != height) else if (OffscreenBufferWidth != width || OffscreenBufferHeight != height)
{ {
delete[] OffscreenColorBuffer; delete[] OffscreenColorBuffer;
OffscreenColorBuffer = new BYTE[width * height]; OffscreenColorBuffer = new BYTE[width * height * 4];
} }
} }
OffscreenBufferWidth = width; OffscreenBufferWidth = width;

View file

@ -128,7 +128,7 @@ extern double pspriteyscale;
extern FTexture *WallSpriteTile; extern FTexture *WallSpriteTile;
void R_DrawMaskedColumn (const BYTE *column, const FTexture::Span *spans, bool useRt); void R_DrawMaskedColumn (FTexture *texture, fixed_t column, bool useRt, bool unmasked = false);
void R_WallSpriteColumn (bool useRt); void R_WallSpriteColumn (bool useRt);
void R_CacheSprite (spritedef_t *sprite); void R_CacheSprite (spritedef_t *sprite);

View file

@ -135,20 +135,9 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms)
using namespace swrenderer; using namespace swrenderer;
using namespace drawerargs; using namespace drawerargs;
FTexture::Span unmaskedSpan[2];
const FTexture::Span **spanptr, *spans;
static short bottomclipper[MAXWIDTH], topclipper[MAXWIDTH]; static short bottomclipper[MAXWIDTH], topclipper[MAXWIDTH];
const BYTE *translation = NULL; const BYTE *translation = NULL;
if (parms.masked)
{
spanptr = &spans;
}
else
{
spanptr = NULL;
}
if (APART(parms.colorOverlay) != 0) if (APART(parms.colorOverlay) != 0)
{ {
// The software renderer cannot invert the source without inverting the overlay // The software renderer cannot invert the source without inverting the overlay
@ -198,18 +187,8 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms)
if (mode != DontDraw) if (mode != DontDraw)
{ {
const BYTE *pixels;
int stop4; int stop4;
if (spanptr == NULL)
{ // Create a single span for forced unmasked images
spans = unmaskedSpan;
unmaskedSpan[0].TopOffset = 0;
unmaskedSpan[0].Length = img->GetHeight();
unmaskedSpan[1].TopOffset = 0;
unmaskedSpan[1].Length = 0;
}
double centeryback = CenterY; double centeryback = CenterY;
CenterY = 0; CenterY = 0;
@ -301,8 +280,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms)
{ {
while ((dc_x < stop4) && (dc_x & 3)) while ((dc_x < stop4) && (dc_x & 3))
{ {
pixels = img->GetColumn(frac >> FRACBITS, spanptr); R_DrawMaskedColumn(img, frac, false, !parms.masked);
R_DrawMaskedColumn(pixels, spans, false);
dc_x++; dc_x++;
frac += xiscale_i; frac += xiscale_i;
} }
@ -312,8 +290,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms)
rt_initcols(); rt_initcols();
for (int zz = 4; zz; --zz) for (int zz = 4; zz; --zz)
{ {
pixels = img->GetColumn(frac >> FRACBITS, spanptr); R_DrawMaskedColumn(img, frac, true, !parms.masked);
R_DrawMaskedColumn(pixels, spans, true);
dc_x++; dc_x++;
frac += xiscale_i; frac += xiscale_i;
} }
@ -322,8 +299,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms)
while (dc_x < x2_i) while (dc_x < x2_i)
{ {
pixels = img->GetColumn(frac >> FRACBITS, spanptr); R_DrawMaskedColumn(img, frac, false, !parms.masked);
R_DrawMaskedColumn(pixels, spans, false);
dc_x++; dc_x++;
frac += xiscale_i; frac += xiscale_i;
} }