From 59a9f24f3a6fea70302a2ee9b1659a0676776e60 Mon Sep 17 00:00:00 2001 From: Valerie Date: Fri, 3 May 2024 22:08:09 -0400 Subject: [PATCH] added 'hard' scanline option --- shaders/final.fsh | 9 +++------ shaders/lang/en_US.lang | 3 +++ shaders/module/scanline.frag | 17 +++++++++++++++++ shaders/var/scanline.glsl | 5 +++++ 4 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 shaders/module/scanline.frag create mode 100644 shaders/var/scanline.glsl diff --git a/shaders/final.fsh b/shaders/final.fsh index d2c3624..6e5a6d8 100644 --- a/shaders/final.fsh +++ b/shaders/final.fsh @@ -4,7 +4,6 @@ //#define aberration //#define hBlur -//#define scanlines varying vec2 texcoord; @@ -13,6 +12,7 @@ uniform float viewWidth; #include "/module/aberration.frag" #include "/module/horizontal_blur.frag" +#include "/module/scanline.frag" void main() { vec3 color; @@ -26,11 +26,8 @@ void main() { color.rb = aberrate().rb; #endif - #ifdef scanlines - if(mod(int(gl_FragCoord.y / (pixelSize * 2)), 2) == 0) - color.rgb *= 0.95; - else - color.rgb /= 0.95; + #if scanline > 0 + color = scanlines(color); #endif gl_FragData[0] = vec4(color, 1); diff --git a/shaders/lang/en_US.lang b/shaders/lang/en_US.lang index e160122..ffe60f4 100644 --- a/shaders/lang/en_US.lang +++ b/shaders/lang/en_US.lang @@ -55,6 +55,9 @@ screen.SCREEN=Screen option.interlacing=Interlacing option.scanlines=Scanlines +value.scanlines.0=Off +value.scanlines.1=Soft +value.scanlines.2=Hard option.aberration=Chromatic Aberration diff --git a/shaders/module/scanline.frag b/shaders/module/scanline.frag new file mode 100644 index 0000000..042acba --- /dev/null +++ b/shaders/module/scanline.frag @@ -0,0 +1,17 @@ + +#include "/var/scanline.glsl" + +#define scanline 0 // [0 1 2] + +public void scanlines() { + #if scanline == SCANLINE_SOFT + if(mod(int(gl_FragCoord.y) / (pixelSize * 2), 2) == 0) + color.rgb *= 0.95; + else + color.rgb /= 0.95; + #elif scanline == SCANLINE_HARD + if(mod(int(gl_FragCoord.y) / (pixelSize * 2), 2) == 0) + color.rgb *= 0.5; + #endif +} + diff --git a/shaders/var/scanline.glsl b/shaders/var/scanline.glsl new file mode 100644 index 0000000..9861367 --- /dev/null +++ b/shaders/var/scanline.glsl @@ -0,0 +1,5 @@ + +#define SCANLINE_SOFT 1 +#define SCANLINE_HARD 2 +#define SCANLINE_STRETCH 3 +