mirror of
https://github.com/libretro/glsl-shaders.git
synced 2024-11-23 07:40:29 +00:00
add manual maister ntsc conversion
This commit is contained in:
parent
89c5e1ed3b
commit
0e98e58d67
26
ntsc/ntsc-256px-gauss-scanline.glslp
Normal file
26
ntsc/ntsc-256px-gauss-scanline.glslp
Normal file
@ -0,0 +1,26 @@
|
||||
shaders = 4
|
||||
shader0 = shaders/ntsc-pass1-composite-3phase.glsl
|
||||
shader1 = shaders/ntsc-pass2-3phase.glsl
|
||||
shader2 = shaders/ntsc-gauss-pass.glsl
|
||||
shader3 = shaders/ntsc-stock.glsl
|
||||
|
||||
filter_linear0 = false
|
||||
filter_linear1 = false
|
||||
filter_linear2 = false
|
||||
filter_linear3 = true
|
||||
|
||||
scale_type_x0 = absolute
|
||||
scale_type_y0 = source
|
||||
scale_x0 = 1024
|
||||
scale_y0 = 1.0
|
||||
frame_count_mod0 = 2
|
||||
float_framebuffer0 = true
|
||||
|
||||
scale_type1 = source
|
||||
scale_x1 = 0.5
|
||||
scale_y1 = 1.0
|
||||
|
||||
scale_type_x2 = source
|
||||
scale_type_y2 = viewport
|
||||
scale2 = 1.0
|
||||
|
26
ntsc/ntsc-256px-svideo-gauss-scanline.glslp
Normal file
26
ntsc/ntsc-256px-svideo-gauss-scanline.glslp
Normal file
@ -0,0 +1,26 @@
|
||||
shaders = 4
|
||||
shader0 = shaders/ntsc-pass1-svideo-3phase.glsl
|
||||
shader1 = shaders/ntsc-pass2-3phase.glsl
|
||||
shader2 = shaders/ntsc-gauss-pass.glsl
|
||||
shader3 = shaders/ntsc-stock.glsl
|
||||
|
||||
filter_linear0 = false
|
||||
filter_linear1 = false
|
||||
filter_linear2 = false
|
||||
filter_linear3 = true
|
||||
|
||||
scale_type_x0 = absolute
|
||||
scale_type_y0 = source
|
||||
scale_x0 = 1024
|
||||
scale_y0 = 1.0
|
||||
frame_count_mod0 = 2
|
||||
float_framebuffer0 = true
|
||||
|
||||
scale_type1 = source
|
||||
scale_x1 = 0.5
|
||||
scale_y1 = 1.0
|
||||
|
||||
scale_type_x2 = source
|
||||
scale_type_y2 = viewport
|
||||
scale2 = 1.0
|
||||
|
18
ntsc/ntsc-256px-svideo.glslp
Normal file
18
ntsc/ntsc-256px-svideo.glslp
Normal file
@ -0,0 +1,18 @@
|
||||
shaders = 2
|
||||
shader0 = shaders/ntsc-pass1-svideo-3phase.glsl
|
||||
shader1 = shaders/ntsc-pass2-3phase-gamma.glsl
|
||||
|
||||
filter_linear0 = false
|
||||
filter_linear1 = false
|
||||
|
||||
scale_type_x0 = absolute
|
||||
scale_type_y0 = source
|
||||
scale_x0 = 1024
|
||||
scale_y0 = 1.0
|
||||
frame_count_mod0 = 2
|
||||
float_framebuffer0 = true
|
||||
|
||||
scale_type1 = source
|
||||
scale_x1 = 0.5
|
||||
scale_y1 = 1.0
|
||||
|
18
ntsc/ntsc-256px.glslp
Normal file
18
ntsc/ntsc-256px.glslp
Normal file
@ -0,0 +1,18 @@
|
||||
shaders = 2
|
||||
shader0 = shaders/ntsc-pass1-composite-3phase.glsl
|
||||
shader1 = shaders/ntsc-pass2-3phase-gamma.glsl
|
||||
|
||||
filter_linear0 = false
|
||||
filter_linear1 = false
|
||||
|
||||
scale_type_x0 = absolute
|
||||
scale_type_y0 = source
|
||||
scale_x0 = 1024
|
||||
scale_y0 = 1.0
|
||||
frame_count_mod0 = 2
|
||||
float_framebuffer0 = true
|
||||
|
||||
scale_type1 = source
|
||||
scale_x1 = 0.5
|
||||
scale_y1 = 1.0
|
||||
|
26
ntsc/ntsc-320px-gauss-scanline.glslp
Normal file
26
ntsc/ntsc-320px-gauss-scanline.glslp
Normal file
@ -0,0 +1,26 @@
|
||||
shaders = 4
|
||||
shader0 = shaders/ntsc-pass1-composite-2phase.glsl
|
||||
shader1 = shaders/ntsc-pass2-2phase.glsl
|
||||
shader2 = shaders/ntsc-gauss-pass.glsl
|
||||
shader3 = shaders/ntsc-stock.glsl
|
||||
|
||||
filter_linear0 = false
|
||||
filter_linear1 = false
|
||||
filter_linear2 = false
|
||||
filter_linear3 = true
|
||||
|
||||
scale_type_x0 = absolute
|
||||
scale_type_y0 = source
|
||||
scale_x0 = 1280
|
||||
scale_y0 = 1.0
|
||||
frame_count_mod0 = 2
|
||||
float_framebuffer0 = true
|
||||
|
||||
scale_type1 = source
|
||||
scale_x1 = 0.5
|
||||
scale_y1 = 1.0
|
||||
|
||||
scale_type_x2 = source
|
||||
scale_type_y2 = viewport
|
||||
scale2 = 1.0
|
||||
|
26
ntsc/ntsc-320px-svideo-gauss-scanline.glslp
Normal file
26
ntsc/ntsc-320px-svideo-gauss-scanline.glslp
Normal file
@ -0,0 +1,26 @@
|
||||
shaders = 4
|
||||
shader0 = shaders/ntsc-pass1-svideo-2phase.glsl
|
||||
shader1 = shaders/ntsc-pass2-2phase.glsl
|
||||
shader2 = shaders/ntsc-gauss-pass.glsl
|
||||
shader3 = shaders/ntsc-stock.glsl
|
||||
|
||||
filter_linear0 = false
|
||||
filter_linear1 = false
|
||||
filter_linear2 = false
|
||||
filter_linear3 = true
|
||||
|
||||
scale_type_x0 = absolute
|
||||
scale_type_y0 = source
|
||||
scale_x0 = 1280
|
||||
scale_y0 = 1.0
|
||||
frame_count_mod0 = 2
|
||||
float_framebuffer0 = true
|
||||
|
||||
scale_type1 = source
|
||||
scale_x1 = 0.5
|
||||
scale_y1 = 1.0
|
||||
|
||||
scale_type_x2 = source
|
||||
scale_type_y2 = viewport
|
||||
scale2 = 1.0
|
||||
|
18
ntsc/ntsc-320px-svideo.glslp
Normal file
18
ntsc/ntsc-320px-svideo.glslp
Normal file
@ -0,0 +1,18 @@
|
||||
shaders = 2
|
||||
shader0 = shaders/ntsc-pass1-svideo-2phase.glsl
|
||||
shader1 = shaders/ntsc-pass2-2phase-gamma.glsl
|
||||
|
||||
filter_linear0 = false
|
||||
filter_linear1 = false
|
||||
|
||||
scale_type_x0 = absolute
|
||||
scale_type_y0 = source
|
||||
scale_x0 = 1280
|
||||
scale_y0 = 1.0
|
||||
frame_count_mod0 = 2
|
||||
float_framebuffer0 = true
|
||||
|
||||
scale_type1 = source
|
||||
scale_x1 = 0.5
|
||||
scale_y1 = 1.0
|
||||
|
18
ntsc/ntsc-320px.glslp
Normal file
18
ntsc/ntsc-320px.glslp
Normal file
@ -0,0 +1,18 @@
|
||||
shaders = 2
|
||||
shader0 = shaders/ntsc-pass1-composite-2phase.glsl
|
||||
shader1 = shaders/ntsc-pass2-2phase-gamma.glsl
|
||||
|
||||
filter_linear0 = false
|
||||
filter_linear1 = false
|
||||
|
||||
scale_type_x0 = absolute
|
||||
scale_type_y0 = source
|
||||
scale_x0 = 1280
|
||||
scale_y0 = 1.0
|
||||
frame_count_mod0 = 2
|
||||
float_framebuffer0 = true
|
||||
|
||||
scale_type1 = source
|
||||
scale_x1 = 0.5
|
||||
scale_y1 = 1.0
|
||||
|
25
ntsc/ntsc-svideo.glslp
Normal file
25
ntsc/ntsc-svideo.glslp
Normal file
@ -0,0 +1,25 @@
|
||||
shaders = 4
|
||||
shader0 = shaders/ntsc-pass1-composite-3phase.glsl
|
||||
shader1 = shaders/ntsc-pass2-3phase.glsl
|
||||
shader2 = shaders/ntsc-gauss-pass.glsl
|
||||
shader3 = shaders/ntsc-stock.glsl
|
||||
|
||||
filter_linear0 = false
|
||||
filter_linear1 = false
|
||||
filter_linear2 = false
|
||||
filter_linear3 = true
|
||||
|
||||
scale_type0 = source
|
||||
scale_x0 = 4.0
|
||||
scale_y0 = 1.0
|
||||
frame_count_mod0 = 2
|
||||
float_framebuffer0 = true
|
||||
|
||||
scale_type1 = source
|
||||
scale_x1 = 0.5
|
||||
scale_y1 = 1.0
|
||||
|
||||
scale_type_x2 = source
|
||||
scale_type_y2 = viewport
|
||||
scale2 = 1.0
|
||||
|
25
ntsc/ntsc.glslp
Normal file
25
ntsc/ntsc.glslp
Normal file
@ -0,0 +1,25 @@
|
||||
shaders = 4
|
||||
shader0 = shaders/ntsc-pass1-composite-3phase.glsl
|
||||
shader1 = shaders/ntsc-pass2-3phase.glsl
|
||||
shader2 = shaders/ntsc-gauss-pass.glsl
|
||||
shader3 = shaders/ntsc-stock.glsl
|
||||
|
||||
filter_linear0 = false
|
||||
filter_linear1 = false
|
||||
filter_linear2 = false
|
||||
filter_linear3 = true
|
||||
|
||||
scale_type0 = source
|
||||
scale_x0 = 4.0
|
||||
scale_y0 = 1.0
|
||||
frame_count_mod0 = 2
|
||||
float_framebuffer0 = true
|
||||
|
||||
scale_type1 = source
|
||||
scale_x1 = 0.5
|
||||
scale_y1 = 1.0
|
||||
|
||||
scale_type_x2 = source
|
||||
scale_type_y2 = viewport
|
||||
scale2 = 1.0
|
||||
|
132
ntsc/shaders/ntsc-gauss-pass.glsl
Normal file
132
ntsc/shaders/ntsc-gauss-pass.glsl
Normal file
@ -0,0 +1,132 @@
|
||||
// Compatibility #ifdefs needed for parameters
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
// Parameter lines go here:
|
||||
#pragma parameter NTSC_CRT_GAMMA "NTSC CRT Gamma" 2.5 0.0 10.0 0.1
|
||||
#pragma parameter NTSC_DISPLAY_GAMMA "NTSC Display Gamma" 2.1 0.0 10.0 0.1
|
||||
#ifdef PARAMETER_UNIFORM
|
||||
// All parameter floats need to have COMPAT_PRECISION in front of them
|
||||
uniform COMPAT_PRECISION float NTSC_CRT_GAMMA;
|
||||
uniform COMPAT_PRECISION float NTSC_DISPLAY_GAMMA;
|
||||
#else
|
||||
#define NTSC_CRT_GAMMA 2.5
|
||||
#define NTSC_DISPLAY_GAMMA 2.1
|
||||
#endif
|
||||
|
||||
#if defined(VERTEX)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING out
|
||||
#define COMPAT_ATTRIBUTE in
|
||||
#define COMPAT_TEXTURE texture
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define COMPAT_ATTRIBUTE attribute
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
COMPAT_ATTRIBUTE vec4 VertexCoord;
|
||||
COMPAT_ATTRIBUTE vec4 COLOR;
|
||||
COMPAT_ATTRIBUTE vec4 TexCoord;
|
||||
COMPAT_VARYING vec4 COL0;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
COMPAT_VARYING vec2 one;
|
||||
COMPAT_VARYING vec2 pix_no;
|
||||
|
||||
uniform mat4 MVPMatrix;
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
|
||||
// vertex compatibility #defines
|
||||
#define vTexCoord TEX0.xy
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = MVPMatrix * VertexCoord;
|
||||
COL0 = COLOR;
|
||||
TEX0.xy = TexCoord.xy;
|
||||
pix_no = vTexCoord * SourceSize.xy;
|
||||
one = 1.0 / SourceSize.xy;
|
||||
}
|
||||
|
||||
#elif defined(FRAGMENT)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING in
|
||||
#define COMPAT_TEXTURE texture
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define FragColor gl_FragColor
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||||
precision highp float;
|
||||
#else
|
||||
precision mediump float;
|
||||
#endif
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
uniform sampler2D Texture;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
COMPAT_VARYING vec2 one;
|
||||
COMPAT_VARYING vec2 pix_no;
|
||||
|
||||
// fragment compatibility #defines
|
||||
#define Source Texture
|
||||
#define vTexCoord TEX0.xy
|
||||
#define texture(c, d) COMPAT_TEXTURE(c, d)
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
#define TEX(off) pow(texture(Source, vTexCoord + vec2(0.0, (off) * one.y)).rgb, vec3(NTSC_CRT_GAMMA))
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 frame0 = TEX(-2.0);
|
||||
vec3 frame1 = TEX(-1.0);
|
||||
vec3 frame2 = TEX(0.0);
|
||||
vec3 frame3 = TEX(1.0);
|
||||
vec3 frame4 = TEX(2.0);
|
||||
|
||||
float offset_dist = fract(pix_no.y) - 0.5;
|
||||
float dist0 = 2.0 + offset_dist;
|
||||
float dist1 = 1.0 + offset_dist;
|
||||
float dist2 = 0.0 + offset_dist;
|
||||
float dist3 = -1.0 + offset_dist;
|
||||
float dist4 = -2.0 + offset_dist;
|
||||
|
||||
vec3 scanline = frame0 * exp(-5.0 * dist0 * dist0);
|
||||
scanline += frame1 * exp(-5.0 * dist1 * dist1);
|
||||
scanline += frame2 * exp(-5.0 * dist2 * dist2);
|
||||
scanline += frame3 * exp(-5.0 * dist3 * dist3);
|
||||
scanline += frame4 * exp(-5.0 * dist4 * dist4);
|
||||
|
||||
FragColor = vec4(pow(1.15 * scanline, vec3(1.0 / NTSC_DISPLAY_GAMMA)), 1.0);
|
||||
}
|
||||
#endif
|
174
ntsc/shaders/ntsc-pass1-composite-2phase.glsl
Normal file
174
ntsc/shaders/ntsc-pass1-composite-2phase.glsl
Normal file
@ -0,0 +1,174 @@
|
||||
// Compatibility #ifdefs needed for parameters
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
#define TWO_PHASE
|
||||
#define COMPOSITE
|
||||
|
||||
// begin params
|
||||
#define PI 3.14159265
|
||||
|
||||
#if defined(TWO_PHASE)
|
||||
#define CHROMA_MOD_FREQ (4.0 * PI / 15.0)
|
||||
#elif defined(THREE_PHASE)
|
||||
#define CHROMA_MOD_FREQ (PI / 3.0)
|
||||
#endif
|
||||
|
||||
#if defined(COMPOSITE)
|
||||
#define SATURATION 1.0
|
||||
#define BRIGHTNESS 1.0
|
||||
#define ARTIFACTING 1.0
|
||||
#define FRINGING 1.0
|
||||
#elif defined(SVIDEO)
|
||||
#define SATURATION 1.0
|
||||
#define BRIGHTNESS 1.0
|
||||
#define ARTIFACTING 0.0
|
||||
#define FRINGING 0.0
|
||||
#endif
|
||||
|
||||
#if defined(COMPOSITE) || defined(SVIDEO)
|
||||
mat3 mix_mat = mat3(
|
||||
BRIGHTNESS, FRINGING, FRINGING,
|
||||
ARTIFACTING, 2.0 * SATURATION, 0.0,
|
||||
ARTIFACTING, 0.0, 2.0 * SATURATION
|
||||
);
|
||||
#endif
|
||||
// end params
|
||||
|
||||
// begin ntsc-rgbyuv
|
||||
mat3 yiq2rgb_mat = mat3(
|
||||
1.0, 1.0, 1.0,
|
||||
0.956, -0.2720, -1.1060,
|
||||
0.6210, -0.6474, 1.7046
|
||||
);
|
||||
|
||||
vec3 yiq2rgb(vec3 yiq)
|
||||
{
|
||||
return (yiq * yiq2rgb_mat);
|
||||
}
|
||||
|
||||
mat3 yiq_mat = mat3(
|
||||
0.2989, 0.5959, 0.2115,
|
||||
0.5870, -0.2744, -0.5229,
|
||||
0.1140, -0.3216, 0.3114
|
||||
);
|
||||
|
||||
vec3 rgb2yiq(vec3 col)
|
||||
{
|
||||
return (col * yiq_mat);
|
||||
}
|
||||
// end ntsc-rgbyuv
|
||||
|
||||
#if defined(VERTEX)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING out
|
||||
#define COMPAT_ATTRIBUTE in
|
||||
#define COMPAT_TEXTURE texture
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define COMPAT_ATTRIBUTE attribute
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
COMPAT_ATTRIBUTE vec4 VertexCoord;
|
||||
COMPAT_ATTRIBUTE vec4 COLOR;
|
||||
COMPAT_ATTRIBUTE vec4 TexCoord;
|
||||
COMPAT_VARYING vec4 COL0;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
COMPAT_VARYING vec2 pix_no;
|
||||
|
||||
uniform mat4 MVPMatrix;
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
|
||||
// vertex compatibility #defines
|
||||
#define vTexCoord TEX0.xy
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = MVPMatrix * VertexCoord;
|
||||
COL0 = COLOR;
|
||||
TEX0.xy = TexCoord.xy;
|
||||
pix_no = vTexCoord * SourceSize.xy * (OutputSize.xy / InputSize.xy);
|
||||
}
|
||||
|
||||
#elif defined(FRAGMENT)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING in
|
||||
#define COMPAT_TEXTURE texture
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define FragColor gl_FragColor
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||||
precision highp float;
|
||||
#else
|
||||
precision mediump float;
|
||||
#endif
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
uniform sampler2D Texture;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
COMPAT_VARYING vec2 pix_no;
|
||||
|
||||
// fragment compatibility #defines
|
||||
#define Source Texture
|
||||
#define vTexCoord TEX0.xy
|
||||
#define texture(c, d) COMPAT_TEXTURE(c, d)
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
// delete all 'params.' or 'registers.' or whatever in the fragment
|
||||
|
||||
void main()
|
||||
{
|
||||
//#ifdef ntsc-pass1-demodulate-encode
|
||||
vec3 col = texture(Source, vTexCoord).rgb;
|
||||
vec3 yiq = rgb2yiq(col);
|
||||
|
||||
#if defined(TWO_PHASE)
|
||||
float chroma_phase = PI * (mod(pix_no.y, 2.0) + FrameCount);
|
||||
#elif defined(THREE_PHASE)
|
||||
float chroma_phase = 0.6667 * PI * (mod(pix_no.y, 3.0) + FrameCount);
|
||||
#endif
|
||||
|
||||
float mod_phase = chroma_phase + pix_no.x * CHROMA_MOD_FREQ;
|
||||
|
||||
float i_mod = cos(mod_phase);
|
||||
float q_mod = sin(mod_phase);
|
||||
|
||||
yiq.yz *= vec2(i_mod, q_mod); // Modulate.
|
||||
yiq *= mix_mat; // Cross-talk.
|
||||
yiq.yz *= vec2(i_mod, q_mod); // Demodulate.
|
||||
FragColor = vec4(yiq, 1.0);
|
||||
//#endif
|
||||
}
|
||||
#endif
|
174
ntsc/shaders/ntsc-pass1-composite-3phase.glsl
Normal file
174
ntsc/shaders/ntsc-pass1-composite-3phase.glsl
Normal file
@ -0,0 +1,174 @@
|
||||
// Compatibility #ifdefs needed for parameters
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
#define THREE_PHASE
|
||||
#define COMPOSITE
|
||||
|
||||
// begin params
|
||||
#define PI 3.14159265
|
||||
|
||||
#if defined(TWO_PHASE)
|
||||
#define CHROMA_MOD_FREQ (4.0 * PI / 15.0)
|
||||
#elif defined(THREE_PHASE)
|
||||
#define CHROMA_MOD_FREQ (PI / 3.0)
|
||||
#endif
|
||||
|
||||
#if defined(COMPOSITE)
|
||||
#define SATURATION 1.0
|
||||
#define BRIGHTNESS 1.0
|
||||
#define ARTIFACTING 1.0
|
||||
#define FRINGING 1.0
|
||||
#elif defined(SVIDEO)
|
||||
#define SATURATION 1.0
|
||||
#define BRIGHTNESS 1.0
|
||||
#define ARTIFACTING 0.0
|
||||
#define FRINGING 0.0
|
||||
#endif
|
||||
|
||||
#if defined(COMPOSITE) || defined(SVIDEO)
|
||||
mat3 mix_mat = mat3(
|
||||
BRIGHTNESS, FRINGING, FRINGING,
|
||||
ARTIFACTING, 2.0 * SATURATION, 0.0,
|
||||
ARTIFACTING, 0.0, 2.0 * SATURATION
|
||||
);
|
||||
#endif
|
||||
// end params
|
||||
|
||||
// begin ntsc-rgbyuv
|
||||
mat3 yiq2rgb_mat = mat3(
|
||||
1.0, 1.0, 1.0,
|
||||
0.956, -0.2720, -1.1060,
|
||||
0.6210, -0.6474, 1.7046
|
||||
);
|
||||
|
||||
vec3 yiq2rgb(vec3 yiq)
|
||||
{
|
||||
return (yiq * yiq2rgb_mat);
|
||||
}
|
||||
|
||||
mat3 yiq_mat = mat3(
|
||||
0.2989, 0.5959, 0.2115,
|
||||
0.5870, -0.2744, -0.5229,
|
||||
0.1140, -0.3216, 0.3114
|
||||
);
|
||||
|
||||
vec3 rgb2yiq(vec3 col)
|
||||
{
|
||||
return (col * yiq_mat);
|
||||
}
|
||||
// end ntsc-rgbyuv
|
||||
|
||||
#if defined(VERTEX)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING out
|
||||
#define COMPAT_ATTRIBUTE in
|
||||
#define COMPAT_TEXTURE texture
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define COMPAT_ATTRIBUTE attribute
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
COMPAT_ATTRIBUTE vec4 VertexCoord;
|
||||
COMPAT_ATTRIBUTE vec4 COLOR;
|
||||
COMPAT_ATTRIBUTE vec4 TexCoord;
|
||||
COMPAT_VARYING vec4 COL0;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
COMPAT_VARYING vec2 pix_no;
|
||||
|
||||
uniform mat4 MVPMatrix;
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
|
||||
// vertex compatibility #defines
|
||||
#define vTexCoord TEX0.xy
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = MVPMatrix * VertexCoord;
|
||||
COL0 = COLOR;
|
||||
TEX0.xy = TexCoord.xy;
|
||||
pix_no = vTexCoord * SourceSize.xy * (OutputSize.xy / InputSize.xy);
|
||||
}
|
||||
|
||||
#elif defined(FRAGMENT)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING in
|
||||
#define COMPAT_TEXTURE texture
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define FragColor gl_FragColor
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||||
precision highp float;
|
||||
#else
|
||||
precision mediump float;
|
||||
#endif
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
uniform sampler2D Texture;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
COMPAT_VARYING vec2 pix_no;
|
||||
|
||||
// fragment compatibility #defines
|
||||
#define Source Texture
|
||||
#define vTexCoord TEX0.xy
|
||||
#define texture(c, d) COMPAT_TEXTURE(c, d)
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
// delete all 'params.' or 'registers.' or whatever in the fragment
|
||||
|
||||
void main()
|
||||
{
|
||||
//#ifdef ntsc-pass1-demodulate-encode
|
||||
vec3 col = texture(Source, vTexCoord).rgb;
|
||||
vec3 yiq = rgb2yiq(col);
|
||||
|
||||
#if defined(TWO_PHASE)
|
||||
float chroma_phase = PI * (mod(pix_no.y, 2.0) + FrameCount);
|
||||
#elif defined(THREE_PHASE)
|
||||
float chroma_phase = 0.6667 * PI * (mod(pix_no.y, 3.0) + FrameCount);
|
||||
#endif
|
||||
|
||||
float mod_phase = chroma_phase + pix_no.x * CHROMA_MOD_FREQ;
|
||||
|
||||
float i_mod = cos(mod_phase);
|
||||
float q_mod = sin(mod_phase);
|
||||
|
||||
yiq.yz *= vec2(i_mod, q_mod); // Modulate.
|
||||
yiq *= mix_mat; // Cross-talk.
|
||||
yiq.yz *= vec2(i_mod, q_mod); // Demodulate.
|
||||
FragColor = vec4(yiq, 1.0);
|
||||
//#endif
|
||||
}
|
||||
#endif
|
174
ntsc/shaders/ntsc-pass1-svideo-2phase.glsl
Normal file
174
ntsc/shaders/ntsc-pass1-svideo-2phase.glsl
Normal file
@ -0,0 +1,174 @@
|
||||
// Compatibility #ifdefs needed for parameters
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
#define TWO_PHASE
|
||||
#define SVIDEO
|
||||
|
||||
// begin params
|
||||
#define PI 3.14159265
|
||||
|
||||
#if defined(TWO_PHASE)
|
||||
#define CHROMA_MOD_FREQ (4.0 * PI / 15.0)
|
||||
#elif defined(THREE_PHASE)
|
||||
#define CHROMA_MOD_FREQ (PI / 3.0)
|
||||
#endif
|
||||
|
||||
#if defined(COMPOSITE)
|
||||
#define SATURATION 1.0
|
||||
#define BRIGHTNESS 1.0
|
||||
#define ARTIFACTING 1.0
|
||||
#define FRINGING 1.0
|
||||
#elif defined(SVIDEO)
|
||||
#define SATURATION 1.0
|
||||
#define BRIGHTNESS 1.0
|
||||
#define ARTIFACTING 0.0
|
||||
#define FRINGING 0.0
|
||||
#endif
|
||||
|
||||
#if defined(COMPOSITE) || defined(SVIDEO)
|
||||
mat3 mix_mat = mat3(
|
||||
BRIGHTNESS, FRINGING, FRINGING,
|
||||
ARTIFACTING, 2.0 * SATURATION, 0.0,
|
||||
ARTIFACTING, 0.0, 2.0 * SATURATION
|
||||
);
|
||||
#endif
|
||||
// end params
|
||||
|
||||
// begin ntsc-rgbyuv
|
||||
mat3 yiq2rgb_mat = mat3(
|
||||
1.0, 1.0, 1.0,
|
||||
0.956, -0.2720, -1.1060,
|
||||
0.6210, -0.6474, 1.7046
|
||||
);
|
||||
|
||||
vec3 yiq2rgb(vec3 yiq)
|
||||
{
|
||||
return (yiq * yiq2rgb_mat);
|
||||
}
|
||||
|
||||
mat3 yiq_mat = mat3(
|
||||
0.2989, 0.5959, 0.2115,
|
||||
0.5870, -0.2744, -0.5229,
|
||||
0.1140, -0.3216, 0.3114
|
||||
);
|
||||
|
||||
vec3 rgb2yiq(vec3 col)
|
||||
{
|
||||
return (col * yiq_mat);
|
||||
}
|
||||
// end ntsc-rgbyuv
|
||||
|
||||
#if defined(VERTEX)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING out
|
||||
#define COMPAT_ATTRIBUTE in
|
||||
#define COMPAT_TEXTURE texture
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define COMPAT_ATTRIBUTE attribute
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
COMPAT_ATTRIBUTE vec4 VertexCoord;
|
||||
COMPAT_ATTRIBUTE vec4 COLOR;
|
||||
COMPAT_ATTRIBUTE vec4 TexCoord;
|
||||
COMPAT_VARYING vec4 COL0;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
COMPAT_VARYING vec2 pix_no;
|
||||
|
||||
uniform mat4 MVPMatrix;
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
|
||||
// vertex compatibility #defines
|
||||
#define vTexCoord TEX0.xy
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = MVPMatrix * VertexCoord;
|
||||
COL0 = COLOR;
|
||||
TEX0.xy = TexCoord.xy;
|
||||
pix_no = vTexCoord * SourceSize.xy * (OutputSize.xy / InputSize.xy);
|
||||
}
|
||||
|
||||
#elif defined(FRAGMENT)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING in
|
||||
#define COMPAT_TEXTURE texture
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define FragColor gl_FragColor
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||||
precision highp float;
|
||||
#else
|
||||
precision mediump float;
|
||||
#endif
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
uniform sampler2D Texture;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
COMPAT_VARYING vec2 pix_no;
|
||||
|
||||
// fragment compatibility #defines
|
||||
#define Source Texture
|
||||
#define vTexCoord TEX0.xy
|
||||
#define texture(c, d) COMPAT_TEXTURE(c, d)
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
// delete all 'params.' or 'registers.' or whatever in the fragment
|
||||
|
||||
void main()
|
||||
{
|
||||
//#ifdef ntsc-pass1-demodulate-encode
|
||||
vec3 col = texture(Source, vTexCoord).rgb;
|
||||
vec3 yiq = rgb2yiq(col);
|
||||
|
||||
#if defined(TWO_PHASE)
|
||||
float chroma_phase = PI * (mod(pix_no.y, 2.0) + FrameCount);
|
||||
#elif defined(THREE_PHASE)
|
||||
float chroma_phase = 0.6667 * PI * (mod(pix_no.y, 3.0) + FrameCount);
|
||||
#endif
|
||||
|
||||
float mod_phase = chroma_phase + pix_no.x * CHROMA_MOD_FREQ;
|
||||
|
||||
float i_mod = cos(mod_phase);
|
||||
float q_mod = sin(mod_phase);
|
||||
|
||||
yiq.yz *= vec2(i_mod, q_mod); // Modulate.
|
||||
yiq *= mix_mat; // Cross-talk.
|
||||
yiq.yz *= vec2(i_mod, q_mod); // Demodulate.
|
||||
FragColor = vec4(yiq, 1.0);
|
||||
//#endif
|
||||
}
|
||||
#endif
|
174
ntsc/shaders/ntsc-pass1-svideo-3phase.glsl
Normal file
174
ntsc/shaders/ntsc-pass1-svideo-3phase.glsl
Normal file
@ -0,0 +1,174 @@
|
||||
// Compatibility #ifdefs needed for parameters
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
#define THREE_PHASE
|
||||
#define SVIDEO
|
||||
|
||||
// begin params
|
||||
#define PI 3.14159265
|
||||
|
||||
#if defined(TWO_PHASE)
|
||||
#define CHROMA_MOD_FREQ (4.0 * PI / 15.0)
|
||||
#elif defined(THREE_PHASE)
|
||||
#define CHROMA_MOD_FREQ (PI / 3.0)
|
||||
#endif
|
||||
|
||||
#if defined(COMPOSITE)
|
||||
#define SATURATION 1.0
|
||||
#define BRIGHTNESS 1.0
|
||||
#define ARTIFACTING 1.0
|
||||
#define FRINGING 1.0
|
||||
#elif defined(SVIDEO)
|
||||
#define SATURATION 1.0
|
||||
#define BRIGHTNESS 1.0
|
||||
#define ARTIFACTING 0.0
|
||||
#define FRINGING 0.0
|
||||
#endif
|
||||
|
||||
#if defined(COMPOSITE) || defined(SVIDEO)
|
||||
mat3 mix_mat = mat3(
|
||||
BRIGHTNESS, FRINGING, FRINGING,
|
||||
ARTIFACTING, 2.0 * SATURATION, 0.0,
|
||||
ARTIFACTING, 0.0, 2.0 * SATURATION
|
||||
);
|
||||
#endif
|
||||
// end params
|
||||
|
||||
// begin ntsc-rgbyuv
|
||||
mat3 yiq2rgb_mat = mat3(
|
||||
1.0, 1.0, 1.0,
|
||||
0.956, -0.2720, -1.1060,
|
||||
0.6210, -0.6474, 1.7046
|
||||
);
|
||||
|
||||
vec3 yiq2rgb(vec3 yiq)
|
||||
{
|
||||
return (yiq * yiq2rgb_mat);
|
||||
}
|
||||
|
||||
mat3 yiq_mat = mat3(
|
||||
0.2989, 0.5959, 0.2115,
|
||||
0.5870, -0.2744, -0.5229,
|
||||
0.1140, -0.3216, 0.3114
|
||||
);
|
||||
|
||||
vec3 rgb2yiq(vec3 col)
|
||||
{
|
||||
return (col * yiq_mat);
|
||||
}
|
||||
// end ntsc-rgbyuv
|
||||
|
||||
#if defined(VERTEX)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING out
|
||||
#define COMPAT_ATTRIBUTE in
|
||||
#define COMPAT_TEXTURE texture
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define COMPAT_ATTRIBUTE attribute
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
COMPAT_ATTRIBUTE vec4 VertexCoord;
|
||||
COMPAT_ATTRIBUTE vec4 COLOR;
|
||||
COMPAT_ATTRIBUTE vec4 TexCoord;
|
||||
COMPAT_VARYING vec4 COL0;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
COMPAT_VARYING vec2 pix_no;
|
||||
|
||||
uniform mat4 MVPMatrix;
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
|
||||
// vertex compatibility #defines
|
||||
#define vTexCoord TEX0.xy
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = MVPMatrix * VertexCoord;
|
||||
COL0 = COLOR;
|
||||
TEX0.xy = TexCoord.xy;
|
||||
pix_no = vTexCoord * SourceSize.xy * (OutputSize.xy / InputSize.xy);
|
||||
}
|
||||
|
||||
#elif defined(FRAGMENT)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING in
|
||||
#define COMPAT_TEXTURE texture
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define FragColor gl_FragColor
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||||
precision highp float;
|
||||
#else
|
||||
precision mediump float;
|
||||
#endif
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
uniform sampler2D Texture;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
COMPAT_VARYING vec2 pix_no;
|
||||
|
||||
// fragment compatibility #defines
|
||||
#define Source Texture
|
||||
#define vTexCoord TEX0.xy
|
||||
#define texture(c, d) COMPAT_TEXTURE(c, d)
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
// delete all 'params.' or 'registers.' or whatever in the fragment
|
||||
|
||||
void main()
|
||||
{
|
||||
//#ifdef ntsc-pass1-demodulate-encode
|
||||
vec3 col = texture(Source, vTexCoord).rgb;
|
||||
vec3 yiq = rgb2yiq(col);
|
||||
|
||||
#if defined(TWO_PHASE)
|
||||
float chroma_phase = PI * (mod(pix_no.y, 2.0) + FrameCount);
|
||||
#elif defined(THREE_PHASE)
|
||||
float chroma_phase = 0.6667 * PI * (mod(pix_no.y, 3.0) + FrameCount);
|
||||
#endif
|
||||
|
||||
float mod_phase = chroma_phase + pix_no.x * CHROMA_MOD_FREQ;
|
||||
|
||||
float i_mod = cos(mod_phase);
|
||||
float q_mod = sin(mod_phase);
|
||||
|
||||
yiq.yz *= vec2(i_mod, q_mod); // Modulate.
|
||||
yiq *= mix_mat; // Cross-talk.
|
||||
yiq.yz *= vec2(i_mod, q_mod); // Demodulate.
|
||||
FragColor = vec4(yiq, 1.0);
|
||||
//#endif
|
||||
}
|
||||
#endif
|
485
ntsc/shaders/ntsc-pass2-2phase-gamma.glsl
Normal file
485
ntsc/shaders/ntsc-pass2-2phase-gamma.glsl
Normal file
@ -0,0 +1,485 @@
|
||||
// Compatibility #ifdefs needed for parameters
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
#define NTSC_CRT_GAMMA 2.5
|
||||
#define NTSC_MONITOR_GAMMA 2.0
|
||||
|
||||
// begin ntsc-rgbyuv
|
||||
mat3 yiq2rgb_mat = mat3(
|
||||
1.0, 1.0, 1.0,
|
||||
0.956, -0.2720, -1.1060,
|
||||
0.6210, -0.6474, 1.7046
|
||||
);
|
||||
|
||||
vec3 yiq2rgb(vec3 yiq)
|
||||
{
|
||||
return (yiq * yiq2rgb_mat);
|
||||
}
|
||||
|
||||
mat3 yiq_mat = mat3(
|
||||
0.2989, 0.5959, 0.2115,
|
||||
0.5870, -0.2744, -0.5229,
|
||||
0.1140, -0.3216, 0.3114
|
||||
);
|
||||
|
||||
vec3 rgb2yiq(vec3 col)
|
||||
{
|
||||
return (col * yiq_mat);
|
||||
}
|
||||
// end ntsc-rgbyuv
|
||||
#define test
|
||||
// begin ntsc-decode-filter-3phase
|
||||
#ifdef test//GL_ES
|
||||
float luma_filter1 = -0.000174844;
|
||||
float luma_filter2 = -0.000205844;
|
||||
float luma_filter3 = -0.000149453;
|
||||
float luma_filter4 = -0.000051693;
|
||||
float luma_filter5 = 0.000000000;
|
||||
float luma_filter6 = -0.000066171;
|
||||
float luma_filter7 = -0.000245058;
|
||||
float luma_filter8 = -0.000432928;
|
||||
float luma_filter9 = -0.000472644;
|
||||
float luma_filter10 = -0.000252236;
|
||||
float luma_filter11 = 0.000198929;
|
||||
float luma_filter12 = 0.000687058;
|
||||
float luma_filter13 = 0.000944112;
|
||||
float luma_filter14 = 0.000803467;
|
||||
float luma_filter15 = 0.000363199;
|
||||
float luma_filter16 = 0.000013422;
|
||||
float luma_filter17 = 0.000253402;
|
||||
float luma_filter18 = 0.001339461;
|
||||
float luma_filter19 = 0.002932972;
|
||||
float luma_filter20 = 0.003983485;
|
||||
float luma_filter21 = 0.00302668;
|
||||
float luma_filter22 = -0.001102056;
|
||||
float luma_filter23 = -0.008373026;
|
||||
float luma_filter24 = -0.016897700;
|
||||
float luma_filter25 = -0.022914480;
|
||||
float luma_filter26 = -0.021642347;
|
||||
float luma_filter27 = -0.008863273;
|
||||
float luma_filter28 = 0.017271957;
|
||||
float luma_filter29 = 0.054921920;
|
||||
float luma_filter30 = 0.098342579;
|
||||
float luma_filter31 = 0.139044281;
|
||||
float luma_filter32 = 0.168055832;
|
||||
float luma_filter33 = 0.178571429;
|
||||
|
||||
float chroma_filter1 = 0.001384762;
|
||||
float chroma_filter2 = 0.001678312;
|
||||
float chroma_filter3 = 0.002021715;
|
||||
float chroma_filter4 = 0.002420562;
|
||||
float chroma_filter5 = 0.002880460;
|
||||
float chroma_filter6 = 0.003406879;
|
||||
float chroma_filter7 = 0.004004985;
|
||||
float chroma_filter8 = 0.004679445;
|
||||
float chroma_filter9 = 0.005434218;
|
||||
float chroma_filter10 = 0.006272332;
|
||||
float chroma_filter11 = 0.007195654;
|
||||
float chroma_filter12 = 0.008204665;
|
||||
float chroma_filter13 = 0.009298238;
|
||||
float chroma_filter14 = 0.010473450;
|
||||
float chroma_filter15 = 0.011725413;
|
||||
float chroma_filter16 = 0.013047155;
|
||||
float chroma_filter17 = 0.014429548;
|
||||
float chroma_filter18 = 0.015861306;
|
||||
float chroma_filter19 = 0.017329037;
|
||||
float chroma_filter20 = 0.018817382;
|
||||
float chroma_filter21 = 0.020309220;
|
||||
float chroma_filter22 = 0.021785952;
|
||||
float chroma_filter23 = 0.023227857;
|
||||
float chroma_filter24 = 0.024614500;
|
||||
float chroma_filter25 = 0.025925203;
|
||||
float chroma_filter26 = 0.027139546;
|
||||
float chroma_filter27 = 0.028237893;
|
||||
float chroma_filter28 = 0.029201910;
|
||||
float chroma_filter29 = 0.030015081;
|
||||
float chroma_filter30 = 0.030663170;
|
||||
float chroma_filter31 = 0.031134640;
|
||||
float chroma_filter32 = 0.031420995;
|
||||
float chroma_filter33 = 0.031517031;
|
||||
#else
|
||||
#define TAPS 32
|
||||
const float luma_filter[TAPS + 1] = float[TAPS + 1](
|
||||
-0.000174844,
|
||||
-0.000205844,
|
||||
-0.000149453,
|
||||
-0.000051693,
|
||||
0.000000000,
|
||||
-0.000066171,
|
||||
-0.000245058,
|
||||
-0.000432928,
|
||||
-0.000472644,
|
||||
-0.000252236,
|
||||
0.000198929,
|
||||
0.000687058,
|
||||
0.000944112,
|
||||
0.000803467,
|
||||
0.000363199,
|
||||
0.000013422,
|
||||
0.000253402,
|
||||
0.001339461,
|
||||
0.002932972,
|
||||
0.003983485,
|
||||
0.003026683,
|
||||
-0.001102056,
|
||||
-0.008373026,
|
||||
-0.016897700,
|
||||
-0.022914480,
|
||||
-0.021642347,
|
||||
-0.008863273,
|
||||
0.017271957,
|
||||
0.054921920,
|
||||
0.098342579,
|
||||
0.139044281,
|
||||
0.168055832,
|
||||
0.178571429);
|
||||
|
||||
const float chroma_filter[TAPS + 1] = float[TAPS + 1](
|
||||
0.001384762,
|
||||
0.001678312,
|
||||
0.002021715,
|
||||
0.002420562,
|
||||
0.002880460,
|
||||
0.003406879,
|
||||
0.004004985,
|
||||
0.004679445,
|
||||
0.005434218,
|
||||
0.006272332,
|
||||
0.007195654,
|
||||
0.008204665,
|
||||
0.009298238,
|
||||
0.010473450,
|
||||
0.011725413,
|
||||
0.013047155,
|
||||
0.014429548,
|
||||
0.015861306,
|
||||
0.017329037,
|
||||
0.018817382,
|
||||
0.020309220,
|
||||
0.021785952,
|
||||
0.023227857,
|
||||
0.024614500,
|
||||
0.025925203,
|
||||
0.027139546,
|
||||
0.028237893,
|
||||
0.029201910,
|
||||
0.030015081,
|
||||
0.030663170,
|
||||
0.031134640,
|
||||
0.031420995,
|
||||
0.031517031);
|
||||
#endif
|
||||
// end ntsc-decode-filter-3phase
|
||||
|
||||
#define fetch_offset(offset, one_x) \
|
||||
texture(Source, vTexCoord + vec2((offset) * (one_x), 0.0)).xyz
|
||||
|
||||
#if defined(VERTEX)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING out
|
||||
#define COMPAT_ATTRIBUTE in
|
||||
#define COMPAT_TEXTURE texture
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define COMPAT_ATTRIBUTE attribute
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
COMPAT_ATTRIBUTE vec4 VertexCoord;
|
||||
COMPAT_ATTRIBUTE vec4 COLOR;
|
||||
COMPAT_ATTRIBUTE vec4 TexCoord;
|
||||
COMPAT_VARYING vec4 COL0;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
// out variables go here as COMPAT_VARYING whatever
|
||||
|
||||
uniform mat4 MVPMatrix;
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
|
||||
// vertex compatibility #defines
|
||||
#define vTexCoord TEX0.xy
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = MVPMatrix * VertexCoord;
|
||||
COL0 = COLOR;
|
||||
TEX0.xy = TexCoord - vec2(0.5 / SourceSize.x, 0.0); // Compensate for decimate-by-2.
|
||||
}
|
||||
|
||||
#elif defined(FRAGMENT)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING in
|
||||
#define COMPAT_TEXTURE texture
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define FragColor gl_FragColor
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||||
precision highp float;
|
||||
#else
|
||||
precision mediump float;
|
||||
#endif
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
uniform sampler2D Texture;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
// in variables go here as COMPAT_VARYING whatever
|
||||
|
||||
// fragment compatibility #defines
|
||||
#define Source Texture
|
||||
#define vTexCoord TEX0.xy
|
||||
#define texture(c, d) COMPAT_TEXTURE(c, d)
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
void main()
|
||||
{
|
||||
// begin ntsc-pass2-decode
|
||||
float one_x = 1.0 / SourceSize.x;
|
||||
vec3 signal = vec3(0.0);
|
||||
#ifdef test//GL_ES
|
||||
float offset;
|
||||
vec3 sums;
|
||||
|
||||
// unrolling the loopz
|
||||
// TAP = 1
|
||||
offset = 0.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter1, chroma_filter1, chroma_filter1);
|
||||
|
||||
// TAP = 2
|
||||
offset = 1.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter2, chroma_filter2, chroma_filter2);
|
||||
|
||||
// TAP = 3
|
||||
offset = 2.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter3, chroma_filter3, chroma_filter3);
|
||||
|
||||
// TAP = 4
|
||||
offset = 3.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter4, chroma_filter4, chroma_filter4);
|
||||
|
||||
// TAP = 5
|
||||
offset = 4.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter5, chroma_filter5, chroma_filter5);
|
||||
|
||||
// TAP = 6
|
||||
offset = 5.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter6, chroma_filter6, chroma_filter6);
|
||||
|
||||
// TAP = 7
|
||||
offset = 6.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter7, chroma_filter7, chroma_filter7);
|
||||
|
||||
// TAP = 8
|
||||
offset = 7.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter8, chroma_filter8, chroma_filter8);
|
||||
|
||||
// TAP = 9
|
||||
offset = 8.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter9, chroma_filter9, chroma_filter9);
|
||||
|
||||
// TAP = 10
|
||||
offset = 9.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter10, chroma_filter10, chroma_filter10);
|
||||
|
||||
// TAP = 11
|
||||
offset = 10.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter11, chroma_filter11, chroma_filter11);
|
||||
|
||||
// TAP = 12
|
||||
offset = 11.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter12, chroma_filter12, chroma_filter12);
|
||||
|
||||
// TAP = 13
|
||||
offset = 12.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter13, chroma_filter13, chroma_filter13);
|
||||
|
||||
// TAP = 14
|
||||
offset = 13.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter14, chroma_filter14, chroma_filter14);
|
||||
|
||||
// TAP = 15
|
||||
offset = 14.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter15, chroma_filter15, chroma_filter15);
|
||||
|
||||
// TAP = 16
|
||||
offset = 15.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter16, chroma_filter16, chroma_filter16);
|
||||
|
||||
// TAP = 17
|
||||
offset = 16.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter17, chroma_filter17, chroma_filter17);
|
||||
|
||||
// TAP = 18
|
||||
offset = 17.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter18, chroma_filter18, chroma_filter18);
|
||||
|
||||
// TAP = 19
|
||||
offset = 18.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter19, chroma_filter19, chroma_filter19);
|
||||
|
||||
// TAP = 20
|
||||
offset = 19.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter20, chroma_filter20, chroma_filter20);
|
||||
|
||||
// TAP = 21
|
||||
offset = 20.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter21, chroma_filter21, chroma_filter21);
|
||||
|
||||
// TAP = 22
|
||||
offset = 21.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter22, chroma_filter22, chroma_filter22);
|
||||
|
||||
// TAP = 23
|
||||
offset = 22.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter23, chroma_filter23, chroma_filter23);
|
||||
|
||||
// TAP = 24
|
||||
offset = 23.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter24, chroma_filter24, chroma_filter24);
|
||||
|
||||
// TAP = 25
|
||||
offset = 32.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter25, chroma_filter25, chroma_filter25);
|
||||
|
||||
// TAP = 26
|
||||
offset = 25.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter26, chroma_filter26, chroma_filter26);
|
||||
|
||||
// TAP = 27
|
||||
offset = 26.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter27, chroma_filter27, chroma_filter27);
|
||||
|
||||
// TAP = 28
|
||||
offset = 27.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter28, chroma_filter28, chroma_filter28);
|
||||
|
||||
// TAP = 29
|
||||
offset = 28.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter29, chroma_filter29, chroma_filter29);
|
||||
|
||||
// TAP = 30
|
||||
offset = 29.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter30, chroma_filter30, chroma_filter30);
|
||||
|
||||
// TAP = 31
|
||||
offset = 30.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter31, chroma_filter31, chroma_filter31);
|
||||
|
||||
// TAP = 32
|
||||
offset = 31.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter32, chroma_filter32, chroma_filter32);
|
||||
|
||||
signal += COMPAT_TEXTURE(Texture, TEX0.xy).xyz *
|
||||
vec3(luma_filter33, chroma_filter33, chroma_filter33);
|
||||
#else
|
||||
for (int i = 0; i < TAPS; i++)
|
||||
{
|
||||
float offset = float(i);
|
||||
|
||||
vec3 sums = fetch_offset(offset - float(TAPS), one_x) +
|
||||
fetch_offset(float(TAPS) - offset, one_x);
|
||||
|
||||
signal += sums * vec3(luma_filter[i], chroma_filter[i], chroma_filter[i]);
|
||||
}
|
||||
signal += texture(Source, vTexCoord).xyz *
|
||||
vec3(luma_filter[TAPS], chroma_filter[TAPS], chroma_filter[TAPS]);
|
||||
#endif
|
||||
// end ntsc-pass2-decode
|
||||
vec3 rgb = yiq2rgb(signal);
|
||||
FragColor = vec4(pow(rgb, vec3(NTSC_CRT_GAMMA / NTSC_MONITOR_GAMMA)), 1.0);
|
||||
}
|
||||
#endif
|
484
ntsc/shaders/ntsc-pass2-2phase-linear.glsl
Normal file
484
ntsc/shaders/ntsc-pass2-2phase-linear.glsl
Normal file
@ -0,0 +1,484 @@
|
||||
// Compatibility #ifdefs needed for parameters
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
#define NTSC_CRT_GAMMA 2.4
|
||||
|
||||
// begin ntsc-rgbyuv
|
||||
mat3 yiq2rgb_mat = mat3(
|
||||
1.0, 1.0, 1.0,
|
||||
0.956, -0.2720, -1.1060,
|
||||
0.6210, -0.6474, 1.7046
|
||||
);
|
||||
|
||||
vec3 yiq2rgb(vec3 yiq)
|
||||
{
|
||||
return (yiq * yiq2rgb_mat);
|
||||
}
|
||||
|
||||
mat3 yiq_mat = mat3(
|
||||
0.2989, 0.5959, 0.2115,
|
||||
0.5870, -0.2744, -0.5229,
|
||||
0.1140, -0.3216, 0.3114
|
||||
);
|
||||
|
||||
vec3 rgb2yiq(vec3 col)
|
||||
{
|
||||
return (col * yiq_mat);
|
||||
}
|
||||
// end ntsc-rgbyuv
|
||||
#define test
|
||||
// begin ntsc-decode-filter-3phase
|
||||
#ifdef test//GL_ES
|
||||
float luma_filter1 = -0.000174844;
|
||||
float luma_filter2 = -0.000205844;
|
||||
float luma_filter3 = -0.000149453;
|
||||
float luma_filter4 = -0.000051693;
|
||||
float luma_filter5 = 0.000000000;
|
||||
float luma_filter6 = -0.000066171;
|
||||
float luma_filter7 = -0.000245058;
|
||||
float luma_filter8 = -0.000432928;
|
||||
float luma_filter9 = -0.000472644;
|
||||
float luma_filter10 = -0.000252236;
|
||||
float luma_filter11 = 0.000198929;
|
||||
float luma_filter12 = 0.000687058;
|
||||
float luma_filter13 = 0.000944112;
|
||||
float luma_filter14 = 0.000803467;
|
||||
float luma_filter15 = 0.000363199;
|
||||
float luma_filter16 = 0.000013422;
|
||||
float luma_filter17 = 0.000253402;
|
||||
float luma_filter18 = 0.001339461;
|
||||
float luma_filter19 = 0.002932972;
|
||||
float luma_filter20 = 0.003983485;
|
||||
float luma_filter21 = 0.00302668;
|
||||
float luma_filter22 = -0.001102056;
|
||||
float luma_filter23 = -0.008373026;
|
||||
float luma_filter24 = -0.016897700;
|
||||
float luma_filter25 = -0.022914480;
|
||||
float luma_filter26 = -0.021642347;
|
||||
float luma_filter27 = -0.008863273;
|
||||
float luma_filter28 = 0.017271957;
|
||||
float luma_filter29 = 0.054921920;
|
||||
float luma_filter30 = 0.098342579;
|
||||
float luma_filter31 = 0.139044281;
|
||||
float luma_filter32 = 0.168055832;
|
||||
float luma_filter33 = 0.178571429;
|
||||
|
||||
float chroma_filter1 = 0.001384762;
|
||||
float chroma_filter2 = 0.001678312;
|
||||
float chroma_filter3 = 0.002021715;
|
||||
float chroma_filter4 = 0.002420562;
|
||||
float chroma_filter5 = 0.002880460;
|
||||
float chroma_filter6 = 0.003406879;
|
||||
float chroma_filter7 = 0.004004985;
|
||||
float chroma_filter8 = 0.004679445;
|
||||
float chroma_filter9 = 0.005434218;
|
||||
float chroma_filter10 = 0.006272332;
|
||||
float chroma_filter11 = 0.007195654;
|
||||
float chroma_filter12 = 0.008204665;
|
||||
float chroma_filter13 = 0.009298238;
|
||||
float chroma_filter14 = 0.010473450;
|
||||
float chroma_filter15 = 0.011725413;
|
||||
float chroma_filter16 = 0.013047155;
|
||||
float chroma_filter17 = 0.014429548;
|
||||
float chroma_filter18 = 0.015861306;
|
||||
float chroma_filter19 = 0.017329037;
|
||||
float chroma_filter20 = 0.018817382;
|
||||
float chroma_filter21 = 0.020309220;
|
||||
float chroma_filter22 = 0.021785952;
|
||||
float chroma_filter23 = 0.023227857;
|
||||
float chroma_filter24 = 0.024614500;
|
||||
float chroma_filter25 = 0.025925203;
|
||||
float chroma_filter26 = 0.027139546;
|
||||
float chroma_filter27 = 0.028237893;
|
||||
float chroma_filter28 = 0.029201910;
|
||||
float chroma_filter29 = 0.030015081;
|
||||
float chroma_filter30 = 0.030663170;
|
||||
float chroma_filter31 = 0.031134640;
|
||||
float chroma_filter32 = 0.031420995;
|
||||
float chroma_filter33 = 0.031517031;
|
||||
#else
|
||||
#define TAPS 32
|
||||
const float luma_filter[TAPS + 1] = float[TAPS + 1](
|
||||
-0.000174844,
|
||||
-0.000205844,
|
||||
-0.000149453,
|
||||
-0.000051693,
|
||||
0.000000000,
|
||||
-0.000066171,
|
||||
-0.000245058,
|
||||
-0.000432928,
|
||||
-0.000472644,
|
||||
-0.000252236,
|
||||
0.000198929,
|
||||
0.000687058,
|
||||
0.000944112,
|
||||
0.000803467,
|
||||
0.000363199,
|
||||
0.000013422,
|
||||
0.000253402,
|
||||
0.001339461,
|
||||
0.002932972,
|
||||
0.003983485,
|
||||
0.003026683,
|
||||
-0.001102056,
|
||||
-0.008373026,
|
||||
-0.016897700,
|
||||
-0.022914480,
|
||||
-0.021642347,
|
||||
-0.008863273,
|
||||
0.017271957,
|
||||
0.054921920,
|
||||
0.098342579,
|
||||
0.139044281,
|
||||
0.168055832,
|
||||
0.178571429);
|
||||
|
||||
const float chroma_filter[TAPS + 1] = float[TAPS + 1](
|
||||
0.001384762,
|
||||
0.001678312,
|
||||
0.002021715,
|
||||
0.002420562,
|
||||
0.002880460,
|
||||
0.003406879,
|
||||
0.004004985,
|
||||
0.004679445,
|
||||
0.005434218,
|
||||
0.006272332,
|
||||
0.007195654,
|
||||
0.008204665,
|
||||
0.009298238,
|
||||
0.010473450,
|
||||
0.011725413,
|
||||
0.013047155,
|
||||
0.014429548,
|
||||
0.015861306,
|
||||
0.017329037,
|
||||
0.018817382,
|
||||
0.020309220,
|
||||
0.021785952,
|
||||
0.023227857,
|
||||
0.024614500,
|
||||
0.025925203,
|
||||
0.027139546,
|
||||
0.028237893,
|
||||
0.029201910,
|
||||
0.030015081,
|
||||
0.030663170,
|
||||
0.031134640,
|
||||
0.031420995,
|
||||
0.031517031);
|
||||
#endif
|
||||
// end ntsc-decode-filter-3phase
|
||||
|
||||
#define fetch_offset(offset, one_x) \
|
||||
texture(Source, vTexCoord + vec2((offset) * (one_x), 0.0)).xyz
|
||||
|
||||
#if defined(VERTEX)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING out
|
||||
#define COMPAT_ATTRIBUTE in
|
||||
#define COMPAT_TEXTURE texture
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define COMPAT_ATTRIBUTE attribute
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
COMPAT_ATTRIBUTE vec4 VertexCoord;
|
||||
COMPAT_ATTRIBUTE vec4 COLOR;
|
||||
COMPAT_ATTRIBUTE vec4 TexCoord;
|
||||
COMPAT_VARYING vec4 COL0;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
// out variables go here as COMPAT_VARYING whatever
|
||||
|
||||
uniform mat4 MVPMatrix;
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
|
||||
// vertex compatibility #defines
|
||||
#define vTexCoord TEX0.xy
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = MVPMatrix * VertexCoord;
|
||||
COL0 = COLOR;
|
||||
TEX0.xy = TexCoord - vec2(0.5 / SourceSize.x, 0.0); // Compensate for decimate-by-2.
|
||||
}
|
||||
|
||||
#elif defined(FRAGMENT)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING in
|
||||
#define COMPAT_TEXTURE texture
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define FragColor gl_FragColor
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||||
precision highp float;
|
||||
#else
|
||||
precision mediump float;
|
||||
#endif
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
uniform sampler2D Texture;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
// in variables go here as COMPAT_VARYING whatever
|
||||
|
||||
// fragment compatibility #defines
|
||||
#define Source Texture
|
||||
#define vTexCoord TEX0.xy
|
||||
#define texture(c, d) COMPAT_TEXTURE(c, d)
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
void main()
|
||||
{
|
||||
// begin ntsc-pass2-decode
|
||||
float one_x = 1.0 / SourceSize.x;
|
||||
vec3 signal = vec3(0.0);
|
||||
#ifdef test//GL_ES
|
||||
float offset;
|
||||
vec3 sums;
|
||||
|
||||
// unrolling the loopz
|
||||
// TAP = 1
|
||||
offset = 0.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter1, chroma_filter1, chroma_filter1);
|
||||
|
||||
// TAP = 2
|
||||
offset = 1.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter2, chroma_filter2, chroma_filter2);
|
||||
|
||||
// TAP = 3
|
||||
offset = 2.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter3, chroma_filter3, chroma_filter3);
|
||||
|
||||
// TAP = 4
|
||||
offset = 3.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter4, chroma_filter4, chroma_filter4);
|
||||
|
||||
// TAP = 5
|
||||
offset = 4.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter5, chroma_filter5, chroma_filter5);
|
||||
|
||||
// TAP = 6
|
||||
offset = 5.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter6, chroma_filter6, chroma_filter6);
|
||||
|
||||
// TAP = 7
|
||||
offset = 6.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter7, chroma_filter7, chroma_filter7);
|
||||
|
||||
// TAP = 8
|
||||
offset = 7.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter8, chroma_filter8, chroma_filter8);
|
||||
|
||||
// TAP = 9
|
||||
offset = 8.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter9, chroma_filter9, chroma_filter9);
|
||||
|
||||
// TAP = 10
|
||||
offset = 9.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter10, chroma_filter10, chroma_filter10);
|
||||
|
||||
// TAP = 11
|
||||
offset = 10.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter11, chroma_filter11, chroma_filter11);
|
||||
|
||||
// TAP = 12
|
||||
offset = 11.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter12, chroma_filter12, chroma_filter12);
|
||||
|
||||
// TAP = 13
|
||||
offset = 12.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter13, chroma_filter13, chroma_filter13);
|
||||
|
||||
// TAP = 14
|
||||
offset = 13.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter14, chroma_filter14, chroma_filter14);
|
||||
|
||||
// TAP = 15
|
||||
offset = 14.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter15, chroma_filter15, chroma_filter15);
|
||||
|
||||
// TAP = 16
|
||||
offset = 15.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter16, chroma_filter16, chroma_filter16);
|
||||
|
||||
// TAP = 17
|
||||
offset = 16.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter17, chroma_filter17, chroma_filter17);
|
||||
|
||||
// TAP = 18
|
||||
offset = 17.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter18, chroma_filter18, chroma_filter18);
|
||||
|
||||
// TAP = 19
|
||||
offset = 18.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter19, chroma_filter19, chroma_filter19);
|
||||
|
||||
// TAP = 20
|
||||
offset = 19.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter20, chroma_filter20, chroma_filter20);
|
||||
|
||||
// TAP = 21
|
||||
offset = 20.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter21, chroma_filter21, chroma_filter21);
|
||||
|
||||
// TAP = 22
|
||||
offset = 21.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter22, chroma_filter22, chroma_filter22);
|
||||
|
||||
// TAP = 23
|
||||
offset = 22.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter23, chroma_filter23, chroma_filter23);
|
||||
|
||||
// TAP = 24
|
||||
offset = 23.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter24, chroma_filter24, chroma_filter24);
|
||||
|
||||
// TAP = 25
|
||||
offset = 32.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter25, chroma_filter25, chroma_filter25);
|
||||
|
||||
// TAP = 26
|
||||
offset = 25.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter26, chroma_filter26, chroma_filter26);
|
||||
|
||||
// TAP = 27
|
||||
offset = 26.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter27, chroma_filter27, chroma_filter27);
|
||||
|
||||
// TAP = 28
|
||||
offset = 27.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter28, chroma_filter28, chroma_filter28);
|
||||
|
||||
// TAP = 29
|
||||
offset = 28.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter29, chroma_filter29, chroma_filter29);
|
||||
|
||||
// TAP = 30
|
||||
offset = 29.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter30, chroma_filter30, chroma_filter30);
|
||||
|
||||
// TAP = 31
|
||||
offset = 30.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter31, chroma_filter31, chroma_filter31);
|
||||
|
||||
// TAP = 32
|
||||
offset = 31.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter32, chroma_filter32, chroma_filter32);
|
||||
|
||||
signal += COMPAT_TEXTURE(Texture, TEX0.xy).xyz *
|
||||
vec3(luma_filter33, chroma_filter33, chroma_filter33);
|
||||
#else
|
||||
for (int i = 0; i < TAPS; i++)
|
||||
{
|
||||
float offset = float(i);
|
||||
|
||||
vec3 sums = fetch_offset(offset - float(TAPS), one_x) +
|
||||
fetch_offset(float(TAPS) - offset, one_x);
|
||||
|
||||
signal += sums * vec3(luma_filter[i], chroma_filter[i], chroma_filter[i]);
|
||||
}
|
||||
signal += texture(Source, vTexCoord).xyz *
|
||||
vec3(luma_filter[TAPS], chroma_filter[TAPS], chroma_filter[TAPS]);
|
||||
#endif
|
||||
// end ntsc-pass2-decode
|
||||
vec3 rgb = yiq2rgb(signal);
|
||||
FragColor = vec4(pow(rgb, vec3(NTSC_CRT_GAMMA)), 1.0);
|
||||
}
|
||||
#endif
|
482
ntsc/shaders/ntsc-pass2-2phase.glsl
Normal file
482
ntsc/shaders/ntsc-pass2-2phase.glsl
Normal file
@ -0,0 +1,482 @@
|
||||
// Compatibility #ifdefs needed for parameters
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
// begin ntsc-rgbyuv
|
||||
mat3 yiq2rgb_mat = mat3(
|
||||
1.0, 1.0, 1.0,
|
||||
0.956, -0.2720, -1.1060,
|
||||
0.6210, -0.6474, 1.7046
|
||||
);
|
||||
|
||||
vec3 yiq2rgb(vec3 yiq)
|
||||
{
|
||||
return (yiq * yiq2rgb_mat);
|
||||
}
|
||||
|
||||
mat3 yiq_mat = mat3(
|
||||
0.2989, 0.5959, 0.2115,
|
||||
0.5870, -0.2744, -0.5229,
|
||||
0.1140, -0.3216, 0.3114
|
||||
);
|
||||
|
||||
vec3 rgb2yiq(vec3 col)
|
||||
{
|
||||
return (col * yiq_mat);
|
||||
}
|
||||
// end ntsc-rgbyuv
|
||||
#define test
|
||||
// begin ntsc-decode-filter-3phase
|
||||
#ifdef test//GL_ES
|
||||
float luma_filter1 = -0.000174844;
|
||||
float luma_filter2 = -0.000205844;
|
||||
float luma_filter3 = -0.000149453;
|
||||
float luma_filter4 = -0.000051693;
|
||||
float luma_filter5 = 0.000000000;
|
||||
float luma_filter6 = -0.000066171;
|
||||
float luma_filter7 = -0.000245058;
|
||||
float luma_filter8 = -0.000432928;
|
||||
float luma_filter9 = -0.000472644;
|
||||
float luma_filter10 = -0.000252236;
|
||||
float luma_filter11 = 0.000198929;
|
||||
float luma_filter12 = 0.000687058;
|
||||
float luma_filter13 = 0.000944112;
|
||||
float luma_filter14 = 0.000803467;
|
||||
float luma_filter15 = 0.000363199;
|
||||
float luma_filter16 = 0.000013422;
|
||||
float luma_filter17 = 0.000253402;
|
||||
float luma_filter18 = 0.001339461;
|
||||
float luma_filter19 = 0.002932972;
|
||||
float luma_filter20 = 0.003983485;
|
||||
float luma_filter21 = 0.00302668;
|
||||
float luma_filter22 = -0.001102056;
|
||||
float luma_filter23 = -0.008373026;
|
||||
float luma_filter24 = -0.016897700;
|
||||
float luma_filter25 = -0.022914480;
|
||||
float luma_filter26 = -0.021642347;
|
||||
float luma_filter27 = -0.008863273;
|
||||
float luma_filter28 = 0.017271957;
|
||||
float luma_filter29 = 0.054921920;
|
||||
float luma_filter30 = 0.098342579;
|
||||
float luma_filter31 = 0.139044281;
|
||||
float luma_filter32 = 0.168055832;
|
||||
float luma_filter33 = 0.178571429;
|
||||
|
||||
float chroma_filter1 = 0.001384762;
|
||||
float chroma_filter2 = 0.001678312;
|
||||
float chroma_filter3 = 0.002021715;
|
||||
float chroma_filter4 = 0.002420562;
|
||||
float chroma_filter5 = 0.002880460;
|
||||
float chroma_filter6 = 0.003406879;
|
||||
float chroma_filter7 = 0.004004985;
|
||||
float chroma_filter8 = 0.004679445;
|
||||
float chroma_filter9 = 0.005434218;
|
||||
float chroma_filter10 = 0.006272332;
|
||||
float chroma_filter11 = 0.007195654;
|
||||
float chroma_filter12 = 0.008204665;
|
||||
float chroma_filter13 = 0.009298238;
|
||||
float chroma_filter14 = 0.010473450;
|
||||
float chroma_filter15 = 0.011725413;
|
||||
float chroma_filter16 = 0.013047155;
|
||||
float chroma_filter17 = 0.014429548;
|
||||
float chroma_filter18 = 0.015861306;
|
||||
float chroma_filter19 = 0.017329037;
|
||||
float chroma_filter20 = 0.018817382;
|
||||
float chroma_filter21 = 0.020309220;
|
||||
float chroma_filter22 = 0.021785952;
|
||||
float chroma_filter23 = 0.023227857;
|
||||
float chroma_filter24 = 0.024614500;
|
||||
float chroma_filter25 = 0.025925203;
|
||||
float chroma_filter26 = 0.027139546;
|
||||
float chroma_filter27 = 0.028237893;
|
||||
float chroma_filter28 = 0.029201910;
|
||||
float chroma_filter29 = 0.030015081;
|
||||
float chroma_filter30 = 0.030663170;
|
||||
float chroma_filter31 = 0.031134640;
|
||||
float chroma_filter32 = 0.031420995;
|
||||
float chroma_filter33 = 0.031517031;
|
||||
#else
|
||||
#define TAPS 32
|
||||
const float luma_filter[TAPS + 1] = float[TAPS + 1](
|
||||
-0.000174844,
|
||||
-0.000205844,
|
||||
-0.000149453,
|
||||
-0.000051693,
|
||||
0.000000000,
|
||||
-0.000066171,
|
||||
-0.000245058,
|
||||
-0.000432928,
|
||||
-0.000472644,
|
||||
-0.000252236,
|
||||
0.000198929,
|
||||
0.000687058,
|
||||
0.000944112,
|
||||
0.000803467,
|
||||
0.000363199,
|
||||
0.000013422,
|
||||
0.000253402,
|
||||
0.001339461,
|
||||
0.002932972,
|
||||
0.003983485,
|
||||
0.003026683,
|
||||
-0.001102056,
|
||||
-0.008373026,
|
||||
-0.016897700,
|
||||
-0.022914480,
|
||||
-0.021642347,
|
||||
-0.008863273,
|
||||
0.017271957,
|
||||
0.054921920,
|
||||
0.098342579,
|
||||
0.139044281,
|
||||
0.168055832,
|
||||
0.178571429);
|
||||
|
||||
const float chroma_filter[TAPS + 1] = float[TAPS + 1](
|
||||
0.001384762,
|
||||
0.001678312,
|
||||
0.002021715,
|
||||
0.002420562,
|
||||
0.002880460,
|
||||
0.003406879,
|
||||
0.004004985,
|
||||
0.004679445,
|
||||
0.005434218,
|
||||
0.006272332,
|
||||
0.007195654,
|
||||
0.008204665,
|
||||
0.009298238,
|
||||
0.010473450,
|
||||
0.011725413,
|
||||
0.013047155,
|
||||
0.014429548,
|
||||
0.015861306,
|
||||
0.017329037,
|
||||
0.018817382,
|
||||
0.020309220,
|
||||
0.021785952,
|
||||
0.023227857,
|
||||
0.024614500,
|
||||
0.025925203,
|
||||
0.027139546,
|
||||
0.028237893,
|
||||
0.029201910,
|
||||
0.030015081,
|
||||
0.030663170,
|
||||
0.031134640,
|
||||
0.031420995,
|
||||
0.031517031);
|
||||
#endif
|
||||
// end ntsc-decode-filter-3phase
|
||||
|
||||
#define fetch_offset(offset, one_x) \
|
||||
texture(Source, vTexCoord + vec2((offset) * (one_x), 0.0)).xyz
|
||||
|
||||
#if defined(VERTEX)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING out
|
||||
#define COMPAT_ATTRIBUTE in
|
||||
#define COMPAT_TEXTURE texture
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define COMPAT_ATTRIBUTE attribute
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
COMPAT_ATTRIBUTE vec4 VertexCoord;
|
||||
COMPAT_ATTRIBUTE vec4 COLOR;
|
||||
COMPAT_ATTRIBUTE vec4 TexCoord;
|
||||
COMPAT_VARYING vec4 COL0;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
// out variables go here as COMPAT_VARYING whatever
|
||||
|
||||
uniform mat4 MVPMatrix;
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
|
||||
// vertex compatibility #defines
|
||||
#define vTexCoord TEX0.xy
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = MVPMatrix * VertexCoord;
|
||||
COL0 = COLOR;
|
||||
TEX0.xy = TexCoord - vec2(0.5 / SourceSize.x, 0.0); // Compensate for decimate-by-2.
|
||||
}
|
||||
|
||||
#elif defined(FRAGMENT)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING in
|
||||
#define COMPAT_TEXTURE texture
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define FragColor gl_FragColor
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||||
precision highp float;
|
||||
#else
|
||||
precision mediump float;
|
||||
#endif
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
uniform sampler2D Texture;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
// in variables go here as COMPAT_VARYING whatever
|
||||
|
||||
// fragment compatibility #defines
|
||||
#define Source Texture
|
||||
#define vTexCoord TEX0.xy
|
||||
#define texture(c, d) COMPAT_TEXTURE(c, d)
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
void main()
|
||||
{
|
||||
// begin ntsc-pass2-decode
|
||||
float one_x = 1.0 / SourceSize.x;
|
||||
vec3 signal = vec3(0.0);
|
||||
#ifdef test//GL_ES
|
||||
float offset;
|
||||
vec3 sums;
|
||||
|
||||
// unrolling the loopz
|
||||
// TAP = 1
|
||||
offset = 0.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter1, chroma_filter1, chroma_filter1);
|
||||
|
||||
// TAP = 2
|
||||
offset = 1.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter2, chroma_filter2, chroma_filter2);
|
||||
|
||||
// TAP = 3
|
||||
offset = 2.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter3, chroma_filter3, chroma_filter3);
|
||||
|
||||
// TAP = 4
|
||||
offset = 3.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter4, chroma_filter4, chroma_filter4);
|
||||
|
||||
// TAP = 5
|
||||
offset = 4.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter5, chroma_filter5, chroma_filter5);
|
||||
|
||||
// TAP = 6
|
||||
offset = 5.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter6, chroma_filter6, chroma_filter6);
|
||||
|
||||
// TAP = 7
|
||||
offset = 6.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter7, chroma_filter7, chroma_filter7);
|
||||
|
||||
// TAP = 8
|
||||
offset = 7.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter8, chroma_filter8, chroma_filter8);
|
||||
|
||||
// TAP = 9
|
||||
offset = 8.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter9, chroma_filter9, chroma_filter9);
|
||||
|
||||
// TAP = 10
|
||||
offset = 9.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter10, chroma_filter10, chroma_filter10);
|
||||
|
||||
// TAP = 11
|
||||
offset = 10.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter11, chroma_filter11, chroma_filter11);
|
||||
|
||||
// TAP = 12
|
||||
offset = 11.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter12, chroma_filter12, chroma_filter12);
|
||||
|
||||
// TAP = 13
|
||||
offset = 12.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter13, chroma_filter13, chroma_filter13);
|
||||
|
||||
// TAP = 14
|
||||
offset = 13.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter14, chroma_filter14, chroma_filter14);
|
||||
|
||||
// TAP = 15
|
||||
offset = 14.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter15, chroma_filter15, chroma_filter15);
|
||||
|
||||
// TAP = 16
|
||||
offset = 15.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter16, chroma_filter16, chroma_filter16);
|
||||
|
||||
// TAP = 17
|
||||
offset = 16.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter17, chroma_filter17, chroma_filter17);
|
||||
|
||||
// TAP = 18
|
||||
offset = 17.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter18, chroma_filter18, chroma_filter18);
|
||||
|
||||
// TAP = 19
|
||||
offset = 18.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter19, chroma_filter19, chroma_filter19);
|
||||
|
||||
// TAP = 20
|
||||
offset = 19.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter20, chroma_filter20, chroma_filter20);
|
||||
|
||||
// TAP = 21
|
||||
offset = 20.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter21, chroma_filter21, chroma_filter21);
|
||||
|
||||
// TAP = 22
|
||||
offset = 21.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter22, chroma_filter22, chroma_filter22);
|
||||
|
||||
// TAP = 23
|
||||
offset = 22.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter23, chroma_filter23, chroma_filter23);
|
||||
|
||||
// TAP = 24
|
||||
offset = 23.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter24, chroma_filter24, chroma_filter24);
|
||||
|
||||
// TAP = 25
|
||||
offset = 32.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter25, chroma_filter25, chroma_filter25);
|
||||
|
||||
// TAP = 26
|
||||
offset = 25.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter26, chroma_filter26, chroma_filter26);
|
||||
|
||||
// TAP = 27
|
||||
offset = 26.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter27, chroma_filter27, chroma_filter27);
|
||||
|
||||
// TAP = 28
|
||||
offset = 27.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter28, chroma_filter28, chroma_filter28);
|
||||
|
||||
// TAP = 29
|
||||
offset = 28.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter29, chroma_filter29, chroma_filter29);
|
||||
|
||||
// TAP = 30
|
||||
offset = 29.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter30, chroma_filter30, chroma_filter30);
|
||||
|
||||
// TAP = 31
|
||||
offset = 30.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter31, chroma_filter31, chroma_filter31);
|
||||
|
||||
// TAP = 32
|
||||
offset = 31.;
|
||||
sums = fetch_offset(offset - 32., one_x) +
|
||||
fetch_offset(32. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter32, chroma_filter32, chroma_filter32);
|
||||
|
||||
signal += COMPAT_TEXTURE(Texture, TEX0.xy).xyz *
|
||||
vec3(luma_filter33, chroma_filter33, chroma_filter33);
|
||||
#else
|
||||
for (int i = 0; i < TAPS; i++)
|
||||
{
|
||||
float offset = float(i);
|
||||
|
||||
vec3 sums = fetch_offset(offset - float(TAPS), one_x) +
|
||||
fetch_offset(float(TAPS) - offset, one_x);
|
||||
|
||||
signal += sums * vec3(luma_filter[i], chroma_filter[i], chroma_filter[i]);
|
||||
}
|
||||
signal += texture(Source, vTexCoord).xyz *
|
||||
vec3(luma_filter[TAPS], chroma_filter[TAPS], chroma_filter[TAPS]);
|
||||
#endif
|
||||
// end ntsc-pass2-decode
|
||||
vec3 rgb = yiq2rgb(signal);
|
||||
FragColor = vec4(rgb, 1.0);
|
||||
}
|
||||
#endif
|
405
ntsc/shaders/ntsc-pass2-3phase-gamma.glsl
Normal file
405
ntsc/shaders/ntsc-pass2-3phase-gamma.glsl
Normal file
@ -0,0 +1,405 @@
|
||||
// Compatibility #ifdefs needed for parameters
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
#define NTSC_CRT_GAMMA 2.5
|
||||
#define NTSC_MONITOR_GAMMA 2.0
|
||||
|
||||
// begin ntsc-rgbyuv
|
||||
mat3 yiq2rgb_mat = mat3(
|
||||
1.0, 1.0, 1.0,
|
||||
0.956, -0.2720, -1.1060,
|
||||
0.6210, -0.6474, 1.7046
|
||||
);
|
||||
|
||||
vec3 yiq2rgb(vec3 yiq)
|
||||
{
|
||||
return (yiq * yiq2rgb_mat);
|
||||
}
|
||||
|
||||
mat3 yiq_mat = mat3(
|
||||
0.2989, 0.5959, 0.2115,
|
||||
0.5870, -0.2744, -0.5229,
|
||||
0.1140, -0.3216, 0.3114
|
||||
);
|
||||
|
||||
vec3 rgb2yiq(vec3 col)
|
||||
{
|
||||
return (col * yiq_mat);
|
||||
}
|
||||
// end ntsc-rgbyuv
|
||||
|
||||
// begin ntsc-decode-filter-3phase
|
||||
#ifdef GL_ES
|
||||
float luma_filter1 = -0.000012020;
|
||||
float luma_filter2 = -0.000022146;
|
||||
float luma_filter3 = -0.000013155;
|
||||
float luma_filter4 = -0.000012020;
|
||||
float luma_filter5 = -0.000049979;
|
||||
float luma_filter6 = -0.000113940;
|
||||
float luma_filter7 = -0.000122150;
|
||||
float luma_filter8 = -0.000005612;
|
||||
float luma_filter9 = 0.000170516;
|
||||
float luma_filter10 = 0.000237199;
|
||||
float luma_filter11 = 0.000169640;
|
||||
float luma_filter12 = 0.000285688;
|
||||
float luma_filter13 = 0.000984574;
|
||||
float luma_filter14 = 0.002018683;
|
||||
float luma_filter15 = 0.002002275;
|
||||
float luma_filter16 = -0.000909882;
|
||||
float luma_filter17 = -0.007049081;
|
||||
float luma_filter18 = -0.013222860;
|
||||
float luma_filter19 = -0.012606931;
|
||||
float luma_filter20 = 0.002460860;
|
||||
float luma_filter21 = 0.035868225;
|
||||
float luma_filter22 = 0.084016453;
|
||||
float luma_filter23 = 0.135563500;
|
||||
float luma_filter24 = 0.175261268;
|
||||
float luma_filter25 = 0.190176552;
|
||||
|
||||
float chroma_filter1 = -0.000118847;
|
||||
float chroma_filter2 = -0.000271306;
|
||||
float chroma_filter3 = -0.000502642;
|
||||
float chroma_filter4 = -0.000930833;
|
||||
float chroma_filter5 = -0.001451013;
|
||||
float chroma_filter6 = -0.002064744;
|
||||
float chroma_filter7 = -0.002700432;
|
||||
float chroma_filter8 = -0.003241276;
|
||||
float chroma_filter9 = -0.003524948;
|
||||
float chroma_filter10 = -0.003350284;
|
||||
float chroma_filter11 = -0.002491729;
|
||||
float chroma_filter12 = -0.000721149;
|
||||
float chroma_filter13 = 0.002164659;
|
||||
float chroma_filter14 = 0.006313635;
|
||||
float chroma_filter15 = 0.011789103;
|
||||
float chroma_filter16 = 0.018545660;
|
||||
float chroma_filter17 = 0.026414396;
|
||||
float chroma_filter18 = 0.035100710;
|
||||
float chroma_filter19 = 0.044196567;
|
||||
float chroma_filter20 = 0.053207202;
|
||||
float chroma_filter21 = 0.061590275;
|
||||
float chroma_filter22 = 0.068803602;
|
||||
float chroma_filter23 = 0.074356193;
|
||||
float chroma_filter24 = 0.077856564;
|
||||
float chroma_filter25 = 0.079052396;
|
||||
#else
|
||||
#define TAPS 24
|
||||
const float luma_filter[TAPS + 1] = float[TAPS + 1](
|
||||
-0.000012020,
|
||||
-0.000022146,
|
||||
-0.000013155,
|
||||
-0.000012020,
|
||||
-0.000049979,
|
||||
-0.000113940,
|
||||
-0.000122150,
|
||||
-0.000005612,
|
||||
0.000170516,
|
||||
0.000237199,
|
||||
0.000169640,
|
||||
0.000285688,
|
||||
0.000984574,
|
||||
0.002018683,
|
||||
0.002002275,
|
||||
-0.000909882,
|
||||
-0.007049081,
|
||||
-0.013222860,
|
||||
-0.012606931,
|
||||
0.002460860,
|
||||
0.035868225,
|
||||
0.084016453,
|
||||
0.135563500,
|
||||
0.175261268,
|
||||
0.190176552);
|
||||
|
||||
const float chroma_filter[TAPS + 1] = float[TAPS + 1](
|
||||
-0.000118847,
|
||||
-0.000271306,
|
||||
-0.000502642,
|
||||
-0.000930833,
|
||||
-0.001451013,
|
||||
-0.002064744,
|
||||
-0.002700432,
|
||||
-0.003241276,
|
||||
-0.003524948,
|
||||
-0.003350284,
|
||||
-0.002491729,
|
||||
-0.000721149,
|
||||
0.002164659,
|
||||
0.006313635,
|
||||
0.011789103,
|
||||
0.018545660,
|
||||
0.026414396,
|
||||
0.035100710,
|
||||
0.044196567,
|
||||
0.053207202,
|
||||
0.061590275,
|
||||
0.068803602,
|
||||
0.074356193,
|
||||
0.077856564,
|
||||
0.079052396);
|
||||
#endif
|
||||
// end ntsc-decode-filter-3phase
|
||||
|
||||
#define fetch_offset(offset, one_x) \
|
||||
texture(Source, vTexCoord + vec2((offset) * (one_x), 0.0)).xyz
|
||||
|
||||
#if defined(VERTEX)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING out
|
||||
#define COMPAT_ATTRIBUTE in
|
||||
#define COMPAT_TEXTURE texture
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define COMPAT_ATTRIBUTE attribute
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
COMPAT_ATTRIBUTE vec4 VertexCoord;
|
||||
COMPAT_ATTRIBUTE vec4 COLOR;
|
||||
COMPAT_ATTRIBUTE vec4 TexCoord;
|
||||
COMPAT_VARYING vec4 COL0;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
// out variables go here as COMPAT_VARYING whatever
|
||||
|
||||
uniform mat4 MVPMatrix;
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
|
||||
// vertex compatibility #defines
|
||||
#define vTexCoord TEX0.xy
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = MVPMatrix * VertexCoord;
|
||||
COL0 = COLOR;
|
||||
TEX0.xy = TexCoord - vec2(0.5 / SourceSize.x, 0.0); // Compensate for decimate-by-2.
|
||||
}
|
||||
|
||||
#elif defined(FRAGMENT)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING in
|
||||
#define COMPAT_TEXTURE texture
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define FragColor gl_FragColor
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||||
precision highp float;
|
||||
#else
|
||||
precision mediump float;
|
||||
#endif
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
uniform sampler2D Texture;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
// in variables go here as COMPAT_VARYING whatever
|
||||
|
||||
// fragment compatibility #defines
|
||||
#define Source Texture
|
||||
#define vTexCoord TEX0.xy
|
||||
#define texture(c, d) COMPAT_TEXTURE(c, d)
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
void main()
|
||||
{
|
||||
// begin ntsc-pass2-decode
|
||||
float one_x = 1.0 / SourceSize.x;
|
||||
vec3 signal = vec3(0.0);
|
||||
#ifdef GL_ES
|
||||
float offset;
|
||||
vec3 sums;
|
||||
|
||||
// unrolling the loopz
|
||||
// TAP = 1
|
||||
offset = 0.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter1, chroma_filter1, chroma_filter1);
|
||||
|
||||
// TAP = 2
|
||||
offset = 1.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter2, chroma_filter2, chroma_filter2);
|
||||
|
||||
// TAP = 3
|
||||
offset = 2.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter3, chroma_filter3, chroma_filter3);
|
||||
|
||||
// TAP = 4
|
||||
offset = 3.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter4, chroma_filter4, chroma_filter4);
|
||||
|
||||
// TAP = 5
|
||||
offset = 4.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter5, chroma_filter5, chroma_filter5);
|
||||
|
||||
// TAP = 6
|
||||
offset = 5.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter6, chroma_filter6, chroma_filter6);
|
||||
|
||||
// TAP = 7
|
||||
offset = 6.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter7, chroma_filter7, chroma_filter7);
|
||||
|
||||
// TAP = 8
|
||||
offset = 7.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter8, chroma_filter8, chroma_filter8);
|
||||
|
||||
// TAP = 9
|
||||
offset = 8.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter9, chroma_filter9, chroma_filter9);
|
||||
|
||||
// TAP = 10
|
||||
offset = 9.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter10, chroma_filter10, chroma_filter10);
|
||||
|
||||
// TAP = 11
|
||||
offset = 10.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter11, chroma_filter11, chroma_filter11);
|
||||
|
||||
// TAP = 12
|
||||
offset = 11.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter12, chroma_filter12, chroma_filter12);
|
||||
|
||||
// TAP = 13
|
||||
offset = 12.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter13, chroma_filter13, chroma_filter13);
|
||||
|
||||
// TAP = 14
|
||||
offset = 13.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter14, chroma_filter14, chroma_filter14);
|
||||
|
||||
// TAP = 15
|
||||
offset = 14.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter15, chroma_filter15, chroma_filter15);
|
||||
|
||||
// TAP = 16
|
||||
offset = 15.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter16, chroma_filter16, chroma_filter16);
|
||||
|
||||
// TAP = 17
|
||||
offset = 16.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter17, chroma_filter17, chroma_filter17);
|
||||
|
||||
// TAP = 18
|
||||
offset = 17.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter18, chroma_filter18, chroma_filter18);
|
||||
|
||||
// TAP = 19
|
||||
offset = 18.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter19, chroma_filter19, chroma_filter19);
|
||||
|
||||
// TAP = 20
|
||||
offset = 19.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter20, chroma_filter20, chroma_filter20);
|
||||
|
||||
// TAP = 21
|
||||
offset = 20.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter21, chroma_filter21, chroma_filter21);
|
||||
|
||||
// TAP = 22
|
||||
offset = 21.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter22, chroma_filter22, chroma_filter22);
|
||||
|
||||
// TAP = 23
|
||||
offset = 22.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter23, chroma_filter23, chroma_filter23);
|
||||
|
||||
// TAP = 24
|
||||
offset = 23.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter24, chroma_filter24, chroma_filter24);
|
||||
|
||||
signal += COMPAT_TEXTURE(Texture, TEX0.xy).xyz *
|
||||
vec3(luma_filter25, chroma_filter25, chroma_filter25);
|
||||
#else
|
||||
for (int i = 0; i < TAPS; i++)
|
||||
{
|
||||
float offset = float(i);
|
||||
|
||||
vec3 sums = fetch_offset(offset - float(TAPS), one_x) +
|
||||
fetch_offset(float(TAPS) - offset, one_x);
|
||||
|
||||
signal += sums * vec3(luma_filter[i], chroma_filter[i], chroma_filter[i]);
|
||||
}
|
||||
signal += texture(Source, vTexCoord).xyz *
|
||||
vec3(luma_filter[TAPS], chroma_filter[TAPS], chroma_filter[TAPS]);
|
||||
#endif
|
||||
// end ntsc-pass2-decode
|
||||
vec3 rgb = yiq2rgb(signal);
|
||||
FragColor = vec4(pow(rgb, vec3(NTSC_CRT_GAMMA / NTSC_MONITOR_GAMMA)), 1.0);
|
||||
}
|
||||
#endif
|
404
ntsc/shaders/ntsc-pass2-3phase-linear.glsl
Normal file
404
ntsc/shaders/ntsc-pass2-3phase-linear.glsl
Normal file
@ -0,0 +1,404 @@
|
||||
// Compatibility #ifdefs needed for parameters
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
#define NTSC_CRT_GAMMA 2.4
|
||||
|
||||
// begin ntsc-rgbyuv
|
||||
mat3 yiq2rgb_mat = mat3(
|
||||
1.0, 1.0, 1.0,
|
||||
0.956, -0.2720, -1.1060,
|
||||
0.6210, -0.6474, 1.7046
|
||||
);
|
||||
|
||||
vec3 yiq2rgb(vec3 yiq)
|
||||
{
|
||||
return (yiq * yiq2rgb_mat);
|
||||
}
|
||||
|
||||
mat3 yiq_mat = mat3(
|
||||
0.2989, 0.5959, 0.2115,
|
||||
0.5870, -0.2744, -0.5229,
|
||||
0.1140, -0.3216, 0.3114
|
||||
);
|
||||
|
||||
vec3 rgb2yiq(vec3 col)
|
||||
{
|
||||
return (col * yiq_mat);
|
||||
}
|
||||
// end ntsc-rgbyuv
|
||||
|
||||
// begin ntsc-decode-filter-3phase
|
||||
#ifdef GL_ES
|
||||
float luma_filter1 = -0.000012020;
|
||||
float luma_filter2 = -0.000022146;
|
||||
float luma_filter3 = -0.000013155;
|
||||
float luma_filter4 = -0.000012020;
|
||||
float luma_filter5 = -0.000049979;
|
||||
float luma_filter6 = -0.000113940;
|
||||
float luma_filter7 = -0.000122150;
|
||||
float luma_filter8 = -0.000005612;
|
||||
float luma_filter9 = 0.000170516;
|
||||
float luma_filter10 = 0.000237199;
|
||||
float luma_filter11 = 0.000169640;
|
||||
float luma_filter12 = 0.000285688;
|
||||
float luma_filter13 = 0.000984574;
|
||||
float luma_filter14 = 0.002018683;
|
||||
float luma_filter15 = 0.002002275;
|
||||
float luma_filter16 = -0.000909882;
|
||||
float luma_filter17 = -0.007049081;
|
||||
float luma_filter18 = -0.013222860;
|
||||
float luma_filter19 = -0.012606931;
|
||||
float luma_filter20 = 0.002460860;
|
||||
float luma_filter21 = 0.035868225;
|
||||
float luma_filter22 = 0.084016453;
|
||||
float luma_filter23 = 0.135563500;
|
||||
float luma_filter24 = 0.175261268;
|
||||
float luma_filter25 = 0.190176552;
|
||||
|
||||
float chroma_filter1 = -0.000118847;
|
||||
float chroma_filter2 = -0.000271306;
|
||||
float chroma_filter3 = -0.000502642;
|
||||
float chroma_filter4 = -0.000930833;
|
||||
float chroma_filter5 = -0.001451013;
|
||||
float chroma_filter6 = -0.002064744;
|
||||
float chroma_filter7 = -0.002700432;
|
||||
float chroma_filter8 = -0.003241276;
|
||||
float chroma_filter9 = -0.003524948;
|
||||
float chroma_filter10 = -0.003350284;
|
||||
float chroma_filter11 = -0.002491729;
|
||||
float chroma_filter12 = -0.000721149;
|
||||
float chroma_filter13 = 0.002164659;
|
||||
float chroma_filter14 = 0.006313635;
|
||||
float chroma_filter15 = 0.011789103;
|
||||
float chroma_filter16 = 0.018545660;
|
||||
float chroma_filter17 = 0.026414396;
|
||||
float chroma_filter18 = 0.035100710;
|
||||
float chroma_filter19 = 0.044196567;
|
||||
float chroma_filter20 = 0.053207202;
|
||||
float chroma_filter21 = 0.061590275;
|
||||
float chroma_filter22 = 0.068803602;
|
||||
float chroma_filter23 = 0.074356193;
|
||||
float chroma_filter24 = 0.077856564;
|
||||
float chroma_filter25 = 0.079052396;
|
||||
#else
|
||||
#define TAPS 24
|
||||
const float luma_filter[TAPS + 1] = float[TAPS + 1](
|
||||
-0.000012020,
|
||||
-0.000022146,
|
||||
-0.000013155,
|
||||
-0.000012020,
|
||||
-0.000049979,
|
||||
-0.000113940,
|
||||
-0.000122150,
|
||||
-0.000005612,
|
||||
0.000170516,
|
||||
0.000237199,
|
||||
0.000169640,
|
||||
0.000285688,
|
||||
0.000984574,
|
||||
0.002018683,
|
||||
0.002002275,
|
||||
-0.000909882,
|
||||
-0.007049081,
|
||||
-0.013222860,
|
||||
-0.012606931,
|
||||
0.002460860,
|
||||
0.035868225,
|
||||
0.084016453,
|
||||
0.135563500,
|
||||
0.175261268,
|
||||
0.190176552);
|
||||
|
||||
const float chroma_filter[TAPS + 1] = float[TAPS + 1](
|
||||
-0.000118847,
|
||||
-0.000271306,
|
||||
-0.000502642,
|
||||
-0.000930833,
|
||||
-0.001451013,
|
||||
-0.002064744,
|
||||
-0.002700432,
|
||||
-0.003241276,
|
||||
-0.003524948,
|
||||
-0.003350284,
|
||||
-0.002491729,
|
||||
-0.000721149,
|
||||
0.002164659,
|
||||
0.006313635,
|
||||
0.011789103,
|
||||
0.018545660,
|
||||
0.026414396,
|
||||
0.035100710,
|
||||
0.044196567,
|
||||
0.053207202,
|
||||
0.061590275,
|
||||
0.068803602,
|
||||
0.074356193,
|
||||
0.077856564,
|
||||
0.079052396);
|
||||
#endif
|
||||
// end ntsc-decode-filter-3phase
|
||||
|
||||
#define fetch_offset(offset, one_x) \
|
||||
texture(Source, vTexCoord + vec2((offset) * (one_x), 0.0)).xyz
|
||||
|
||||
#if defined(VERTEX)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING out
|
||||
#define COMPAT_ATTRIBUTE in
|
||||
#define COMPAT_TEXTURE texture
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define COMPAT_ATTRIBUTE attribute
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
COMPAT_ATTRIBUTE vec4 VertexCoord;
|
||||
COMPAT_ATTRIBUTE vec4 COLOR;
|
||||
COMPAT_ATTRIBUTE vec4 TexCoord;
|
||||
COMPAT_VARYING vec4 COL0;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
// out variables go here as COMPAT_VARYING whatever
|
||||
|
||||
uniform mat4 MVPMatrix;
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
|
||||
// vertex compatibility #defines
|
||||
#define vTexCoord TEX0.xy
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = MVPMatrix * VertexCoord;
|
||||
COL0 = COLOR;
|
||||
TEX0.xy = TexCoord - vec2(0.5 / SourceSize.x, 0.0); // Compensate for decimate-by-2.
|
||||
}
|
||||
|
||||
#elif defined(FRAGMENT)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING in
|
||||
#define COMPAT_TEXTURE texture
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define FragColor gl_FragColor
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||||
precision highp float;
|
||||
#else
|
||||
precision mediump float;
|
||||
#endif
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
uniform sampler2D Texture;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
// in variables go here as COMPAT_VARYING whatever
|
||||
|
||||
// fragment compatibility #defines
|
||||
#define Source Texture
|
||||
#define vTexCoord TEX0.xy
|
||||
#define texture(c, d) COMPAT_TEXTURE(c, d)
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
void main()
|
||||
{
|
||||
// begin ntsc-pass2-decode
|
||||
float one_x = 1.0 / SourceSize.x;
|
||||
vec3 signal = vec3(0.0);
|
||||
#ifdef GL_ES
|
||||
float offset;
|
||||
vec3 sums;
|
||||
|
||||
// unrolling the loopz
|
||||
// TAP = 1
|
||||
offset = 0.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter1, chroma_filter1, chroma_filter1);
|
||||
|
||||
// TAP = 2
|
||||
offset = 1.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter2, chroma_filter2, chroma_filter2);
|
||||
|
||||
// TAP = 3
|
||||
offset = 2.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter3, chroma_filter3, chroma_filter3);
|
||||
|
||||
// TAP = 4
|
||||
offset = 3.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter4, chroma_filter4, chroma_filter4);
|
||||
|
||||
// TAP = 5
|
||||
offset = 4.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter5, chroma_filter5, chroma_filter5);
|
||||
|
||||
// TAP = 6
|
||||
offset = 5.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter6, chroma_filter6, chroma_filter6);
|
||||
|
||||
// TAP = 7
|
||||
offset = 6.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter7, chroma_filter7, chroma_filter7);
|
||||
|
||||
// TAP = 8
|
||||
offset = 7.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter8, chroma_filter8, chroma_filter8);
|
||||
|
||||
// TAP = 9
|
||||
offset = 8.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter9, chroma_filter9, chroma_filter9);
|
||||
|
||||
// TAP = 10
|
||||
offset = 9.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter10, chroma_filter10, chroma_filter10);
|
||||
|
||||
// TAP = 11
|
||||
offset = 10.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter11, chroma_filter11, chroma_filter11);
|
||||
|
||||
// TAP = 12
|
||||
offset = 11.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter12, chroma_filter12, chroma_filter12);
|
||||
|
||||
// TAP = 13
|
||||
offset = 12.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter13, chroma_filter13, chroma_filter13);
|
||||
|
||||
// TAP = 14
|
||||
offset = 13.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter14, chroma_filter14, chroma_filter14);
|
||||
|
||||
// TAP = 15
|
||||
offset = 14.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter15, chroma_filter15, chroma_filter15);
|
||||
|
||||
// TAP = 16
|
||||
offset = 15.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter16, chroma_filter16, chroma_filter16);
|
||||
|
||||
// TAP = 17
|
||||
offset = 16.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter17, chroma_filter17, chroma_filter17);
|
||||
|
||||
// TAP = 18
|
||||
offset = 17.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter18, chroma_filter18, chroma_filter18);
|
||||
|
||||
// TAP = 19
|
||||
offset = 18.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter19, chroma_filter19, chroma_filter19);
|
||||
|
||||
// TAP = 20
|
||||
offset = 19.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter20, chroma_filter20, chroma_filter20);
|
||||
|
||||
// TAP = 21
|
||||
offset = 20.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter21, chroma_filter21, chroma_filter21);
|
||||
|
||||
// TAP = 22
|
||||
offset = 21.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter22, chroma_filter22, chroma_filter22);
|
||||
|
||||
// TAP = 23
|
||||
offset = 22.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter23, chroma_filter23, chroma_filter23);
|
||||
|
||||
// TAP = 24
|
||||
offset = 23.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter24, chroma_filter24, chroma_filter24);
|
||||
|
||||
signal += COMPAT_TEXTURE(Texture, TEX0.xy).xyz *
|
||||
vec3(luma_filter25, chroma_filter25, chroma_filter25);
|
||||
#else
|
||||
for (int i = 0; i < TAPS; i++)
|
||||
{
|
||||
float offset = float(i);
|
||||
|
||||
vec3 sums = fetch_offset(offset - float(TAPS), one_x) +
|
||||
fetch_offset(float(TAPS) - offset, one_x);
|
||||
|
||||
signal += sums * vec3(luma_filter[i], chroma_filter[i], chroma_filter[i]);
|
||||
}
|
||||
signal += texture(Source, vTexCoord).xyz *
|
||||
vec3(luma_filter[TAPS], chroma_filter[TAPS], chroma_filter[TAPS]);
|
||||
#endif
|
||||
// end ntsc-pass2-decode
|
||||
vec3 rgb = yiq2rgb(signal);
|
||||
FragColor = vec4(pow(rgb, vec3(NTSC_CRT_GAMMA)), 1.0);
|
||||
}
|
||||
#endif
|
402
ntsc/shaders/ntsc-pass2-3phase.glsl
Normal file
402
ntsc/shaders/ntsc-pass2-3phase.glsl
Normal file
@ -0,0 +1,402 @@
|
||||
// Compatibility #ifdefs needed for parameters
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
// begin ntsc-rgbyuv
|
||||
mat3 yiq2rgb_mat = mat3(
|
||||
1.0, 1.0, 1.0,
|
||||
0.956, -0.2720, -1.1060,
|
||||
0.6210, -0.6474, 1.7046
|
||||
);
|
||||
|
||||
vec3 yiq2rgb(vec3 yiq)
|
||||
{
|
||||
return (yiq * yiq2rgb_mat);
|
||||
}
|
||||
|
||||
mat3 yiq_mat = mat3(
|
||||
0.2989, 0.5959, 0.2115,
|
||||
0.5870, -0.2744, -0.5229,
|
||||
0.1140, -0.3216, 0.3114
|
||||
);
|
||||
|
||||
vec3 rgb2yiq(vec3 col)
|
||||
{
|
||||
return (col * yiq_mat);
|
||||
}
|
||||
// end ntsc-rgbyuv
|
||||
|
||||
// begin ntsc-decode-filter-3phase
|
||||
#ifdef GL_ES
|
||||
float luma_filter1 = -0.000012020;
|
||||
float luma_filter2 = -0.000022146;
|
||||
float luma_filter3 = -0.000013155;
|
||||
float luma_filter4 = -0.000012020;
|
||||
float luma_filter5 = -0.000049979;
|
||||
float luma_filter6 = -0.000113940;
|
||||
float luma_filter7 = -0.000122150;
|
||||
float luma_filter8 = -0.000005612;
|
||||
float luma_filter9 = 0.000170516;
|
||||
float luma_filter10 = 0.000237199;
|
||||
float luma_filter11 = 0.000169640;
|
||||
float luma_filter12 = 0.000285688;
|
||||
float luma_filter13 = 0.000984574;
|
||||
float luma_filter14 = 0.002018683;
|
||||
float luma_filter15 = 0.002002275;
|
||||
float luma_filter16 = -0.000909882;
|
||||
float luma_filter17 = -0.007049081;
|
||||
float luma_filter18 = -0.013222860;
|
||||
float luma_filter19 = -0.012606931;
|
||||
float luma_filter20 = 0.002460860;
|
||||
float luma_filter21 = 0.035868225;
|
||||
float luma_filter22 = 0.084016453;
|
||||
float luma_filter23 = 0.135563500;
|
||||
float luma_filter24 = 0.175261268;
|
||||
float luma_filter25 = 0.190176552;
|
||||
|
||||
float chroma_filter1 = -0.000118847;
|
||||
float chroma_filter2 = -0.000271306;
|
||||
float chroma_filter3 = -0.000502642;
|
||||
float chroma_filter4 = -0.000930833;
|
||||
float chroma_filter5 = -0.001451013;
|
||||
float chroma_filter6 = -0.002064744;
|
||||
float chroma_filter7 = -0.002700432;
|
||||
float chroma_filter8 = -0.003241276;
|
||||
float chroma_filter9 = -0.003524948;
|
||||
float chroma_filter10 = -0.003350284;
|
||||
float chroma_filter11 = -0.002491729;
|
||||
float chroma_filter12 = -0.000721149;
|
||||
float chroma_filter13 = 0.002164659;
|
||||
float chroma_filter14 = 0.006313635;
|
||||
float chroma_filter15 = 0.011789103;
|
||||
float chroma_filter16 = 0.018545660;
|
||||
float chroma_filter17 = 0.026414396;
|
||||
float chroma_filter18 = 0.035100710;
|
||||
float chroma_filter19 = 0.044196567;
|
||||
float chroma_filter20 = 0.053207202;
|
||||
float chroma_filter21 = 0.061590275;
|
||||
float chroma_filter22 = 0.068803602;
|
||||
float chroma_filter23 = 0.074356193;
|
||||
float chroma_filter24 = 0.077856564;
|
||||
float chroma_filter25 = 0.079052396;
|
||||
#else
|
||||
#define TAPS 24
|
||||
const float luma_filter[TAPS + 1] = float[TAPS + 1](
|
||||
-0.000012020,
|
||||
-0.000022146,
|
||||
-0.000013155,
|
||||
-0.000012020,
|
||||
-0.000049979,
|
||||
-0.000113940,
|
||||
-0.000122150,
|
||||
-0.000005612,
|
||||
0.000170516,
|
||||
0.000237199,
|
||||
0.000169640,
|
||||
0.000285688,
|
||||
0.000984574,
|
||||
0.002018683,
|
||||
0.002002275,
|
||||
-0.000909882,
|
||||
-0.007049081,
|
||||
-0.013222860,
|
||||
-0.012606931,
|
||||
0.002460860,
|
||||
0.035868225,
|
||||
0.084016453,
|
||||
0.135563500,
|
||||
0.175261268,
|
||||
0.190176552);
|
||||
|
||||
const float chroma_filter[TAPS + 1] = float[TAPS + 1](
|
||||
-0.000118847,
|
||||
-0.000271306,
|
||||
-0.000502642,
|
||||
-0.000930833,
|
||||
-0.001451013,
|
||||
-0.002064744,
|
||||
-0.002700432,
|
||||
-0.003241276,
|
||||
-0.003524948,
|
||||
-0.003350284,
|
||||
-0.002491729,
|
||||
-0.000721149,
|
||||
0.002164659,
|
||||
0.006313635,
|
||||
0.011789103,
|
||||
0.018545660,
|
||||
0.026414396,
|
||||
0.035100710,
|
||||
0.044196567,
|
||||
0.053207202,
|
||||
0.061590275,
|
||||
0.068803602,
|
||||
0.074356193,
|
||||
0.077856564,
|
||||
0.079052396);
|
||||
#endif
|
||||
// end ntsc-decode-filter-3phase
|
||||
|
||||
#define fetch_offset(offset, one_x) \
|
||||
texture(Source, vTexCoord + vec2((offset) * (one_x), 0.0)).xyz
|
||||
|
||||
#if defined(VERTEX)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING out
|
||||
#define COMPAT_ATTRIBUTE in
|
||||
#define COMPAT_TEXTURE texture
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define COMPAT_ATTRIBUTE attribute
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
COMPAT_ATTRIBUTE vec4 VertexCoord;
|
||||
COMPAT_ATTRIBUTE vec4 COLOR;
|
||||
COMPAT_ATTRIBUTE vec4 TexCoord;
|
||||
COMPAT_VARYING vec4 COL0;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
// out variables go here as COMPAT_VARYING whatever
|
||||
|
||||
uniform mat4 MVPMatrix;
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
|
||||
// vertex compatibility #defines
|
||||
#define vTexCoord TEX0.xy
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = MVPMatrix * VertexCoord;
|
||||
COL0 = COLOR;
|
||||
TEX0.xy = TexCoord - vec2(0.5 / SourceSize.x, 0.0); // Compensate for decimate-by-2.
|
||||
}
|
||||
|
||||
#elif defined(FRAGMENT)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING in
|
||||
#define COMPAT_TEXTURE texture
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define FragColor gl_FragColor
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||||
precision highp float;
|
||||
#else
|
||||
precision mediump float;
|
||||
#endif
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
uniform sampler2D Texture;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
// in variables go here as COMPAT_VARYING whatever
|
||||
|
||||
// fragment compatibility #defines
|
||||
#define Source Texture
|
||||
#define vTexCoord TEX0.xy
|
||||
#define texture(c, d) COMPAT_TEXTURE(c, d)
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
void main()
|
||||
{
|
||||
// begin ntsc-pass2-decode
|
||||
float one_x = 1.0 / SourceSize.x;
|
||||
vec3 signal = vec3(0.0);
|
||||
#ifdef GL_ES
|
||||
float offset;
|
||||
vec3 sums;
|
||||
|
||||
// unrolling the loopz
|
||||
// TAP = 1
|
||||
offset = 0.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter1, chroma_filter1, chroma_filter1);
|
||||
|
||||
// TAP = 2
|
||||
offset = 1.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter2, chroma_filter2, chroma_filter2);
|
||||
|
||||
// TAP = 3
|
||||
offset = 2.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter3, chroma_filter3, chroma_filter3);
|
||||
|
||||
// TAP = 4
|
||||
offset = 3.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter4, chroma_filter4, chroma_filter4);
|
||||
|
||||
// TAP = 5
|
||||
offset = 4.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter5, chroma_filter5, chroma_filter5);
|
||||
|
||||
// TAP = 6
|
||||
offset = 5.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter6, chroma_filter6, chroma_filter6);
|
||||
|
||||
// TAP = 7
|
||||
offset = 6.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter7, chroma_filter7, chroma_filter7);
|
||||
|
||||
// TAP = 8
|
||||
offset = 7.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter8, chroma_filter8, chroma_filter8);
|
||||
|
||||
// TAP = 9
|
||||
offset = 8.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter9, chroma_filter9, chroma_filter9);
|
||||
|
||||
// TAP = 10
|
||||
offset = 9.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter10, chroma_filter10, chroma_filter10);
|
||||
|
||||
// TAP = 11
|
||||
offset = 10.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter11, chroma_filter11, chroma_filter11);
|
||||
|
||||
// TAP = 12
|
||||
offset = 11.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter12, chroma_filter12, chroma_filter12);
|
||||
|
||||
// TAP = 13
|
||||
offset = 12.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter13, chroma_filter13, chroma_filter13);
|
||||
|
||||
// TAP = 14
|
||||
offset = 13.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter14, chroma_filter14, chroma_filter14);
|
||||
|
||||
// TAP = 15
|
||||
offset = 14.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter15, chroma_filter15, chroma_filter15);
|
||||
|
||||
// TAP = 16
|
||||
offset = 15.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter16, chroma_filter16, chroma_filter16);
|
||||
|
||||
// TAP = 17
|
||||
offset = 16.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter17, chroma_filter17, chroma_filter17);
|
||||
|
||||
// TAP = 18
|
||||
offset = 17.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter18, chroma_filter18, chroma_filter18);
|
||||
|
||||
// TAP = 19
|
||||
offset = 18.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter19, chroma_filter19, chroma_filter19);
|
||||
|
||||
// TAP = 20
|
||||
offset = 19.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter20, chroma_filter20, chroma_filter20);
|
||||
|
||||
// TAP = 21
|
||||
offset = 20.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter21, chroma_filter21, chroma_filter21);
|
||||
|
||||
// TAP = 22
|
||||
offset = 21.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter22, chroma_filter22, chroma_filter22);
|
||||
|
||||
// TAP = 23
|
||||
offset = 22.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter23, chroma_filter23, chroma_filter23);
|
||||
|
||||
// TAP = 24
|
||||
offset = 23.;
|
||||
sums = fetch_offset(offset - 24., one_x) +
|
||||
fetch_offset(24. - offset, one_x);
|
||||
signal += sums * vec3(luma_filter24, chroma_filter24, chroma_filter24);
|
||||
|
||||
signal += COMPAT_TEXTURE(Texture, TEX0.xy).xyz *
|
||||
vec3(luma_filter25, chroma_filter25, chroma_filter25);
|
||||
#else
|
||||
for (int i = 0; i < TAPS; i++)
|
||||
{
|
||||
float offset = float(i);
|
||||
|
||||
vec3 sums = fetch_offset(offset - float(TAPS), one_x) +
|
||||
fetch_offset(float(TAPS) - offset, one_x);
|
||||
|
||||
signal += sums * vec3(luma_filter[i], chroma_filter[i], chroma_filter[i]);
|
||||
}
|
||||
signal += texture(Source, vTexCoord).xyz *
|
||||
vec3(luma_filter[TAPS], chroma_filter[TAPS], chroma_filter[TAPS]);
|
||||
#endif
|
||||
// end ntsc-pass2-decode
|
||||
vec3 rgb = yiq2rgb(signal);
|
||||
FragColor = vec4(rgb, 1.0);
|
||||
}
|
||||
#endif
|
110
ntsc/shaders/ntsc-stock.glsl
Normal file
110
ntsc/shaders/ntsc-stock.glsl
Normal file
@ -0,0 +1,110 @@
|
||||
// Compatibility #ifdefs needed for parameters
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
// Parameter lines go here:
|
||||
#pragma parameter RETRO_PIXEL_SIZE "Retro Pixel Size" 0.84 0.0 1.0 0.01
|
||||
#ifdef PARAMETER_UNIFORM
|
||||
// All parameter floats need to have COMPAT_PRECISION in front of them
|
||||
uniform COMPAT_PRECISION float RETRO_PIXEL_SIZE;
|
||||
#else
|
||||
#define RETRO_PIXEL_SIZE 0.84
|
||||
#endif
|
||||
|
||||
#if defined(VERTEX)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING out
|
||||
#define COMPAT_ATTRIBUTE in
|
||||
#define COMPAT_TEXTURE texture
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define COMPAT_ATTRIBUTE attribute
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
COMPAT_ATTRIBUTE vec4 VertexCoord;
|
||||
COMPAT_ATTRIBUTE vec4 COLOR;
|
||||
COMPAT_ATTRIBUTE vec4 TexCoord;
|
||||
COMPAT_VARYING vec4 COL0;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
// out variables go here as COMPAT_VARYING whatever
|
||||
|
||||
uniform mat4 MVPMatrix;
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
|
||||
// vertex compatibility #defines
|
||||
#define vTexCoord TEX0.xy
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = MVPMatrix * VertexCoord;
|
||||
COL0 = COLOR;
|
||||
TEX0.xy = TexCoord.xy;
|
||||
// Paste vertex contents here:
|
||||
|
||||
}
|
||||
|
||||
#elif defined(FRAGMENT)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING in
|
||||
#define COMPAT_TEXTURE texture
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define FragColor gl_FragColor
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||||
precision highp float;
|
||||
#else
|
||||
precision mediump float;
|
||||
#endif
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
uniform sampler2D Texture;
|
||||
COMPAT_VARYING vec4 TEX0;
|
||||
// in variables go here as COMPAT_VARYING whatever
|
||||
|
||||
// fragment compatibility #defines
|
||||
#define Source Texture
|
||||
#define vTexCoord TEX0.xy
|
||||
#define texture(c, d) COMPAT_TEXTURE(c, d)
|
||||
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
|
||||
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
|
||||
|
||||
// delete all 'params.' or 'registers.' or whatever in the fragment
|
||||
|
||||
void main()
|
||||
{
|
||||
// Paste fragment contents here:
|
||||
|
||||
FragColor = texture(Source, vTexCoord);
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user