mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-23 12:32:34 +00:00
Also calculate wallsprite and decal texture coordinates in ProjectedWallTexcoords
This commit is contained in:
parent
37fdf14422
commit
879fae7cd0
5 changed files with 32 additions and 65 deletions
|
@ -157,7 +157,7 @@ namespace swrenderer
|
|||
texturemid = MIN(frontsector->GetPlaneTexZ(sector_t::ceiling), backsector->GetPlaneTexZ(sector_t::ceiling));
|
||||
double rowoffset = curline->sidedef->GetTextureYOffset(side_t::mid);
|
||||
if (tex->useWorldPanning(curline->GetLevel()))
|
||||
rowoffset /= fabs(ds->texcoords.yscale);
|
||||
rowoffset /= fabs(tex->GetScale().Y * curline->sidedef->GetTextureYScale(side_t::mid));
|
||||
double textop = texturemid + rowoffset - Thread->Viewport->viewpoint.Pos.Z;
|
||||
|
||||
// [RH] Don't bother drawing segs that are completely offscreen
|
||||
|
|
|
@ -432,6 +432,19 @@ namespace swrenderer
|
|||
Project(viewport, lineseg->sidedef->TexelLength * xscale, x1, x2, WallT);
|
||||
}
|
||||
|
||||
void ProjectedWallTexcoords::ProjectSprite(RenderViewport* viewport, double topZ, double scale, bool flipX, bool flipY, int x1, int x2, const FWallTmapVals& WallT, FSoftwareTexture* pic)
|
||||
{
|
||||
yscale = 1.0 / scale;
|
||||
texturemid = pic->GetTopOffset(0) + (topZ - viewport->viewpoint.Pos.Z) * yscale;
|
||||
if (flipY)
|
||||
{
|
||||
yscale = -yscale;
|
||||
texturemid -= pic->GetHeight();
|
||||
}
|
||||
|
||||
Project(viewport, pic->GetWidth(), x1, x2, WallT, flipX);
|
||||
}
|
||||
|
||||
void ProjectedWallTexcoords::Project(RenderViewport *viewport, double walxrepeat, int x1, int x2, const FWallTmapVals &WallT, bool flipx)
|
||||
{
|
||||
this->walxrepeat = walxrepeat;
|
||||
|
|
|
@ -66,19 +66,16 @@ namespace swrenderer
|
|||
void ProjectBottom(RenderViewport* viewport, sector_t* frontsector, sector_t* backsector, seg_t* lineseg, int x1, int x2, const FWallTmapVals& WallT, FSoftwareTexture* pic);
|
||||
void ProjectTranslucent(RenderViewport* viewport, sector_t* frontsector, sector_t* backsector, seg_t* lineseg, int x1, int x2, const FWallTmapVals& WallT, FSoftwareTexture* pic);
|
||||
void Project3DFloor(RenderViewport* viewport, F3DFloor* rover, seg_t* lineseg, int x1, int x2, const FWallTmapVals& WallT, FSoftwareTexture* pic);
|
||||
|
||||
void Project(RenderViewport *viewport, double walxrepeat, int x1, int x2, const FWallTmapVals &WallT, bool flipx = false);
|
||||
void ProjectSprite(RenderViewport* viewport, double topZ, double scale, bool flipX, bool flipY, int x1, int x2, const FWallTmapVals& WallT, FSoftwareTexture* pic);
|
||||
|
||||
float VStep(int x) const;
|
||||
fixed_t UPos(int x) const;
|
||||
|
||||
float yscale = 1.0f;
|
||||
fixed_t xoffset = 0;
|
||||
double texturemid = 0.0f;
|
||||
|
||||
explicit operator bool() const { return valid; }
|
||||
|
||||
private:
|
||||
void Project(RenderViewport* viewport, double walxrepeat, int x1, int x2, const FWallTmapVals& WallT, bool flipx = false);
|
||||
|
||||
static fixed_t GetXOffset(seg_t* lineseg, FSoftwareTexture* tex, side_t::ETexpart texpart);
|
||||
static double GetRowOffset(seg_t* lineseg, FSoftwareTexture* tex, side_t::ETexpart texpart);
|
||||
static double GetXScale(side_t* sidedef, FSoftwareTexture* tex, side_t::ETexpart texpart);
|
||||
|
@ -93,6 +90,10 @@ namespace swrenderer
|
|||
FWallTmapVals WallT;
|
||||
bool flipx;
|
||||
|
||||
float yscale = 1.0f;
|
||||
fixed_t xoffset = 0;
|
||||
double texturemid = 0.0f;
|
||||
|
||||
friend class RenderWallPart;
|
||||
friend class SpriteDrawerArgs;
|
||||
};
|
||||
|
|
|
@ -69,8 +69,6 @@ namespace swrenderer
|
|||
{
|
||||
DVector2 decal_left, decal_right, decal_pos;
|
||||
int x1, x2;
|
||||
double yscale;
|
||||
uint8_t flipx;
|
||||
double zpos;
|
||||
int needrepeat = 0;
|
||||
sector_t *back;
|
||||
|
@ -127,7 +125,6 @@ namespace swrenderer
|
|||
}
|
||||
|
||||
FTexture *tex = TexMan.GetPalettedTexture(decal->PicNum, true);
|
||||
flipx = (uint8_t)(decal->RenderFlags & RF_XFLIP);
|
||||
|
||||
if (tex == NULL || !tex->isValid())
|
||||
{
|
||||
|
@ -149,13 +146,11 @@ namespace swrenderer
|
|||
decal_pos = { dcx, dcy };
|
||||
|
||||
DVector2 angvec = (curline->v2->fPos() - curline->v1->fPos()).Unit();
|
||||
float maskedScaleY;
|
||||
|
||||
decal_left = decal_pos - edge_left * angvec - thread->Viewport->viewpoint.Pos;
|
||||
decal_right = decal_pos + edge_right * angvec - thread->Viewport->viewpoint.Pos;
|
||||
|
||||
CameraLight *cameraLight;
|
||||
double texturemid;
|
||||
|
||||
FWallCoords WallC;
|
||||
if (WallC.Init(thread, decal_left, decal_right, TOO_CLOSE_Z))
|
||||
|
@ -167,9 +162,6 @@ namespace swrenderer
|
|||
if (x1 >= clipper->x2 || x2 <= clipper->x1)
|
||||
return;
|
||||
|
||||
FWallTmapVals WallT;
|
||||
WallT.InitFromWallCoords(thread, &WallC);
|
||||
|
||||
if (drawsegPass)
|
||||
{
|
||||
uint32_t clipMode = decal->RenderFlags & RF_CLIPMASK;
|
||||
|
@ -230,9 +222,6 @@ namespace swrenderer
|
|||
}
|
||||
}
|
||||
|
||||
yscale = decal->ScaleY;
|
||||
texturemid = WallSpriteTile->GetTopOffset(0) + (zpos - thread->Viewport->viewpoint.Pos.Z) / yscale;
|
||||
|
||||
// Clip sprite to drawseg
|
||||
x1 = MAX<int>(clipper->x1, x1);
|
||||
x2 = MIN<int>(clipper->x2, x2);
|
||||
|
@ -255,24 +244,12 @@ namespace swrenderer
|
|||
cameraLight = CameraLight::Instance();
|
||||
|
||||
// Draw it
|
||||
bool sprflipvert;
|
||||
if (decal->RenderFlags & RF_YFLIP)
|
||||
{
|
||||
sprflipvert = true;
|
||||
yscale = -yscale;
|
||||
texturemid -= WallSpriteTile->GetHeight();
|
||||
}
|
||||
else
|
||||
{
|
||||
sprflipvert = false;
|
||||
}
|
||||
|
||||
maskedScaleY = float(1 / yscale);
|
||||
FWallTmapVals WallT;
|
||||
WallT.InitFromWallCoords(thread, &WallC);
|
||||
|
||||
ProjectedWallTexcoords walltexcoords;
|
||||
walltexcoords.Project(thread->Viewport.get(), WallSpriteTile->GetWidth(), x1, x2, WallT, flipx);
|
||||
walltexcoords.yscale = maskedScaleY;
|
||||
walltexcoords.texturemid = texturemid;
|
||||
walltexcoords.ProjectSprite(thread->Viewport.get(), zpos, decal->ScaleY, decal->RenderFlags & RF_XFLIP, decal->RenderFlags & RF_YFLIP, x1, x2, WallT, WallSpriteTile);
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -288,6 +265,7 @@ namespace swrenderer
|
|||
if (visible)
|
||||
{
|
||||
thread->PrepareTexture(WallSpriteTile, decal->RenderStyle);
|
||||
bool sprflipvert = (decal->RenderFlags & RF_YFLIP);
|
||||
while (x < x2)
|
||||
{
|
||||
if (calclighting)
|
||||
|
|
|
@ -67,8 +67,6 @@
|
|||
#include "swrenderer/r_memory.h"
|
||||
#include "swrenderer/r_renderthread.h"
|
||||
|
||||
EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor);
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
void RenderWallSprite::Project(RenderThread *thread, AActor *thing, const DVector3 &pos, FTexture *ppic, const DVector2 &scale, int renderflags, int lightlevel, bool foggy, FDynamicColormap *basecolormap)
|
||||
|
@ -162,21 +160,11 @@ namespace swrenderer
|
|||
{
|
||||
auto spr = this;
|
||||
|
||||
int x1, x2;
|
||||
double iyscale;
|
||||
bool sprflipvert;
|
||||
|
||||
x1 = MAX<int>(spr->x1, spr->wallc.sx1);
|
||||
x2 = MIN<int>(spr->x2, spr->wallc.sx2);
|
||||
int x1 = MAX<int>(spr->x1, spr->wallc.sx1);
|
||||
int x2 = MIN<int>(spr->x2, spr->wallc.sx2);
|
||||
if (x1 >= x2)
|
||||
return;
|
||||
|
||||
FWallTmapVals WallT;
|
||||
WallT.InitFromWallCoords(thread, &spr->wallc);
|
||||
|
||||
iyscale = 1 / spr->yscale;
|
||||
double texturemid = (spr->gzt - thread->Viewport->viewpoint.Pos.Z) * iyscale;
|
||||
|
||||
// Prepare lighting
|
||||
|
||||
// Decals that are added to the scene must fade to black.
|
||||
|
@ -200,30 +188,18 @@ namespace swrenderer
|
|||
|
||||
// Draw it
|
||||
auto WallSpriteTile = spr->pic;
|
||||
if (spr->renderflags & RF_YFLIP)
|
||||
{
|
||||
sprflipvert = true;
|
||||
iyscale = -iyscale;
|
||||
texturemid -= spr->pic->GetHeight();
|
||||
}
|
||||
else
|
||||
{
|
||||
sprflipvert = false;
|
||||
}
|
||||
|
||||
float maskedScaleY = (float)iyscale;
|
||||
|
||||
int x = x1;
|
||||
FWallTmapVals WallT;
|
||||
WallT.InitFromWallCoords(thread, &spr->wallc);
|
||||
|
||||
ProjectedWallTexcoords walltexcoords;
|
||||
walltexcoords.Project(thread->Viewport.get(), spr->pic->GetWidth(), x1, x2, WallT, spr->renderflags & RF_XFLIP);
|
||||
walltexcoords.yscale = maskedScaleY;
|
||||
walltexcoords.texturemid = texturemid;
|
||||
walltexcoords.ProjectSprite(thread->Viewport.get(), spr->gzt, spr->yscale, spr->renderflags & RF_XFLIP, spr->renderflags & RF_YFLIP, x1, x2, WallT, WallSpriteTile);
|
||||
|
||||
RenderTranslucentPass *translucentPass = thread->TranslucentPass.get();
|
||||
|
||||
thread->PrepareTexture(WallSpriteTile, spr->RenderStyle);
|
||||
while (x < x2)
|
||||
bool sprflipvert = (spr->renderflags & RF_YFLIP);
|
||||
for (int x = x1; x < x2; x++)
|
||||
{
|
||||
if (calclighting)
|
||||
{
|
||||
|
@ -233,7 +209,6 @@ namespace swrenderer
|
|||
if (!translucentPass->ClipSpriteColumnWithPortals(x, spr))
|
||||
drawerargs.DrawMaskedColumn(thread, x, WallSpriteTile, walltexcoords, sprflipvert, mfloorclip, mceilingclip, spr->RenderStyle);
|
||||
light += lightstep;
|
||||
x++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue