diff --git a/src/gl/renderer/gl_colormap.h b/src/gl/renderer/gl_colormap.h index 33c1a8337..46e36431e 100644 --- a/src/gl/renderer/gl_colormap.h +++ b/src/gl/renderer/gl_colormap.h @@ -14,6 +14,7 @@ enum EColorManipulation CM_INVALID=-1, CM_DEFAULT=0, // untranslated CM_FIRSTSPECIALCOLORMAP, // first special fixed colormap + CM_FIRSTSPECIALCOLORMAPFORCED= 0x08000000, // first special fixed colormap, application forced (for 2D overlays) CM_FOGLAYER = 0x10000000, // Sprite shaped fog layer @@ -23,6 +24,7 @@ enum EColorManipulation }; #define CM_MAXCOLORMAP int(CM_FIRSTSPECIALCOLORMAP + SpecialColormaps.Size()) +#define CM_MAXCOLORMAPFORCED int(CM_FIRSTSPECIALCOLORMAPFORCED + SpecialColormaps.Size()) #endif diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index b59f45e61..28d31ca8e 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -546,7 +546,7 @@ void FGLRenderer::Draw2D(F2DDrawer *drawer) if (index < 0 || (unsigned)index >= SpecialColormaps.Size()) index = 0; // if it isn't in the table FBitmap cannot use it. Shouldn't happen anyway. if (!gl.legacyMode) { - gl_RenderState.SetFixedColormap(CM_FIRSTSPECIALCOLORMAP + int(index)); + gl_RenderState.SetFixedColormap(CM_FIRSTSPECIALCOLORMAPFORCED + int(index)); } else { diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 2f6b11515..b93d77de7 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -253,9 +253,9 @@ bool FRenderState::ApplyShader() { activeShader->muFixedColormap.Set(0); } - else if (mColormapState > CM_DEFAULT && mColormapState < CM_MAXCOLORMAP) + else if ((mColormapState >= CM_FIRSTSPECIALCOLORMAP && mColormapState < CM_MAXCOLORMAPFORCED)) { - if (FGLRenderBuffers::IsEnabled()) + if (FGLRenderBuffers::IsEnabled() && mColormapState < CM_FIRSTSPECIALCOLORMAPFORCED) { // When using postprocessing to apply the colormap, we must render the image fullbright here. activeShader->muFixedColormap.Set(2); @@ -263,13 +263,20 @@ bool FRenderState::ApplyShader() } else { - FSpecialColormap *scm = &SpecialColormaps[mColormapState - CM_FIRSTSPECIALCOLORMAP]; - float m[] = { scm->ColorizeEnd[0] - scm->ColorizeStart[0], - scm->ColorizeEnd[1] - scm->ColorizeStart[1], scm->ColorizeEnd[2] - scm->ColorizeStart[2], 0.f }; + if (mColormapState >= CM_FIRSTSPECIALCOLORMAPFORCED) + { + auto colormapState = mColormapState + CM_FIRSTSPECIALCOLORMAP - CM_FIRSTSPECIALCOLORMAPFORCED; + if (colormapState < CM_MAXCOLORMAP) + { + FSpecialColormap *scm = &SpecialColormaps[colormapState - CM_FIRSTSPECIALCOLORMAP]; + float m[] = { scm->ColorizeEnd[0] - scm->ColorizeStart[0], + scm->ColorizeEnd[1] - scm->ColorizeStart[1], scm->ColorizeEnd[2] - scm->ColorizeStart[2], 0.f }; - activeShader->muFixedColormap.Set(1); - activeShader->muColormapStart.Set(scm->ColorizeStart[0], scm->ColorizeStart[1], scm->ColorizeStart[2], 0.f); - activeShader->muColormapRange.Set(m); + activeShader->muFixedColormap.Set(1); + activeShader->muColormapStart.Set(scm->ColorizeStart[0], scm->ColorizeStart[1], scm->ColorizeStart[2], 0.f); + activeShader->muColormapRange.Set(m); + } + } } } else if (mColormapState == CM_FOGLAYER)