Merge remote-tracking branch 'gzdoom/master' into specularlight

This commit is contained in:
Magnus Norddahl 2017-08-15 00:30:23 +02:00
commit 85f7040f80
46 changed files with 488 additions and 218 deletions

View file

@ -562,6 +562,10 @@ void FDecalLib::ParseDecal (FScanner &sc)
case DECAL_ANIMATOR:
sc.MustGetString ();
newdecal.Animator = FindAnimator (sc.String);
if (newdecal.Animator == nullptr)
{
sc.ScriptMessage("Unable to find animator %s", sc.String);
}
break;
case DECAL_LOWERDECAL:

View file

@ -762,6 +762,7 @@ void DStaticEventHandler::WorldThingDamaged(AActor* actor, AActor* inflictor, AA
return;
FWorldEvent e = E_SetupWorldEvent();
e.Thing = actor;
e.Inflictor = inflictor;
e.Damage = damage;
e.DamageSource = source;
e.DamageType = mod;

View file

@ -2910,11 +2910,14 @@ void FParser::SF_MoveCamera(void)
DAngle targetangle = floatvalue(t_argv[4]);
DAngle anglespeed = floatvalue(t_argv[5]);
DAngle diffangle = deltaangle(cam->Angles.Yaw, targetangle);
if (movespeed > 0 && anglespeed == 0.)
{
if (!finished) targetangle = diffangle * movespeed / movelen;
if (!finished)
{
const DAngle diffangle = targetangle - cam->Angles.Yaw;
targetangle = cam->Angles.Yaw + diffangle * movespeed / movelen;
}
}
else
{
@ -2924,6 +2927,7 @@ void FParser::SF_MoveCamera(void)
cam->radius = 1 / 8192.;
cam->Height = 1 / 8192.;
cam->SetOrigin(movepos, true);
cam->SetAngle(targetangle, false);
t_return.value.i = 1;
}
else

View file

@ -376,6 +376,7 @@ void FMapInfoParser::ParseGameInfo()
GAMEINFOKEY_BOOL(drawreadthis, "drawreadthis")
GAMEINFOKEY_BOOL(swapmenu, "swapmenu")
GAMEINFOKEY_BOOL(dontcrunchcorpses, "dontcrunchcorpses")
GAMEINFOKEY_BOOL(correctprintbold, "correctprintbold")
GAMEINFOKEY_BOOL(intermissioncounter, "intermissioncounter")
GAMEINFOKEY_BOOL(nightmarefast, "nightmarefast")
GAMEINFOKEY_COLOR(dimcolor, "dimcolor")

View file

@ -114,6 +114,7 @@ struct gameinfo_t
bool nightmarefast;
bool swapmenu;
bool dontcrunchcorpses;
bool correctprintbold;
TArray<FName> creditPages;
TArray<FName> finalePages;
TArray<FName> infoPages;

View file

@ -685,7 +685,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal)
// check renderrequired vs ~r_rendercaps, if anything matches we don't support that feature,
// check renderhidden vs r_rendercaps, if anything matches we do support that feature and should hide it.
if (!r_debug_disable_vis_filter && (!!(thing->RenderRequired & ~r_renderercaps)) ||
if ((!r_debug_disable_vis_filter && !!(thing->RenderRequired & ~r_renderercaps)) ||
(!!(thing->RenderHidden & r_renderercaps)))
return;

View file

@ -876,8 +876,7 @@ void P_Spawn3DFloors (void)
line.args[4]=0;
}
}
if (line.args[0] != 0)
P_Set3DFloor(&line, line.args[1]&~8, line.args[2], line.args[3]);
P_Set3DFloor(&line, line.args[1]&~8, line.args[2], line.args[3]);
break;
default:

View file

@ -1843,7 +1843,9 @@ static bool DoUseInv (AActor *actor, PClassActor *info)
AInventory *item = actor->FindInventory (info);
if (item != NULL)
{
if (actor->player == NULL)
player_t* const player = actor->player;
if (nullptr == player)
{
return actor->UseInventory(item);
}
@ -1853,10 +1855,10 @@ static bool DoUseInv (AActor *actor, PClassActor *info)
bool res;
// Bypass CF_TOTALLYFROZEN
cheats = actor->player->cheats;
actor->player->cheats &= ~CF_TOTALLYFROZEN;
cheats = player->cheats;
player->cheats &= ~CF_TOTALLYFROZEN;
res = actor->UseInventory(item);
actor->player->cheats |= (cheats & CF_TOTALLYFROZEN);
player->cheats |= (cheats & CF_TOTALLYFROZEN);
return res;
}
}
@ -8765,7 +8767,10 @@ scriptwait:
if (pcd == PCD_ENDPRINTBOLD || screen == NULL ||
screen->CheckLocalView (consoleplayer))
{
C_MidPrint (activefont, work);
if (pcd == PCD_ENDPRINTBOLD && (gameinfo.correctprintbold || (level.flags2 & LEVEL2_HEXENHACK)))
C_MidPrintBold(activefont, work);
else
C_MidPrint (activefont, work);
}
STRINGBUILDER_FINISH(work);
}

View file

@ -5904,9 +5904,9 @@ static void DoKill(AActor *killtarget, AActor *inflictor, AActor *source, FName
{
int dmgFlags = DMG_NO_ARMOR | DMG_NO_FACTOR;
if (KILS_FOILINVUL)
if (flags & KILS_FOILINVUL)
dmgFlags |= DMG_FOILINVUL;
if (KILS_FOILBUDDHA)
if (flags & KILS_FOILBUDDHA)
dmgFlags |= DMG_FOILBUDDHA;
if ((killtarget->flags & MF_MISSILE) && (flags & KILS_KILLMISSILES))

View file

@ -4036,6 +4036,14 @@ void AActor::CheckPortalTransition(bool islinked)
if (islinked && moved) LinkToWorld(&ctx);
}
DEFINE_ACTION_FUNCTION(AActor, CheckPortalTransition)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_BOOL_DEF(linked);
self->CheckPortalTransition(linked);
return 0;
}
//
// P_MobjThinker
//
@ -4069,10 +4077,6 @@ void AActor::Tick ()
return;
}
// This is necessary to properly interpolate movement outside this function
// like from an ActorMover
ClearInterpolation();
if (flags5 & MF5_NOINTERACTION)
{
// only do the minimally necessary things here to save time:

View file

@ -236,7 +236,7 @@ bool SightCheck::PTR_SightTraverse (intercept_t *in)
FLinePortal *lport = li->getPortal();
if (open.range == 0 && open.portalflags == 0 && (lport == NULL || lport->mType != PORTT_LINKED)) // quick test for totally closed doors (must be delayed if portal checks are needed, though)
if (open.range == 0 && open.portalflags == 0 && (lport == nullptr || lport->mType != PORTT_LINKED)) // quick test for totally closed doors (must be delayed if portal checks are needed, though)
return false; // stop
if (in->frac == 0)
@ -284,7 +284,7 @@ bool SightCheck::PTR_SightTraverse (intercept_t *in)
portals.Push({ in->frac, topslope, bottomslope, sector_t::floor, backsec->GetOppositePortalGroup(sector_t::floor) });
}
}
if (lport)
if (lport != nullptr && lport->mDestination != nullptr)
{
portals.Push({ in->frac, topslope, bottomslope, portaldir, lport->mDestination->frontsector->PortalGroup });
return false;

View file

@ -40,6 +40,7 @@
#include "p_spec.h"
#include "g_levellocals.h"
#include "events.h"
#include "actorinlines.h"
extern gamestate_t wipegamestate;
@ -119,6 +120,15 @@ void P_Ticker (void)
P_ResetSightCounters (false);
R_ClearInterpolationPath();
// Reset all actor interpolations for all actors before the current thinking turn so that indirect actor movement gets properly interpolated.
TThinkerIterator<AActor> it;
AActor *ac;
while ((ac = it.Next()))
{
ac->ClearInterpolation();
}
// Since things will be moving, it's okay to interpolate them in the renderer.
r_NoInterpolate = false;

View file

@ -38,13 +38,13 @@
/////////////////////////////////////////////////////////////////////////////
PolySubsectorGBuffer *PolySubsectorGBuffer::Instance()
PolyZBuffer *PolyZBuffer::Instance()
{
static PolySubsectorGBuffer buffer;
static PolyZBuffer buffer;
return &buffer;
}
void PolySubsectorGBuffer::Resize(int newwidth, int newheight)
void PolyZBuffer::Resize(int newwidth, int newheight)
{
width = newwidth;
height = newheight;

View file

@ -26,21 +26,21 @@
struct TriVertex;
class PolySubsectorGBuffer
class PolyZBuffer
{
public:
static PolySubsectorGBuffer *Instance();
static PolyZBuffer *Instance();
void Resize(int newwidth, int newheight);
int Width() const { return width; }
int Height() const { return height; }
int BlockWidth() const { return (width + 7) / 8; }
int BlockHeight() const { return (height + 7) / 8; }
uint32_t *Values() { return values.data(); }
float *Values() { return values.data(); }
private:
int width;
int height;
std::vector<uint32_t> values;
std::vector<float> values;
};
class PolyStencilBuffer

View file

@ -53,12 +53,11 @@ public:
void SetTexture(FTexture *texture);
void SetTexture(FTexture *texture, uint32_t translationID, bool forcePal = false);
void SetLight(FSWColormap *basecolormap, uint32_t lightlevel, double globVis, bool fixed);
void SetSubsectorDepth(uint32_t subsectorDepth) { mSubsectorDepth = subsectorDepth; }
void SetSubsectorDepthTest(bool enable) { mSubsectorTest = enable; }
void SetDepthTest(bool enable) { mDepthTest = enable; }
void SetStencilTestValue(uint8_t stencilTestValue) { mStencilTestValue = stencilTestValue; }
void SetWriteColor(bool enable) { mWriteColor = enable; }
void SetWriteStencil(bool enable, uint8_t stencilWriteValue = 0) { mWriteStencil = enable; mStencilWriteValue = stencilWriteValue; }
void SetWriteSubsectorDepth(bool enable) { mWriteSubsector = enable; }
void SetWriteDepth(bool enable) { mWriteDepth = enable; }
void SetFaceCullCCW(bool counterclockwise) { mFaceCullCCW = counterclockwise; }
void SetStyle(TriBlendMode blendmode, double srcalpha = 1.0, double destalpha = 1.0) { mBlendMode = blendmode; mSrcAlpha = (uint32_t)(srcalpha * 256.0 + 0.5); mDestAlpha = (uint32_t)(destalpha * 256.0 + 0.5); }
void SetStyle(const FRenderStyle &renderstyle, double alpha, uint32_t fillcolor, uint32_t translationID, FTexture *texture, bool fullbright);
@ -85,9 +84,8 @@ public:
uint8_t StencilTestValue() const { return mStencilTestValue; }
uint8_t StencilWriteValue() const { return mStencilWriteValue; }
bool SubsectorTest() const { return mSubsectorTest; }
bool WriteSubsector() const { return mWriteSubsector; }
uint32_t SubsectorDepth() const { return mSubsectorDepth; }
bool DepthTest() const { return mDepthTest; }
bool WriteDepth() const { return mWriteDepth; }
TriBlendMode BlendMode() const { return mBlendMode; }
uint32_t Color() const { return mColor; }
@ -117,10 +115,10 @@ private:
int mVertexCount = 0;
PolyDrawMode mDrawMode = PolyDrawMode::Triangles;
bool mFaceCullCCW = false;
bool mSubsectorTest = false;
bool mDepthTest = false;
bool mWriteStencil = true;
bool mWriteColor = true;
bool mWriteSubsector = true;
bool mWriteDepth = true;
const uint8_t *mTexturePixels = nullptr;
int mTextureWidth = 0;
int mTextureHeight = 0;
@ -131,7 +129,6 @@ private:
float mClipPlane[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
TriBlendMode mBlendMode = TriBlendMode::FillOpaque;
uint32_t mLight = 0;
uint32_t mSubsectorDepth = 0;
uint32_t mColor = 0;
uint32_t mSrcAlpha = 0;
uint32_t mDestAlpha = 0;

View file

@ -99,7 +99,7 @@ void PolyTriangleDrawer::draw_arrays(const PolyDrawArgs &drawargs, WorkerThreadD
args.stencilPitch = PolyStencilBuffer::Instance()->BlockWidth();
args.stencilValues = PolyStencilBuffer::Instance()->Values();
args.stencilMasks = PolyStencilBuffer::Instance()->Masks();
args.subsectorGBuffer = PolySubsectorGBuffer::Instance()->Values();
args.zbuffer = PolyZBuffer::Instance()->Values();
bool ccw = drawargs.FaceCullCCW();
const TriVertex *vinput = drawargs.Vertices();

View file

@ -76,10 +76,9 @@ private:
int clipright;
int clipbottom;
// Subsector buffer
uint32_t * RESTRICT subsectorGBuffer;
uint32_t subsectorDepth;
int32_t subsectorPitch;
// Depth buffer
float * RESTRICT zbuffer;
int32_t zbufferPitch;
// Triangle bounding block
int minx, miny;
@ -113,10 +112,10 @@ private:
void CoverageTest();
void StencilEqualTest();
void StencilGreaterEqualTest();
void SubsectorTest();
void DepthTest(const TriDrawTriangleArgs *args);
void ClipTest();
void StencilWrite();
void SubsectorWrite();
void DepthWrite(const TriDrawTriangleArgs *args);
};
TriangleBlock::TriangleBlock(const TriDrawTriangleArgs *args)
@ -134,9 +133,8 @@ TriangleBlock::TriangleBlock(const TriDrawTriangleArgs *args)
stencilTestValue = args->uniforms->StencilTestValue();
stencilWriteValue = args->uniforms->StencilWriteValue();
subsectorGBuffer = args->subsectorGBuffer;
subsectorDepth = args->uniforms->SubsectorDepth();
subsectorPitch = args->stencilPitch;
zbuffer = args->zbuffer;
zbufferPitch = args->stencilPitch;
// 28.4 fixed-point coordinates
#ifdef NO_SSE
@ -235,10 +233,10 @@ void TriangleBlock::Loop(const TriDrawTriangleArgs *args, WorkerThreadData *thre
int core_skip = (num_cores - ((miny / q) - core) % num_cores) % num_cores;
int start_miny = miny + core_skip * q;
bool subsectorTest = args->uniforms->SubsectorTest();
bool depthTest = args->uniforms->DepthTest();
bool writeColor = args->uniforms->WriteColor();
bool writeStencil = args->uniforms->WriteStencil();
bool writeSubsector = args->uniforms->WriteSubsector();
bool writeDepth = args->uniforms->WriteDepth();
int bmode = (int)args->uniforms->BlendMode();
auto drawFunc = args->destBgra ? ScreenTriangle::TriDrawers32[bmode] : ScreenTriangle::TriDrawers8[bmode];
@ -259,8 +257,8 @@ void TriangleBlock::Loop(const TriDrawTriangleArgs *args, WorkerThreadData *thre
if (Mask0 == 0 && Mask1 == 0)
continue;
// To do: make the stencil test use its own flag for comparison mode instead of abusing the subsector test..
if (!subsectorTest)
// To do: make the stencil test use its own flag for comparison mode instead of abusing the depth test..
if (!depthTest)
{
StencilEqualTest();
if (Mask0 == 0 && Mask1 == 0)
@ -272,7 +270,7 @@ void TriangleBlock::Loop(const TriDrawTriangleArgs *args, WorkerThreadData *thre
if (Mask0 == 0 && Mask1 == 0)
continue;
SubsectorTest();
DepthTest(args);
if (Mask0 == 0 && Mask1 == 0)
continue;
}
@ -281,34 +279,54 @@ void TriangleBlock::Loop(const TriDrawTriangleArgs *args, WorkerThreadData *thre
drawFunc(X, Y, Mask0, Mask1, args);
if (writeStencil)
StencilWrite();
if (writeSubsector)
SubsectorWrite();
if (writeDepth)
DepthWrite(args);
}
}
}
#ifdef NO_SSE
void TriangleBlock::SubsectorTest()
void TriangleBlock::DepthTest(const TriDrawTriangleArgs *args)
{
int block = (X >> 3) + (Y >> 3) * subsectorPitch;
uint32_t *subsector = subsectorGBuffer + block * 64;
int block = (X >> 3) + (Y >> 3) * zbufferPitch;
float *depth = zbuffer + block * 64;
const TriVertex &v1 = *args->v1;
float stepXW = args->gradientX.W;
float stepYW = args->gradientY.W;
float posYW = v1.w + stepXW * (X - v1.x) + stepYW * (Y - v1.y);
uint32_t mask0 = 0;
uint32_t mask1 = 0;
for (int i = 0; i < 32; i++)
for (int iy = 0; iy < 4; iy++)
{
bool covered = *subsector >= subsectorDepth;
mask0 <<= 1;
mask0 |= (uint32_t)covered;
subsector++;
float posXW = posYW;
for (int ix = 0; ix < 8; ix++)
{
bool covered = *depth <= posXW;
mask0 <<= 1;
mask0 |= (uint32_t)covered;
depth++;
posXW += stepXW;
}
posYW += stepYW;
}
for (int i = 0; i < 32; i++)
for (int iy = 0; iy < 4; iy++)
{
bool covered = *subsector >= subsectorDepth;
mask1 <<= 1;
mask1 |= (uint32_t)covered;
subsector++;
float posXW = posYW;
for (int ix = 0; ix < 8; ix++)
{
bool covered = *depth <= posXW;
mask1 <<= 1;
mask1 |= (uint32_t)covered;
depth++;
posXW += stepXW;
}
posYW += stepYW;
}
Mask0 = Mask0 & mask0;
@ -317,26 +335,50 @@ void TriangleBlock::SubsectorTest()
#else
void TriangleBlock::SubsectorTest()
void TriangleBlock::DepthTest(const TriDrawTriangleArgs *args)
{
int block = (X >> 3) + (Y >> 3) * subsectorPitch;
uint32_t *subsector = subsectorGBuffer + block * 64;
int block = (X >> 3) + (Y >> 3) * zbufferPitch;
float *depth = zbuffer + block * 64;
const TriVertex &v1 = *args->v1;
float stepXW = args->gradientX.W;
float stepYW = args->gradientY.W;
float posYW = v1.w + stepXW * (X - v1.x) + stepYW * (Y - v1.y);
__m128 mposYW = _mm_setr_ps(posYW, posYW + stepXW, posYW + stepXW + stepXW, posYW + stepXW + stepXW + stepXW);
__m128 mstepXW = _mm_set1_ps(stepXW * 4.0f);
__m128 mstepYW = _mm_set1_ps(stepYW);
uint32_t mask0 = 0;
uint32_t mask1 = 0;
__m128i msubsectorDepth = _mm_set1_epi32(subsectorDepth);
__m128i mnotxor = _mm_set1_epi32(0xffffffff);
for (int iy = 0; iy < 8; iy++)
for (int iy = 0; iy < 4; iy++)
{
mask0 <<= 4;
mask0 |= _mm_movemask_ps(_mm_castsi128_ps(_mm_shuffle_epi32(_mm_xor_si128(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)subsector), msubsectorDepth), mnotxor), _MM_SHUFFLE(0, 1, 2, 3))));
subsector += 4;
__m128 mposXW = mposYW;
for (int ix = 0; ix < 2; ix++)
{
__m128 covered = _mm_cmplt_ps(_mm_loadu_ps(depth), mposXW);
mask0 <<= 4;
mask0 |= _mm_movemask_ps(_mm_shuffle_ps(covered, covered, _MM_SHUFFLE(0, 1, 2, 3)));
depth += 4;
mposXW = _mm_add_ps(mposXW, mstepXW);
}
mposYW = _mm_add_ps(mposYW, mstepYW);
}
for (int iy = 0; iy < 8; iy++)
for (int iy = 0; iy < 4; iy++)
{
mask1 <<= 4;
mask1 |= _mm_movemask_ps(_mm_castsi128_ps(_mm_shuffle_epi32(_mm_xor_si128(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)subsector), msubsectorDepth), mnotxor), _MM_SHUFFLE(0, 1, 2, 3))));
subsector += 4;
__m128 mposXW = mposYW;
for (int ix = 0; ix < 2; ix++)
{
__m128 covered = _mm_cmplt_ps(_mm_loadu_ps(depth), mposXW);
mask1 <<= 4;
mask1 |= _mm_movemask_ps(_mm_shuffle_ps(covered, covered, _MM_SHUFFLE(0, 1, 2, 3)));
depth += 4;
mposXW = _mm_add_ps(mposXW, mstepXW);
}
mposYW = _mm_add_ps(mposYW, mstepYW);
}
Mask0 = Mask0 & mask0;
@ -798,65 +840,91 @@ void TriangleBlock::StencilWrite()
#ifdef NO_SSE
void TriangleBlock::SubsectorWrite()
void TriangleBlock::DepthWrite(const TriDrawTriangleArgs *args)
{
int block = (X >> 3) + (Y >> 3) * subsectorPitch;
uint32_t *subsector = subsectorGBuffer + block * 64;
int block = (X >> 3) + (Y >> 3) * zbufferPitch;
float *depth = zbuffer + block * 64;
const TriVertex &v1 = *args->v1;
float stepXW = args->gradientX.W;
float stepYW = args->gradientY.W;
float posYW = v1.w + stepXW * (X - v1.x) + stepYW * (Y - v1.y);
if (Mask0 == 0xffffffff && Mask1 == 0xffffffff)
{
for (int i = 0; i < 64; i++)
for (int iy = 0; iy < 8; iy++)
{
*(subsector++) = subsectorDepth;
float posXW = posYW;
for (int ix = 0; ix < 8; ix++)
{
*(depth++) = posXW;
posXW += stepXW;
}
posYW += stepYW;
}
}
else
{
uint32_t mask0 = Mask0;
uint32_t mask1 = Mask1;
for (int i = 0; i < 32; i++)
for (int iy = 0; iy < 4; iy++)
{
if (mask0 & (1 << 31))
*subsector = subsectorDepth;
mask0 <<= 1;
subsector++;
float posXW = posYW;
for (int ix = 0; ix < 8; ix++)
{
if (mask0 & (1 << 31))
*depth = posXW;
posXW += stepXW;
mask0 <<= 1;
depth++;
}
posYW += stepYW;
}
for (int i = 0; i < 32; i++)
for (int iy = 0; iy < 4; iy++)
{
if (mask1 & (1 << 31))
*subsector = subsectorDepth;
mask1 <<= 1;
subsector++;
float posXW = posYW;
for (int ix = 0; ix < 8; ix++)
{
if (mask1 & (1 << 31))
*depth = posXW;
posXW += stepXW;
mask1 <<= 1;
depth++;
}
posYW += stepYW;
}
}
}
#else
void TriangleBlock::SubsectorWrite()
void TriangleBlock::DepthWrite(const TriDrawTriangleArgs *args)
{
int block = (X >> 3) + (Y >> 3) * subsectorPitch;
uint32_t *subsector = subsectorGBuffer + block * 64;
__m128i msubsectorDepth = _mm_set1_epi32(subsectorDepth);
int block = (X >> 3) + (Y >> 3) * zbufferPitch;
float *depth = zbuffer + block * 64;
const TriVertex &v1 = *args->v1;
float stepXW = args->gradientX.W;
float stepYW = args->gradientY.W;
float posYW = v1.w + stepXW * (X - v1.x) + stepYW * (Y - v1.y);
__m128 mposYW = _mm_setr_ps(posYW, posYW + stepXW, posYW + stepXW + stepXW, posYW + stepXW + stepXW + stepXW);
__m128 mstepXW = _mm_set1_ps(stepXW * 4.0f);
__m128 mstepYW = _mm_set1_ps(stepYW);
if (Mask0 == 0xffffffff && Mask1 == 0xffffffff)
{
_mm_storeu_si128((__m128i*)subsector, msubsectorDepth); subsector += 4;
_mm_storeu_si128((__m128i*)subsector, msubsectorDepth); subsector += 4;
_mm_storeu_si128((__m128i*)subsector, msubsectorDepth); subsector += 4;
_mm_storeu_si128((__m128i*)subsector, msubsectorDepth); subsector += 4;
_mm_storeu_si128((__m128i*)subsector, msubsectorDepth); subsector += 4;
_mm_storeu_si128((__m128i*)subsector, msubsectorDepth); subsector += 4;
_mm_storeu_si128((__m128i*)subsector, msubsectorDepth); subsector += 4;
_mm_storeu_si128((__m128i*)subsector, msubsectorDepth); subsector += 4;
_mm_storeu_si128((__m128i*)subsector, msubsectorDepth); subsector += 4;
_mm_storeu_si128((__m128i*)subsector, msubsectorDepth); subsector += 4;
_mm_storeu_si128((__m128i*)subsector, msubsectorDepth); subsector += 4;
_mm_storeu_si128((__m128i*)subsector, msubsectorDepth); subsector += 4;
_mm_storeu_si128((__m128i*)subsector, msubsectorDepth); subsector += 4;
_mm_storeu_si128((__m128i*)subsector, msubsectorDepth); subsector += 4;
_mm_storeu_si128((__m128i*)subsector, msubsectorDepth); subsector += 4;
_mm_storeu_si128((__m128i*)subsector, msubsectorDepth);
for (int iy = 0; iy < 8; iy++)
{
__m128 mposXW = mposYW;
_mm_storeu_ps(depth, mposXW); depth += 4; mposXW = _mm_add_ps(mposXW, mstepXW);
_mm_storeu_ps(depth, mposXW); depth += 4;
mposYW = _mm_add_ps(mposYW, mstepYW);
}
}
else
{
@ -866,23 +934,21 @@ void TriangleBlock::SubsectorWrite()
__m128i mmask0 = _mm_set1_epi32(Mask0);
__m128i mmask1 = _mm_set1_epi32(Mask1);
_mm_maskmoveu_si128(msubsectorDepth, _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask0, topfour), _mm_setzero_si128()), mxormask), (char*)subsector); mmask0 = _mm_slli_epi32(mmask0, 4); subsector += 4;
_mm_maskmoveu_si128(msubsectorDepth, _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask0, topfour), _mm_setzero_si128()), mxormask), (char*)subsector); mmask0 = _mm_slli_epi32(mmask0, 4); subsector += 4;
_mm_maskmoveu_si128(msubsectorDepth, _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask0, topfour), _mm_setzero_si128()), mxormask), (char*)subsector); mmask0 = _mm_slli_epi32(mmask0, 4); subsector += 4;
_mm_maskmoveu_si128(msubsectorDepth, _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask0, topfour), _mm_setzero_si128()), mxormask), (char*)subsector); mmask0 = _mm_slli_epi32(mmask0, 4); subsector += 4;
_mm_maskmoveu_si128(msubsectorDepth, _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask0, topfour), _mm_setzero_si128()), mxormask), (char*)subsector); mmask0 = _mm_slli_epi32(mmask0, 4); subsector += 4;
_mm_maskmoveu_si128(msubsectorDepth, _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask0, topfour), _mm_setzero_si128()), mxormask), (char*)subsector); mmask0 = _mm_slli_epi32(mmask0, 4); subsector += 4;
_mm_maskmoveu_si128(msubsectorDepth, _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask0, topfour), _mm_setzero_si128()), mxormask), (char*)subsector); mmask0 = _mm_slli_epi32(mmask0, 4); subsector += 4;
_mm_maskmoveu_si128(msubsectorDepth, _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask0, topfour), _mm_setzero_si128()), mxormask), (char*)subsector); subsector += 4;
for (int iy = 0; iy < 4; iy++)
{
__m128 mposXW = mposYW;
_mm_maskmoveu_si128(_mm_castps_si128(mposXW), _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask0, topfour), _mm_setzero_si128()), mxormask), (char*)depth); mmask0 = _mm_slli_epi32(mmask0, 4); depth += 4; mposXW = _mm_add_ps(mposXW, mstepXW);
_mm_maskmoveu_si128(_mm_castps_si128(mposXW), _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask0, topfour), _mm_setzero_si128()), mxormask), (char*)depth); mmask0 = _mm_slli_epi32(mmask0, 4); depth += 4;
mposYW = _mm_add_ps(mposYW, mstepYW);
}
_mm_maskmoveu_si128(msubsectorDepth, _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask1, topfour), _mm_setzero_si128()), mxormask), (char*)subsector); mmask1 = _mm_slli_epi32(mmask1, 4); subsector += 4;
_mm_maskmoveu_si128(msubsectorDepth, _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask1, topfour), _mm_setzero_si128()), mxormask), (char*)subsector); mmask1 = _mm_slli_epi32(mmask1, 4); subsector += 4;
_mm_maskmoveu_si128(msubsectorDepth, _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask1, topfour), _mm_setzero_si128()), mxormask), (char*)subsector); mmask1 = _mm_slli_epi32(mmask1, 4); subsector += 4;
_mm_maskmoveu_si128(msubsectorDepth, _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask1, topfour), _mm_setzero_si128()), mxormask), (char*)subsector); mmask1 = _mm_slli_epi32(mmask1, 4); subsector += 4;
_mm_maskmoveu_si128(msubsectorDepth, _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask1, topfour), _mm_setzero_si128()), mxormask), (char*)subsector); mmask1 = _mm_slli_epi32(mmask1, 4); subsector += 4;
_mm_maskmoveu_si128(msubsectorDepth, _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask1, topfour), _mm_setzero_si128()), mxormask), (char*)subsector); mmask1 = _mm_slli_epi32(mmask1, 4); subsector += 4;
_mm_maskmoveu_si128(msubsectorDepth, _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask1, topfour), _mm_setzero_si128()), mxormask), (char*)subsector); mmask1 = _mm_slli_epi32(mmask1, 4); subsector += 4;
_mm_maskmoveu_si128(msubsectorDepth, _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask1, topfour), _mm_setzero_si128()), mxormask), (char*)subsector); subsector += 4;
for (int iy = 0; iy < 4; iy++)
{
__m128 mposXW = mposYW;
_mm_maskmoveu_si128(_mm_castps_si128(mposXW), _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask1, topfour), _mm_setzero_si128()), mxormask), (char*)depth); mmask1 = _mm_slli_epi32(mmask1, 4); depth += 4; mposXW = _mm_add_ps(mposXW, mstepXW);
_mm_maskmoveu_si128(_mm_castps_si128(mposXW), _mm_xor_si128(_mm_cmpeq_epi32(_mm_and_si128(mmask1, topfour), _mm_setzero_si128()), mxormask), (char*)depth); mmask1 = _mm_slli_epi32(mmask1, 4); depth += 4;
mposYW = _mm_add_ps(mposYW, mstepYW);
}
}
}

View file

@ -60,7 +60,7 @@ struct TriDrawTriangleArgs
uint8_t *stencilValues;
uint32_t *stencilMasks;
int32_t stencilPitch;
uint32_t *subsectorGBuffer;
float *zbuffer;
const PolyDrawArgs *uniforms;
bool destBgra;
ScreenTriangleStepVariables gradientX;

View file

@ -159,7 +159,7 @@ void PolyRenderer::ClearBuffers()
{
FrameMemory.Clear();
PolyStencilBuffer::Instance()->Clear(RenderTarget->GetWidth(), RenderTarget->GetHeight(), 0);
PolySubsectorGBuffer::Instance()->Resize(RenderTarget->GetPitch(), RenderTarget->GetHeight());
PolyZBuffer::Instance()->Resize(RenderTarget->GetPitch(), RenderTarget->GetHeight());
NextStencilValue = 0;
}

View file

@ -31,7 +31,7 @@
#include "a_sharedglobal.h"
#include "swrenderer/scene/r_scene.h"
void RenderPolyDecal::RenderWallDecals(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, const seg_t *line, uint32_t subsectorDepth, uint32_t stencilValue)
void RenderPolyDecal::RenderWallDecals(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, const seg_t *line, uint32_t stencilValue)
{
if (line->linedef == nullptr && line->sidedef == nullptr)
return;
@ -39,11 +39,11 @@ void RenderPolyDecal::RenderWallDecals(const TriMatrix &worldToClip, const PolyC
for (DBaseDecal *decal = line->sidedef->AttachedDecals; decal != nullptr; decal = decal->WallNext)
{
RenderPolyDecal render;
render.Render(worldToClip, clipPlane, decal, line, subsectorDepth, stencilValue);
render.Render(worldToClip, clipPlane, decal, line, stencilValue);
}
}
void RenderPolyDecal::Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, DBaseDecal *decal, const seg_t *line, uint32_t subsectorDepth, uint32_t stencilValue)
void RenderPolyDecal::Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, DBaseDecal *decal, const seg_t *line, uint32_t stencilValue)
{
if (decal->RenderFlags & RF_INVISIBLE || !viewactive || !decal->PicNum.isValid())
return;
@ -62,6 +62,10 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, const PolyClipPlane &
DVector2 decal_pos = { dcx, dcy };
DVector2 angvec = (line->v2->fPos() - line->v1->fPos()).Unit();
DVector2 normal = { angvec.Y, -angvec.X };
decal_pos += normal;
DVector2 decal_left = decal_pos - edge_left * angvec;
DVector2 decal_right = decal_pos + edge_right * angvec;
@ -139,7 +143,6 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, const PolyClipPlane &
PolyDrawArgs args;
args.SetLight(GetColorTable(front->Colormap), lightlevel, PolyRenderer::Instance()->Light.WallGlobVis(foggy), fullbrightSprite);
args.SetSubsectorDepth(subsectorDepth);
args.SetColor(0xff000000 | decal->AlphaColor, decal->AlphaColor >> 24);
args.SetStyle(decal->RenderStyle, decal->Alpha, decal->AlphaColor, decal->Translation, tex, false);
args.SetTransform(&worldToClip);
@ -147,8 +150,8 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, const PolyClipPlane &
args.SetStencilTestValue(stencilValue);
args.SetWriteStencil(true, stencilValue);
args.SetClipPlane(clipPlane);
args.SetSubsectorDepthTest(true);
args.SetDepthTest(true);
args.SetWriteStencil(false);
args.SetWriteSubsectorDepth(false);
args.SetWriteDepth(false);
args.DrawArray(vertices, 4, PolyDrawMode::TriangleFan);
}

