- better handling of texture clamp state.

Free combination of clamping with all texture modes still missing in GLES and Softpoly renderers!
This commit is contained in:
Christoph Oelckers 2021-09-19 14:54:34 +02:00
parent 3acc5a2723
commit a0043ec09d
5 changed files with 21 additions and 7 deletions

View file

@ -127,7 +127,8 @@ bool FGLRenderState::ApplyShader()
ShaderFlavourData flavour;
flavour.textureMode = (mTextureMode == TM_NORMAL && mTempTM == TM_OPAQUE ? TM_OPAQUE : mTextureMode);
flavour.textureMode = (mTextureMode == TM_NORMAL && mTempTM == TM_OPAQUE ? TM_OPAQUE : mTextureMode) & 0xff;
if (mTextureClamp && flavour.textureMode == TM_NORMAL) flavour.textureMode = 5; // fixme. Clamp can now be combined with all modes.
if (flavour.textureMode == -1)
flavour.textureMode = 0;

View file

@ -219,6 +219,7 @@ protected:
int mLightIndex;
int mSpecialEffect;
int mTextureMode;
int mTextureClamp;
int mTextureModeFlags;
int mSoftLight;
float mLightParms[4];
@ -259,6 +260,7 @@ public:
mFogColor = 0xffffffff;
mStreamData.uFogColor = mFogColor;
mTextureMode = -1;
mTextureClamp = 0;
mTextureModeFlags = 0;
mStreamData.uDesaturationFactor = 0.0f;
mAlphaThreshold = 0.5f;
@ -344,12 +346,18 @@ public:
mStreamData.uDesaturationFactor = 0.0f;
}
void SetTextureClamp(bool on)
{
if (on) mTextureClamp = TM_CLAMPY;
else mTextureClamp = 0;
}
void SetTextureMode(int mode)
{
mTextureMode = mode;
}
void SetTextureMode(FRenderStyle style, bool clampy = false)
void SetTextureMode(FRenderStyle style)
{
if (style.Flags & STYLEF_RedIsAlpha)
{
@ -363,7 +371,6 @@ public:
{
SetTextureMode(TM_INVERSE);
}
if (clampy) mTextureMode |= TM_CLAMPY;
}
int GetTextureMode()

View file

@ -380,7 +380,11 @@ static void ProcessMaterial(int x0, int x1, PolyTriangleThreadData* thread)
{
auto constants = thread->PushConstants;
switch (constants->uTextureMode)
if (constants->uTextureMode == TM_CLAMPY)
{
FuncNormal_ClampY(x0, x1, thread);
}
else switch (constants->uTextureMode & 0xff)
{
default:
case TM_NORMAL:
@ -389,7 +393,6 @@ static void ProcessMaterial(int x0, int x1, PolyTriangleThreadData* thread)
case TM_OPAQUE: FuncNormal_Opaque(x0, x1, thread); break;
case TM_INVERSE: FuncNormal_Inverse(x0, x1, thread); break;
case TM_ALPHATEXTURE: FuncNormal_AlphaTexture(x0, x1, thread); break;
case TM_CLAMPY: FuncNormal_ClampY(x0, x1, thread); break;
case TM_INVERTOPAQUE: FuncNormal_InvertOpaque(x0, x1, thread); break;
}

View file

@ -61,7 +61,7 @@ void HWDecal::DrawDecal(HWDrawInfo *di, FRenderState &state)
state.SetObjectColor(DecalColor);
state.SetLightIndex(dynlightindex);
state.SetTextureMode(decal->RenderStyle, true);
state.SetTextureMode(decal->RenderStyle);
state.SetRenderStyle(decal->RenderStyle);
state.SetMaterial(texture, UF_Sprite, 0, CLAMP_XY, decal->Translation, -1);
@ -129,6 +129,7 @@ void HWDrawInfo::DrawDecals(FRenderState &state, TArray<HWDecal *> &decals)
{
side_t *wall = nullptr;
state.SetDepthMask(false);
state.SetTextureClamp(true);
state.SetDepthBias(-1, -128);
for (auto gldecal : decals)
{
@ -151,6 +152,7 @@ void HWDrawInfo::DrawDecals(FRenderState &state, TArray<HWDecal *> &decals)
state.ClearDepthBias();
state.SetTextureMode(TM_NORMAL);
state.SetDepthMask(true);
state.SetTextureClamp(false);
}
//==========================================================================

View file

@ -210,7 +210,7 @@ void HWWall::RenderTexturedWall(HWDrawInfo *di, FRenderState &state, int rflags)
if (flags & HWWall::HWF_CLAMPY && (type == RENDERWALL_M2S || type == RENDERWALL_M2SNF))
{
state.SetTextureMode(tmode | TM_CLAMPY);
state.SetTextureClamp(true);
}
if (type == RENDERWALL_M2SNF)
@ -300,6 +300,7 @@ void HWWall::RenderTexturedWall(HWDrawInfo *di, FRenderState &state, int rflags)
state.SetObjectColor2(0);
state.SetAddColor(0);
state.SetTextureMode(tmode);
state.SetTextureClamp(false);
state.EnableGlow(false);
state.EnableGradient(false);
state.ApplyTextureManipulation(nullptr);