- adjusted GL renderer to the new rules for alpha textures. This means that the translation fallback is only needed for the legacy renderer now. Modern GL can use the regular texture and will apply a grayscale mapping instead of merely using the red channel.

This commit is contained in:
Christoph Oelckers 2018-03-22 20:42:17 +01:00
parent 1756035594
commit d586d774cf
4 changed files with 9 additions and 11 deletions

View file

@ -91,7 +91,9 @@ void F2DDrawer::AddTexture(FTexture *img, DrawParms &parms)
if (!img->bHasCanvas)
{
if (!parms.alphaChannel)
dg.mAlphaTexture = !!(parms.style.Flags & STYLEF_RedIsAlpha);
if (!dg.mAlphaTexture)
{
if (parms.remap != NULL && !parms.remap->Inactive)
{
@ -99,7 +101,6 @@ void F2DDrawer::AddTexture(FTexture *img, DrawParms &parms)
if (pal) dg.mTranslation = -pal->GetIndex();
}
}
dg.mAlphaTexture = !!(parms.style.Flags & STYLEF_RedIsAlpha);
u1 = gltex->GetUL();
v1 = gltex->GetVT();
u2 = gltex->GetUR();

View file

@ -144,14 +144,9 @@ public:
void SetMaterial(FMaterial *mat, int clampmode, int translation, int overrideshader, bool alphatexture)
{
// textures without their own palette are a special case for use as an alpha texture:
// They use the color index directly as an alpha value instead of using the palette's red.
// To handle this case, we need to set a special translation for such textures.
// Without shaders this translation must be applied to any texture.
if (alphatexture)
{
if (mat->tex->UseBasePalette() || gl.legacyMode) translation = TRANSLATION(TRANSLATION_Standard, 8);
}
// alpha textures need special treatment in the legacy renderer because withouz shaders they need a different texture.
if (alphatexture && gl.legacyMode) translation = TRANSLATION(TRANSLATION_Standard, 8);
if (mat->tex->bHasCanvas)
{
mTempTM = TM_OPAQUE;

View file

@ -211,6 +211,7 @@ public:
TEX_Flat,
TEX_Sprite,
TEX_WallPatch,
TEX_Build, // no longer used but needs to remain for ZScript
TEX_SkinSprite,
TEX_Decal,
TEX_MiscPatch,

View file

@ -64,7 +64,8 @@ vec4 getTexel(vec2 st)
break;
case 4: // TM_REDTOALPHA
texel = vec4(1.0, 1.0, 1.0, texel.r*texel.a);
float gray = (texel.r * 0.3 + texel.g * 0.56 + texel.b * 0.14);
texel = vec4(1.0, 1.0, 1.0, gray*texel.a);
break;
case 5: // TM_CLAMPY