- fixed texture clamping for elements that are partially behind a slope.

This is mainly mid textures on linedefs and decals.
This commit is contained in:
Christoph Oelckers 2021-09-17 00:25:28 +02:00
parent fdf879167c
commit 918e9e9b0d
5 changed files with 20 additions and 17 deletions

View file

@ -51,10 +51,12 @@ enum ETexMode
TM_OPAQUE, // (r, g, b, 1)
TM_INVERSE, // (1-r, 1-g, 1-b, a)
TM_ALPHATEXTURE, // (1, 1, 1, r)
TM_CLAMPY, // (r, g, b, (t >= 0.0 && t <= 1.0)? a:0)
TM_INVERTOPAQUE, // (1-r, 1-g, 1-b, 1)
TM_INVERTOPAQUE = 6, // (1-r, 1-g, 1-b, 1)
TM_FOGLAYER, // (renders a fog layer in the shape of the active texture)
TM_FIXEDCOLORMAP = TM_FOGLAYER, // repurposes the objectcolor uniforms to render a fixed colormap range. (Same constant because they cannot be used in the same context.
TM_CLAMPY = 0x1000, // (r, g, b, (t >= 0.0 && t <= 1.0)? a:0)
};
// Legacy render styles

View file

@ -342,7 +342,7 @@ public:
mTextureMode = mode;
}
void SetTextureMode(FRenderStyle style)
void SetTextureMode(FRenderStyle style, bool clampy = false)
{
if (style.Flags & STYLEF_RedIsAlpha)
{
@ -356,6 +356,7 @@ public:
{
SetTextureMode(TM_INVERSE);
}
if (clampy) mTextureMode |= TM_CLAMPY;
}
int GetTextureMode()

View file

@ -61,7 +61,7 @@ void HWDecal::DrawDecal(HWDrawInfo *di, FRenderState &state)
state.SetObjectColor(DecalColor);
state.SetLightIndex(dynlightindex);
state.SetTextureMode(decal->RenderStyle);
state.SetTextureMode(decal->RenderStyle, true);
state.SetRenderStyle(decal->RenderStyle);
state.SetMaterial(texture, UF_Sprite, 0, CLAMP_XY, decal->Translation, -1);

View file

@ -208,13 +208,13 @@ void HWWall::RenderTexturedWall(HWDrawInfo *di, FRenderState &state, int rflags)
}
#endif
if (flags & HWWall::HWF_CLAMPY && (type == RENDERWALL_M2S || type == RENDERWALL_M2SNF))
{
state.SetTextureMode(tmode | TM_CLAMPY);
}
if (type == RENDERWALL_M2SNF)
{
if (flags & HWWall::HWF_CLAMPY)
{
if (tmode == TM_NORMAL) state.SetTextureMode(TM_CLAMPY);
}
di->SetFog(state, 255, 0, di->isFullbrightScene(), nullptr, false);
}
if (type != RENDERWALL_COLOR && seg->sidedef != nullptr)
@ -1933,7 +1933,7 @@ void HWWall::Process(HWDrawInfo *di, seg_t *seg, sector_t * frontsector, sector_
sector_t * segback;
#ifdef _DEBUG
if (seg->linedef->Index() == 14454)
if (seg->linedef->Index() == 759)
{
int a = 0;
}

View file

@ -166,7 +166,7 @@ vec4 getTexel(vec2 st)
//
// Apply texture modes
//
switch (uTextureMode & 0xffff)
switch (uTextureMode & 0xfff)
{
case 1: // TM_STENCIL
texel.rgb = vec3(1.0,1.0,1.0);
@ -187,13 +187,6 @@ vec4 getTexel(vec2 st)
break;
}
case 5: // TM_CLAMPY
if (st.t < 0.0 || st.t > 1.0)
{
texel.a = 0.0;
}
break;
case 6: // TM_OPAQUEINVERSE
texel = vec4(1.0-texel.r, 1.0-texel.b, 1.0-texel.g, 1.0);
break;
@ -202,6 +195,13 @@ vec4 getTexel(vec2 st)
return texel;
}
if ((uTextureMode & 0x1000) != 0) // TM_CLAMPY
{
if (st.t < 0.0 || st.t > 1.0)
{
texel.a = 0.0;
}
}
// Apply the texture modification colors.
int blendflags = int(uTextureAddColor.a); // this alpha is unused otherwise