mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-25 21:51:09 +00:00
Create CameraLight class
This commit is contained in:
parent
4bbf1ba11c
commit
ed05a2edd3
27 changed files with 133 additions and 96 deletions
|
@ -1409,7 +1409,7 @@ void OpenGLSWFrameBuffer::Draw3DPart(bool copy3d)
|
|||
uint32_t color0, color1;
|
||||
if (Accel2D)
|
||||
{
|
||||
auto &map = swrenderer::realfixedcolormap;
|
||||
auto &map = swrenderer::CameraLight::Instance()->realfixedcolormap;
|
||||
if (map == nullptr)
|
||||
{
|
||||
color0 = 0;
|
||||
|
|
|
@ -69,10 +69,11 @@ void PolyRenderer::RenderView(player_t *player)
|
|||
RenderActorView(player->mo, false);
|
||||
|
||||
// Apply special colormap if the target cannot do it
|
||||
if (realfixedcolormap && r_swtruecolor && !(r_shadercolormaps && screen->Accel2D))
|
||||
CameraLight *cameraLight = CameraLight::Instance();
|
||||
if (cameraLight->realfixedcolormap && r_swtruecolor && !(r_shadercolormaps && screen->Accel2D))
|
||||
{
|
||||
R_BeginDrawerCommands();
|
||||
DrawerCommandQueue::QueueCommand<ApplySpecialColormapRGBACommand>(realfixedcolormap, screen);
|
||||
DrawerCommandQueue::QueueCommand<ApplySpecialColormapRGBACommand>(cameraLight->realfixedcolormap, screen);
|
||||
R_EndDrawerCommands();
|
||||
}
|
||||
|
||||
|
@ -119,7 +120,7 @@ void PolyRenderer::RenderActorView(AActor *actor, bool dontmaplines)
|
|||
P_FindParticleSubsectors();
|
||||
PO_LinkToSubsectors();
|
||||
R_SetupFrame(actor);
|
||||
swrenderer::R_SetupColormap(actor);
|
||||
swrenderer::CameraLight::Instance()->SetCamera(actor);
|
||||
swrenderer::RenderViewport::Instance()->SetupFreelook();
|
||||
|
||||
ActorRenderFlags savedflags = camera->renderflags;
|
||||
|
|
|
@ -133,12 +133,14 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan
|
|||
|
||||
bool fullbrightSprite = (decal->RenderFlags & RF_FULLBRIGHT) == RF_FULLBRIGHT;
|
||||
|
||||
swrenderer::CameraLight *cameraLight = swrenderer::CameraLight::Instance();
|
||||
|
||||
PolyDrawArgs args;
|
||||
args.uniforms.flags = 0;
|
||||
args.SetColormap(front->ColorMap);
|
||||
args.SetTexture(tex, decal->Translation, true);
|
||||
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->WallGlobVis();
|
||||
if (fullbrightSprite || swrenderer::fixedlightlev >= 0 || swrenderer::fixedcolormap)
|
||||
if (fullbrightSprite || cameraLight->fixedlightlev >= 0 || cameraLight->fixedcolormap)
|
||||
{
|
||||
args.uniforms.light = 256;
|
||||
args.uniforms.flags |= TriUniforms::fixed_light;
|
||||
|
|
|
@ -70,12 +70,13 @@ void RenderPolyParticle::Render(const TriMatrix &worldToClip, const Vec4f &clipP
|
|||
|
||||
// int color = (particle->color >> 24) & 0xff; // pal index, I think
|
||||
bool fullbrightSprite = particle->bright != 0;
|
||||
swrenderer::CameraLight *cameraLight = swrenderer::CameraLight::Instance();
|
||||
|
||||
PolyDrawArgs args;
|
||||
|
||||
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->ParticleGlobVis();
|
||||
|
||||
if (fullbrightSprite || swrenderer::fixedlightlev >= 0 || swrenderer::fixedcolormap)
|
||||
if (fullbrightSprite || cameraLight->fixedlightlev >= 0 || cameraLight->fixedcolormap)
|
||||
{
|
||||
args.uniforms.light = 256;
|
||||
args.uniforms.flags = TriUniforms::fixed_light;
|
||||
|
|
|
@ -96,8 +96,10 @@ void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, const Vec4f &c
|
|||
if (tex->UseType == FTexture::TEX_Null)
|
||||
return;
|
||||
|
||||
swrenderer::CameraLight *cameraLight = swrenderer::CameraLight::Instance();
|
||||
|
||||
int lightlevel = 255;
|
||||
if (swrenderer::fixedlightlev < 0 && sub->sector->e->XFloor.lightlist.Size())
|
||||
if (cameraLight->fixedlightlev < 0 && sub->sector->e->XFloor.lightlist.Size())
|
||||
{
|
||||
lightlist_t *light = P_GetPlaneLight(sub->sector, &sub->sector->ceilingplane, false);
|
||||
//basecolormap = light->extra_colormap;
|
||||
|
@ -109,7 +111,7 @@ void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, const Vec4f &c
|
|||
PolyDrawArgs args;
|
||||
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->SlopePlaneGlobVis() * 48.0f;
|
||||
args.uniforms.light = (uint32_t)(lightlevel / 255.0f * 256.0f);
|
||||
if (swrenderer::fixedlightlev >= 0 || swrenderer::fixedcolormap)
|
||||
if (cameraLight->fixedlightlev >= 0 || cameraLight->fixedcolormap)
|
||||
args.uniforms.light = 256;
|
||||
args.uniforms.flags = 0;
|
||||
args.uniforms.subsectorDepth = subsectorDepth;
|
||||
|
@ -300,10 +302,12 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan
|
|||
|
||||
UVTransform transform(ceiling ? frontsector->planes[sector_t::ceiling].xform : frontsector->planes[sector_t::floor].xform, tex);
|
||||
|
||||
swrenderer::CameraLight *cameraLight = swrenderer::CameraLight::Instance();
|
||||
|
||||
PolyDrawArgs args;
|
||||
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->SlopePlaneGlobVis() * 48.0f;
|
||||
args.uniforms.light = (uint32_t)(frontsector->lightlevel / 255.0f * 256.0f);
|
||||
if (swrenderer::fixedlightlev >= 0 || swrenderer::fixedcolormap)
|
||||
if (cameraLight->fixedlightlev >= 0 || cameraLight->fixedcolormap)
|
||||
args.uniforms.light = 256;
|
||||
args.uniforms.flags = 0;
|
||||
args.uniforms.subsectorDepth = isSky ? RenderPolyScene::SkySubsectorDepth : subsectorDepth;
|
||||
|
|
|
@ -326,14 +326,15 @@ void RenderPolyPlayerSprites::RenderSprite(DPSprite *sprite, AActor *owner, floa
|
|||
}
|
||||
// If the main colormap has fixed lights, and this sprite is being drawn with that
|
||||
// colormap, disable acceleration so that the lights can remain fixed.
|
||||
if (!noaccel && swrenderer::realfixedcolormap == nullptr &&
|
||||
swrenderer::CameraLight *cameraLight = swrenderer::CameraLight::Instance();
|
||||
if (!noaccel && cameraLight->realfixedcolormap == nullptr &&
|
||||
NormalLightHasFixedLights && mybasecolormap == &NormalLight &&
|
||||
tex->UseBasePalette())
|
||||
{
|
||||
noaccel = true;
|
||||
}
|
||||
// [SP] If emulating GZDoom fullbright, disable acceleration
|
||||
if (r_fullbrightignoresectorcolor && swrenderer::fixedlightlev >= 0)
|
||||
if (r_fullbrightignoresectorcolor && cameraLight->fixedlightlev >= 0)
|
||||
mybasecolormap = &FullNormalLight;
|
||||
if (r_fullbrightignoresectorcolor && !foggy && sprite->GetState()->GetFullbright())
|
||||
mybasecolormap = &FullNormalLight;
|
||||
|
|
|
@ -136,11 +136,12 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const Vec4f &clipPla
|
|||
}
|
||||
|
||||
bool fullbrightSprite = ((thing->renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT));
|
||||
swrenderer::CameraLight *cameraLight = swrenderer::CameraLight::Instance();
|
||||
|
||||
PolyDrawArgs args;
|
||||
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->SpriteGlobVis();
|
||||
args.uniforms.flags = 0;
|
||||
if (fullbrightSprite || swrenderer::fixedlightlev >= 0 || swrenderer::fixedcolormap)
|
||||
if (fullbrightSprite || cameraLight->fixedlightlev >= 0 || cameraLight->fixedcolormap)
|
||||
{
|
||||
args.uniforms.light = 256;
|
||||
args.uniforms.flags |= TriUniforms::fixed_light;
|
||||
|
|
|
@ -352,7 +352,8 @@ FTexture *RenderPolyWall::GetTexture()
|
|||
|
||||
int RenderPolyWall::GetLightLevel()
|
||||
{
|
||||
if (swrenderer::fixedlightlev >= 0 || swrenderer::fixedcolormap)
|
||||
swrenderer::CameraLight *cameraLight = swrenderer::CameraLight::Instance();
|
||||
if (cameraLight->fixedlightlev >= 0 || cameraLight->fixedcolormap)
|
||||
{
|
||||
return 255;
|
||||
}
|
||||
|
|
|
@ -98,10 +98,11 @@ void RenderPolyWallSprite::Render(const TriMatrix &worldToClip, const Vec4f &cli
|
|||
}
|
||||
|
||||
bool fullbrightSprite = ((thing->renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT));
|
||||
swrenderer::CameraLight *cameraLight = swrenderer::CameraLight::Instance();
|
||||
|
||||
PolyDrawArgs args;
|
||||
args.uniforms.globvis = (float)swrenderer::LightVisibility::Instance()->WallGlobVis();
|
||||
if (fullbrightSprite || swrenderer::fixedlightlev >= 0 || swrenderer::fixedcolormap)
|
||||
if (fullbrightSprite || cameraLight->fixedlightlev >= 0 || cameraLight->fixedcolormap)
|
||||
{
|
||||
args.uniforms.light = 256;
|
||||
args.uniforms.flags = TriUniforms::fixed_light;
|
||||
|
|
|
@ -456,11 +456,12 @@ namespace swrenderer
|
|||
return false;
|
||||
colfunc = &SWPixelFormatDrawers::DrawShadedColumn;
|
||||
drawer_needs_pal_input = true;
|
||||
dc_color = fixedcolormap ? fixedcolormap->Maps[APART(color)] : basecolormap->Maps[APART(color)];
|
||||
CameraLight *cameraLight = CameraLight::Instance();
|
||||
dc_color = cameraLight->fixedcolormap ? cameraLight->fixedcolormap->Maps[APART(color)] : basecolormap->Maps[APART(color)];
|
||||
basecolormap = &ShadeFakeColormap[16 - alpha];
|
||||
if (fixedlightlev >= 0 && fixedcolormap == NULL)
|
||||
if (cameraLight->fixedlightlev >= 0 && cameraLight->fixedcolormap == NULL)
|
||||
{
|
||||
R_SetColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev));
|
||||
R_SetColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->fixedlightlev));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -901,7 +901,8 @@ namespace swrenderer
|
|||
|
||||
walltexcoords.Project(sidedef->TexelLength * lwallscale, WallC.sx1, WallC.sx2, WallT);
|
||||
|
||||
if (fixedcolormap == NULL && fixedlightlev < 0)
|
||||
CameraLight *cameraLight = CameraLight::Instance();
|
||||
if (cameraLight->fixedcolormap == nullptr && cameraLight->fixedlightlev < 0)
|
||||
{
|
||||
wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, frontsector->lightlevel) + R_ActualExtraLight(foggy));
|
||||
double GlobVis = LightVisibility::Instance()->WallGlobVis();
|
||||
|
@ -918,7 +919,7 @@ namespace swrenderer
|
|||
|
||||
bool SWRenderLine::IsFogBoundary(sector_t *front, sector_t *back) const
|
||||
{
|
||||
return r_fogboundary && fixedcolormap == NULL && front->ColorMap->Fade &&
|
||||
return r_fogboundary && CameraLight::Instance()->fixedcolormap == nullptr && front->ColorMap->Fade &&
|
||||
front->ColorMap->Fade != back->ColorMap->Fade &&
|
||||
(front->GetTexture(sector_t::ceiling) != skyflatnum || back->GetTexture(sector_t::ceiling) != skyflatnum);
|
||||
}
|
||||
|
@ -932,10 +933,11 @@ namespace swrenderer
|
|||
double yscale;
|
||||
fixed_t xoffset = rw_offset;
|
||||
|
||||
if (fixedlightlev >= 0)
|
||||
R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev));
|
||||
else if (fixedcolormap != NULL)
|
||||
R_SetColorMapLight(fixedcolormap, 0, 0);
|
||||
CameraLight *cameraLight = CameraLight::Instance();
|
||||
if (cameraLight->fixedlightlev >= 0)
|
||||
R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->fixedlightlev));
|
||||
else if (cameraLight->fixedcolormap != nullptr)
|
||||
R_SetColorMapLight(cameraLight->fixedcolormap, 0, 0);
|
||||
|
||||
// clip wall to the floor and ceiling
|
||||
auto ceilingclip = RenderOpaquePass::Instance()->ceilingclip;
|
||||
|
|
|
@ -97,7 +97,8 @@ namespace swrenderer
|
|||
|
||||
Clip3DFloors *clip3d = Clip3DFloors::Instance();
|
||||
|
||||
if (fixedlightlev < 0)
|
||||
CameraLight *cameraLight = CameraLight::Instance();
|
||||
if (cameraLight->fixedlightlev < 0)
|
||||
{
|
||||
if (!(clip3d->fake3D & FAKE3D_CLIPTOP))
|
||||
{
|
||||
|
@ -139,10 +140,10 @@ namespace swrenderer
|
|||
spryscale = ds->iscale + ds->iscalestep * (x1 - ds->x1);
|
||||
rw_scalestep = ds->iscalestep;
|
||||
|
||||
if (fixedlightlev >= 0)
|
||||
R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev));
|
||||
else if (fixedcolormap != nullptr)
|
||||
R_SetColorMapLight(fixedcolormap, 0, 0);
|
||||
if (cameraLight->fixedlightlev >= 0)
|
||||
R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->fixedlightlev));
|
||||
else if (cameraLight->fixedcolormap != nullptr)
|
||||
R_SetColorMapLight(cameraLight->fixedcolormap, 0, 0);
|
||||
|
||||
// find positioning
|
||||
texheight = tex->GetScaledHeightDouble();
|
||||
|
@ -269,7 +270,7 @@ namespace swrenderer
|
|||
{
|
||||
for (int x = x1; x < x2; ++x)
|
||||
{
|
||||
if (fixedcolormap == nullptr && fixedlightlev < 0)
|
||||
if (cameraLight->fixedcolormap == nullptr && cameraLight->fixedlightlev < 0)
|
||||
{
|
||||
R_SetColorMapLight(basecolormap, rw_light, wallshade);
|
||||
}
|
||||
|
@ -440,10 +441,11 @@ namespace swrenderer
|
|||
texturemid += rowoffset;
|
||||
}
|
||||
|
||||
if (fixedlightlev >= 0)
|
||||
R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev));
|
||||
else if (fixedcolormap != nullptr)
|
||||
R_SetColorMapLight(fixedcolormap, 0, 0);
|
||||
CameraLight *cameraLight = CameraLight::Instance();
|
||||
if (cameraLight->fixedlightlev >= 0)
|
||||
R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->fixedlightlev));
|
||||
else if (cameraLight->fixedcolormap != nullptr)
|
||||
R_SetColorMapLight(cameraLight->fixedcolormap, 0, 0);
|
||||
|
||||
WallC.sz1 = ds->sz1;
|
||||
WallC.sz2 = ds->sz2;
|
||||
|
@ -665,7 +667,8 @@ namespace swrenderer
|
|||
// correct colors now
|
||||
FDynamicColormap *basecolormap = frontsector->ColorMap;
|
||||
wallshade = ds->shade;
|
||||
if (fixedlightlev < 0)
|
||||
CameraLight *cameraLight = CameraLight::Instance();
|
||||
if (cameraLight->fixedlightlev < 0)
|
||||
{
|
||||
if ((ds->bFakeBoundary & 3) == 2)
|
||||
{
|
||||
|
@ -839,7 +842,8 @@ namespace swrenderer
|
|||
// correct colors now
|
||||
FDynamicColormap *basecolormap = frontsector->ColorMap;
|
||||
wallshade = ds->shade;
|
||||
if (fixedlightlev < 0)
|
||||
CameraLight *cameraLight = CameraLight::Instance();
|
||||
if (cameraLight->fixedlightlev < 0)
|
||||
{
|
||||
if ((ds->bFakeBoundary & 3) == 2)
|
||||
{
|
||||
|
|
|
@ -326,7 +326,8 @@ namespace swrenderer
|
|||
|
||||
dc_wall_fracbits = r_swtruecolor ? FRACBITS : fracbits;
|
||||
|
||||
bool fixed = (fixedcolormap != NULL || fixedlightlev >= 0);
|
||||
CameraLight *cameraLight = CameraLight::Instance();
|
||||
bool fixed = (cameraLight->fixedcolormap != NULL || cameraLight->fixedlightlev >= 0);
|
||||
if (fixed)
|
||||
{
|
||||
dc_wall_colormap[0] = dc_colormap;
|
||||
|
@ -339,8 +340,8 @@ namespace swrenderer
|
|||
dc_wall_light[3] = 0;
|
||||
}
|
||||
|
||||
if (fixedcolormap)
|
||||
R_SetColorMapLight(fixedcolormap, 0, 0);
|
||||
if (cameraLight->fixedcolormap)
|
||||
R_SetColorMapLight(cameraLight->fixedcolormap, 0, 0);
|
||||
else
|
||||
R_SetColorMapLight(basecolormap, 0, 0);
|
||||
|
||||
|
@ -455,7 +456,8 @@ namespace swrenderer
|
|||
}
|
||||
else
|
||||
{
|
||||
if (fixedcolormap != NULL || fixedlightlev >= 0 || !(frontsector->e && frontsector->e->XFloor.lightlist.Size()))
|
||||
CameraLight *cameraLight = CameraLight::Instance();
|
||||
if (cameraLight->fixedcolormap != NULL || cameraLight->fixedlightlev >= 0 || !(frontsector->e && frontsector->e->XFloor.lightlist.Size()))
|
||||
{
|
||||
ProcessNormalWall(uwal, dwal, texturemid, swal, lwal);
|
||||
}
|
||||
|
|
|
@ -108,14 +108,15 @@ namespace swrenderer
|
|||
basecolormap = colormap;
|
||||
GlobVis = LightVisibility::Instance()->FlatPlaneGlobVis() / planeheight;
|
||||
ds_light = 0;
|
||||
if (fixedlightlev >= 0)
|
||||
CameraLight *cameraLight = CameraLight::Instance();
|
||||
if (cameraLight->fixedlightlev >= 0)
|
||||
{
|
||||
R_SetDSColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev));
|
||||
R_SetDSColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->fixedlightlev));
|
||||
plane_shade = false;
|
||||
}
|
||||
else if (fixedcolormap)
|
||||
else if (cameraLight->fixedcolormap)
|
||||
{
|
||||
R_SetDSColorMapLight(fixedcolormap, 0, 0);
|
||||
R_SetDSColorMapLight(cameraLight->fixedcolormap, 0, 0);
|
||||
plane_shade = false;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -148,21 +148,22 @@ namespace swrenderer
|
|||
}
|
||||
|
||||
bool fakefixed = false;
|
||||
if (fixedcolormap)
|
||||
CameraLight *cameraLight = CameraLight::Instance();
|
||||
if (cameraLight->fixedcolormap)
|
||||
{
|
||||
R_SetColorMapLight(fixedcolormap, 0, 0);
|
||||
R_SetColorMapLight(cameraLight->fixedcolormap, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
fakefixed = true;
|
||||
fixedcolormap = &NormalLight;
|
||||
R_SetColorMapLight(fixedcolormap, 0, 0);
|
||||
cameraLight->fixedcolormap = &NormalLight;
|
||||
R_SetColorMapLight(cameraLight->fixedcolormap, 0, 0);
|
||||
}
|
||||
|
||||
DrawSky(pl);
|
||||
|
||||
if (fakefixed)
|
||||
fixedcolormap = NULL;
|
||||
cameraLight->fixedcolormap = nullptr;
|
||||
}
|
||||
|
||||
void RenderSkyPlane::DrawSkyColumnStripe(int start_x, int y1, int y2, int columns, double scale, double texturemid, double yrepeat)
|
||||
|
|
|
@ -150,14 +150,15 @@ namespace swrenderer
|
|||
|
||||
basecolormap = colormap;
|
||||
|
||||
if (fixedlightlev >= 0)
|
||||
CameraLight *cameraLight = CameraLight::Instance();
|
||||
if (cameraLight->fixedlightlev >= 0)
|
||||
{
|
||||
R_SetDSColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev));
|
||||
R_SetDSColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->fixedlightlev));
|
||||
plane_shade = false;
|
||||
}
|
||||
else if (fixedcolormap)
|
||||
else if (cameraLight->fixedcolormap)
|
||||
{
|
||||
R_SetDSColorMapLight(fixedcolormap, 0, 0);
|
||||
R_SetDSColorMapLight(cameraLight->fixedcolormap, 0, 0);
|
||||
plane_shade = false;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -254,8 +254,7 @@ void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoin
|
|||
|
||||
// curse Doom's overuse of global variables in the renderer.
|
||||
// These get clobbered by rendering to a camera texture but they need to be preserved so the final rendering can be done with the correct palette.
|
||||
FSWColormap *savecolormap = fixedcolormap;
|
||||
FSpecialColormap *savecm = realfixedcolormap;
|
||||
CameraLight savedCameraLight = *CameraLight::Instance();
|
||||
|
||||
DAngle savedfov = FieldOfView;
|
||||
R_SetFOV ((double)fov);
|
||||
|
@ -315,8 +314,7 @@ void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoin
|
|||
|
||||
tex->SetUpdated();
|
||||
|
||||
fixedcolormap = savecolormap;
|
||||
realfixedcolormap = savecm;
|
||||
*CameraLight::Instance() = savedCameraLight;
|
||||
}
|
||||
|
||||
sector_t *FSoftwareRenderer::FakeFlat(sector_t *sec, sector_t *tempsec, int *floorlightlevel, int *ceilinglightlevel)
|
||||
|
|
|
@ -38,21 +38,23 @@ EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor)
|
|||
|
||||
namespace swrenderer
|
||||
{
|
||||
int fixedlightlev;
|
||||
FSWColormap *fixedcolormap;
|
||||
FSpecialColormap *realfixedcolormap;
|
||||
CameraLight *CameraLight::Instance()
|
||||
{
|
||||
static CameraLight instance;
|
||||
return &instance;
|
||||
}
|
||||
|
||||
void R_SetupColormap(AActor *actor)
|
||||
void CameraLight::SetCamera(AActor *actor)
|
||||
{
|
||||
player_t *player = actor->player;
|
||||
if (camera && camera->player != 0)
|
||||
if (camera && camera->player != nullptr)
|
||||
player = camera->player;
|
||||
|
||||
realfixedcolormap = NULL;
|
||||
fixedcolormap = NULL;
|
||||
realfixedcolormap = nullptr;
|
||||
fixedcolormap = nullptr;
|
||||
fixedlightlev = -1;
|
||||
|
||||
if (player != NULL && camera == player->mo)
|
||||
if (player != nullptr && camera == player->mo)
|
||||
{
|
||||
if (player->fixedcolormap >= 0 && player->fixedcolormap < (int)SpecialColormaps.Size())
|
||||
{
|
||||
|
@ -80,7 +82,7 @@ namespace swrenderer
|
|||
}
|
||||
}
|
||||
// [RH] Inverse light for shooting the Sigil
|
||||
if (fixedcolormap == NULL && extralight == INT_MIN)
|
||||
if (fixedcolormap == nullptr && extralight == INT_MIN)
|
||||
{
|
||||
fixedcolormap = &SpecialColormaps[INVERSECOLORMAP];
|
||||
extralight = 0;
|
||||
|
@ -184,15 +186,16 @@ namespace swrenderer
|
|||
basecolormap = GetSpecialLights(basecolormap->Color, basecolormap->Fade.InverseColor(), basecolormap->Desaturate);
|
||||
}
|
||||
|
||||
if (fixedcolormap)
|
||||
CameraLight *cameraLight = CameraLight::Instance();
|
||||
if (cameraLight->fixedcolormap)
|
||||
{
|
||||
BaseColormap = fixedcolormap;
|
||||
BaseColormap = cameraLight->fixedcolormap;
|
||||
ColormapNum = 0;
|
||||
}
|
||||
else if (fixedlightlev >= 0)
|
||||
else if (cameraLight->fixedlightlev >= 0)
|
||||
{
|
||||
BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap;
|
||||
ColormapNum = fixedlightlev >> COLORMAPSHIFT;
|
||||
ColormapNum = cameraLight->fixedlightlev >> COLORMAPSHIFT;
|
||||
}
|
||||
else if (fullbright)
|
||||
{
|
||||
|
|
|
@ -54,11 +54,17 @@ struct FSWColormap;
|
|||
|
||||
namespace swrenderer
|
||||
{
|
||||
extern int fixedlightlev;
|
||||
extern FSWColormap *fixedcolormap;
|
||||
extern FSpecialColormap *realfixedcolormap;
|
||||
class CameraLight
|
||||
{
|
||||
public:
|
||||
static CameraLight *Instance();
|
||||
|
||||
void R_SetupColormap(AActor *actor);
|
||||
int fixedlightlev = 0;
|
||||
FSWColormap *fixedcolormap = nullptr;
|
||||
FSpecialColormap *realfixedcolormap = nullptr;
|
||||
|
||||
void SetCamera(AActor *actor);
|
||||
};
|
||||
|
||||
class LightVisibility
|
||||
{
|
||||
|
|
|
@ -479,8 +479,9 @@ namespace swrenderer
|
|||
bool foggy = level.fadeto || frontsector->ColorMap->Fade || (level.flags & LEVEL_HASFADETABLE);
|
||||
|
||||
// kg3D - fake lights
|
||||
CameraLight *cameraLight = CameraLight::Instance();
|
||||
FDynamicColormap *basecolormap;
|
||||
if (fixedlightlev < 0 && frontsector->e && frontsector->e->XFloor.lightlist.Size())
|
||||
if (cameraLight->fixedlightlev < 0 && frontsector->e && frontsector->e->XFloor.lightlist.Size())
|
||||
{
|
||||
light = P_GetPlaneLight(frontsector, &frontsector->ceilingplane, false);
|
||||
basecolormap = light->extra_colormap;
|
||||
|
@ -493,7 +494,7 @@ namespace swrenderer
|
|||
}
|
||||
else
|
||||
{
|
||||
basecolormap = (r_fullbrightignoresectorcolor && fixedlightlev >= 0) ? &FullNormalLight : frontsector->ColorMap;
|
||||
basecolormap = (r_fullbrightignoresectorcolor && cameraLight->fixedlightlev >= 0) ? &FullNormalLight : frontsector->ColorMap;
|
||||
}
|
||||
|
||||
portal = frontsector->ValidatePortal(sector_t::ceiling);
|
||||
|
@ -518,7 +519,7 @@ namespace swrenderer
|
|||
if (ceilingplane)
|
||||
ceilingplane->AddLights(frontsector->lighthead);
|
||||
|
||||
if (fixedlightlev < 0 && frontsector->e && frontsector->e->XFloor.lightlist.Size())
|
||||
if (cameraLight->fixedlightlev < 0 && frontsector->e && frontsector->e->XFloor.lightlist.Size())
|
||||
{
|
||||
light = P_GetPlaneLight(frontsector, &frontsector->floorplane, false);
|
||||
basecolormap = light->extra_colormap;
|
||||
|
@ -531,7 +532,7 @@ namespace swrenderer
|
|||
}
|
||||
else
|
||||
{
|
||||
basecolormap = (r_fullbrightignoresectorcolor && fixedlightlev >= 0) ? &FullNormalLight : frontsector->ColorMap;
|
||||
basecolormap = (r_fullbrightignoresectorcolor && cameraLight->fixedlightlev >= 0) ? &FullNormalLight : frontsector->ColorMap;
|
||||
}
|
||||
|
||||
// killough 3/7/98: Add (x,y) offsets to flats, add deep water check
|
||||
|
@ -603,7 +604,7 @@ namespace swrenderer
|
|||
else position = sector_t::floor;
|
||||
frontsector = &tempsec;
|
||||
|
||||
if (fixedlightlev < 0 && sub->sector->e->XFloor.lightlist.Size())
|
||||
if (cameraLight->fixedlightlev < 0 && sub->sector->e->XFloor.lightlist.Size())
|
||||
{
|
||||
light = P_GetPlaneLight(sub->sector, &frontsector->floorplane, false);
|
||||
basecolormap = light->extra_colormap;
|
||||
|
@ -668,7 +669,7 @@ namespace swrenderer
|
|||
frontsector = &tempsec;
|
||||
|
||||
tempsec.ceilingplane.ChangeHeight(-1 / 65536.);
|
||||
if (fixedlightlev < 0 && sub->sector->e->XFloor.lightlist.Size())
|
||||
if (cameraLight->fixedlightlev < 0 && sub->sector->e->XFloor.lightlist.Size())
|
||||
{
|
||||
light = P_GetPlaneLight(sub->sector, &frontsector->ceilingplane, false);
|
||||
basecolormap = light->extra_colormap;
|
||||
|
|
|
@ -103,9 +103,9 @@ namespace swrenderer
|
|||
RenderActorView(player->mo);
|
||||
|
||||
// Apply special colormap if the target cannot do it
|
||||
if (realfixedcolormap && r_swtruecolor && !(r_shadercolormaps && screen->Accel2D))
|
||||
if (CameraLight::Instance()->realfixedcolormap && r_swtruecolor && !(r_shadercolormaps && screen->Accel2D))
|
||||
{
|
||||
DrawerCommandQueue::QueueCommand<ApplySpecialColormapRGBACommand>(realfixedcolormap, screen);
|
||||
DrawerCommandQueue::QueueCommand<ApplySpecialColormapRGBACommand>(CameraLight::Instance()->realfixedcolormap, screen);
|
||||
}
|
||||
|
||||
R_EndDrawerCommands();
|
||||
|
@ -125,7 +125,7 @@ namespace swrenderer
|
|||
clip3d->ResetClip(); // reset clips (floor/ceiling)
|
||||
|
||||
R_SetupFrame(actor);
|
||||
R_SetupColormap(actor);
|
||||
CameraLight::Instance()->SetCamera(actor);
|
||||
RenderViewport::Instance()->SetupFreelook();
|
||||
|
||||
RenderPortal::Instance()->CopyStackedViewParameters();
|
||||
|
@ -193,7 +193,7 @@ namespace swrenderer
|
|||
// copy to the screen does not use a special colormap shader.
|
||||
if (!r_shadercolormaps && !r_swtruecolor)
|
||||
{
|
||||
realfixedcolormap = NULL;
|
||||
CameraLight::Instance()->realfixedcolormap = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -253,10 +253,11 @@ namespace swrenderer
|
|||
}
|
||||
|
||||
light = lightleft + (x1 - savecoord.sx1) * lightstep;
|
||||
if (fixedlightlev >= 0)
|
||||
R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : usecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev));
|
||||
else if (fixedcolormap != NULL)
|
||||
R_SetColorMapLight(fixedcolormap, 0, 0);
|
||||
CameraLight *cameraLight = CameraLight::Instance();
|
||||
if (cameraLight->fixedlightlev >= 0)
|
||||
R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : usecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->fixedlightlev));
|
||||
else if (cameraLight->fixedcolormap != NULL)
|
||||
R_SetColorMapLight(cameraLight->fixedcolormap, 0, 0);
|
||||
else if (!foggy && (decal->RenderFlags & RF_FULLBRIGHT))
|
||||
R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : usecolormap, 0, 0);
|
||||
else
|
||||
|
|
|
@ -90,7 +90,8 @@ namespace swrenderer
|
|||
return;
|
||||
|
||||
FDynamicColormap *basecolormap;
|
||||
if (fixedlightlev < 0 && viewsector->e && viewsector->e->XFloor.lightlist.Size())
|
||||
CameraLight *cameraLight = CameraLight::Instance();
|
||||
if (cameraLight->fixedlightlev < 0 && viewsector->e && viewsector->e->XFloor.lightlist.Size())
|
||||
{
|
||||
for (i = viewsector->e->XFloor.lightlist.Size() - 1; i >= 0; i--)
|
||||
{
|
||||
|
@ -480,7 +481,8 @@ namespace swrenderer
|
|||
}
|
||||
// If the main colormap has fixed lights, and this sprite is being drawn with that
|
||||
// colormap, disable acceleration so that the lights can remain fixed.
|
||||
if (!noaccel && realfixedcolormap == nullptr &&
|
||||
CameraLight *cameraLight = CameraLight::Instance();
|
||||
if (!noaccel && cameraLight->realfixedcolormap == nullptr &&
|
||||
NormalLightHasFixedLights && vis.Light.BaseColormap == &NormalLight &&
|
||||
vis.pic->UseBasePalette())
|
||||
{
|
||||
|
|
|
@ -86,7 +86,8 @@ namespace swrenderer
|
|||
if ((clip3d->fake3D & FAKE3D_CLIPTOP) && spr->gzb >= clip3d->sclipTop) return;
|
||||
|
||||
// kg3D - correct colors now
|
||||
if (!fixedcolormap && fixedlightlev < 0 && spr->sector->e && spr->sector->e->XFloor.lightlist.Size())
|
||||
CameraLight *cameraLight = CameraLight::Instance();
|
||||
if (!cameraLight->fixedcolormap && cameraLight->fixedlightlev < 0 && spr->sector->e && spr->sector->e->XFloor.lightlist.Size())
|
||||
{
|
||||
if (!(clip3d->fake3D & FAKE3D_CLIPTOP))
|
||||
{
|
||||
|
|
|
@ -184,10 +184,11 @@ namespace swrenderer
|
|||
float lightleft = float(GlobVis / spr->wallc.sz1);
|
||||
float lightstep = float((GlobVis / spr->wallc.sz2 - lightleft) / (spr->wallc.sx2 - spr->wallc.sx1));
|
||||
float light = lightleft + (x1 - spr->wallc.sx1) * lightstep;
|
||||
if (fixedlightlev >= 0)
|
||||
R_SetColorMapLight(usecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev));
|
||||
else if (fixedcolormap != NULL)
|
||||
R_SetColorMapLight(fixedcolormap, 0, 0);
|
||||
CameraLight *cameraLight = CameraLight::Instance();
|
||||
if (cameraLight->fixedlightlev >= 0)
|
||||
R_SetColorMapLight(usecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->fixedlightlev));
|
||||
else if (cameraLight->fixedcolormap != NULL)
|
||||
R_SetColorMapLight(cameraLight->fixedcolormap, 0, 0);
|
||||
else if (!spr->foggy && (spr->renderflags & RF_FULLBRIGHT))
|
||||
R_SetColorMapLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : usecolormap, 0, 0);
|
||||
else
|
||||
|
|
|
@ -197,7 +197,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms)
|
|||
R_SetTranslationMap(identitymap);
|
||||
}
|
||||
|
||||
fixedcolormap = dc_fcolormap;
|
||||
CameraLight::Instance()->fixedcolormap = dc_fcolormap;
|
||||
bool visible;
|
||||
FDynamicColormap *basecolormap = nullptr;
|
||||
if (r_swtruecolor)
|
||||
|
|
|
@ -1405,7 +1405,7 @@ void D3DFB::Draw3DPart(bool copy3d)
|
|||
D3DCOLOR color0, color1;
|
||||
if (Accel2D)
|
||||
{
|
||||
auto &map = swrenderer::realfixedcolormap;
|
||||
auto &map = swrenderer::CameraLight::Instance()->realfixedcolormap;
|
||||
if (map == NULL)
|
||||
{
|
||||
color0 = 0;
|
||||
|
|
Loading…
Reference in a new issue