add nonfunctional dir, add gtu-famicom and super-xbr to it

This commit is contained in:
hunterk 2016-08-10 16:04:38 -05:00
parent d743b85124
commit 748440e43f
12 changed files with 475 additions and 4 deletions

View file

@ -0,0 +1,40 @@
shaders = 5
shader0 = shaders/gtu-famicom/DAC.slang
scale_type_x0 = source
scale_x0 = 8.0
scale_type_y0 = source
scale_y0 = 1.0
float_framebuffer0 = true
filter_linear0 = false
frame_count_mod0 = 2
shader1 = shaders/gtu-famicom/lowPass.slang
scale_type_1 = source
scale_1 = 1.0
float_framebuffer1 = true
filter_linear1 = false
frame_count_mod1 = 32
shader2 = shaders/gtu-famicom/combFilter.slang
scale_type_2 = source
scale_2 = 1.0
float_framebuffer2 = true
filter_linear2 = false
frame_count_mod2 = 2
shader3 = shaders/gtu-famicom/scaleX.slang
scale_type_x3 = viewport
scale_x3 = 1.0
scale_type_y3 = source
scale_y3 = 1.0
float_framebuffer3 = true
filter_linear3 = false
shader4 = shaders/gtu-famicom/scaleY.slang
scale_type_x4 = source
scale_x4 = 1.0
scale_type_y4 = viewport
scale_y4 = 1.0
float_framebuffer4 = true
filter_linear4 = false

View file

@ -0,0 +1,83 @@
#version 450
layout(std140, set = 0, binding = 0) uniform UBO
{
mat4 MVP;
vec4 OutputSize;
vec4 OriginalSize;
vec4 SourceSize;
uint FrameCount;
} global;
////////////////////////////////////////////////////////
// GTU-famicom version 0.50
// Author: aliaspider - aliaspider@gmail.com
// License: GPLv3
////////////////////////////////////////////////////////
#define TO_INT2(X) int(floor(((X) * 3.0) + 0.5))
#define TO_INT3(X) int(floor(((X) * 7.0) + 0.5))
#define TO_INT4(X) int(floor(((X) * 15.0) + 0.5))
bool InColorp (int p, int color) {
return ((color + p) % 12 < 6);
}
float NTSCsignal(int emphasis, int level, int color, int p)
{
float black=.518;
float white=1.962;
float attenuation=0.746;
const float levels[8] = float[] (0.350 , 0.518, 0.962, 1.550,
1.094f, 1.506, 1.962, 1.962);
if(color > 13) level = 1;
float low = levels[0 + level];
float high = levels[4 + level];
if(color == 0) low = high;
if(color > 12) high = low;
float signal = InColorp(p, color) ? high : low;
if( (bool(emphasis & 1) && InColorp(p, 0))
|| (bool(emphasis & 2) && InColorp(p, 4))
|| (bool(emphasis & 4) && InColorp(p, 8)) ) signal = signal * attenuation;
signal = (signal-black) / (white-black);
return signal;
}
#pragma stage vertex
layout(location = 0) in vec4 Position;
layout(location = 1) in vec2 TexCoord;
layout(location = 0) out vec2 vTexCoord;
layout(location = 1) out float colorPhase;
void main()
{
gl_Position = global.MVP * Position;
vTexCoord = TexCoord;
vec2 pos = (vTexCoord.xy*global.OutputSize.xy)-0.5;
colorPhase = 8.0001 + pos.x + pos.y * 4.0001 + global.FrameCount * 4.0001;
}
#pragma stage fragment
layout(location = 0) in vec2 vTexCoord;
layout(location = 1) in float colorPhase;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D Source;
void main()
{
vec4 c=texture(Source, vTexCoord.xy);
int color = TO_INT4(c.x);
int level = TO_INT2(c.y);
int emphasis = TO_INT3(c.z);
float signal = NTSCsignal(emphasis,level,color,int(colorPhase + 0.5));
FragColor = vec4(signal);
}

View file

