Remove basecolormap global

This commit is contained in:
Magnus Norddahl 2017-01-12 21:29:19 +01:00
parent 929e07697d
commit 9e940b4287
37 changed files with 140 additions and 142 deletions

View file

@ -100,7 +100,7 @@ void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, const Vec4f &c
if (swrenderer::fixedlightlev < 0 && sub->sector->e->XFloor.lightlist.Size()) if (swrenderer::fixedlightlev < 0 && sub->sector->e->XFloor.lightlist.Size())
{ {
lightlist_t *light = P_GetPlaneLight(sub->sector, &sub->sector->ceilingplane, false); lightlist_t *light = P_GetPlaneLight(sub->sector, &sub->sector->ceilingplane, false);
swrenderer::basecolormap = light->extra_colormap; //basecolormap = light->extra_colormap;
lightlevel = *light->p_lightlevel; lightlevel = *light->p_lightlevel;
} }

View file

@ -375,11 +375,9 @@ namespace swrenderer
default: return 0; default: return 0;
} }
} }
FDynamicColormap *basecolormapsave;
} }
bool R_SetPatchStyle(FRenderStyle style, fixed_t alpha, int translation, uint32_t color) bool R_SetPatchStyle(FRenderStyle style, fixed_t alpha, int translation, uint32_t color, FDynamicColormap *&basecolormap)
{ {
using namespace drawerargs; using namespace drawerargs;
@ -428,7 +426,6 @@ namespace swrenderer
} }
} }
} }
basecolormapsave = basecolormap;
// Check for special modes // Check for special modes
if (style.BlendOp == STYLEOP_Fuzz) if (style.BlendOp == STYLEOP_Fuzz)
@ -488,14 +485,9 @@ namespace swrenderer
return true; return true;
} }
bool R_SetPatchStyle(FRenderStyle style, float alpha, int translation, uint32_t color) bool R_SetPatchStyle(FRenderStyle style, float alpha, int translation, uint32_t color, FDynamicColormap *&basecolormap)
{ {
return R_SetPatchStyle(style, FLOAT2FIXED(alpha), translation, color); return R_SetPatchStyle(style, FLOAT2FIXED(alpha), translation, color, basecolormap);
}
void R_FinishSetPatchStyle()
{
basecolormap = basecolormapsave;
} }
DrawerFunc R_GetTransMaskDrawer() DrawerFunc R_GetTransMaskDrawer()

View file

@ -162,7 +162,7 @@ namespace swrenderer
virtual void DrawSpanAddClamp() = 0; virtual void DrawSpanAddClamp() = 0;
virtual void DrawSpanMaskedAddClamp() = 0; virtual void DrawSpanMaskedAddClamp() = 0;
virtual void FillSpan() = 0; virtual void FillSpan() = 0;
virtual void DrawTiltedSpan(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy) = 0; virtual void DrawTiltedSpan(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy, FDynamicColormap *basecolormap) = 0;
virtual void DrawColoredSpan(int y, int x1, int x2) = 0; virtual void DrawColoredSpan(int y, int x1, int x2) = 0;
virtual void DrawFogBoundaryLine(int y, int x1, int x2) = 0; virtual void DrawFogBoundaryLine(int y, int x1, int x2) = 0;
}; };
@ -175,9 +175,8 @@ namespace swrenderer
void R_InitShadeMaps(); void R_InitShadeMaps();
void R_InitFuzzTable(int fuzzoff); void R_InitFuzzTable(int fuzzoff);
bool R_SetPatchStyle(FRenderStyle style, fixed_t alpha, int translation, uint32_t color); bool R_SetPatchStyle(FRenderStyle style, fixed_t alpha, int translation, uint32_t color, FDynamicColormap *&basecolormap);
bool R_SetPatchStyle(FRenderStyle style, float alpha, int translation, uint32_t color); bool R_SetPatchStyle(FRenderStyle style, float alpha, int translation, uint32_t color, FDynamicColormap *&basecolormap);
void R_FinishSetPatchStyle(); // Call this after finished drawing the current thing, in case its style was STYLE_Shade
DrawerFunc R_GetTransMaskDrawer(); DrawerFunc R_GetTransMaskDrawer();
void R_UpdateFuzzPos(); void R_UpdateFuzzPos();

View file

