diff --git a/src/common/textures/texture.cpp b/src/common/textures/texture.cpp index 27e95614c..0543e3fd5 100644 --- a/src/common/textures/texture.cpp +++ b/src/common/textures/texture.cpp @@ -346,6 +346,18 @@ FTextureBuffer FTexture::CreateTexBuffer(int translation, int flags) result.mHeight = h; result.mContentId = 0; ImageHelpers::FlipNonSquareBlock(result.mBuffer, p, h, w, h); + + auto remap = translation <= 0 || IsLuminosityTranslation(translation) ? nullptr : GPalette.TranslationToTable(translation); + if (remap && remap->Inactive) remap = nullptr; + if (remap) translation = remap->Index; + + if (remap) + { + for (int i = 0, count = w * h; i < count; i++) + { + result.mBuffer[i] = remap->Remap[result.mBuffer[i]]; + } + } } else { diff --git a/src/rendering/hwrenderer/scene/hw_drawinfo.cpp b/src/rendering/hwrenderer/scene/hw_drawinfo.cpp index fa71ee946..31809c5fc 100644 --- a/src/rendering/hwrenderer/scene/hw_drawinfo.cpp +++ b/src/rendering/hwrenderer/scene/hw_drawinfo.cpp @@ -900,7 +900,7 @@ void HWDrawInfo::RenderScene(FRenderState &state) drawlists[GLDL_MODELS].Draw(this, state, false); - state.SetPaletteMode(false); // Translucent stuff uses other rules in the software renderer. We don't support that right now. + state.SetPaletteMode(false); // Decals run with some renderstyle that is still not correctly handled state.SetRenderStyle(STYLE_Translucent); @@ -1007,6 +1007,15 @@ void HWDrawInfo::RenderTranslucent(FRenderState &state) { RenderAll.Clock(); + if (!V_IsTrueColor()) + { + state.SetPaletteMode(!V_IsTrueColor()); + + FColormap cm; + cm.Clear(); + state.SetSWColormap(GetColorTable(cm)); + } + // final pass: translucent stuff state.AlphaFunc(Alpha_GEqual, gl_mask_sprite_threshold); state.SetRenderStyle(STYLE_Translucent); @@ -1031,6 +1040,7 @@ void HWDrawInfo::RenderTranslucent(FRenderState &state) drawlists[GLDL_TRANSLUCENT].DrawSorted(this, state); state.EnableBrightmap(false); + state.SetPaletteMode(false); state.AlphaFunc(Alpha_GEqual, 0.5f); state.SetDepthMask(true); diff --git a/src/rendering/hwrenderer/scene/hw_sprites.cpp b/src/rendering/hwrenderer/scene/hw_sprites.cpp index e52be64a4..46dc153c3 100644 --- a/src/rendering/hwrenderer/scene/hw_sprites.cpp +++ b/src/rendering/hwrenderer/scene/hw_sprites.cpp @@ -43,6 +43,7 @@ #include "vectors.h" #include "texturemanager.h" #include "basics.h" +#include "d_main.h" #include "hw_models.h" #include "hwrenderer/scene/hw_drawstructs.h" @@ -109,6 +110,13 @@ CVARD(Bool, r_showhitbox, false, CVAR_GLOBALCONFIG | CVAR_CHEAT, "show actor hit void HWSprite::DrawSprite(HWDrawInfo *di, FRenderState &state, bool translucent) { + bool paletteModeDisabled = false; + if ((OverrideShader != -1 || RenderStyle.BlendOp >= STYLEOP_Fuzz) && !V_IsTrueColor()) // We can't do these in palette mode with current shaders + { + paletteModeDisabled = true; + state.SetPaletteMode(false); + } + int gl_spritelight = get_gl_spritelight(); if(!actor && gl_spritelight > 1) gl_spritelight = 1; @@ -432,6 +440,9 @@ void HWSprite::DrawSprite(HWDrawInfo *di, FRenderState &state, bool translucent) state.EnableTexture(true); state.SetDynLight(0, 0, 0); state.SetShadeVertex(false); + + if (paletteModeDisabled) + state.SetPaletteMode(true); } //========================================================================== diff --git a/wadsrc/static/shaders/scene/lightmode.glsl b/wadsrc/static/shaders/scene/lightmode.glsl index 86903761e..e66adde12 100644 --- a/wadsrc/static/shaders/scene/lightmode.glsl +++ b/wadsrc/static/shaders/scene/lightmode.glsl @@ -48,7 +48,7 @@ vec4 getLightColor(Material material) int light = clamp(int((shade - vis) * 32), 0, 31); vec3 matColor = texelFetch(textures[uColormapIndex], ivec2(color, 32), 0).rgb; - vec4 frag = vec4(texelFetch(textures[uColormapIndex], ivec2(color, light), 0).rgb, 1.0); + vec4 frag = vec4(texelFetch(textures[uColormapIndex], ivec2(color, light), 0).rgb, material.Base.a * vColor.a); vec4 dynlight = uDynLightColor;