- create a ProjectedWallLight class for the variables used to calculate light for columns

This commit is contained in:
Magnus Norddahl 2018-12-27 22:03:02 +01:00
parent 0a6ec054d2
commit ed094d0b2f
9 changed files with 99 additions and 105 deletions

View file

@ -78,8 +78,8 @@ namespace swrenderer
mBackSector = fakebacksector; mBackSector = fakebacksector;
mFloorPlane = linefloorplane; mFloorPlane = linefloorplane;
mCeilingPlane = lineceilingplane; mCeilingPlane = lineceilingplane;
foggy = infog; mLight.foggy = infog;
basecolormap = colormap; mLight.basecolormap = colormap;
mLineSegment = line; mLineSegment = line;
m3DFloor = opaque3dfloor; m3DFloor = opaque3dfloor;
@ -345,7 +345,7 @@ namespace swrenderer
draw_segment->x1 = start; draw_segment->x1 = start;
draw_segment->x2 = stop; draw_segment->x2 = stop;
draw_segment->curline = mLineSegment; draw_segment->curline = mLineSegment;
draw_segment->foggy = foggy; draw_segment->foggy = mLight.foggy;
draw_segment->SubsectorDepth = Thread->OpaquePass->GetSubsectorDepth(mSubsector->Index()); draw_segment->SubsectorDepth = Thread->OpaquePass->GetSubsectorDepth(mSubsector->Index());
bool markportal = ShouldMarkPortal(); bool markportal = ShouldMarkPortal();
@ -490,8 +490,8 @@ namespace swrenderer
draw_segment->iscalestep = 0; draw_segment->iscalestep = 0;
} }
} }
draw_segment->light = rw_lightleft + rw_lightstep * (start - WallC.sx1); draw_segment->light = mLight.lightleft + mLight.lightstep * (start - WallC.sx1);
draw_segment->lightstep = rw_lightstep; draw_segment->lightstep = mLight.lightstep;
// Masked mMiddlePart.Textures should get the light level from the sector they reference, // Masked mMiddlePart.Textures should get the light level from the sector they reference,
// not from the current subsector, which is what the current lightlevel value // not from the current subsector, which is what the current lightlevel value
@ -499,11 +499,11 @@ namespace swrenderer
// sector should be whichever one they move into. // sector should be whichever one they move into.
if (mLineSegment->sidedef->Flags & WALLF_POLYOBJ) if (mLineSegment->sidedef->Flags & WALLF_POLYOBJ)
{ {
draw_segment->lightlevel = lightlevel; draw_segment->lightlevel = mLight.lightlevel;
} }
else else
{ {
draw_segment->lightlevel = mLineSegment->sidedef->GetLightLevel(foggy, mLineSegment->frontsector->lightlevel); draw_segment->lightlevel = mLineSegment->sidedef->GetLightLevel(mLight.foggy, mLineSegment->frontsector->lightlevel);
} }
if (draw_segment->bFogBoundary || draw_segment->maskedtexturecol != nullptr) if (draw_segment->bFogBoundary || draw_segment->maskedtexturecol != nullptr)
@ -552,7 +552,7 @@ namespace swrenderer
// [ZZ] Only if not an active mirror // [ZZ] Only if not an active mirror
if (!markportal) if (!markportal)
{ {
RenderDecal::RenderDecals(Thread, mLineSegment->sidedef, draw_segment, lightlevel, rw_lightleft, rw_lightstep, mLineSegment, WallC, foggy, basecolormap, walltop.ScreenY, wallbottom.ScreenY, false); RenderDecal::RenderDecals(Thread, mLineSegment->sidedef, draw_segment, mLineSegment, WallC, mLight, walltop.ScreenY, wallbottom.ScreenY, false);
} }
if (markportal) if (markportal)
@ -789,14 +789,14 @@ namespace swrenderer
CameraLight *cameraLight = CameraLight::Instance(); CameraLight *cameraLight = CameraLight::Instance();
if (cameraLight->FixedColormap() == nullptr && cameraLight->FixedLightLevel() < 0) if (cameraLight->FixedColormap() == nullptr && cameraLight->FixedLightLevel() < 0)
{ {
lightlevel = mLineSegment->sidedef->GetLightLevel(foggy, mFrontSector->lightlevel); mLight.lightlevel = mLineSegment->sidedef->GetLightLevel(mLight.foggy, mFrontSector->lightlevel);
rw_lightleft = float(Thread->Light->WallVis(WallC.sz1, foggy)); mLight.lightleft = float(Thread->Light->WallVis(WallC.sz1, mLight.foggy));
rw_lightstep = float((Thread->Light->WallVis(WallC.sz2, foggy) - rw_lightleft) / (WallC.sx2 - WallC.sx1)); mLight.lightstep = float((Thread->Light->WallVis(WallC.sz2, mLight.foggy) - mLight.lightleft) / (WallC.sx2 - WallC.sx1));
} }
else else
{ {
rw_lightleft = 1; mLight.lightleft = 1;
rw_lightstep = 0; mLight.lightstep = 0;
} }
} }
} }
@ -1164,10 +1164,10 @@ namespace swrenderer
offset = -offset; offset = -offset;
} }
float rw_light = rw_lightleft + rw_lightstep * (x1 - WallC.sx1); mLight.light = mLight.lightleft + mLight.lightstep * (x1 - WallC.sx1);
RenderWallPart renderWallpart(Thread); RenderWallPart renderWallpart(Thread);
renderWallpart.Render(mFrontSector, mLineSegment, WallC, rw_pic, x1, x2, walltop.ScreenY, wallupper.ScreenY, mTopPart.TextureMid, walltexcoords.VStep, walltexcoords.UPos, yscale, MAX(mFrontCeilingZ1, mFrontCeilingZ2), MIN(mBackCeilingZ1, mBackCeilingZ2), false, false, OPAQUE, lightlevel, offset, rw_light, rw_lightstep, GetLightList(), foggy, basecolormap); renderWallpart.Render(mFrontSector, mLineSegment, WallC, rw_pic, x1, x2, walltop.ScreenY, wallupper.ScreenY, mTopPart.TextureMid, walltexcoords.VStep, walltexcoords.UPos, yscale, MAX(mFrontCeilingZ1, mFrontCeilingZ2), MIN(mBackCeilingZ1, mBackCeilingZ2), false, false, OPAQUE, offset, mLight, GetLightList());
} }
void SWRenderLine::RenderMiddleTexture(int x1, int x2) void SWRenderLine::RenderMiddleTexture(int x1, int x2)
@ -1197,10 +1197,10 @@ namespace swrenderer
offset = -offset; offset = -offset;
} }
float rw_light = rw_lightleft + rw_lightstep * (x1 - WallC.sx1); mLight.light = mLight.lightleft + mLight.lightstep * (x1 - WallC.sx1);
RenderWallPart renderWallpart(Thread); RenderWallPart renderWallpart(Thread);
renderWallpart.Render(mFrontSector, mLineSegment, WallC, rw_pic, x1, x2, walltop.ScreenY, wallbottom.ScreenY, mMiddlePart.TextureMid, walltexcoords.VStep, walltexcoords.UPos, yscale, MAX(mFrontCeilingZ1, mFrontCeilingZ2), MIN(mFrontFloorZ1, mFrontFloorZ2), false, false, OPAQUE, lightlevel, offset, rw_light, rw_lightstep, GetLightList(), foggy, basecolormap); renderWallpart.Render(mFrontSector, mLineSegment, WallC, rw_pic, x1, x2, walltop.ScreenY, wallbottom.ScreenY, mMiddlePart.TextureMid, walltexcoords.VStep, walltexcoords.UPos, yscale, MAX(mFrontCeilingZ1, mFrontCeilingZ2), MIN(mFrontFloorZ1, mFrontFloorZ2), false, false, OPAQUE, offset, mLight, GetLightList());
} }
void SWRenderLine::RenderBottomTexture(int x1, int x2) void SWRenderLine::RenderBottomTexture(int x1, int x2)
@ -1231,10 +1231,10 @@ namespace swrenderer
offset = -offset; offset = -offset;
} }
float rw_light = rw_lightleft + rw_lightstep * (x1 - WallC.sx1); mLight.light = mLight.lightleft + mLight.lightstep * (x1 - WallC.sx1);
RenderWallPart renderWallpart(Thread); RenderWallPart renderWallpart(Thread);
renderWallpart.Render(mFrontSector, mLineSegment, WallC, rw_pic, x1, x2, walllower.ScreenY, wallbottom.ScreenY, mBottomPart.TextureMid, walltexcoords.VStep, walltexcoords.UPos, yscale, MAX(mBackFloorZ1, mBackFloorZ2), MIN(mFrontFloorZ1, mFrontFloorZ2), false, false, OPAQUE, lightlevel, offset, rw_light, rw_lightstep, GetLightList(), foggy, basecolormap); renderWallpart.Render(mFrontSector, mLineSegment, WallC, rw_pic, x1, x2, walllower.ScreenY, wallbottom.ScreenY, mBottomPart.TextureMid, walltexcoords.VStep, walltexcoords.UPos, yscale, MAX(mBackFloorZ1, mBackFloorZ2), MIN(mFrontFloorZ1, mFrontFloorZ2), false, false, OPAQUE, offset, mLight, GetLightList());
} }
FLightNode *SWRenderLine::GetLightList() FLightNode *SWRenderLine::GetLightList()