@ -2480,7 +2480,7 @@ namespace swrenderer
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
DrawTiltedSpanPalCommand::DrawTiltedSpanPalCommand(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy) DrawTiltedSpanPalCommand::DrawTiltedSpanPalCommand(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy, FDynamicColormap *basecolormap)
: y(y), x1(x1), x2(x2), plane_sz(plane_sz), plane_su(plane_su), plane_sv(plane_sv), plane_shade(plane_shade), planeshade(planeshade), planelightfloat(planelightfloat), pviewx(pviewx), pviewy(pviewy) : y(y), x1(x1), x2(x2), plane_sz(plane_sz), plane_su(plane_su), plane_sv(plane_sv), plane_shade(plane_shade), planeshade(planeshade), planelightfloat(planelightfloat), pviewx(pviewx), pviewy(pviewy)
{ {
using namespace drawerargs; using namespace drawerargs;

View file

@ -162,7 +162,7 @@ namespace swrenderer
class DrawTiltedSpanPalCommand : public DrawerCommand class DrawTiltedSpanPalCommand : public DrawerCommand
{ {
public: public:
DrawTiltedSpanPalCommand(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy); DrawTiltedSpanPalCommand(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy, FDynamicColormap *basecolormap);
void Execute(DrawerThread *thread) override; void Execute(DrawerThread *thread) override;
FString DebugInfo() override { return "DrawTiltedSpanPalCommand"; } FString DebugInfo() override { return "DrawTiltedSpanPalCommand"; }
@ -276,9 +276,9 @@ namespace swrenderer
void DrawSpanMaskedAddClamp() override { DrawerCommandQueue::QueueCommand<DrawSpanMaskedAddClampPalCommand>(); } void DrawSpanMaskedAddClamp() override { DrawerCommandQueue::QueueCommand<DrawSpanMaskedAddClampPalCommand>(); }
void FillSpan() override { DrawerCommandQueue::QueueCommand<FillSpanPalCommand>(); } void FillSpan() override { DrawerCommandQueue::QueueCommand<FillSpanPalCommand>(); }
void DrawTiltedSpan(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy) override void DrawTiltedSpan(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy, FDynamicColormap *basecolormap) override
{ {
DrawerCommandQueue::QueueCommand<DrawTiltedSpanPalCommand>(y, x1, x2, plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy); DrawerCommandQueue::QueueCommand<DrawTiltedSpanPalCommand>(y, x1, x2, plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy, basecolormap);
} }
void DrawColoredSpan(int y, int x1, int x2) override { DrawerCommandQueue::QueueCommand<DrawColoredSpanPalCommand>(y, x1, x2); } void DrawColoredSpan(int y, int x1, int x2) override { DrawerCommandQueue::QueueCommand<DrawColoredSpanPalCommand>(y, x1, x2); }

View file

@ -380,7 +380,7 @@ namespace swrenderer
void DrawSpanMaskedAddClamp() override { DrawerCommandQueue::QueueCommand<DrawSpanMaskedAddClampLLVMCommand>(); } void DrawSpanMaskedAddClamp() override { DrawerCommandQueue::QueueCommand<DrawSpanMaskedAddClampLLVMCommand>(); }
void FillSpan() override { DrawerCommandQueue::QueueCommand<FillSpanRGBACommand>(); } void FillSpan() override { DrawerCommandQueue::QueueCommand<FillSpanRGBACommand>(); }
void DrawTiltedSpan(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy) override void DrawTiltedSpan(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy, FDynamicColormap *basecolormap) override
{ {
DrawerCommandQueue::QueueCommand<DrawTiltedSpanRGBACommand>(y, x1, x2, plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy); DrawerCommandQueue::QueueCommand<DrawTiltedSpanRGBACommand>(y, x1, x2, plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy);
} }

View file

@ -45,7 +45,7 @@
namespace swrenderer namespace swrenderer
{ {
void RenderFogBoundary::Render(int x1, int x2, short *uclip, short *dclip, int wallshade, float lightleft, float lightstep) void RenderFogBoundary::Render(int x1, int x2, short *uclip, short *dclip, int wallshade, float lightleft, float lightstep, FDynamicColormap *basecolormap)
{ {
// This is essentially the same as R_MapVisPlane but with an extra step // This is essentially the same as R_MapVisPlane but with an extra step
// to create new horizontal spans whenever the light changes enough that // to create new horizontal spans whenever the light changes enough that

View file

@ -18,7 +18,7 @@ namespace swrenderer
class RenderFogBoundary class RenderFogBoundary
{ {
public: public:
static void Render(int x1, int x2, short *uclip, short *dclip, int wallshade, float lightleft, float lightstep); static void Render(int x1, int x2, short *uclip, short *dclip, int wallshade, float lightleft, float lightstep, FDynamicColormap *basecolormap);
private: private:
static void RenderSection(int y, int y2, int x1); static void RenderSection(int y, int y2, int x1);

View file

@ -55,7 +55,7 @@ EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor);
namespace swrenderer namespace swrenderer
{ {
void SWRenderLine::Render(seg_t *line, subsector_t *subsector, sector_t *sector, sector_t *fakebacksector, visplane_t *linefloorplane, visplane_t *lineceilingplane, bool infog) void SWRenderLine::Render(seg_t *line, subsector_t *subsector, sector_t *sector, sector_t *fakebacksector, visplane_t *linefloorplane, visplane_t *lineceilingplane, bool infog, FDynamicColormap *colormap)
{ {
static sector_t tempsec; // killough 3/8/98: ceiling/water hack static sector_t tempsec; // killough 3/8/98: ceiling/water hack
bool solid; bool solid;
@ -67,6 +67,7 @@ namespace swrenderer
floorplane = linefloorplane; floorplane = linefloorplane;
ceilingplane = lineceilingplane; ceilingplane = lineceilingplane;
foggy = infog; foggy = infog;
basecolormap = colormap;
curline = line; curline = line;
@ -591,7 +592,7 @@ namespace swrenderer
// [ZZ] Only if not an active mirror // [ZZ] Only if not an active mirror
if (!rw_markportal) if (!rw_markportal)
{ {
RenderDecal::RenderDecals(curline->sidedef, draw_segment, wallshade, rw_lightleft, rw_lightstep, curline, WallC, foggy); RenderDecal::RenderDecals(curline->sidedef, draw_segment, wallshade, rw_lightleft, rw_lightstep, curline, WallC, foggy, basecolormap);
} }
if (rw_markportal) if (rw_markportal)
@ -1079,7 +1080,7 @@ namespace swrenderer
{ {
rw_offset = -rw_offset; rw_offset = -rw_offset;
} }
R_DrawWallSegment(frontsector, curline, WallC, rw_pic, x1, x2, walltop, wallbottom, swall, lwall, yscale, MAX(rw_frontcz1, rw_frontcz2), MIN(rw_frontfz1, rw_frontfz2), false, wallshade, rw_offset, rw_light, rw_lightstep, light_list, foggy); R_DrawWallSegment(frontsector, curline, WallC, rw_pic, x1, x2, walltop, wallbottom, swall, lwall, yscale, MAX(rw_frontcz1, rw_frontcz2), MIN(rw_frontfz1, rw_frontfz2), false, wallshade, rw_offset, rw_light, rw_lightstep, light_list, foggy, basecolormap);
} }
fillshort(ceilingclip + x1, x2 - x1, viewheight); fillshort(ceilingclip + x1, x2 - x1, viewheight);
fillshort(floorclip + x1, x2 - x1, 0xffff); fillshort(floorclip + x1, x2 - x1, 0xffff);
@ -1115,7 +1116,7 @@ namespace swrenderer
{ {
rw_offset = -rw_offset; rw_offset = -rw_offset;
} }
R_DrawWallSegment(frontsector, curline, WallC, rw_pic, x1, x2, walltop, wallupper, swall, lwall, yscale, MAX(rw_frontcz1, rw_frontcz2), MIN(rw_backcz1, rw_backcz2), false, wallshade, rw_offset, rw_light, rw_lightstep, light_list, foggy); R_DrawWallSegment(frontsector, curline, WallC, rw_pic, x1, x2, walltop, wallupper, swall, lwall, yscale, MAX(rw_frontcz1, rw_frontcz2), MIN(rw_backcz1, rw_backcz2), false, wallshade, rw_offset, rw_light, rw_lightstep, light_list, foggy, basecolormap);
} }
memcpy(ceilingclip + x1, wallupper + x1, (x2 - x1) * sizeof(short)); memcpy(ceilingclip + x1, wallupper + x1, (x2 - x1) * sizeof(short));
} }
@ -1154,7 +1155,7 @@ namespace swrenderer
{ {
rw_offset = -rw_offset; rw_offset = -rw_offset;
} }
R_DrawWallSegment(frontsector, curline, WallC, rw_pic, x1, x2, walllower, wallbottom, swall, lwall, yscale, MAX(rw_backfz1, rw_backfz2), MIN(rw_frontfz1, rw_frontfz2), false, wallshade, rw_offset, rw_light, rw_lightstep, light_list, foggy); R_DrawWallSegment(frontsector, curline, WallC, rw_pic, x1, x2, walllower, wallbottom, swall, lwall, yscale, MAX(rw_backfz1, rw_backfz2), MIN(rw_frontfz1, rw_frontfz2), false, wallshade, rw_offset, rw_light, rw_lightstep, light_list, foggy, basecolormap);
} }
memcpy(floorclip + x1, walllower + x1, (x2 - x1) * sizeof(short)); memcpy(floorclip + x1, walllower + x1, (x2 - x1) * sizeof(short));
} }

View file

@ -20,6 +20,7 @@ struct subsector_t;
struct sector_t; struct sector_t;
struct side_t; struct side_t;
struct line_t; struct line_t;
struct FDynamicColormap;
namespace swrenderer namespace swrenderer
{ {
@ -48,7 +49,7 @@ namespace swrenderer
class SWRenderLine class SWRenderLine
{ {
public: public:
void Render(seg_t *line, subsector_t *subsector, sector_t *sector, sector_t *fakebacksector, visplane_t *floorplane, visplane_t *ceilingplane, bool foggy); void Render(seg_t *line, subsector_t *subsector, sector_t *sector, sector_t *fakebacksector, visplane_t *floorplane, visplane_t *ceilingplane, bool foggy, FDynamicColormap *basecolormap);
private: private:
bool RenderWallSegment(int x1, int x2); bool RenderWallSegment(int x1, int x2);
@ -118,5 +119,6 @@ namespace swrenderer
FTexture *midtexture; FTexture *midtexture;
bool foggy; bool foggy;
FDynamicColormap *basecolormap;
}; };
} }

View file

@ -337,7 +337,7 @@ namespace swrenderer
static void ProcessWallWorker( static void ProcessWallWorker(
const FWallCoords &WallC, const FWallCoords &WallC,
int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, FDynamicColormap *basecolormap,
const BYTE *(*getcol)(FTexture *tex, int x), DrawerFunc drawcolumn) const BYTE *(*getcol)(FTexture *tex, int x), DrawerFunc drawcolumn)
{ {
if (rw_pic->UseType == FTexture::TEX_Null) if (rw_pic->UseType == FTexture::TEX_Null)
@ -400,41 +400,39 @@ namespace swrenderer
NetUpdate(); NetUpdate();
} }
static void ProcessNormalWall(const FWallCoords &WallC, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, const BYTE *(*getcol)(FTexture *tex, int x) = R_GetColumn) static void ProcessNormalWall(const FWallCoords &WallC, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, FDynamicColormap *basecolormap, const BYTE *(*getcol)(FTexture *tex, int x) = R_GetColumn)
{ {
ProcessWallWorker(WallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, getcol, &SWPixelFormatDrawers::DrawWallColumn); ProcessWallWorker(WallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, getcol, &SWPixelFormatDrawers::DrawWallColumn);
} }
static void ProcessMaskedWall(const FWallCoords &WallC, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, const BYTE *(*getcol)(FTexture *tex, int x) = R_GetColumn) static void ProcessMaskedWall(const FWallCoords &WallC, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, FDynamicColormap *basecolormap, const BYTE *(*getcol)(FTexture *tex, int x) = R_GetColumn)
{ {
if (!rw_pic->bMasked) // Textures that aren't masked can use the faster ProcessNormalWall. if (!rw_pic->bMasked) // Textures that aren't masked can use the faster ProcessNormalWall.
{ {
ProcessNormalWall(WallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, getcol); ProcessNormalWall(WallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, getcol);
} }
else else
{ {
ProcessWallWorker(WallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, getcol, &SWPixelFormatDrawers::DrawWallMaskedColumn); ProcessWallWorker(WallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, getcol, &SWPixelFormatDrawers::DrawWallMaskedColumn);
} }
} }
static void ProcessTranslucentWall(const FWallCoords &WallC, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, const BYTE *(*getcol)(FTexture *tex, int x) = R_GetColumn) static void ProcessTranslucentWall(const FWallCoords &WallC, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, FDynamicColormap *basecolormap, const BYTE *(*getcol)(FTexture *tex, int x) = R_GetColumn)
{ {
DrawerFunc drawcol1 = R_GetTransMaskDrawer(); DrawerFunc drawcol1 = R_GetTransMaskDrawer();
if (drawcol1 == nullptr) if (drawcol1 == nullptr)
{ {
// The current translucency is unsupported, so draw with regular ProcessMaskedWall instead. // The current translucency is unsupported, so draw with regular ProcessMaskedWall instead.
ProcessMaskedWall(WallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, getcol); ProcessMaskedWall(WallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, getcol);
} }
else else
{ {
ProcessWallWorker(WallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, getcol, drawcol1); ProcessWallWorker(WallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, getcol, drawcol1);
} }
} }
static void ProcessStripedWall(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, bool foggy) static void ProcessStripedWall(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, bool foggy, FDynamicColormap *basecolormap)
{ {
FDynamicColormap *startcolormap = basecolormap;
short most1[MAXWIDTH], most2[MAXWIDTH], most3[MAXWIDTH]; short most1[MAXWIDTH], most2[MAXWIDTH], most3[MAXWIDTH];
short *up, *down; short *up, *down;
@ -456,7 +454,7 @@ namespace swrenderer
{ {
down[j] = clamp(most3[j], up[j], dwal[j]); down[j] = clamp(most3[j], up[j], dwal[j]);
} }
ProcessNormalWall(WallC, x1, x2, up, down, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep); ProcessNormalWall(WallC, x1, x2, up, down, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap);
up = down; up = down;
down = (down == most1) ? most2 : most1; down = (down == most1) ? most2 : most1;
} }
@ -466,32 +464,31 @@ namespace swrenderer
wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, *lit->p_lightlevel, lit->lightsource != NULL) + R_ActualExtraLight(foggy)); wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, *lit->p_lightlevel, lit->lightsource != NULL) + R_ActualExtraLight(foggy));
} }
ProcessNormalWall(WallC, x1, x2, up, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep); ProcessNormalWall(WallC, x1, x2, up, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap);
basecolormap = startcolormap;
} }
static void ProcessWall(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, bool mask, bool foggy) static void ProcessWall(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, bool mask, bool foggy, FDynamicColormap *basecolormap)
{ {
if (mask) if (mask)
{ {
if (colfunc == basecolfunc) if (colfunc == basecolfunc)
{ {
ProcessMaskedWall(WallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep); ProcessMaskedWall(WallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap);
} }
else else
{ {
ProcessTranslucentWall(WallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep); ProcessTranslucentWall(WallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap);
} }
} }
else else
{ {
if (fixedcolormap != NULL || fixedlightlev >= 0 || !(frontsector->e && frontsector->e->XFloor.lightlist.Size())) if (fixedcolormap != NULL || fixedlightlev >= 0 || !(frontsector->e && frontsector->e->XFloor.lightlist.Size()))
{ {
ProcessNormalWall(WallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep); ProcessNormalWall(WallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap);
} }
else else
{ {
ProcessStripedWall(frontsector, curline, WallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, foggy); ProcessStripedWall(frontsector, curline, WallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, foggy, basecolormap);
} }
} }
} }
@ -507,7 +504,7 @@ namespace swrenderer
// //
//============================================================================= //=============================================================================
static void ProcessWallNP2(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, double top, double bot, int wallshade, fixed_t xoffset, float light, float lightstep, bool mask, bool foggy) static void ProcessWallNP2(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, double top, double bot, int wallshade, fixed_t xoffset, float light, float lightstep, bool mask, bool foggy, FDynamicColormap *basecolormap)
{ {
short most1[MAXWIDTH], most2[MAXWIDTH], most3[MAXWIDTH]; short most1[MAXWIDTH], most2[MAXWIDTH], most3[MAXWIDTH];
short *up, *down; short *up, *down;
@ -534,14 +531,14 @@ namespace swrenderer
{ {
down[j] = clamp(most3[j], up[j], dwal[j]); down[j] = clamp(most3[j], up[j], dwal[j]);
} }
ProcessWall(frontsector, curline, WallC, x1, x2, up, down, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, mask, foggy); ProcessWall(frontsector, curline, WallC, x1, x2, up, down, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, mask, foggy, basecolormap);
up = down; up = down;
down = (down == most1) ? most2 : most1; down = (down == most1) ? most2 : most1;
} }
partition -= scaledtexheight; partition -= scaledtexheight;
dc_texturemid -= texheight; dc_texturemid -= texheight;
} }
ProcessWall(frontsector, curline, WallC, x1, x2, up, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, mask, foggy); ProcessWall(frontsector, curline, WallC, x1, x2, up, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, mask, foggy, basecolormap);
} }
else else
{ // upside down: draw strips from bottom to top { // upside down: draw strips from bottom to top
@ -558,18 +555,18 @@ namespace swrenderer
{ {
up[j] = clamp(most3[j], uwal[j], down[j]); up[j] = clamp(most3[j], uwal[j], down[j]);
} }
ProcessWall(frontsector, curline, WallC, x1, x2, up, down, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, mask, foggy); ProcessWall(frontsector, curline, WallC, x1, x2, up, down, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, mask, foggy, basecolormap);
down = up; down = up;
up = (up == most1) ? most2 : most1; up = (up == most1) ? most2 : most1;
} }
partition -= scaledtexheight; partition -= scaledtexheight;
dc_texturemid -= texheight; dc_texturemid -= texheight;
} }
ProcessWall(frontsector, curline, WallC, x1, x2, uwal, down, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, mask, foggy); ProcessWall(frontsector, curline, WallC, x1, x2, uwal, down, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, mask, foggy, basecolormap);
} }
} }
void R_DrawDrawSeg(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, FTexture *pic, drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, bool foggy) void R_DrawDrawSeg(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, FTexture *pic, drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, bool foggy, FDynamicColormap *basecolormap)
{ {
rw_pic = pic; rw_pic = pic;
if (rw_pic->GetHeight() != 1 << rw_pic->HeightBits) if (rw_pic->GetHeight() != 1 << rw_pic->HeightBits)
@ -589,34 +586,34 @@ namespace swrenderer
{ {
bot = MAX(bot, clip3d->sclipBottom); bot = MAX(bot, clip3d->sclipBottom);
} }
ProcessWallNP2(frontsector, curline, WallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, top, bot, wallshade, xoffset, light, lightstep, true, foggy); ProcessWallNP2(frontsector, curline, WallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, top, bot, wallshade, xoffset, light, lightstep, true, foggy, basecolormap);
} }
else else
{ {
ProcessWall(frontsector, curline, WallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, true, foggy); ProcessWall(frontsector, curline, WallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, true, foggy, basecolormap);
} }
} }
void R_DrawWallSegment(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, FTexture *pic, int x1, int x2, short *walltop, short *wallbottom, float *swall, fixed_t *lwall, double yscale, double top, double bottom, bool mask, int wallshade, fixed_t xoffset, float light, float lightstep, FLightNode *light_list, bool foggy) void R_DrawWallSegment(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, FTexture *pic, int x1, int x2, short *walltop, short *wallbottom, float *swall, fixed_t *lwall, double yscale, double top, double bottom, bool mask, int wallshade, fixed_t xoffset, float light, float lightstep, FLightNode *light_list, bool foggy, FDynamicColormap *basecolormap)
{ {
rw_pic = pic; rw_pic = pic;
dc_light_list = light_list; dc_light_list = light_list;
if (rw_pic->GetHeight() != 1 << rw_pic->HeightBits) if (rw_pic->GetHeight() != 1 << rw_pic->HeightBits)
{ {
ProcessWallNP2(frontsector, curline, WallC, x1, x2, walltop, wallbottom, swall, lwall, yscale, top, bottom, wallshade, xoffset, light, lightstep, false, foggy); ProcessWallNP2(frontsector, curline, WallC, x1, x2, walltop, wallbottom, swall, lwall, yscale, top, bottom, wallshade, xoffset, light, lightstep, false, foggy, basecolormap);
} }
else else
{ {
ProcessWall(frontsector, curline, WallC, x1, x2, walltop, wallbottom, swall, lwall, yscale, wallshade, xoffset, light, lightstep, false, foggy); ProcessWall(frontsector, curline, WallC, x1, x2, walltop, wallbottom, swall, lwall, yscale, wallshade, xoffset, light, lightstep, false, foggy, basecolormap);
} }
dc_light_list = nullptr; dc_light_list = nullptr;
} }
void R_DrawSkySegment(FTexture *pic, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, const uint8_t *(*getcol)(FTexture *tex, int x)) void R_DrawSkySegment(FTexture *pic, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, FDynamicColormap *basecolormap, const uint8_t *(*getcol)(FTexture *tex, int x))
{ {
rw_pic = pic; rw_pic = pic;
FWallCoords wallC; // Not used. To do: don't use r_walldraw to draw the sky!! FWallCoords wallC; // Not used. To do: don't use r_walldraw to draw the sky!!
ProcessNormalWall(wallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, getcol); ProcessNormalWall(wallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, getcol);
} }
} }

