(gtu-famicom) Style nits, changed div by 2 with mul by 0.5

This commit is contained in:
Arzed Five 2016-12-07 01:12:14 +00:00
parent 9ee5eb1eb4
commit 5fdb0ee25d
6 changed files with 251 additions and 230 deletions

View file

@ -19,7 +19,8 @@ layout(std140, set = 0, binding = 0) uniform UBO
#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) {
bool InColorp (int p, int color)
{
return ((color + p) % 12 < 6);
}
@ -31,18 +32,26 @@ float NTSCsignal(int emphasis, int level, int color, int p)
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;
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;
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;
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);

View file

@ -56,7 +56,7 @@ void main()
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;
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;

View file

@ -42,10 +42,12 @@ float rand2(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);
}
float rand(vec2 co){
float rand(vec2 co)
{
return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
}
@ -83,5 +85,6 @@ void main()
signal += (rand(vec2(pos.x * pos.y, params.FrameCount)) - 0.50001) * params.noiseStrength;
signal += 0.5;
}
FragColor = vec4(signal);
}

View file

@ -30,11 +30,13 @@ layout(std140, set = 0, binding = 0) uniform UBO
#define pi 3.14159265358
float d(float x, float b){
float d(float x, float b)
{
return (pi*b*min(abs(x)+0.5,1.0/b));
}
float e(float x, float b){
float e(float x, float b)
{
return (pi*b*min(max(abs(x)-0.5,-1.0/b),1.0/b));
}
@ -46,8 +48,10 @@ 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;
}
@ -71,8 +75,9 @@ void main()
float i;
// for (i=-range;i<range+2.0;i++){
for (i=1.0-range;i<range+1.0;i++){
X = (offset-(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));

View file

@ -56,6 +56,7 @@ float normalGaussIntegral(float x)
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);
}
@ -65,10 +66,11 @@ vec3 scanlines( float x , vec3 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);
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;
}
@ -82,6 +84,7 @@ void main()
gl_Position = global.MVP * Position;
if (params.cropOverscan_y > 0.0)
gl_Position.y /= (224.0 / 240.0);
vTexCoord = TexCoord;
}
@ -102,14 +105,15 @@ void main()
// for (i=-range;i<range+2.0;i++){
if (params.noScanlines > 0.0)
for (i=1.0-range;i<range+1.0;i++)
for (i = 1.0-range; i < range + 1.0; ++i)
tempColor += VAL(i);
else
for (i=1.0-range;i<range+1.0;i++)
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);
}