From c560ccbabc443eab215c2d978a1700d832b743ff Mon Sep 17 00:00:00 2001 From: Themaister Date: Mon, 15 Nov 2010 21:51:16 +0100 Subject: [PATCH] Should fix quad shader. :P --- hqflt/cg/quad.cg | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/hqflt/cg/quad.cg b/hqflt/cg/quad.cg index 60488c3282..fa6832953d 100644 --- a/hqflt/cg/quad.cg +++ b/hqflt/cg/quad.cg @@ -51,21 +51,37 @@ float3 quad_inter(float3 x0, float3 x1, float3 x2, float x) output main_fragment (float2 tex : TEXCOORD0, uniform input IN, uniform sampler2D s0 : TEXUNIT0) { float2 texsize = IN.texture_size; - float dx = float(pow(1.0 * texsize.x, -1.0)); - float dy = float(pow(1.0 * texsize.y, -1.0)); + float sharpness = 2.0; + float dx = float(pow(sharpness * texsize.x, -1.0)); + float dy = float(pow(sharpness * texsize.y, -1.0)); + float3 c00 = tex2D(s0, tex + float2(-dx, -dy)).xyz; float3 c01 = tex2D(s0, tex + float2(-dx, 0)).xyz; + float3 c02 = tex2D(s0, tex + float2(-dx, dy)).xyz; float3 c10 = tex2D(s0, tex + float2(0, -dy)).xyz; float3 c11 = tex2D(s0, tex + float2(0, 0)).xyz; float3 c12 = tex2D(s0, tex + float2(0, dy)).xyz; + float3 c20 = tex2D(s0, tex + float2(dx, -dy)).xyz; float3 c21 = tex2D(s0, tex + float2(dx, 0)).xyz; + float3 c22 = tex2D(s0, tex + float2(dx, dy)).xyz; - float blur = 1.5; - float3 xval0 = quad_inter(c01, c11, c21, blur*(frac(tex.x * texsize.x)) + (2.0 - blur) * 0.5); - float3 yval0 = quad_inter(c10, c11, c12, blur*(frac(tex.y * texsize.y)) + (2.0 - blur) * 0.5); + float frac_amt_x = frac(tex.x * texsize.x); + float frac_amt_y = frac(tex.y * texsize.y); + float3 loval = quad_inter(c00, c10, c20, frac_amt_x + 0.5); + float3 midval = quad_inter(c01, c11, c21, frac_amt_x + 0.5); + float3 hival = quad_inter(c02, c12, c22, frac_amt_x + 0.5); + float3 res = quad_inter(loval, midval, hival, frac_amt_y + 0.5); output OUT; - OUT.color = float4(lerp(xval0, yval0, 0.5), 1.0); + +// Bilinear! +// float3 first = lerp(c00, c20, frac(tex.x * texsize.x + 0.5)); +// float3 second = lerp(c02, c22, frac(tex.x * texsize.x + 0.5)); +// float3 res = lerp(first, second, frac(tex.y * texsize.y + 0.5)); +// OUT.color = float4(res, 1.0); + + + OUT.color = float4(res, 1.0); return OUT; }