created signal effect with NTSC emulation

This commit is contained in:
Valerie Wolfe 2024-05-03 23:58:07 -04:00
parent ac6255175c
commit b73905e8af
5 changed files with 43 additions and 4 deletions

View file

@ -52,6 +52,10 @@ suffix.valBits=-bit
screen.SCREEN=Screen
option.signal=Signal
value.signal.0=RGB (Off)
value.signal.1=NTSC
option.interlacing=Interlacing
option.scanline=Scanlines

View file

@ -0,0 +1,31 @@
#include "/var/signal.glsl"
#define signal 0 // [0 1]
vec3 ntsc(vec3 color) {
// convert to YIQ
float y = dot(color, vec3(0.299, 0.587, 0.114));
float i = dot(color, vec3(0.596, -.274, -.322));
float q = dot(color, vec3(0.211, -.523, 0.312));
// faux ntsc signal
float carrier = 6.283 * 3.570 * gl_FragCoord.x;
float phase = sin(carrier) * i + cos(carrier) * q;
float quad = cos(carrier) * i - sin(carrier) * q;
// decode faux signal
i = quad * cos(carrier);
q = phase * sin(carrier);
// convert back to RGB
vec3 yiqColor = vec3(y, i, q);
vec3 outColor = vec3(0);
outColor.r = dot(yiqColor, vec3(1, 0.956, 0.619));
outColor.g = dot(yiqColor, vec3(1, -.272, -.674));
outColor.b = dot(yiqColor, vec3(1, -1.106, 1.703));
return outColor;
}

View file

@ -20,7 +20,7 @@ screen.COLOR.columns=3
screen.COLOR=colorMode dithering <empty> colorDepth <empty> monoPalette hueBits satBits valBits
# screen effects
screen.SCREEN=interlacing scanline aberration
screen.SCREEN=signal <empty> interlacing scanline aberration
# console effects
screen.CONSOLE.columns=1

View file

@ -1,5 +1,5 @@
#define SCANLINE_SOFT 1
#define SCANLINE_HARD 2
#define SCANLINE_STRETCH 3
#define SCANLINE_SOFT 1
#define SCANLINE_HARD 2
#define SCANLINE_STRETCH 3

4
shaders/var/signal.glsl Normal file
View file

@ -0,0 +1,4 @@
#define SIGNAL_RGB 0
#define SIGNAL_NTSC 1