View file

@ -27,8 +27,8 @@
class RenderPolyDecal
{
public:
static void RenderWallDecals(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, const seg_t *line, uint32_t subsectorDepth, uint32_t stencilValue);
static void RenderWallDecals(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, const seg_t *line, uint32_t stencilValue);
private:
void Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, DBaseDecal *decal, const seg_t *line, uint32_t subsectorDepth, uint32_t stencilValue);
void Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, DBaseDecal *decal, const seg_t *line, uint32_t stencilValue);
};

View file

@ -31,7 +31,7 @@
EXTERN_CVAR(Int, gl_particles_style)
void RenderPolyParticle::Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, particle_t *particle, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue)
void RenderPolyParticle::Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, particle_t *particle, subsector_t *sub, uint32_t stencilValue)
{
DVector3 pos = particle->Pos;
double psize = particle->size / 8.0;
@ -75,15 +75,14 @@ void RenderPolyParticle::Render(const TriMatrix &worldToClip, const PolyClipPlan
PolyDrawArgs args;
args.SetLight(GetColorTable(sub->sector->Colormap), lightlevel, PolyRenderer::Instance()->Light.ParticleGlobVis(foggy), fullbrightSprite);
args.SetSubsectorDepth(subsectorDepth);
args.SetSubsectorDepthTest(true);
args.SetDepthTest(true);
args.SetColor(particle->color | 0xff000000, particle->color >> 24);
args.SetStyle(TriBlendMode::Shaded, particle->alpha, 1.0 - particle->alpha);
args.SetTransform(&worldToClip);
args.SetFaceCullCCW(true);
args.SetStencilTestValue(stencilValue);
args.SetWriteStencil(false);
args.SetWriteSubsectorDepth(false);
args.SetWriteDepth(false);
args.SetClipPlane(clipPlane);
args.SetTexture(GetParticleTexture(), ParticleTextureSize, ParticleTextureSize);
args.DrawArray(vertices, 4, PolyDrawMode::TriangleFan);

View file

@ -28,7 +28,7 @@
class RenderPolyParticle
{
public:
void Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, particle_t *particle, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue);
void Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, particle_t *particle, subsector_t *sub, uint32_t stencilValue);
private:
static uint8_t *GetParticleTexture();

View file

@ -33,7 +33,7 @@
EXTERN_CVAR(Int, r_3dfloors)
void RenderPolyPlane::RenderPlanes(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t ceilingSubsectorDepth, uint32_t floorSubsectorDepth, uint32_t stencilValue, double skyCeilingHeight, double skyFloorHeight, std::vector<std::unique_ptr<PolyDrawSectorPortal>> &sectorPortals)
void RenderPolyPlane::RenderPlanes(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t stencilValue, double skyCeilingHeight, double skyFloorHeight, std::vector<std::unique_ptr<PolyDrawSectorPortal>> &sectorPortals)
{
RenderPolyPlane plane;
@ -61,7 +61,7 @@ void RenderPolyPlane::RenderPlanes(const TriMatrix &worldToClip, const PolyClipP
double fakeHeight = fakeFloor->top.plane->ZatPoint(frontsector->centerspot);
if (fakeHeight < viewpoint.Pos.Z && fakeHeight > frontsector->floorplane.ZatPoint(frontsector->centerspot))
{
plane.Render3DFloor(worldToClip, clipPlane, sub, floorSubsectorDepth, stencilValue, false, fakeFloor);
plane.Render3DFloor(worldToClip, clipPlane, sub, stencilValue, false, fakeFloor);
}
}
@ -82,16 +82,16 @@ void RenderPolyPlane::RenderPlanes(const TriMatrix &worldToClip, const PolyClipP
double fakeHeight = fakeFloor->bottom.plane->ZatPoint(frontsector->centerspot);
if (fakeHeight > viewpoint.Pos.Z && fakeHeight < frontsector->ceilingplane.ZatPoint(frontsector->centerspot))
{
plane.Render3DFloor(worldToClip, clipPlane, sub, ceilingSubsectorDepth, stencilValue, true, fakeFloor);
plane.Render3DFloor(worldToClip, clipPlane, sub, stencilValue, true, fakeFloor);
}
}
}
plane.Render(worldToClip, clipPlane, cull, sub, ceilingSubsectorDepth, stencilValue, true, skyCeilingHeight, sectorPortals);
plane.Render(worldToClip, clipPlane, cull, sub, floorSubsectorDepth, stencilValue, false, skyFloorHeight, sectorPortals);
plane.Render(worldToClip, clipPlane, cull, sub, stencilValue, true, skyCeilingHeight, sectorPortals);
plane.Render(worldToClip, clipPlane, cull, sub, stencilValue, false, skyFloorHeight, sectorPortals);
}
void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, F3DFloor *fakeFloor)
void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, subsector_t *sub, uint32_t stencilValue, bool ceiling, F3DFloor *fakeFloor)
{
FTextureID picnum = ceiling ? *fakeFloor->bottom.texture : *fakeFloor->top.texture;
FTexture *tex = TexMan(picnum);
@ -131,7 +131,6 @@ void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, const PolyClip
PolyDrawArgs args;
args.SetLight(GetColorTable(sub->sector->Colormap), lightlevel, PolyRenderer::Instance()->Light.WallGlobVis(foggy), false);
args.SetSubsectorDepth(subsectorDepth);
args.SetTransform(&worldToClip);
args.SetStyle(TriBlendMode::TextureOpaque);
args.SetFaceCullCCW(true);
@ -142,7 +141,7 @@ void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, const PolyClip
args.DrawArray(vertices, sub->numlines, PolyDrawMode::TriangleFan);
}
void RenderPolyPlane::Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, double skyHeight, std::vector<std::unique_ptr<PolyDrawSectorPortal>> &sectorPortals)
void RenderPolyPlane::Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t stencilValue, bool ceiling, double skyHeight, std::vector<std::unique_ptr<PolyDrawSectorPortal>> &sectorPortals)
{
const auto &viewpoint = PolyRenderer::Instance()->Viewpoint;
bool foggy = false;
@ -302,7 +301,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, const PolyClipPlane &
PolyDrawArgs args;
args.SetLight(GetColorTable(frontsector->Colormap, frontsector->SpecialColors[ceiling]), frontsector->lightlevel, PolyRenderer::Instance()->Light.WallGlobVis(foggy), false);
args.SetSubsectorDepth(isSky ? RenderPolyScene::SkySubsectorDepth : subsectorDepth);
//args.SetSubsectorDepth(isSky ? RenderPolyScene::SkySubsectorDepth : subsectorDepth);
args.SetTransform(&worldToClip);
args.SetFaceCullCCW(ccw);
args.SetStencilTestValue(stencilValue);
@ -320,7 +319,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, const PolyClipPlane &
if (portal)
{
args.SetWriteStencil(true, polyportal->StencilValue);
polyportal->Shape.push_back({ vertices, (int)sub->numlines, ccw, subsectorDepth });
polyportal->Shape.push_back({ vertices, (int)sub->numlines, ccw });
}
else
{
@ -328,7 +327,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, const PolyClipPlane &
}
args.SetWriteColor(false);
args.SetWriteSubsectorDepth(false);
args.SetWriteDepth(false);
args.DrawArray(vertices, sub->numlines, PolyDrawMode::TriangleFan);
for (uint32_t i = 0; i < sub->numlines; i++)
@ -397,7 +396,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, const PolyClipPlane &
if (portal)
{
polyportal->Shape.push_back({ wallvert, 4, ccw, subsectorDepth });
polyportal->Shape.push_back({ wallvert, 4, ccw });
}
}
}

