Use palette textures for translucent/sprites and apply the translation remap when requesting an indexed texture
This commit is contained in:
parent
56e796cd3e
commit
b23617475c
4 changed files with 35 additions and 2 deletions
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue