Fix shader compile error and level palettes #57

Merged
hayaunderscore merged 1 commits from paletteshader into paletteshader 2023-09-11 10:40:02 +02:00
3 changed files with 13 additions and 4 deletions

No files matched your search

+3 -3
View File
@@ -566,7 +566,7 @@ static boolean gl_batching = false;// are we currently collecting batches?
static GLint gl_palette[768];
static INT32 gl_use_palette_shader = 0;
static boolean gl_palette_initialized = false;
boolean gl_palette_initialized = false;
static INT32 gl_enable_screen_textures = 1;
@@ -740,7 +740,7 @@ static gl_shaderprogram_t gl_shaderprograms[MAXSHADERPROGRAMS];
GLSL_DOOM_COLORMAP \
"void main(void) {\n" \
"vec4 texel = texture2D(tex, gl_TexCoord[0].st);\n" \
"float pal_idx = int(texture3D(lookup_tex, vec3((texel * 63.0 + 0.5) / 64.0))[0] * 255.0);\n" \
"int pal_idx = int(texture3D(lookup_tex, vec3((texel * 63.0 + 0.5) / 64.0))[0] * 255.0);\n" \
"float z = gl_FragCoord.z / gl_FragCoord.w;\n" \
"float light_y = clamp(floor(R_DoomColormap(lighting, z)), 0.0, 31.0);\n" \
"gl_FragColor = vec4(float(palette[pal_idx*3])/255.0, float(palette[pal_idx*3+1])/255.0, float(palette[pal_idx*3+2])/255.0, 1.0);\n" \
@@ -1109,7 +1109,7 @@ EXPORT void HWRAPI(KillShaders) (void)
// the +2 in the NearestColor call also needs to be adjusted if LUT_SIZE is changed!
// the hardcoded values in the shader also need to be adjusted if LUT_SIZE is changed!
static void InitPalette(void)
void InitPalette(void)
{
int i, r, g, b;
// init the palette
+4
View File
@@ -133,4 +133,8 @@ typedef enum
GLF_NOTEXENV = 0x02,
} oglflags_t;
// in order for custom playpals n shit to work properly
extern boolean gl_palette_initialized;
void InitPalette(void);
#endif
+6 -1
View File
@@ -28,6 +28,7 @@
#ifdef HWRENDER
#include "hardware/hw_main.h"
#include "hardware/r_opengl/r_opengl.h"
#endif
// Each screen is [vid.width*vid.height];
@@ -238,8 +239,12 @@ void V_SetPaletteLump(const char *pal)
{
LoadPalette(pal);
#ifdef HWRENDER
if (rendermode != render_soft && rendermode != render_none)
if (rendermode != render_soft && rendermode != render_none) {
// reset our palette lookups n shit
gl_palette_initialized = false;
InitPalette();
HWR_SetPalette(pLocalPalette);
}
#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL)
else
#endif