View file

@ -30,7 +30,7 @@ class PolyCull;
class RenderPolyPlane
{
public:
static void RenderPlanes(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t ceilingSubsectorDepth, uint32_t floorSubsectorDepth, uint32_t stencilValue, double skyCeilingHeight, double skyFloorHeight, std::vector<std::unique_ptr<PolyDrawSectorPortal>> &sectorPortals);
static void RenderPlanes(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t stencilValue, double skyCeilingHeight, double skyFloorHeight, std::vector<std::unique_ptr<PolyDrawSectorPortal>> &sectorPortals);
private:
struct UVTransform
@ -47,7 +47,7 @@ private:
float xOffs, yOffs;
};
void Render3DFloor(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, F3DFloor *fakefloor);
void Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, bool ceiling, double skyHeight, std::vector<std::unique_ptr<PolyDrawSectorPortal>> &sectorPortals);
void Render3DFloor(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, subsector_t *sub, uint32_t stencilValue, bool ceiling, F3DFloor *fakefloor);
void Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, PolyCull &cull, subsector_t *sub, uint32_t stencilValue, bool ceiling, double skyHeight, std::vector<std::unique_ptr<PolyDrawSectorPortal>> &sectorPortals);
TriVertex PlaneVertex(vertex_t *v1, double height, const UVTransform &transform);
};

View file

@ -26,11 +26,10 @@
struct PolyPortalVertexRange
{
PolyPortalVertexRange(const TriVertex *vertices, int count, bool ccw, uint32_t subsectorDepth) : Vertices(vertices), Count(count), Ccw(ccw), SubsectorDepth(subsectorDepth) { }
PolyPortalVertexRange(const TriVertex *vertices, int count, bool ccw) : Vertices(vertices), Count(count), Ccw(ccw) { }
const TriVertex *Vertices;
int Count;
bool Ccw;
uint32_t SubsectorDepth;
};
class PolyPortalSegment

View file

