- remove InitSoftwareSky

This commit is contained in:
Magnus Norddahl 2018-12-19 04:44:25 +01:00
parent db295fae3a
commit ebfa61514e
4 changed files with 95 additions and 65 deletions

View file

@ -31,12 +31,7 @@
#include "polyrenderer/scene/poly_light.h"
EXTERN_CVAR(Float, skyoffset)
extern double skytexturemid;
extern float skyiscale;
extern double skyscale;
extern fixed_t sky1cyl, sky2cyl;
EXTERN_CVAR(Int, r_skymode)
PolySkyDome::PolySkyDome()
{
@ -292,6 +287,53 @@ static FSoftwareTexture *GetSWTex(FTextureID texid, bool allownull = true)
void PolySkySetup::Update()
{
double skytexturemid = 0.0;
double skyscale = 0.0;
float skyiscale = 0.0f;
fixed_t sky1cyl = 0, sky2cyl = 0;
auto skytex1 = TexMan.GetPalettedTexture(sky1texture, true);
auto skytex2 = TexMan.GetPalettedTexture(sky2texture, true);
if (skytex1)
{
FSoftwareTexture *sskytex1 = skytex1->GetSoftwareTexture();
FSoftwareTexture *sskytex2 = skytex2->GetSoftwareTexture();
skytexturemid = 0;
int skyheight = skytex1->GetDisplayHeight();
if (skyheight >= 128 && skyheight < 200)
{
skytexturemid = -28;
}
else if (skyheight > 200)
{
skytexturemid = (200 - skyheight) * sskytex1->GetScale().Y + ((r_skymode == 2 && !(level.flags & LEVEL_FORCETILEDSKY)) ? skytex1->GetSkyOffset() : 0);
}
if (viewwidth != 0 && viewheight != 0)
{
skyiscale = float(r_Yaspect / freelookviewheight);
skyscale = freelookviewheight / r_Yaspect;
skyiscale *= float(r_viewpoint.FieldOfView.Degrees / 90.);
skyscale *= float(90. / r_viewpoint.FieldOfView.Degrees);
}
if (skystretch)
{
skyscale *= (double)SKYSTRETCH_HEIGHT / skyheight;
skyiscale *= skyheight / (float)SKYSTRETCH_HEIGHT;
skytexturemid *= skyheight / (double)SKYSTRETCH_HEIGHT;
}
// The standard Doom sky texture is 256 pixels wide, repeated 4 times over 360 degrees,
// giving a total sky width of 1024 pixels. So if the sky texture is no wider than 1024,
// we map it to a cylinder with circumfrence 1024. For larger ones, we use the width of
// the texture as the cylinder's circumfrence.
sky1cyl = MAX(sskytex1->GetWidth(), fixed_t(sskytex1->GetScale().X * 1024));
sky2cyl = MAX(sskytex2->GetWidth(), fixed_t(sskytex2->GetScale().Y * 1024));
}
FTextureID sky1tex, sky2tex;
double frontdpos = 0, backdpos = 0;

View file

@ -57,22 +57,26 @@
CVAR(Bool, r_linearsky, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG);
EXTERN_CVAR(Int, r_skymode)
double skytexturemid;
double skyscale;
float skyiscale;
fixed_t sky1cyl, sky2cyl;
void InitSoftwareSky()
namespace swrenderer
{
static FSoftwareTexture *GetSWTex(FTextureID texid, bool allownull = true)
{
auto tex = TexMan.GetPalettedTexture(texid, true);
if (tex == nullptr) return nullptr;
if (!allownull && !tex->isValid()) return nullptr;
return tex->GetSoftwareTexture();
}
RenderSkyPlane::RenderSkyPlane(RenderThread *thread)
{
Thread = thread;
auto skytex1 = TexMan.GetPalettedTexture(sky1texture, true);
auto skytex2 = TexMan.GetPalettedTexture(sky2texture, true);
if (skytex1 == nullptr)
return;
// Note: I don't think it is good that this stuff gets cached globally.
// For something that only needs to be once per frame it is rather pointless and makes it hard to swap out the underlying textures based on user settings.
FSoftwareTexture *sskytex1 = skytex1->GetSoftwareTexture();
FSoftwareTexture *sskytex2 = skytex2->GetSoftwareTexture();
skytexturemid = 0;
@ -108,25 +112,6 @@ void InitSoftwareSky()
// the texture as the cylinder's circumfrence.
sky1cyl = MAX(sskytex1->GetWidth(), fixed_t(sskytex1->GetScale().X * 1024));
sky2cyl = MAX(sskytex2->GetWidth(), fixed_t(sskytex2->GetScale().Y * 1024));
}
namespace swrenderer
{
static FSoftwareTexture *GetSWTex(FTextureID texid, bool allownull = true)
{
auto tex = TexMan.GetPalettedTexture(texid, true);
if (tex == nullptr) return nullptr;
if (!allownull && !tex->isValid()) return nullptr;
return tex->GetSoftwareTexture();
}
RenderSkyPlane::RenderSkyPlane(RenderThread *thread)
{
Thread = thread;
}
void RenderSkyPlane::Render(VisiblePlane *pl)

View file

@ -41,6 +41,11 @@ namespace swrenderer
void DrawSkyColumnStripe(int start_x, int y1, int y2, double scale, double texturemid, double yrepeat);
void DrawSkyColumn(int start_x, int y1, int y2);
double skytexturemid;
double skyscale;
float skyiscale;
fixed_t sky1cyl, sky2cyl;
FSoftwareTexture *frontskytex = nullptr;
FSoftwareTexture *backskytex = nullptr;
angle_t skyflip = 0;

View file

@ -38,7 +38,6 @@
// [RH] Base blending values (for e.g. underwater)
int BaseBlendR, BaseBlendG, BaseBlendB;
float BaseBlendA;
void InitSoftwareSky();
@ -87,7 +86,6 @@ SWSceneDrawer::~SWSceneDrawer()
sector_t *SWSceneDrawer::RenderView(player_t *player)
{
// Avoid using the pixel buffer from the last frame
InitSoftwareSky(); // do this here to avoid problems when texture modes are changed on the fly.
FBTextureIndex = (FBTextureIndex + 1) % 2;
auto &fbtex = FBTexture[FBTextureIndex];