View file

@ -37,7 +37,7 @@ namespace swrenderer
uint32_t height; uint32_t height;
}; };
void R_DrawWallSegment(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, FTexture *rw_pic, int x1, int x2, short *walltop, short *wallbottom, float *swall, fixed_t *lwall, double yscale, double top, double bottom, bool mask, int wallshade, fixed_t xoffset, float light, float lightstep, FLightNode *light_list, bool foggy); void R_DrawWallSegment(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, FTexture *rw_pic, int x1, int x2, short *walltop, short *wallbottom, float *swall, fixed_t *lwall, double yscale, double top, double bottom, bool mask, int wallshade, fixed_t xoffset, float light, float lightstep, FLightNode *light_list, bool foggy, FDynamicColormap *basecolormap);
void R_DrawSkySegment(FTexture *rw_pic, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, const uint8_t *(*getcol)(FTexture *tex, int col)); void R_DrawSkySegment(FTexture *rw_pic, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, FDynamicColormap *basecolormap, const uint8_t *(*getcol)(FTexture *tex, int col));
void R_DrawDrawSeg(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, FTexture *rw_pic, drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, bool foggy); void R_DrawDrawSeg(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, FTexture *rw_pic, drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, bool foggy, FDynamicColormap *basecolormap);
} }