@ -179,7 +179,7 @@ void RenderPolyScene::RenderSubsector(subsector_t *sub, uint32_t ceilingSubsecto
if (sub->sector->CenterFloor() != sub->sector->CenterCeiling())
{
RenderPolyPlane::RenderPlanes(WorldToClip, PortalPlane, Cull, sub, ceilingSubsectorDepth, floorSubsectorDepth, StencilValue, Cull.MaxCeilingHeight, Cull.MinFloorHeight, SectorPortals);
RenderPolyPlane::RenderPlanes(WorldToClip, PortalPlane, Cull, sub, StencilValue, Cull.MaxCeilingHeight, Cull.MinFloorHeight, SectorPortals);
}
if (mainBSP)
@ -384,7 +384,6 @@ void RenderPolyScene::RenderPortals(int portalDepth)
for (const auto &verts : portal->Shape)
{
args.SetFaceCullCCW(verts.Ccw);
args.SetSubsectorDepth(verts.SubsectorDepth);
args.DrawArray(verts.Vertices, verts.Count, PolyDrawMode::TriangleFan);
}
}
@ -396,7 +395,6 @@ void RenderPolyScene::RenderPortals(int portalDepth)
for (const auto &verts : portal->Shape)
{
args.SetFaceCullCCW(verts.Ccw);
args.SetSubsectorDepth(verts.SubsectorDepth);
args.DrawArray(verts.Vertices, verts.Count, PolyDrawMode::TriangleFan);
}
}
@ -420,7 +418,6 @@ void RenderPolyScene::RenderTranslucent(int portalDepth)
for (const auto &verts : portal->Shape)
{
args.SetFaceCullCCW(verts.Ccw);
args.SetSubsectorDepth(verts.SubsectorDepth);
args.SetWriteColor(false);
args.DrawArray(verts.Vertices, verts.Count, PolyDrawMode::TriangleFan);
}
@ -439,7 +436,6 @@ void RenderPolyScene::RenderTranslucent(int portalDepth)
for (const auto &verts : portal->Shape)
{
args.SetFaceCullCCW(verts.Ccw);
args.SetSubsectorDepth(verts.SubsectorDepth);
args.SetWriteColor(false);
args.DrawArray(verts.Vertices, verts.Count, PolyDrawMode::TriangleFan);
}
@ -467,7 +463,7 @@ void RenderPolyScene::RenderTranslucent(int portalDepth)
if (obj->particle)
{
RenderPolyParticle spr;
spr.Render(WorldToClip, PortalPlane, obj->particle, obj->sub, obj->subsectorDepth, StencilValue + 1);
spr.Render(WorldToClip, PortalPlane, obj->particle, obj->sub, StencilValue + 1);
}
else if (!obj->thing)
{
@ -476,12 +472,12 @@ void RenderPolyScene::RenderTranslucent(int portalDepth)
else if ((obj->thing->renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE)
{
RenderPolyWallSprite wallspr;
wallspr.Render(WorldToClip, PortalPlane, obj->thing, obj->sub, obj->subsectorDepth, StencilValue + 1);
wallspr.Render(WorldToClip, PortalPlane, obj->thing, obj->sub, StencilValue + 1);
}
else
{
RenderPolySprite spr;
spr.Render(WorldToClip, PortalPlane, obj->thing, obj->sub, obj->subsectorDepth, StencilValue + 1, obj->SpriteLeft, obj->SpriteRight);
spr.Render(WorldToClip, PortalPlane, obj->thing, obj->sub, StencilValue + 1, obj->SpriteLeft, obj->SpriteRight);
}
}
}

View file

@ -83,7 +83,6 @@ void PolySkyDome::Render(const TriMatrix &worldToClip)
PolyDrawArgs args;
args.SetLight(&NormalLight, 255, PolyRenderer::Instance()->Light.WallGlobVis(false), true);
args.SetSubsectorDepth(RenderPolyScene::SkySubsectorDepth);
args.SetTransform(&objectToClip);
args.SetStencilTestValue(255);
args.SetWriteStencil(true, 1);

View file

@ -29,10 +29,14 @@
#include "polyrenderer/poly_renderer.h"
#include "polyrenderer/scene/poly_light.h"
#include "r_data/r_vanillatrans.h"
#include "actorinlines.h"
EXTERN_CVAR(Float, transsouls)
EXTERN_CVAR(Int, r_drawfuzz)
EXTERN_CVAR (Bool, r_debug_disable_vis_filter)
EXTERN_CVAR(Int, gl_spriteclip)
EXTERN_CVAR(Float, gl_sclipthreshold)
EXTERN_CVAR(Float, gl_sclipfactor)
extern uint32_t r_renderercaps;
bool RenderPolySprite::GetLine(AActor *thing, DVector2 &left, DVector2 &right)
@ -67,15 +71,24 @@ bool RenderPolySprite::GetLine(AActor *thing, DVector2 &left, DVector2 &right)
return true;
}
void RenderPolySprite::Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, float t1, float t2)
void RenderPolySprite::Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, AActor *thing, subsector_t *sub, uint32_t stencilValue, float t1, float t2)
{
DVector2 line[2];
if (!GetLine(thing, line[0], line[1]))
return;
const auto &viewpoint = PolyRenderer::Instance()->Viewpoint;
DVector3 pos = thing->InterpolatedPosition(viewpoint.TicFrac);
pos.Z += thing->GetBobOffset(viewpoint.TicFrac);
DVector3 thingpos = thing->InterpolatedPosition(viewpoint.TicFrac);
DVector3 pos = thingpos;
uint32_t spritetype = (thing->renderflags & RF_SPRITETYPEMASK);
if (spritetype == RF_FACESPRITE)
pos.Z -= thing->Floorclip;
if (thing->flags2 & MF2_FLOATBOB)
pos.Z += thing->GetBobOffset(viewpoint.TicFrac);
bool flipTextureX = false;
FTexture *tex = GetSpriteTexture(thing, flipTextureX);
@ -85,20 +98,19 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const PolyClipPlane
DVector2 spriteScale = thing->Scale;
double thingxscalemul = spriteScale.X / tex->Scale.X;
double thingyscalemul = spriteScale.Y / tex->Scale.Y;
double spriteHalfWidth = thingxscalemul * tex->GetWidth() * 0.5;
double spriteHeight = thingyscalemul * tex->GetHeight();
if (flipTextureX)
pos.X -= (tex->GetWidth() - tex->LeftOffset) * thingxscalemul;
else
pos.X -= tex->LeftOffset * thingxscalemul;
//pos.Z -= tex->TopOffset * thingyscalemul;
pos.Z -= (tex->GetHeight() - tex->TopOffset) * thingyscalemul + thing->Floorclip;
double spriteHalfWidth = thingxscalemul * tex->GetWidth() * 0.5;
double spriteHeight = thingyscalemul * tex->GetHeight();
pos.X += spriteHalfWidth;
pos.Z -= (tex->GetHeight() - tex->TopOffset) * thingyscalemul;
pos.Z = PerformSpriteClipAdjustment(thing, thingpos, spriteHeight, pos.Z);
//double depth = 1.0;
//visstyle_t visstyle = GetSpriteVisStyle(thing, depth);
// Rumor has it that AlterWeaponSprite needs to be called with visstyle passed in somewhere around here..
@ -142,7 +154,6 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const PolyClipPlane
PolyDrawArgs args;
args.SetLight(GetColorTable(sub->sector->Colormap, sub->sector->SpecialColors[sector_t::sprites], true), lightlevel, PolyRenderer::Instance()->Light.SpriteGlobVis(foggy), fullbrightSprite);
args.SetSubsectorDepth(subsectorDepth);
args.SetTransform(&worldToClip);
args.SetFaceCullCCW(true);
args.SetStencilTestValue(stencilValue);
@ -152,12 +163,115 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const PolyClipPlane
args.SetStyle(LegacyRenderStyles[STYLE_Normal], 1.0f, thing->fillcolor, thing->Translation, tex, fullbrightSprite);
else
args.SetStyle(thing->RenderStyle, thing->Alpha, thing->fillcolor, thing->Translation, tex, fullbrightSprite);
args.SetSubsectorDepthTest(true);
args.SetWriteSubsectorDepth(false);
args.SetDepthTest(true);
args.SetWriteDepth(false);
args.SetWriteStencil(false);
args.DrawArray(vertices, 4, PolyDrawMode::TriangleFan);
}
double RenderPolySprite::GetSpriteFloorZ(AActor *thing, const DVector2 &thingpos)
{
extsector_t::xfloor &x = thing->Sector->e->XFloor;
for (unsigned int i = 0; i < x.ffloors.Size(); i++)
{
F3DFloor *ff = x.ffloors[i];
double floorh = ff->top.plane->ZatPoint(thingpos);
if (floorh == thing->floorz)
return floorh;
}
if (thing->Sector->heightsec && !(thing->Sector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC))
{
if (thing->flags2&MF2_ONMOBJ && thing->floorz == thing->Sector->heightsec->floorplane.ZatPoint(thingpos))
{
return thing->floorz;
}
}
return thing->Sector->floorplane.ZatPoint(thing) - thing->Floorclip;
}
double RenderPolySprite::GetSpriteCeilingZ(AActor *thing, const DVector2 &thingpos)
{
extsector_t::xfloor &x = thing->Sector->e->XFloor;
for (unsigned int i = 0; i < x.ffloors.Size(); i++)
{
F3DFloor *ff = x.ffloors[i];
double ceilingh = ff->bottom.plane->ZatPoint(thingpos);
if (ceilingh == thing->ceilingz)
return ceilingh;
}
if (thing->Sector->heightsec && !(thing->Sector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC))
{
if (thing->flags2&MF2_ONMOBJ && thing->ceilingz == thing->Sector->heightsec->ceilingplane.ZatPoint(thingpos))
{
return thing->ceilingz;
}
}
return thing->Sector->ceilingplane.ZatPoint(thingpos);
}
double RenderPolySprite::PerformSpriteClipAdjustment(AActor *thing, const DVector2 &thingpos, double spriteheight, double z2)
{
int spriteclip = 2; // gl_spriteclip, but use 'always' mode for now
double z1 = z2 + spriteheight;
// Tests show that this doesn't look good for many decorations and corpses
uint32_t spritetype = (thing->renderflags & RF_SPRITETYPEMASK);
if (!(spriteheight > 0 && spriteclip > 0 && spritetype == RF_FACESPRITE))
return z2;
bool clipthing = (thing->player || thing->flags3&MF3_ISMONSTER || thing->IsKindOf(RUNTIME_CLASS(AInventory))) && (thing->flags&MF_ICECORPSE || !(thing->flags&MF_CORPSE));
bool smarterclip = !clipthing && spriteclip == 3;
if (clipthing || spriteclip > 1)
{
double diffb = MIN(z2 - GetSpriteFloorZ(thing, thingpos), 0.0);
// Adjust sprites clipping into ceiling and adjust clipping adjustment for tall graphics
if (smarterclip)
{
// Reduce slightly clipping adjustment of corpses
if (thing->flags & MF_CORPSE || spriteheight > fabs(diffb))
{
double ratio = clamp<double>((fabs(diffb) * (double)gl_sclipfactor / (spriteheight + 1)), 0.5, 1.0);
diffb *= ratio;
}
if (!diffb)
{
double difft = MAX(z1 - GetSpriteCeilingZ(thing, thingpos), 0.0);
if (difft >= (double)gl_sclipthreshold)
{
// dumb copy of the above.
if (!(thing->flags3&MF3_ISMONSTER) || (thing->flags&MF_NOGRAVITY) || (thing->flags&MF_CORPSE) || difft > (double)gl_sclipthreshold)
{
difft = 0;
}
}
if (spriteheight > fabs(difft))
{
double ratio = clamp<double>((fabs(difft) * (double)gl_sclipfactor / (spriteheight + 1)), 0.5, 1.0);
difft *= ratio;
}
z2 -= difft;
}
}
if (diffb <= (0 - (double)gl_sclipthreshold)) // such a large displacement can't be correct!
{
// for living monsters standing on the floor allow a little more.
if (!(thing->flags3&MF3_ISMONSTER) || (thing->flags&MF_NOGRAVITY) || (thing->flags&MF_CORPSE) || diffb < (-1.8*(double)gl_sclipthreshold))
{
diffb = 0;
}
}
z2 -= diffb;
}
return z2;
}
bool RenderPolySprite::IsThingCulled(AActor *thing)
{
FIntCVar *cvar = thing->GetInfo()->distancecheck;
@ -180,7 +294,7 @@ bool RenderPolySprite::IsThingCulled(AActor *thing)
// check renderrequired vs ~r_rendercaps, if anything matches we don't support that feature,
// check renderhidden vs r_rendercaps, if anything matches we do support that feature and should hide it.
if (!r_debug_disable_vis_filter && (!!(thing->RenderRequired & ~r_renderercaps)) ||
if ((!r_debug_disable_vis_filter && !!(thing->RenderRequired & ~r_renderercaps)) ||
(!!(thing->RenderHidden & r_renderercaps)))
return true;

View file

@ -27,12 +27,14 @@
class RenderPolySprite
{
public:
void Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, float t1, float t2);
void Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, AActor *thing, subsector_t *sub, uint32_t stencilValue, float t1, float t2);
static bool GetLine(AActor *thing, DVector2 &left, DVector2 &right);
static bool IsThingCulled(AActor *thing);
static FTexture *GetSpriteTexture(AActor *thing, /*out*/ bool &flipX);
private:
//visstyle_t GetSpriteVisStyle(AActor *thing, double z);
static double PerformSpriteClipAdjustment(AActor *thing, const DVector2 &thingpos, double spriteheight, double z);
static double GetSpriteFloorZ(AActor *thing, const DVector2 &thingpos);
static double GetSpriteCeilingZ(AActor *thing, const DVector2 &thingpos);
};