@ -0,0 +1,73 @@
#version 450
layout(push_constant) uniform Push
{
vec4 SourceSize;
vec4 OriginalSize;
vec4 OutputSize;
uint FrameCount;
float combFilter;
float phaseOffset;
} params;
#pragma parameter combFilter "comb filter" 0.0 0.0 1.0 1.0
#pragma parameter phaseOffset "phase offset" 0.0 -0.5 0.5 0.01
layout(std140, set = 0, binding = 0) uniform UBO
{
mat4 MVP;
} global;
////////////////////////////////////////////////////////
// GTU version 0.50
// Author: aliaspider - aliaspider@gmail.com
// License: GPLv3
////////////////////////////////////////////////////////
//#include "config.h"
#define pi 3.14159265358
#pragma stage vertex
layout(location = 0) in vec4 Position;
layout(location = 1) in vec2 TexCoord;
layout(location = 0) out vec2 vTexCoord;
layout(location = 1) out float colorPhase;
void main()
{
gl_Position = global.MVP * Position;
vTexCoord = TexCoord;
vec2 pos = (vTexCoord.xy*params.OutputSize.xy)-0.5;
colorPhase = 8.0001 + pos.x + pos.y * 4.0001 + params.FrameCount * 4.0001 + 4.0001 + params.phaseOffset * 12.0001;
}
#pragma stage fragment
layout(location = 0) in vec2 vTexCoord;
layout(location = 1) in float colorPhase;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D Source;
void main()
{
float current = texture(Source,vTexCoord.xy).r;
float signal, I, Q;
if (params.combFilter > 0.0)
{
float prev6 = texture(Source, vTexCoord.xy - vec2(5.9999 * (params.OutputSize.z), 0.0)).r;
signal = (current + prev6) / 2.0001;
float chromaSignal = current - signal;
I = chromaSignal * cos (colorPhase * (2.0001 * pi / 12.0001))*2.0001;
Q = chromaSignal * sin (colorPhase * (2.0001 * pi / 12.0001))*2.0001;
}
else
{
signal = current;
I = signal * cos (colorPhase * (2.0001 * pi / 12.0001))*2.0001;
Q = signal * sin (colorPhase * (2.0001 * pi / 12.0001))*2.0001;
}
FragColor = vec4(signal, I, Q, 1.0);
}

View file

@ -0,0 +1,84 @@
#version 450
layout(push_constant) uniform Push
{
vec4 OutputSize;
vec4 OriginalSize;
vec4 SourceSize;
float signalResolution;
float addNoise;
float noiseStrength;
uint FrameCount;
} params;
#pragma parameter signalResolution "Signal Resolution" 700.0 20.0 2000.0 10.0
#pragma parameter addNoise "Add Noise" 0.0 0.0 1.0 1.0
#pragma parameter noiseStrength "Noise Strength" 0.0 0.0 1.0 0.05
//#include "config.h"
layout(std140, set = 0, binding = 0) uniform UBO
{
mat4 MVP;
} global;
////////////////////////////////////////////////////////
// GTU-famicom version 0.50
// Author: aliaspider - aliaspider@gmail.com
// License: GPLv3
////////////////////////////////////////////////////////
#define pi 3.14159265358
#define a(x) abs(x)
#define d(x,b) (pi*b*min(a(x)+0.5,1.0/b))
#define e(x,b) (pi*b*min(max(a(x)-0.5,-1.0/b),1.0/b))
#define STU(x,b) ((d(x,b)+sin(d(x,b))-e(x,b)-sin(e(x,b)))/(2.0*pi))
#define X(i) (offset-(i))
#define S(i) (texture(Source, vec2(vTexCoord.x - X(i)/params.SourceSize.x,vTexCoord.y)).x)
#define VAL(i) (S(i)*STU(X(i),(params.signalResolution * params.SourceSize.z)))
float rand(vec2 co)
{
float c = 43758.5453;
float dt= dot(co.xy ,vec2(12.9898,78.233));
float sn= mod(dt,3.14);
return fract(sin(sn) * c);
}
#pragma stage vertex
layout(location = 0) in vec4 Position;
layout(location = 1) in vec2 TexCoord;
layout(location = 0) out vec2 vTexCoord;
void main()
{
gl_Position = global.MVP * Position;
vTexCoord = TexCoord;
}
#pragma stage fragment
layout(location = 0) in vec2 vTexCoord;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D Source;
void main()
{
float offset = fract((vTexCoord.x * params.SourceSize.x) - 0.50001);
float signal = 0.0;
float range = ceil(0.50001 + params.SourceSize.x / params.signalResolution);
range = min(range, 255.0);
float i;
for (i = 1-range; i < 1+range; i++)
signal+=VAL(i);
if(params.addNoise > 0.0)
{
vec2 pos = (vTexCoord.xy * params.SourceSize.xy);
signal -= 0.5;
signal += (rand(vec2(pos.x * pos.y, params.FrameCount)) - 0.50001) * params.noiseStrength;
signal += 0.5;
}
FragColor = vec4(signal);
}

View file

