- move visibility calculation to LightVisibility

This commit is contained in:
Magnus Norddahl 2018-12-17 05:10:26 +01:00
parent 9787e32d28
commit f35aeec6c3
11 changed files with 14 additions and 17 deletions

View file

@ -790,9 +790,8 @@ namespace swrenderer
if (cameraLight->FixedColormap() == nullptr && cameraLight->FixedLightLevel() < 0)
{
wallshade = LightVisibility::LightLevelToShade(mLineSegment->sidedef->GetLightLevel(foggy, mFrontSector->lightlevel) + LightVisibility::ActualExtraLight(foggy, Thread->Viewport.get()), foggy);
double GlobVis = Thread->Light->WallGlobVis(foggy);
rw_lightleft = float(GlobVis / WallC.sz1);
rw_lightstep = float((GlobVis / WallC.sz2 - rw_lightleft) / (WallC.sx2 - WallC.sx1));
rw_lightleft = float(Thread->Light->WallVis(WallC.sz1, foggy));
rw_lightstep = float((Thread->Light->WallVis(WallC.sz2, foggy) - rw_lightleft) / (WallC.sx2 - WallC.sx1));
}
else
{

View file

@ -137,9 +137,7 @@ namespace swrenderer
basecolormap = colormap;
// [RH] set foggy flag
bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE));
GlobVis = Thread->Light->FlatPlaneGlobVis(foggy) / planeheight;
foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE));
CameraLight *cameraLight = CameraLight::Instance();
if (cameraLight->FixedLightLevel() >= 0)
@ -202,7 +200,7 @@ namespace swrenderer
if (plane_shade)
{
// Determine lighting based on the span's distance from the viewer.
drawerargs.SetLight(basecolormap, (float)(GlobVis * fabs(viewport->CenterY - y)), planeshade);
drawerargs.SetLight(basecolormap, (float)Thread->Light->FlatPlaneVis(y, planeheight, foggy, viewport), planeshade);
}
if (r_dynlights)

View file

@ -45,7 +45,7 @@ namespace swrenderer
double planeheight;
bool plane_shade;
int planeshade;
double GlobVis;
bool foggy;
FDynamicColormap *basecolormap;
double pviewx, pviewy;
double xstepscale, ystepscale;

View file

@ -88,9 +88,9 @@ namespace swrenderer
// The vis value to pass into the GETPALOOKUP or LIGHTSCALE macros
double WallVis(double screenZ, bool foggy) const { return WallGlobVis(foggy) / screenZ; }
double SpriteVis(double screenZ, bool foggy) const { return SpriteGlobVis(foggy) / screenZ; }
double SpriteVis(double screenZ, bool foggy) const { return SpriteGlobVis(foggy) / MAX(screenZ, MINZ); }
double ParticleVis(double screenZ, bool foggy) const { return ParticleGlobVis(foggy) / screenZ; }
double FlatPlaneVis(int screenY, double planeZ, bool foggy, RenderViewport *viewport) const { return FlatPlaneGlobVis(foggy) / fabs(planeZ - viewport->viewpoint.Pos.Z) * fabs(viewport->CenterY - screenY); }
double FlatPlaneVis(int screenY, double planeheight, bool foggy, RenderViewport *viewport) const { return FlatPlaneGlobVis(foggy) / planeheight * fabs(viewport->CenterY - screenY); }
static fixed_t LightLevelToShade(int lightlevel, bool foggy);
static int ActualExtraLight(bool fog, RenderViewport *viewport) { return fog ? 0 : viewport->viewpoint.extralight << 4; }

View file

@ -23,8 +23,6 @@
#include "tarray.h"
#define MINZ double((2048*4) / double(1 << 20))
struct particle_t;
struct FVoxel;

View file

@ -220,7 +220,7 @@ namespace swrenderer
vis->floorclip = 0;
vis->foggy = foggy;
vis->Light.SetColormap(tiz * thread->Light->ParticleGlobVis(foggy), shade, map, particle->bright != 0, false, false);
vis->Light.SetColormap(thread->Light->ParticleVis(tz, foggy), shade, map, particle->bright != 0, false, false);
thread->SpriteList->Push(vis);
}

View file

@ -300,7 +300,7 @@ namespace swrenderer
vis->dynlightcolor = 0;
}
vis->Light.SetColormap(thread->Light->SpriteGlobVis(foggy) / MAX(tz, MINZ), spriteshade, basecolormap, fullbright, invertcolormap, fadeToBlack);
vis->Light.SetColormap(thread->Light->SpriteVis(tz, foggy), spriteshade, basecolormap, fullbright, invertcolormap, fadeToBlack);
thread->SpriteList->Push(vis);
}

View file

@ -165,7 +165,7 @@ namespace swrenderer
int spriteshade = LightVisibility::LightLevelToShade(sec->lightlevel + LightVisibility::ActualExtraLight(spr->foggy, thread->Viewport.get()), foggy);
Light.SetColormap(thread->Light->SpriteGlobVis(foggy) / MAX(MINZ, (double)spr->depth), spriteshade, mybasecolormap, isFullBright, invertcolormap, fadeToBlack);
Light.SetColormap(thread->Light->SpriteVis(spr->depth, foggy), spriteshade, mybasecolormap, isFullBright, invertcolormap, fadeToBlack);
}
}

View file

@ -188,7 +188,7 @@ namespace swrenderer
bool fullbright = !vis->foggy && ((renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT));
bool fadeToBlack = (vis->RenderStyle.Flags & STYLEF_FadeToBlack) != 0;
vis->Light.SetColormap(thread->Light->SpriteGlobVis(foggy) / MAX(tz, MINZ), spriteshade, basecolormap, fullbright, invertcolormap, fadeToBlack);
vis->Light.SetColormap(thread->Light->SpriteVis(tz, foggy), spriteshade, basecolormap, fullbright, invertcolormap, fadeToBlack);
// Fake a voxel drawing to find its extents..
SpriteDrawerArgs drawerargs;

View file

@ -141,7 +141,7 @@ namespace swrenderer
vis->wallc = wallc;
vis->foggy = foggy;
vis->Light.SetColormap(thread->Light->SpriteGlobVis(foggy) / MAX(tz, MINZ), spriteshade, basecolormap, false, false, false);
vis->Light.SetColormap(thread->Light->SpriteVis(tz, foggy), spriteshade, basecolormap, false, false, false);
thread->SpriteList->Push(vis);
}

View file

@ -7,6 +7,8 @@
#include "r_defs.h"
#include "polyrenderer/math/gpu_types.h"
#define MINZ double((2048*4) / double(1 << 20))
namespace swrenderer
{
class RenderThread;