From 3c8f69c7edd52eda5a6efd50bad2bfbc8627e98f Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Fri, 25 Sep 2020 20:16:44 +0200 Subject: [PATCH] Platform: A bit more fun with the Unreal post-proc shader. The dithering should be done on the surface shader not the fb, but who cares. --- .../glsl/postproc_unreal.glsl | 54 +++++++++---------- .../base_postproc.pk3dir/postproc_dull.cfg | 3 +- .../base_postproc.pk3dir/postproc_none.cfg | 1 + .../postproc_software.cfg | 3 +- .../base_postproc.pk3dir/postproc_unreal.cfg | 3 +- .../base_postproc.pk3dir/postproc_voodoo.cfg | 3 +- 6 files changed, 33 insertions(+), 34 deletions(-) diff --git a/platform/base_postproc.pk3dir/glsl/postproc_unreal.glsl b/platform/base_postproc.pk3dir/glsl/postproc_unreal.glsl index 35184efe..f5836fc9 100755 --- a/platform/base_postproc.pk3dir/glsl/postproc_unreal.glsl +++ b/platform/base_postproc.pk3dir/glsl/postproc_unreal.glsl @@ -38,41 +38,33 @@ void main() #ifdef FRAGMENT_SHADER uniform vec2 e_sourcesize; -// from https://github.com/hughsk/glsl-dither/blob/master/4x4.glsl +// this is the kernel dithering scheme, but applied to the end framebuffer +// like, this really oughta to done on the individual surfaces, but why bother. +// it's just for a bit of fun. vec3 p_dither(vec2 position, vec3 col) { - float brightness = col.r + col.g + col.b / 3.0; - - int x = int(mod(position.x, 4.0)); - int y = int(mod(position.y, 4.0)); - int index = x + y * 4; - float limit = 0.0; + int x = int(mod(position.x, 2.0)); + int y = int(mod(position.y, 2.0)); + int index = x + y * 2; + vec2 coord_ofs; - if (x < 8) { - if (index == 0) limit = 0.0625; - if (index == 1) limit = 0.5625; - if (index == 2) limit = 0.1875; - if (index == 3) limit = 0.6875; - if (index == 4) limit = 0.8125; - if (index == 5) limit = 0.3125; - if (index == 6) limit = 0.9375; - if (index == 7) limit = 0.4375; - if (index == 8) limit = 0.25; - if (index == 9) limit = 0.75; - if (index == 10) limit = 0.125; - if (index == 11) limit = 0.625; - if (index == 12) limit = 1.0; - if (index == 13) limit = 0.5; - if (index == 14) limit = 0.875; - if (index == 15) limit = 0.375; - } + if (index == 0) + coord_ofs = vec2(0.25f, 0.0f); + else if (index == 1) + coord_ofs = vec2(0.50f, 0.75f); + else if (index == 2) + coord_ofs = vec2(0.75f, 0.50f); + else if (index == 3) + coord_ofs = vec2(0.00f, 0.25f); - return col * (brightness < limit ? 0.0 : 1.0); + // -0.003 is the distance intensity, all this is whipped up + return texture2D(s_screen, texcoord + coord_ofs * -0.003).rgb; } +// accentuate the gritty lighting vec3 p_gamma(vec3 col) { - float gamma = 0.75f; + float gamma = 0.85f; col.r = pow(col.r, 1.0 / gamma); col.g = pow(col.g, 1.0 / gamma); col.b = pow(col.b, 1.0 / gamma); @@ -84,13 +76,15 @@ void main(void) vec2 pos = vec2(gl_FragCoord.x, gl_FragCoord.y); vec3 col = texture2D(s_screen, texcoord).rgb; - col = p_gamma(col); + // dither me first + col = p_dither(pos, col); - // dither me - col = mix(col, p_dither(pos, col), 0.5f); + // mess with gamma + col = p_gamma(col); // 16-bit ify col.rgb = floor(col.rgb * vec3(32,64,32))/vec3(32,64,32); + gl_FragColor = vec4(col, 1.0); } #endif diff --git a/platform/base_postproc.pk3dir/postproc_dull.cfg b/platform/base_postproc.pk3dir/postproc_dull.cfg index 1fad4852..f27c1a80 100644 --- a/platform/base_postproc.pk3dir/postproc_dull.cfg +++ b/platform/base_postproc.pk3dir/postproc_dull.cfg @@ -24,7 +24,8 @@ seta r_nolerp 0 // lighting seta r_lightmap 0 -seta r_lightmap_format rgb8 +seta r_lightmap_format rgb565 +seta r_lightmap_saturation 1 seta r_nolightdir 0 seta r_loadlit 1 diff --git a/platform/base_postproc.pk3dir/postproc_none.cfg b/platform/base_postproc.pk3dir/postproc_none.cfg index d8c178be..3ca37678 100644 --- a/platform/base_postproc.pk3dir/postproc_none.cfg +++ b/platform/base_postproc.pk3dir/postproc_none.cfg @@ -25,6 +25,7 @@ seta r_nolerp 0 // lighting seta r_lightmap 0 seta r_lightmap_format rgb9e5 +seta r_lightmap_saturation 1 seta r_nolightdir 0 seta r_loadlit 1 diff --git a/platform/base_postproc.pk3dir/postproc_software.cfg b/platform/base_postproc.pk3dir/postproc_software.cfg index 10ed5a1f..912ffe12 100644 --- a/platform/base_postproc.pk3dir/postproc_software.cfg +++ b/platform/base_postproc.pk3dir/postproc_software.cfg @@ -24,7 +24,8 @@ seta r_nolerp 1 // lighting seta r_lightmap 0 -seta r_lightmap_format rgb8 +seta r_lightmap_format rgb565 +seta r_lightmap_saturation 1 seta r_nolightdir 1 seta r_loadlit 0 diff --git a/platform/base_postproc.pk3dir/postproc_unreal.cfg b/platform/base_postproc.pk3dir/postproc_unreal.cfg index e2349285..34bc08a9 100644 --- a/platform/base_postproc.pk3dir/postproc_unreal.cfg +++ b/platform/base_postproc.pk3dir/postproc_unreal.cfg @@ -25,6 +25,7 @@ seta r_nolerp 1 // lighting seta r_lightmap 0 seta r_lightmap_format rgb9e5 +seta r_lightmap_saturation 2 seta r_nolightdir 0 seta r_loadlit 0 @@ -35,7 +36,7 @@ seta r_renderscale 1 seta r_glsl_offsetmapping 0 seta r_softwarebanding 1 seta r_postprocshader postproc_unreal -seta gl_ldr 0 +seta gl_ldr 1 // 3dfx GL Quake did not bother respecting colormaps, HL doesn't have one seta r_fb_bmodels 1 diff --git a/platform/base_postproc.pk3dir/postproc_voodoo.cfg b/platform/base_postproc.pk3dir/postproc_voodoo.cfg index 7f9c1349..d5b54137 100644 --- a/platform/base_postproc.pk3dir/postproc_voodoo.cfg +++ b/platform/base_postproc.pk3dir/postproc_voodoo.cfg @@ -24,7 +24,8 @@ seta r_nolerp 0 // lighting seta r_lightmap 0 -seta r_lightmap_format rgb8 +seta r_lightmap_format rgb565 +seta r_lightmap_saturation 1 seta r_nolightdir 1 seta r_loadlit 0