From 6282062492a070c272ad74b234ff4e037a7440c8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 18 Feb 2020 20:43:16 +0100 Subject: [PATCH] - fixed brightmaps. They are no longer run through the texture postprocessor and the shader now applies them correctly. --- source/glbackend/gl_texture.cpp | 2 +- wadsrc/static/engine/shaders/glsl/polymost.fp | 27 +++++++------------ 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/source/glbackend/gl_texture.cpp b/source/glbackend/gl_texture.cpp index f6eb2a4b8..41c328ae7 100644 --- a/source/glbackend/gl_texture.cpp +++ b/source/glbackend/gl_texture.cpp @@ -96,7 +96,7 @@ FHardwareTexture* GLInstance::CreateTrueColorTexture(FTexture* tex, int palid, b { auto palette = palid < 0? nullptr : palmanager.GetPaletteData(palid); if (palid >= 0 && palette == nullptr) return nullptr; - auto texbuffer = tex->CreateTexBuffer(palette, CTF_ProcessData); + auto texbuffer = tex->CreateTexBuffer(palette, checkfulltransparency? 0: CTF_ProcessData); // Check if the texture is fully transparent. When creating a brightmap such textures can be discarded. if (checkfulltransparency) { diff --git a/wadsrc/static/engine/shaders/glsl/polymost.fp b/wadsrc/static/engine/shaders/glsl/polymost.fp index 71ff2cc10..cf2266cec 100644 --- a/wadsrc/static/engine/shaders/glsl/polymost.fp +++ b/wadsrc/static/engine/shaders/glsl/polymost.fp @@ -205,26 +205,19 @@ void main() } else { - if (u_tintFlags != -1) color = convertColor(color); color.rgb *= detailColor.rgb; - - vec3 lightcolor = v_color.rgb; - bool shadeIt = ((u_flags & RF_FogDisabled) == 0); - // The lighting model here does not really allow more than a simple on/off brightmap because anything more complex inteferes with the shade ramp... :( - if ((u_flags & RF_Brightmapping) != 0) + if (u_tintFlags != -1) color = convertColor(color); + if ((u_flags & RF_FogDisabled) == 0) { - vec4 brightcolor = texture(s_brightmap, v_texCoord.xy); - if (grayscale(brightcolor) > 0.5) - { - shadeIt = false; - } - } - if (shadeIt) - { - color.rgb *= lightcolor; shade = clamp(shade * u_shadeDiv, 0.0, 1.0); // u_shadeDiv is really 1/shadeDiv. - // Apply the shade as a linear depth fade ramp. - color.rgb = mix(color.rgb, u_fogColor.rgb, shade); + vec3 lightcolor = v_color.rgb * (1.0 - shade); + + if ((u_flags & RF_Brightmapping) != 0) + { + lightcolor = texture(s_brightmap, v_texCoord.xy).rgb; + } + color.rgb *= lightcolor; + color.rgb += u_fogColor.rgb * shade; } } if (color.a < u_alphaThreshold) discard; // it's only here that we have the alpha value available to be able to perform the alpha test.