From eeed80fe769151bde413c5b5e65d3d25a9ea740d Mon Sep 17 00:00:00 2001 From: Valerie Date: Sat, 4 May 2024 00:33:08 -0400 Subject: [PATCH] added connector option for composite and s-video --- shaders/final.fsh | 19 +++++++++++++++---- shaders/lang/en_US.lang | 4 ++++ shaders/module/aberration.frag | 6 +++--- shaders/module/signal.frag | 9 ++++++++- shaders/shaders.properties | 2 +- shaders/var/signal.glsl | 3 +++ 6 files changed, 34 insertions(+), 9 deletions(-) diff --git a/shaders/final.fsh b/shaders/final.fsh index 6e5a6d8..21331c6 100644 --- a/shaders/final.fsh +++ b/shaders/final.fsh @@ -13,23 +13,34 @@ uniform float viewWidth; #include "/module/aberration.frag" #include "/module/horizontal_blur.frag" #include "/module/scanline.frag" +#include "/module/signal.frag" void main() { vec3 color; + + + // software post-processing effects #ifdef hBlur color = hblur(); #else color = texture2D(gcolor, texcoord).rgb; #endif - #ifdef aberration - color.rb = aberrate().rb; - #endif - #if scanline > 0 color = scanlines(color); #endif + // hardware post-processing effects + #if signal == SIGNAL_NTSC + color = ntsc(color); + #endif + + // physical post-processing effects + #ifdef aberration + color.rb = aberrate(color).rb; + #endif + + gl_FragData[0] = vec4(color, 1); } diff --git a/shaders/lang/en_US.lang b/shaders/lang/en_US.lang index 2b4dfae..79718fc 100644 --- a/shaders/lang/en_US.lang +++ b/shaders/lang/en_US.lang @@ -56,6 +56,10 @@ option.signal=Signal value.signal.0=RGB (Off) value.signal.1=NTSC +option.wire=Connector +value.wire.0=Composite +value.wire.1=S-Video + option.interlacing=Interlacing option.scanline=Scanlines diff --git a/shaders/module/aberration.frag b/shaders/module/aberration.frag index d4b300d..49a1f9e 100644 --- a/shaders/module/aberration.frag +++ b/shaders/module/aberration.frag @@ -1,10 +1,10 @@ vec2 caOffset = vec2(2 * pixelSize / viewWidth, 0); -vec3 aberrate() { +vec3 aberrate(vec3 color) { vec2 offset = caOffset * abs(cos(texcoord * 3.14)); - float red = texture2D(gcolor, texcoord - offset).r; - float blue = texture2D(gcolor, texcoord + offset).b; + float red = color.r; + float blue = color.b; return vec3(red, 0, blue); } diff --git a/shaders/module/signal.frag b/shaders/module/signal.frag index 4c69ef5..7d3db79 100644 --- a/shaders/module/signal.frag +++ b/shaders/module/signal.frag @@ -2,6 +2,7 @@ #include "/var/signal.glsl" #define signal 0 // [0 1] +#define wire 0 // [0 1] vec3 ntsc(vec3 color) { // convert to YIQ @@ -10,11 +11,17 @@ vec3 ntsc(vec3 color) { float q = dot(color, vec3(0.211, -.523, 0.312)); // faux ntsc signal - float carrier = 6.283 * 3.570 * gl_FragCoord.x; + float carrier = 6.283 * 3.570 * gl_FragCoord.x; // 2π * 3.57MHz * x float phase = sin(carrier) * i + cos(carrier) * q; float quad = cos(carrier) * i - sin(carrier) * q; // decode faux signal + #if wire == WIRE_COMPOSITE + float composite = phase + quad + (y * 5.500); // p + q + (y * 5.5MHz) + y = round(composite * 5.500) / 30.250; + phase = composite - quad - (y * 5.500); + quad = composite - phase - (y * 5.500); + #endif i = quad * cos(carrier); q = phase * sin(carrier); diff --git a/shaders/shaders.properties b/shaders/shaders.properties index a18aeb7..c85bc7f 100644 --- a/shaders/shaders.properties +++ b/shaders/shaders.properties @@ -20,7 +20,7 @@ screen.COLOR.columns=3 screen.COLOR=colorMode dithering colorDepth monoPalette hueBits satBits valBits # screen effects -screen.SCREEN=signal interlacing scanline aberration +screen.SCREEN=signal wire interlacing scanline aberration # console effects screen.CONSOLE.columns=1 diff --git a/shaders/var/signal.glsl b/shaders/var/signal.glsl index 866ec50..a2c0e46 100644 --- a/shaders/var/signal.glsl +++ b/shaders/var/signal.glsl @@ -2,3 +2,6 @@ #define SIGNAL_RGB 0 #define SIGNAL_NTSC 1 +#define WIRE_COMPOSITE 0 +#define WIRE_SVIDEO 1 +