Apply colormaps

This commit is contained in:
Magnus Norddahl 2025-05-20 02:59:52 +02:00
commit ac335a5fbf
2 changed files with 22 additions and 5 deletions

View file

@ -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);
}
}
}

View file

@ -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);