mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-26 05:41:39 +00:00
- fully implemented "nolightfade" to turn off diminishing lights in the software renderer.
- unfortunately, LIGHT2SHADE had to be transformed into a namespaced function.
This commit is contained in:
parent
5c3b9d81ad
commit
28abc96aef
24 changed files with 84 additions and 52 deletions
|
@ -2951,7 +2951,7 @@ void OpenGLSWFrameBuffer::FillSimplePoly(FTexture *texture, FVector2 *points, in
|
||||||
DAngle rotation, FDynamicColormap *colormap, PalEntry flatcolor, int lightlevel, int bottomclip)
|
DAngle rotation, FDynamicColormap *colormap, PalEntry flatcolor, int lightlevel, int bottomclip)
|
||||||
{
|
{
|
||||||
// Use an equation similar to player sprites to determine shade
|
// Use an equation similar to player sprites to determine shade
|
||||||
double fadelevel = clamp((LIGHT2SHADE(lightlevel) / 65536. - 12) / NUMCOLORMAPS, 0.0, 1.0);
|
double fadelevel = clamp((swrenderer::LIGHT2SHADE(lightlevel, true) / 65536. - 12) / NUMCOLORMAPS, 0.0, 1.0);
|
||||||
|
|
||||||
BufferedTris *quad;
|
BufferedTris *quad;
|
||||||
FBVERTEX *verts;
|
FBVERTEX *verts;
|
||||||
|
|
|
@ -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();
|
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->WallGlobVis(foggy);
|
||||||
if (fullbrightSprite || cameraLight->FixedLightLevel() >= 0 || cameraLight->FixedColormap())
|
if (fullbrightSprite || cameraLight->FixedLightLevel() >= 0 || cameraLight->FixedColormap())
|
||||||
{
|
{
|
||||||
args.uniforms.light = 256;
|
args.uniforms.light = 256;
|
||||||
|
|
|
@ -74,7 +74,7 @@ void RenderPolyParticle::Render(const TriMatrix &worldToClip, const Vec4f &clipP
|
||||||
|
|
||||||
PolyDrawArgs args;
|
PolyDrawArgs args;
|
||||||
|
|
||||||
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->ParticleGlobVis();
|
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->ParticleGlobVis(foggy);
|
||||||
|
|
||||||
if (fullbrightSprite || cameraLight->FixedLightLevel() >= 0 || cameraLight->FixedColormap())
|
if (fullbrightSprite || cameraLight->FixedLightLevel() >= 0 || cameraLight->FixedColormap())
|
||||||
{
|
{
|
||||||
|
|
|
@ -99,6 +99,7 @@ void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, const Vec4f &c
|
||||||
swrenderer::CameraLight *cameraLight = swrenderer::CameraLight::Instance();
|
swrenderer::CameraLight *cameraLight = swrenderer::CameraLight::Instance();
|
||||||
|
|
||||||
int lightlevel = 255;
|
int lightlevel = 255;
|
||||||
|
bool foggy = false;
|
||||||
if (cameraLight->FixedLightLevel() < 0 && sub->sector->e->XFloor.lightlist.Size())
|
if (cameraLight->FixedLightLevel() < 0 && sub->sector->e->XFloor.lightlist.Size())
|
||||||
{
|
{
|
||||||
lightlist_t *light = P_GetPlaneLight(sub->sector, &sub->sector->ceilingplane, false);
|
lightlist_t *light = P_GetPlaneLight(sub->sector, &sub->sector->ceilingplane, false);
|
||||||
|
@ -109,7 +110,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() * 48.0f;
|
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->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;
|
||||||
|
@ -155,6 +156,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan
|
||||||
{
|
{
|
||||||
std::vector<PolyPortalSegment> portalSegments;
|
std::vector<PolyPortalSegment> portalSegments;
|
||||||
FSectorPortal *portal = nullptr;// sub->sector->ValidatePortal(ceiling ? sector_t::ceiling : sector_t::floor);
|
FSectorPortal *portal = nullptr;// sub->sector->ValidatePortal(ceiling ? sector_t::ceiling : sector_t::floor);
|
||||||
|
bool foggy = false;
|
||||||
PolyDrawSectorPortal *polyportal = nullptr;
|
PolyDrawSectorPortal *polyportal = nullptr;
|
||||||
if (portal && (portal->mFlags & PORTSF_INSKYBOX) == PORTSF_INSKYBOX) // Do not recurse into portals we already recursed into
|
if (portal && (portal->mFlags & PORTSF_INSKYBOX) == PORTSF_INSKYBOX) // Do not recurse into portals we already recursed into
|
||||||
portal = nullptr;
|
portal = nullptr;
|
||||||
|
@ -305,7 +307,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() * 48.0f;
|
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->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;
|
||||||
|
|
|
@ -223,9 +223,9 @@ void RenderPolyPlayerSprites::RenderSprite(DPSprite *sprite, AActor *owner, floa
|
||||||
|
|
||||||
bool foggy = false;
|
bool foggy = false;
|
||||||
int actualextralight = foggy ? 0 : extralight << 4;
|
int actualextralight = foggy ? 0 : extralight << 4;
|
||||||
int spriteshade = LIGHT2SHADE(owner->Sector->lightlevel + actualextralight);
|
int spriteshade = swrenderer::LIGHT2SHADE(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() / minz, spriteshade);
|
ColormapNum = GETPALOOKUP(swrenderer::LightVisibility::Instance()->SpriteGlobVis(foggy) / minz, spriteshade);
|
||||||
|
|
||||||
if (sprite->GetID() < PSP_TARGETCENTER)
|
if (sprite->GetID() < PSP_TARGETCENTER)
|
||||||
{
|
{
|
||||||
|
|
|
@ -228,6 +228,7 @@ void RenderPolyScene::RenderLine(subsector_t *sub, seg_t *line, sector_t *fronts
|
||||||
|
|
||||||
void RenderPolyScene::RenderPortals(int portalDepth)
|
void RenderPolyScene::RenderPortals(int portalDepth)
|
||||||
{
|
{
|
||||||
|
bool foggy = false;
|
||||||
if (portalDepth < r_portal_recursions)
|
if (portalDepth < r_portal_recursions)
|
||||||
{
|
{
|
||||||
for (auto &portal : SectorPortals)
|
for (auto &portal : SectorPortals)
|
||||||
|
@ -241,7 +242,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();
|
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->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;
|
||||||
|
|
|
@ -139,7 +139,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();
|
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->SpriteGlobVis(foggy);
|
||||||
args.uniforms.flags = 0;
|
args.uniforms.flags = 0;
|
||||||
if (fullbrightSprite || cameraLight->FixedLightLevel() >= 0 || cameraLight->FixedColormap())
|
if (fullbrightSprite || cameraLight->FixedLightLevel() >= 0 || cameraLight->FixedColormap())
|
||||||
{
|
{
|
||||||
|
|
|
@ -198,6 +198,7 @@ void RenderPolyWall::SetCoords(const DVector2 &v1, const DVector2 &v2, double ce
|
||||||
|
|
||||||
void RenderPolyWall::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, PolyCull &cull)
|
void RenderPolyWall::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, PolyCull &cull)
|
||||||
{
|
{
|
||||||
|
bool foggy = false;
|
||||||
FTexture *tex = GetTexture();
|
FTexture *tex = GetTexture();
|
||||||
if (!tex && !Polyportal)
|
if (!tex && !Polyportal)
|
||||||
return;
|
return;
|
||||||
|
@ -247,7 +248,7 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane
|
||||||
}
|
}
|
||||||
|
|
||||||
PolyDrawArgs args;
|
PolyDrawArgs args;
|
||||||
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->WallGlobVis();
|
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->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;
|
||||||
|
|
|
@ -101,7 +101,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();
|
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->WallGlobVis(foggy);
|
||||||
if (fullbrightSprite || cameraLight->FixedLightLevel() >= 0 || cameraLight->FixedColormap())
|
if (fullbrightSprite || cameraLight->FixedLightLevel() >= 0 || cameraLight->FixedColormap())
|
||||||
{
|
{
|
||||||
args.uniforms.light = 256;
|
args.uniforms.light = 256;
|
||||||
|
|
|
@ -496,7 +496,7 @@ namespace swrenderer
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
draw_segment->shade = LIGHT2SHADE(mLineSegment->sidedef->GetLightLevel(foggy, mLineSegment->frontsector->lightlevel) + R_ActualExtraLight(foggy));
|
draw_segment->shade = LIGHT2SHADE(mLineSegment->sidedef->GetLightLevel(foggy, mLineSegment->frontsector->lightlevel) + R_ActualExtraLight(foggy), foggy);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (draw_segment->bFogBoundary || draw_segment->maskedtexturecol != nullptr)
|
if (draw_segment->bFogBoundary || draw_segment->maskedtexturecol != nullptr)
|
||||||
|
@ -781,8 +781,8 @@ namespace swrenderer
|
||||||
CameraLight *cameraLight = CameraLight::Instance();
|
CameraLight *cameraLight = CameraLight::Instance();
|
||||||
if (cameraLight->FixedColormap() == nullptr && cameraLight->FixedLightLevel() < 0)
|
if (cameraLight->FixedColormap() == nullptr && cameraLight->FixedLightLevel() < 0)
|
||||||
{
|
{
|
||||||
wallshade = LIGHT2SHADE(mLineSegment->sidedef->GetLightLevel(foggy, mFrontSector->lightlevel) + R_ActualExtraLight(foggy));
|
wallshade = LIGHT2SHADE(mLineSegment->sidedef->GetLightLevel(foggy, mFrontSector->lightlevel) + R_ActualExtraLight(foggy), foggy);
|
||||||
double GlobVis = LightVisibility::Instance()->WallGlobVis();
|
double GlobVis = LightVisibility::Instance()->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));
|
||||||
}
|
}
|
||||||
|
|
|
@ -401,7 +401,7 @@ namespace swrenderer
|
||||||
|
|
||||||
lightlist_t *lit = &frontsector->e->XFloor.lightlist[i];
|
lightlist_t *lit = &frontsector->e->XFloor.lightlist[i];
|
||||||
basecolormap = lit->extra_colormap;
|
basecolormap = lit->extra_colormap;
|
||||||
wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, *lit->p_lightlevel, lit->lightsource != NULL) + R_ActualExtraLight(foggy));
|
wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, *lit->p_lightlevel, lit->lightsource != NULL) + R_ActualExtraLight(foggy), foggy);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessNormalWall(up, dwal, texturemid, swal, lwal);
|
ProcessNormalWall(up, dwal, texturemid, swal, lwal);
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "cmdlib.h"
|
#include "cmdlib.h"
|
||||||
#include "d_net.h"
|
#include "d_net.h"
|
||||||
#include "g_level.h"
|
#include "g_level.h"
|
||||||
|
#include "g_levellocals.h"
|
||||||
#include "swrenderer/scene/r_opaque_pass.h"
|
#include "swrenderer/scene/r_opaque_pass.h"
|
||||||
#include "r_flatplane.h"
|
#include "r_flatplane.h"
|
||||||
#include "swrenderer/scene/r_3dfloors.h"
|
#include "swrenderer/scene/r_3dfloors.h"
|
||||||
|
@ -115,7 +116,11 @@ namespace swrenderer
|
||||||
planeheight = fabs(pl->height.Zat0() - ViewPos.Z);
|
planeheight = fabs(pl->height.Zat0() - ViewPos.Z);
|
||||||
|
|
||||||
basecolormap = colormap;
|
basecolormap = colormap;
|
||||||
GlobVis = LightVisibility::Instance()->FlatPlaneGlobVis() / planeheight;
|
|
||||||
|
// [RH] set foggy flag
|
||||||
|
bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE));
|
||||||
|
|
||||||
|
GlobVis = LightVisibility::Instance()->FlatPlaneGlobVis(foggy) / planeheight;
|
||||||
|
|
||||||
CameraLight *cameraLight = CameraLight::Instance();
|
CameraLight *cameraLight = CameraLight::Instance();
|
||||||
if (cameraLight->FixedLightLevel() >= 0)
|
if (cameraLight->FixedLightLevel() >= 0)
|
||||||
|
@ -131,7 +136,7 @@ namespace swrenderer
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
plane_shade = true;
|
plane_shade = true;
|
||||||
planeshade = LIGHT2SHADE(pl->lightlevel);
|
planeshade = LIGHT2SHADE(pl->lightlevel, foggy);
|
||||||
}
|
}
|
||||||
|
|
||||||
drawerargs.SetStyle(masked, additive, alpha);
|
drawerargs.SetStyle(masked, additive, alpha);
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "cmdlib.h"
|
#include "cmdlib.h"
|
||||||
#include "d_net.h"
|
#include "d_net.h"
|
||||||
#include "g_level.h"
|
#include "g_level.h"
|
||||||
|
#include "g_levellocals.h"
|
||||||
#include "swrenderer/scene/r_opaque_pass.h"
|
#include "swrenderer/scene/r_opaque_pass.h"
|
||||||
#include "r_slopeplane.h"
|
#include "r_slopeplane.h"
|
||||||
#include "swrenderer/scene/r_3dfloors.h"
|
#include "swrenderer/scene/r_3dfloors.h"
|
||||||
|
@ -152,12 +153,15 @@ namespace swrenderer
|
||||||
plane_sz[0] = -plane_sz[0];
|
plane_sz[0] = -plane_sz[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
planelightfloat = (LightVisibility::Instance()->SlopePlaneGlobVis() * lxscale * lyscale) / (fabs(pl->height.ZatPoint(ViewPos) - ViewPos.Z)) / 65536.f;
|
// [RH] set foggy flag
|
||||||
|
basecolormap = colormap;
|
||||||
|
bool foggy = level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE);;
|
||||||
|
|
||||||
|
planelightfloat = (LightVisibility::Instance()->SlopePlaneGlobVis(foggy) * lxscale * lyscale) / (fabs(pl->height.ZatPoint(ViewPos) - ViewPos.Z)) / 65536.f;
|
||||||
|
|
||||||
if (pl->height.fC() > 0)
|
if (pl->height.fC() > 0)
|
||||||
planelightfloat = -planelightfloat;
|
planelightfloat = -planelightfloat;
|
||||||
|
|
||||||
basecolormap = colormap;
|
|
||||||
|
|
||||||
CameraLight *cameraLight = CameraLight::Instance();
|
CameraLight *cameraLight = CameraLight::Instance();
|
||||||
if (cameraLight->FixedLightLevel() >= 0)
|
if (cameraLight->FixedLightLevel() >= 0)
|
||||||
|
@ -174,7 +178,7 @@ namespace swrenderer
|
||||||
{
|
{
|
||||||
drawerargs.SetLight(basecolormap, 0, 0);
|
drawerargs.SetLight(basecolormap, 0, 0);
|
||||||
plane_shade = true;
|
plane_shade = true;
|
||||||
planeshade = LIGHT2SHADE(pl->lightlevel);
|
planeshade = LIGHT2SHADE(pl->lightlevel, foggy);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hack in support for 1 x Z and Z x 1 texture sizes
|
// Hack in support for 1 x Z and Z x 1 texture sizes
|
||||||
|
|
|
@ -198,7 +198,7 @@ void SWCanvas::FillSimplePoly(DCanvas *canvas, FTexture *tex, FVector2 *points,
|
||||||
FDynamicColormap *colormap, PalEntry flatcolor, int lightlevel, int bottomclip)
|
FDynamicColormap *colormap, PalEntry flatcolor, int lightlevel, int bottomclip)
|
||||||
{
|
{
|
||||||
// Use an equation similar to player sprites to determine shade
|
// Use an equation similar to player sprites to determine shade
|
||||||
fixed_t shade = LIGHT2SHADE(lightlevel) - 12 * FRACUNIT;
|
fixed_t shade = LIGHT2SHADE(lightlevel, true) - 12 * FRACUNIT;
|
||||||
float topy, boty, leftx, rightx;
|
float topy, boty, leftx, rightx;
|
||||||
int toppt, botpt, pt1, pt2;
|
int toppt, botpt, pt1, pt2;
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -32,12 +32,20 @@
|
||||||
#include "d_player.h"
|
#include "d_player.h"
|
||||||
#include "swrenderer/scene/r_light.h"
|
#include "swrenderer/scene/r_light.h"
|
||||||
#include "swrenderer/viewport/r_viewport.h"
|
#include "swrenderer/viewport/r_viewport.h"
|
||||||
|
#include "gl/data/gl_data.h"
|
||||||
|
|
||||||
CVAR(Bool, r_shadercolormaps, true, CVAR_ARCHIVE)
|
CVAR(Bool, r_shadercolormaps, true, CVAR_ARCHIVE)
|
||||||
EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor)
|
EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor)
|
||||||
|
|
||||||
namespace swrenderer
|
namespace swrenderer
|
||||||
{
|
{
|
||||||
|
fixed_t LIGHT2SHADE(int l, bool foggy)
|
||||||
|
{
|
||||||
|
return (!foggy && (glset.nolightfade) ?
|
||||||
|
((MAX(255 - l, 0) * NUMCOLORMAPS) << (FRACBITS - 8)) :
|
||||||
|
((NUMCOLORMAPS*2*FRACUNIT)-(((l)+12)*(FRACUNIT*NUMCOLORMAPS/128))));
|
||||||
|
}
|
||||||
|
|
||||||
CameraLight *CameraLight::Instance()
|
CameraLight *CameraLight::Instance()
|
||||||
{
|
{
|
||||||
static CameraLight instance;
|
static CameraLight instance;
|
||||||
|
@ -146,10 +154,12 @@ namespace swrenderer
|
||||||
|
|
||||||
TiltVisibility = float(vis * FocalTangent * (16.f * 320.f) / viewwidth);
|
TiltVisibility = float(vis * FocalTangent * (16.f * 320.f) / viewwidth);
|
||||||
|
|
||||||
// Disable diminishing light (To do: make a cvar control this)
|
NoLightFade = glset.nolightfade;
|
||||||
WallVisibility = 0.0;
|
|
||||||
FloorVisibility = 0.0;
|
// Disable diminishing light
|
||||||
TiltVisibility = 0.0f;
|
// WallVisibility = 0.0;
|
||||||
|
// FloorVisibility = 0.0;
|
||||||
|
// TiltVisibility = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Controls how quickly light ramps across a 1/z range. Set this, and it
|
// Controls how quickly light ramps across a 1/z range. Set this, and it
|
||||||
|
|
|
@ -29,13 +29,18 @@
|
||||||
// The size of a single colormap, in bits
|
// The size of a single colormap, in bits
|
||||||
#define COLORMAPSHIFT 8
|
#define COLORMAPSHIFT 8
|
||||||
|
|
||||||
// Convert a light level into an unbounded colormap index (shade). Result is
|
// Convert a light level into an unbounded colormap index (shade). Result is
|
||||||
// fixed point. Why the +12? I wish I knew, but experimentation indicates it
|
// fixed point. Why the +12? I wish I knew, but experimentation indicates it
|
||||||
// is necessary in order to best reproduce Doom's original lighting.
|
// is necessary in order to best reproduce Doom's original lighting.
|
||||||
//#define LIGHT2SHADE(l) ((NUMCOLORMAPS*2*FRACUNIT)-(((l)+12)*(FRACUNIT*NUMCOLORMAPS/128)))
|
//#define LIGHT2SHADE(l) ((NUMCOLORMAPS*2*FRACUNIT)-(((l)+12)*(FRACUNIT*NUMCOLORMAPS/128)))
|
||||||
|
|
||||||
// Disable diminishing light (To do: merge with LIGHT2SHADE and let a cvar control it, maybe by converting this to a function, like R_ActualExtraLight)
|
// Disable diminishing light (To do: merge with LIGHT2SHADE and let a cvar control it, maybe by converting this to a function, like R_ActualExtraLight)
|
||||||
#define LIGHT2SHADE(lightlev) ((MAX(255 - lightlev, 0) * NUMCOLORMAPS) << (FRACBITS - 8))
|
//#define LIGHT2SHADE(lightlev) ((MAX(255 - lightlev, 0) * NUMCOLORMAPS) << (FRACBITS - 8))
|
||||||
|
|
||||||
|
// combined!
|
||||||
|
//#define LIGHT2SHADE(l) ((glset.nolightfade)? \
|
||||||
|
// ((MAX(255 - l, 0) * NUMCOLORMAPS) << (FRACBITS - 8)) : \
|
||||||
|
// ((NUMCOLORMAPS*2*FRACUNIT)-(((l)+12)*(FRACUNIT*NUMCOLORMAPS/128))))
|
||||||
|
|
||||||
// MAXLIGHTSCALE from original DOOM, divided by 2.
|
// MAXLIGHTSCALE from original DOOM, divided by 2.
|
||||||
#define MAXLIGHTVIS (24.0)
|
#define MAXLIGHTVIS (24.0)
|
||||||
|
@ -57,6 +62,8 @@ struct FSWColormap;
|
||||||
|
|
||||||
namespace swrenderer
|
namespace swrenderer
|
||||||
{
|
{
|
||||||
|
fixed_t LIGHT2SHADE(int lightlevel, bool foggy);
|
||||||
|
|
||||||
class CameraLight
|
class CameraLight
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -83,17 +90,17 @@ namespace swrenderer
|
||||||
void SetVisibility(double visibility);
|
void SetVisibility(double visibility);
|
||||||
double GetVisibility() const { return CurrentVisibility; }
|
double GetVisibility() const { return CurrentVisibility; }
|
||||||
|
|
||||||
double WallGlobVis() const { return WallVisibility; }
|
double WallGlobVis(bool foggy) const { return (NoLightFade && !foggy) ? 0.0f : WallVisibility; }
|
||||||
double SpriteGlobVis() const { return WallVisibility; }
|
double SpriteGlobVis(bool foggy) const { return (NoLightFade && !foggy) ? 0.0f : WallVisibility; }
|
||||||
double ParticleGlobVis() const { return WallVisibility * 0.5; }
|
double ParticleGlobVis(bool foggy) const { return (NoLightFade && !foggy) ? 0.0f : (WallVisibility * 0.5); }
|
||||||
double FlatPlaneGlobVis() const { return FloorVisibility; }
|
double FlatPlaneGlobVis(bool foggy) const { return (NoLightFade && !foggy) ? 0.0f : FloorVisibility; }
|
||||||
double SlopePlaneGlobVis() const { return TiltVisibility; }
|
double SlopePlaneGlobVis(bool foggy) const { return (NoLightFade && !foggy) ? 0.0f : TiltVisibility; }
|
||||||
|
|
||||||
// The vis value to pass into the GETPALOOKUP or LIGHTSCALE macros
|
// The vis value to pass into the GETPALOOKUP or LIGHTSCALE macros
|
||||||
double WallVis(double screenZ) const { return WallGlobVis() / screenZ; }
|
double WallVis(double screenZ, bool foggy) const { return WallGlobVis(foggy) / screenZ; }
|
||||||
double SpriteVis(double screenZ) const { return SpriteGlobVis() / screenZ; }
|
double SpriteVis(double screenZ, bool foggy) const { return SpriteGlobVis(foggy) / screenZ; }
|
||||||
double ParticleVis(double screenZ) const { return ParticleGlobVis() / screenZ; }
|
double ParticleVis(double screenZ, bool foggy) const { return ParticleGlobVis(foggy) / screenZ; }
|
||||||
double FlatPlaneVis(int screenY, double planeZ) const { return FlatPlaneGlobVis() / fabs(planeZ - ViewPos.Z) * fabs(RenderViewport::Instance()->CenterY - screenY); }
|
double FlatPlaneVis(int screenY, double planeZ, bool foggy) const { return FlatPlaneGlobVis(foggy) / fabs(planeZ - ViewPos.Z) * fabs(RenderViewport::Instance()->CenterY - screenY); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double BaseVisibility = 0.0;
|
double BaseVisibility = 0.0;
|
||||||
|
@ -101,6 +108,8 @@ namespace swrenderer
|
||||||
double FloorVisibility = 0.0;
|
double FloorVisibility = 0.0;
|
||||||
float TiltVisibility = 0.0f;
|
float TiltVisibility = 0.0f;
|
||||||
|
|
||||||
|
bool NoLightFade = false;
|
||||||
|
|
||||||
double CurrentVisibility = 8.f;
|
double CurrentVisibility = 8.f;
|
||||||
double MaxVisForWall = 0.0;
|
double MaxVisForWall = 0.0;
|
||||||
double MaxVisForFloor = 0.0;
|
double MaxVisForFloor = 0.0;
|
||||||
|
|
|
@ -717,7 +717,7 @@ namespace swrenderer
|
||||||
// [RH] Add particles
|
// [RH] Add particles
|
||||||
if ((unsigned int)(sub - subsectors) < (unsigned int)numsubsectors)
|
if ((unsigned int)(sub - subsectors) < (unsigned int)numsubsectors)
|
||||||
{ // Only do it for the main BSP.
|
{ // Only do it for the main BSP.
|
||||||
int shade = LIGHT2SHADE((floorlightlevel + ceilinglightlevel) / 2 + R_ActualExtraLight(foggy));
|
int shade = LIGHT2SHADE((floorlightlevel + ceilinglightlevel) / 2 + R_ActualExtraLight(foggy), foggy);
|
||||||
for (WORD i = ParticlesInSubsec[(unsigned int)(sub - subsectors)]; i != NO_PARTICLE; i = Particles[i].snext)
|
for (WORD i = ParticlesInSubsec[(unsigned int)(sub - subsectors)]; i != NO_PARTICLE; i = Particles[i].snext)
|
||||||
{
|
{
|
||||||
RenderParticle::Project(Thread, Particles + i, subsectors[sub - subsectors].sector, shade, FakeSide, foggy);
|
RenderParticle::Project(Thread, Particles + i, subsectors[sub - subsectors].sector, shade, FakeSide, foggy);
|
||||||
|
@ -834,7 +834,7 @@ namespace swrenderer
|
||||||
//sec->validcount = validcount;
|
//sec->validcount = validcount;
|
||||||
SeenSpriteSectors.insert(sec);
|
SeenSpriteSectors.insert(sec);
|
||||||
|
|
||||||
int spriteshade = LIGHT2SHADE(lightlevel + R_ActualExtraLight(foggy));
|
int spriteshade = LIGHT2SHADE(lightlevel + R_ActualExtraLight(foggy), foggy);
|
||||||
|
|
||||||
// Handle all things in sector.
|
// Handle all things in sector.
|
||||||
for (auto p = sec->touching_renderthings; p != nullptr; p = p->m_snext)
|
for (auto p = sec->touching_renderthings; p != nullptr; p = p->m_snext)
|
||||||
|
@ -886,7 +886,7 @@ namespace swrenderer
|
||||||
if (sec->sectornum != thing->Sector->sectornum) // compare sectornums to account for R_FakeFlat copies.
|
if (sec->sectornum != thing->Sector->sectornum) // compare sectornums to account for R_FakeFlat copies.
|
||||||
{
|
{
|
||||||
int lightlevel = thing->Sector->GetTexture(sector_t::ceiling) == skyflatnum ? thing->Sector->GetCeilingLight() : thing->Sector->GetFloorLight();
|
int lightlevel = thing->Sector->GetTexture(sector_t::ceiling) == skyflatnum ? thing->Sector->GetCeilingLight() : thing->Sector->GetFloorLight();
|
||||||
thingShade = LIGHT2SHADE(lightlevel + R_ActualExtraLight(foggy));
|
thingShade = LIGHT2SHADE(lightlevel + R_ActualExtraLight(foggy), foggy);
|
||||||
thingColormap = thing->Sector->ColorMap;
|
thingColormap = thing->Sector->ColorMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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(), shade, map, particle->bright != 0, false, false);
|
vis->Light.SetColormap(tiz * LightVisibility::Instance()->ParticleGlobVis(foggy), shade, map, particle->bright != 0, false, false);
|
||||||
|
|
||||||
thread->SpriteList->Push(vis);
|
thread->SpriteList->Push(vis);
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@ namespace swrenderer
|
||||||
|
|
||||||
// get light level
|
// get light level
|
||||||
lightnum = ((floorlight + ceilinglight) >> 1) + R_ActualExtraLight(foggy);
|
lightnum = ((floorlight + ceilinglight) >> 1) + R_ActualExtraLight(foggy);
|
||||||
int spriteshade = LIGHT2SHADE(lightnum) - 24 * FRACUNIT;
|
int spriteshade = LIGHT2SHADE(lightnum, foggy) - 24 * FRACUNIT;
|
||||||
|
|
||||||
if (camera->player != NULL)
|
if (camera->player != NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -280,7 +280,7 @@ namespace swrenderer
|
||||||
vis->dynlightcolor = 0;
|
vis->dynlightcolor = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
vis->Light.SetColormap(LightVisibility::Instance()->SpriteGlobVis() / MAX(tz, MINZ), spriteshade, basecolormap, fullbright, invertcolormap, fadeToBlack);
|
vis->Light.SetColormap(LightVisibility::Instance()->SpriteGlobVis(foggy) / MAX(tz, MINZ), spriteshade, basecolormap, fullbright, invertcolormap, fadeToBlack);
|
||||||
|
|
||||||
thread->SpriteList->Push(vis);
|
thread->SpriteList->Push(vis);
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,9 +138,9 @@ namespace swrenderer
|
||||||
bool isFullBright = !foggy && (renderflags & RF_FULLBRIGHT);
|
bool isFullBright = !foggy && (renderflags & RF_FULLBRIGHT);
|
||||||
bool fadeToBlack = spr->RenderStyle == LegacyRenderStyles[STYLE_Add] && mybasecolormap->Fade != 0;
|
bool fadeToBlack = spr->RenderStyle == LegacyRenderStyles[STYLE_Add] && mybasecolormap->Fade != 0;
|
||||||
|
|
||||||
int spriteshade = LIGHT2SHADE(sec->lightlevel + R_ActualExtraLight(spr->foggy));
|
int spriteshade = LIGHT2SHADE(sec->lightlevel + R_ActualExtraLight(spr->foggy), foggy);
|
||||||
|
|
||||||
Light.SetColormap(LightVisibility::Instance()->SpriteGlobVis() / MAX(MINZ, (double)spr->depth), spriteshade, mybasecolormap, isFullBright, invertcolormap, fadeToBlack);
|
Light.SetColormap(LightVisibility::Instance()->SpriteGlobVis(foggy) / MAX(MINZ, (double)spr->depth), spriteshade, mybasecolormap, isFullBright, invertcolormap, fadeToBlack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -178,7 +178,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() / MAX(tz, MINZ), spriteshade, basecolormap, fullbright, invertcolormap, fadeToBlack);
|
vis->Light.SetColormap(LightVisibility::Instance()->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() / MAX(tz, MINZ), spriteshade, basecolormap, false, false, false);
|
vis->Light.SetColormap(LightVisibility::Instance()->SpriteGlobVis(foggy) / MAX(tz, MINZ), spriteshade, basecolormap, false, false, false);
|
||||||
|
|
||||||
thread->SpriteList->Push(vis);
|
thread->SpriteList->Push(vis);
|
||||||
}
|
}
|
||||||
|
@ -182,8 +182,8 @@ namespace swrenderer
|
||||||
|
|
||||||
SpriteDrawerArgs drawerargs;
|
SpriteDrawerArgs drawerargs;
|
||||||
|
|
||||||
int shade = LIGHT2SHADE(spr->sector->lightlevel + R_ActualExtraLight(spr->foggy));
|
int shade = LIGHT2SHADE(spr->sector->lightlevel + R_ActualExtraLight(spr->foggy), spr->foggy);
|
||||||
double GlobVis = LightVisibility::Instance()->WallGlobVis();
|
double GlobVis = LightVisibility::Instance()->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;
|
||||||
|
|
|
@ -3130,7 +3130,7 @@ void D3DFB::FillSimplePoly(FTexture *texture, FVector2 *points, int npoints,
|
||||||
DAngle rotation, FDynamicColormap *colormap, PalEntry flatcolor, int lightlevel, int bottomclip)
|
DAngle rotation, FDynamicColormap *colormap, PalEntry flatcolor, int lightlevel, int bottomclip)
|
||||||
{
|
{
|
||||||
// Use an equation similar to player sprites to determine shade
|
// Use an equation similar to player sprites to determine shade
|
||||||
double fadelevel = clamp((LIGHT2SHADE(lightlevel)/65536. - 12) / NUMCOLORMAPS, 0.0, 1.0);
|
double fadelevel = clamp((swrenderer::LIGHT2SHADE(lightlevel, true)/65536. - 12) / NUMCOLORMAPS, 0.0, 1.0);
|
||||||
|
|
||||||
BufferedTris *quad;
|
BufferedTris *quad;
|
||||||
FBVERTEX *verts;
|
FBVERTEX *verts;
|
||||||
|
|
Loading…
Reference in a new issue