- use a non-0 depth bias for sprites.

Hopefully this helps fixing the z-fighting issue with wall sprites in some Blood maps.
This commit is contained in:
Christoph Oelckers 2020-02-06 18:43:27 +01:00
parent 1479e1feae
commit 215cb14401
4 changed files with 46 additions and 1 deletions

View file

@ -7646,6 +7646,7 @@ killsprite:
GLInterface.EnableBlend(false); GLInterface.EnableBlend(false);
GLInterface.EnableAlphaTest(true); GLInterface.EnableAlphaTest(true);
GLInterface.SetClamp(1+2); GLInterface.SetClamp(1+2);
GLInterface.SetDepthBias(-2, -256);
if (spritesortcnt < numSprites) if (spritesortcnt < numSprites)
{ {
@ -7714,7 +7715,7 @@ killsprite:
GLInterface.EnableBlend(true); GLInterface.EnableBlend(true);
GLInterface.EnableAlphaTest(true); GLInterface.EnableAlphaTest(true);
GLInterface.SetDepthMask(false); GLInterface.SetDepthMask(false);
} }
#endif #endif
vec2f_t pos; vec2f_t pos;
@ -7855,6 +7856,7 @@ killsprite:
{ {
GLInterface.SetDepthMask(true); GLInterface.SetDepthMask(true);
GLInterface.SetClamp(0); GLInterface.SetClamp(0);
GLInterface.SetDepthBias(0, 0);
} }
#endif #endif

View file

@ -55,6 +55,21 @@ enum PRSFlags
}; };
struct FDepthBiasState
{
float mFactor;
float mUnits;
bool mChanged;
void Reset()
{
mFactor = 0;
mUnits = 0;
mChanged = false;
}
};
struct PolymostRenderState struct PolymostRenderState
{ {
int vindex, vcount, primtype; int vindex, vcount, primtype;
@ -72,6 +87,7 @@ struct PolymostRenderState
short matrixIndex[NUMMATRICES] = { 0,0,0,0,0 }; short matrixIndex[NUMMATRICES] = { 0,0,0,0,0 };
PalEntry fullscreenTint = 0xffffff, hictint = 0xffffff, hictint_overlay = 0xffffff; PalEntry fullscreenTint = 0xffffff, hictint = 0xffffff, hictint_overlay = 0xffffff;
int hictint_flags = -1; int hictint_flags = -1;
FDepthBiasState mBias{ };
int StateFlags = STF_COLORMASK|STF_DEPTHMASK; int StateFlags = STF_COLORMASK|STF_DEPTHMASK;
FRenderStyle Style{}; FRenderStyle Style{};

View file

@ -428,6 +428,19 @@ void PolymostRenderState::Apply(PolymostShader* shader, GLState &oldState)
else else
glDisable(GL_SCISSOR_TEST); glDisable(GL_SCISSOR_TEST);
} }
if (mBias.mChanged)
{
if (mBias.mFactor == 0 && mBias.mUnits == 0)
{
glDisable(GL_POLYGON_OFFSET_FILL);
}
else
{
glEnable(GL_POLYGON_OFFSET_FILL);
}
glPolygonOffset(mBias.mFactor, mBias.mUnits);
mBias.mChanged = false;
}
StateFlags &= ~(STF_CLEARCOLOR | STF_CLEARDEPTH | STF_VIEWPORTSET | STF_SCISSORSET); StateFlags &= ~(STF_CLEARCOLOR | STF_CLEARDEPTH | STF_VIEWPORTSET | STF_SCISSORSET);
oldState.Flags = StateFlags; oldState.Flags = StateFlags;

View file

@ -225,6 +225,20 @@ public:
void ReadPixels(int w, int h, uint8_t* buffer); void ReadPixels(int w, int h, uint8_t* buffer);
void SetDepthBias(float a, float b)
{
renderState.mBias.mFactor = a;
renderState.mBias.mUnits = b;
renderState.mBias.mChanged = true;
}
void ClearDepthBias()
{
renderState.mBias.mFactor = 0;
renderState.mBias.mUnits = 0;
renderState.mBias.mChanged = true;
}
void SetPaletteData(int index, const uint8_t* data) void SetPaletteData(int index, const uint8_t* data)
{ {
palmanager.SetPalette(index, data); palmanager.SetPalette(index, data);