rendered paste bodyIndex: plugins/GSdx/GSDevice.cpp===================================================================--- plugins/GSdx/GSDevice.cpp (revision 1478)+++ plugins/GSdx/GSDevice.cpp (working copy)@@ -94,9 +94,10 @@ if(m_current) {- static int s_shader[3] = {0, 5, 6}; // FIXME+ static int s_shader[4] = {12, 0, 11, 0};+ static bool s_linear[4] = {false, false, false, false}; - StretchRect(m_current, m_backbuffer, GSVector4(r), s_shader[shader]);+ StretchRect(m_current, m_backbuffer, GSVector4(r), s_shader[shader], s_linear[shader]); } Flip();@@ -159,6 +160,7 @@ void GSDevice::StretchRect(GSTexture* st, GSTexture* dt, const GSVector4& dr, int shader, bool linear) { StretchRect(st, GSVector4(0, 0, 1, 1), dt, dr, shader, linear);+ //StretchRect(st, GSVector4(0.4f, 0.4f, .6f, .6f), dt, dr, shader, linear); } GSTexture* GSDevice::GetCurrent()Index: plugins/GSdx/GSDevice9.cpp===================================================================--- plugins/GSdx/GSDevice9.cpp (revision 1478)+++ plugins/GSdx/GSDevice9.cpp (working copy)@@ -632,6 +632,8 @@ // ps PSSetShader(ps, ps_cb, ps_cb_len);+ float texsize[4] = {st->GetWidth(), st->GetHeight(), 0, 0};+ m_dev->SetPixelShaderConstantF(100, texsize, 1); PSSetSamplerState(linear ? &m_convert.ln : &m_convert.pt); PSSetShaderResources(st, NULL); Index: plugins/GSdx/GSDevice9.h===================================================================--- plugins/GSdx/GSDevice9.h (revision 1478)+++ plugins/GSdx/GSDevice9.h (working copy)@@ -110,7 +110,7 @@ { CComPtr<IDirect3DVertexDeclaration9> il; CComPtr<IDirect3DVertexShader9> vs;- CComPtr<IDirect3DPixelShader9> ps[7];+ CComPtr<IDirect3DPixelShader9> ps[13]; Direct3DSamplerState9 ln; Direct3DSamplerState9 pt; Direct3DDepthStencilState9 dss;Index: plugins/GSdx/GSRenderer.cpp===================================================================--- plugins/GSdx/GSRenderer.cpp (revision 1478)+++ plugins/GSdx/GSRenderer.cpp (working copy)@@ -419,7 +419,7 @@ m_aspectratio = (m_aspectratio + 3 + step) % 3; return; case VK_F7:- m_shader = (m_shader + 3 + step) % 3;+ m_shader = (m_shader + step) % 4; return; case VK_F12: if(m_capture.IsCapturing()) m_capture.EndCapture();Index: plugins/GSdx/res/convert.fx===================================================================--- plugins/GSdx/res/convert.fx (revision 1478)+++ plugins/GSdx/res/convert.fx (working copy)@@ -1,3 +1,5 @@+float2 texsize : register(c100);+ #if SHADER_MODEL >= 0x400 struct VS_INPUT@@ -181,4 +183,376 @@ return ps_crt(t, (p.x + (p.y % 3)) % 3); } +// SaI apparently, I can't find a description of the algorithm so this is just copied from another shader+float4 ps_main7(float2 tc : TEXCOORD0) : COLOR+{+ const float4 texel = {.5/512, .5/448, 0, 0};++ float3 c11 = tex2D(Texture, tc);+ float3 c01 = tex2D(Texture, tc - texel.xz);+ float3 c21 = tex2D(Texture, tc + texel.xz);+ float3 c10 = tex2D(Texture, tc - texel.zy);+ float3 c12 = tex2D(Texture, tc + texel.zy);+ + float3 dt = float3(1.0, 1.0, 1.0);+ float k1 = dot(abs(c01 - c21), dt);+ float k2 = dot(abs(c10 - c12), dt);+ + return float4(saturate(k1 * (c10 + c12) + k2 * (c01 + c21) + 0.001 * c11) / (2.0 * (k1 + k2) + 0.001), 0);+}++float4 rgb2yuv(float4 rgb)+{+ float4 rgb2y = float4( 0.299f, 0.587f, 0.114f, 0.0f);+ float4 rgb2u = float4( 0.500f, 0.419f, -0.081f, 0.0f);+ float4 rgb2v = float4(-0.169f, -0.331f, 0.500f, 0.0f);++ float4 y = rgb2y * rgb;+ float4 u = rgb2u * rgb;+ float4 v = rgb2v * rgb;+ + return float4( y.r+y.g+y.b, u.r+u.g+u.b, v.r+v.g+v.b, rgb.a);+}++float4 ps_main8(float2 tc : TEXCOORD0) : COLOR+{+ const float2 TextureSize = float2(512., 448.);+ float2 TexelSize = 1/TextureSize;+ + //float4 thresholds = float4(0.3f,0.6f,0.6f,1.0f);+ float4 thresholds = float4(0.15f,0.2f,0.3f,1.0f);+ + float2 TA = tc * TextureSize;+ float2 TB = floor(TA);+ float2 TP = TA-TB;++ float2 TX = TB * TexelSize;++ float4 rgb0 = tex2D(Texture, TX + float2( 0, 0) );+ float4 rgb1 = tex2D(Texture, TX + float2(TexelSize.x, 0) );+ float4 rgb2 = tex2D(Texture, TX + float2( 0,TexelSize.y) );+ float4 rgb3 = tex2D(Texture, TX + float2(TexelSize.x,TexelSize.y) );++ float4 yuv0 = rgb2yuv( rgb0 );+ float4 yuv1 = rgb2yuv( rgb1 );+ float4 yuv2 = rgb2yuv( rgb2 );+ float4 yuv3 = rgb2yuv( rgb3 );+ + float4 t01 = clamp(ceil(abs(yuv0 - yuv1)-thresholds),0,1);+ float4 t02 = clamp(ceil(abs(yuv0 - yuv2)-thresholds),0,1);+ float4 t03 = clamp(ceil(abs(yuv0 - yuv3)-thresholds),0,1);+ float4 t12 = clamp(ceil(abs(yuv1 - yuv2)-thresholds),0,1);+ float4 t13 = clamp(ceil(abs(yuv1 - yuv3)-thresholds),0,1);+ float4 t23 = clamp(ceil(abs(yuv2 - yuv3)-thresholds),0,1);+ + float b01 = max(t01.r,max(t01.g,t01.b));+ float b02 = max(t02.r,max(t02.g,t02.b));+ float b03 = max(t03.r,max(t03.g,t03.b));+ float b12 = max(t12.r,max(t12.g,t12.b));+ float b13 = max(t13.r,max(t13.g,t13.b));+ float b23 = max(t23.r,max(t23.g,t23.b));+ + float4 ocolor = lerp(lerp(rgb0,rgb1,TP.x),lerp(rgb2,rgb3,TP.x),TP.y);++ if( (b01+b02+b12+b23) > 3) // SmartFlt Cases 11,12,13+ {+ if( b03 < 1)+ {+ if( (1-TP.x+TP.y) < 0.5 )+ ocolor = rgb1;+ else if( (1-TP.x+TP.y) > 1.5 )+ ocolor = rgb2;+ else+ ocolor = lerp( rgb0,rgb3, (TP.x+TP.y)/2);+ }+ else if( b12 < 1)+ {+ if( (TP.x+TP.y) < 0.5 )+ ocolor = rgb0;+ else if( (TP.x+TP.y) > 1.5 )+ ocolor = rgb3;+ else+ ocolor = lerp( rgb1,rgb2, (1-TP.x+TP.y)/2);+ }+ else if( TP.y < 0.5)+ {+ if( TP.x < 0.5)+ ocolor = rgb0;+ else+ ocolor = rgb1;+ }+ else+ {+ if( TP.x < 0.5)+ ocolor = rgb2;+ else+ ocolor = rgb3;+ }+ }+ else if( (b03+b13+b23) > 2 ) // SmartFlt Case 3+ {+ if( (TP.x + TP.y) > 1.5 )+ ocolor = rgb3;+ else+ ocolor = lerp(lerp(rgb0,rgb1,TP.x),lerp(rgb2,rgb0,TP.x),TP.y);+ }+ else if( (b02+b12+b23) > 2 ) // SmartFlt Case 4+ {+ if( (1+TP.x - TP.y) < 0.5 )+ ocolor = rgb2;+ else+ ocolor = lerp(lerp(rgb0,rgb1,TP.x),lerp(rgb1,rgb3,TP.x),TP.y);+ }+ else if( (b01+b02+b03) > 2 ) // SmartFlt Case 5+ {+ if( (TP.x + TP.y) < 0.5 )+ ocolor = rgb0;+ else+ ocolor = lerp(lerp(rgb3,rgb1,TP.x),lerp(rgb2,rgb3,TP.x),TP.y);+ }+ else if( (b01+b12+b13) > 2 ) // SmartFlt Case 6+ {+ if( (1-TP.x + TP.y) < 0.5 )+ ocolor = rgb1;+ else+ ocolor = lerp(lerp(rgb0,rgb2,TP.x),lerp(rgb2,rgb3,TP.x),TP.y);+ }+ else if( (b01+b02+b13) > 2 && b23<1 ) // SmartFlt Case 7+ {+ if( TP.y < 0.5)+ {+ if( TP.x < 0.5)+ ocolor = rgb0;+ else+ ocolor = rgb1;+ }+ else+ ocolor = lerp(rgb2,rgb3,TP.x);+ }+ else if( (b23+b02+b13) > 2 && b01<1 ) // SmartFlt Case 8+ {+ if( TP.y < 0.5)+ ocolor = lerp(rgb0,rgb1,TP.x);+ else+ {+ if( TP.x < 0.5)+ ocolor = rgb2;+ else+ ocolor = rgb3;+ }+ }+ else if( (b01+b02+b23) > 2 && b13<1 ) // SmartFlt Case 9+ {+ if( TP.x < 0.5)+ {+ if( TP.y < 0.5)+ ocolor = rgb0;+ else+ ocolor = rgb2;+ }+ else+ {+ ocolor = lerp(rgb1,rgb3,TP.y);+ }+ }+ else if( (b01+b23+b13) > 2 && b02<1 ) // SmartFlt Case 10+ {+ if( TP.x < 0.5)+ {+ ocolor = lerp(rgb0,rgb2,TP.y);+ }+ else+ {+ if( TP.y < 0.5)+ ocolor = rgb1;+ else+ ocolor = rgb3;+ }+ }+ else if( (b01+b23) > 1 && (b02+b13) < 1 ) // SmartFlt Case 1+ {+ if( TP.x < 0.5)+ ocolor = lerp(rgb0,rgb2,TP.y);+ else+ ocolor = lerp(rgb1,rgb3,TP.y);+ }+ else if( (b02+b13) > 1 && (b01+b23) < 1 ) // SmartFlt Case 2+ {+ if( TP.y < 0.5)+ ocolor = lerp(rgb0,rgb1,TP.x);+ else+ ocolor = lerp(rgb2,rgb3,TP.x);+ }+ else if( (b01+b02+b12+b23) > 2)+ {+ if( TP.y < 0.5)+ {+ if( TP.x < 0.5)+ ocolor = rgb0;+ else+ ocolor = rgb1;+ }+ else+ {+ if( TP.x < 0.5)+ ocolor = rgb2;+ else+ ocolor = rgb3;+ } + }+ + ocolor.a=1;+ return ocolor;+}++// here is where my fragile mind shuts down in self-defense+float4 hq4x (in float2 tc) : COLOR+{+ const float2 texel = {1./512, 1./448};+ const float2 halftexel = texel / 2.;++ const float3 dt = float3(1.4,1.4,1.4); // I have no fucking idea+ const float4 d4 = float4(1,1,1,1);+ const float mx = 1.00; // start smoothing wt.+ const float k = -1.10; // wt. decrease factor+ const float max_w = 0.90; // max filter weigth+ const float min_w = 0.05; // min filter weigth+ const float lum_add = 0.33; // effects smoothing++ float3 c = tex2D(Texture, tc).xyz;+ + float3 o1 = tex2D(Texture, tc + float2(-texel.x, -texel.y)).xyz;+ float3 o2 = tex2D(Texture, tc + float2( texel.x, -texel.y)).xyz;+ float3 o3 = tex2D(Texture, tc + float2( texel.x, texel.y)).xyz;+ float3 o4 = tex2D(Texture, tc + float2(-texel.x, texel.y)).xyz;++ float3 i1 = tex2D(Texture, tc + float2(-halftexel.x, -halftexel.y)).xyz;+ float3 i2 = tex2D(Texture, tc + float2( halftexel.x, -halftexel.y)).xyz;+ float3 i3 = tex2D(Texture, tc + float2( halftexel.x, halftexel.y)).xyz;+ float3 i4 = tex2D(Texture, tc + float2(-halftexel.x, halftexel.y)).xyz;+ + float3 s1 = tex2D(Texture, tc + float2(-texel.x, 0 )).xyz;+ float3 s2 = tex2D(Texture, tc + float2( texel.x, 0 )).xyz;+ float3 s3 = tex2D(Texture, tc + float2( 0 , -texel.y)).xyz;+ float3 s4 = tex2D(Texture, tc + float2( 0 , texel.y)).xyz;++ float ko1=dot(abs(o1-c),dt);+ float ko2=dot(abs(o2-c),dt);+ float ko3=dot(abs(o3-c),dt);+ float ko4=dot(abs(o4-c),dt);++ float4 w;+ w.yw = min(dot(abs(i1-i3),dt),0.6*(ko1+ko3));+ w.xz = min(dot(abs(i2-i4),dt),0.6*(ko2+ko4));++ if (ko3<ko1) w.x*= ko3/ko1;+ if (ko4<ko2) w.y*= ko4/ko2;+ if (ko1<ko3) w.z*= ko1/ko3;+ if (ko2<ko4) w.w*= ko2/ko4;++ c = (w.x*o1+w.y*o2+w.z*o3+w.w*o4+0.001*c)/(dot(w,d4)+0.001);++ w.x = k*dot(abs(i1-c)+abs(i3-c),dt)/(0.125*dot(i1+i3,dt)+lum_add);+ w.y = k*dot(abs(i2-c)+abs(i4-c),dt)/(0.125*dot(i2+i4,dt)+lum_add);+ w.z = k*dot(abs(s1-c)+abs(s2-c),dt)/(0.125*dot(s1+s2,dt)+lum_add);+ w.w = k*dot(abs(s3-c)+abs(s4-c),dt)/(0.125*dot(s3+s4,dt)+lum_add);+ + w.x = clamp(w.x+mx,min_w,max_w);+ w.y = clamp(w.y+mx,min_w,max_w);+ w.z = clamp(w.z+mx,min_w,max_w);+ w.w = clamp(w.w+mx,min_w,max_w);+ + c = (w.x*(i1+i3)+w.y*(i2+i4)+w.z*(s1+s2)+w.w*(s3+s4)+c)/(2.0*dot(w,d4)+1.0);++ return float4(c, 0);+}++float4 ps_main9(float2 t : TEXCOORD0) : COLOR // hq4x OR IS IT?+{+ return hq4x(t);+}++float cdist(float3 c1, float3 c2)+{+ float3x3 rgb2yuv = {0.299, 0.587, 0.114,+ -0.147, -0.289, 0.436,+ 0.615, -0.515, -0.1};+ return length(mul(c1, rgb2yuv) - mul(c2, rgb2yuv)); +}++float4 ps_main10(float2 tc : TEXCOORD0) : COLOR // scale2x+{+ float accept = 2;+ float reject = 1;+ float3 texel = float3(1 / texsize, 0);+ + float2 f = frac(tc / texel.xy);+ if (f.x >= 0.5)+ texel.x = -texel.x;+ if (f.y >= 0.5)+ texel.y = -texel.y; ++ float3 c = tex2D(Texture, tc);+ float3 l = tex2D(Texture, tc - texel.xz);+ float3 r = tex2D(Texture, tc + texel.xz);+ float3 u = tex2D(Texture, tc - texel.zy);+ float3 d = tex2D(Texture, tc + texel.zy);++ c = lerp(c, (l + u) / 2., saturate(accept * (1 - cdist(l, u))) * saturate(accept * (1 - cdist(d, r))) * saturate(reject * cdist(l, r)) * saturate(reject * cdist(u, d)));+ + return float4(c, 0);+}++float4 ps_main11(float2 tc : TEXCOORD0) : COLOR+{+ float3 texel = float3(1 / texsize, 0);++ float2 f = frac(tc * texsize);+ if (f.x >= 0.5) {+ texel.x = -texel.x;+ f.x = 1 - f.x;+ }+ if (f.y >= 0.5) {+ texel.y = -texel.y;+ f.y = 1 - f.y;+ }+ + float4 c = tex2D(Texture, tc);+ + if (f.x + f.y >= 0.5)+ return c;+ + float4 n = tex2D(Texture, tc - texel.zy);+ float4 w = tex2D(Texture, tc - texel.xz);+ + if (cdist(n,c) + cdist(w,c) > 4 * cdist(n, w))+ return lerp(w, n, 0.5 + f.x - f.y);++ return c;+}++float4 ps_main12(float2 tc : TEXCOORD0) : COLOR+{+ float3 texel = float3(1 / texsize, 0);++ float2 f = frac(tc * texsize);+ if (f.x >= 0.5) {+ texel.x = -texel.x;+ f.x = 1 - f.x;+ }+ if (f.y >= 0.5) {+ texel.y = -texel.y;+ f.y = 1 - f.y;+ }+ + float4 c = tex2D(Texture, tc);+ float4 n = tex2D(Texture, tc - texel.zy);+ float4 w = tex2D(Texture, tc - texel.xz);+ + if (cdist(n,c) + cdist(w,c) > 4 * cdist(n, w))+ return lerp(w, n, 0.5 + f.x - f.y);++ return c;+}+ #endif\ No newline at end of file