View file

@ -128,16 +128,11 @@ namespace swrenderer
FWallCoords WallC; FWallCoords WallC;
FWallTmapVals WallT; FWallTmapVals WallT;
bool foggy;
FDynamicColormap *basecolormap;
// Wall segment variables: // Wall segment variables:
bool rw_prepped; bool rw_prepped;
int lightlevel; ProjectedWallLight mLight;
float rw_lightstep;
float rw_lightleft;
double lwallscale; double lwallscale;

View file

@ -80,12 +80,11 @@ namespace swrenderer
sector_t tempsec; sector_t tempsec;
const sector_t *sec = Thread->OpaquePass->FakeFlat(frontsector, &tempsec, nullptr, nullptr, nullptr, 0, 0, 0, 0); const sector_t *sec = Thread->OpaquePass->FakeFlat(frontsector, &tempsec, nullptr, nullptr, nullptr, 0, 0, 0, 0);
FDynamicColormap *basecolormap = GetColorTable(sec->Colormap, sec->SpecialColors[sector_t::walltop]); // [RH] Set basecolormap mLight.basecolormap = GetColorTable(sec->Colormap, sec->SpecialColors[sector_t::walltop]); // [RH] Set basecolormap
mLight.foggy = ds->foggy;
bool foggy = ds->foggy; mLight.lightlevel = ds->lightlevel;
int lightlevel = ds->lightlevel; mLight.lightstep = ds->lightstep;
rw_lightstep = ds->lightstep; mLight.light = ds->light + (x1 - ds->x1) * mLight.lightstep;
rw_light = ds->light + (x1 - ds->x1) * rw_lightstep;
Clip3DFloors *clip3d = Thread->Clip3D.get(); Clip3DFloors *clip3d = Thread->Clip3D.get();
@ -95,9 +94,9 @@ namespace swrenderer
if (clipTop <= frontsector->e->XFloor.lightlist[i].plane.Zat0()) if (clipTop <= frontsector->e->XFloor.lightlist[i].plane.Zat0())
{ {
lightlist_t *lit = &frontsector->e->XFloor.lightlist[i]; lightlist_t *lit = &frontsector->e->XFloor.lightlist[i];
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]); mLight.basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag mLight.foggy = (level.fadeto || mLight.basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag
lightlevel = curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr); mLight.lightlevel = curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr);
break; break;
} }
} }
@ -107,7 +106,7 @@ namespace swrenderer
SpriteDrawerArgs columndrawerargs; SpriteDrawerArgs columndrawerargs;
ColormapLight cmlight; ColormapLight cmlight;
cmlight.SetColormap(Thread, MINZ, lightlevel, foggy, basecolormap, false, false, false, false, false); cmlight.SetColormap(Thread, MINZ, mLight.lightlevel, mLight.foggy, mLight.basecolormap, false, false, false, false, false);
bool visible = columndrawerargs.SetStyle(viewport, LegacyRenderStyles[additive ? STYLE_Add : STYLE_Translucent], alpha, 0, 0, cmlight); bool visible = columndrawerargs.SetStyle(viewport, LegacyRenderStyles[additive ? STYLE_Add : STYLE_Translucent], alpha, 0, 0, cmlight);
if (!visible && !ds->bFogBoundary && !ds->Has3DFloorWalls()) if (!visible && !ds->bFogBoundary && !ds->Has3DFloorWalls())
{ {
@ -123,7 +122,7 @@ namespace swrenderer
const short *mceilingclip = ds->sprtopclip - ds->x1; const short *mceilingclip = ds->sprtopclip - ds->x1;
RenderFogBoundary renderfog; RenderFogBoundary renderfog;
renderfog.Render(Thread, x1, x2, mceilingclip, mfloorclip, lightlevel, ds->foggy, rw_light, rw_lightstep, basecolormap); renderfog.Render(Thread, x1, x2, mceilingclip, mfloorclip, mLight.lightlevel, ds->foggy, mLight.light, mLight.lightstep, mLight.basecolormap);
if (ds->maskedtexturecol == nullptr) if (ds->maskedtexturecol == nullptr)
renderwall = false; renderwall = false;
@ -134,7 +133,7 @@ namespace swrenderer
} }
if (renderwall) if (renderwall)
notrelevant = RenderWall(ds, x1, x2, basecolormap, columndrawerargs, visible, lightlevel, foggy); notrelevant = RenderWall(ds, x1, x2, columndrawerargs, visible);
if (ds->Has3DFloorFrontSectorWalls() || ds->Has3DFloorBackSectorWalls()) if (ds->Has3DFloorFrontSectorWalls() || ds->Has3DFloorBackSectorWalls())
{ {
@ -147,7 +146,7 @@ namespace swrenderer
} }
} }
bool RenderDrawSegment::RenderWall(DrawSegment *ds, int x1, int x2, FDynamicColormap *basecolormap, SpriteDrawerArgs &columndrawerargs, bool visible, int lightlevel, bool foggy) bool RenderDrawSegment::RenderWall(DrawSegment *ds, int x1, int x2, SpriteDrawerArgs &columndrawerargs, bool visible)
{ {
auto renderstyle = DefaultRenderStyle(); auto renderstyle = DefaultRenderStyle();
auto viewport = Thread->Viewport.get(); auto viewport = Thread->Viewport.get();
@ -320,7 +319,7 @@ namespace swrenderer
for (int x = x1; x < x2; ++x) for (int x = x1; x < x2; ++x)
{ {
if (needslight) if (needslight)
columndrawerargs.SetLight(rw_light, lightlevel, foggy, Thread->Viewport.get()); columndrawerargs.SetLight(mLight.light, mLight.lightlevel, mLight.foggy, Thread->Viewport.get());
fixed_t iscale = xs_Fix<16>::ToFix(MaskedSWall[x] * MaskedScaleY); fixed_t iscale = xs_Fix<16>::ToFix(MaskedSWall[x] * MaskedScaleY);
double sprtopscreen; double sprtopscreen;
@ -331,7 +330,7 @@ namespace swrenderer
columndrawerargs.DrawMaskedColumn(Thread, x, iscale, tex, maskedtexturecol[x], spryscale, sprtopscreen, sprflipvert, mfloorclip, mceilingclip, renderstyle); columndrawerargs.DrawMaskedColumn(Thread, x, iscale, tex, maskedtexturecol[x], spryscale, sprtopscreen, sprflipvert, mfloorclip, mceilingclip, renderstyle);
rw_light += rw_lightstep; mLight.light += mLight.lightstep;
spryscale += rw_scalestep; spryscale += rw_scalestep;
} }
} }
@ -399,14 +398,14 @@ namespace swrenderer
bool additive = (curline->linedef->flags & ML_ADDTRANS) != 0; bool additive = (curline->linedef->flags & ML_ADDTRANS) != 0;
RenderWallPart renderWallpart(Thread); RenderWallPart renderWallpart(Thread);
renderWallpart.Render(frontsector, curline, WallC, rw_pic, x1, x2, mceilingclip, mfloorclip, texturemid, MaskedSWall, maskedtexturecol, ds->yscale, top, bot, true, additive, alpha, lightlevel, rw_offset, rw_light, rw_lightstep, nullptr, ds->foggy, basecolormap); renderWallpart.Render(frontsector, curline, WallC, rw_pic, x1, x2, mceilingclip, mfloorclip, texturemid, MaskedSWall, maskedtexturecol, ds->yscale, top, bot, true, additive, alpha, rw_offset, mLight, nullptr);
} }
return false; return false;
} }
// kg3D - render one fake wall // kg3D - render one fake wall
void RenderDrawSegment::RenderFakeWall(DrawSegment *ds, int x1, int x2, F3DFloor *rover, int lightlevel, FDynamicColormap *basecolormap, double clipTop, double clipBottom, FSoftwareTexture *rw_pic) void RenderDrawSegment::RenderFakeWall(DrawSegment *ds, int x1, int x2, F3DFloor *rover, double clipTop, double clipBottom, FSoftwareTexture *rw_pic)
{ {
int i; int i;
double xscale; double xscale;
@ -416,8 +415,8 @@ namespace swrenderer
if (Alpha <= 0) if (Alpha <= 0)
return; return;
rw_lightstep = ds->lightstep; mLight.lightstep = ds->lightstep;
rw_light = ds->light + (x1 - ds->x1) * rw_lightstep; mLight.light = ds->light + (x1 - ds->x1) * mLight.lightstep;
const short *mfloorclip = ds->sprbottomclip - ds->x1; const short *mfloorclip = ds->sprbottomclip - ds->x1;
const short *mceilingclip = ds->sprtopclip - ds->x1; const short *mceilingclip = ds->sprtopclip - ds->x1;
@ -501,9 +500,9 @@ namespace swrenderer
GetMaskedWallTopBottom(ds, top, bot); GetMaskedWallTopBottom(ds, top, bot);
RenderWallPart renderWallpart(Thread); RenderWallPart renderWallpart(Thread);
renderWallpart.Render(frontsector, curline, WallC, rw_pic, x1, x2, wallupper.ScreenY, walllower.ScreenY, texturemid, MaskedSWall, walltexcoords.UPos, yscale, top, bot, true, (rover->flags & FF_ADDITIVETRANS) != 0, Alpha, lightlevel, rw_offset, rw_light, rw_lightstep, nullptr, ds->foggy, basecolormap); renderWallpart.Render(frontsector, curline, WallC, rw_pic, x1, x2, wallupper.ScreenY, walllower.ScreenY, texturemid, MaskedSWall, walltexcoords.UPos, yscale, top, bot, true, (rover->flags & FF_ADDITIVETRANS) != 0, Alpha, rw_offset, mLight, nullptr);
RenderDecal::RenderDecals(Thread, curline->sidedef, ds, lightlevel, rw_light, rw_lightstep, curline, WallC, ds->foggy, basecolormap, wallupper.ScreenY, walllower.ScreenY, true); RenderDecal::RenderDecals(Thread, curline->sidedef, ds, curline, WallC, mLight, wallupper.ScreenY, walllower.ScreenY, true);
} }
// kg3D - walls of fake floors // kg3D - walls of fake floors
@ -696,8 +695,8 @@ namespace swrenderer
rw_pic = rw_tex && rw_tex->isValid() ? rw_tex->GetSoftwareTexture() : nullptr; rw_pic = rw_tex && rw_tex->isValid() ? rw_tex->GetSoftwareTexture() : nullptr;
} }
// correct colors now // correct colors now
FDynamicColormap *basecolormap = nullptr; mLight.basecolormap = nullptr;
int lightlevel = ds->lightlevel; mLight.lightlevel = ds->lightlevel;
CameraLight *cameraLight = CameraLight::Instance(); CameraLight *cameraLight = CameraLight::Instance();
if (cameraLight->FixedLightLevel() < 0) if (cameraLight->FixedLightLevel() < 0)
{ {
@ -708,9 +707,9 @@ namespace swrenderer
if (clipTop <= backsector->e->XFloor.lightlist[j].plane.Zat0()) if (clipTop <= backsector->e->XFloor.lightlist[j].plane.Zat0())
{ {
lightlist_t *lit = &backsector->e->XFloor.lightlist[j]; lightlist_t *lit = &backsector->e->XFloor.lightlist[j];
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]); mLight.basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
//bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag mLight.foggy = (level.fadeto || mLight.basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag
lightlevel = curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr); mLight.lightlevel = curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr);
break; break;
} }
} }
@ -722,19 +721,19 @@ namespace swrenderer
if (clipTop <= frontsector->e->XFloor.lightlist[j].plane.Zat0()) if (clipTop <= frontsector->e->XFloor.lightlist[j].plane.Zat0())
{ {
lightlist_t *lit = &frontsector->e->XFloor.lightlist[j]; lightlist_t *lit = &frontsector->e->XFloor.lightlist[j];
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]); mLight.basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
//bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag mLight.foggy = (level.fadeto || mLight.basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag
lightlevel = curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr); mLight.lightlevel = curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr);
break; break;
} }
} }
} }
} }
if (basecolormap == nullptr) basecolormap = GetColorTable(frontsector->Colormap, frontsector->SpecialColors[sector_t::walltop]); if (mLight.basecolormap == nullptr) mLight.basecolormap = GetColorTable(frontsector->Colormap, frontsector->SpecialColors[sector_t::walltop]);
if (rw_pic && !swimmable_found) if (rw_pic && !swimmable_found)
{ {
RenderFakeWall(ds, x1, x2, fover ? fover : rover, lightlevel, basecolormap, clipTop, clipBottom, rw_pic); RenderFakeWall(ds, x1, x2, fover ? fover : rover, clipTop, clipBottom, rw_pic);
} }
break; break;
} }
@ -883,8 +882,8 @@ namespace swrenderer
rw_pic = rw_tex && rw_tex->isValid() ? rw_tex->GetSoftwareTexture() : nullptr; rw_pic = rw_tex && rw_tex->isValid() ? rw_tex->GetSoftwareTexture() : nullptr;
} }
// correct colors now // correct colors now
FDynamicColormap *basecolormap = nullptr; mLight.basecolormap = nullptr;
int lightlevel = ds->lightlevel; mLight.lightlevel = ds->lightlevel;
CameraLight *cameraLight = CameraLight::Instance(); CameraLight *cameraLight = CameraLight::Instance();
if (cameraLight->FixedLightLevel() < 0) if (cameraLight->FixedLightLevel() < 0)
{ {
@ -895,9 +894,9 @@ namespace swrenderer
if (clipTop <= backsector->e->XFloor.lightlist[j].plane.Zat0()) if (clipTop <= backsector->e->XFloor.lightlist[j].plane.Zat0())
{ {
lightlist_t *lit = &backsector->e->XFloor.lightlist[j]; lightlist_t *lit = &backsector->e->XFloor.lightlist[j];
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]); mLight.basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag mLight.foggy = (level.fadeto || mLight.basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag
lightlevel = curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr); mLight.lightlevel = curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr);
break; break;
} }
} }
@ -909,19 +908,19 @@ namespace swrenderer
if (clipTop <= frontsector->e->XFloor.lightlist[j].plane.Zat0()) if (clipTop <= frontsector->e->XFloor.lightlist[j].plane.Zat0())
{ {
lightlist_t *lit = &frontsector->e->XFloor.lightlist[j]; lightlist_t *lit = &frontsector->e->XFloor.lightlist[j];
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]); mLight.basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag mLight.foggy = (level.fadeto || mLight.basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag
lightlevel = curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr); mLight.lightlevel = curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr);
break; break;
} }
} }
} }
} }
if (basecolormap == nullptr) basecolormap = GetColorTable(frontsector->Colormap, frontsector->SpecialColors[sector_t::walltop]); if (mLight.basecolormap == nullptr) mLight.basecolormap = GetColorTable(frontsector->Colormap, frontsector->SpecialColors[sector_t::walltop]);
if (rw_pic && !swimmable_found) if (rw_pic && !swimmable_found)
{ {
RenderFakeWall(ds, x1, x2, fover ? fover : rover, lightlevel, basecolormap, clipTop, clipBottom, rw_pic); RenderFakeWall(ds, x1, x2, fover ? fover : rover, clipTop, clipBottom, rw_pic);
} }
break; break;
} }

View file

@ -37,9 +37,9 @@ namespace swrenderer
RenderThread *Thread = nullptr; RenderThread *Thread = nullptr;
private: private:
bool RenderWall(DrawSegment *ds, int x1, int x2, FDynamicColormap *basecolormap, SpriteDrawerArgs &columndrawerargs, bool visible, int lightlevel, bool foggy); bool RenderWall(DrawSegment *ds, int x1, int x2, SpriteDrawerArgs &columndrawerargs, bool visible);
void ClipMidtex(int x1, int x2); void ClipMidtex(int x1, int x2);
void RenderFakeWall(DrawSegment *ds, int x1, int x2, F3DFloor *rover, int lightlevel, FDynamicColormap *basecolormap, double clipTop, double clipBottom, FSoftwareTexture *rw_pic); void RenderFakeWall(DrawSegment *ds, int x1, int x2, F3DFloor *rover, double clipTop, double clipBottom, FSoftwareTexture *rw_pic);
void RenderFakeWallRange(DrawSegment *ds, int x1, int x2); void RenderFakeWallRange(DrawSegment *ds, int x1, int x2);
void GetMaskedWallTopBottom(DrawSegment *ds, double &top, double &bot); void GetMaskedWallTopBottom(DrawSegment *ds, double &top, double &bot);
@ -52,8 +52,8 @@ namespace swrenderer
FWallCoords WallC; FWallCoords WallC;
FWallTmapVals WallT; FWallTmapVals WallT;
float rw_light = 0.0f; ProjectedWallLight mLight;
float rw_lightstep = 0.0f;
fixed_t rw_offset = 0; fixed_t rw_offset = 0;
ProjectedWallLine wallupper; ProjectedWallLine wallupper;

View file

@ -349,11 +349,11 @@ namespace swrenderer
// Textures that aren't masked can use the faster opaque drawer // Textures that aren't masked can use the faster opaque drawer
if (!rw_pic->GetTexture()->isMasked() && mask && alpha >= OPAQUE && !additive) if (!rw_pic->GetTexture()->isMasked() && mask && alpha >= OPAQUE && !additive)
{ {
drawerargs.SetStyle(true, false, OPAQUE, basecolormap); drawerargs.SetStyle(true, false, OPAQUE, mLight.basecolormap);
} }
else else
{ {
drawerargs.SetStyle(mask, additive, alpha, basecolormap); drawerargs.SetStyle(mask, additive, alpha, mLight.basecolormap);
} }
CameraLight *cameraLight = CameraLight::Instance(); CameraLight *cameraLight = CameraLight::Instance();
@ -368,8 +368,8 @@ namespace swrenderer
double xmagnitude = 1.0; double xmagnitude = 1.0;
float curlight = light; float curlight = mLight.light;
for (int x = x1; x < x2; x++, curlight += lightstep) for (int x = x1; x < x2; x++, curlight += mLight.lightstep)
{ {
int y1 = uwal[x]; int y1 = uwal[x];
int y2 = dwal[x]; int y2 = dwal[x];
@ -377,7 +377,7 @@ namespace swrenderer
continue; continue;
if (!fixed) if (!fixed)
drawerargs.SetLight(curlight, lightlevel, foggy, Thread->Viewport.get()); drawerargs.SetLight(curlight, mLight.lightlevel, mLight.foggy, Thread->Viewport.get());
if (x + 1 < x2) xmagnitude = fabs(FIXED2DBL(lwal[x + 1]) - FIXED2DBL(lwal[x])); if (x + 1 < x2) xmagnitude = fabs(FIXED2DBL(lwal[x + 1]) - FIXED2DBL(lwal[x]));
@ -424,8 +424,8 @@ namespace swrenderer
} }
lightlist_t *lit = &frontsector->e->XFloor.lightlist[i]; lightlist_t *lit = &frontsector->e->XFloor.lightlist[i];
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]); mLight.basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
lightlevel = curline->sidedef->GetLightLevel(foggy, *lit->p_lightlevel, lit->lightsource != NULL); mLight.lightlevel = curline->sidedef->GetLightLevel(mLight.foggy, *lit->p_lightlevel, lit->lightsource != NULL);
} }
ProcessNormalWall(up, dwal, texturemid, swal, lwal); ProcessNormalWall(up, dwal, texturemid, swal, lwal);
@ -516,7 +516,7 @@ namespace swrenderer
} }
} }
void RenderWallPart::Render(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, FSoftwareTexture *pic, int x1, int x2, const short *walltop, const short *wallbottom, double texturemid, float *swall, fixed_t *lwall, double yscale, double top, double bottom, bool mask, bool additive, fixed_t alpha, int lightlevel, fixed_t xoffset, float light, float lightstep, FLightNode *light_list, bool foggy, FDynamicColormap *basecolormap) void RenderWallPart::Render(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, FSoftwareTexture *pic, int x1, int x2, const short *walltop, const short *wallbottom, double texturemid, float *swall, fixed_t *lwall, double yscale, double top, double bottom, bool mask, bool additive, fixed_t alpha, fixed_t xoffset, const ProjectedWallLight &light, FLightNode *light_list)
{ {
this->x1 = x1; this->x1 = x1;
this->x2 = x2; this->x2 = x2;
@ -524,12 +524,8 @@ namespace swrenderer
this->curline = curline; this->curline = curline;
this->WallC = WallC; this->WallC = WallC;
this->yrepeat = yscale; this->yrepeat = yscale;
this->lightlevel = lightlevel; this->mLight = light;
this->xoffset = xoffset; this->xoffset = xoffset;
this->light = light;
this->lightstep = lightstep;
this->foggy = foggy;
this->basecolormap = basecolormap;
this->light_list = light_list; this->light_list = light_list;
this->rw_pic = pic; this->rw_pic = pic;
this->mask = mask; this->mask = mask;

View file

@ -63,13 +63,9 @@ namespace swrenderer
bool mask, bool mask,
bool additive, bool additive,
fixed_t alpha, fixed_t alpha,
int lightlevel,
fixed_t xoffset, fixed_t xoffset,
float light, const ProjectedWallLight &light,
float lightstep, FLightNode *light_list);
FLightNode *light_list,
bool foggy,
FDynamicColormap *basecolormap);
RenderThread *Thread = nullptr; RenderThread *Thread = nullptr;
@ -88,13 +84,10 @@ namespace swrenderer
seg_t *curline = nullptr; seg_t *curline = nullptr;
FWallCoords WallC; FWallCoords WallC;
ProjectedWallLight mLight;
double yrepeat = 0.0; double yrepeat = 0.0;
int lightlevel = 0;
fixed_t xoffset = 0; fixed_t xoffset = 0;
float light = 0.0f;
float lightstep = 0.0f;
bool foggy = false;
FDynamicColormap *basecolormap = nullptr;
FLightNode *light_list = nullptr; FLightNode *light_list = nullptr;
bool mask = false; bool mask = false;
bool additive = false; bool additive = false;