View file

@ -44,7 +44,7 @@
namespace swrenderer namespace swrenderer
{ {
void RenderFlatPlane::Render(visplane_t *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked) void RenderFlatPlane::Render(visplane_t *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked, FDynamicColormap *colormap)
{ {
using namespace drawerargs; using namespace drawerargs;
@ -105,6 +105,7 @@ namespace swrenderer
planeheight = fabs(pl->height.Zat0() - ViewPos.Z); planeheight = fabs(pl->height.Zat0() - ViewPos.Z);
basecolormap = colormap;
GlobVis = r_FloorVisibility / planeheight; GlobVis = r_FloorVisibility / planeheight;
ds_light = 0; ds_light = 0;
if (fixedlightlev >= 0) if (fixedlightlev >= 0)

View file

@ -22,7 +22,7 @@ namespace swrenderer
class RenderFlatPlane : PlaneRenderer class RenderFlatPlane : PlaneRenderer
{ {
public: public:
void Render(visplane_t *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked); void Render(visplane_t *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked, FDynamicColormap *basecolormap);
static void SetupSlope(); static void SetupSlope();
@ -34,6 +34,7 @@ namespace swrenderer
bool plane_shade; bool plane_shade;
int planeshade; int planeshade;
double GlobVis; double GlobVis;
FDynamicColormap *basecolormap;
fixed_t pviewx, pviewy; fixed_t pviewx, pviewy;
fixed_t xscale, yscale; fixed_t xscale, yscale;
double xstepscale, ystepscale; double xstepscale, ystepscale;

View file

@ -446,7 +446,7 @@ namespace swrenderer
lastskycol_bgra[x] = 0xffffffff; lastskycol_bgra[x] = 0xffffffff;
} }
R_DrawSkySegment(frontskytex, pl->left, pl->right, (short *)pl->top, (short *)pl->bottom, swall, lwall, R_DrawSkySegment(frontskytex, pl->left, pl->right, (short *)pl->top, (short *)pl->bottom, swall, lwall,
frontyScale, 0, 0, 0.0f, 0.0f, backskytex == NULL ? RenderSkyPlane::GetOneSkyColumn : RenderSkyPlane::GetTwoSkyColumns); frontyScale, 0, 0, 0.0f, 0.0f, nullptr, backskytex == nullptr ? RenderSkyPlane::GetOneSkyColumn : RenderSkyPlane::GetTwoSkyColumns);
} }
else else
{ // The texture does not tile nicely { // The texture does not tile nicely
@ -483,7 +483,7 @@ namespace swrenderer
lastskycol[x] = 0xffffffff; lastskycol[x] = 0xffffffff;
lastskycol_bgra[x] = 0xffffffff; lastskycol_bgra[x] = 0xffffffff;
} }
R_DrawSkySegment(frontskytex, pl->left, pl->right, top, bot, swall, lwall, frontskytex->Scale.Y, 0, 0, 0.0f, 0.0f, backskytex == NULL ? RenderSkyPlane::GetOneSkyColumn : RenderSkyPlane::GetTwoSkyColumns); R_DrawSkySegment(frontskytex, pl->left, pl->right, top, bot, swall, lwall, frontskytex->Scale.Y, 0, 0, 0.0f, 0.0f, nullptr, backskytex == nullptr ? RenderSkyPlane::GetOneSkyColumn : RenderSkyPlane::GetTwoSkyColumns);
yl = yh; yl = yh;
yh += drawheight; yh += drawheight;
dc_texturemid = iscale * (centery - yl - 1); dc_texturemid = iscale * (centery - yl - 1);

View file

@ -48,7 +48,7 @@
namespace swrenderer namespace swrenderer
{ {
void RenderSlopePlane::Render(visplane_t *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked) void RenderSlopePlane::Render(visplane_t *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked, FDynamicColormap *colormap)
{ {
using namespace drawerargs; using namespace drawerargs;
@ -148,6 +148,8 @@ namespace swrenderer
if (pl->height.fC() > 0) if (pl->height.fC() > 0)
planelightfloat = -planelightfloat; planelightfloat = -planelightfloat;
basecolormap = colormap;
if (fixedlightlev >= 0) if (fixedlightlev >= 0)
{ {
R_SetDSColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev)); R_SetDSColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev));
@ -180,6 +182,6 @@ namespace swrenderer
void RenderSlopePlane::RenderLine(int y, int x1, int x2) void RenderSlopePlane::RenderLine(int y, int x1, int x2)
{ {
R_Drawers()->DrawTiltedSpan(y, x1, x2, plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy); R_Drawers()->DrawTiltedSpan(y, x1, x2, plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy, basecolormap);
} }
} }

View file

@ -20,7 +20,7 @@ namespace swrenderer
class RenderSlopePlane : PlaneRenderer class RenderSlopePlane : PlaneRenderer
{ {
public: public:
void Render(visplane_t *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked); void Render(visplane_t *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked, FDynamicColormap *basecolormap);
private: private:
void RenderLine(int y, int x1, int x2) override; void RenderLine(int y, int x1, int x2) override;
@ -31,5 +31,6 @@ namespace swrenderer
int planeshade; int planeshade;
fixed_t pviewx, pviewy; fixed_t pviewx, pviewy;
fixed_t xscale, yscale; fixed_t xscale, yscale;
FDynamicColormap *basecolormap;
}; };
} }

View file

@ -108,17 +108,15 @@ namespace swrenderer
double xscale = xform.xScale * tex->Scale.X; double xscale = xform.xScale * tex->Scale.X;
double yscale = xform.yScale * tex->Scale.Y; double yscale = xform.yScale * tex->Scale.Y;
basecolormap = colormap;
if (!height.isSlope() && !tilt) if (!height.isSlope() && !tilt)
{ {
RenderFlatPlane renderer; RenderFlatPlane renderer;
renderer.Render(this, xscale, yscale, alpha, additive, masked); renderer.Render(this, xscale, yscale, alpha, additive, masked, colormap);
} }
else else
{ {
RenderSlopePlane renderer; RenderSlopePlane renderer;
renderer.Render(this, xscale, yscale, alpha, additive, masked); renderer.Render(this, xscale, yscale, alpha, additive, masked, colormap);
} }
} }
NetUpdate(); NetUpdate();

View file

