From 022c074eceb19d6dc2c5b14b1f468cb630121dee Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 11 Nov 2019 23:54:09 +0100 Subject: [PATCH] - fixed brightmaps again - hopefully for real this time. The lighting model being used here is not really good for implementing render effect. --- source/build/src/sdlayer.cpp | 3 --- source/build/src/voxmodel.cpp | 3 +++ source/glbackend/gl_texture.cpp | 2 +- wadsrc/static/demolition/shaders/glsl/polymost.fp | 8 ++++++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/source/build/src/sdlayer.cpp b/source/build/src/sdlayer.cpp index 3636f9973..bf68f4d88 100644 --- a/source/build/src/sdlayer.cpp +++ b/source/build/src/sdlayer.cpp @@ -1162,7 +1162,6 @@ static void destroy_window_resources() #endif } -extern int globalShadeDiv; void sdlayer_setvideomode_opengl(int y) { glsurface_destroy(); @@ -1171,8 +1170,6 @@ void sdlayer_setvideomode_opengl(int y) GLInterface.Deinit(); GLInterface.Init(y); GLInterface.InitGLState(4, glmultisample); - // I have no idea how to get this info from the lookup tables. Fortunately it is consistent per game. - GLInterface.SetShadeDiv(globalShadeDiv); GLInterface.mSamplers->SetTextureFilterMode(hw_texfilter, hw_anisotropy); diff --git a/source/build/src/voxmodel.cpp b/source/build/src/voxmodel.cpp index 0d3c2a5bb..7bb7f7650 100644 --- a/source/build/src/voxmodel.cpp +++ b/source/build/src/voxmodel.cpp @@ -1128,6 +1128,9 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr) m->texid[globalpal] = gloadtex(m->mytex, m->mytexx, m->mytexy, m->is8bit, globalpal); GLInterface.BindTexture(0, m->texid[globalpal], -1); + GLInterface.UseBrightmaps(false); + GLInterface.UseGlowMapping(false); + GLInterface.UseDetailMapping(false); #endif auto data = GLInterface.AllocVertices(m->qcnt * 4); diff --git a/source/glbackend/gl_texture.cpp b/source/glbackend/gl_texture.cpp index 1a7a74d98..4219d7a41 100644 --- a/source/glbackend/gl_texture.cpp +++ b/source/glbackend/gl_texture.cpp @@ -288,7 +288,7 @@ bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int else { UseBrightmaps(true); - BindTexture(5, mtex, sampler); + BindTexture(5, htex, sampler); } } } diff --git a/wadsrc/static/demolition/shaders/glsl/polymost.fp b/wadsrc/static/demolition/shaders/glsl/polymost.fp index 8a6f4ef35..989ddcf47 100644 --- a/wadsrc/static/demolition/shaders/glsl/polymost.fp +++ b/wadsrc/static/demolition/shaders/glsl/polymost.fp @@ -196,13 +196,17 @@ void main() 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) { vec4 brightcolor = texture2D(s_brightmap, v_texCoord.xy); - color.rgb *= clamp(brightcolor.rgb + v_color.rgb, 0.0, 1.0); + if (grayscale(brightcolor) > 0.5) + { + shadeIt = false; + } } - else if ((u_flags & RF_FogDisabled) == 0) + if (shadeIt) { color.rgb *= lightcolor; shade = clamp(shade * u_shadeDiv, 0.0, 1.0); // u_shadeDiv is really 1/shadeDiv.