From 39489fc6f11508b0cc953b9ab8d4e2db9a0bbdf5 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 6 Jan 2024 08:07:11 +0100 Subject: [PATCH 1/2] =?UTF-8?q?use=20srb2=C2=B4s=20sky=20shader?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit also its finally a defined shader now + move default fragment shader to the top --- src/hardware/r_opengl/r_opengl.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index f2510a389..451237160 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -687,6 +687,17 @@ static float shader_leveltime = 0; // Fragment shader macros // ======================== +// +// GLSL generic fragment shader +// + +#define GLSL_DEFAULT_FRAGMENT_SHADER \ + "uniform sampler2D tex;\n" \ + "uniform vec4 poly_color;\n" \ + "void main(void) {\n" \ + "gl_FragColor = texture2D(tex, gl_TexCoord[0].st) * poly_color;\n" \ + "}\0" + // // GLSL Software fragment shader // @@ -919,14 +930,14 @@ static float shader_leveltime = 0; "}\0" // -// GLSL generic fragment shader -// - -#define GLSL_DEFAULT_FRAGMENT_SHADER \ +// Sky fragment shader +// Modulates poly_color with gl_Color +// +#define GLSL_SKY_FRAGMENT_SHADER \ "uniform sampler2D tex;\n" \ "uniform vec4 poly_color;\n" \ "void main(void) {\n" \ - "gl_FragColor = texture2D(tex, gl_TexCoord[0].st) * poly_color;\n" \ + "gl_FragColor = texture2D(tex, gl_TexCoord[0].st) * gl_Color * poly_color;\n" \ "}\0" static const char *fragment_shaders[] = { @@ -952,10 +963,7 @@ static const char *fragment_shaders[] = { GLSL_FOG_FRAGMENT_SHADER, // Sky fragment shader - "uniform sampler2D tex;\n" - "void main(void) {\n" - "gl_FragColor = texture2D(tex, gl_TexCoord[0].st);\n" - "}\0", + GLSL_SKY_FRAGMENT_SHADER, // Palette fragment shader GLSL_PALETTE_FRAGMENT_SHADER, From cf78516c77be6111f44e911ae1f7b43408c49b37 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 6 Jan 2024 08:13:24 +0100 Subject: [PATCH 2/2] use fudge defines + remove wall and floor doom_colormap shader both are now consilidated ( i have no idea how to spell that) into doom_colormap shader --- src/hardware/r_opengl/r_opengl.c | 50 ++++++++++++++------------------ 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 451237160..4d1fb626d 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -702,28 +702,7 @@ static float shader_leveltime = 0; // GLSL Software fragment shader // -#define GLSL_DOOM_COLORMAP_floors \ - "float R_DoomColormap(float light, float z)\n" \ - "{\n" \ - "float lightnum = clamp(light / 17.0, 0.0, 15.0);\n" \ - "float lightz = clamp(z / 16.0, 0.0, 127.0);\n" \ - "float startmap = (15.0 - lightnum) * 4.0;\n" \ - "float scale = 160.0 / (lightz + 1.0);\n" \ - "float cap = (155.0 - light) * 0.26;\n" \ - "return max(startmap * 1.06 - scale * 0.5 * 1.15, cap);\n" \ - "}\n" - #define GLSL_DOOM_COLORMAP \ - "float R_DoomColormap(float light, float z)\n" \ - "{\n" \ - "float lightnum = clamp(light / 17.0, 0.0, 15.0);\n" \ - "float lightz = clamp(z / 16.0, 0.0, 127.0);\n" \ - "float startmap = (15.0 - lightnum) * 4.0;\n" \ - "float scale = 160.0 / (lightz + 1.0);\n" \ - "return startmap - scale * 0.5;\n" \ - "}\n" - -#define GLSL_DOOM_COLORMAP_walls \ "float R_DoomColormap(float light, float z)\n" \ "{\n" \ "float lightnum = clamp(light / 17.0, 0.0, 15.0);\n" \ @@ -731,7 +710,7 @@ static float shader_leveltime = 0; "float startmap = (15.0 - lightnum) * 4.0;\n" \ "float scale = 160.0 / (lightz + 1.0);\n" \ "float cap = (155.0 - light) * 0.26;\n" \ - "return max(startmap * 1.05 - scale * 0.5 * 2.2, cap);\n" \ + "return max(startmap * STARTMAP_FUDGE - scale * 0.5 * SCALE_FUDGE, cap);\n" \ "}\n" #define GLSL_DOOM_LIGHT_EQUATION \ @@ -781,16 +760,26 @@ static float shader_leveltime = 0; "gl_FragColor = final_color;\n" \ "}\n" +#define GLSL_FLOOR_FUDGES \ + "#define STARTMAP_FUDGE 1.06\n" \ + "#define SCALE_FUDGE 1.15\n" + +#define GLSL_WALL_FUDGES \ + "#define STARTMAP_FUDGE 1.05\n" \ + "#define SCALE_FUDGE 2.2\n" + #define GLSL_SOFTWARE_FRAGMENT_SHADER_FLOORS \ GLSL_SOFTWARE_UNIFORMS \ - GLSL_DOOM_COLORMAP_floors \ + GLSL_FLOOR_FUDGES \ + GLSL_DOOM_COLORMAP \ GLSL_DOOM_LIGHT_EQUATION \ GLSL_SOFTWARE_MAIN \ "\0" #define GLSL_SOFTWARE_FRAGMENT_SHADER_WALLS \ GLSL_SOFTWARE_UNIFORMS \ - GLSL_DOOM_COLORMAP_walls \ + GLSL_WALL_FUDGES \ + GLSL_DOOM_COLORMAP \ GLSL_DOOM_LIGHT_EQUATION \ GLSL_SOFTWARE_MAIN \ "\0" @@ -818,13 +807,15 @@ static float shader_leveltime = 0; #define GLSL_SOFTWARE_PAL_FRAGMENT_SHADER_FLOORS \ GLSL_SOFTWARE_PAL_UNIFORMS \ - GLSL_DOOM_COLORMAP_floors \ + GLSL_FLOOR_FUDGES \ + GLSL_DOOM_COLORMAP \ GLSL_SOFTWARE_PAL_MAIN \ "\0" #define GLSL_SOFTWARE_PAL_FRAGMENT_SHADER_WALLS \ GLSL_SOFTWARE_PAL_UNIFORMS \ - GLSL_DOOM_COLORMAP_walls \ + GLSL_WALL_FUDGES \ + GLSL_DOOM_COLORMAP \ GLSL_SOFTWARE_PAL_MAIN \ "\0" @@ -836,6 +827,7 @@ static float shader_leveltime = 0; // #define GLSL_WATER_FRAGMENT_SHADER \ + GLSL_FLOOR_FUDGES \ "uniform sampler2D tex;\n" \ "uniform vec4 poly_color;\n" \ "uniform vec4 tint_color;\n" \ @@ -865,6 +857,7 @@ static float shader_leveltime = 0; "}\0" #define GLSL_PALETTE_WATER_FRAGMENT_SHADER \ + GLSL_FLOOR_FUDGES \ "const float freq = 0.025;\n" \ "const float amp = 0.025;\n" \ "const float speed = 2.0;\n" \ @@ -876,7 +869,7 @@ static float shader_leveltime = 0; "uniform vec4 poly_color;\n" \ "uniform float lighting;\n" \ "uniform float leveltime;\n" \ - GLSL_DOOM_COLORMAP_floors \ + GLSL_DOOM_COLORMAP \ "void main(void) {\n" \ "float water_z = (gl_FragCoord.z / gl_FragCoord.w) / 2.0;\n" \ "float a = -pi * (water_z * freq) + (leveltime * speed);\n" \ @@ -900,12 +893,13 @@ static float shader_leveltime = 0; // #define GLSL_FOG_FRAGMENT_SHADER \ + GLSL_FLOOR_FUDGES \ "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_floors \ + GLSL_DOOM_COLORMAP \ GLSL_DOOM_LIGHT_EQUATION \ "void main(void) {\n" \ "vec4 base_color = gl_Color;\n" \