@ -165,7 +165,7 @@ namespace swrenderer
} }
} }
visplane_t *VisiblePlaneList::FindPlane(const secplane_t &height, FTextureID picnum, int lightlevel, double Alpha, bool additive, const FTransform &xxform, int sky, FSectorPortal *portal) visplane_t *VisiblePlaneList::FindPlane(const secplane_t &height, FTextureID picnum, int lightlevel, double Alpha, bool additive, const FTransform &xxform, int sky, FSectorPortal *portal, FDynamicColormap *basecolormap)
{ {
secplane_t plane; secplane_t plane;
visplane_t *check; visplane_t *check;

View file

@ -31,7 +31,7 @@ namespace swrenderer
void Deinit(); void Deinit();
void Clear(bool fullclear); void Clear(bool fullclear);
visplane_t *FindPlane(const secplane_t &height, FTextureID picnum, int lightlevel, double Alpha, bool additive, const FTransform &xxform, int sky, FSectorPortal *portal); visplane_t *FindPlane(const secplane_t &height, FTextureID picnum, int lightlevel, double Alpha, bool additive, const FTransform &xxform, int sky, FSectorPortal *portal, FDynamicColormap *basecolormap);
visplane_t *GetRange(visplane_t *pl, int start, int stop); visplane_t *GetRange(visplane_t *pl, int start, int stop);
int Render(); int Render();

View file

@ -45,7 +45,6 @@ namespace swrenderer
double r_SpriteVisibility; double r_SpriteVisibility;
double r_ParticleVisibility; double r_ParticleVisibility;
FDynamicColormap *basecolormap; // [RH] colormap currently drawing with
int fixedlightlev; int fixedlightlev;
FSWColormap *fixedcolormap; FSWColormap *fixedcolormap;
FSpecialColormap *realfixedcolormap; FSpecialColormap *realfixedcolormap;

View file

@ -60,7 +60,6 @@ namespace swrenderer
extern int fixedlightlev; extern int fixedlightlev;
extern FSWColormap *fixedcolormap; extern FSWColormap *fixedcolormap;
extern FSpecialColormap *realfixedcolormap; extern FSpecialColormap *realfixedcolormap;
extern FDynamicColormap *basecolormap; // [RH] Colormap for sector currently being drawn
inline int R_ActualExtraLight(bool fog) { return fog ? 0 : extralight << 4; } inline int R_ActualExtraLight(bool fog) { return fog ? 0 : extralight << 4; }

View file

@ -398,7 +398,7 @@ namespace swrenderer
} }
// kg3D - add fake segs, never rendered // kg3D - add fake segs, never rendered
void RenderOpaquePass::FakeDrawLoop(subsector_t *sub, visplane_t *floorplane, visplane_t *ceilingplane, bool foggy) void RenderOpaquePass::FakeDrawLoop(subsector_t *sub, visplane_t *floorplane, visplane_t *ceilingplane, bool foggy, FDynamicColormap *basecolormap)
{ {
int count; int count;
seg_t* line; seg_t* line;
@ -410,7 +410,7 @@ namespace swrenderer
{ {
if ((line->sidedef) && !(line->sidedef->Flags & WALLF_POLYOBJ)) if ((line->sidedef) && !(line->sidedef->Flags & WALLF_POLYOBJ))
{ {
renderline.Render(line, InSubsector, frontsector, nullptr, floorplane, ceilingplane, foggy); renderline.Render(line, InSubsector, frontsector, nullptr, floorplane, ceilingplane, foggy, basecolormap);
} }
line++; line++;
} }
@ -479,6 +479,7 @@ namespace swrenderer
bool foggy = level.fadeto || frontsector->ColorMap->Fade || (level.flags & LEVEL_HASFADETABLE); bool foggy = level.fadeto || frontsector->ColorMap->Fade || (level.flags & LEVEL_HASFADETABLE);
// kg3D - fake lights // kg3D - fake lights
FDynamicColormap *basecolormap;
if (fixedlightlev < 0 && frontsector->e && frontsector->e->XFloor.lightlist.Size()) if (fixedlightlev < 0 && frontsector->e && frontsector->e->XFloor.lightlist.Size())
{ {
light = P_GetPlaneLight(frontsector, &frontsector->ceilingplane, false); light = P_GetPlaneLight(frontsector, &frontsector->ceilingplane, false);
@ -510,7 +511,8 @@ namespace swrenderer
!!(frontsector->GetFlags(sector_t::ceiling) & PLANEF_ADDITIVE), !!(frontsector->GetFlags(sector_t::ceiling) & PLANEF_ADDITIVE),
frontsector->planes[sector_t::ceiling].xform, frontsector->planes[sector_t::ceiling].xform,
frontsector->sky, frontsector->sky,
portal portal,
basecolormap
) : nullptr; ) : nullptr;
if (ceilingplane) if (ceilingplane)
@ -550,7 +552,8 @@ namespace swrenderer
!!(frontsector->GetFlags(sector_t::floor) & PLANEF_ADDITIVE), !!(frontsector->GetFlags(sector_t::floor) & PLANEF_ADDITIVE),
frontsector->planes[sector_t::floor].xform, frontsector->planes[sector_t::floor].xform,
frontsector->sky, frontsector->sky,
portal portal,
basecolormap
) : nullptr; ) : nullptr;
if (floorplane) if (floorplane)
@ -615,12 +618,13 @@ namespace swrenderer
!!(clip3d->fakeFloor->flags & FF_ADDITIVETRANS), !!(clip3d->fakeFloor->flags & FF_ADDITIVETRANS),
frontsector->planes[position].xform, frontsector->planes[position].xform,
frontsector->sky, frontsector->sky,
nullptr); nullptr,
basecolormap);
if (floorplane) if (floorplane)
floorplane->AddLights(frontsector->lighthead); floorplane->AddLights(frontsector->lighthead);
FakeDrawLoop(sub, floorplane, ceilingplane, foggy); FakeDrawLoop(sub, floorplane, ceilingplane, foggy, basecolormap);
clip3d->fake3D = 0; clip3d->fake3D = 0;
frontsector = sub->sector; frontsector = sub->sector;
} }
@ -680,12 +684,13 @@ namespace swrenderer
!!(clip3d->fakeFloor->flags & FF_ADDITIVETRANS), !!(clip3d->fakeFloor->flags & FF_ADDITIVETRANS),
frontsector->planes[position].xform, frontsector->planes[position].xform,
frontsector->sky, frontsector->sky,
nullptr); nullptr,
basecolormap);
if (ceilingplane) if (ceilingplane)
ceilingplane->AddLights(frontsector->lighthead); ceilingplane->AddLights(frontsector->lighthead);
FakeDrawLoop(sub, floorplane, ceilingplane, foggy); FakeDrawLoop(sub, floorplane, ceilingplane, foggy, basecolormap);
clip3d->fake3D = 0; clip3d->fake3D = 0;
frontsector = sub->sector; frontsector = sub->sector;
} }
@ -704,7 +709,7 @@ namespace swrenderer
// lightlevels on floor & ceiling lightlevels in the surrounding area. // lightlevels on floor & ceiling lightlevels in the surrounding area.
// [RH] Handle sprite lighting like Duke 3D: If the ceiling is a sky, sprites are lit by // [RH] Handle sprite lighting like Duke 3D: If the ceiling is a sky, sprites are lit by
// it, otherwise they are lit by the floor. // it, otherwise they are lit by the floor.
AddSprites(sub->sector, frontsector->GetTexture(sector_t::ceiling) == skyflatnum ? ceilinglightlevel : floorlightlevel, FakeSide, foggy); AddSprites(sub->sector, frontsector->GetTexture(sector_t::ceiling) == skyflatnum ? ceilinglightlevel : floorlightlevel, FakeSide, foggy, basecolormap);
// [RH] Add particles // [RH] Add particles
if ((unsigned int)(sub - subsectors) < (unsigned int)numsubsectors) if ((unsigned int)(sub - subsectors) < (unsigned int)numsubsectors)
@ -746,14 +751,14 @@ namespace swrenderer
clip3d->fakeFloor->validcount = validcount; clip3d->fakeFloor->validcount = validcount;
clip3d->NewClip(); clip3d->NewClip();
} }
renderline.Render(line, InSubsector, frontsector, &tempsec, floorplane, ceilingplane, foggy); // fake renderline.Render(line, InSubsector, frontsector, &tempsec, floorplane, ceilingplane, foggy, basecolormap); // fake
} }
clip3d->fakeFloor = nullptr; clip3d->fakeFloor = nullptr;
clip3d->fake3D = 0; clip3d->fake3D = 0;
floorplane = backupfp; floorplane = backupfp;
ceilingplane = backupcp; ceilingplane = backupcp;
} }
renderline.Render(line, InSubsector, frontsector, nullptr, floorplane, ceilingplane, foggy); // now real renderline.Render(line, InSubsector, frontsector, nullptr, floorplane, ceilingplane, foggy, basecolormap); // now real
} }
line++; line++;
} }
@ -809,7 +814,7 @@ namespace swrenderer
fillshort(ceilingclip, viewwidth, !screen->Accel2D && ConBottom > viewwindowy && !bRenderingToCanvas ? (ConBottom - viewwindowy) : 0); fillshort(ceilingclip, viewwidth, !screen->Accel2D && ConBottom > viewwindowy && !bRenderingToCanvas ? (ConBottom - viewwindowy) : 0);
} }
void RenderOpaquePass::AddSprites(sector_t *sec, int lightlevel, WaterFakeSide fakeside, bool foggy) void RenderOpaquePass::AddSprites(sector_t *sec, int lightlevel, WaterFakeSide fakeside, bool foggy, FDynamicColormap *basecolormap)
{ {
F3DFloor *fakeceiling = nullptr; F3DFloor *fakeceiling = nullptr;
F3DFloor *fakefloor = nullptr; F3DFloor *fakefloor = nullptr;
@ -869,15 +874,15 @@ namespace swrenderer
{ {
if ((sprite.renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE) if ((sprite.renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE)
{ {
RenderWallSprite::Project(thing, sprite.pos, sprite.picnum, sprite.spriteScale, sprite.renderflags, spriteshade, foggy); RenderWallSprite::Project(thing, sprite.pos, sprite.picnum, sprite.spriteScale, sprite.renderflags, spriteshade, foggy, basecolormap);
} }
else if (sprite.voxel) else if (sprite.voxel)
{ {
RenderVoxel::Project(thing, sprite.pos, sprite.voxel, sprite.spriteScale, sprite.renderflags, fakeside, fakefloor, fakeceiling, sec, spriteshade, foggy); RenderVoxel::Project(thing, sprite.pos, sprite.voxel, sprite.spriteScale, sprite.renderflags, fakeside, fakefloor, fakeceiling, sec, spriteshade, foggy, basecolormap);
} }
else else
{ {
RenderSprite::Project(thing, sprite.pos, sprite.tex, sprite.spriteScale, sprite.renderflags, fakeside, fakefloor, fakeceiling, sec, spriteshade, foggy); RenderSprite::Project(thing, sprite.pos, sprite.tex, sprite.spriteScale, sprite.renderflags, fakeside, fakefloor, fakeceiling, sec, spriteshade, foggy, basecolormap);
} }
} }
} }

View file

@ -68,9 +68,9 @@ namespace swrenderer
bool CheckBBox(float *bspcoord); bool CheckBBox(float *bspcoord);
void AddPolyobjs(subsector_t *sub); void AddPolyobjs(subsector_t *sub);
void FakeDrawLoop(subsector_t *sub, visplane_t *floorplane, visplane_t *ceilingplane, bool foggy); void FakeDrawLoop(subsector_t *sub, visplane_t *floorplane, visplane_t *ceilingplane, bool foggy, FDynamicColormap *basecolormap);
void AddSprites(sector_t *sec, int lightlevel, WaterFakeSide fakeside, bool foggy); void AddSprites(sector_t *sec, int lightlevel, WaterFakeSide fakeside, bool foggy, FDynamicColormap *basecolormap);
static bool IsPotentiallyVisible(AActor *thing); static bool IsPotentiallyVisible(AActor *thing);
static bool GetThingSprite(AActor *thing, ThingSprite &sprite); static bool GetThingSprite(AActor *thing, ThingSprite &sprite);

View file

@ -147,8 +147,9 @@ namespace swrenderer
curline = ds->curline; curline = ds->curline;
FDynamicColormap *patchstylecolormap = nullptr;
bool visible = R_SetPatchStyle(LegacyRenderStyles[curline->linedef->flags & ML_ADDTRANS ? STYLE_Add : STYLE_Translucent], bool visible = R_SetPatchStyle(LegacyRenderStyles[curline->linedef->flags & ML_ADDTRANS ? STYLE_Add : STYLE_Translucent],
(float)MIN(curline->linedef->alpha, 1.), 0, 0); (float)MIN(curline->linedef->alpha, 1.), 0, 0, patchstylecolormap);
if (!visible && !ds->bFogBoundary && !ds->bFakeBoundary) if (!visible && !ds->bFogBoundary && !ds->bFakeBoundary)
{ {
@ -169,7 +170,7 @@ namespace swrenderer
// killough 4/13/98: get correct lightlevel for 2s normal textures // killough 4/13/98: get correct lightlevel for 2s normal textures
sec = RenderOpaquePass::Instance()->FakeFlat(frontsector, &tempsec, nullptr, nullptr, nullptr, 0, 0, 0, 0); sec = RenderOpaquePass::Instance()->FakeFlat(frontsector, &tempsec, nullptr, nullptr, nullptr, 0, 0, 0, 0);
basecolormap = sec->ColorMap; // [RH] Set basecolormap FDynamicColormap *basecolormap = sec->ColorMap; // [RH] Set basecolormap
int wallshade = ds->shade; int wallshade = ds->shade;
rw_lightstep = ds->lightstep; rw_lightstep = ds->lightstep;
@ -202,7 +203,7 @@ namespace swrenderer
// [RH] Draw fog partition // [RH] Draw fog partition
if (ds->bFogBoundary) if (ds->bFogBoundary)
{ {
RenderFogBoundary::Render(x1, x2, mceilingclip, mfloorclip, wallshade, rw_light, rw_lightstep); RenderFogBoundary::Render(x1, x2, mceilingclip, mfloorclip, wallshade, rw_light, rw_lightstep, basecolormap);
if (ds->maskedtexturecol == -1) if (ds->maskedtexturecol == -1)
{ {
goto clearfog; goto clearfog;
@ -420,11 +421,10 @@ namespace swrenderer
rw_offset = 0; rw_offset = 0;
rw_pic = tex; rw_pic = tex;
R_DrawDrawSeg(frontsector, curline, WallC, rw_pic, ds, x1, x2, mceilingclip, mfloorclip, MaskedSWall, maskedtexturecol, ds->yscale, wallshade, rw_offset, rw_light, rw_lightstep, ds->foggy); R_DrawDrawSeg(frontsector, curline, WallC, rw_pic, ds, x1, x2, mceilingclip, mfloorclip, MaskedSWall, maskedtexturecol, ds->yscale, wallshade, rw_offset, rw_light, rw_lightstep, ds->foggy, basecolormap);
} }
clearfog: clearfog:
R_FinishSetPatchStyle();
if (ds->bFakeBoundary & 3) if (ds->bFakeBoundary & 3)
{ {
R_RenderFakeWallRange(ds, x1, x2, wallshade); R_RenderFakeWallRange(ds, x1, x2, wallshade);
@ -448,7 +448,7 @@ namespace swrenderer
} }
// kg3D - render one fake wall // kg3D - render one fake wall
void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover, int wallshade) void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover, int wallshade, FDynamicColormap *basecolormap)
{ {
int i; int i;
double xscale; double xscale;
@ -456,12 +456,10 @@ namespace swrenderer
fixed_t Alpha = Scale(rover->alpha, OPAQUE, 255); fixed_t Alpha = Scale(rover->alpha, OPAQUE, 255);
bool visible = R_SetPatchStyle(LegacyRenderStyles[rover->flags & FF_ADDITIVETRANS ? STYLE_Add : STYLE_Translucent], bool visible = R_SetPatchStyle(LegacyRenderStyles[rover->flags & FF_ADDITIVETRANS ? STYLE_Add : STYLE_Translucent],
Alpha, 0, 0); Alpha, 0, 0, basecolormap);
if (!visible) { if (!visible)
R_FinishSetPatchStyle();
return; return;
}
rw_lightstep = ds->lightstep; rw_lightstep = ds->lightstep;
rw_light = ds->light + (x1 - ds->x1) * rw_lightstep; rw_light = ds->light + (x1 - ds->x1) * rw_lightstep;
@ -547,8 +545,7 @@ namespace swrenderer
} }
PrepLWall(lwall, curline->sidedef->TexelLength*xscale, ds->sx1, ds->sx2, WallT); PrepLWall(lwall, curline->sidedef->TexelLength*xscale, ds->sx1, ds->sx2, WallT);
R_DrawDrawSeg(frontsector, curline, WallC, rw_pic, ds, x1, x2, wallupper, walllower, MaskedSWall, lwall, yscale, wallshade, rw_offset, rw_light, rw_lightstep, ds->foggy); R_DrawDrawSeg(frontsector, curline, WallC, rw_pic, ds, x1, x2, wallupper, walllower, MaskedSWall, lwall, yscale, wallshade, rw_offset, rw_light, rw_lightstep, ds->foggy, basecolormap);
R_FinishSetPatchStyle();
} }
// kg3D - walls of fake floors // kg3D - walls of fake floors
@ -734,7 +731,7 @@ namespace swrenderer
} }
} }
// correct colors now // correct colors now
basecolormap = frontsector->ColorMap; FDynamicColormap *basecolormap = frontsector->ColorMap;
wallshade = ds->shade; wallshade = ds->shade;
if (fixedlightlev < 0) if (fixedlightlev < 0)
{ {
@ -767,7 +764,7 @@ namespace swrenderer
} }
if (rw_pic != DONT_DRAW) if (rw_pic != DONT_DRAW)
{ {
R_RenderFakeWall(ds, x1, x2, fover ? fover : rover, wallshade); R_RenderFakeWall(ds, x1, x2, fover ? fover : rover, wallshade, basecolormap);
} }
else rw_pic = nullptr; else rw_pic = nullptr;
break; break;
@ -908,7 +905,7 @@ namespace swrenderer
} }
} }
// correct colors now // correct colors now
basecolormap = frontsector->ColorMap; FDynamicColormap *basecolormap = frontsector->ColorMap;
wallshade = ds->shade; wallshade = ds->shade;
if (fixedlightlev < 0) if (fixedlightlev < 0)
{ {
@ -942,7 +939,7 @@ namespace swrenderer
if (rw_pic != DONT_DRAW) if (rw_pic != DONT_DRAW)
{ {
R_RenderFakeWall(ds, x1, x2, fover ? fover : rover, wallshade); R_RenderFakeWall(ds, x1, x2, fover ? fover : rover, wallshade, basecolormap);
} }
else else
{ {

View file

@ -60,6 +60,6 @@ namespace swrenderer
drawseg_t *R_AddDrawSegment(); drawseg_t *R_AddDrawSegment();
void ClipMidtex(int x1, int x2); void ClipMidtex(int x1, int x2);
void R_RenderMaskedSegRange(drawseg_t *ds, int x1, int x2); void R_RenderMaskedSegRange(drawseg_t *ds, int x1, int x2);
void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover, int wallshade); void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover, int wallshade, FDynamicColormap *basecolormap);
void R_RenderFakeWallRange(drawseg_t *ds, int x1, int x2, int wallshade); void R_RenderFakeWallRange(drawseg_t *ds, int x1, int x2, int wallshade);
} }