View file

@ -270,7 +270,6 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip, const PolyClipPlane &c
PolyDrawArgs args;
args.SetLight(GetColorTable(Line->frontsector->Colormap, Line->frontsector->SpecialColors[sector_t::walltop]), GetLightLevel(), PolyRenderer::Instance()->Light.WallGlobVis(foggy), false);
args.SetSubsectorDepth(SubsectorDepth);
args.SetTransform(&worldToClip);
args.SetFaceCullCCW(true);
args.SetStencilTestValue(StencilValue);
@ -283,9 +282,9 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip, const PolyClipPlane &c
{
args.SetWriteStencil(true, Polyportal->StencilValue);
args.SetWriteColor(false);
args.SetWriteSubsectorDepth(false);
args.SetWriteDepth(false);
args.DrawArray(vertices, 4, PolyDrawMode::TriangleFan);
Polyportal->Shape.push_back({ vertices, 4, true, SubsectorDepth });
Polyportal->Shape.push_back({ vertices, 4, true });
}
else if (!Masked)
{
@ -298,13 +297,13 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip, const PolyClipPlane &c
double srcalpha = MIN(Line->alpha, 1.0);
double destalpha = addtrans ? 1.0 : 1.0 - srcalpha;
args.SetStyle(TriBlendMode::TextureAdd, srcalpha, destalpha);
args.SetSubsectorDepthTest(true);
args.SetWriteSubsectorDepth(true);
args.SetDepthTest(true);
args.SetWriteDepth(true);
args.SetWriteStencil(false);
args.DrawArray(vertices, 4, PolyDrawMode::TriangleFan);
}
RenderPolyDecal::RenderWallDecals(worldToClip, clipPlane, LineSeg, SubsectorDepth, StencilValue);
RenderPolyDecal::RenderWallDecals(worldToClip, clipPlane, LineSeg, StencilValue);
}
void RenderPolyWall::ClampHeight(TriVertex &v1, TriVertex &v2)

View file

@ -29,7 +29,7 @@
#include "polyrenderer/poly_renderer.h"
#include "polyrenderer/scene/poly_light.h"
void RenderPolyWallSprite::Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue)
void RenderPolyWallSprite::Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, AActor *thing, subsector_t *sub, uint32_t stencilValue)
{
if (RenderPolySprite::IsThingCulled(thing))
return;
@ -106,8 +106,8 @@ void RenderPolyWallSprite::Render(const TriMatrix &worldToClip, const PolyClipPl
args.SetStencilTestValue(stencilValue);
args.SetTexture(tex);
args.SetClipPlane(clipPlane);
args.SetSubsectorDepthTest(true);
args.SetWriteSubsectorDepth(false);
args.SetDepthTest(true);
args.SetWriteDepth(false);
args.SetWriteStencil(false);
args.SetStyle(TriBlendMode::TextureMasked);
args.DrawArray(vertices, 4, PolyDrawMode::TriangleFan);

View file

@ -27,5 +27,5 @@
class RenderPolyWallSprite
{
public:
void Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue);
void Render(const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, AActor *thing, subsector_t *sub, uint32_t stencilValue);
};

View file

@ -11101,7 +11101,7 @@ ExpEmit FxRuntimeStateIndex::Emit(VMFunctionBuilder *build)
//
//==========================================================================
FxMultiNameState::FxMultiNameState(const char *_statestring, const FScriptPosition &pos)
FxMultiNameState::FxMultiNameState(const char *_statestring, const FScriptPosition &pos, PClassActor *checkclass)
:FxExpression(EFX_MultiNameState, pos)
{
FName scopename;
@ -11119,7 +11119,7 @@ FxMultiNameState::FxMultiNameState(const char *_statestring, const FScriptPositi
}
names = MakeStateNameList(statestring);
names.Insert(0, scopename);
scope = nullptr;
scope = checkclass;
}
//==========================================================================
@ -11135,8 +11135,8 @@ FxExpression *FxMultiNameState::Resolve(FCompileContext &ctx)
int symlabel;
auto vclass = PType::toClass(ctx.Class);
assert(vclass != nullptr);
auto clstype = ValidateActor(vclass->Descriptor);
//assert(vclass != nullptr);
auto clstype = vclass == nullptr? nullptr : ValidateActor(vclass->Descriptor);
if (names[0] == NAME_None)
{

View file

@ -2089,7 +2089,7 @@ class FxMultiNameState : public FxExpression
TArray<FName> names;
public:
FxMultiNameState(const char *statestring, const FScriptPosition &pos);
FxMultiNameState(const char *statestring, const FScriptPosition &pos, PClassActor *checkclass = nullptr);
FxExpression *Resolve(FCompileContext&);
};

View file

@ -545,7 +545,7 @@ bool TimidityPPMIDIDevice::LaunchTimidity ()
globfree(&glb);
int strCount = 1;
for (spaceIdx = 0; spaceIdx < CommandLine.Len(); spaceIdx++)
for (spaceIdx = 0; spaceIdx < static_cast<int>(CommandLine.Len()); spaceIdx++)
{
if (CommandLine[spaceIdx] == ' ')
{

View file

@ -61,6 +61,9 @@ enum
STAT_MAPMARKER, // Map marker actors
STAT_DLIGHT,
STAT_USER = 70,
STAT_USER_MAX = 90,
STAT_DEFAULT = 100, // Thinkers go here unless specified otherwise.
STAT_SECTOREFFECT, // All sector effects that cause floor and ceiling movement
STAT_ACTORMOVER, // actor movers

View file

@ -972,7 +972,7 @@ namespace swrenderer
// check renderrequired vs ~r_rendercaps, if anything matches we don't support that feature,
// check renderhidden vs r_rendercaps, if anything matches we do support that feature and should hide it.
if (!r_debug_disable_vis_filter && (!!(thing->RenderRequired & ~r_renderercaps)) ||
if ((!r_debug_disable_vis_filter && !!(thing->RenderRequired & ~r_renderercaps)) ||
(!!(thing->RenderHidden & r_renderercaps)))
return false;

View file

@ -766,6 +766,7 @@ FRemapTable *FFont::GetColorTranslation (EColorRange range, PalEntry *color) con
if (range >= 0 && range < NumTextColors && range != CR_UNTRANSLATED)
{
retcolor = TranslationColors[range];
retcolor.a = 255;
}
if (color != nullptr) *color = retcolor;
}

View file

@ -46,16 +46,10 @@
#define PRINTFISH(x)
#endif
#ifdef __clang__
#ifdef __GNUC__
#define IGNORE_FORMAT_PRE \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wformat-invalid-specifier\"") \
_Pragma("GCC diagnostic ignored \"-Wformat-extra-args\"")
#define IGNORE_FORMAT_POST _Pragma("GCC diagnostic pop")
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ >= 6)))
#define IGNORE_FORMAT_PRE \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wformat=\"") \
_Pragma("GCC diagnostic ignored \"-Wformat\"") \
_Pragma("GCC diagnostic ignored \"-Wformat-extra-args\"")
#define IGNORE_FORMAT_POST _Pragma("GCC diagnostic pop")
#else