@ -0,0 +1,78 @@
#version 450
layout(push_constant) uniform Push
{
vec4 SourceSize;
vec4 OriginalSize;
vec4 OutputSize;
uint FrameCount;
float cropOverscan_x;
float signalResolutionY;
float signalResolutionI;
float signalResolutionQ;
} params;
#pragma parameter cropOverscan_x "Crop Overscan X" 0.0 0.0 1.0 1.0
#pragma parameter signalResolutionY "Signal Res Y" 200.0 20.0 500.0 10.0
#pragma parameter signalResolutionI "Signal Res I" 125.0 20.0 350.0 10.0
#pragma parameter signalResolutionQ "Signal Res Q" 125.0 20.0 350.0 10.0
layout(std140, set = 0, binding = 0) uniform UBO
{
mat4 MVP;
} global;
////////////////////////////////////////////////////////
// GTU-famicom version 0.50
// Author: aliaspider - aliaspider@gmail.com
// License: GPLv3
////////////////////////////////////////////////////////
#define YIQ_to_RGB mat3x3( 1.0 , 1.0 , 1.0 , 0.9563 , -0.2721 , -1.1070 , 0.6210 , -0.6474 , 1.7046 )
#define pi 3.14159265358
#define a(x) abs(x)
#define d(x,b) (pi*b*min(a(x)+0.5,1.0/b))
#define e(x,b) (pi*b*min(max(a(x)-0.5,-1.0/b),1.0/b))
#define STU(x,b) ((d(x,b)+sin(d(x,b))-e(x,b)-sin(e(x,b)))/(2.0*pi))
//#define X(i) (offset-(i))
#define GETC (texture(Source, vec2(vTexCoord.x - X * params.SourceSize.z, vTexCoord.y)).rgb)
#define VAL vec3((c.x*STU(X,(params.signalResolutionY * params.SourceSize.z))),(c.y*STU(X,(params.signalResolutionI * params.SourceSize.z))),(c.z*STU(X,(params.signalResolutionQ * params.SourceSize.z))))
#define PROCESS(i) X=(offset-(i));c=GETC;tempColor+=VAL;
#pragma stage vertex
layout(location = 0) in vec4 Position;
layout(location = 1) in vec2 TexCoord;
layout(location = 0) out vec2 vTexCoord;
void main()
{
gl_Position = global.MVP * Position;
if (params.cropOverscan_x > 0.0)
gl_Position.x /= (240.0 / 256.0);
vTexCoord = TexCoord;
}
#pragma stage fragment
layout(location = 0) in vec2 vTexCoord;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D Source;
void main()
{
float offset = fract((vTexCoord.x * params.SourceSize.x) - 0.5);
vec3 tempColor = vec3(0.0);
float X;
vec3 c;
float range = ceil(0.5 + params.SourceSize.x / min(min(params.signalResolutionY, params.signalResolutionI), params.signalResolutionQ));
float i;
// for (i=-range;i<range+2.0;i++){
for (i=1.0-range;i<range+1.0;i++){
PROCESS(i)
}
tempColor=clamp(YIQ_to_RGB * tempColor,0.0,1.0);
FragColor = vec4(tempColor, 1.0);
}

View file

