Fix up NTSC shaders, nw

This commit is contained in:
therealmogminer@gmail.com 2016-03-12 03:17:41 +01:00
parent cd8f796df6
commit 9c33c40b82
32 changed files with 60 additions and 45 deletions

View File

@ -40,6 +40,12 @@
"prescale": 1,
"doublebuffer": true
},
{
"name": "deadend",
"mode": "guest",
"prescale": 1,
"doublebuffer": true
},
{ "name": "native",
"mode": "native",
"prescale": 1,
@ -53,7 +59,7 @@
],
"passes": [
{ "effect": "ntsc_encode",
"name": "NTSC Decode",
"name": "NTSC Encode",
"disablewhen": [
{ "type": "slider", "condition": "equal", "combine": "or", "name": "adjustments", "value": 0 },
{ "type": "slider", "condition": "equal", "combine": "or", "name": "ntsc", "value": 0 }
@ -108,7 +114,25 @@
],
"output": "guest"
},
{ "effect": "blit",
{ "effect": "color",
"name": "Color Convolution",
"disablewhen": [
{ "type": "slider", "condition": "equal", "name": "adjustments", "value": 0 }
],
"uniforms": [
{ "uniform": "u_red_ratios", "slider": "red_ratios" },
{ "uniform": "u_grn_ratios", "slider": "grn_ratios" },
{ "uniform": "u_blu_ratios", "slider": "blu_ratios" },
{ "uniform": "u_offset", "slider": "offset" },
{ "uniform": "u_scale", "slider": "scale" },
{ "uniform": "u_saturation", "slider": "saturation" }
],
"input": [
{ "sampler": "DiffuseSampler", "texture": "guest" }
],
"output": "guest"
},
{ "effect": "blit",
"name": "Prescale",
"input": [
{ "sampler": "s_tex", "texture": "guest" }

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -22,6 +22,7 @@ bgfx_entry_uniform* entry_uniform_reader::read_from_value(const Value& value, bg
std::string name = value["uniform"].GetString();
bgfx_uniform* uniform = effect->uniform(name);
assert(uniform != nullptr);
if (value.HasMember("slider"))

View File

@ -31,20 +31,6 @@ SAMPLER2D(DiffuseSampler, 0);
// Constants
//-----------------------------------------------------------------------------
const vec4 PI = vec4(3.1415927, 3.1415927, 3.1415927, 3.1415927);
const vec4 PI2 = vec4(6.2831854, 6.2831854, 6.2831854, 6.2831854);
const vec4 YDot = vec4(0.299, 0.587, 0.114, 0.0);
const vec4 IDot = vec4(0.595716, -0.274453, -0.321263, 0.0);
const vec4 QDot = vec4(0.211456, -0.522591, 0.311135, 0.0);
const vec3 RDot = vec3(1.0, 0.956, 0.621);
const vec3 GDot = vec3(1.0, -0.272, -0.647);
const vec3 BDot = vec3(1.0, -1.106, 1.703);
const vec4 OffsetX = vec4(0.0, 0.25, 0., 0.75);
const vec4 NotchOffset = vec4(0.0, 1.0, 2.0, 3.0);
void main()
{
vec4 BaseTexel = texture2D(DiffuseSampler, v_texcoord0.xy);
@ -68,6 +54,9 @@ void main()
vec4 Fc_i_2 = Fc_i * two;
vec4 Fc_q_2 = Fc_q * two;
const vec4 PI = vec4(3.1415927, 3.1415927, 3.1415927, 3.1415927);
const vec4 PI2 = vec4(6.2831854, 6.2831854, 6.2831854, 6.2831854);
vec4 W = PI2 * u_cc_value.xxxx * u_scan_time.xxxx;
vec4 WoPI = W / PI;
@ -81,16 +70,15 @@ void main()
vec4 Cy = v_texcoord0.yyyy;
vec4 VPosition = vec4(Cy / u_screenrect.y);
vec4 i = zero;
/* for (int i = 0; i < 64; i = i + 4) */
/* { &*/
// float n = i - 32.0;
// vec4 n4 = vec4(n, n, n, n) + NotchOffset;
vec4 n4 = i + NotchOffset;
for (int index = 0; index < 64; index = index + 4)
{
float n = float(index);
vec4 n4 = vec4(n, n, n, n) + vec4(0.0, 1.0, 2.0, 3.0);
vec4 Cx = v_texcoord0.xxxx + SourceTexelDims.xxxx * (n4 * quarter);
vec4 HPosition = Cx / u_screenrect.xxxx;
// theory: What if we put white in the input of the NTSC decode shader?
vec4 C = texture2D(DiffuseSampler, vec2(Cx.x, Cy.x));
vec4 T = HPosition + HOffset + VPosition * VScale;
@ -104,13 +92,20 @@ void main()
vec4 SincIIn = Fc_i * PI2 * n4;
vec4 SincQIn = Fc_q * PI2 * n4;
SincYIn1 = SincYIn1 == zero ? one : SincYIn1;
SincYIn2 = SincYIn2 == zero ? one : SincYIn2;
SincYIn3 = SincYIn3 == zero ? one : SincYIn3;
SincIIn = SincIIn == zero ? one : SincIIn;
SincQIn = SincQIn == zero ? one : SincQIn;
vec4 SincY1 = SincYIn1 != zero ? sin(SincYIn1) / SincYIn1 : one;
vec4 SincY2 = SincYIn2 != zero ? sin(SincYIn2) / SincYIn2 : one;
vec4 SincY3 = SincYIn3 != zero ? sin(SincYIn3) / SincYIn3 : one;
vec4 IdealY = (Fc_y1 * two * SincY1 - Fc_y2 * two * SincY2) + Fc_y3 * two * SincY3;
vec4 IdealI = Fc_i_2 * (SincIIn != zero ? sin(SincIIn) / SincIIn : one);
vec4 IdealQ = Fc_q_2 * (SincQIn != zero ? sin(SincIIn) / SincIIn : one);
vec4 IdealQ = Fc_q_2 * (SincQIn != zero ? sin(SincQIn) / SincQIn : one);
vec4 FilterY = SincKernel * IdealY;
vec4 FilterI = SincKernel * IdealI;
@ -119,17 +114,18 @@ void main()
YAccum = YAccum + C * FilterY;
IAccum = IAccum + C * cos(WT) * FilterI;
QAccum = QAccum + C * sin(WT) * FilterQ;
/* } */
}
vec3 YIQ = vec3(
(YAccum.r + YAccum.g + YAccum.b + YAccum.a),
(IAccum.r + IAccum.g + IAccum.b + IAccum.a) * 2.0,
(QAccum.r + QAccum.g + QAccum.b + QAccum.a) * 2.0);
vec3 RGB = vec3(
dot(YIQ, RDot),
dot(YIQ, GDot),
dot(YIQ, BDot));
dot(YIQ, vec3(1.0, 0.956, 0.621)),
dot(YIQ, vec3(1.0, -0.272, -0.647)),
dot(YIQ, vec3(1.0, -1.106, 1.703)));
// RGB obviously contains a NaN somewhere along the line! Returns black if vec4 etc. are included, white if just vec4(1.0)
gl_FragColor = vec4(RGB, BaseTexel.a) * v_color0;
}

View File

@ -27,27 +27,16 @@ SAMPLER2D(DiffuseSampler, 0);
// Constants
//-----------------------------------------------------------------------------
const vec4 PI = vec4(3.1415927, 3.1415927, 3.1415927, 3.1415927);
const vec4 PI2 = vec4(6.2831854, 6.2831854, 6.2831854, 6.2831854);
const vec4 YDot = vec4(0.299, 0.587, 0.114, 0.0);
const vec4 IDot = vec4(0.595716, -0.274453, -0.321263, 0.0);
const vec4 QDot = vec4(0.211456, -0.522591, 0.311135, 0.0);
const vec4 OffsetX = vec4(0.0, 0.25, 0., 0.75);
const vec4 NotchOffset = vec4(0.0, 1.0, 2.0, 3.0);
void main()
{
vec2 SourceTexelDims = u_texsize.xy;
vec2 SourceRes = (1.0 / u_texsize.xy) * u_screenrect.xy;
vec2 PValueSourceTexel = vec2(u_p_value.x, 0.0) * u_texsize.xy;
vec2 C0 = v_texcoord0 + PValueSourceTexel * vec2(OffsetX.x, 0.0);
vec2 C1 = v_texcoord0 + PValueSourceTexel * vec2(OffsetX.y, 0.0);
vec2 C2 = v_texcoord0 + PValueSourceTexel * vec2(OffsetX.z, 0.0);
vec2 C3 = v_texcoord0 + PValueSourceTexel * vec2(OffsetX.w, 0.0);
vec2 C0 = v_texcoord0 + PValueSourceTexel * vec2(0.0, 0.0);
vec2 C1 = v_texcoord0 + PValueSourceTexel * vec2(0.25, 0.0);
vec2 C2 = v_texcoord0 + PValueSourceTexel * vec2(0.5, 0.0);
vec2 C3 = v_texcoord0 + PValueSourceTexel * vec2(0.75, 0.0);
vec4 Cx = vec4(C0.x, C1.x, C2.x, C3.x);
vec4 Cy = vec4(C0.y, C1.y, C2.y, C3.y);
vec4 Texel0 = texture2D(DiffuseSampler, C0);
@ -55,13 +44,18 @@ void main()
vec4 Texel2 = texture2D(DiffuseSampler, C2);
vec4 Texel3 = texture2D(DiffuseSampler, C3);
vec4 HPosition = Cx / u_screenrect.x;
vec4 VPosition = Cy / u_screenrect.y;
vec4 HPosition = Cx / u_screenrect.xxxx;
vec4 VPosition = Cy / u_screenrect.yyyy;
const vec4 YDot = vec4(0.299, 0.587, 0.114, 0.0);
const vec4 IDot = vec4(0.595716, -0.274453, -0.321263, 0.0);
const vec4 QDot = vec4(0.211456, -0.522591, 0.311135, 0.0);
vec4 Y = vec4(dot(Texel0, YDot), dot(Texel1, YDot), dot(Texel2, YDot), dot(Texel3, YDot));
vec4 I = vec4(dot(Texel0, IDot), dot(Texel1, IDot), dot(Texel2, IDot), dot(Texel3, IDot));
vec4 Q = vec4(dot(Texel0, QDot), dot(Texel1, QDot), dot(Texel2, QDot), dot(Texel3, QDot));
const vec4 PI = vec4(3.1415927, 3.1415927, 3.1415927, 3.1415927);
const vec4 PI2 = vec4(6.2831854, 6.2831854, 6.2831854, 6.2831854);
vec4 W = PI2 * u_cc_value.xxxx * u_scan_time.xxxx;
vec4 WoPI = W / PI;