mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 07:12:02 +00:00
Make LightVisibility thread local
This commit is contained in:
parent
438b983ab1
commit
00f6ed45a2
28 changed files with 45 additions and 48 deletions
|
@ -66,7 +66,7 @@ void PolyRenderer::RenderView(player_t *player)
|
||||||
int stHeight = gST_Y;
|
int stHeight = gST_Y;
|
||||||
float trueratio;
|
float trueratio;
|
||||||
ActiveRatio(width, height, &trueratio);
|
ActiveRatio(width, height, &trueratio);
|
||||||
viewport->SetViewport(width, height, trueratio);
|
viewport->SetViewport(&Thread, width, height, trueratio);
|
||||||
|
|
||||||
RenderActorView(player->mo, false);
|
RenderActorView(player->mo, false);
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ void PolyRenderer::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int
|
||||||
viewwidth = width;
|
viewwidth = width;
|
||||||
viewport->RenderTarget = canvas;
|
viewport->RenderTarget = canvas;
|
||||||
R_SetWindow(viewport->viewpoint, viewport->viewwindow, 12, width, height, height, true);
|
R_SetWindow(viewport->viewpoint, viewport->viewwindow, 12, width, height, height, true);
|
||||||
viewport->SetViewport(width, height, viewport->viewwindow.WidescreenRatio);
|
viewport->SetViewport(&Thread, width, height, viewport->viewwindow.WidescreenRatio);
|
||||||
viewwindowx = x;
|
viewwindowx = x;
|
||||||
viewwindowy = y;
|
viewwindowy = y;
|
||||||
viewactive = true;
|
viewactive = true;
|
||||||
|
@ -105,7 +105,7 @@ void PolyRenderer::RenderViewToCanvas(AActor *actor, DCanvas *canvas, int x, int
|
||||||
R_ExecuteSetViewSize(viewport->viewpoint, viewport->viewwindow);
|
R_ExecuteSetViewSize(viewport->viewpoint, viewport->viewwindow);
|
||||||
float trueratio;
|
float trueratio;
|
||||||
ActiveRatio(width, height, &trueratio);
|
ActiveRatio(width, height, &trueratio);
|
||||||
viewport->SetViewport(width, height, viewport->viewwindow.WidescreenRatio);
|
viewport->SetViewport(&Thread, width, height, viewport->viewwindow.WidescreenRatio);
|
||||||
viewactive = savedviewactive;
|
viewactive = savedviewactive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,7 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan
|
||||||
args.uniforms.flags = 0;
|
args.uniforms.flags = 0;
|
||||||
args.SetColormap(front->ColorMap);
|
args.SetColormap(front->ColorMap);
|
||||||
args.SetTexture(tex, decal->Translation, true);
|
args.SetTexture(tex, decal->Translation, true);
|
||||||
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->WallGlobVis(foggy);
|
args.uniforms.globvis = (float)PolyRenderer::Instance()->Thread.Light->WallGlobVis(foggy);
|
||||||
if (fullbrightSprite || cameraLight->FixedLightLevel() >= 0 || cameraLight->FixedColormap())
|
if (fullbrightSprite || cameraLight->FixedLightLevel() >= 0 || cameraLight->FixedColormap())
|
||||||
{
|
{
|
||||||
args.uniforms.light = 256;
|
args.uniforms.light = 256;
|
||||||
|
|
|
@ -76,7 +76,7 @@ void RenderPolyParticle::Render(const TriMatrix &worldToClip, const Vec4f &clipP
|
||||||
|
|
||||||
PolyDrawArgs args;
|
PolyDrawArgs args;
|
||||||
|
|
||||||
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->ParticleGlobVis(foggy);
|
args.uniforms.globvis = (float)PolyRenderer::Instance()->Thread.Light->ParticleGlobVis(foggy);
|
||||||
|
|
||||||
if (fullbrightSprite || cameraLight->FixedLightLevel() >= 0 || cameraLight->FixedColormap())
|
if (fullbrightSprite || cameraLight->FixedLightLevel() >= 0 || cameraLight->FixedColormap())
|
||||||
{
|
{
|
||||||
|
|
|
@ -112,7 +112,7 @@ void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, const Vec4f &c
|
||||||
UVTransform xform(ceiling ? fakeFloor->top.model->planes[sector_t::ceiling].xform : fakeFloor->top.model->planes[sector_t::floor].xform, tex);
|
UVTransform xform(ceiling ? fakeFloor->top.model->planes[sector_t::ceiling].xform : fakeFloor->top.model->planes[sector_t::floor].xform, tex);
|
||||||
|
|
||||||
PolyDrawArgs args;
|
PolyDrawArgs args;
|
||||||
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->SlopePlaneGlobVis(foggy) * 48.0f;
|
args.uniforms.globvis = (float)PolyRenderer::Instance()->Thread.Light->SlopePlaneGlobVis(foggy) * 48.0f;
|
||||||
args.uniforms.light = (uint32_t)(lightlevel / 255.0f * 256.0f);
|
args.uniforms.light = (uint32_t)(lightlevel / 255.0f * 256.0f);
|
||||||
if (cameraLight->FixedLightLevel() >= 0 || cameraLight->FixedColormap())
|
if (cameraLight->FixedLightLevel() >= 0 || cameraLight->FixedColormap())
|
||||||
args.uniforms.light = 256;
|
args.uniforms.light = 256;
|
||||||
|
@ -310,7 +310,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan
|
||||||
swrenderer::CameraLight *cameraLight = swrenderer::CameraLight::Instance();
|
swrenderer::CameraLight *cameraLight = swrenderer::CameraLight::Instance();
|
||||||
|
|
||||||
PolyDrawArgs args;
|
PolyDrawArgs args;
|
||||||
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->SlopePlaneGlobVis(foggy) * 48.0f;
|
args.uniforms.globvis = (float)PolyRenderer::Instance()->Thread.Light->SlopePlaneGlobVis(foggy) * 48.0f;
|
||||||
args.uniforms.light = (uint32_t)(frontsector->lightlevel / 255.0f * 256.0f);
|
args.uniforms.light = (uint32_t)(frontsector->lightlevel / 255.0f * 256.0f);
|
||||||
if (cameraLight->FixedLightLevel() >= 0 || cameraLight->FixedColormap())
|
if (cameraLight->FixedLightLevel() >= 0 || cameraLight->FixedColormap())
|
||||||
args.uniforms.light = 256;
|
args.uniforms.light = 256;
|
||||||
|
|
|
@ -228,7 +228,7 @@ void RenderPolyPlayerSprites::RenderSprite(DPSprite *sprite, AActor *owner, floa
|
||||||
int actualextralight = foggy ? 0 : viewpoint.extralight << 4;
|
int actualextralight = foggy ? 0 : viewpoint.extralight << 4;
|
||||||
int spriteshade = swrenderer::LightVisibility::LightLevelToShade(owner->Sector->lightlevel + actualextralight, foggy);
|
int spriteshade = swrenderer::LightVisibility::LightLevelToShade(owner->Sector->lightlevel + actualextralight, foggy);
|
||||||
double minz = double((2048 * 4) / double(1 << 20));
|
double minz = double((2048 * 4) / double(1 << 20));
|
||||||
ColormapNum = GETPALOOKUP(swrenderer::LightVisibility::Instance()->SpriteGlobVis(foggy) / minz, spriteshade);
|
ColormapNum = GETPALOOKUP(PolyRenderer::Instance()->Thread.Light->SpriteGlobVis(foggy) / minz, spriteshade);
|
||||||
|
|
||||||
if (sprite->GetID() < PSP_TARGETCENTER)
|
if (sprite->GetID() < PSP_TARGETCENTER)
|
||||||
{
|
{
|
||||||
|
|
|
@ -93,7 +93,7 @@ void PolyDrawSectorPortal::SaveGlobals()
|
||||||
savedextralight = viewpoint.extralight;
|
savedextralight = viewpoint.extralight;
|
||||||
savedpos = viewpoint.Pos;
|
savedpos = viewpoint.Pos;
|
||||||
savedangles = viewpoint.Angles;
|
savedangles = viewpoint.Angles;
|
||||||
savedvisibility = swrenderer::LightVisibility::Instance()->GetVisibility();
|
savedvisibility = PolyRenderer::Instance()->Thread.Light->GetVisibility();
|
||||||
savedcamera = viewpoint.camera;
|
savedcamera = viewpoint.camera;
|
||||||
savedsector = viewpoint.sector;
|
savedsector = viewpoint.sector;
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ void PolyDrawSectorPortal::SaveGlobals()
|
||||||
// Don't let gun flashes brighten the sky box
|
// Don't let gun flashes brighten the sky box
|
||||||
AActor *sky = Portal->mSkybox;
|
AActor *sky = Portal->mSkybox;
|
||||||
viewpoint.extralight = 0;
|
viewpoint.extralight = 0;
|
||||||
swrenderer::LightVisibility::Instance()->SetVisibility(PolyRenderer::Instance()->Thread.Viewport.get(), sky->args[0] * 0.25f);
|
PolyRenderer::Instance()->Thread.Light->SetVisibility(PolyRenderer::Instance()->Thread.Viewport.get(), sky->args[0] * 0.25f);
|
||||||
viewpoint.Pos = sky->InterpolatedPosition(viewpoint.TicFrac);
|
viewpoint.Pos = sky->InterpolatedPosition(viewpoint.TicFrac);
|
||||||
viewpoint.Angles.Yaw = savedangles.Yaw + (sky->PrevAngles.Yaw + deltaangle(sky->PrevAngles.Yaw, sky->Angles.Yaw) * viewpoint.TicFrac);
|
viewpoint.Angles.Yaw = savedangles.Yaw + (sky->PrevAngles.Yaw + deltaangle(sky->PrevAngles.Yaw, sky->Angles.Yaw) * viewpoint.TicFrac);
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ void PolyDrawSectorPortal::RestoreGlobals()
|
||||||
viewpoint.camera = savedcamera;
|
viewpoint.camera = savedcamera;
|
||||||
viewpoint.sector = savedsector;
|
viewpoint.sector = savedsector;
|
||||||
viewpoint.Pos = savedpos;
|
viewpoint.Pos = savedpos;
|
||||||
swrenderer::LightVisibility::Instance()->SetVisibility(PolyRenderer::Instance()->Thread.Viewport.get(), savedvisibility);
|
PolyRenderer::Instance()->Thread.Light->SetVisibility(PolyRenderer::Instance()->Thread.Viewport.get(), savedvisibility);
|
||||||
viewpoint.extralight = savedextralight;
|
viewpoint.extralight = savedextralight;
|
||||||
viewpoint.Angles = savedangles;
|
viewpoint.Angles = savedangles;
|
||||||
R_SetViewAngle(viewpoint, viewwindow);
|
R_SetViewAngle(viewpoint, viewwindow);
|
||||||
|
|
|
@ -244,7 +244,7 @@ void RenderPolyScene::RenderPortals(int portalDepth)
|
||||||
PolyDrawArgs args;
|
PolyDrawArgs args;
|
||||||
args.objectToClip = &WorldToClip;
|
args.objectToClip = &WorldToClip;
|
||||||
args.mode = TriangleDrawMode::Fan;
|
args.mode = TriangleDrawMode::Fan;
|
||||||
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->WallGlobVis(foggy);
|
args.uniforms.globvis = (float)PolyRenderer::Instance()->Thread.Light->WallGlobVis(foggy);
|
||||||
args.uniforms.color = 0;
|
args.uniforms.color = 0;
|
||||||
args.uniforms.light = 256;
|
args.uniforms.light = 256;
|
||||||
args.uniforms.flags = TriUniforms::fixed_light;
|
args.uniforms.flags = TriUniforms::fixed_light;
|
||||||
|
|
|
@ -57,7 +57,7 @@ void PolySkyDome::Render(const TriMatrix &worldToClip)
|
||||||
int rc = mRows + 1;
|
int rc = mRows + 1;
|
||||||
|
|
||||||
PolyDrawArgs args;
|
PolyDrawArgs args;
|
||||||
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->WallGlobVis(foggy);
|
args.uniforms.globvis = (float)PolyRenderer::Instance()->Thread.Light->WallGlobVis(foggy);
|
||||||
args.uniforms.light = 256;
|
args.uniforms.light = 256;
|
||||||
args.uniforms.flags = 0;
|
args.uniforms.flags = 0;
|
||||||
args.uniforms.subsectorDepth = RenderPolyScene::SkySubsectorDepth;
|
args.uniforms.subsectorDepth = RenderPolyScene::SkySubsectorDepth;
|
||||||
|
|
|
@ -141,7 +141,7 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const Vec4f &clipPla
|
||||||
swrenderer::CameraLight *cameraLight = swrenderer::CameraLight::Instance();
|
swrenderer::CameraLight *cameraLight = swrenderer::CameraLight::Instance();
|
||||||
|
|
||||||
PolyDrawArgs args;
|
PolyDrawArgs args;
|
||||||
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->SpriteGlobVis(foggy);
|
args.uniforms.globvis = (float)PolyRenderer::Instance()->Thread.Light->SpriteGlobVis(foggy);
|
||||||
args.uniforms.flags = 0;
|
args.uniforms.flags = 0;
|
||||||
if (fullbrightSprite || cameraLight->FixedLightLevel() >= 0 || cameraLight->FixedColormap())
|
if (fullbrightSprite || cameraLight->FixedLightLevel() >= 0 || cameraLight->FixedColormap())
|
||||||
{
|
{
|
||||||
|
|
|
@ -249,7 +249,7 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane
|
||||||
}
|
}
|
||||||
|
|
||||||
PolyDrawArgs args;
|
PolyDrawArgs args;
|
||||||
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->WallGlobVis(foggy);
|
args.uniforms.globvis = (float)PolyRenderer::Instance()->Thread.Light->WallGlobVis(foggy);
|
||||||
args.uniforms.light = (uint32_t)(GetLightLevel() / 255.0f * 256.0f);
|
args.uniforms.light = (uint32_t)(GetLightLevel() / 255.0f * 256.0f);
|
||||||
args.uniforms.flags = 0;
|
args.uniforms.flags = 0;
|
||||||
args.uniforms.subsectorDepth = SubsectorDepth;
|
args.uniforms.subsectorDepth = SubsectorDepth;
|
||||||
|
|
|
@ -102,7 +102,7 @@ void RenderPolyWallSprite::Render(const TriMatrix &worldToClip, const Vec4f &cli
|
||||||
swrenderer::CameraLight *cameraLight = swrenderer::CameraLight::Instance();
|
swrenderer::CameraLight *cameraLight = swrenderer::CameraLight::Instance();
|
||||||
|
|
||||||
PolyDrawArgs args;
|
PolyDrawArgs args;
|
||||||
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->WallGlobVis(foggy);
|
args.uniforms.globvis = (float)PolyRenderer::Instance()->Thread.Light->WallGlobVis(foggy);
|
||||||
if (fullbrightSprite || cameraLight->FixedLightLevel() >= 0 || cameraLight->FixedColormap())
|
if (fullbrightSprite || cameraLight->FixedLightLevel() >= 0 || cameraLight->FixedColormap())
|
||||||
{
|
{
|
||||||
args.uniforms.light = 256;
|
args.uniforms.light = 256;
|
||||||
|
|
|
@ -782,7 +782,7 @@ namespace swrenderer
|
||||||
if (cameraLight->FixedColormap() == nullptr && cameraLight->FixedLightLevel() < 0)
|
if (cameraLight->FixedColormap() == nullptr && cameraLight->FixedLightLevel() < 0)
|
||||||
{
|
{
|
||||||
wallshade = LightVisibility::LightLevelToShade(mLineSegment->sidedef->GetLightLevel(foggy, mFrontSector->lightlevel) + LightVisibility::ActualExtraLight(foggy, Thread->Viewport.get()), foggy);
|
wallshade = LightVisibility::LightLevelToShade(mLineSegment->sidedef->GetLightLevel(foggy, mFrontSector->lightlevel) + LightVisibility::ActualExtraLight(foggy, Thread->Viewport.get()), foggy);
|
||||||
double GlobVis = LightVisibility::Instance()->WallGlobVis(foggy);
|
double GlobVis = Thread->Light->WallGlobVis(foggy);
|
||||||
rw_lightleft = float(GlobVis / WallC.sz1);
|
rw_lightleft = float(GlobVis / WallC.sz1);
|
||||||
rw_lightstep = float((GlobVis / WallC.sz2 - rw_lightleft) / (WallC.sx2 - WallC.sx1));
|
rw_lightstep = float((GlobVis / WallC.sz2 - rw_lightleft) / (WallC.sx2 - WallC.sx1));
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,7 @@ namespace swrenderer
|
||||||
// [RH] set foggy flag
|
// [RH] set foggy flag
|
||||||
bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE));
|
bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE));
|
||||||
|
|
||||||
GlobVis = LightVisibility::Instance()->FlatPlaneGlobVis(foggy) / planeheight;
|
GlobVis = Thread->Light->FlatPlaneGlobVis(foggy) / planeheight;
|
||||||
|
|
||||||
CameraLight *cameraLight = CameraLight::Instance();
|
CameraLight *cameraLight = CameraLight::Instance();
|
||||||
if (cameraLight->FixedLightLevel() >= 0)
|
if (cameraLight->FixedLightLevel() >= 0)
|
||||||
|
|
|
@ -157,7 +157,7 @@ namespace swrenderer
|
||||||
basecolormap = colormap;
|
basecolormap = colormap;
|
||||||
bool foggy = level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE);;
|
bool foggy = level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE);;
|
||||||
|
|
||||||
planelightfloat = (LightVisibility::Instance()->SlopePlaneGlobVis(foggy) * lxscale * lyscale) / (fabs(pl->height.ZatPoint(Thread->Viewport->viewpoint.Pos) - Thread->Viewport->viewpoint.Pos.Z)) / 65536.f;
|
planelightfloat = (Thread->Light->SlopePlaneGlobVis(foggy) * lxscale * lyscale) / (fabs(pl->height.ZatPoint(Thread->Viewport->viewpoint.Pos) - Thread->Viewport->viewpoint.Pos.Z)) / 65536.f;
|
||||||
|
|
||||||
if (pl->height.fC() > 0)
|
if (pl->height.fC() > 0)
|
||||||
planelightfloat = -planelightfloat;
|
planelightfloat = -planelightfloat;
|
||||||
|
|
|
@ -62,6 +62,7 @@ namespace swrenderer
|
||||||
MainThread = mainThread;
|
MainThread = mainThread;
|
||||||
FrameMemory = std::make_unique<RenderMemory>();
|
FrameMemory = std::make_unique<RenderMemory>();
|
||||||
Viewport = std::make_unique<RenderViewport>();
|
Viewport = std::make_unique<RenderViewport>();
|
||||||
|
Light = std::make_unique<LightVisibility>();
|
||||||
DrawQueue = std::make_shared<DrawerCommandQueue>(this);
|
DrawQueue = std::make_shared<DrawerCommandQueue>(this);
|
||||||
OpaquePass = std::make_unique<RenderOpaquePass>(this);
|
OpaquePass = std::make_unique<RenderOpaquePass>(this);
|
||||||
TranslucentPass = std::make_unique<RenderTranslucentPass>(this);
|
TranslucentPass = std::make_unique<RenderTranslucentPass>(this);
|
||||||
|
|
|
@ -43,6 +43,7 @@ namespace swrenderer
|
||||||
class RenderClipSegment;
|
class RenderClipSegment;
|
||||||
class RenderMemory;
|
class RenderMemory;
|
||||||
class RenderViewport;
|
class RenderViewport;
|
||||||
|
class LightVisibility;
|
||||||
class SWPixelFormatDrawers;
|
class SWPixelFormatDrawers;
|
||||||
class SWTruecolorDrawers;
|
class SWTruecolorDrawers;
|
||||||
class SWPalDrawers;
|
class SWPalDrawers;
|
||||||
|
@ -69,6 +70,7 @@ namespace swrenderer
|
||||||
std::unique_ptr<DrawSegmentList> DrawSegments;
|
std::unique_ptr<DrawSegmentList> DrawSegments;
|
||||||
std::unique_ptr<RenderClipSegment> ClipSegments;
|
std::unique_ptr<RenderClipSegment> ClipSegments;
|
||||||
std::unique_ptr<RenderViewport> Viewport;
|
std::unique_ptr<RenderViewport> Viewport;
|
||||||
|
std::unique_ptr<LightVisibility> Light;
|
||||||
DrawerCommandQueuePtr DrawQueue;
|
DrawerCommandQueuePtr DrawQueue;
|
||||||
|
|
||||||
std::thread thread;
|
std::thread thread;
|
||||||
|
|
|
@ -370,10 +370,10 @@ void FSoftwareRenderer::CleanLevelData()
|
||||||
|
|
||||||
double FSoftwareRenderer::GetVisibility()
|
double FSoftwareRenderer::GetVisibility()
|
||||||
{
|
{
|
||||||
return LightVisibility::Instance()->GetVisibility();
|
return mScene.MainThread()->Light->GetVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSoftwareRenderer::SetVisibility(double vis)
|
void FSoftwareRenderer::SetVisibility(double vis)
|
||||||
{
|
{
|
||||||
LightVisibility::Instance()->SetVisibility(mScene.MainThread()->Viewport.get(), vis);
|
mScene.MainThread()->Light->SetVisibility(mScene.MainThread()->Viewport.get(), vis);
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,12 +93,6 @@ namespace swrenderer
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
LightVisibility *LightVisibility::Instance()
|
|
||||||
{
|
|
||||||
static LightVisibility instance;
|
|
||||||
return &instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Changes how rapidly things get dark with distance
|
// Changes how rapidly things get dark with distance
|
||||||
void LightVisibility::SetVisibility(RenderViewport *viewport, double vis)
|
void LightVisibility::SetVisibility(RenderViewport *viewport, double vis)
|
||||||
{
|
{
|
||||||
|
|
|
@ -69,8 +69,6 @@ namespace swrenderer
|
||||||
class LightVisibility
|
class LightVisibility
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static LightVisibility *Instance();
|
|
||||||
|
|
||||||
void SetVisibility(RenderViewport *viewport, double visibility);
|
void SetVisibility(RenderViewport *viewport, double visibility);
|
||||||
double GetVisibility() const { return CurrentVisibility; }
|
double GetVisibility() const { return CurrentVisibility; }
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ namespace swrenderer
|
||||||
int savedextralight = Thread->Viewport->viewpoint.extralight;
|
int savedextralight = Thread->Viewport->viewpoint.extralight;
|
||||||
DVector3 savedpos = Thread->Viewport->viewpoint.Pos;
|
DVector3 savedpos = Thread->Viewport->viewpoint.Pos;
|
||||||
DRotator savedangles = Thread->Viewport->viewpoint.Angles;
|
DRotator savedangles = Thread->Viewport->viewpoint.Angles;
|
||||||
double savedvisibility = LightVisibility::Instance()->GetVisibility();
|
double savedvisibility = Thread->Light->GetVisibility();
|
||||||
AActor *savedcamera = Thread->Viewport->viewpoint.camera;
|
AActor *savedcamera = Thread->Viewport->viewpoint.camera;
|
||||||
sector_t *savedsector = Thread->Viewport->viewpoint.sector;
|
sector_t *savedsector = Thread->Viewport->viewpoint.sector;
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ namespace swrenderer
|
||||||
// Don't let gun flashes brighten the sky box
|
// Don't let gun flashes brighten the sky box
|
||||||
AActor *sky = port->mSkybox;
|
AActor *sky = port->mSkybox;
|
||||||
Thread->Viewport->viewpoint.extralight = 0;
|
Thread->Viewport->viewpoint.extralight = 0;
|
||||||
LightVisibility::Instance()->SetVisibility(Thread->Viewport.get(), sky->args[0] * 0.25f);
|
Thread->Light->SetVisibility(Thread->Viewport.get(), sky->args[0] * 0.25f);
|
||||||
|
|
||||||
Thread->Viewport->viewpoint.Pos = sky->InterpolatedPosition(Thread->Viewport->viewpoint.TicFrac);
|
Thread->Viewport->viewpoint.Pos = sky->InterpolatedPosition(Thread->Viewport->viewpoint.TicFrac);
|
||||||
Thread->Viewport->viewpoint.Angles.Yaw = savedangles.Yaw + (sky->PrevAngles.Yaw + deltaangle(sky->PrevAngles.Yaw, sky->Angles.Yaw) * Thread->Viewport->viewpoint.TicFrac);
|
Thread->Viewport->viewpoint.Angles.Yaw = savedangles.Yaw + (sky->PrevAngles.Yaw + deltaangle(sky->PrevAngles.Yaw, sky->Angles.Yaw) * Thread->Viewport->viewpoint.TicFrac);
|
||||||
|
@ -139,7 +139,7 @@ namespace swrenderer
|
||||||
case PORTS_PORTAL:
|
case PORTS_PORTAL:
|
||||||
case PORTS_LINKEDPORTAL:
|
case PORTS_LINKEDPORTAL:
|
||||||
Thread->Viewport->viewpoint.extralight = pl->extralight;
|
Thread->Viewport->viewpoint.extralight = pl->extralight;
|
||||||
LightVisibility::Instance()->SetVisibility(Thread->Viewport.get(), pl->visibility);
|
Thread->Light->SetVisibility(Thread->Viewport.get(), pl->visibility);
|
||||||
Thread->Viewport->viewpoint.Pos.X = pl->viewpos.X + port->mDisplacement.X;
|
Thread->Viewport->viewpoint.Pos.X = pl->viewpos.X + port->mDisplacement.X;
|
||||||
Thread->Viewport->viewpoint.Pos.Y = pl->viewpos.Y + port->mDisplacement.Y;
|
Thread->Viewport->viewpoint.Pos.Y = pl->viewpos.Y + port->mDisplacement.Y;
|
||||||
Thread->Viewport->viewpoint.Pos.Z = pl->viewpos.Z;
|
Thread->Viewport->viewpoint.Pos.Z = pl->viewpos.Z;
|
||||||
|
@ -245,7 +245,7 @@ namespace swrenderer
|
||||||
Thread->Viewport->viewpoint.camera = savedcamera;
|
Thread->Viewport->viewpoint.camera = savedcamera;
|
||||||
Thread->Viewport->viewpoint.sector = savedsector;
|
Thread->Viewport->viewpoint.sector = savedsector;
|
||||||
Thread->Viewport->viewpoint.Pos = savedpos;
|
Thread->Viewport->viewpoint.Pos = savedpos;
|
||||||
LightVisibility::Instance()->SetVisibility(Thread->Viewport.get(), savedvisibility);
|
Thread->Light->SetVisibility(Thread->Viewport.get(), savedvisibility);
|
||||||
Thread->Viewport->viewpoint.extralight = savedextralight;
|
Thread->Viewport->viewpoint.extralight = savedextralight;
|
||||||
Thread->Viewport->viewpoint.Angles = savedangles;
|
Thread->Viewport->viewpoint.Angles = savedangles;
|
||||||
R_SetViewAngle(Thread->Viewport->viewpoint, Thread->Viewport->viewwindow);
|
R_SetViewAngle(Thread->Viewport->viewpoint, Thread->Viewport->viewwindow);
|
||||||
|
@ -517,7 +517,7 @@ namespace swrenderer
|
||||||
stacked_viewpos = Thread->Viewport->viewpoint.Pos;
|
stacked_viewpos = Thread->Viewport->viewpoint.Pos;
|
||||||
stacked_angle = Thread->Viewport->viewpoint.Angles;
|
stacked_angle = Thread->Viewport->viewpoint.Angles;
|
||||||
stacked_extralight = Thread->Viewport->viewpoint.extralight;
|
stacked_extralight = Thread->Viewport->viewpoint.extralight;
|
||||||
stacked_visibility = LightVisibility::Instance()->GetVisibility();
|
stacked_visibility = Thread->Light->GetVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderPortal::SetMainPortal()
|
void RenderPortal::SetMainPortal()
|
||||||
|
|
|
@ -83,7 +83,7 @@ namespace swrenderer
|
||||||
int height = SCREENHEIGHT;
|
int height = SCREENHEIGHT;
|
||||||
float trueratio;
|
float trueratio;
|
||||||
ActiveRatio(width, height, &trueratio);
|
ActiveRatio(width, height, &trueratio);
|
||||||
viewport->SetViewport(width, height, trueratio);
|
viewport->SetViewport(MainThread(), width, height, trueratio);
|
||||||
|
|
||||||
if (r_clearbuffer != 0)
|
if (r_clearbuffer != 0)
|
||||||
{
|
{
|
||||||
|
@ -185,6 +185,7 @@ namespace swrenderer
|
||||||
for (int i = 0; i < numThreads; i++)
|
for (int i = 0; i < numThreads; i++)
|
||||||
{
|
{
|
||||||
*Threads[i]->Viewport = *MainThread()->Viewport;
|
*Threads[i]->Viewport = *MainThread()->Viewport;
|
||||||
|
*Threads[i]->Light = *MainThread()->Light;
|
||||||
Threads[i]->X1 = viewwidth * i / numThreads;
|
Threads[i]->X1 = viewwidth * i / numThreads;
|
||||||
Threads[i]->X2 = viewwidth * (i + 1) / numThreads;
|
Threads[i]->X2 = viewwidth * (i + 1) / numThreads;
|
||||||
}
|
}
|
||||||
|
@ -333,7 +334,7 @@ namespace swrenderer
|
||||||
viewwindowx = x;
|
viewwindowx = x;
|
||||||
viewwindowy = y;
|
viewwindowy = y;
|
||||||
viewactive = true;
|
viewactive = true;
|
||||||
viewport->SetViewport(width, height, MainThread()->Viewport->viewwindow.WidescreenRatio);
|
viewport->SetViewport(MainThread(), width, height, MainThread()->Viewport->viewwindow.WidescreenRatio);
|
||||||
|
|
||||||
RenderActorView(actor, dontmaplines);
|
RenderActorView(actor, dontmaplines);
|
||||||
|
|
||||||
|
@ -343,7 +344,7 @@ namespace swrenderer
|
||||||
float trueratio;
|
float trueratio;
|
||||||
ActiveRatio(width, height, &trueratio);
|
ActiveRatio(width, height, &trueratio);
|
||||||
screen->Lock(true);
|
screen->Lock(true);
|
||||||
viewport->SetViewport(width, height, trueratio);
|
viewport->SetViewport(MainThread(), width, height, trueratio);
|
||||||
screen->Unlock();
|
screen->Unlock();
|
||||||
|
|
||||||
viewactive = savedviewactive;
|
viewactive = savedviewactive;
|
||||||
|
@ -358,7 +359,7 @@ namespace swrenderer
|
||||||
float trueratio;
|
float trueratio;
|
||||||
ActiveRatio(width, height, &trueratio);
|
ActiveRatio(width, height, &trueratio);
|
||||||
screen->Lock(true);
|
screen->Lock(true);
|
||||||
viewport->SetViewport(SCREENWIDTH, SCREENHEIGHT, trueratio);
|
viewport->SetViewport(MainThread(), SCREENWIDTH, SCREENHEIGHT, trueratio);
|
||||||
screen->Unlock();
|
screen->Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -204,7 +204,7 @@ namespace swrenderer
|
||||||
vis->floorclip = 0;
|
vis->floorclip = 0;
|
||||||
vis->foggy = foggy;
|
vis->foggy = foggy;
|
||||||
|
|
||||||
vis->Light.SetColormap(tiz * LightVisibility::Instance()->ParticleGlobVis(foggy), shade, map, particle->bright != 0, false, false);
|
vis->Light.SetColormap(tiz * thread->Light->ParticleGlobVis(foggy), shade, map, particle->bright != 0, false, false);
|
||||||
|
|
||||||
thread->SpriteList->Push(vis);
|
thread->SpriteList->Push(vis);
|
||||||
}
|
}
|
||||||
|
|
|
@ -280,7 +280,7 @@ namespace swrenderer
|
||||||
vis->dynlightcolor = 0;
|
vis->dynlightcolor = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
vis->Light.SetColormap(LightVisibility::Instance()->SpriteGlobVis(foggy) / MAX(tz, MINZ), spriteshade, basecolormap, fullbright, invertcolormap, fadeToBlack);
|
vis->Light.SetColormap(thread->Light->SpriteGlobVis(foggy) / MAX(tz, MINZ), spriteshade, basecolormap, fullbright, invertcolormap, fadeToBlack);
|
||||||
|
|
||||||
thread->SpriteList->Push(vis);
|
thread->SpriteList->Push(vis);
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,7 +140,7 @@ namespace swrenderer
|
||||||
|
|
||||||
int spriteshade = LightVisibility::LightLevelToShade(sec->lightlevel + LightVisibility::ActualExtraLight(spr->foggy, thread->Viewport.get()), foggy);
|
int spriteshade = LightVisibility::LightLevelToShade(sec->lightlevel + LightVisibility::ActualExtraLight(spr->foggy, thread->Viewport.get()), foggy);
|
||||||
|
|
||||||
Light.SetColormap(LightVisibility::Instance()->SpriteGlobVis(foggy) / MAX(MINZ, (double)spr->depth), spriteshade, mybasecolormap, isFullBright, invertcolormap, fadeToBlack);
|
Light.SetColormap(thread->Light->SpriteGlobVis(foggy) / MAX(MINZ, (double)spr->depth), spriteshade, mybasecolormap, isFullBright, invertcolormap, fadeToBlack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -170,7 +170,7 @@ namespace swrenderer
|
||||||
bool fullbright = !vis->foggy && ((renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT));
|
bool fullbright = !vis->foggy && ((renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT));
|
||||||
bool fadeToBlack = (vis->RenderStyle.Flags & STYLEF_FadeToBlack) != 0;
|
bool fadeToBlack = (vis->RenderStyle.Flags & STYLEF_FadeToBlack) != 0;
|
||||||
|
|
||||||
vis->Light.SetColormap(LightVisibility::Instance()->SpriteGlobVis(foggy) / MAX(tz, MINZ), spriteshade, basecolormap, fullbright, invertcolormap, fadeToBlack);
|
vis->Light.SetColormap(thread->Light->SpriteGlobVis(foggy) / MAX(tz, MINZ), spriteshade, basecolormap, fullbright, invertcolormap, fadeToBlack);
|
||||||
|
|
||||||
thread->SpriteList->Push(vis, true);
|
thread->SpriteList->Push(vis, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,7 +133,7 @@ namespace swrenderer
|
||||||
vis->wallc = wallc;
|
vis->wallc = wallc;
|
||||||
vis->foggy = foggy;
|
vis->foggy = foggy;
|
||||||
|
|
||||||
vis->Light.SetColormap(LightVisibility::Instance()->SpriteGlobVis(foggy) / MAX(tz, MINZ), spriteshade, basecolormap, false, false, false);
|
vis->Light.SetColormap(thread->Light->SpriteGlobVis(foggy) / MAX(tz, MINZ), spriteshade, basecolormap, false, false, false);
|
||||||
|
|
||||||
thread->SpriteList->Push(vis);
|
thread->SpriteList->Push(vis);
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,7 @@ namespace swrenderer
|
||||||
SpriteDrawerArgs drawerargs;
|
SpriteDrawerArgs drawerargs;
|
||||||
|
|
||||||
int shade = LightVisibility::LightLevelToShade(spr->sector->lightlevel + LightVisibility::ActualExtraLight(spr->foggy, thread->Viewport.get()), spr->foggy);
|
int shade = LightVisibility::LightLevelToShade(spr->sector->lightlevel + LightVisibility::ActualExtraLight(spr->foggy, thread->Viewport.get()), spr->foggy);
|
||||||
double GlobVis = LightVisibility::Instance()->WallGlobVis(foggy);
|
double GlobVis = thread->Light->WallGlobVis(foggy);
|
||||||
float lightleft = float(GlobVis / spr->wallc.sz1);
|
float lightleft = float(GlobVis / spr->wallc.sz1);
|
||||||
float lightstep = float((GlobVis / spr->wallc.sz2 - lightleft) / (spr->wallc.sx2 - spr->wallc.sx1));
|
float lightstep = float((GlobVis / spr->wallc.sz2 - lightleft) / (spr->wallc.sx2 - spr->wallc.sx1));
|
||||||
float light = lightleft + (x1 - spr->wallc.sx1) * lightstep;
|
float light = lightleft + (x1 - spr->wallc.sx1) * lightstep;
|
||||||
|
|
|
@ -48,7 +48,7 @@ namespace swrenderer
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderViewport::SetViewport(int fullWidth, int fullHeight, float trueratio)
|
void RenderViewport::SetViewport(RenderThread *thread, int fullWidth, int fullHeight, float trueratio)
|
||||||
{
|
{
|
||||||
int virtheight, virtwidth, virtwidth2, virtheight2;
|
int virtheight, virtwidth, virtwidth2, virtheight2;
|
||||||
|
|
||||||
|
@ -101,8 +101,7 @@ namespace swrenderer
|
||||||
InitTextureMapping();
|
InitTextureMapping();
|
||||||
|
|
||||||
// Reset r_*Visibility vars
|
// Reset r_*Visibility vars
|
||||||
LightVisibility *visibility = LightVisibility::Instance();
|
thread->Light->SetVisibility(this, thread->Light->GetVisibility());
|
||||||
visibility->SetVisibility(this, visibility->GetVisibility());
|
|
||||||
|
|
||||||
SetupBuffer();
|
SetupBuffer();
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,15 @@
|
||||||
|
|
||||||
namespace swrenderer
|
namespace swrenderer
|
||||||
{
|
{
|
||||||
|
class RenderThread;
|
||||||
|
|
||||||
class RenderViewport
|
class RenderViewport
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RenderViewport();
|
RenderViewport();
|
||||||
~RenderViewport();
|
~RenderViewport();
|
||||||
|
|
||||||
void SetViewport(int width, int height, float trueratio);
|
void SetViewport(RenderThread *thread, int width, int height, float trueratio);
|
||||||
void SetupFreelook();
|
void SetupFreelook();
|
||||||
|
|
||||||
DCanvas *RenderTarget = nullptr;
|
DCanvas *RenderTarget = nullptr;
|
||||||
|
|
Loading…
Reference in a new issue