From 479ecdba8d8286ec2491f25b3ec867416fc8efca Mon Sep 17 00:00:00 2001 From: NepDisk Date: Sat, 6 Dec 2025 17:04:47 -0500 Subject: [PATCH 1/3] comment out other save game compressors for testing --- src/d_clisrv.c | 18 +++++++++--------- src/doomdef.h | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index b3d6b1c6d..f00c97036 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -68,13 +68,13 @@ #include "discord.h" #endif -#ifdef USE_LZ4 +/*#ifdef USE_LZ4 #include "lz4.h" #elif defined HAVE_ZLIB #include -#else +#else*/ #include "lzf.h" -#endif +//#endif // // NETWORKING @@ -1233,14 +1233,14 @@ static void SV_SendSaveGame(INT32 node, boolean resending) } // Attempt to compress it. -#if defined USE_LZ4 +/*#if defined USE_LZ4 if ((compressedlen = LZ4_compress_fast((char*)(save.buffer + sizeof(UINT32)), (char*)(compressedsave + sizeof(UINT32)), length - sizeof(UINT32), length - sizeof(UINT32) - 1, LZ4_ACCEL))) #elif defined HAVE_ZLIB int compresstatus = compress2(compressedsave + sizeof(UINT32), &compressedlen, save.buffer + sizeof(UINT32), length - sizeof(UINT32), ZLIB_LEVEL); if (compresstatus == Z_OK) -#else +#else*/ if ((compressedlen = lzf_compress(save.buffer + sizeof(UINT32), length - sizeof(UINT32), compressedsave + sizeof(UINT32), length - sizeof(UINT32) - 1))) -#endif +//#endif { CONS_Printf("Compressed savegame of size %zu\n", length - sizeof(UINT32)); CONS_Printf("Compressed savegame is %zu\n", compressedlen); @@ -1341,13 +1341,13 @@ static void CL_LoadReceivedSavegame(boolean reloading) CONS_Printf("Decompressing compressed savegame of size %zu\n", length - sizeof(UINT32)); -#if defined USE_LZ4 +/*#if defined USE_LZ4 LZ4_decompress_safe((char*)save.p, (char*)decompressedbuffer, length - sizeof(UINT32), decompressedlen); #elif defined HAVE_ZLIB uncompress(decompressedbuffer, &decompressedlen, save.p, length - sizeof(UINT32)); -#else +#else*/ lzf_decompress(save.p, length - sizeof(UINT32), decompressedbuffer, decompressedlen); -#endif +//#endif CONS_Printf("Decompressed save is %zu\n", decompressedlen); diff --git a/src/doomdef.h b/src/doomdef.h index 98462f882..1365a90a3 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -213,8 +213,8 @@ extern char logfilename[1024]; //#define ZLIB_LEVEL 5 // LZ4 Options -#define USE_LZ4 // Use LZ4 for network savegame compression -#define LZ4_ACCEL 1 +//#define USE_LZ4 // Use LZ4 for network savegame compression +//#define LZ4_ACCEL 1 // surely nobody's gonna change the palette a second time :Clueless: #define FADECOLOR 0 // 120 From 4c491d8647cd97d4a679b86ab87948fa0324946f Mon Sep 17 00:00:00 2001 From: NepDisk Date: Sat, 6 Dec 2025 17:19:29 -0500 Subject: [PATCH 2/3] Revert "comment out other save game compressors for testing" This reverts commit 479ecdba8d8286ec2491f25b3ec867416fc8efca. --- src/d_clisrv.c | 18 +++++++++--------- src/doomdef.h | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index f00c97036..b3d6b1c6d 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -68,13 +68,13 @@ #include "discord.h" #endif -/*#ifdef USE_LZ4 +#ifdef USE_LZ4 #include "lz4.h" #elif defined HAVE_ZLIB #include -#else*/ +#else #include "lzf.h" -//#endif +#endif // // NETWORKING @@ -1233,14 +1233,14 @@ static void SV_SendSaveGame(INT32 node, boolean resending) } // Attempt to compress it. -/*#if defined USE_LZ4 +#if defined USE_LZ4 if ((compressedlen = LZ4_compress_fast((char*)(save.buffer + sizeof(UINT32)), (char*)(compressedsave + sizeof(UINT32)), length - sizeof(UINT32), length - sizeof(UINT32) - 1, LZ4_ACCEL))) #elif defined HAVE_ZLIB int compresstatus = compress2(compressedsave + sizeof(UINT32), &compressedlen, save.buffer + sizeof(UINT32), length - sizeof(UINT32), ZLIB_LEVEL); if (compresstatus == Z_OK) -#else*/ +#else if ((compressedlen = lzf_compress(save.buffer + sizeof(UINT32), length - sizeof(UINT32), compressedsave + sizeof(UINT32), length - sizeof(UINT32) - 1))) -//#endif +#endif { CONS_Printf("Compressed savegame of size %zu\n", length - sizeof(UINT32)); CONS_Printf("Compressed savegame is %zu\n", compressedlen); @@ -1341,13 +1341,13 @@ static void CL_LoadReceivedSavegame(boolean reloading) CONS_Printf("Decompressing compressed savegame of size %zu\n", length - sizeof(UINT32)); -/*#if defined USE_LZ4 +#if defined USE_LZ4 LZ4_decompress_safe((char*)save.p, (char*)decompressedbuffer, length - sizeof(UINT32), decompressedlen); #elif defined HAVE_ZLIB uncompress(decompressedbuffer, &decompressedlen, save.p, length - sizeof(UINT32)); -#else*/ +#else lzf_decompress(save.p, length - sizeof(UINT32), decompressedbuffer, decompressedlen); -//#endif +#endif CONS_Printf("Decompressed save is %zu\n", decompressedlen); diff --git a/src/doomdef.h b/src/doomdef.h index 1365a90a3..98462f882 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -213,8 +213,8 @@ extern char logfilename[1024]; //#define ZLIB_LEVEL 5 // LZ4 Options -//#define USE_LZ4 // Use LZ4 for network savegame compression -//#define LZ4_ACCEL 1 +#define USE_LZ4 // Use LZ4 for network savegame compression +#define LZ4_ACCEL 1 // surely nobody's gonna change the palette a second time :Clueless: #define FADECOLOR 0 // 120 From fea8fe250593a19e4d7adc4dbf6271cb1f9a4573 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 7 Dec 2025 00:42:05 +0100 Subject: [PATCH 3/3] Unhack Brightmap handling for Palette Rendering Turns out the Issue was just both the palette and lighttable textures were already bound to the texture unit the brightmap will be bound to, which led the shader to just try get the brightmap data from the lighttable texture instead of the brightmap texture --- src/hardware/hw_cache.c | 4 +- src/hardware/hw_defs.h | 3 -- src/hardware/hw_main.c | 40 ++++++--------- src/hardware/hw_shaders.c | 18 ++----- src/hardware/hw_shaders.h | 83 ++++++-------------------------- src/hardware/r_opengl/r_opengl.c | 13 ++--- 6 files changed, 42 insertions(+), 119 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index daf9f9cdc..45e4c443f 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -1809,8 +1809,8 @@ UINT32 HWR_GetLightTableID(extracolormap_t *colormap) if (default_colormap) colormap_pointer = colormaps; // don't actually use the data from the "default colormap" - else - colormap_pointer = colormap->colormap; + else + colormap_pointer = colormap->colormap; colormap->gl_lighttable_id = HWR_CreateLightTable(colormap_pointer); } diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index cd02be906..3a21c08cc 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -150,14 +150,11 @@ enum SHADER_NONE = -1, SHADER_FLOOR = 0, - SHADER_BRIGHTMAP_FLOOR, SHADER_WALL, - SHADER_BRIGHTMAP_WALL, SHADER_SPRITE, SHADER_MODEL, SHADER_MODEL_LIGHTING, SHADER_WATER, - SHADER_BRIGHTMAP_WATER, SHADER_FOG, SHADER_SKY, SHADER_PALETTE_POSTPROCESS, diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 64d546481..0e3d096bb 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -547,12 +547,8 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool { if (PolyFlags & PF_Fog) shader = SHADER_FOG; - else if ((PolyFlags & PF_Ripple) && levelflat != NULL && levelflat->type == LEVELFLAT_TEXTURE && R_GetTextureBrightmap(levelflat->texture_id) && HWR_ShouldUsePaletteRendering()) - shader = SHADER_BRIGHTMAP_WATER; else if (PolyFlags & PF_Ripple) shader = SHADER_WATER; - else if (levelflat != NULL && levelflat->type == LEVELFLAT_TEXTURE && R_GetTextureBrightmap(levelflat->texture_id) && HWR_ShouldUsePaletteRendering()) - shader = SHADER_BRIGHTMAP_FLOOR; else shader = SHADER_FLOOR; @@ -744,7 +740,7 @@ static void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, I // // HWR_ProjectWall // -static void HWR_ProjectWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blendmode, INT32 lightlevel, extracolormap_t *wallcolormap, INT32 texnum) +static void HWR_ProjectWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blendmode, INT32 lightlevel, extracolormap_t *wallcolormap) { INT32 shader = SHADER_NONE; @@ -752,11 +748,7 @@ static void HWR_ProjectWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIEL if (HWR_UseShader()) { - if (R_GetTextureBrightmap(texnum) && HWR_ShouldUsePaletteRendering()) - shader = SHADER_BRIGHTMAP_WALL; - else - shader = SHADER_WALL; - + shader = SHADER_WALL; blendmode |= PF_ColorMapped; } @@ -919,7 +911,7 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, else if (polyflags & PF_EnvironmentTrans) HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, polyflags, false, HWR_CalcWallLight(lightnum, gl_curline), colormap); else - HWR_ProjectWall(wallVerts, Surf, polyflags, HWR_CalcWallLight(lightnum, gl_curline), colormap, texnum); + HWR_ProjectWall(wallVerts, Surf, polyflags, HWR_CalcWallLight(lightnum, gl_curline), colormap); top = bot; endtop = endbot; @@ -948,7 +940,7 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, else if (polyflags & PF_EnvironmentTrans) HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, polyflags, false, HWR_CalcWallLight(lightnum, gl_curline), colormap); else - HWR_ProjectWall(wallVerts, Surf, polyflags, HWR_CalcWallLight(lightnum, gl_curline), colormap, texnum); + HWR_ProjectWall(wallVerts, Surf, polyflags, HWR_CalcWallLight(lightnum, gl_curline), colormap); } // HWR_DrawSkyWall @@ -961,8 +953,8 @@ static void HWR_DrawSkyWall(FOutVector *wallVerts, FSurfaceInfo *Surf) wallVerts[0].t = wallVerts[1].t = 0; wallVerts[0].s = wallVerts[3].s = 0; wallVerts[2].s = wallVerts[1].s = 0; - // this no longer sets top/bottom coords, this should be done before caling the function - HWR_ProjectWall(wallVerts, Surf, PF_Invisible|PF_NoTexture, 255, NULL, 0); + // this no longer sets top/bottom coords, this should be done before calling the function + HWR_ProjectWall(wallVerts, Surf, PF_Invisible|PF_NoTexture, 255, NULL); // PF_Invisible so it's not drawn into the colour buffer // PF_NoTexture for no texture // PF_Occlude is set in HWR_ProjectWall to draw into the depth buffer @@ -1279,7 +1271,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom else if (grTex->mipmap.flags & TF_TRANSPARENT) HWR_AddTransparentWall(wallVerts, &Surf, gl_toptexture, noencore, polyflags, false, lightnum, colormap); else - HWR_ProjectWall(wallVerts, &Surf, polyflags, lightnum, colormap, gl_toptexture); + HWR_ProjectWall(wallVerts, &Surf, polyflags, lightnum, colormap); } // check BOTTOM TEXTURE @@ -1343,7 +1335,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom else if (grTex->mipmap.flags & TF_TRANSPARENT) HWR_AddTransparentWall(wallVerts, &Surf, gl_bottomtexture, noencore, polyflags, false, lightnum, colormap); else - HWR_ProjectWall(wallVerts, &Surf, polyflags, lightnum, colormap, gl_bottomtexture); + HWR_ProjectWall(wallVerts, &Surf, polyflags, lightnum, colormap); } // Render midtexture if there's one. Determine if it's visible first, though @@ -1566,7 +1558,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom else if (!(blendmode & PF_Masked)) HWR_AddTransparentWall(wallVerts, &Surf, gl_midtexture, noencore, blendmode, false, lightnum, colormap); else - HWR_ProjectWall(wallVerts, &Surf, blendmode, lightnum, colormap, gl_midtexture); + HWR_ProjectWall(wallVerts, &Surf, blendmode, lightnum, colormap); } // Sky culling @@ -1657,7 +1649,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (grTex->mipmap.flags & TF_TRANSPARENT) HWR_AddTransparentWall(wallVerts, &Surf, gl_midtexture, noencore, blendmode, false, lightnum, colormap); else - HWR_ProjectWall(wallVerts, &Surf, blendmode, lightnum, colormap, gl_midtexture); + HWR_ProjectWall(wallVerts, &Surf, blendmode, lightnum, colormap); } } } @@ -1865,7 +1857,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (blendmode != PF_Masked) HWR_AddTransparentWall(wallVerts, &Surf, texnum, noencore, blendmode, false, lightnum, colormap); else - HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap, texnum); + HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); } } } @@ -1991,7 +1983,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (blendmode != PF_Masked) HWR_AddTransparentWall(wallVerts, &Surf, texnum, noencore, blendmode, false, lightnum, colormap); else - HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap, texnum); + HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); } } } @@ -4242,7 +4234,7 @@ typedef struct static wallinfo_t *wallinfo = NULL; static size_t numwalls = 0; // a list of transparent walls to be drawn -void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap, INT32 texnum); +void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap); #define MAX_TRANSPARENTWALL 256 @@ -4506,7 +4498,7 @@ static void HWR_CreateDrawNodes(void) if (!(sortnode[sortindex[i]].wall->blend & PF_NoTexture)) HWR_GetTexture(sortnode[sortindex[i]].wall->texnum, sortnode[sortindex[i]].wall->noencore); HWR_RenderWall(sortnode[sortindex[i]].wall->wallVerts, &sortnode[sortindex[i]].wall->Surf, sortnode[sortindex[i]].wall->blend, sortnode[sortindex[i]].wall->fogwall, - sortnode[sortindex[i]].wall->lightlevel, sortnode[sortindex[i]].wall->wallcolormap, sortnode[sortindex[i]].wall->texnum); + sortnode[sortindex[i]].wall->lightlevel, sortnode[sortindex[i]].wall->wallcolormap); } } @@ -6506,7 +6498,7 @@ static void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, I numwalls++; } -void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap, INT32 texnum) +void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap) { FBITFIELD blendmode = blend; UINT8 alpha = pSurf->PolyColor.s.alpha; // retain the alpha @@ -6525,8 +6517,6 @@ void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend, { if (fogwall) shader = SHADER_FOG; - else if (R_GetTextureBrightmap(texnum) && HWR_ShouldUsePaletteRendering()) - shader = SHADER_BRIGHTMAP_WALL; else shader = SHADER_WALL; diff --git a/src/hardware/hw_shaders.c b/src/hardware/hw_shaders.c index aed0587ad..7458e25df 100644 --- a/src/hardware/hw_shaders.c +++ b/src/hardware/hw_shaders.c @@ -27,15 +27,9 @@ static struct { // Floor shader {GLSL_DEFAULT_VERTEX_SHADER, GLSL_FLOOR_FRAGMENT_SHADER}, - // Brightmap Floor shader - {GLSL_DEFAULT_VERTEX_SHADER, GLSL_BRIGHTMAP_FLOOR_FRAGMENT_SHADER}, - // Wall shader {GLSL_DEFAULT_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER}, - // Brightmap Wall shader - {GLSL_DEFAULT_VERTEX_SHADER, GLSL_BRIGHTMAP_WALL_FRAGMENT_SHADER}, - // Sprite shader {GLSL_DEFAULT_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER}, @@ -48,9 +42,6 @@ static struct { // Water shader {GLSL_DEFAULT_VERTEX_SHADER, GLSL_WATER_FRAGMENT_SHADER}, - // Brightmap Water shader - {GLSL_DEFAULT_VERTEX_SHADER, GLSL_WATER_FRAGMENT_SHADER_NOPAL}, - // Fog shader {GLSL_DEFAULT_VERTEX_SHADER, GLSL_FOG_FRAGMENT_SHADER}, @@ -440,14 +431,11 @@ static inline UINT16 HWR_FindShaderDefs(UINT16 wadnum) customshaderxlat_t shaderxlat[] = { {"Flat", SHADER_FLOOR}, - {"BrightmapFloor", SHADER_BRIGHTMAP_FLOOR}, {"WallTexture", SHADER_WALL}, - {"BrightmapWall", SHADER_BRIGHTMAP_WALL}, {"Sprite", SHADER_SPRITE}, {"Model", SHADER_MODEL}, {"ModelLight", SHADER_MODEL_LIGHTING}, {"WaterRipple", SHADER_WATER}, - {"BrightmapWaterRipple", SHADER_BRIGHTMAP_WATER}, {"Fog", SHADER_FOG}, {"Sky", SHADER_SKY}, {"PalettePostprocess", SHADER_PALETTE_POSTPROCESS}, @@ -457,11 +445,13 @@ customshaderxlat_t shaderxlat[] = void HWR_LoadAllCustomShaders(void) { + /* INT32 i; // read every custom shader - //for (i = 0; i < numwadfiles; i++) - // HWR_LoadCustomShadersFromFile(i, (type == RET_PK3))); + for (i = 0; i < numwadfiles; i++) + HWR_LoadCustomShadersFromFile(i, (type == RET_PK3))); + */ } void HWR_LoadCustomShadersFromFile(UINT16 wadnum, boolean PK3) diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index 245359fad..9e99bdd1f 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -151,26 +151,26 @@ #define GLSL_PALETTE_RENDERING \ "float tex_pal_idx = texture3D(palette_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" \ + "float light_y = clamp(floor(R_DoomColormap(final_lighting, z)), 0.0, 31.0);\n" \ "vec2 lighttable_coord = vec2((tex_pal_idx + 0.5) / 256.0, (light_y + 0.5) / 32.0);\n" \ "vec4 final_color = texture2D(lighttable_tex, lighttable_coord);\n" \ "final_color.a = texel.a * poly_color.a;\n" \ - "float brightmap_mix = floor(texture2D(brightmap, gl_TexCoord[0].st).r);\n" \ - "float light_gain = (255.0 - lighting) * brightmap_mix;\n" \ - "float final_lighting = lighting + light_gain;\n" \ "gl_FragColor = final_color;\n" \ #define GLSL_SOFTWARE_FRAGMENT_SHADER \ "#ifdef SRB2_PALETTE_RENDERING\n" \ "uniform sampler2D tex;\n" \ "uniform sampler2D brightmap;\n" \ - "uniform sampler3D palette_lookup_tex;\n" \ - "uniform sampler2D lighttable_tex;\n" \ "uniform vec4 poly_color;\n" \ "uniform float lighting;\n" \ + "uniform sampler3D palette_lookup_tex;\n" \ + "uniform sampler2D lighttable_tex;\n" \ GLSL_DOOM_COLORMAP \ "void main(void) {\n" \ "vec4 texel = texture2D(tex, gl_TexCoord[0].st);\n" \ + "float brightmap_mix = floor(texture2D(brightmap, gl_TexCoord[0].st).r);\n" \ + "float light_gain = (255.0 - lighting) * brightmap_mix;\n" \ + "float final_lighting = lighting + light_gain;\n" \ GLSL_PALETTE_RENDERING \ "}\n" \ "#else\n" \ @@ -197,30 +197,6 @@ "gl_FragColor = final_color;\n" \ "}\n" \ "#endif\0" - -#define GLSL_SOFTWARE_FRAGMENT_SHADER_NOPAL \ - "uniform sampler2D tex;\n" \ - "uniform sampler2D brightmap;\n" \ - "uniform vec4 poly_color;\n" \ - "uniform vec4 tint_color;\n" \ - "uniform vec4 fade_color;\n" \ - "uniform float lighting;\n" \ - "uniform float fade_start;\n" \ - "uniform float fade_end;\n" \ - GLSL_DOOM_COLORMAP \ - GLSL_DOOM_LIGHT_EQUATION \ - "void main(void) {\n" \ - "vec4 texel = texture2D(tex, gl_TexCoord[0].st);\n" \ - "vec4 base_color = texel * poly_color;\n" \ - "vec4 final_color = base_color;\n" \ - "float brightmap_mix = floor(texture2D(brightmap, gl_TexCoord[0].st).r);\n" \ - "float light_gain = (255.0 - lighting) * brightmap_mix;\n" \ - "float final_lighting = lighting + light_gain;\n" \ - GLSL_SOFTWARE_TINT_EQUATION \ - GLSL_SOFTWARE_FADE_EQUATION \ - "final_color.a = texel.a * poly_color.a;\n" \ - "gl_FragColor = final_color;\n" \ - "}\n" \ // hand tuned adjustments for light level calculation #define GLSL_FLOOR_FUDGES \ @@ -241,14 +217,6 @@ GLSL_WALL_FUDGES \ GLSL_SOFTWARE_FRAGMENT_SHADER -#define GLSL_BRIGHTMAP_FLOOR_FRAGMENT_SHADER \ - GLSL_FLOOR_FUDGES \ - GLSL_SOFTWARE_FRAGMENT_SHADER_NOPAL - -#define GLSL_BRIGHTMAP_WALL_FRAGMENT_SHADER \ - GLSL_WALL_FUDGES \ - GLSL_SOFTWARE_FRAGMENT_SHADER_NOPAL - // same as above but multiplies results with the lighting value from the // accompanying vertex shader (stored in gl_Color) #define GLSL_SOFTWARE_MODEL_LIGHTING_FRAGMENT_SHADER \ @@ -266,7 +234,11 @@ "#ifdef SRB2_MODEL_LIGHTING\n" \ "texel *= gl_Color;\n" \ "#endif\n" \ - GLSL_PALETTE_RENDERING \ + "float final_lighting = gl_Color.r * 255.0;\n" \ + "float brightmap_mix = floor(texture2D(brightmap, gl_TexCoord[0].st).r);\n" \ + "float light_gain = (255.0 - final_lighting) * brightmap_mix;\n" \ + "final_lighting += light_gain;\n" \ +GLSL_PALETTE_RENDERING \ "}\n" \ "#else\n" \ "uniform sampler2D tex;\n" \ @@ -325,6 +297,9 @@ GLSL_DOOM_COLORMAP \ "void main(void) {\n" \ GLSL_WATER_TEXEL \ + "float brightmap_mix = floor(texture2D(brightmap, gl_TexCoord[0].st).r);\n" \ + "float light_gain = (255.0 - lighting) * brightmap_mix;\n" \ + "float final_lighting = lighting + light_gain;\n" \ GLSL_PALETTE_RENDERING \ "}\n" \ "#else\n" \ @@ -352,36 +327,6 @@ "gl_FragColor = final_color;\n" \ "}\n" \ "#endif\0" - -#define GLSL_WATER_FRAGMENT_SHADER_NOPAL \ - GLSL_FLOOR_FUDGES \ - "const float freq = 0.025;\n" \ - "const float amp = 0.025;\n" \ - "const float speed = 2.0;\n" \ - "const float pi = 3.14159;\n" \ - "uniform sampler2D tex;\n" \ - "uniform sampler2D brightmap;\n" \ - "uniform vec4 poly_color;\n" \ - "uniform vec4 tint_color;\n" \ - "uniform vec4 fade_color;\n" \ - "uniform float lighting;\n" \ - "uniform float fade_start;\n" \ - "uniform float fade_end;\n" \ - "uniform float leveltime;\n" \ - GLSL_DOOM_COLORMAP \ - GLSL_DOOM_LIGHT_EQUATION \ - "void main(void) {\n" \ - GLSL_WATER_TEXEL \ - "vec4 base_color = texel * poly_color;\n" \ - "vec4 final_color = base_color;\n" \ - "float brightmap_mix = floor(texture2D(brightmap, gl_TexCoord[0].st).r);\n" \ - "float light_gain = (255.0 - lighting) * brightmap_mix;\n" \ - "float final_lighting = lighting + light_gain;\n" \ - GLSL_SOFTWARE_TINT_EQUATION \ - GLSL_SOFTWARE_FADE_EQUATION \ - "final_color.a = texel.a * poly_color.a;\n" \ - "gl_FragColor = final_color;\n" \ - "}\n" \ // // Fog block shader diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 4e9de5dc1..3700083e2 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -2051,9 +2051,10 @@ static boolean Shader_CompileProgram(gl_shader_t *shader, GLint i) pglUseProgram(shader->program); // texture unit numbers for the samplers used for palette rendering - UNIFORM_1(shader->uniforms[gluniform_palette_tex], 2, pglUniform1i); - UNIFORM_1(shader->uniforms[gluniform_palette_lookup_tex], 1, pglUniform1i); - UNIFORM_1(shader->uniforms[gluniform_lighttable_tex], 2, pglUniform1i); + UNIFORM_1(shader->uniforms[gluniform_palette_tex], 3, pglUniform1i); + UNIFORM_1(shader->uniforms[gluniform_palette_lookup_tex], 2, pglUniform1i); + UNIFORM_1(shader->uniforms[gluniform_lighttable_tex], 3, pglUniform1i); + // changed to tex units 2 and 3 due to brightmap handling, binding two things to the same unit will just overwrite each other! // restore gl shader state pglUseProgram(gl_shaderstate.program); @@ -2124,7 +2125,7 @@ static void PreparePolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FBITFIELD if (pSurf->LightTableId && pSurf->LightTableId != lt_downloaded) { - pglActiveTexture(GL_TEXTURE2); + pglActiveTexture(GL_TEXTURE3); pglBindTexture(GL_TEXTURE_2D, pSurf->LightTableId); pglActiveTexture(GL_TEXTURE0); lt_downloaded = pSurf->LightTableId; @@ -3388,7 +3389,7 @@ EXPORT void HWRAPI(SetPaletteLookup)(UINT8 *lut) } if (!paletteLookupTex) pglGenTextures(1, &paletteLookupTex); - pglActiveTexture(GL_TEXTURE1); + pglActiveTexture(GL_TEXTURE2); pglBindTexture(GL_TEXTURE_3D, paletteLookupTex); pglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); pglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -3447,7 +3448,7 @@ EXPORT void HWRAPI(SetScreenPalette)(RGBA_t *palette) memcpy(screenPalette, palette, sizeof(screenPalette)); if (!screenPaletteTex) pglGenTextures(1, &screenPaletteTex); - pglActiveTexture(GL_TEXTURE2); + pglActiveTexture(GL_TEXTURE3); pglBindTexture(GL_TEXTURE_1D, screenPaletteTex); pglTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); pglTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);