From 2b7f2da5ee252e52e521a59a926167e70b32a630 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 1 Nov 2025 15:33:13 +0100 Subject: [PATCH] Mipmaps: fix translucent textures turning black i.e. since we allow texture filtering on translucent textures now, the min filter may specifcy one of the mipmap filters, this means we NEED to call GL_GENERATE_MIPMAP and set the LODs for them, otherwise no texture will be generated alternatively we could do a bunch of special cases for the mipmap filters, but this is simpler --- src/hardware/hw_main.cpp | 4 ---- src/hardware/r_opengl/r_opengl.c | 14 +++++++++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index dcefdaec2..c45404159 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -1259,8 +1259,6 @@ static inline boolean HWR_BlendMidtextureSurface(FSurfaceInfo *pSurf) case 256: if (gl_linedef->blendmode) blendmode = HWR_SurfaceBlend(gl_linedef->blendmode, R_GetLinedefTransTable(gl_linedef->alpha), pSurf); - else - blendmode = PF_Translucent; break; default: if (gl_linedef->blendmode) @@ -1272,8 +1270,6 @@ static inline boolean HWR_BlendMidtextureSurface(FSurfaceInfo *pSurf) } else if (gl_linedef->alpha >= 0 && gl_linedef->alpha < FRACUNIT) blendmode = HWR_TranstableToAlpha(R_GetLinedefTransTable(gl_linedef->alpha), pSurf); - else - blendmode = PF_Masked; break; } } diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index d481b56db..09f460c34 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -2089,7 +2089,7 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo) pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter); pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter); - if (MipMap && !(pTexInfo->flags & TF_TRANSPARENT)) // No mipmaps on transparent stuff + if (MipMap) { pglTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); @@ -2100,8 +2100,16 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo) // Control the mipmap level of detail pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, 0); - pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 5); - GenerateMipmaps(w, h, tex, 5, pTexInfo->flags); + + if (pTexInfo->flags & TF_TRANSPARENT) + { + pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 0); // No mipmaps on transparent stuff + } + else + { + pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 4); + GenerateMipmaps(w, h, tex, 4, pTexInfo->flags); + } } else {