diff --git a/src/gl/renderer/gl_2ddrawer.cpp b/src/gl/renderer/gl_2ddrawer.cpp index cda4ea374..9c89c6f60 100644 --- a/src/gl/renderer/gl_2ddrawer.cpp +++ b/src/gl/renderer/gl_2ddrawer.cpp @@ -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(); diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 09888db5c..4e844c979 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -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; diff --git a/src/textures/textures.h b/src/textures/textures.h index 0c175f328..c0a1e9dcf 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -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, diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 444a9811f..2ff3ef483 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -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