View file

@ -689,6 +689,30 @@ EBDAC00E9D25D884B2C8F4B1F0390539 // doom2.wad map21
setsectorspecial 93 0
setwalltexture 582 back top ZIMMER3
}
20251EDA21B2F2ECF6FF5B8BBC00B26C // Doom II, MAP29
{
// Missing textures on teleporters
setwalltexture 405 back bot SUPPORT3
setwalltexture 406 back bot SUPPORT3
setwalltexture 407 back bot SUPPORT3
setwalltexture 408 back bot SUPPORT3
setwalltexture 516 back bot SUPPORT3
setwalltexture 517 back bot SUPPORT3
setwalltexture 518 back bot SUPPORT3
setwalltexture 519 back bot SUPPORT3
setwalltexture 524 back bot SUPPORT3
setwalltexture 525 back bot SUPPORT3
setwalltexture 526 back bot SUPPORT3
setwalltexture 527 back bot SUPPORT3
setwalltexture 1146 back bot SUPPORT3
setwalltexture 1147 back bot SUPPORT3
setwalltexture 1148 back bot SUPPORT3
setwalltexture 1149 back bot SUPPORT3
setwalltexture 1138 back bot SUPPORT3
setwalltexture 1139 back bot SUPPORT3
setwalltexture 1140 back bot SUPPORT3
setwalltexture 1141 back bot SUPPORT3
}
ABC4EB5A1535ECCD0061AD14F3547908 // Plutonia Experiment, map26
{
setsectorspecial 156 0

View file

@ -138,27 +138,57 @@ float R_DoomLightingEquation(float light)
#ifdef SUPPORTS_SHADOWMAPS
float sampleShadowmap(vec2 dir, float v)
float shadowDirToU(vec2 dir)
{
float u;
if (abs(dir.x) > abs(dir.y))
{
if (dir.x >= 0.0)
u = dir.y / dir.x * 0.125 + (0.25 + 0.125);
return dir.y / dir.x * 0.125 + (0.25 + 0.125);
else
u = dir.y / dir.x * 0.125 + (0.75 + 0.125);
return dir.y / dir.x * 0.125 + (0.75 + 0.125);
}
else
{
if (dir.y >= 0.0)
u = dir.x / dir.y * 0.125 + 0.125;
return dir.x / dir.y * 0.125 + 0.125;
else
u = dir.x / dir.y * 0.125 + (0.50 + 0.125);
return dir.x / dir.y * 0.125 + (0.50 + 0.125);
}
}
float sampleShadowmap(vec2 dir, float v)
{
float u = shadowDirToU(dir);
float dist2 = dot(dir, dir);
return texture(ShadowMap, vec2(u, v)).x > dist2 ? 1.0 : 0.0;
}
float sampleShadowmapLinear(vec2 dir, float v)
{
float u = shadowDirToU(dir);
float dist2 = dot(dir, dir);
vec2 isize = textureSize(ShadowMap, 0);
vec2 size = vec2(isize);
vec2 fetchPos = vec2(u, v) * size - vec2(0.5, 0.0);
if (fetchPos.x < 0.0)
fetchPos.x += size.x;
ivec2 ifetchPos = ivec2(fetchPos);
int y = ifetchPos.y;
float t = fract(fetchPos.x);
int x0 = ifetchPos.x;
int x1 = ifetchPos.x + 1;
if (x1 == isize.x)
x1 = 0;
float depth0 = texelFetch(ShadowMap, ivec2(x0, y), 0).x;
float depth1 = texelFetch(ShadowMap, ivec2(x1, y), 0).x;
return mix(step(dist2, depth0), step(dist2, depth1), t);
}
//===========================================================================
//
// Check if light is in shadow using Percentage Closer Filtering (PCF)
@ -168,6 +198,9 @@ float sampleShadowmap(vec2 dir, float v)
#define PCF_FILTER_STEP_COUNT 3
#define PCF_COUNT (PCF_FILTER_STEP_COUNT * 2 + 1)
// #define USE_LINEAR_SHADOW_FILTER
#define USE_PCF_SHADOW_FILTER 1
float shadowmapAttenuation(vec4 lightpos, float shadowIndex)
{
if (shadowIndex >= 1024.0)
@ -182,7 +215,11 @@ float shadowmapAttenuation(vec4 lightpos, float shadowIndex)
vec2 dir = ray / length;
ray -= dir * 2.0; // margin
#if defined(USE_LINEAR_SHADOW_FILTER)
ray -= dir * 6.0; // Shadow acne margin
return sampleShadowmapLinear(ray, v);
#elif defined(USE_PCF_SHADOW_FILTER)
ray -= dir * 2.0; // Shadow acne margin
dir = dir * min(length / 50.0, 1.0); // avoid sampling behind light
vec2 normal = vec2(-dir.y, dir.x);
@ -194,6 +231,10 @@ float shadowmapAttenuation(vec4 lightpos, float shadowIndex)
sum += sampleShadowmap(ray + normal * x - bias * abs(x), v);
}
return sum / PCF_COUNT;
#else // nearest shadow filter
ray -= dir * 6.0; // Shadow acne margin
return sampleShadowmap(ray, v);
#endif
}
#endif

View file

@ -518,6 +518,7 @@ class Actor : Thinker native
native clearscope int GetRenderStyle() const;
native clearscope bool CheckKeys(int locknum, bool remote, bool quiet = false);
native clearscope Inventory FirstInv() const;
protected native void CheckPortalTransition(bool linked = true);
native clearscope string GetTag(string defstr = "") const;
native void SetTag(string defstr = "");

View file

@ -385,6 +385,9 @@ class Thinker : Object native play
STAT_MAPMARKER, // Map marker actors
STAT_DLIGHT, // Dynamic lights
STAT_USER = 70,
STAT_USER_MAX = 90,
STAT_DEFAULT = 100, // Thinkers go here unless specified otherwise.
STAT_SECTOREFFECT, // All sector effects that cause floor and ceiling movement
STAT_ACTORMOVER, // actor movers

View file

@ -156,6 +156,7 @@ class FastProjectile : Actor
ExplodeMissile (NULL, NULL);
return;
}
CheckPortalTransition();
if (changexy && ripcount <= 0)
{
ripcount = count >> 3;

View file

@ -753,7 +753,7 @@ class PlayerPawn : Actor native
Vel.Z -= zpush;
move *= cos(Pitch);
}
Thrust(move);
Thrust(move, angle);
}
//----------------------------------------------------------------------------