Merge remote-tracking branch 'origin/newpalshader' into lugstuff

This commit is contained in:
Alug committed 2024-01-11 18:46:12 +01:00
commit 6f61331d46
4 files changed
+16 -12

No files matched your search

+6 -5
View File
@@ -925,7 +925,6 @@ void HWR_SetPalette(RGBA_t *palette)
if (HWR_ShouldUsePaletteRendering())
{
// set the palette for palette postprocessing
if (cv_grpalettedepth.value == 16)
{
// crush to 16-bit rgb565, like software currently does in the standard configuration
@@ -963,6 +962,7 @@ void HWR_SetPalette(RGBA_t *palette)
memset(mapPalette, 0, sizeof(mapPalette));
// hardware driver will flush there own cache if cache is non paletized
// now flush data texture cache so 32 bit texture are recomputed
//if (patchformat == GL_TEXFMT_RGBA || textureformat == GL_TEXFMT_RGBA)
if (patchformat == GR_RGBA || textureformat == GR_RGBA)
{
@@ -1004,16 +1004,16 @@ void HWR_SetMapPalette(void)
RGBA_t *palette;
int i;
if ((!(gamestate == GS_LEVEL)) || (gamestate == GS_TITLESCREEN)) //we dont have a master palette
if ((!(gamestate == GS_LEVEL)) || (gamestate == GS_TITLESCREEN))
{
// outside of a level, pMasterPalette should have PLAYPAL ready for us
//palette = pMasterPalette; // we dont have this in kart so just use plocalpalette as before
//palette = pMasterPalette; // we dont have this in kart so just use pLocalPalette as before
palette = pLocalPalette;
}
else
{
// in a level pMasterPalette might have a flash palette, but we
// in a level pLocalPalette might have a flash palette, but we
// want the map's original palette.
lumpnum_t lumpnum = W_GetNumForName(GetPalette());
size_t palsize = W_LumpLength(lumpnum);
@@ -1040,6 +1040,7 @@ void HWR_SetMapPalette(void)
// and the lookup table is outdated
HWR_SetPaletteLookup(mapPalette);
HWD.pfnSetTexturePalette(mapPalette);
//if (patchformat == GL_TEXFMT_RGBA || textureformat == GL_TEXFMT_RGBA)
if (patchformat == GR_RGBA || textureformat == GR_RGBA)
{
@@ -1098,7 +1099,7 @@ UINT32 HWR_GetLightTableID(extracolormap_t *colormap)
// call become invalid and must not be used.
void HWR_ClearLightTables(void)
{
//if (vid.glstate == VID_GL_LIBRARY_LOADED)
//if (vid.glstate == VID_GL_LIBRARY_LOADED) // we have pfnInit which is essentially the same, but it doesent work here for whatever reason, since this should not be done in software renderer ever!
if (rendermode == render_opengl)
HWD.pfnClearLightTables();
}
+1 -1
View File
@@ -189,7 +189,7 @@ static void CV_grshaders_OnChange(void)
}
}
static void CV_useCustomShaders_ONChange(void)
static void CV_useCustomShaders_ONChange(void) // should we do a call to HWR_TogglePaletteRendering here aswell in pal rendering mode?
{
if (rendermode == render_opengl)
{
+8 -5
View File
@@ -78,6 +78,7 @@ static float NEAR_CLIPPING_PLANE = NZCLIP_PLANE;
// **************************************************************************
static GLuint tex_downloaded = 0;
// these didnt work with karts batching system, hope this is not an issue
//static GLuint lt_downloaded = 0; // currently bound lighttable texture - currentSurfaceInfo
//static GLuint lt_downloaded2 = 0; // currently bound lighttable texture - nextSurfaceInfo
//static GLuint lt_downloaded3 = 0; // currently bound lighttable texture - pSurf
@@ -756,6 +757,7 @@ static float shader_leveltime = 0;
"}\n"
// hand tuned adjustments for light level calculation
// do those even work correctly without the preprocessor?
#define GLSL_FLOOR_FUDGES \
"#define STARTMAP_FUDGE 1.06\n" \
"#define MULT_FUDGE 0.5\n" \
@@ -851,7 +853,8 @@ static float shader_leveltime = 0;
"final_color.a = texel.a * poly_color.a;\n" \
"gl_FragColor = final_color;\n" \
"}\0"
//TODO: make this not a hacky copy of two shaders mixed together
#define GLSL_PALETTE_WATER_FRAGMENT_SHADER \
GLSL_FLOOR_FUDGES \
"const float freq = 0.030;\n" \
@@ -1220,7 +1223,7 @@ EXPORT boolean HWRAPI(LoadShaders) (void)
// restore gl shader state
//pglUseProgram(gl_shaderstate.program);
pglUseProgram(gl_currentshaderprogram);
//pglUseProgram(0);
//pglUseProgram(0); // dont remember why this was here in the first place, but seems fine?
#undef UNIFORM_1
}
#endif
@@ -4253,7 +4256,6 @@ EXPORT void HWRAPI(DrawScreenFinalTexture)(int width, int height)
off[10] = -yoff;
off[11] = 1.0f;
fix[0] = 0.0f;
fix[1] = 0.0f;
fix[2] = 0.0f;
@@ -4268,12 +4270,13 @@ EXPORT void HWRAPI(DrawScreenFinalTexture)(int width, int height)
clearColour.red = clearColour.green = clearColour.blue = 0;
clearColour.alpha = 1;
ClearBuffer(true, false, false, &clearColour);
if (HWR_ShouldUsePaletteRendering())
SetBlend(PF_NoDepthTest);
pglBindTexture(GL_TEXTURE_2D, finalScreenTexture);
if (HWR_ShouldUsePaletteRendering())
if (HWR_ShouldUsePaletteRendering()) // still quite hacky, but the replacement code in i_video didnt work and killed performance instead. somehow need to figure out whats up with that.
pglUseProgram(gl_shaderprograms[8].program); // palette postprocess shader
pglColor4ubv(white);
@@ -4312,7 +4315,7 @@ EXPORT void HWRAPI(SetPaletteLookup)(UINT8 *lut)
pglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
pglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
pglTexImage3D(GL_TEXTURE_3D, 0, internalFormat, HWR_PALETTE_LUT_SIZE, HWR_PALETTE_LUT_SIZE, HWR_PALETTE_LUT_SIZE,
0, GL_RED, GL_UNSIGNED_BYTE, lut);
0, GL_RED, GL_UNSIGNED_BYTE, lut); // should there be a safety guard here aswell as the old one had? cant really test since i dont have hardware which doesent support 3D textures
pglActiveTexture(GL_TEXTURE0);
}
+1 -1
View File
@@ -3150,7 +3150,7 @@ boolean P_SetupLevel(boolean skipprecip)
HWR_CorrectSWTricks();
HWR_CreatePlanePolygons((INT32)numnodes - 1);
if (HWR_ShouldUsePaletteRendering())
if (HWR_ShouldUsePaletteRendering()) //unsure if this is the right place, but seems to work since we dont have HWR_LoadLevel like srb2
HWR_SetMapPalette();
}