From 219979e20b0b9140bf0c0d0c5e0c9ca4bc47586e Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 3 Jul 2024 18:24:35 +0200 Subject: [PATCH 1/8] dont think kart even supports trivial maps so no need to constantly check for this --- src/r_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index f1ffeebce..fc753941c 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1119,8 +1119,8 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y) subsector_t *ret; // single subsector is a special case - if (numnodes == 0) - return subsectors; + //if (numnodes == 0) + //return subsectors; nodenum = numnodes - 1; From 711d7dcfccfa4ccd3e9620cc99c99d464de737c8 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 3 Jul 2024 19:35:52 +0200 Subject: [PATCH 2/8] Always use system-specific path seperator https://git.srb2.org/KartKrew/RingRacers/-/commit/0f16c61d04f42b463db5c8987571fc986ae6ce9f --- src/filesrch.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/filesrch.c b/src/filesrch.c index 55d40d811..3a3a576ce 100644 --- a/src/filesrch.c +++ b/src/filesrch.c @@ -37,7 +37,6 @@ #include #define SUFFIX "*" -#define SLASH "\\" #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) #ifndef INVALID_FILE_ATTRIBUTES @@ -135,7 +134,7 @@ opendir (const CHAR *szPath) /* Allocate enough space to store DIR structure and the complete * directory path given. */ nd = (DIR *) malloc (sizeof (DIR) + (strlen(szFullPath) + strlen (SLASH) + - strlen(SUFFIX) + 1) * sizeof (CHAR)); + strlen(PATHSEP) + 1) * sizeof (CHAR)); if (!nd) { @@ -149,10 +148,9 @@ opendir (const CHAR *szPath) /* Add on a slash if the path does not end with one. */ if (nd->dd_name[0] != '\0' && - nd->dd_name[strlen (nd->dd_name) - 1] != '/' && - nd->dd_name[strlen (nd->dd_name) - 1] != '\\') + nd->dd_name[strlen (nd->dd_name) - 1] != PATHSEP[0]) { - strcat (nd->dd_name, SLASH); + strcat (nd->dd_name, PATHSEP); } /* Add on the search pattern */ @@ -382,9 +380,9 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want return FS_NOTFOUND; } - if (searchpath[searchpathindex[depthleft]-2] != '/') + if (searchpath[searchpathindex[depthleft]-2] != PATHSEP[0]) { - searchpath[searchpathindex[depthleft]-1] = '/'; + searchpath[searchpathindex[depthleft]-1] = PATHSEP[0]; searchpath[searchpathindex[depthleft]] = 0; } else @@ -392,7 +390,7 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want while ((!found) && (depthleft < maxsearchdepth)) { - searchpath[searchpathindex[depthleft]]=0; + searchpath[searchpathindex[depthleft]] = 0; dent = readdir(dirhandle[depthleft]); if (!dent) @@ -419,7 +417,7 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want if (S_ISDIR(fsstat.st_mode)) dent->d_type = DT_DIR; else if (S_ISLNK(fsstat.st_mode)) - dent->d_type = DT_LNK; + dent->d_type = DT_LNK; } // Symlinks aren't always directory symlinks. Dunno if this would resolve recursive @@ -447,8 +445,8 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want depthleft++; } - searchpath[searchpathindex[depthleft]-1]='/'; - searchpath[searchpathindex[depthleft]]=0; + searchpath[searchpathindex[depthleft]-1] = PATHSEP[0]; + searchpath[searchpathindex[depthleft]] = 0; } else if (!strcasecmp(searchname, dent->d_name)) { From edbf20d97569c1091148197a51018a1e8bf2e699 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 4 Jul 2024 08:50:45 +0200 Subject: [PATCH 3/8] oops this should be min --- src/k_kart.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 93ddadd40..52e2ceb95 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -9350,10 +9350,9 @@ static void K_drawDriftGauge(void) if (driftcharge >= driftval*4) // rainbow sparks { - int index = max((leveltime % 18) + 1, 18 - 1); cmap = R_GetTranslationColormap(TC_RAINBOW, 1 + leveltime % (MAXSKINCOLORS-1),GTC_CACHE); for (i = 0; i < 4; i++) - V_DrawFill(barx, bary+dup*1+dup*i, BAR_WIDTH, dup, (driftrainbow[index] + i*2) | V_NOSCALESTART|drifttrans); + V_DrawFill(barx, bary+dup*1+dup*i, BAR_WIDTH, dup, (driftrainbow[min((leveltime % 18) + 1, 18 - 1)] + i*2) | V_NOSCALESTART|drifttrans); } else // none/blue/red { From 66eb2014667c345072dcc7638109bbc1898fab02 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 4 Jul 2024 08:51:11 +0200 Subject: [PATCH 4/8] simplify this a little --- src/hardware/hw_main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index d5c789368..b50e05e61 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -533,10 +533,8 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col poly_color.s.blue = (UINT8)blue; } - light_level = SOFTLIGHT(light_level); - // Clamp the light level, since it can sometimes go out of the 0-255 range from animations - light_level = min(max(light_level, cv_secbright.value), 255); + light_level = CLAMP(SOFTLIGHT(light_level), cv_secbright.value, 255); // in palette rendering mode, this is not needed since it properly takes the changes to the palette itself if (!HWR_ShouldUsePaletteRendering()) From d9f25354023be0a217fc14a3ad23e5e780a5e8f9 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 8 Jul 2024 06:02:01 +0200 Subject: [PATCH 5/8] scale and fade out dither pattern makes the image a bit cleaner and easier to look at in palrender --- src/hardware/hw_shaders.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index 7b188f64b..f7a086186 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -61,6 +61,9 @@ "if (scr_resolution.y > 720.0) {\n" \ "halfResolutiony = scr_resolution.y * 0.5;\n" \ "}\n" \ + "float zFactor = clamp((z - 768.0) / (2304.0 - 768.0), 0.0, 1.0);\n" \ + "halfResolutionx = mix(halfResolutionx, halfResolutionx * 2.0, zFactor);\n" \ + "halfResolutiony = mix(halfResolutiony, halfResolutiony * 2.0, zFactor);\n" \ "vec2 normalizedPosition = position * vec2(halfResolutionx / scr_resolution.x, halfResolutiony / scr_resolution.y);\n" \ "int x = int(mod(normalizedPosition.x, 4.0));\n" \ "int y = int(mod(normalizedPosition.y, 4.0));\n" \ @@ -71,9 +74,9 @@ "15.0, 7.0, 13.0, 5.0\n" \ ");\n" \ "#ifdef SRB2_PALETTE_RENDERING\n" \ - "float threshold = bayerMatrix[y*4 + x] / 12.0;\n" \ + "float threshold = (1.0 - pow(zFactor, 2.0)) * (bayerMatrix[y*4 + x] / 11.0);\n" \ "#else\n" \ - "float threshold = bayerMatrix[y*4 + x] / 16.0;\n" \ + "float threshold = (1.0 - pow(zFactor, 2.0)) * (bayerMatrix[y*4 + x] / 16.0);\n" \ "#endif\n" \ "return baseValue + threshold - 0.5 / 16.0;\n" \ From 58dd0b75914eeeef8878aafc8b8933e4efea7e02 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 8 Jul 2024 19:28:26 +0200 Subject: [PATCH 6/8] oops that actually didnt fade out at all lol --- src/hardware/hw_shaders.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index f7a086186..0ef5acccf 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -61,9 +61,9 @@ "if (scr_resolution.y > 720.0) {\n" \ "halfResolutiony = scr_resolution.y * 0.5;\n" \ "}\n" \ - "float zFactor = clamp((z - 768.0) / (2304.0 - 768.0), 0.0, 1.0);\n" \ - "halfResolutionx = mix(halfResolutionx, halfResolutionx * 2.0, zFactor);\n" \ - "halfResolutiony = mix(halfResolutiony, halfResolutiony * 2.0, zFactor);\n" \ + "float zFactor = clamp((z - 768.0) / (3072.0 - 768.0), 0.0, 1.0);\n" \ + "halfResolutionx = mix(halfResolutionx, halfResolutionx * 4.0, zFactor);\n" \ + "halfResolutiony = mix(halfResolutiony, halfResolutiony * 4.0, zFactor);\n" \ "vec2 normalizedPosition = position * vec2(halfResolutionx / scr_resolution.x, halfResolutiony / scr_resolution.y);\n" \ "int x = int(mod(normalizedPosition.x, 4.0));\n" \ "int y = int(mod(normalizedPosition.y, 4.0));\n" \ @@ -74,11 +74,11 @@ "15.0, 7.0, 13.0, 5.0\n" \ ");\n" \ "#ifdef SRB2_PALETTE_RENDERING\n" \ - "float threshold = (1.0 - pow(zFactor, 2.0)) * (bayerMatrix[y*4 + x] / 11.0);\n" \ + "float threshold = bayerMatrix[y*4 + x] / 11.0;\n" \ "#else\n" \ - "float threshold = (1.0 - pow(zFactor, 2.0)) * (bayerMatrix[y*4 + x] / 16.0);\n" \ + "float threshold = bayerMatrix[y*4 + x] / 16.0;\n" \ "#endif\n" \ - "return baseValue + threshold - 0.5 / 16.0;\n" \ + "return mix(baseValue + threshold - 0.5 / 16.0, baseValue, zFactor);\n" #define GLSL_DOOM_COLORMAP_NODITHER \ "return max(startmap * STARTMAP_FUDGE - scale * 0.5 * SCALE_FUDGE, cap);\n" \ From cbbde8dea54b02014c088ba2b6d03c93c99352e1 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 8 Jul 2024 19:37:04 +0200 Subject: [PATCH 7/8] more tweaks --- src/hardware/hw_shaders.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index 0ef5acccf..6235d9e1f 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -61,9 +61,9 @@ "if (scr_resolution.y > 720.0) {\n" \ "halfResolutiony = scr_resolution.y * 0.5;\n" \ "}\n" \ - "float zFactor = clamp((z - 768.0) / (3072.0 - 768.0), 0.0, 1.0);\n" \ - "halfResolutionx = mix(halfResolutionx, halfResolutionx * 4.0, zFactor);\n" \ - "halfResolutiony = mix(halfResolutiony, halfResolutiony * 4.0, zFactor);\n" \ + "float zFactor = clamp((z - 768.0) / (6144.0 - 768.0), 0.0, 1.0);\n" \ + "halfResolutionx = mix(halfResolutionx, halfResolutionx * 2.0, zFactor);\n" \ + "halfResolutiony = mix(halfResolutiony, halfResolutiony * 2.0, zFactor);\n" \ "vec2 normalizedPosition = position * vec2(halfResolutionx / scr_resolution.x, halfResolutiony / scr_resolution.y);\n" \ "int x = int(mod(normalizedPosition.x, 4.0));\n" \ "int y = int(mod(normalizedPosition.y, 4.0));\n" \ @@ -74,9 +74,9 @@ "15.0, 7.0, 13.0, 5.0\n" \ ");\n" \ "#ifdef SRB2_PALETTE_RENDERING\n" \ - "float threshold = bayerMatrix[y*4 + x] / 11.0;\n" \ + "float threshold = (1.0 - pow(zFactor, 2.0)) * (bayerMatrix[y*4 + x] / 11.0);\n" \ "#else\n" \ - "float threshold = bayerMatrix[y*4 + x] / 16.0;\n" \ + "float threshold = (1.0 - pow(zFactor, 2.0)) * (bayerMatrix[y*4 + x] / 16.0);\n" \ "#endif\n" \ "return mix(baseValue + threshold - 0.5 / 16.0, baseValue, zFactor);\n" From b5d7b84c1e3024296148b48918b1977c16d6722c Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 9 Jul 2024 08:39:38 +0200 Subject: [PATCH 8/8] more changes to dither use interger for distance scales start z factor earlier rename halfResolution to endResolution --- src/hardware/hw_shaders.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index 6235d9e1f..714b004b1 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -53,18 +53,19 @@ // Include GLSL_FLOOR_FUDGES or GLSL_WALL_FUDGES or define the fudges in shaders that use this macro. #define GLSL_DOOM_COLORMAP_DITHER \ "float baseValue = max(startmap * STARTMAP_FUDGE - scale * 0.5 * SCALE_FUDGE, cap);\n" \ - "float halfResolutionx = scr_resolution.x;\n" \ - "float halfResolutiony = scr_resolution.y;\n" \ + "float endResolutionx = scr_resolution.x;\n" \ + "float endResolutiony = scr_resolution.y;\n" \ "if (scr_resolution.x > 1280.0) {\n" \ - "halfResolutionx = scr_resolution.x * 0.5;\n" \ + "endResolutionx = scr_resolution.x * 0.5;\n" \ "}\n" \ "if (scr_resolution.y > 720.0) {\n" \ - "halfResolutiony = scr_resolution.y * 0.5;\n" \ + "endResolutiony = scr_resolution.y * 0.5;\n" \ "}\n" \ - "float zFactor = clamp((z - 768.0) / (6144.0 - 768.0), 0.0, 1.0);\n" \ - "halfResolutionx = mix(halfResolutionx, halfResolutionx * 2.0, zFactor);\n" \ - "halfResolutiony = mix(halfResolutiony, halfResolutiony * 2.0, zFactor);\n" \ - "vec2 normalizedPosition = position * vec2(halfResolutionx / scr_resolution.x, halfResolutiony / scr_resolution.y);\n" \ + "float zFactor = clamp((z - 192.0) / (6144.0 - 192.0), 0.0, 1.0);\n" \ + "int scaleFactor = int(mix(1.0, 8.0, zFactor));\n" \ + "endResolutionx = endResolutionx * scaleFactor;\n" \ + "endResolutiony = endResolutiony * scaleFactor;\n" \ + "vec2 normalizedPosition = position * vec2(endResolutionx / scr_resolution.x, endResolutiony / scr_resolution.y);\n" \ "int x = int(mod(normalizedPosition.x, 4.0));\n" \ "int y = int(mod(normalizedPosition.y, 4.0));\n" \ "float bayerMatrix[4*4] = float[4*4](\n" \