@ -0,0 +1,115 @@
#version 450
layout(push_constant) uniform Push
{
vec4 SourceSize;
vec4 OriginalSize;
vec4 OutputSize;
uint FrameCount;
float noScanlines;
float tvVerticalResolution;
float blackLevel;
float contrast;
float gamma;
float cropOverscan_y;
} params;
#pragma parameter noScanlines "No Scanlines" 0.0 0.0 1.0 1.0
#pragma parameter tvVerticalResolution "TV Vert. Res" 250.0 20.0 1000.0 10.0
#pragma parameter blackLevel "Black Level" 0.07 -0.30 0.30 0.01
#pragma parameter contrast "Contrast" 1.0 0.0 2.0 0.1
#pragma parameter gamma "Gamma" 1.0 0.5 1.5 0.01
#pragma parameter cropOverscan_y "Crop Overscan Y" 0.0 0.0 1.0 1.0
layout(std140, set = 0, binding = 0) uniform UBO
{
mat4 MVP;
} global;
////////////////////////////////////////////////////////
// GTU-famicom version 0.50
// Author: aliaspider - aliaspider@gmail.com
// License: GPLv3
////////////////////////////////////////////////////////
//#include "config.h"
#define pi 3.14159265358
#define normalGauss(x) ((exp(-(x)*(x)*0.5))/sqrt(2.0*pi))
#define Y(j) (offset.y-(j))
#define a(x) abs(x)
#define d(x,b) (pi*b*min(a(x)+0.5,1.0/b))
#define e(x,b) (pi*b*min(max(a(x)-0.5,-1.0/b),1.0/b))
#define STU(x,b) ((d(x,b)+sin(d(x,b))-e(x,b)-sin(e(x,b)))/(2.0*pi))
#define SOURCE(j) vec2(vTexCoord.x,vTexCoord.y - Y(j) * params.SourceSize.w)
#define C(j) (texture(Source, SOURCE(j)).xyz)
#define VAL(j) (C(j)*STU(Y(j),(params.tvVerticalResolution * params.SourceSize.w)))
#define VAL_scanlines(j) (scanlines(Y(j),C(j)))
float normalGaussIntegral(float x)
{
float a1 = 0.4361836;
float a2 = -0.1201676;
float a3 = 0.9372980;
float p = 0.3326700;
float t = 1.0 / (1.0 + p*abs(x));
return (0.5-normalGauss(x) * (t*(a1 + t*(a2 + a3*t))))*sign(x);
}
vec3 scanlines( float x , vec3 c){
float temp=sqrt(2*pi)*(params.tvVerticalResolution * params.SourceSize.w);
float rrr=0.5 * (params.SourceSize.y * params.OutputSize.w);
float x1=(x+rrr)*temp;
float x2=(x-rrr)*temp;
c.r=(c.r*(normalGaussIntegral(x1)-normalGaussIntegral(x2)));
c.g=(c.g*(normalGaussIntegral(x1)-normalGaussIntegral(x2)));
c.b=(c.b*(normalGaussIntegral(x1)-normalGaussIntegral(x2)));
c*=(params.OutputSize.y * params.SourceSize.w);
return c;
}
#pragma stage vertex
layout(location = 0) in vec4 Position;
layout(location = 1) in vec2 TexCoord;
layout(location = 0) out vec2 vTexCoord;
void main()
{
gl_Position = global.MVP * Position;
if (params.cropOverscan_y > 0.0)
gl_Position.y /= (224.0 / 240.0);
vTexCoord = TexCoord;
}
#pragma stage fragment
layout(location = 0) in vec2 vTexCoord;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D Source;
void main()
{
vec2 offset = fract((vTexCoord.xy * params.SourceSize.xy) - 0.5);
vec3 tempColor = vec3(0.0);
float range = ceil(0.5 + params.SourceSize.y / params.tvVerticalResolution);
range = min(range, 255.0);
float i;
// for (i=-range;i<range+2.0;i++){
if (params.noScanlines > 0.0)
for (i=1.0-range;i<range+1.0;i++)
tempColor+=VAL(i);
else
for (i=1.0-range;i<range+1.0;i++)
tempColor+=VAL_scanlines(i);
tempColor -= vec3(params.blackLevel);
tempColor *= (params.contrast / vec3(1.0 - params.blackLevel));
tempColor = pow(tempColor, vec3(params.gamma));
FragColor = vec4(tempColor, 1.0);
}

View file

@ -190,9 +190,7 @@ void main()
vec3 c4 = mat4x3(C+B, F+E, I+H, I5+H5) * w2; vec3 c4 = mat4x3(C+B, F+E, I+H, I5+H5) * w2;
/* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */ /* Smoothly blends the two strongest directions (one in diagonal and the other in vert/horiz direction). */
vec3 color = mix(mix(c1, c2, step(0.0, d_edge)), vec3 color = mix(mix(c1, c2, step(0.0, d_edge)), mix(c3, c4, step(0.0, hv_edge)), 1 - edge_strength);
mix(c3, c4, step(0.0, hv_edge)),
1 - edge_strength);
/* Anti-ringing code. */ /* Anti-ringing code. */
vec3 min_sample = min4( E, F, H, I ) + (1-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge)); vec3 min_sample = min4( E, F, H, I ) + (1-XBR_ANTI_RINGING)*mix((P2-H)*(F-P1), (P0-E)*(I-P3), step(0.0, d_edge));

View file

@ -64,7 +64,7 @@ layout(set = 0, binding = 3) uniform sampler2D Original;
#define weight1 (XBR_WEIGHT*1.75068/10.0) #define weight1 (XBR_WEIGHT*1.75068/10.0)
#define weight2 (XBR_WEIGHT*1.29633/10.0/2.0) #define weight2 (XBR_WEIGHT*1.29633/10.0/2.0)
vec3 Y = vec3(.2126, .7152, .0722); const vec3 Y = vec3(.2126, .7152, .0722);
float RGBtoYUV(vec3 color) float RGBtoYUV(vec3 color)
{ {