add a520 glsl (#268)

* Add files via upload

* Add files via upload

* Update ntsc-simple.glsl

Replaced with a better shader

* Update ntsc-simple.glslp

* Update Amiga_a520.glslp

* Add files via upload

* Update glow_x.glsl

* Update glow_y.glsl

* Update crt-consumer.glslp

* Update crt-consumer.glsl

* Update C64_res_enchance.glslp

* Add files via upload
This commit is contained in:
metallic77 2023-08-16 21:35:04 +03:00 committed by GitHub
parent 2a895ed500
commit 4e59bb1d43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 491 additions and 166 deletions

View File

@ -1,7 +1,9 @@
shaders = "3"
shader0 = shaders/crt-consumer/glow_x.glsl
shaders = "4"
shader0 = shaders/crt-consumer/linearize.glsl
filter_linear0 = "false"
shader1 = shaders/crt-consumer/glow_y.glsl
shader1 = shaders/crt-consumer/glow_x.glsl
filter_linear1 = "false"
shader2 = shaders/crt-consumer/crt-consumer.glsl
filter_linear2 = "true"
shader2 = shaders/crt-consumer/glow_y.glsl
filter_linear2 = "false"
shader3 = shaders/crt-consumer/crt-consumer.glsl
filter_linear3 = "true"

View File

@ -1,4 +1,4 @@
#version 110
// Parameter lines go here:
#pragma parameter blurx "Convergence X" 0.25 -2.0 2.0 0.05
#pragma parameter blury "Convergence Y" -0.15 -2.0 2.0 0.05
@ -33,6 +33,7 @@
#pragma parameter vstr " Vignette strength" 45.0 0.0 50.0 1.0
#pragma parameter sawtooth " Sawtooth Effect" 1.0 0.0 1.0 1.0
#pragma parameter bleed " Color Bleed Effect" 1.0 0.0 1.0 1.0
#pragma parameter bl_size " Color Bleed Size" 0.75 0.1 2.0 0.05
#pragma parameter alloff " Switch off shader" 0.0 0.0 1.0 1.0
#define pi 6.28318
@ -151,6 +152,7 @@ uniform COMPAT_PRECISION float alloff;
uniform COMPAT_PRECISION float GLOW_LINE;
uniform COMPAT_PRECISION float sawtooth;
uniform COMPAT_PRECISION float bleed;
uniform COMPAT_PRECISION float bl_size;
#else
#define blurx 0.0
@ -187,6 +189,7 @@ uniform COMPAT_PRECISION float bleed;
#define GLOW_LINE 0.0
#define sawtooth 0.0
#define bleed 0.0
#define bl_size 1.0
#endif
@ -505,8 +508,9 @@ void main()
vec4 res = vec4(1.0);
if (alloff == 1.0) res= COMPAT_TEXTURE(Source,pC4);
if (alloff == 1.0) {res= COMPAT_TEXTURE(Source,pC4);
res = pow(res,vec4(1.0/GAMMA_OUT));
}
else
{
vec3 sample1 = COMPAT_TEXTURE(Source,vec2(pC4.x + blurx*0.001, pC4.y - blury*0.001)).rgb;
@ -532,9 +536,9 @@ if (bleed == 1.0){
vec3 yuv = vec3(0.0);
float px = 0.0;
for( int x = -2; x <= 2; x++ ) {
px = float(x) * SourceSize.z - SourceSize.w * 0.5;
yuv.g += RGB2U( texture2D( Source, pC4 + vec2(px, 0.0)).rgb ) * a_kernel[x + 2];
yuv.b += RGB2V( texture2D( Source, pC4 + vec2(px, 0.0)).rgb ) * a_kernel[x + 2];
px = float(x)/bl_size * SourceSize.z - SourceSize.w * 0.5;
yuv.g += RGB2U( COMPAT_TEXTURE( Source, pC4 + vec2(px, 0.0)).rgb ) * a_kernel[x + 2];
yuv.b += RGB2V( COMPAT_TEXTURE( Source, pC4 + vec2(px, 0.0)).rgb ) * a_kernel[x + 2];
}
yuv.r = RGB2Y(color.rgb);

View File

@ -1,7 +1,6 @@
#version 130
#pragma parameter gammain "Gamma In" 2.5 1.0 4.0 0.05
#pragma parameter glow "Glow Strength" 0.4 0.0 1.0 0.05
#pragma parameter sizex "Glow Size X" 1.0 0.0 1.25 0.05
#pragma parameter glow "Glow Strength" 0.15 0.0 1.0 0.01
#pragma parameter sizex "Glow Size X" 1.0 0.0 2.0 0.05
#if defined(VERTEX)
@ -109,9 +108,8 @@ void main()
{
sum += COMPAT_TEXTURE(Source,(pos + i*dx)*tex).rgb * k[int(i) + 3];
}
res = (res + sum*glow)/(1.0+glow);
res = pow(res,vec3(gammain));
res = (res + sum*glow);
FragColor = vec4(res,1.0);
}
#endif
#endif

View File

@ -1,5 +1,5 @@
#version 130
#pragma parameter sizey "Glow Size Y" 0.25 0.0 1.0 0.05
#pragma parameter sizey "Glow Size Y" 0.5 0.0 1.0 0.05
#if defined(VERTEX)
@ -106,8 +106,8 @@ void main()
{
sum += COMPAT_TEXTURE(Source,(pos + i*dy)*tex).rgb * k[int(i) + 3];
}
res = (res+sum*glow)/(1.0+glow);
res = (res+sum*glow);
FragColor = vec4(res,1.0);
}
#endif
#endif

View File

@ -0,0 +1,103 @@
#version 110
#pragma parameter gammain "Gamma In" 2.6 1.0 4.0 0.05
#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;
vec4 _oPosition1;
uniform mat4 MVPMatrix;
uniform COMPAT_PRECISION int FrameDirection;
uniform COMPAT_PRECISION int FrameCount;
uniform COMPAT_PRECISION vec2 OutputSize;
uniform COMPAT_PRECISION vec2 TextureSize;
uniform COMPAT_PRECISION vec2 InputSize;
// compatibility #defines
#define vTexCoord TEX0.xy
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define OutSize vec4(OutputSize, 1.0 / OutputSize)
void main()
{
gl_Position = MVPMatrix * VertexCoord;
TEX0.xy = TexCoord.xy*1.0001;
}
#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 COMPAT_PRECISION int FrameDirection;
uniform COMPAT_PRECISION int FrameCount;
uniform COMPAT_PRECISION vec2 OutputSize;
uniform COMPAT_PRECISION vec2 TextureSize;
uniform COMPAT_PRECISION vec2 InputSize;
uniform sampler2D Texture;
COMPAT_VARYING vec4 TEX0;
// compatibility #defines
#define Source Texture
#define vTexCoord TEX0.xy
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define OutSize vec4(OutputSize, 1.0 / OutputSize)
#ifdef PARAMETER_UNIFORM
uniform COMPAT_PRECISION float sizex;
uniform COMPAT_PRECISION float glow;
uniform COMPAT_PRECISION float gammain;
#else
#define sizex 1.0
#define glow 1.0
#define gammain 2.5
#endif
void main()
{
vec4 res = COMPAT_TEXTURE(Source,vTexCoord);
res = pow(res,vec4(gammain,gammain,gammain,1.0));
FragColor = res;
}
#endif

View File

@ -2,4 +2,8 @@ shaders = 1
shader0 = shaders/ntsc-simple/ntsc-simple.glsl
filter_linear0 = false
scale_type_x0 = "source"
scale_x0 = "1.000000"
scale_type_y0 = "source"
scale_y0 = "1.000000"

View File

@ -1,5 +1,4 @@
#version 110
/*
Simple S-video like shader by DariusG 2023
This program is free software; you can redistribute it and/or modify it
@ -7,16 +6,15 @@
Software Foundation; either version 2 of the License, or (at your option)
any later version.
*/
#pragma parameter distortion "Overall Distortion" 0.25 0.0 1.0 0.01
#pragma parameter artifacts "Artifacts Strength" 0.01 0.0 1.0 0.01
#pragma parameter fringing "Fringing Strength" 0.06 0.0 1.0 0.01
#pragma parameter bleed "Color Bleed Strength" 0.25 0.0 1.0 0.01
#pragma parameter rad "Color Bleed Radius" 1.0 0.0 3.0 0.05
#pragma parameter brightness "NTSC Brightness" 1.0 0.0 2.0 0.05
#pragma parameter contrast "NTSC Contrast" 1.0 0.0 2.0 0.05
#pragma parameter sat "NTSC Saturation" 1.0 0.0 2.0 0.05
#pragma parameter NTSC "NTSC Colors" 1.0 0.0 1.0 1.0
#pragma parameter CHR_BLUR "CHROMA RESOLUTION" 1.5 1.0 10.0 0.1
#pragma parameter L_BLUR "LUMA RESOLUTION" 8.0 2.0 10.0 0.25
#pragma parameter CHROMA_SATURATION "CHROMA SATURATION" 5.0 0.0 15.0 0.1
#pragma parameter BRIGHTNESS "LUMA BRIGHTNESS" 0.55 0.0 2.0 0.01
#pragma parameter IHUE "I SHIFT (blue to orange)" 0.0 -1.0 1.0 0.01
#pragma parameter QHUE "Q SHIFT (green to purple)" 0.0 -1.0 1.0 0.01
// https://www.shadertoy.com/view/wlBcWG
#if defined(VERTEX)
#if __VERSION__ >= 130
@ -54,10 +52,16 @@ uniform COMPAT_PRECISION vec2 InputSize;
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define OutSize vec4(OutputSize, 1.0 / OutputSize)
#ifdef PARAMETER_UNIFORM
uniform COMPAT_PRECISION float WHATEVER;
#else
#define WHATEVER 0.0
#endif
void main()
{
gl_Position = MVPMatrix * VertexCoord;
TEX0.xy = TexCoord.xy;
TEX0.xy = TexCoord.xy*1.0001;
}
#elif defined(FRAGMENT)
@ -99,153 +103,96 @@ COMPAT_VARYING vec4 TEX0;
#define OutSize vec4(OutputSize, 1.0 / OutputSize)
#ifdef PARAMETER_UNIFORM
uniform COMPAT_PRECISION float distortion;
uniform COMPAT_PRECISION float artifacts;
uniform COMPAT_PRECISION float fringing;
uniform COMPAT_PRECISION float bleed;
uniform COMPAT_PRECISION float rad;
uniform COMPAT_PRECISION float contrast;
uniform COMPAT_PRECISION float brightness;
uniform COMPAT_PRECISION float sat;
uniform COMPAT_PRECISION float NTSC;
uniform COMPAT_PRECISION float CHR_BLUR;
uniform COMPAT_PRECISION float L_BLUR;
uniform COMPAT_PRECISION float CHROMA_SATURATION;
uniform COMPAT_PRECISION float BRIGHTNESS;
uniform COMPAT_PRECISION float IHUE;
uniform COMPAT_PRECISION float QHUE;
#else
#define distortion 0.25
#define artifacts 0.01
#define fringing 0.06
#define bleed 0.5
#define rad 2.0
#define contrast 1.0
#define brightness 1.0
#define sat 1.0
#define NTSC 1.0
#define CHR_BLUR 4.0
#define L_BLUR 12.0
#define CHROMA_SATURATION 7.0
#define BRIGHTNESS 10.0
#define IHUE 0.0
#define QHUE 0.0
#endif
#define PI 3.14159265
#define time float (FrameCount)
#define PI 3.14159265358979323846
#define TAU 6.28318530717958647693
#define FSC 3.57945*4.0
// Size of the decoding FIR filter
#define FIR_SIZE 20
float RGB2Y(vec3 _rgb) {
return dot(_rgb, vec3(0.29900, 0.58700, 0.11400));
// YIQ to RGB matrices
const mat3 yiq_to_rgb = mat3(1.000, 1.000, 1.000,
0.956,-0.272,-1.106,
0.621,-0.647, 1.703);
const mat3 rgb_to_yiq = mat3(0.299, 0.596, 0.211,
0.587,-0.274,-0.523,
0.114,-0.322, 0.312);
float blackman(float n, float N) {
float a0 = (1.0 - 0.16) / 2.0;
float a1 = 1.0 / 2.0;
float a2 = 0.16 / 2.0;
return a0 - (a1 * cos((2.0 * PI * n) / N)) + (a2 * cos((4.0 * PI * n) / N));
}
float RGB2U(vec3 _rgb) {
return dot(_rgb, vec3(-0.14713, -0.28886, 0.43600));
}
float RGB2V(vec3 _rgb) {
return dot(_rgb, vec3(0.61500, -0.51499, -0.10001));
}
float YUV2R(vec3 _yuv) {
return dot(_yuv, vec3(1, 0.00000, 1.13983));
}
float YUV2G(vec3 _yuv) {
return dot(_yuv, vec3(1.0, -0.39465, -0.58060));
}
float YUV2B(vec3 _yuv) {
return dot(_yuv, vec3(1.0, 2.03211, 0.00000));
}
vec3 YUV2RGB(vec3 _yuv) {
vec3 _rgb;
_rgb.r = YUV2R(_yuv);
_rgb.g = YUV2G(_yuv);
_rgb.b = YUV2B(_yuv);
return _rgb;
}
vec3 RGB2YUV(vec3 _rgb) {
vec3 _yuv;
_yuv.r = RGB2Y(_rgb);
_yuv.g = RGB2U(_rgb);
_yuv.b = RGB2V(_rgb);
return _yuv;
}
float Overlay(float col, float M) {
col += 0.5;
M += 0.5;
return (col * (col + (2.0 * M)*(1.0 - col))) -0.5;
}
//non linear approximate (but not exact)
const mat3 ntsc = mat3 (
1.5164, -0.4945, -0.02,
-0.0372, 0.9571, 0.0802,
-0.0192, -0.0309, 1.0500
);
void main() {
// moved due to GLES fix.
mat3 mix_mat = mat3(
1.0, 0.0, 0.0,
IHUE, 1.0, 0.0,
QHUE, 0.0, 1.0
);
float kernel[3];
kernel[0] = 0.2;
kernel[1] = 0.5;
kernel[2] = 0.3;
// Chroma decoder oscillator frequency
float fc = SourceSize.x*TAU;
float kernelb[5];
kernelb[0] = 2.0*bleed;
kernelb[1] = 4.0*bleed;
kernelb[2] = 1.0;
kernelb[3] = 4.0*bleed;
kernelb[4] = 2.0*bleed;
float odd = mod(abs(vTexCoord.x*SourceSize.x + vTexCoord.y*SourceSize.y) + 0.5, 2.0);
float distort = SourceSize.z* odd * distortion;
float counter = 0.0;
vec3 yiq = vec3(0.0);
// UV distortion
vec4 color_out = COMPAT_TEXTURE( Source, vTexCoord );
color_out += COMPAT_TEXTURE( Source, vTexCoord + vec2( distort, 0.0 ) );
color_out += COMPAT_TEXTURE( Source, vTexCoord - vec2( distort, 0.0 ) );
vec3 YUV = RGB2YUV(color_out.rgb*0.3333);
for (int d = -FIR_SIZE; d < FIR_SIZE; d++) {
//luma encode/decode
vec2 pos = vec2((vTexCoord.x + (float(d)/2.0/L_BLUR)*SourceSize.z), vTexCoord.y);
vec3 s = COMPAT_TEXTURE(Source, pos).rgb;
s = rgb_to_yiq*s;
// encode end
// decode
// Apply Blackman window for smoother colors
float window = blackman(float(d/2 + 5), float(FIR_SIZE/2));
// Y distortion for fringing/artifacts
vec3 Ycol = vec3(0.0);
Ycol += COMPAT_TEXTURE( Source, vTexCoord - vec2( SourceSize.x * distort, 0.0) ).rgb * kernel[0];
Ycol += COMPAT_TEXTURE( Source, vTexCoord + vec2( distort, 0.0 ) ).rgb * kernel[1];
Ycol += COMPAT_TEXTURE( Source, vTexCoord + vec2( SourceSize.x * distort, 0.0) ).rgb * kernel[2];
float Y = RGB2Y(Ycol);
if( floor(odd) == 0.0 ) Y = -Y;
// Color Bleeding
float px;
for(int x = -2; x <= 2; x++ ) {
px = float(x) * SourceSize.z - SourceSize.w * 0.5;
float T = floor(mod(time,2.0));
YUV.g += RGB2U (COMPAT_TEXTURE( Source, vTexCoord + vec2(px*rad, 0.0) ).rgb) * kernelb[x+2];
YUV.g += RGB2U (COMPAT_TEXTURE( Source, vTexCoord - vec2(px*rad, 0.0) ).rgb) * kernelb[x+2];
YUV.b += RGB2V (COMPAT_TEXTURE( Source, vTexCoord + vec2(px*rad, 0.0) ).rgb) * kernelb[x+2];
YUV.b += RGB2V (COMPAT_TEXTURE( Source, vTexCoord - vec2(px*rad, 0.0) ).rgb) * kernelb[x+2];
yiq.r += s.r * BRIGHTNESS * window;
// chroma encode/decode
pos = vec2(vTexCoord.x + (float(d)/CHR_BLUR)*SourceSize.z, vTexCoord.y);
s = COMPAT_TEXTURE(Source, pos).rgb;
s = rgb_to_yiq*s;
s.yz *= vec2(cos(fc*vTexCoord.x+11.0*PI/60.0),sin(fc*vTexCoord.x+11.0*PI/60.0));
// encode end
float wt = fc * (vTexCoord.x - float(d)*SourceSize.z);
// decode
// Apply Blackman window for smoother colors
window = blackman(float(d + FIR_SIZE), float(FIR_SIZE * 2 + 1));
yiq.yz += s.yz * vec2(cos(wt+11.0*PI/60.0), sin(wt+11.0*PI/60.0)) * window;
counter++;
}
YUV.g /= 3.0+24.0*bleed;
YUV.b /= 3.0+24.0*bleed;
// fringing-artifacts
yiq.yz /= counter;
yiq.r /= counter/4.0;
float artifact = Y * artifacts;
float fringing = Y * fringing;
YUV.r = Overlay(YUV.r, artifact);
YUV.g = Overlay(YUV.g, fringing);
YUV.b = Overlay(YUV.b, fringing);
/////////
YUV.r *= brightness;
color_out.rgb = contrast * (YUV2RGB( YUV )-vec3(0.5)) + vec3(0.5);
color_out.rgb = mix(vec3(dot(vec3(0.3,0.6,0.1),color_out.rgb)),color_out.rgb,sat);
if (NTSC == 1.0) color_out.rgb = color_out.rgb*ntsc;
color_out - clamp(color_out,0.0,1.0);
FragColor = color_out;
// Saturate chroma (IQ)
yiq.yz *= CHROMA_SATURATION;
yiq *= mix_mat;
FragColor = vec4((yiq_to_rgb * yiq), 1.0);
}
#endif

4
pal/Amiga_a520.glslp Normal file
View File

@ -0,0 +1,4 @@
shaders = "1"
feedback_pass = "0"
shader0 = "shaders/a520.glsl"
filter_linear0 = "true"

235
pal/shaders/a520.glsl Normal file
View File

@ -0,0 +1,235 @@
#version 120
/*
A modification of Retroarch PAL Shader
to look-alike an Amiga A520 Composite
TV-modulator.
Made by DariusG at Aug.2023
*/
#pragma parameter FIR_GAIN "FIR Gain" 1.62 0.0 3.0 0.01
#pragma parameter FIR_INVGAIN "FIR Inv Gain" 1.0 0.0 3.0 0.01
#pragma parameter ihue "I Hue" 0.1 -1.0 1.0 0.01
#pragma parameter qhue "Q Hue" 0.1 -1.0 1.0 0.01
#pragma parameter sat "Saturation" 1.0 0.0 2.0 0.01
#pragma parameter crawl "Dot Crawl" 1.0 0.0 1.0 1.0
#pragma parameter blur "Blur Size" 0.5 0.0 2.0 0.05
#pragma parameter SCAN "Scanline" 0.5 0.0 1.0 0.05
#pragma parameter BLUR "Texel Size" 0.07 0.0 1.0 0.01
#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;
vec4 _oPosition1;
uniform mat4 MVPMatrix;
uniform COMPAT_PRECISION int FrameDirection;
uniform COMPAT_PRECISION int FrameCount;
uniform COMPAT_PRECISION vec2 OutputSize;
uniform COMPAT_PRECISION vec2 TextureSize;
uniform COMPAT_PRECISION vec2 InputSize;
// compatibility #defines
#define vTexCoord TEX0.xy
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define OutSize vec4(OutputSize, 1.0 / OutputSize)
#ifdef PARAMETER_UNIFORM
uniform COMPAT_PRECISION float WHATEVER;
#else
#define WHATEVER 0.0
#endif
void main()
{
gl_Position = MVPMatrix * VertexCoord;
TEX0.xy = TexCoord.xy*1.0001;
}
#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 COMPAT_PRECISION int FrameDirection;
uniform COMPAT_PRECISION int FrameCount;
uniform COMPAT_PRECISION vec2 OutputSize;
uniform COMPAT_PRECISION vec2 TextureSize;
uniform COMPAT_PRECISION vec2 InputSize;
uniform sampler2D Texture;
COMPAT_VARYING vec4 TEX0;
// compatibility #defines
#define Source Texture
#define vTexCoord TEX0.xy
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define OutSize vec4(OutputSize, 1.0 / OutputSize)
#ifdef PARAMETER_UNIFORM
uniform COMPAT_PRECISION float FIR_GAIN;
uniform COMPAT_PRECISION float FIR_INVGAIN;
uniform COMPAT_PRECISION float ihue;
uniform COMPAT_PRECISION float qhue;
uniform COMPAT_PRECISION float sat;
uniform COMPAT_PRECISION float crawl;
uniform COMPAT_PRECISION float blur;
uniform COMPAT_PRECISION float SCAN;
uniform COMPAT_PRECISION float BLUR;
#else
#define FIR_GAIN 2.0
#define FIR_INVGAIN 1.0
#define ihue 0.0
#define qhue 0.0
#define sat 1.0
#define crawl 1.0
#define blur 1.0
#define SCAN 0.4
#define BLUR 0.1
#endif
#define PI 3.14159265358
#define FSC 3579545.0*4.0
#define FLINE 15625.0
#define VISIBLELINES 312.0
#define RGB_to_YIQ mat3( 0.299 , 0.595716 , 0.211456 , 0.587 , -0.274453 , -0.522591 , 0.114 , -0.321263 , 0.311135 )
#define YIQ_to_RGB mat3( 1.0 , 1.0 , 1.0 , 0.9563 , -0.2721 , -1.1070 , 0.6210 , -0.6474 , 1.7046 )
#define RGB_to_YUV mat3( 0.299 , -0.14713 , 0.615 , 0.587 , -0.28886 , -0.514991 , 0.114 , 0.436 , -0.10001 )
#define YUV_to_RGB mat3( 1.0 , 1.0 , 1.0 , 0.0 , -0.39465 , 2.03211 , 1.13983 , -0.58060 , 0.0 )
#define FIRTAPS 20
const float FIR[20] = float[20] (-0.008030271,0.003107906,0.016841352,0.032545161,0.049360136,
0.066256720,0.082120150,0.095848433,0.106453014,0.113151423,
0.115441842,0.113151423,0.106453014,0.095848433,0.082120150,
0.066256720,0.049360136,0.032545161,0.016841352,0.003107906);
//#define FIR_GAIN 2.0
//#define FIR_INVGAIN 1.02
float width_ratio;
float height_ratio;
float altv;
float invx;
vec2 dx;
float crawler;
#define time float(FrameCount)
#define fetch(offset, pos, invx) COMPAT_TEXTURE(Source, vec2(pos.xy + vec2(offset*invx ,0.0)))
float mod_luma(vec2 xy, float sinwt, float coswt) {
vec3 rgb = fetch(0.0, xy, invx).xyz*0.5;
rgb += fetch(0.0, xy + dx, invx).xyz*0.3;
rgb += fetch(0.0, xy - dx, invx).xyz*0.2;
vec3 yuv = RGB_to_YUV * rgb;
return clamp(yuv.r + yuv.g*sinwt + yuv.b*coswt, 0.0, 1.0);
}
vec2 modem_UV(vec2 pos, float ofs) {
float t = (pos.x + ofs*invx) * OutputSize.x*SourceSize.x/InputSize.x;
float wt = t * 2.0 * PI/2.0 ;
float phase = wt + altv;
float sinwt = sin(phase);
float coswt = cos(phase);
vec3 rgb = fetch(ofs, pos, invx).xyz*0.5;
rgb += fetch(0.0, pos + dx, invx).xyz*0.3;
rgb += fetch(0.0, pos - dx, invx).xyz*0.2;
vec3 yuv = RGB_to_YUV * rgb;
float signal = clamp(yuv.x + yuv.y*sinwt + yuv.z*coswt, 0.0, 1.0);
return vec2(signal * sinwt, signal * coswt);
}
void main() {
mat3 mix_mat = mat3(
1.0, 0.0, 0.0,
ihue, sat, 0.0,
qhue, 0.0, sat
);
// Quilez
vec2 pos = vTexCoord * TextureSize;
vec2 i = floor(pos) + 0.50;
vec2 f = pos - i;
pos = (i + 4.0*f*f*f)*SourceSize.zw;
pos.x = mix( pos.x , vTexCoord.x, 0.5);
///
dx = vec2(SourceSize.z*blur,0.0);
crawler = crawl == 1.0? 2.0*mod(time,30.0): 0.0;
altv = pos.y*SourceSize.y*PI/2.0 + crawler;
invx = InputSize.x > 300.0? BLUR*2.0/OutputSize.x : BLUR/OutputSize.x; // equals 5 samples per Fsc period
// lowpass U/V at baseband
vec2 UV = vec2(0.0);
for (int i = 0; i < FIRTAPS; i++) {
vec2 uv = modem_UV(pos, 2.0*float(i) - float(FIRTAPS)); // floats for GLES, or else, bang!
UV += FIR_GAIN* uv * FIR[i];
}
float wt = (pos.x ) * SourceSize.x*2.0*PI/2.0;
float sinwt = sin(wt + altv);
float coswt = cos(wt + altv);
float luma = mod_luma(pos, sinwt, coswt) - FIR_INVGAIN*(UV.x*sinwt + UV.y*coswt);
vec3 yuv_result = vec3(luma, UV.x, UV.y);
yuv_result *= mix_mat;
float scan = SCAN*sin(vTexCoord.y*SourceSize.y*2.0*PI) + 1.0-SCAN;
vec3 RGB = 1.05*YUV_to_RGB * yuv_result;
RGB *= RGB;
RGB *= mix(scan,1.0, dot(RGB,vec3(0.25)));
RGB = sqrt(RGB);
FragColor = vec4(RGB, 1.0);
}
#endif

View File

@ -1,4 +1,4 @@
shaders = "3"
shaders = "4"
feedback_pass = "0"
shader0 = "../interpolation/shaders/wide_pixels_AA.glsl"
filter_linear0 = "false"
@ -12,6 +12,12 @@ scale_type_x1 = "source"
scale_x1 = "1.000000"
scale_type_y1 = "source"
scale_y1 = "1.000000"
shader2 = "../crt/shaders/crt-sines.glsl"
filter_linear2 = "true"
shader2 = "../dithering/shaders/simple_dither.glsl"
filter_linear2 = "false""
scale_type_x2 = "source"
scale_x2 = "1.000000"
scale_type_y2 = "source"
scale_y2 = "1.000000"
shader3 = "../crt/shaders/crt-sines.glsl"
filter_linear3 = "true"

22
presets/hatari.glslp Normal file
View File

@ -0,0 +1,22 @@
shaders = "6"
feedback_pass = "0"
shader0 = "../misc/shaders/chromaticity.glsl"
filter_linear0 = "false"
shader1 = "../interpolation/shaders/pixel_art_AA.glsl"
filter_linear1 = "false"
scale_type_x1 = "source"
scale_x1 = "1.000000"
scale_type_y1 = "source"
scale_y1 = "1.000000"
shader2 = "../crt/shaders/crt-consumer/linearize.glsl"
filter_linear2 = "false"
shader3 = "../crt/shaders/crt-consumer/glow_x.glsl"
filter_linear3 = "false"
shader4 = "../crt/shaders/crt-consumer/glow_y.glsl"
filter_linear4 = "false"
shader5 = "../crt/shaders/crt-consumer/crt-consumer.glsl"
filter_linear5 = "true"
COLOR_MODE = "6.000000"
glow = "0.100000"
inter = "0.000000"
sat = "1.000000"