mirror of
https://github.com/italicsjenga/slang-shaders.git
synced 2024-11-23 00:01:31 +11:00
(gtu-famicom) Style nits, changed div by 2 with mul by 0.5
This commit is contained in:
parent
9ee5eb1eb4
commit
5fdb0ee25d
|
@ -2,52 +2,61 @@
|
|||
|
||||
layout(std140, set = 0, binding = 0) uniform UBO
|
||||
{
|
||||
mat4 MVP;
|
||||
vec4 OutputSize;
|
||||
vec4 OriginalSize;
|
||||
vec4 SourceSize;
|
||||
uint FrameCount;
|
||||
mat4 MVP;
|
||||
vec4 OutputSize;
|
||||
vec4 OriginalSize;
|
||||
vec4 SourceSize;
|
||||
uint FrameCount;
|
||||
} global;
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
// GTU-famicom version 0.50
|
||||
// Author: aliaspider - aliaspider@gmail.com
|
||||
// License: GPLv3
|
||||
// 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);
|
||||
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 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 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;
|
||||
}
|
||||
|
||||
|
||||
float signal = InColorp(p, color) ? high : low;
|
||||
signal = (signal - black) / (white - black);
|
||||
|
||||
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;
|
||||
return signal;
|
||||
}
|
||||
|
||||
#pragma stage vertex
|
||||
|
@ -58,10 +67,10 @@ 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;
|
||||
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
|
||||
|
@ -72,12 +81,12 @@ layout(set = 0, binding = 2) uniform sampler2D Source;
|
|||
|
||||
void main()
|
||||
{
|
||||
vec4 c=texture(Source, vTexCoord.xy);
|
||||
vec4 c = texture(Source, vTexCoord.xy);
|
||||
|
||||
int color = TO_INT4(c.x);
|
||||
int level = TO_INT2(c.y);
|
||||
int emphasis = TO_INT3(c.z);
|
||||
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);
|
||||
}
|
||||
float signal = NTSCsignal(emphasis, level, color, int(colorPhase + 0.5));
|
||||
FragColor = vec4(signal);
|
||||
}
|
||||
|
|
|
@ -2,17 +2,17 @@
|
|||
|
||||
layout(std140, set = 0, binding = 0) uniform UBO
|
||||
{
|
||||
mat4 MVP;
|
||||
vec4 OutputSize;
|
||||
vec4 OriginalSize;
|
||||
vec4 SourceSize;
|
||||
uint FrameCount;
|
||||
mat4 MVP;
|
||||
vec4 OutputSize;
|
||||
vec4 OriginalSize;
|
||||
vec4 SourceSize;
|
||||
uint FrameCount;
|
||||
} global;
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
// GTU-famicom version 0.50
|
||||
// Author: aliaspider - aliaspider@gmail.com
|
||||
// License: GPLv3
|
||||
// GTU-famicom version 0.50
|
||||
// Author: aliaspider - aliaspider@gmail.com
|
||||
// License: GPLv3
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
#define GET_LEVEL(X) ((X)*(255.0f / (128.0f*(1.962f-.518f)))-(.518f / (1.962f-.518f)))
|
||||
|
@ -25,10 +25,10 @@ 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;
|
||||
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
|
||||
|
@ -40,11 +40,11 @@ layout(set = 0, binding = 3) uniform sampler2D nestable;
|
|||
|
||||
void main()
|
||||
{
|
||||
vec4 c = texture(Source, vTexCoord.xy);
|
||||
|
||||
vec2 pixmapCoord;
|
||||
pixmapCoord.x = c.x * (15.0 / (16.0 * 4.0)) + c.y * (3.0 / 4.0) +(0.5 / (16.0 * 4.0));
|
||||
pixmapCoord.y = 1.0 - (floor(mod(colorPhase + 0.5, 12.0)) / (12.0 * 8.0) + c.z * (7.0 / 8.0) + (0.5 / (12.0 * 8.0)));
|
||||
vec4 c = texture(Source, vTexCoord.xy);
|
||||
|
||||
FragColor = vec4(GET_LEVEL(texture(nestable, pixmapCoord.xy).r));//vec4(signal);
|
||||
}
|
||||
vec2 pixmapCoord;
|
||||
pixmapCoord.x = c.x * (15.0 / (16.0 * 4.0)) + c.y * (3.0 / 4.0) +(0.5 / (16.0 * 4.0));
|
||||
pixmapCoord.y = 1.0 - (floor(mod(colorPhase + 0.5, 12.0)) / (12.0 * 8.0) + c.z * (7.0 / 8.0) + (0.5 / (12.0 * 8.0)));
|
||||
|
||||
FragColor = vec4(GET_LEVEL(texture(nestable, pixmapCoord.xy).r));//vec4(signal);
|
||||
}
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
layout(push_constant) uniform Push
|
||||
{
|
||||
vec4 SourceSize;
|
||||
vec4 OriginalSize;
|
||||
vec4 OutputSize;
|
||||
uint FrameCount;
|
||||
float combFilter;
|
||||
float phaseOffset;
|
||||
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
|
||||
|
@ -15,16 +15,16 @@ layout(push_constant) uniform Push
|
|||
|
||||
layout(std140, set = 0, binding = 0) uniform UBO
|
||||
{
|
||||
mat4 MVP;
|
||||
mat4 MVP;
|
||||
} global;
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
// GTU version 0.50
|
||||
// Author: aliaspider - aliaspider@gmail.com
|
||||
// License: GPLv3
|
||||
// GTU version 0.50
|
||||
// Author: aliaspider - aliaspider@gmail.com
|
||||
// License: GPLv3
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
#define pi 3.14159265358
|
||||
#define pi 3.14159265358
|
||||
|
||||
#pragma stage vertex
|
||||
layout(location = 0) in vec4 Position;
|
||||
|
@ -34,10 +34,10 @@ layout(location = 1) out float colorPhase;
|
|||
|
||||
void main()
|
||||
{
|
||||
gl_Position = global.MVP * Position;
|
||||
vTexCoord = TexCoord;
|
||||
vec2 pos = (vTexCoord.xy * params.OutputSize.xy * params.SourceSize.xy * params.SourceSize.zw) - 0.5;
|
||||
colorPhase = 8.0 + pos.x + pos.y * 4.0 + params.FrameCount * 4.0 + 4.0 + params.phaseOffset * 12.0;
|
||||
gl_Position = global.MVP * Position;
|
||||
vTexCoord = TexCoord;
|
||||
vec2 pos = (vTexCoord.xy * params.OutputSize.xy * params.SourceSize.xy * params.SourceSize.zw) - 0.5;
|
||||
colorPhase = 8.0 + pos.x + pos.y * 4.0 + params.FrameCount * 4.0 + 4.0 + params.phaseOffset * 12.0;
|
||||
}
|
||||
|
||||
#pragma stage fragment
|
||||
|
@ -49,25 +49,25 @@ 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(6.0 * (params.OutputSize.x * params.SourceSize.x * params.SourceSize.z), 0.0)).r;
|
||||
signal = (current + prev6) / 2.0;
|
||||
float chromaSignal = current - signal;
|
||||
I = chromaSignal * cos (colorPhase * (2.0 * pi / 12.0)) * 2.0;
|
||||
Q = chromaSignal * sin (colorPhase * (2.0 * pi / 12.0)) * 2.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
signal = current;
|
||||
I = signal * cos (colorPhase * (2.0 * pi / 12.0))*2.0;
|
||||
Q = signal * sin (colorPhase * (2.0 * pi / 12.0))*2.0;
|
||||
}
|
||||
|
||||
FragColor = vec4(signal, I, Q, 1.0);
|
||||
float current = texture(Source,vTexCoord.xy).r;
|
||||
|
||||
float signal, I, Q;
|
||||
|
||||
if (params.combFilter > 0.0)
|
||||
{
|
||||
float prev6 = texture(Source, vTexCoord.xy - vec2(6.0 * (params.OutputSize.x * params.SourceSize.x * params.SourceSize.z), 0.0)).r;
|
||||
signal = (current + prev6) * 0.5;
|
||||
float chromaSignal = current - signal;
|
||||
I = chromaSignal * cos (colorPhase * (2.0 * pi / 12.0)) * 2.0;
|
||||
Q = chromaSignal * sin (colorPhase * (2.0 * pi / 12.0)) * 2.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
signal = current;
|
||||
I = signal * cos (colorPhase * (2.0 * pi / 12.0))*2.0;
|
||||
Q = signal * sin (colorPhase * (2.0 * pi / 12.0))*2.0;
|
||||
}
|
||||
|
||||
FragColor = vec4(signal, I, Q, 1.0);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
layout(push_constant) uniform Push
|
||||
{
|
||||
vec4 OutputSize;
|
||||
vec4 OriginalSize;
|
||||
vec4 SourceSize;
|
||||
float signalResolution;
|
||||
float addNoise;
|
||||
float noiseStrength;
|
||||
uint FrameCount;
|
||||
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
|
||||
|
@ -23,12 +23,12 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
} global;
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
// GTU-famicom version 0.50
|
||||
// Author: aliaspider - aliaspider@gmail.com
|
||||
// License: GPLv3
|
||||
// GTU-famicom version 0.50
|
||||
// Author: aliaspider - aliaspider@gmail.com
|
||||
// License: GPLv3
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
#define pi 3.14159265358
|
||||
#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))
|
||||
|
@ -40,13 +40,15 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
float rand2(vec2 co)
|
||||
{
|
||||
float c = 43758.5453;
|
||||
float dt= dot(co.xy ,vec2(12.9898,78.233));
|
||||
float sn= mod(dt,3.14);
|
||||
float dt = dot(co.xy, vec2(12.9898, 78.233));
|
||||
float sn = mod(dt, 3.14);
|
||||
|
||||
return fract(sin(sn) * c);
|
||||
}
|
||||
|
||||
float rand(vec2 co){
|
||||
return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
|
||||
float rand(vec2 co)
|
||||
{
|
||||
return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
|
||||
}
|
||||
|
||||
#pragma stage vertex
|
||||
|
@ -56,8 +58,8 @@ layout(location = 0) out vec2 vTexCoord;
|
|||
|
||||
void main()
|
||||
{
|
||||
gl_Position = global.MVP * Position;
|
||||
vTexCoord = TexCoord;
|
||||
gl_Position = global.MVP * Position;
|
||||
vTexCoord = TexCoord;
|
||||
}
|
||||
|
||||
#pragma stage fragment
|
||||
|
@ -67,21 +69,22 @@ 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);
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
|
||||
layout(push_constant) uniform Push
|
||||
{
|
||||
vec4 SourceSize;
|
||||
vec4 OriginalSize;
|
||||
vec4 OutputSize;
|
||||
uint FrameCount;
|
||||
float cropOverscan_x;
|
||||
float signalResolutionY;
|
||||
float signalResolutionI;
|
||||
float signalResolutionQ;
|
||||
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
|
||||
|
@ -19,23 +19,25 @@ layout(push_constant) uniform Push
|
|||
|
||||
layout(std140, set = 0, binding = 0) uniform UBO
|
||||
{
|
||||
mat4 MVP;
|
||||
mat4 MVP;
|
||||
} global;
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
// GTU-famicom version 0.50
|
||||
// Author: aliaspider - aliaspider@gmail.com
|
||||
// License: GPLv3
|
||||
// GTU-famicom version 0.50
|
||||
// Author: aliaspider - aliaspider@gmail.com
|
||||
// License: GPLv3
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
#define pi 3.14159265358
|
||||
#define pi 3.14159265358
|
||||
|
||||
float d(float x, float b){
|
||||
return (pi*b*min(abs(x)+0.5,1.0/b));
|
||||
float d(float x, float b)
|
||||
{
|
||||
return (pi*b*min(abs(x)+0.5,1.0/b));
|
||||
}
|
||||
|
||||
float e(float x, float b){
|
||||
return (pi*b*min(max(abs(x)-0.5,-1.0/b),1.0/b));
|
||||
float e(float x, float b)
|
||||
{
|
||||
return (pi*b*min(max(abs(x)-0.5,-1.0/b),1.0/b));
|
||||
}
|
||||
|
||||
#pragma stage vertex
|
||||
|
@ -45,10 +47,12 @@ 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;
|
||||
gl_Position = global.MVP * Position;
|
||||
|
||||
if (params.cropOverscan_x > 0.0)
|
||||
gl_Position.x /= (240.0 / 256.0);
|
||||
|
||||
vTexCoord = TexCoord;
|
||||
}
|
||||
|
||||
#pragma stage fragment
|
||||
|
@ -58,31 +62,32 @@ layout(set = 0, binding = 2) uniform sampler2D Source;
|
|||
|
||||
void main()
|
||||
{
|
||||
float offset = fract((vTexCoord.x * params.SourceSize.x) - 0.5);
|
||||
vec3 YIQ = vec3(0.0);
|
||||
vec3 RGB = vec3(0.0);
|
||||
float X;
|
||||
vec3 c;
|
||||
float Y = params.signalResolutionY * params.SourceSize.z;
|
||||
float I = params.signalResolutionI * params.SourceSize.z;
|
||||
float Q = params.signalResolutionQ * params.SourceSize.z;
|
||||
|
||||
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++){
|
||||
X = (offset-(i));
|
||||
c = texture(Source, vec2(vTexCoord.x - X * params.SourceSize.z, vTexCoord.y)).rgb;
|
||||
c.x *= ((d(X,Y) + sin(d(X,Y)) - e(X,Y) - sin(e(X,Y))) / (2.0 * pi));
|
||||
c.y *= ((d(X,I) + sin(d(X,I)) - e(X,I) - sin(e(X,I))) / (2.0 * pi));
|
||||
c.z *= ((d(X,Q) + sin(d(X,Q)) - e(X,Q) - sin(e(X,Q))) / (2.0 * pi));
|
||||
YIQ+=c;
|
||||
}
|
||||
float offset = fract((vTexCoord.x * params.SourceSize.x) - 0.5);
|
||||
vec3 YIQ = vec3(0.0);
|
||||
vec3 RGB = vec3(0.0);
|
||||
float X;
|
||||
vec3 c;
|
||||
float Y = params.signalResolutionY * params.SourceSize.z;
|
||||
float I = params.signalResolutionI * params.SourceSize.z;
|
||||
float Q = params.signalResolutionQ * params.SourceSize.z;
|
||||
|
||||
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++)
|
||||
{
|
||||
X = offset - i;
|
||||
c = texture(Source, vec2(vTexCoord.x - X * params.SourceSize.z, vTexCoord.y)).rgb;
|
||||
c.x *= ((d(X, Y) + sin(d(X, Y)) - e(X, Y) - sin(e(X, Y))) / (2.0 * pi));
|
||||
c.y *= ((d(X, I) + sin(d(X, I)) - e(X, I) - sin(e(X, I))) / (2.0 * pi));
|
||||
c.z *= ((d(X, Q) + sin(d(X, Q)) - e(X, Q) - sin(e(X, Q))) / (2.0 * pi));
|
||||
YIQ += c;
|
||||
}
|
||||
|
||||
RGB.r = YIQ.r + 0.956 * YIQ.g + 0.621 * YIQ.b;
|
||||
RGB.g = YIQ.r - 0.272 * YIQ.g - 0.647 * YIQ.b;
|
||||
RGB.b = YIQ.r - 1.106 * YIQ.g + 1.703 * YIQ.b;
|
||||
RGB.r = YIQ.r + 0.956 * YIQ.g + 0.621 * YIQ.b;
|
||||
RGB.g = YIQ.r - 0.272 * YIQ.g - 0.647 * YIQ.b;
|
||||
RGB.b = YIQ.r - 1.106 * YIQ.g + 1.703 * YIQ.b;
|
||||
|
||||
FragColor = vec4(clamp(RGB, 0.0, 1.0), 1.0);
|
||||
}
|
||||
FragColor = vec4(clamp(RGB, 0.0, 1.0), 1.0);
|
||||
}
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
|
||||
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;
|
||||
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
|
||||
|
@ -23,18 +23,18 @@ layout(push_constant) uniform Push
|
|||
|
||||
layout(std140, set = 0, binding = 0) uniform UBO
|
||||
{
|
||||
mat4 MVP;
|
||||
mat4 MVP;
|
||||
} global;
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
// GTU-famicom version 0.50
|
||||
// Author: aliaspider - aliaspider@gmail.com
|
||||
// License: GPLv3
|
||||
// GTU-famicom version 0.50
|
||||
// Author: aliaspider - aliaspider@gmail.com
|
||||
// License: GPLv3
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
//#include "config.h"
|
||||
|
||||
#define pi 3.14159265358
|
||||
#define pi 3.14159265358
|
||||
#define normalGauss(x) ((exp(-(x)*(x)*0.5))/sqrt(2.0*pi))
|
||||
|
||||
#define Y(j) (offset.y-(j))
|
||||
|
@ -51,25 +51,27 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
|
||||
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);
|
||||
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 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;
|
||||
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
|
||||
|
@ -79,37 +81,39 @@ 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;
|
||||
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) 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++){
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue