mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-14 00:20:38 +00:00
- simplify colormap selection to a single function
This commit is contained in:
parent
c0a4ba5e82
commit
4d3d4ea746
13 changed files with 159 additions and 163 deletions
|
@ -54,19 +54,20 @@
|
|||
|
||||
namespace swrenderer
|
||||
{
|
||||
void RenderFogBoundary::Render(RenderThread *thread, int x1, int x2, const short *uclip, const short *dclip, int lightlevel, bool foggy, float lightleft, float lightstep, FDynamicColormap *basecolormap)
|
||||
void RenderFogBoundary::Render(RenderThread *thread, int x1, int x2, const short *uclip, const short *dclip, const ProjectedWallLight &wallLight)
|
||||
{
|
||||
// This is essentially the same as R_MapVisPlane but with an extra step
|
||||
// to create new horizontal spans whenever the light changes enough that
|
||||
// we need to use a new colormap.
|
||||
|
||||
int wallshade = LightVisibility::LightLevelToShade(lightlevel, foggy, thread->Viewport.get());
|
||||
float light = lightleft + lightstep*(x2 - x1 - 1);
|
||||
int wallshade = LightVisibility::LightLevelToShade(wallLight.GetLightLevel(), wallLight.GetFoggy(), thread->Viewport.get());
|
||||
int x = x2 - 1;
|
||||
int t2 = uclip[x];
|
||||
int b2 = dclip[x];
|
||||
float light = wallLight.GetLightPos(x);
|
||||
int rcolormap = GETPALOOKUP(light, wallshade);
|
||||
int lcolormap;
|
||||
FDynamicColormap *basecolormap = wallLight.GetBaseColormap();
|
||||
uint8_t *basecolormapdata = basecolormap->Maps;
|
||||
|
||||
if (b2 > t2)
|
||||
|
@ -75,7 +76,7 @@ namespace swrenderer
|
|||
}
|
||||
|
||||
drawerargs.SetBaseColormap(basecolormap);
|
||||
drawerargs.SetLight(light, lightlevel, foggy, thread->Viewport.get());
|
||||
drawerargs.SetLight(light, wallLight.GetLightLevel(), wallLight.GetFoggy(), thread->Viewport.get());
|
||||
|
||||
uint8_t *fake_dc_colormap = basecolormap->Maps + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT);
|
||||
|
||||
|
@ -86,7 +87,7 @@ namespace swrenderer
|
|||
const int xr = x + 1;
|
||||
int stop;
|
||||
|
||||
light -= lightstep;
|
||||
light -= wallLight.GetLightStep();
|
||||
lcolormap = GETPALOOKUP(light, wallshade);
|
||||
if (lcolormap != rcolormap)
|
||||
{
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace swrenderer
|
|||
class RenderFogBoundary
|
||||
{
|
||||
public:
|
||||
void Render(RenderThread *thread, int x1, int x2, const short *uclip, const short *dclip, int lightlevel, bool foggy, float lightleft, float lightstep, FDynamicColormap *basecolormap);
|
||||
void Render(RenderThread *thread, int x1, int x2, const short *uclip, const short *dclip, const ProjectedWallLight &wallLight);
|
||||
|
||||
private:
|
||||
void RenderSection(RenderThread *thread, int y, int y2, int x1);
|
||||
|
|
|
@ -71,15 +71,13 @@ namespace swrenderer
|
|||
Thread = thread;
|
||||
}
|
||||
|
||||
void SWRenderLine::Render(seg_t *line, subsector_t *subsector, sector_t *sector, sector_t *fakebacksector, VisiblePlane *linefloorplane, VisiblePlane *lineceilingplane, bool infog, FDynamicColormap *colormap, Fake3DOpaque opaque3dfloor)
|
||||
void SWRenderLine::Render(seg_t *line, subsector_t *subsector, sector_t *sector, sector_t *fakebacksector, VisiblePlane *linefloorplane, VisiblePlane *lineceilingplane, Fake3DOpaque opaque3dfloor)
|
||||
{
|
||||
mSubsector = subsector;
|
||||
mFrontSector = sector;
|
||||
mBackSector = fakebacksector;
|
||||
mFloorPlane = linefloorplane;
|
||||
mCeilingPlane = lineceilingplane;
|
||||
mLight.foggy = infog;
|
||||
mLight.basecolormap = colormap;
|
||||
mLineSegment = line;
|
||||
m3DFloor = opaque3dfloor;
|
||||
|
||||
|
@ -314,7 +312,7 @@ namespace swrenderer
|
|||
if (!rw_prepped)
|
||||
{
|
||||
rw_prepped = true;
|
||||
SetWallVariables(true);
|
||||
SetWallVariables();
|
||||
}
|
||||
|
||||
side_t *sidedef = mLineSegment->sidedef;
|
||||
|
@ -326,8 +324,7 @@ namespace swrenderer
|
|||
|
||||
// 3D floors code abuses the line render code to update plane clipping
|
||||
// lists but doesn't actually draw anything.
|
||||
bool onlyUpdatePlaneClip = (m3DFloor.type != Fake3DOpaque::Normal);
|
||||
if (!onlyUpdatePlaneClip)
|
||||
if (m3DFloor.type == Fake3DOpaque::Normal)
|
||||
Thread->DrawSegments->Push(draw_segment);
|
||||
|
||||
draw_segment->CurrentPortalUniq = renderportal->CurrentPortalUniq;
|
||||
|
@ -345,7 +342,6 @@ namespace swrenderer
|
|||
draw_segment->x1 = start;
|
||||
draw_segment->x2 = stop;
|
||||
draw_segment->curline = mLineSegment;
|
||||
draw_segment->foggy = mLight.foggy;
|
||||
draw_segment->SubsectorDepth = Thread->OpaquePass->GetSubsectorDepth(mSubsector->Index());
|
||||
|
||||
bool markportal = ShouldMarkPortal();
|
||||
|
@ -400,29 +396,30 @@ namespace swrenderer
|
|||
}
|
||||
}
|
||||
|
||||
if (!onlyUpdatePlaneClip && r_3dfloors)
|
||||
if (m3DFloor.type == Fake3DOpaque::Normal)
|
||||
{
|
||||
if (mBackSector->e && mBackSector->e->XFloor.ffloors.Size()) {
|
||||
for (i = 0; i < (int)mBackSector->e->XFloor.ffloors.Size(); i++) {
|
||||
F3DFloor *rover = mBackSector->e->XFloor.ffloors[i];
|
||||
if (rover->flags & FF_RENDERSIDES && (!(rover->flags & FF_INVERTSIDES) || rover->flags & FF_ALLSIDES)) {
|
||||
draw_segment->SetHas3DFloorBackSectorWalls();
|
||||
break;
|
||||
if (r_3dfloors)
|
||||
{
|
||||
if (mBackSector->e && mBackSector->e->XFloor.ffloors.Size()) {
|
||||
for (i = 0; i < (int)mBackSector->e->XFloor.ffloors.Size(); i++) {
|
||||
F3DFloor *rover = mBackSector->e->XFloor.ffloors[i];
|
||||
if (rover->flags & FF_RENDERSIDES && (!(rover->flags & FF_INVERTSIDES) || rover->flags & FF_ALLSIDES)) {
|
||||
draw_segment->SetHas3DFloorBackSectorWalls();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mFrontSector->e && mFrontSector->e->XFloor.ffloors.Size()) {
|
||||
for (i = 0; i < (int)mFrontSector->e->XFloor.ffloors.Size(); i++) {
|
||||
F3DFloor *rover = mFrontSector->e->XFloor.ffloors[i];
|
||||
if (rover->flags & FF_RENDERSIDES && (rover->flags & FF_ALLSIDES || rover->flags & FF_INVERTSIDES)) {
|
||||
draw_segment->SetHas3DFloorFrontSectorWalls();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mFrontSector->e && mFrontSector->e->XFloor.ffloors.Size()) {
|
||||
for (i = 0; i < (int)mFrontSector->e->XFloor.ffloors.Size(); i++) {
|
||||
F3DFloor *rover = mFrontSector->e->XFloor.ffloors[i];
|
||||
if (rover->flags & FF_RENDERSIDES && (rover->flags & FF_ALLSIDES || rover->flags & FF_INVERTSIDES)) {
|
||||
draw_segment->SetHas3DFloorFrontSectorWalls();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!onlyUpdatePlaneClip)
|
||||
// allocate space for masked texture tables, if needed
|
||||
// [RH] Don't just allocate the space; fill it in too.
|
||||
if ((sidedef->GetTexture(side_t::mid).isValid() || draw_segment->Has3DFloorWalls() || IsFogBoundary(mFrontSector, mBackSector)) &&
|
||||
|
@ -452,8 +449,8 @@ namespace swrenderer
|
|||
lwal = draw_segment->maskedtexturecol;
|
||||
swal = draw_segment->swall;
|
||||
FTexture *tex = TexMan.GetPalettedTexture(sidedef->GetTexture(side_t::mid), true);
|
||||
FSoftwareTexture *pic = tex && tex->isValid()? tex->GetSoftwareTexture() : nullptr;
|
||||
double yscale = (pic? pic->GetScale().Y : 1.0) * sidedef->GetTextureYScale(side_t::mid);
|
||||
FSoftwareTexture *pic = tex && tex->isValid() ? tex->GetSoftwareTexture() : nullptr;
|
||||
double yscale = (pic ? pic->GetScale().Y : 1.0) * sidedef->GetTextureYScale(side_t::mid);
|
||||
fixed_t xoffset = FLOAT2FIXED(sidedef->GetTextureXOffset(side_t::mid));
|
||||
|
||||
if (pic && pic->useWorldPanning())
|
||||
|
@ -490,27 +487,16 @@ namespace swrenderer
|
|||
draw_segment->iscalestep = 0;
|
||||
}
|
||||
}
|
||||
|
||||
draw_segment->light = mLight.GetLightPos(start);
|
||||
draw_segment->lightstep = mLight.GetLightStep();
|
||||
|
||||
// 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
|
||||
// comes from. We make an exeption for polyobjects, however, since their "home"
|
||||
// sector should be whichever one they move into.
|
||||
if (mLineSegment->sidedef->Flags & WALLF_POLYOBJ)
|
||||
{
|
||||
draw_segment->lightlevel = mLight.lightlevel;
|
||||
}
|
||||
else
|
||||
{
|
||||
draw_segment->lightlevel = mLineSegment->sidedef->GetLightLevel(mLight.foggy, mLineSegment->frontsector->lightlevel);
|
||||
}
|
||||
|
||||
if (draw_segment->bFogBoundary || draw_segment->maskedtexturecol != nullptr)
|
||||
{
|
||||
Thread->DrawSegments->PushTranslucent(draw_segment);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ClipSegmentTopBottom(start, stop);
|
||||
|
@ -700,7 +686,7 @@ namespace swrenderer
|
|||
}
|
||||
}
|
||||
|
||||
void SWRenderLine::SetWallVariables(bool needlights)
|
||||
void SWRenderLine::SetWallVariables()
|
||||
{
|
||||
RenderPortal *renderportal = Thread->Portal.get();
|
||||
|
||||
|
@ -775,8 +761,13 @@ namespace swrenderer
|
|||
|
||||
bool segtextured = ftex != NULL || mTopPart.Texture != NULL || mBottomPart.Texture != NULL;
|
||||
|
||||
if (m3DFloor.type == Fake3DOpaque::Normal)
|
||||
{
|
||||
mLight.SetColormap(mFrontSector, mLineSegment);
|
||||
}
|
||||
|
||||
// calculate light table
|
||||
if (needlights && (segtextured || (mBackSector && IsFogBoundary(mFrontSector, mBackSector))))
|
||||
if (segtextured || (mBackSector && IsFogBoundary(mFrontSector, mBackSector)))
|
||||
{
|
||||
lwallscale =
|
||||
ftex ? ((midtex? midtex->GetScale().X : 1.0) * sidedef->GetTextureXScale(side_t::mid)) :
|
||||
|
@ -786,7 +777,7 @@ namespace swrenderer
|
|||
|
||||
walltexcoords.Project(Thread->Viewport.get(), sidedef->TexelLength * lwallscale, WallC.sx1, WallC.sx2, WallT);
|
||||
|
||||
mLight.SetLightLeft(Thread, mLineSegment, mFrontSector, WallC);
|
||||
mLight.SetLightLeft(Thread, WallC);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -72,13 +72,13 @@ namespace swrenderer
|
|||
{
|
||||
public:
|
||||
SWRenderLine(RenderThread *thread);
|
||||
void Render(seg_t *line, subsector_t *subsector, sector_t *sector, sector_t *fakebacksector, VisiblePlane *floorplane, VisiblePlane *ceilingplane, bool foggy, FDynamicColormap *basecolormap, Fake3DOpaque fake3DOpaque);
|
||||
void Render(seg_t *line, subsector_t *subsector, sector_t *sector, sector_t *fakebacksector, VisiblePlane *floorplane, VisiblePlane *ceilingplane, Fake3DOpaque fake3DOpaque);
|
||||
|
||||
RenderThread *Thread = nullptr;
|
||||
|
||||
private:
|
||||
bool RenderWallSegment(int x1, int x2) override;
|
||||
void SetWallVariables(bool needlights);
|
||||
void SetWallVariables();
|
||||
void SetTopTexture();
|
||||
void SetMiddleTexture();
|
||||
void SetBottomTexture();
|
||||
|
|
|
@ -80,9 +80,7 @@ namespace swrenderer
|
|||
sector_t tempsec;
|
||||
const sector_t *sec = Thread->OpaquePass->FakeFlat(frontsector, &tempsec, nullptr, nullptr, nullptr, 0, 0, 0, 0);
|
||||
|
||||
mLight.basecolormap = GetColorTable(sec->Colormap, sec->SpecialColors[sector_t::walltop]); // [RH] Set basecolormap
|
||||
mLight.foggy = ds->foggy;
|
||||
mLight.lightlevel = ds->lightlevel;
|
||||
mLight.SetColormap(sec, curline);
|
||||
mLight.SetLightLeft(ds->light, ds->lightstep, ds->x1);
|
||||
|
||||
Clip3DFloors *clip3d = Thread->Clip3D.get();
|
||||
|
@ -92,10 +90,7 @@ namespace swrenderer
|
|||
{
|
||||
if (clipTop <= frontsector->e->XFloor.lightlist[i].plane.Zat0())
|
||||
{
|
||||
lightlist_t *lit = &frontsector->e->XFloor.lightlist[i];
|
||||
mLight.basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
|
||||
mLight.foggy = (level.fadeto || mLight.basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag
|
||||
mLight.lightlevel = curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr);
|
||||
mLight.SetColormap(frontsector, curline, &frontsector->e->XFloor.lightlist[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +100,7 @@ namespace swrenderer
|
|||
|
||||
SpriteDrawerArgs columndrawerargs;
|
||||
ColormapLight cmlight;
|
||||
cmlight.SetColormap(Thread, MINZ, mLight.lightlevel, mLight.foggy, mLight.basecolormap, false, false, false, false, false);
|
||||
cmlight.SetColormap(Thread, MINZ, mLight.GetLightLevel(), mLight.GetFoggy(), mLight.GetBaseColormap(), false, false, false, false, false);
|
||||
bool visible = columndrawerargs.SetStyle(viewport, LegacyRenderStyles[additive ? STYLE_Add : STYLE_Translucent], alpha, 0, 0, cmlight);
|
||||
if (!visible && !ds->bFogBoundary && !ds->Has3DFloorWalls())
|
||||
{
|
||||
|
@ -121,7 +116,7 @@ namespace swrenderer
|
|||
const short *mceilingclip = ds->sprtopclip - ds->x1;
|
||||
|
||||
RenderFogBoundary renderfog;
|
||||
renderfog.Render(Thread, x1, x2, mceilingclip, mfloorclip, mLight.lightlevel, ds->foggy, mLight.GetLightPos(x1), mLight.GetLightStep(), mLight.basecolormap);
|
||||
renderfog.Render(Thread, x1, x2, mceilingclip, mfloorclip, mLight);
|
||||
|
||||
if (ds->maskedtexturecol == nullptr)
|
||||
renderwall = false;
|
||||
|
@ -319,7 +314,7 @@ namespace swrenderer
|
|||
for (int x = x1; x < x2; ++x)
|
||||
{
|
||||
if (needslight)
|
||||
columndrawerargs.SetLight(lightpos, mLight.lightlevel, mLight.foggy, Thread->Viewport.get());
|
||||
columndrawerargs.SetLight(lightpos, mLight.GetLightLevel(), mLight.GetFoggy(), Thread->Viewport.get());
|
||||
|
||||
fixed_t iscale = xs_Fix<16>::ToFix(MaskedSWall[x] * MaskedScaleY);
|
||||
double sprtopscreen;
|
||||
|
@ -693,45 +688,41 @@ namespace swrenderer
|
|||
}
|
||||
rw_pic = rw_tex && rw_tex->isValid() ? rw_tex->GetSoftwareTexture() : nullptr;
|
||||
}
|
||||
// correct colors now
|
||||
mLight.basecolormap = nullptr;
|
||||
mLight.lightlevel = ds->lightlevel;
|
||||
CameraLight *cameraLight = CameraLight::Instance();
|
||||
if (cameraLight->FixedLightLevel() < 0)
|
||||
{
|
||||
if (ds->Has3DFloorFrontSectorWalls() && !ds->Has3DFloorBackSectorWalls())
|
||||
{
|
||||
for (j = backsector->e->XFloor.lightlist.Size() - 1; j >= 0; j--)
|
||||
{
|
||||
if (clipTop <= backsector->e->XFloor.lightlist[j].plane.Zat0())
|
||||
{
|
||||
lightlist_t *lit = &backsector->e->XFloor.lightlist[j];
|
||||
mLight.basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
|
||||
mLight.foggy = (level.fadeto || mLight.basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag
|
||||
mLight.lightlevel = curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (j = frontsector->e->XFloor.lightlist.Size() - 1; j >= 0; j--)
|
||||
{
|
||||
if (clipTop <= frontsector->e->XFloor.lightlist[j].plane.Zat0())
|
||||
{
|
||||
lightlist_t *lit = &frontsector->e->XFloor.lightlist[j];
|
||||
mLight.basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
|
||||
mLight.foggy = (level.fadeto || mLight.basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag
|
||||
mLight.lightlevel = curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mLight.basecolormap == nullptr) mLight.basecolormap = GetColorTable(frontsector->Colormap, frontsector->SpecialColors[sector_t::walltop]);
|
||||
|
||||
if (rw_pic && !swimmable_found)
|
||||
{
|
||||
// correct colors now
|
||||
lightlist_t *lit = nullptr;
|
||||
CameraLight *cameraLight = CameraLight::Instance();
|
||||
if (cameraLight->FixedLightLevel() < 0)
|
||||
{
|
||||
if (ds->Has3DFloorFrontSectorWalls() && !ds->Has3DFloorBackSectorWalls())
|
||||
{
|
||||
for (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 (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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//mLight.lightlevel = ds->lightlevel;
|
||||
mLight.SetColormap(frontsector, curline, lit);
|
||||
|
||||
RenderFakeWall(ds, x1, x2, fover ? fover : rover, clipTop, clipBottom, rw_pic);
|
||||
}
|
||||
break;
|
||||
|
@ -880,45 +871,40 @@ namespace swrenderer
|
|||
}
|
||||
rw_pic = rw_tex && rw_tex->isValid() ? rw_tex->GetSoftwareTexture() : nullptr;
|
||||
}
|
||||
// correct colors now
|
||||
mLight.basecolormap = nullptr;
|
||||
mLight.lightlevel = ds->lightlevel;
|
||||
CameraLight *cameraLight = CameraLight::Instance();
|
||||
if (cameraLight->FixedLightLevel() < 0)
|
||||
{
|
||||
if (ds->Has3DFloorFrontSectorWalls() && !ds->Has3DFloorBackSectorWalls())
|
||||
{
|
||||
for (j = backsector->e->XFloor.lightlist.Size() - 1; j >= 0; j--)
|
||||
{
|
||||
if (clipTop <= backsector->e->XFloor.lightlist[j].plane.Zat0())
|
||||
{
|
||||
lightlist_t *lit = &backsector->e->XFloor.lightlist[j];
|
||||
mLight.basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
|
||||
mLight.foggy = (level.fadeto || mLight.basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag
|
||||
mLight.lightlevel = curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (j = frontsector->e->XFloor.lightlist.Size() - 1; j >= 0; j--)
|
||||
{
|
||||
if (clipTop <= frontsector->e->XFloor.lightlist[j].plane.Zat0())
|
||||
{
|
||||
lightlist_t *lit = &frontsector->e->XFloor.lightlist[j];
|
||||
mLight.basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
|
||||
mLight.foggy = (level.fadeto || mLight.basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag
|
||||
mLight.lightlevel = curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mLight.basecolormap == nullptr) mLight.basecolormap = GetColorTable(frontsector->Colormap, frontsector->SpecialColors[sector_t::walltop]);
|
||||
|
||||
if (rw_pic && !swimmable_found)
|
||||
{
|
||||
// correct colors now
|
||||
lightlist_t *lit = nullptr;
|
||||
CameraLight *cameraLight = CameraLight::Instance();
|
||||
if (cameraLight->FixedLightLevel() < 0)
|
||||
{
|
||||
if (ds->Has3DFloorFrontSectorWalls() && !ds->Has3DFloorBackSectorWalls())
|
||||
{
|
||||
for (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 (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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//mLight.lightlevel = ds->lightlevel;
|
||||
mLight.SetColormap(frontsector, curline, lit);
|
||||
|
||||
RenderFakeWall(ds, x1, x2, fover ? fover : rover, clipTop, clipBottom, rw_pic);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -349,11 +349,11 @@ namespace swrenderer
|
|||
// Textures that aren't masked can use the faster opaque drawer
|
||||
if (!rw_pic->GetTexture()->isMasked() && mask && alpha >= OPAQUE && !additive)
|
||||
{
|
||||
drawerargs.SetStyle(true, false, OPAQUE, mLight.basecolormap);
|
||||
drawerargs.SetStyle(true, false, OPAQUE, mLight.GetBaseColormap());
|
||||
}
|
||||
else
|
||||
{
|
||||
drawerargs.SetStyle(mask, additive, alpha, mLight.basecolormap);
|
||||
drawerargs.SetStyle(mask, additive, alpha, mLight.GetBaseColormap());
|
||||
}
|
||||
|
||||
CameraLight *cameraLight = CameraLight::Instance();
|
||||
|
@ -377,7 +377,7 @@ namespace swrenderer
|
|||
continue;
|
||||
|
||||
if (!fixed)
|
||||
drawerargs.SetLight(curlight, mLight.lightlevel, mLight.foggy, Thread->Viewport.get());
|
||||
drawerargs.SetLight(curlight, mLight.GetLightLevel(), mLight.GetFoggy(), Thread->Viewport.get());
|
||||
|
||||
if (x + 1 < x2) xmagnitude = fabs(FIXED2DBL(lwal[x + 1]) - FIXED2DBL(lwal[x]));
|
||||
|
||||
|
@ -423,9 +423,7 @@ namespace swrenderer
|
|||
down = (down == most1.ScreenY) ? most2.ScreenY : most1.ScreenY;
|
||||
}
|
||||
|
||||
lightlist_t *lit = &frontsector->e->XFloor.lightlist[i];
|
||||
mLight.basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
|
||||
mLight.lightlevel = curline->sidedef->GetLightLevel(mLight.foggy, *lit->p_lightlevel, lit->lightsource != NULL);
|
||||
mLight.SetColormap(frontsector, curline, &frontsector->e->XFloor.lightlist[i]);
|
||||
}
|
||||
|
||||
ProcessNormalWall(up, dwal, texturemid, swal, lwal);
|
||||
|
|
|
@ -244,14 +244,13 @@ namespace swrenderer
|
|||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ProjectedWallLight::SetLightLeft(RenderThread *thread, seg_t *lineseg, sector_t *frontsector, const FWallCoords &wallc)
|
||||
void ProjectedWallLight::SetLightLeft(RenderThread *thread, const FWallCoords &wallc)
|
||||
{
|
||||
x1 = wallc.sx1;
|
||||
|
||||
CameraLight *cameraLight = CameraLight::Instance();
|
||||
if (cameraLight->FixedColormap() == nullptr && cameraLight->FixedLightLevel() < 0)
|
||||
{
|
||||
lightlevel = lineseg->sidedef->GetLightLevel(foggy, frontsector->lightlevel);
|
||||
lightleft = float(thread->Light->WallVis(wallc.sz1, foggy));
|
||||
lightstep = float((thread->Light->WallVis(wallc.sz2, foggy) - lightleft) / (wallc.sx2 - wallc.sx1));
|
||||
}
|
||||
|
@ -261,4 +260,24 @@ namespace swrenderer
|
|||
lightstep = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectedWallLight::SetColormap(const sector_t *frontsector, seg_t *lineseg, lightlist_t *lit)
|
||||
{
|
||||
if (!lit)
|
||||
{
|
||||
basecolormap = GetColorTable(frontsector->Colormap, frontsector->SpecialColors[sector_t::walltop]);
|
||||
foggy = level.fadeto || frontsector->Colormap.FadeColor || (level.flags & LEVEL_HASFADETABLE);
|
||||
|
||||
if (!(lineseg->sidedef->Flags & WALLF_POLYOBJ))
|
||||
lightlevel = lineseg->sidedef->GetLightLevel(foggy, frontsector->lightlevel);
|
||||
else
|
||||
lightlevel = frontsector->GetLightLevel();
|
||||
}
|
||||
else
|
||||
{
|
||||
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
|
||||
foggy = level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE);
|
||||
lightlevel = lineseg->sidedef->GetLightLevel(foggy, *lit->p_lightlevel, lit->lightsource != nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,17 +60,23 @@ namespace swrenderer
|
|||
class ProjectedWallLight
|
||||
{
|
||||
public:
|
||||
int lightlevel;
|
||||
bool foggy;
|
||||
FDynamicColormap *basecolormap;
|
||||
int GetLightLevel() const { return lightlevel; }
|
||||
bool GetFoggy() const { return foggy; }
|
||||
FDynamicColormap *GetBaseColormap() const { return basecolormap; }
|
||||
|
||||
float GetLightPos(int x) const { return lightleft + lightstep * (x - x1); }
|
||||
float GetLightStep() const { return lightstep; }
|
||||
|
||||
void SetColormap(const sector_t *frontsector, seg_t *lineseg, lightlist_t *lit = nullptr);
|
||||
|
||||
void SetLightLeft(float left, float step, int startx) { lightleft = left; lightstep = step; x1 = startx; }
|
||||
void SetLightLeft(RenderThread *thread, seg_t *lineseg, sector_t *frontsector, const FWallCoords &wallc);
|
||||
void SetLightLeft(RenderThread *thread, const FWallCoords &wallc);
|
||||
|
||||
private:
|
||||
int lightlevel;
|
||||
bool foggy;
|
||||
FDynamicColormap *basecolormap;
|
||||
|
||||
int x1;
|
||||
float lightleft;
|
||||
float lightstep;
|
||||
|
|
|
@ -451,7 +451,7 @@ namespace swrenderer
|
|||
}
|
||||
|
||||
// kg3D - add fake segs, never rendered
|
||||
void RenderOpaquePass::FakeDrawLoop(subsector_t *sub, sector_t *frontsector, VisiblePlane *floorplane, VisiblePlane *ceilingplane, bool foggy, FDynamicColormap *basecolormap, Fake3DOpaque opaque3dfloor)
|
||||
void RenderOpaquePass::FakeDrawLoop(subsector_t *sub, sector_t *frontsector, VisiblePlane *floorplane, VisiblePlane *ceilingplane, Fake3DOpaque opaque3dfloor)
|
||||
{
|
||||
int count;
|
||||
seg_t* line;
|
||||
|
@ -463,7 +463,7 @@ namespace swrenderer
|
|||
{
|
||||
if ((line->sidedef) && !(line->sidedef->Flags & WALLF_POLYOBJ))
|
||||
{
|
||||
renderline.Render(line, InSubsector, frontsector, nullptr, floorplane, ceilingplane, foggy, basecolormap, opaque3dfloor);
|
||||
renderline.Render(line, InSubsector, frontsector, nullptr, floorplane, ceilingplane, opaque3dfloor);
|
||||
}
|
||||
line++;
|
||||
}
|
||||
|
@ -622,8 +622,6 @@ namespace swrenderer
|
|||
|
||||
DVector2 viewpointPos = Thread->Viewport->viewpoint.Pos.XY();
|
||||
|
||||
basecolormap = GetColorTable(frontsector->Colormap, frontsector->SpecialColors[sector_t::walltop]);
|
||||
|
||||
seg_t *line = sub->firstline;
|
||||
int count = sub->numlines;
|
||||
while (count--)
|
||||
|
@ -637,8 +635,8 @@ namespace swrenderer
|
|||
}
|
||||
else if (!outersubsector || line->sidedef == nullptr || !(line->sidedef->Flags & WALLF_POLYOBJ))
|
||||
{
|
||||
Add3DFloorLine(line, frontsector, basecolormap, foggy);
|
||||
renderline.Render(line, InSubsector, frontsector, nullptr, floorplane, ceilingplane, foggy, basecolormap, Fake3DOpaque::Normal); // now real
|
||||
Add3DFloorLine(line, frontsector);
|
||||
renderline.Render(line, InSubsector, frontsector, nullptr, floorplane, ceilingplane, Fake3DOpaque::Normal); // now real
|
||||
}
|
||||
line++;
|
||||
}
|
||||
|
@ -648,7 +646,7 @@ namespace swrenderer
|
|||
}
|
||||
}
|
||||
|
||||
void RenderOpaquePass::Add3DFloorLine(seg_t *line, sector_t *frontsector, FDynamicColormap *basecolormap, bool foggy)
|
||||
void RenderOpaquePass::Add3DFloorLine(seg_t *line, sector_t *frontsector)
|
||||
{
|
||||
// kg3D - fake planes bounding calculation
|
||||
if (r_3dfloors && line->backsector && frontsector->e && line->backsector->e->XFloor.ffloors.Size())
|
||||
|
@ -669,7 +667,7 @@ namespace swrenderer
|
|||
clip3d->fakeFloor->validcount = validcount;
|
||||
clip3d->NewClip();
|
||||
}
|
||||
renderline.Render(line, InSubsector, frontsector, &tempsec, nullptr, nullptr, foggy, basecolormap, opaque3dfloor); // fake
|
||||
renderline.Render(line, InSubsector, frontsector, &tempsec, nullptr, nullptr, opaque3dfloor); // fake
|
||||
}
|
||||
clip3d->fakeFloor = nullptr;
|
||||
}
|
||||
|
@ -744,7 +742,7 @@ namespace swrenderer
|
|||
|
||||
floorplane3d->AddLights(Thread, sub->section->lighthead);
|
||||
|
||||
FakeDrawLoop(sub, &tempsec, floorplane3d, nullptr, foggy, basecolormap, Fake3DOpaque::FakeFloor);
|
||||
FakeDrawLoop(sub, &tempsec, floorplane3d, nullptr, Fake3DOpaque::FakeFloor);
|
||||
}
|
||||
}
|
||||
// and now ceilings
|
||||
|
@ -812,7 +810,7 @@ namespace swrenderer
|
|||
|
||||
ceilingplane3d->AddLights(Thread, sub->section->lighthead);
|
||||
|
||||
FakeDrawLoop(sub, &tempsec, nullptr, ceilingplane3d, foggy, basecolormap, Fake3DOpaque::FakeCeiling);
|
||||
FakeDrawLoop(sub, &tempsec, nullptr, ceilingplane3d, Fake3DOpaque::FakeCeiling);
|
||||
}
|
||||
}
|
||||
clip3d->fakeFloor = nullptr;
|
||||
|
|
|
@ -86,8 +86,8 @@ namespace swrenderer
|
|||
void AddPolyobjs(subsector_t *sub);
|
||||
|
||||
void Add3DFloorPlanes(subsector_t *sub, sector_t *frontsector, FDynamicColormap *basecolormap, bool foggy, int adjusted_ceilinglightlevel, int adjusted_floorlightlevel);
|
||||
void FakeDrawLoop(subsector_t *sub, sector_t *frontsector, VisiblePlane *floorplane, VisiblePlane *ceilingplane, bool foggy, FDynamicColormap *basecolormap, Fake3DOpaque opaque3dfloor);
|
||||
void Add3DFloorLine(seg_t *line, sector_t *frontsector, FDynamicColormap *basecolormap, bool foggy);
|
||||
void FakeDrawLoop(subsector_t *sub, sector_t *frontsector, VisiblePlane *floorplane, VisiblePlane *ceilingplane, Fake3DOpaque opaque3dfloor);
|
||||
void Add3DFloorLine(seg_t *line, sector_t *frontsector);
|
||||
|
||||
void AddSprites(sector_t *sec, int lightlevel, WaterFakeSide fakeside, bool foggy, FDynamicColormap *basecolormap);
|
||||
bool IsPotentiallyVisible(AActor *thing);
|
||||
|
|
|
@ -219,7 +219,6 @@ namespace swrenderer
|
|||
draw_segment->swall = nullptr;
|
||||
draw_segment->bFogBoundary = false;
|
||||
draw_segment->curline = nullptr;
|
||||
draw_segment->foggy = false;
|
||||
memcpy(draw_segment->sprbottomclip, floorclip + pl->left, (pl->right - pl->left) * sizeof(short));
|
||||
memcpy(draw_segment->sprtopclip, ceilingclip + pl->left, (pl->right - pl->left) * sizeof(short));
|
||||
drawseglist->Push(draw_segment);
|
||||
|
|
|
@ -38,8 +38,6 @@ namespace swrenderer
|
|||
float yscale;
|
||||
uint8_t silhouette = 0; // 0=none, 1=bottom, 2=top, 3=both
|
||||
bool bFogBoundary = false;
|
||||
int lightlevel = 0;
|
||||
bool foggy = false;
|
||||
|
||||
// Pointers to lists for sprite clipping, all three adjusted so [x1] is first value.
|
||||
short *sprtopclip = nullptr;
|
||||
|
|
|
@ -256,7 +256,7 @@ namespace swrenderer
|
|||
}
|
||||
|
||||
// Prepare lighting
|
||||
usecolormap = light.basecolormap;
|
||||
usecolormap = light.GetBaseColormap();
|
||||
|
||||
// Decals that are added to the scene must fade to black.
|
||||
if (decal->RenderStyle == LegacyRenderStyles[STYLE_Add] && usecolormap->Fade != 0)
|
||||
|
@ -287,7 +287,7 @@ namespace swrenderer
|
|||
int x = x1;
|
||||
|
||||
ColormapLight cmlight;
|
||||
cmlight.SetColormap(thread, MINZ, light.lightlevel, light.foggy, usecolormap, decal->RenderFlags & RF_FULLBRIGHT, false, false, false, false);
|
||||
cmlight.SetColormap(thread, MINZ, light.GetLightLevel(), light.GetFoggy(), usecolormap, decal->RenderFlags & RF_FULLBRIGHT, false, false, false, false);
|
||||
|
||||
SpriteDrawerArgs drawerargs;
|
||||
bool visible = drawerargs.SetStyle(thread->Viewport.get(), decal->RenderStyle, (float)decal->Alpha, decal->Translation, decal->AlphaColor, cmlight);
|
||||
|
@ -300,7 +300,7 @@ namespace swrenderer
|
|||
{
|
||||
if (calclighting)
|
||||
{ // calculate lighting
|
||||
drawerargs.SetLight(lightpos, light.lightlevel, light.foggy, thread->Viewport.get());
|
||||
drawerargs.SetLight(lightpos, light.GetLightLevel(), light.GetFoggy(), thread->Viewport.get());
|
||||
}
|
||||
DrawColumn(thread, drawerargs, x, WallSpriteTile, walltexcoords, texturemid, maskedScaleY, sprflipvert, mfloorclip, mceilingclip, decal->RenderStyle);
|
||||
lightpos += light.GetLightStep();
|
||||
|
|
Loading…
Reference in a new issue