View file

@ -56,4 +56,16 @@ namespace swrenderer
void Project(RenderViewport *viewport, double walxrepeat, int x1, int x2, const FWallTmapVals &WallT); void Project(RenderViewport *viewport, double walxrepeat, int x1, int x2, const FWallTmapVals &WallT);
void ProjectPos(RenderViewport *viewport, double walxrepeat, int x1, int x2, const FWallTmapVals &WallT); void ProjectPos(RenderViewport *viewport, double walxrepeat, int x1, int x2, const FWallTmapVals &WallT);
}; };
class ProjectedWallLight
{
public:
int lightlevel;
bool foggy;
FDynamicColormap *basecolormap;
float lightleft;
float lightstep;
float light;
};
} }

View file

@ -57,15 +57,15 @@ EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor);
namespace swrenderer namespace swrenderer
{ {
void RenderDecal::RenderDecals(RenderThread *thread, side_t *sidedef, DrawSegment *draw_segment, int lightlevel, float lightleft, float lightstep, seg_t *curline, const FWallCoords &wallC, bool foggy, FDynamicColormap *basecolormap, const short *walltop, const short *wallbottom, bool drawsegPass) void RenderDecal::RenderDecals(RenderThread *thread, side_t *sidedef, DrawSegment *draw_segment, seg_t *curline, const FWallCoords &wallC, const ProjectedWallLight &light, const short *walltop, const short *wallbottom, bool drawsegPass)
{ {
for (DBaseDecal *decal = sidedef->AttachedDecals; decal != NULL; decal = decal->WallNext) for (DBaseDecal *decal = sidedef->AttachedDecals; decal != NULL; decal = decal->WallNext)
{ {
Render(thread, sidedef, decal, draw_segment, lightlevel, lightleft, lightstep, curline, wallC, foggy, basecolormap, walltop, wallbottom, drawsegPass); Render(thread, sidedef, decal, draw_segment, curline, wallC, light, walltop, wallbottom, drawsegPass);
} }
} }
void RenderDecal::Render(RenderThread *thread, side_t *wall, DBaseDecal *decal, DrawSegment *clipper, int lightlevel, float lightleft, float lightstep, seg_t *curline, const FWallCoords &savecoord, bool foggy, FDynamicColormap *basecolormap, const short *walltop, const short *wallbottom, bool drawsegPass) void RenderDecal::Render(RenderThread *thread, side_t *wall, DBaseDecal *decal, DrawSegment *clipper, seg_t *curline, const FWallCoords &savecoord, const ProjectedWallLight &light, const short *walltop, const short *wallbottom, bool drawsegPass)
{ {
DVector2 decal_left, decal_right, decal_pos; DVector2 decal_left, decal_right, decal_pos;
int x1, x2; int x1, x2;
@ -75,7 +75,6 @@ namespace swrenderer
int needrepeat = 0; int needrepeat = 0;
sector_t *back; sector_t *back;
FDynamicColormap *usecolormap; FDynamicColormap *usecolormap;
float light = 0;
const short *mfloorclip; const short *mfloorclip;
const short *mceilingclip; const short *mceilingclip;
@ -257,7 +256,7 @@ namespace swrenderer
} }
// Prepare lighting // Prepare lighting
usecolormap = basecolormap; usecolormap = light.basecolormap;
// Decals that are added to the scene must fade to black. // Decals that are added to the scene must fade to black.
if (decal->RenderStyle == LegacyRenderStyles[STYLE_Add] && usecolormap->Fade != 0) if (decal->RenderStyle == LegacyRenderStyles[STYLE_Add] && usecolormap->Fade != 0)
@ -265,7 +264,7 @@ namespace swrenderer
usecolormap = GetSpecialLights(usecolormap->Color, 0, usecolormap->Desaturate); usecolormap = GetSpecialLights(usecolormap->Color, 0, usecolormap->Desaturate);
} }
light = lightleft + (x1 - savecoord.sx1) * lightstep; float lightpos = light.lightleft + (x1 - savecoord.sx1) * light.lightstep;
cameraLight = CameraLight::Instance(); cameraLight = CameraLight::Instance();
@ -288,7 +287,7 @@ namespace swrenderer
int x = x1; int x = x1;
ColormapLight cmlight; ColormapLight cmlight;
cmlight.SetColormap(thread, MINZ, lightlevel, foggy, usecolormap, decal->RenderFlags & RF_FULLBRIGHT, false, false, false, false); cmlight.SetColormap(thread, MINZ, light.lightlevel, light.foggy, usecolormap, decal->RenderFlags & RF_FULLBRIGHT, false, false, false, false);
SpriteDrawerArgs drawerargs; SpriteDrawerArgs drawerargs;
bool visible = drawerargs.SetStyle(thread->Viewport.get(), decal->RenderStyle, (float)decal->Alpha, decal->Translation, decal->AlphaColor, cmlight); bool visible = drawerargs.SetStyle(thread->Viewport.get(), decal->RenderStyle, (float)decal->Alpha, decal->Translation, decal->AlphaColor, cmlight);
@ -301,10 +300,10 @@ namespace swrenderer
{ {
if (calclighting) if (calclighting)
{ // calculate lighting { // calculate lighting
drawerargs.SetLight(light, lightlevel, foggy, thread->Viewport.get()); drawerargs.SetLight(lightpos, light.lightlevel, light.foggy, thread->Viewport.get());
} }
DrawColumn(thread, drawerargs, x, WallSpriteTile, walltexcoords, texturemid, maskedScaleY, sprflipvert, mfloorclip, mceilingclip, decal->RenderStyle); DrawColumn(thread, drawerargs, x, WallSpriteTile, walltexcoords, texturemid, maskedScaleY, sprflipvert, mfloorclip, mceilingclip, decal->RenderStyle);
light += lightstep; lightpos += light.lightstep;
x++; x++;
} }
} }