View file

@ -47,11 +47,11 @@ EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor);
namespace swrenderer namespace swrenderer
{ {
void RenderDecal::RenderDecals(side_t *sidedef, drawseg_t *draw_segment, int wallshade, float lightleft, float lightstep, seg_t *curline, const FWallCoords &wallC, bool foggy) void RenderDecal::RenderDecals(side_t *sidedef, drawseg_t *draw_segment, int wallshade, float lightleft, float lightstep, seg_t *curline, const FWallCoords &wallC, bool foggy, FDynamicColormap *basecolormap)
{ {
for (DBaseDecal *decal = sidedef->AttachedDecals; decal != NULL; decal = decal->WallNext) for (DBaseDecal *decal = sidedef->AttachedDecals; decal != NULL; decal = decal->WallNext)
{ {
Render(sidedef, decal, draw_segment, wallshade, lightleft, lightstep, curline, wallC, foggy, 0); Render(sidedef, decal, draw_segment, wallshade, lightleft, lightstep, curline, wallC, foggy, basecolormap, 0);
} }
} }
@ -59,7 +59,7 @@ namespace swrenderer
// = 1: drawing masked textures (including sprites) // = 1: drawing masked textures (including sprites)
// Currently, only pass = 0 is done or used // Currently, only pass = 0 is done or used
void RenderDecal::Render(side_t *wall, DBaseDecal *decal, drawseg_t *clipper, int wallshade, float lightleft, float lightstep, seg_t *curline, FWallCoords WallC, bool foggy, int pass) void RenderDecal::Render(side_t *wall, DBaseDecal *decal, drawseg_t *clipper, int wallshade, float lightleft, float lightstep, seg_t *curline, FWallCoords WallC, bool foggy, FDynamicColormap *basecolormap, int pass)
{ {
DVector2 decal_left, decal_right, decal_pos; DVector2 decal_left, decal_right, decal_pos;
int x1, x2; int x1, x2;
@ -277,7 +277,7 @@ namespace swrenderer
{ {
int x = x1; int x = x1;
bool visible = R_SetPatchStyle(decal->RenderStyle, (float)decal->Alpha, decal->Translation, decal->AlphaColor); bool visible = R_SetPatchStyle(decal->RenderStyle, (float)decal->Alpha, decal->Translation, decal->AlphaColor, basecolormap);
// R_SetPatchStyle can modify basecolormap. // R_SetPatchStyle can modify basecolormap.
if (rereadcolormap) if (rereadcolormap)
@ -304,12 +304,10 @@ namespace swrenderer
// needrepeat will be 0, and the while will fail. // needrepeat will be 0, and the while will fail.
mceilingclip = RenderOpaquePass::Instance()->floorclip; mceilingclip = RenderOpaquePass::Instance()->floorclip;
mfloorclip = wallbottom; mfloorclip = wallbottom;
R_FinishSetPatchStyle();
} while (needrepeat--); } while (needrepeat--);
colfunc = basecolfunc; colfunc = basecolfunc;
R_FinishSetPatchStyle();
done: done:
WallC = savecoord; WallC = savecoord;
} }

View file

@ -23,10 +23,10 @@ namespace swrenderer
class RenderDecal class RenderDecal
{ {
public: public:
static void RenderDecals(side_t *wall, drawseg_t *draw_segment, int wallshade, float lightleft, float lightstep, seg_t *curline, const FWallCoords &wallC, bool foggy); static void RenderDecals(side_t *wall, drawseg_t *draw_segment, int wallshade, float lightleft, float lightstep, seg_t *curline, const FWallCoords &wallC, bool foggy, FDynamicColormap *basecolormap);
private: private:
static void Render(side_t *wall, DBaseDecal *first, drawseg_t *clipper, int wallshade, float lightleft, float lightstep, seg_t *curline, FWallCoords wallC, bool foggy, int pass); static void Render(side_t *wall, DBaseDecal *first, drawseg_t *clipper, int wallshade, float lightleft, float lightstep, seg_t *curline, FWallCoords wallC, bool foggy, FDynamicColormap *basecolormap, int pass);
static void DrawColumn(int x, FTexture *WallSpriteTile, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip); static void DrawColumn(int x, FTexture *WallSpriteTile, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip);
}; };
} }

