glsl-ntsc-video
modulate and demodulate an ntsc video signal in a shader
compile with glslify
ntsc was a broadcast television standard used in north america, the caribbean, parts of south america, and a few places in east asia and the pacific. ntsc was mostly discontinued in 2009 for over-the-air use but lives on in legacy consumer electronics such as game consoles and vhs tapes made for ntsc regions.
this module has not been tested against an actual ntsc signal, but it can decode its own signals with some fidelity.
example
this example modulates and then demodulates a picture from an image file.
check the example directory for a demo that reads from a visual effect written to framebuffer and then modulated and demodulated.
var glsl =var regl =var fbopts =color: reglcolor: reglvar fbo =reglreglmanifest: picture: type: 'image' src: 'smpte.png'{var draw =modulate:demodulate:var tick = 0;window{reglfbotick%2fboptstick%2drawreglclear color: 0001 depth: truedrawtick++}}
api
#pragma glslify: modulate = require('glsl-ntsc-video/modulate')
#pragma glslify: demodulate = require('glsl-ntsc-video/demodulate')
float signal = modulate(vec2 uv, float n_lines, sampler2D picture)
return the modulated floating point signal
from 0.0
to +1.0
for uv
in unit coordinates
(values from 0 to 1, inclusive) where (0,0)
is the bottom-left. the picture
texture should have
its (0,0)
at the bottom-left too.
n_lines
is the total number of lines (262 or 263).
vec3 rgb = demodulate(uv, vec3(n_lines,width,height), sampler2D signal)
decode a texture signal
with its red channel set as modulated ntsc from 0.0
to +1.0
for
uv
in unit coordinates (values from 0 to 1, inclusive) where (0,0)
is the bottom-left.
n_lines
is the number of lines (262 or 263).
width
and height
are the decoded size of the resulting visual image (use 720,485
).
For higher precision you can use a floating point texture for signal
although in practice it
doesn't appear to make much of a difference.
license
bsd
install
npm install glsl-ntsc-video