View file

@ -12,10 +12,10 @@ namespace swrenderer
class RenderDecal class RenderDecal
{ {
public: public:
static void RenderDecals(RenderThread *thread, side_t *wall, DrawSegment *draw_segment, int lightlevel, float lightleft, float lightstep, seg_t *curline, const FWallCoords &wallC, bool foggy, FDynamicColormap *basecolormap, const short *walltop, const short *wallbottom, bool drawsegPass); static void RenderDecals(RenderThread *thread, side_t *wall, DrawSegment *draw_segment, seg_t *curline, const FWallCoords &wallC, const ProjectedWallLight &light, const short *walltop, const short *wallbottom, bool drawsegPass);
private: private:
static void Render(RenderThread *thread, side_t *wall, DBaseDecal *first, DrawSegment *clipper, int lightlevel, float lightleft, float lightstep, seg_t *curline, const FWallCoords &wallC, bool foggy, FDynamicColormap *basecolormap, const short *walltop, const short *wallbottom, bool drawsegPass); static void Render(RenderThread *thread, side_t *wall, DBaseDecal *first, DrawSegment *clipper, seg_t *curline, const FWallCoords &wallC, const ProjectedWallLight &light, const short *walltop, const short *wallbottom, bool drawsegPass);
static void DrawColumn(RenderThread *thread, SpriteDrawerArgs &drawerargs, int x, FSoftwareTexture *WallSpriteTile, const ProjectedWallTexcoords &walltexcoords, double texturemid, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, FRenderStyle style); static void DrawColumn(RenderThread *thread, SpriteDrawerArgs &drawerargs, int x, FSoftwareTexture *WallSpriteTile, const ProjectedWallTexcoords &walltexcoords, double texturemid, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, FRenderStyle style);
}; };
} }