Calculate all light in RenderWallPart

This commit is contained in:
Magnus Norddahl 2019-11-15 05:45:52 +01:00
parent 82855ab1fd
commit 7168466c28
4 changed files with 23 additions and 76 deletions

View file

@ -62,7 +62,6 @@
CVAR(Bool, r_fogboundary, true, 0)
CVAR(Bool, r_drawmirrors, true, 0)
EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor);
namespace swrenderer
{
@ -884,12 +883,8 @@ namespace swrenderer
ProjectedWallTexcoords texcoords;
texcoords.ProjectTop(Thread->Viewport.get(), mFrontSector, mBackSector, mLineSegment, WallC.sx1, WallC.sx2, WallT, mTopTexture);
ProjectedWallLight walllight;
walllight.SetColormap(mFrontSector, mLineSegment);
walllight.SetLightLeft(Thread, WallC);
RenderWallPart renderWallpart(Thread);
renderWallpart.Render(mFrontSector, mLineSegment, WallC, mTopTexture, x1, x2, walltop.ScreenY, wallupper.ScreenY, texcoords, MAX(mFrontCeilingZ1, mFrontCeilingZ2), MIN(mBackCeilingZ1, mBackCeilingZ2), false, false, OPAQUE, walllight, GetLightList());
renderWallpart.Render(mFrontSector, mLineSegment, WallC, mTopTexture, x1, x2, walltop.ScreenY, wallupper.ScreenY, texcoords, MAX(mFrontCeilingZ1, mFrontCeilingZ2), MIN(mBackCeilingZ1, mBackCeilingZ2), false, false, OPAQUE, GetLightList());
}
void SWRenderLine::RenderMiddleTexture(int x1, int x2)
@ -900,12 +895,8 @@ namespace swrenderer
ProjectedWallTexcoords texcoords;
texcoords.ProjectMid(Thread->Viewport.get(), mFrontSector, mLineSegment, WallC.sx1, WallC.sx2, WallT, mMiddleTexture);
ProjectedWallLight walllight;
walllight.SetColormap(mFrontSector, mLineSegment);
walllight.SetLightLeft(Thread, WallC);
RenderWallPart renderWallpart(Thread);
renderWallpart.Render(mFrontSector, mLineSegment, WallC, mMiddleTexture, x1, x2, walltop.ScreenY, wallbottom.ScreenY, texcoords, MAX(mFrontCeilingZ1, mFrontCeilingZ2), MIN(mFrontFloorZ1, mFrontFloorZ2), false, false, OPAQUE, walllight, GetLightList());
renderWallpart.Render(mFrontSector, mLineSegment, WallC, mMiddleTexture, x1, x2, walltop.ScreenY, wallbottom.ScreenY, texcoords, MAX(mFrontCeilingZ1, mFrontCeilingZ2), MIN(mFrontFloorZ1, mFrontFloorZ2), false, false, OPAQUE, GetLightList());
}
void SWRenderLine::RenderBottomTexture(int x1, int x2)
@ -917,12 +908,8 @@ namespace swrenderer
ProjectedWallTexcoords texcoords;
texcoords.ProjectBottom(Thread->Viewport.get(), mFrontSector, mBackSector, mLineSegment, WallC.sx1, WallC.sx2, WallT, mBottomTexture);
ProjectedWallLight walllight;
walllight.SetColormap(mFrontSector, mLineSegment);
walllight.SetLightLeft(Thread, WallC);
RenderWallPart renderWallpart(Thread);
renderWallpart.Render(mFrontSector, mLineSegment, WallC, mBottomTexture, x1, x2, walllower.ScreenY, wallbottom.ScreenY, texcoords, MAX(mBackFloorZ1, mBackFloorZ2), MIN(mFrontFloorZ1, mFrontFloorZ2), false, false, OPAQUE, walllight, GetLightList());
renderWallpart.Render(mFrontSector, mLineSegment, WallC, mBottomTexture, x1, x2, walllower.ScreenY, wallbottom.ScreenY, texcoords, MAX(mBackFloorZ1, mBackFloorZ2), MIN(mFrontFloorZ1, mFrontFloorZ2), false, false, OPAQUE, GetLightList());
}
FLightNode *SWRenderLine::GetLightList()

View file

@ -194,21 +194,7 @@ namespace swrenderer
}
sector_t tempsec;
const sector_t* sec = Thread->OpaquePass->FakeFlat(frontsector, &tempsec, nullptr, nullptr, nullptr, 0, 0, 0, 0);
ProjectedWallLight walllight;
walllight.SetColormap(sec, curline);
walllight.SetLightLeft(Thread, ds->WallC);
double clipTop = m3DFloor.clipTop ? m3DFloor.sclipTop : sec->ceilingplane.ZatPoint(Thread->Viewport->viewpoint.Pos);
for (int i = frontsector->e->XFloor.lightlist.Size() - 1; i >= 0; i--)
{
if (clipTop <= frontsector->e->XFloor.lightlist[i].plane.Zat0())
{
walllight.SetColormap(frontsector, curline, &frontsector->e->XFloor.lightlist[i]);
break;
}
}
const sector_t* lightsector = Thread->OpaquePass->FakeFlat(frontsector, &tempsec, nullptr, nullptr, nullptr, 0, 0, 0, 0);
double top, bot;
GetMaskedWallTopBottom(ds, top, bot);
@ -217,7 +203,7 @@ namespace swrenderer
bool additive = (curline->linedef->flags & ML_ADDTRANS) != 0;
RenderWallPart renderWallpart(Thread);
renderWallpart.Render(frontsector, curline, ds->WallC, tex, x1, x2, mceilingclip, mfloorclip, ds->texcoords, top, bot, true, additive, alpha, walllight, nullptr);
renderWallpart.Render(lightsector, curline, ds->WallC, tex, x1, x2, mceilingclip, mfloorclip, ds->texcoords, top, bot, true, additive, alpha, nullptr);
}
void RenderDrawSegment::Render3DFloorWall(DrawSegment *ds, int x1, int x2, F3DFloor *rover, double clipTop, double clipBottom, FSoftwareTexture *rw_pic)
@ -226,37 +212,7 @@ namespace swrenderer
if (Alpha <= 0)
return;
lightlist_t* lit = nullptr;
CameraLight* cameraLight = CameraLight::Instance();
if (cameraLight->FixedLightLevel() < 0)
{
if (ds->Has3DFloorFrontSectorWalls() && !ds->Has3DFloorBackSectorWalls())
{
for (int j = backsector->e->XFloor.lightlist.Size() - 1; j >= 0; j--)
{
if (clipTop <= backsector->e->XFloor.lightlist[j].plane.Zat0())
{
lit = &backsector->e->XFloor.lightlist[j];
break;
}
}
}
else
{
for (int j = frontsector->e->XFloor.lightlist.Size() - 1; j >= 0; j--)
{
if (clipTop <= frontsector->e->XFloor.lightlist[j].plane.Zat0())
{
lit = &frontsector->e->XFloor.lightlist[j];
break;
}
}
}
}
ProjectedWallLight walllight;
walllight.SetColormap(frontsector, curline, lit);
walllight.SetLightLeft(Thread, ds->WallC);
sector_t* lightsector = (ds->Has3DFloorFrontSectorWalls() && !ds->Has3DFloorBackSectorWalls()) ? backsector : frontsector;
wallupper.Project(Thread->Viewport.get(), clipTop - Thread->Viewport->viewpoint.Pos.Z, &ds->WallC);
walllower.Project(Thread->Viewport.get(), clipBottom - Thread->Viewport->viewpoint.Pos.Z, &ds->WallC);
@ -271,8 +227,11 @@ namespace swrenderer
GetMaskedWallTopBottom(ds, top, bot);
RenderWallPart renderWallpart(Thread);
renderWallpart.Render(frontsector, curline, ds->WallC, rw_pic, x1, x2, wallupper.ScreenY, walllower.ScreenY, walltexcoords, top, bot, true, (rover->flags & FF_ADDITIVETRANS) != 0, Alpha, walllight, nullptr);
renderWallpart.Render(lightsector, curline, ds->WallC, rw_pic, x1, x2, wallupper.ScreenY, walllower.ScreenY, walltexcoords, top, bot, true, (rover->flags & FF_ADDITIVETRANS) != 0, Alpha, nullptr);
ProjectedWallLight walllight;
walllight.SetColormap(lightsector, curline);
walllight.SetLightLeft(Thread, ds->WallC);
RenderDecal::RenderDecals(Thread, curline->sidedef, ds, curline, walllight, wallupper.ScreenY, walllower.ScreenY, true);
}
@ -640,10 +599,10 @@ namespace swrenderer
}
sector_t tempsec;
const sector_t* sec = Thread->OpaquePass->FakeFlat(frontsector, &tempsec, nullptr, nullptr, nullptr, 0, 0, 0, 0);
const sector_t* lightsector = Thread->OpaquePass->FakeFlat(frontsector, &tempsec, nullptr, nullptr, nullptr, 0, 0, 0, 0);
ProjectedWallLight walllight;
walllight.SetColormap(sec, curline);
walllight.SetColormap(lightsector, curline);
walllight.SetLightLeft(Thread, ds->WallC);
RenderFogBoundary renderfog;

