From a3070e8846ce5268fa5201eabb154c53db65aaca Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 29 Dec 2016 14:33:53 +0100 Subject: [PATCH] - fixed: FGLTexture::CreateTexBuffer needs to be more careful with setting the texture's translucency information. First, if it has already been determined the value should be left alone and second, for translated textures the generated buffer is inconclusive so in that case it cannot be used at all. --- src/gl/scene/gl_sprite.cpp | 2 +- src/gl/textures/gl_material.cpp | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index f79549a39a..642e31c913 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -916,7 +916,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) RenderStyle = LegacyRenderStyles[STYLE_Translucent]; OverrideShader = gl_fuzztype + 4; trans = 0.99f; // trans may not be 1 here - hw_styleflags |= STYLEHW_NoAlphaTest; + hw_styleflags = STYLEHW_NoAlphaTest; } else { diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index dd224b8e0a..5aa1d75b98 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -187,6 +187,7 @@ unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, F { unsigned char * buffer; int W, H; + int isTransparent = -1; // Textures that are already scaled in the texture lump will not get replaced @@ -224,14 +225,16 @@ unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, F int trans = tex->CopyTrueColorPixels(&imgCreate, exx, exx); bmp.CopyPixelDataRGB(0, 0, imgCreate.GetPixels(), W, H, 4, W * 4, 0, CF_BGRA); tex->CheckTrans(buffer, W*H, trans); - bIsTransparent = tex->gl_info.mIsTransparent; + isTransparent = tex->gl_info.mIsTransparent; + if (bIsTransparent == -1) bIsTransparent = isTransparent; } } else if (translation<=0) { int trans = tex->CopyTrueColorPixels(&bmp, exx, exx); tex->CheckTrans(buffer, W*H, trans); - bIsTransparent = tex->gl_info.mIsTransparent; + isTransparent = tex->gl_info.mIsTransparent; + if (bIsTransparent == -1) bIsTransparent = isTransparent; } else { @@ -239,7 +242,8 @@ unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, F // Since FTexture's method is doing exactly that by calling GetPixels let's use that here // to do all the dirty work for us. ;) tex->FTexture::CopyTrueColorPixels(&bmp, exx, exx); - bIsTransparent = 0; + isTransparent = 0; + // This is not conclusive for setting the texture's transparency info. } // if we just want the texture for some checks there's no need for upsampling. @@ -247,7 +251,7 @@ unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, F // [BB] The hqnx upsampling (not the scaleN one) destroys partial transparency, don't upsamle textures using it. // [BB] Potentially upsample the buffer. - return gl_CreateUpsampledTextureBuffer ( tex, buffer, W, H, w, h, !!bIsTransparent); + return gl_CreateUpsampledTextureBuffer ( tex, buffer, W, H, w, h, !!isTransparent); }