View file

@ -99,6 +99,7 @@ namespace swrenderer
(r_deathcamera && camera->health <= 0)) (r_deathcamera && camera->health <= 0))
return; return;
FDynamicColormap *basecolormap;
if (fixedlightlev < 0 && viewsector->e && viewsector->e->XFloor.lightlist.Size()) if (fixedlightlev < 0 && viewsector->e && viewsector->e->XFloor.lightlist.Size())
{ {
for (i = viewsector->e->XFloor.lightlist.Size() - 1; i >= 0; i--) for (i = viewsector->e->XFloor.lightlist.Size() - 1; i >= 0; i--)
@ -183,7 +184,7 @@ namespace swrenderer
if ((psp->GetID() != PSP_TARGETCENTER || CrosshairImage == nullptr) && psp->GetCaller() != nullptr) if ((psp->GetID() != PSP_TARGETCENTER || CrosshairImage == nullptr) && psp->GetCaller() != nullptr)
{ {
Render(psp, camera, bobx, boby, wx, wy, r_TicFracF, spriteshade); Render(psp, camera, bobx, boby, wx, wy, r_TicFracF, spriteshade, basecolormap);
} }
psp = psp->GetNext(); psp = psp->GetNext();
@ -193,7 +194,7 @@ namespace swrenderer
} }
} }
void RenderPlayerSprite::Render(DPSprite *pspr, AActor *owner, float bobx, float boby, double wx, double wy, double ticfrac, int spriteshade) void RenderPlayerSprite::Render(DPSprite *pspr, AActor *owner, float bobx, float boby, double wx, double wy, double ticfrac, int spriteshade, FDynamicColormap *basecolormap)
{ {
double tx; double tx;
int x1; int x1;

View file

@ -28,7 +28,7 @@ namespace swrenderer
static void RenderRemainingPlayerSprites(); static void RenderRemainingPlayerSprites();
private: private:
static void Render(DPSprite *pspr, AActor *owner, float bobx, float boby, double wx, double wy, double ticfrac, int spriteshade); static void Render(DPSprite *pspr, AActor *owner, float bobx, float boby, double wx, double wy, double ticfrac, int spriteshade, FDynamicColormap *basecolormap);
enum { BASEXCENTER = 160 }; enum { BASEXCENTER = 160 };
enum { BASEYCENTER = 100 }; enum { BASEYCENTER = 100 };

View file

@ -60,7 +60,7 @@ EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor)
namespace swrenderer namespace swrenderer
{ {
void RenderSprite::Project(AActor *thing, const DVector3 &pos, FTexture *tex, const DVector2 &spriteScale, int renderflags, WaterFakeSide fakeside, F3DFloor *fakefloor, F3DFloor *fakeceiling, sector_t *current_sector, int spriteshade, bool foggy) void RenderSprite::Project(AActor *thing, const DVector3 &pos, FTexture *tex, const DVector2 &spriteScale, int renderflags, WaterFakeSide fakeside, F3DFloor *fakefloor, F3DFloor *fakeceiling, sector_t *current_sector, int spriteshade, bool foggy, FDynamicColormap *basecolormap)
{ {
// transform the origin point // transform the origin point
double tr_x = pos.X - ViewPos.X; double tr_x = pos.X - ViewPos.X;
@ -295,7 +295,9 @@ namespace swrenderer
fixed_t centeryfrac = FLOAT2FIXED(CenterY); fixed_t centeryfrac = FLOAT2FIXED(CenterY);
R_SetColorMapLight(vis->Style.BaseColormap, 0, vis->Style.ColormapNum << FRACBITS); R_SetColorMapLight(vis->Style.BaseColormap, 0, vis->Style.ColormapNum << FRACBITS);
bool visible = R_SetPatchStyle(vis->Style.RenderStyle, vis->Style.Alpha, vis->Translation, vis->FillColor); FDynamicColormap *basecolormap = static_cast<FDynamicColormap*>(vis->Style.BaseColormap);
bool visible = R_SetPatchStyle(vis->Style.RenderStyle, vis->Style.Alpha, vis->Translation, vis->FillColor, basecolormap);
if (vis->Style.RenderStyle == LegacyRenderStyles[STYLE_Shaded]) if (vis->Style.RenderStyle == LegacyRenderStyles[STYLE_Shaded])
{ // 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
@ -343,8 +345,6 @@ namespace swrenderer
} }
} }
R_FinishSetPatchStyle();
NetUpdate(); NetUpdate();
} }
} }

View file

@ -20,7 +20,7 @@ namespace swrenderer
class RenderSprite class RenderSprite
{ {
public: public:
static void Project(AActor *thing, const DVector3 &pos, FTexture *tex, const DVector2 &spriteScale, int renderflags, WaterFakeSide fakeside, F3DFloor *fakefloor, F3DFloor *fakeceiling, sector_t *current_sector, int spriteshade, bool foggy); static void Project(AActor *thing, const DVector3 &pos, FTexture *tex, const DVector2 &spriteScale, int renderflags, WaterFakeSide fakeside, F3DFloor *fakefloor, F3DFloor *fakeceiling, sector_t *current_sector, int spriteshade, bool foggy, FDynamicColormap *basecolormap);
static void Render(vissprite_t *vis, const short *mfloorclip, const short *mceilingclip); static void Render(vissprite_t *vis, const short *mfloorclip, const short *mceilingclip);
}; };
} }

View file

@ -46,7 +46,7 @@ EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor)
namespace swrenderer namespace swrenderer
{ {
void RenderVoxel::Project(AActor *thing, DVector3 pos, FVoxelDef *voxel, const DVector2 &spriteScale, int renderflags, WaterFakeSide fakeside, F3DFloor *fakefloor, F3DFloor *fakeceiling, sector_t *current_sector, int spriteshade, bool foggy) void RenderVoxel::Project(AActor *thing, DVector3 pos, FVoxelDef *voxel, const DVector2 &spriteScale, int renderflags, WaterFakeSide fakeside, F3DFloor *fakefloor, F3DFloor *fakeceiling, sector_t *current_sector, int spriteshade, bool foggy, FDynamicColormap *basecolormap)
{ {
// transform the origin point // transform the origin point
double tr_x = pos.X - ViewPos.X; double tr_x = pos.X - ViewPos.X;
@ -206,6 +206,7 @@ namespace swrenderer
{ {
mybasecolormap = GetSpecialLights(mybasecolormap->Color, mybasecolormap->Fade.InverseColor(), mybasecolormap->Desaturate); mybasecolormap = GetSpecialLights(mybasecolormap->Color, mybasecolormap->Fade.InverseColor(), mybasecolormap->Desaturate);
} }
if (fixedlightlev >= 0) if (fixedlightlev >= 0)
{ {
vis->Style.BaseColormap = mybasecolormap; vis->Style.BaseColormap = mybasecolormap;
@ -226,8 +227,11 @@ namespace swrenderer
void RenderVoxel::Render(vissprite_t *sprite, int minZ, int maxZ, short *cliptop, short *clipbottom) void RenderVoxel::Render(vissprite_t *sprite, int minZ, int maxZ, short *cliptop, short *clipbottom)
{ {
FDynamicColormap *basecolormap = static_cast<FDynamicColormap*>(sprite->Style.BaseColormap);
R_SetColorMapLight(sprite->Style.BaseColormap, 0, sprite->Style.ColormapNum << FRACBITS); R_SetColorMapLight(sprite->Style.BaseColormap, 0, sprite->Style.ColormapNum << FRACBITS);
bool visible = R_SetPatchStyle(sprite->Style.RenderStyle, sprite->Style.Alpha, sprite->Translation, sprite->FillColor);
bool visible = R_SetPatchStyle(sprite->Style.RenderStyle, sprite->Style.Alpha, sprite->Translation, sprite->FillColor, basecolormap);
if (!visible) if (!visible)
return; return;

View file

@ -55,7 +55,7 @@ namespace swrenderer
class RenderVoxel class RenderVoxel
{ {
public: public:
static void Project(AActor *thing, DVector3 pos, FVoxelDef *voxel, const DVector2 &spriteScale, int renderflags, WaterFakeSide fakeside, F3DFloor *fakefloor, F3DFloor *fakeceiling, sector_t *current_sector, int spriteshade, bool foggy); static void Project(AActor *thing, DVector3 pos, FVoxelDef *voxel, const DVector2 &spriteScale, int renderflags, WaterFakeSide fakeside, F3DFloor *fakefloor, F3DFloor *fakeceiling, sector_t *current_sector, int spriteshade, bool foggy, FDynamicColormap *basecolormap);
static void Render(vissprite_t *sprite, int minZ, int maxZ, short *cliptop, short *clipbottom); static void Render(vissprite_t *sprite, int minZ, int maxZ, short *cliptop, short *clipbottom);
static void Deinit(); static void Deinit();

View file

@ -62,7 +62,7 @@ EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor);
namespace swrenderer namespace swrenderer
{ {
void RenderWallSprite::Project(AActor *thing, const DVector3 &pos, FTextureID picnum, const DVector2 &scale, int renderflags, int spriteshade, bool foggy) void RenderWallSprite::Project(AActor *thing, const DVector3 &pos, FTextureID picnum, const DVector2 &scale, int renderflags, int spriteshade, bool foggy, FDynamicColormap *basecolormap)
{ {
FWallCoords wallc; FWallCoords wallc;
double x1, x2; double x1, x2;
@ -165,7 +165,7 @@ namespace swrenderer
} }
// Prepare lighting // Prepare lighting
bool calclighting = false; bool calclighting = false;
FDynamicColormap *usecolormap = basecolormap; FSWColormap *usecolormap = spr->Style.BaseColormap;
bool rereadcolormap = true; bool rereadcolormap = true;
// Decals that are added to the scene must fade to black. // Decals that are added to the scene must fade to black.
@ -206,12 +206,14 @@ namespace swrenderer
int x = x1; int x = x1;
bool visible = R_SetPatchStyle(spr->Style.RenderStyle, spr->Style.Alpha, spr->Translation, spr->FillColor); FDynamicColormap *basecolormap = static_cast<FDynamicColormap*>(spr->Style.BaseColormap);
bool visible = R_SetPatchStyle(spr->Style.RenderStyle, spr->Style.Alpha, spr->Translation, spr->FillColor, basecolormap);
// R_SetPatchStyle can modify basecolormap. // R_SetPatchStyle can modify basecolormap.
if (rereadcolormap) if (rereadcolormap)
{ {
usecolormap = basecolormap; usecolormap = spr->Style.BaseColormap;
} }
if (!visible) if (!visible)
@ -232,7 +234,6 @@ namespace swrenderer
x++; x++;
} }
} }
R_FinishSetPatchStyle();
} }
void RenderWallSprite::DrawColumn(int x, FTexture *WallSpriteTile, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip) void RenderWallSprite::DrawColumn(int x, FTexture *WallSpriteTile, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip)

View file

@ -20,7 +20,7 @@ namespace swrenderer
class RenderWallSprite class RenderWallSprite
{ {
public: public:
static void Project(AActor *thing, const DVector3 &pos, FTextureID picnum, const DVector2 &scale, int renderflags, int spriteshade, bool foggy); static void Project(AActor *thing, const DVector3 &pos, FTextureID picnum, const DVector2 &scale, int renderflags, int spriteshade, bool foggy, FDynamicColormap *basecolormap);
static void Render(vissprite_t *spr, const short *mfloorclip, const short *mceilingclip); static void Render(vissprite_t *spr, const short *mfloorclip, const short *mceilingclip);
private: private:

View file

@ -189,10 +189,11 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms)
fixedcolormap = dc_fcolormap; fixedcolormap = dc_fcolormap;
bool visible; bool visible;
FDynamicColormap *basecolormap = nullptr;
if (r_swtruecolor) if (r_swtruecolor)
visible = R_SetPatchStyle(parms.style, parms.Alpha, -1, parms.fillcolor); visible = R_SetPatchStyle(parms.style, parms.Alpha, -1, parms.fillcolor, basecolormap);
else else
visible = R_SetPatchStyle(parms.style, parms.Alpha, 0, parms.fillcolor); visible = R_SetPatchStyle(parms.style, parms.Alpha, 0, parms.fillcolor, basecolormap);
BYTE *destorgsave = dc_destorg; BYTE *destorgsave = dc_destorg;
int destheightsave = dc_destheight; int destheightsave = dc_destheight;
@ -287,7 +288,6 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms)
CenterY = centeryback; CenterY = centeryback;
} }
R_FinishSetPatchStyle ();
dc_destorg = destorgsave; dc_destorg = destorgsave;
dc_destheight = destheightsave; dc_destheight = destheightsave;