View file

@ -423,9 +423,9 @@ namespace swrenderer
RenderPortal *renderportal = Thread->Portal.get();
// kg3D - fake floors instead of zdoom light list
for (unsigned int i = 0; i < frontsector->e->XFloor.lightlist.Size(); i++)
for (unsigned int i = 0; i < lightsector->e->XFloor.lightlist.Size(); i++)
{
ProjectedWallCull j = most3.Project(Thread->Viewport.get(), frontsector->e->XFloor.lightlist[i].plane, &WallC, curline, renderportal->MirrorFlags & RF_XFLIP);
ProjectedWallCull j = most3.Project(Thread->Viewport.get(), lightsector->e->XFloor.lightlist[i].plane, &WallC, curline, renderportal->MirrorFlags & RF_XFLIP);
if (j != ProjectedWallCull::OutsideAbove)
{
for (int j = x1; j < x2; ++j)
@ -437,7 +437,7 @@ namespace swrenderer
down = (down == most1.ScreenY) ? most2.ScreenY : most1.ScreenY;
}
mLight.SetColormap(frontsector, curline, &frontsector->e->XFloor.lightlist[i]);
mLight.SetColormap(lightsector, curline, &lightsector->e->XFloor.lightlist[i]);
}
ProcessNormalWall(up, dwal, texcoords);
@ -446,7 +446,7 @@ namespace swrenderer
void RenderWallPart::ProcessWall(const short *uwal, const short *dwal, const ProjectedWallTexcoords& texcoords)
{
CameraLight *cameraLight = CameraLight::Instance();
if (cameraLight->FixedColormap() != NULL || cameraLight->FixedLightLevel() >= 0 || !(frontsector->e && frontsector->e->XFloor.lightlist.Size()))
if (cameraLight->FixedColormap() != NULL || cameraLight->FixedLightLevel() >= 0 || !(lightsector->e && lightsector->e->XFloor.lightlist.Size()))
{
ProcessNormalWall(uwal, dwal, texcoords);
}
@ -528,20 +528,22 @@ 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, const ProjectedWallTexcoords& texcoords, double top, double bottom, bool mask, bool additive, fixed_t alpha, const ProjectedWallLight &light, FLightNode *light_list)
void RenderWallPart::Render(const sector_t *lightsector, seg_t *curline, const FWallCoords &WallC, FSoftwareTexture *pic, int x1, int x2, const short *walltop, const short *wallbottom, const ProjectedWallTexcoords& texcoords, double top, double bottom, bool mask, bool additive, fixed_t alpha, FLightNode *light_list)
{
this->x1 = x1;
this->x2 = x2;
this->frontsector = frontsector;
this->lightsector = lightsector;
this->curline = curline;
this->WallC = WallC;
this->mLight = light;
this->light_list = light_list;
this->rw_pic = pic;
this->mask = mask;
this->additive = additive;
this->alpha = alpha;
mLight.SetColormap(lightsector, curline);
mLight.SetLightLeft(Thread, WallC);
Thread->PrepareTexture(pic, DefaultRenderStyle()); // Get correct render style? Shaded won't get here.
if (rw_pic->GetHeight() != (1 << rw_pic->GetHeightBits()))

View file

@ -46,7 +46,7 @@ namespace swrenderer
RenderWallPart(RenderThread *thread);
void Render(
sector_t *frontsector,
const sector_t *lightsector,
seg_t *curline,
const FWallCoords &WallC,
FSoftwareTexture *rw_pic,
@ -60,7 +60,6 @@ namespace swrenderer
bool mask,
bool additive,
fixed_t alpha,
const ProjectedWallLight &light,
FLightNode *light_list);
RenderThread *Thread = nullptr;
@ -75,7 +74,7 @@ namespace swrenderer
int x1 = 0;
int x2 = 0;
FSoftwareTexture *rw_pic = nullptr;
sector_t *frontsector = nullptr;
const sector_t *lightsector = nullptr;
seg_t *curline = nullptr;
FWallCoords WallC;