mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-03-20 09:52:18 +00:00
Merge branch 'colorlutfix' into 'master'
Fix color LUT using the wrong palette See merge request STJr/SRB2!739
This commit is contained in:
commit
decc381698
5 changed files with 17 additions and 24 deletions
|
@ -624,14 +624,6 @@ static void GIF_framewrite(void)
|
|||
//
|
||||
INT32 GIF_open(const char *filename)
|
||||
{
|
||||
#if 0
|
||||
if (rendermode != render_soft)
|
||||
{
|
||||
CONS_Alert(CONS_WARNING, M_GetText("GIFs cannot be taken in non-software modes!\n"));
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
gif_out = fopen(filename, "wb");
|
||||
if (!gif_out)
|
||||
return 0;
|
||||
|
@ -640,13 +632,13 @@ INT32 GIF_open(const char *filename)
|
|||
gif_downscale = (!!cv_gif_downscale.value);
|
||||
|
||||
// GIF color table
|
||||
// In hardware mode, uses the master palette
|
||||
gif_palette = ((cv_screenshot_colorprofile.value
|
||||
// In hardware mode, forces the local palette
|
||||
#ifdef HWRENDER
|
||||
&& (rendermode == render_soft)
|
||||
if (rendermode == render_opengl)
|
||||
gif_palette = pLocalPalette;
|
||||
else
|
||||
#endif
|
||||
) ? pLocalPalette
|
||||
: pMasterPalette);
|
||||
gif_palette = ((cv_screenshot_colorprofile.value) ? pLocalPalette : pMasterPalette);
|
||||
|
||||
GIF_headwrite();
|
||||
gif_frames = 0;
|
||||
|
|
12
src/r_data.c
12
src/r_data.c
|
@ -2465,16 +2465,20 @@ extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *ex
|
|||
|
||||
// Thanks to quake2 source!
|
||||
// utils3/qdata/images.c
|
||||
UINT8 NearestColor(UINT8 r, UINT8 g, UINT8 b)
|
||||
UINT8 NearestPaletteColor(UINT8 r, UINT8 g, UINT8 b, RGBA_t *palette)
|
||||
{
|
||||
int dr, dg, db;
|
||||
int distortion, bestdistortion = 256 * 256 * 4, bestcolor = 0, i;
|
||||
|
||||
// Use master palette if none specified
|
||||
if (palette == NULL)
|
||||
palette = pMasterPalette;
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
dr = r - pMasterPalette[i].s.red;
|
||||
dg = g - pMasterPalette[i].s.green;
|
||||
db = b - pMasterPalette[i].s.blue;
|
||||
dr = r - palette[i].s.red;
|
||||
dg = g - palette[i].s.green;
|
||||
db = b - palette[i].s.blue;
|
||||
distortion = dr*dr + dg*dg + db*db;
|
||||
if (distortion < bestdistortion)
|
||||
{
|
||||
|
|
|
@ -171,7 +171,8 @@ const char *R_NameForColormap(extracolormap_t *extra_colormap);
|
|||
#define R_PutRgbaRGB(r, g, b) (R_PutRgbaR(r) + R_PutRgbaG(g) + R_PutRgbaB(b))
|
||||
#define R_PutRgbaRGBA(r, g, b, a) (R_PutRgbaRGB(r, g, b) + R_PutRgbaA(a))
|
||||
|
||||
UINT8 NearestColor(UINT8 r, UINT8 g, UINT8 b);
|
||||
UINT8 NearestPaletteColor(UINT8 r, UINT8 g, UINT8 b, RGBA_t *palette);
|
||||
#define NearestColor(r, g, b) NearestPaletteColor(r, g, b, NULL)
|
||||
|
||||
extern INT32 numtextures;
|
||||
|
||||
|
|
|
@ -3244,7 +3244,6 @@ Unoptimized version
|
|||
#endif
|
||||
}
|
||||
|
||||
// Taken from my videos-in-SRB2 project
|
||||
// Generates a color look-up table
|
||||
// which has up to 64 colors at each channel
|
||||
// (see the defines in v_video.h)
|
||||
|
@ -3261,7 +3260,7 @@ void InitColorLUT(RGBA_t *palette)
|
|||
for (r = 0; r < CLUTSIZE; r++)
|
||||
for (g = 0; g < CLUTSIZE; g++)
|
||||
for (b = 0; b < CLUTSIZE; b++)
|
||||
colorlookup[r][g][b] = NearestColor(r << SHIFTCOLORBITS, g << SHIFTCOLORBITS, b << SHIFTCOLORBITS);
|
||||
colorlookup[r][g][b] = NearestPaletteColor(r << SHIFTCOLORBITS, g << SHIFTCOLORBITS, b << SHIFTCOLORBITS, palette);
|
||||
clutinit = true;
|
||||
lastpalette = palette;
|
||||
}
|
||||
|
|
|
@ -37,10 +37,7 @@ cv_allcaps;
|
|||
// Allocates buffer screens, call before R_Init.
|
||||
void V_Init(void);
|
||||
|
||||
// Taken from my videos-in-SRB2 project
|
||||
// Generates a color look-up table
|
||||
// which has up to 64 colors at each channel
|
||||
|
||||
// Color look-up table
|
||||
#define COLORBITS 6
|
||||
#define SHIFTCOLORBITS (8-COLORBITS)
|
||||
#define CLUTSIZE (1<<COLORBITS)
|
||||
|
|
Loading…
Reference in a new issue