#if SHADER_MODEL >= 0x400 #define COLOR SV_Target0 Texture2D Texture; SamplerState Sampler; float4 sample(float2 t) { return Texture.Sample(Sampler, t); } #else sampler Texture : register(s0); float4 sample(float2 t) { return tex2D(Texture, t); } #endif float2 texsize : register(c100); struct VS_INPUT { float4 p : POSITION; float2 t : TEXCOORD0; }; struct VS_OUTPUT { float4 p : POSITION; float2 pp : TEXCOORD1; float2 t : TEXCOORD0; }; struct PS_INPUT { float2 p : TEXCOORD1; float2 t : TEXCOORD0; }; VS_OUTPUT vs_main(VS_INPUT input) { VS_OUTPUT output; output.p = input.p; output.pp = input.p; output.t = input.t; return output; } float4 ps_main0(PS_INPUT input) : COLOR { return sample(input.t); } #if SHADER_MODEL >= 0x400 uint ps_main1(PS_INPUT input) : COLOR { float4 f = Texture.Sample(Sampler, input.t); f.a *= 256.0f/127; // hm, 0.5 won't give us 1.0 if we just multiply with 2 uint4 i = f * float4(0x001f, 0x03e0, 0x7c00, 0x8000); return (i.x & 0x001f) | (i.y & 0x03e0) | (i.z & 0x7c00) | (i.w & 0x8000); } #else float4 ps_main1(PS_INPUT input) : COLOR { float4 c = sample(input.t); c.a *= 128.0f / 255; // *= 0.5f is no good here, need to do this in order to get 0x80 for 1.0f (instead of 0x7f) return c; } #endif float4 ps_main2(PS_INPUT input) : COLOR { // huh? #if SHADER_MODEL >= 0x400 clip(sample(input.t).a - (0.5 - 0.9f/256)); #else clip(sample(input.t).a - (1.0 - 0.9f/256)); #endif // wtf? return 0; } // huh and wtf again float4 ps_main3(PS_INPUT input) : COLOR { #if SHADER_MODEL >= 0x400 clip((0.5 - 0.9f/256) - sample(input.t).a); #else clip((1.0 - 0.9f/256) - sample(input.t).a); #endif return 0; } float4 ps_main4(PS_INPUT input) : COLOR { #if SHADER_MODEL >= 0x400 float4 c = sample(input.t); return fmod(c * 255 + 0.5f, 256) / 255; #else // looks right to me! return 1; #endif } float4 ps_crt(PS_INPUT input, int i) { float4 mask[4] = { float4(1, 0, 0, 0), float4(0, 1, 0, 0), float4(0, 0, 1, 0), float4(1, 1, 1, 0) }; return sample(input.t) * saturate(mask[i] + 0.5f); } float4 ps_main5(PS_INPUT input) : COLOR // triangular { int2 p = (int2)input.p; // return ps_crt(input, ((p.x + (p.y & 1) * 3) >> 1) % 3); return ps_crt(input, ((p.x + ((p.y / 2) % 2) * 3) / 2) % 3); // return ps_crt(input, ((p.x + (p.y % 2) * 3) / 2) % 3); //return ps_crt(input, ((p.x + ((p.y >> 1) & 1) * 3) >> 1) % 3); } float4 ps_main6(PS_INPUT input) : COLOR // diagonal { int2 p = (int2)input.p; return ps_crt(input, (p.x + (p.y % 3)) % 3); } // guest's SaI (SaL according to guest) float4 ps_main7(PS_INPUT input) : COLOR { const float3 texel = float3(1/texsize, 0); const float3 htexel = 0.5 * texel; const float3 qtexel = 0.25 * texel; float3 dt = float3(1.0, 1.0, 1.0); float3 c11 = sample(input.t); float3 c01 = sample(input.t - htexel.xz); float3 c21 = sample(input.t + htexel.xz); float3 c10 = sample(input.t - htexel.zy); float3 c12 = sample(input.t + htexel.zy); 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); } // 8 was gigaherz's broken smartflt thing // hq4x-alike for dosbox float4 ps_main9 (PS_INPUT input) : COLOR { const float3 texel = float3(1/texsize, 0); const float3 htexel = 0.5 * texel; const float3 qtexel = 0.25 * texel; 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 = sample(input.t).xyz; float3 o1 = sample(input.t - htexel).xyz; float3 o2 = sample(input.t + htexel * float2( 1, -1)).xyz; float3 o3 = sample(input.t + htexel).xyz; float3 o4 = sample(input.t + htexel * float2(-1, 1)).xyz; float3 i1 = sample(input.t - qtexel).xyz; float3 i2 = sample(input.t + qtexel * float2( 1, -1)).xyz; float3 i3 = sample(input.t + qtexel).xyz; float3 i4 = sample(input.t + qtexel * float2(-1, 1)).xyz; float3 s1 = sample(input.t - htexel.xz).xyz; float3 s2 = sample(input.t + htexel.xz).xyz; float3 s3 = sample(input.t - htexel.zy).xyz; float3 s4 = sample(input.t + htexel.zy).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= 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 = sample(input.t); if (f.x + f.y >= 0.5) return c; float4 n = sample(input.t - texel.zy); float4 w = sample(input.t - 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; } // scale2x inspired float4 ps_main12(PS_INPUT input) : COLOR { float3 texel = float3(1 / texsize, 0); float2 f = frac(input.t * 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 = sample(input.t); float4 n = sample(input.t - texel.zy); float4 w = sample(input.t - 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; } // 13 was guest's "4xGLSLHqFilter", but 9 is generally superior