diff --git a/src/rendering/hwrenderer/scene/hw_setcolor.cpp b/src/rendering/hwrenderer/scene/hw_setcolor.cpp index 2b277313a..ad42aed79 100644 --- a/src/rendering/hwrenderer/scene/hw_setcolor.cpp +++ b/src/rendering/hwrenderer/scene/hw_setcolor.cpp @@ -32,6 +32,8 @@ #include "hw_lighting.h" #include "hw_cvars.h" #include "hw_drawcontext.h" +#include "d_main.h" +#include "rendering/swrenderer/r_swcolormaps.h" //========================================================================== // @@ -51,8 +53,16 @@ void SetColor(FRenderState &state, FLevelLocals* Level, ELightMode lightmode, in int hwlightlevel = CalcLightLevel(lightmode, sectorlightlevel, rellight, weapon, cm.BlendFactor); PalEntry pe = CalcLightColor(lightmode, hwlightlevel, cm.LightColor, cm.BlendFactor); state.SetColorAlpha(pe, alpha, cm.Desaturation); - if (isSoftwareLighting(lightmode)) state.SetSoftLightLevel(hw_ClampLight(sectorlightlevel + rellight), cm.BlendFactor); - else state.SetNoSoftLightLevel(); + if (V_IsTrueColor()) + { + if (isSoftwareLighting(lightmode)) state.SetSoftLightLevel(hw_ClampLight(sectorlightlevel + rellight), cm.BlendFactor); + else state.SetNoSoftLightLevel(); + } + else + { + state.SetSoftLightLevel(hw_ClampLight(sectorlightlevel + rellight), 0); + state.SetSWColormap(GetColorTable(cm)); + } } } @@ -69,8 +79,15 @@ void SetColor(SurfaceLightUniforms& uniforms, FLevelLocals* Level, ELightMode li int hwlightlevel = CalcLightLevel(lightmode, sectorlightlevel, rellight, weapon, cm.BlendFactor); PalEntry pe = CalcLightColor(lightmode, hwlightlevel, cm.LightColor, cm.BlendFactor); uniforms.SetColorAlpha(pe, alpha, cm.Desaturation); - if (isSoftwareLighting(lightmode)) uniforms.SetSoftLightLevel(hw_ClampLight(sectorlightlevel + rellight), cm.BlendFactor); - else uniforms.SetNoSoftLightLevel(); + if (V_IsTrueColor()) + { + if (isSoftwareLighting(lightmode)) uniforms.SetSoftLightLevel(hw_ClampLight(sectorlightlevel + rellight), cm.BlendFactor); + else uniforms.SetNoSoftLightLevel(); + } + else + { + uniforms.SetSoftLightLevel(hw_ClampLight(sectorlightlevel + rellight), 0); + } } } diff --git a/wadsrc/static/shaders/scene/lightmode.glsl b/wadsrc/static/shaders/scene/lightmode.glsl index baf935463..da920daa9 100644 --- a/wadsrc/static/shaders/scene/lightmode.glsl +++ b/wadsrc/static/shaders/scene/lightmode.glsl @@ -45,7 +45,7 @@ vec4 getLightColor(Material material) float L = uLightLevel * 255.0; float vis = min(uGlobVis / z, 24.0 / 32.0); float shade = 2.0 - (L + 12.0) / 128.0; - int light = max(int((shade - vis) * 32), 0); + int light = clamp(int((shade - vis) * 32), 0, 31); vec3 matColor = texelFetch(textures[uColormapIndex], ivec2(color, 0), 0).rgb; vec4 frag = vec4(texelFetch(textures[uColormapIndex], ivec2(color, light), 0).rgb, 1.0);