2 * Copyright (C) 2005-2010-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
22 texture g_KernelTexture;
27 Texture = <g_Texture>;
34 sampler KernelSampler =
37 Texture = <g_KernelTexture>;
46 float4 Position : POSITION;
47 float2 TextureUV : TEXCOORD0;
52 float4 RGBColor : COLOR0;
55 half3 weight(float pos)
59 w = tex1D(KernelSampler, pos).rgb;
61 w = tex1D(KernelSampler, pos).bgr;
64 #ifdef HAS_FLOAT_TEXTURE
71 half3 pixel(float xpos, float ypos)
73 return tex2D(RGBSampler, float2(xpos, ypos)).rgb;
76 half3 getLine(float ypos, float3 xpos1, float3 xpos2, half3 linetaps1, half3 linetaps2)
79 pixel(xpos1.r, ypos) * linetaps1.r +
80 pixel(xpos1.g, ypos) * linetaps2.r +
81 pixel(xpos1.b, ypos) * linetaps1.g +
82 pixel(xpos2.r, ypos) * linetaps2.g +
83 pixel(xpos2.g, ypos) * linetaps1.b +
84 pixel(xpos2.b, ypos) * linetaps2.b;
87 PS_OUTPUT CONVOLUTION6x6(VS_OUTPUT In)
91 float2 pos = In.TextureUV + g_StepXY * 0.5;
92 float2 f = frac(pos / g_StepXY);
94 half3 linetaps1 = weight((1.0 - f.x) / 2.0);
95 half3 linetaps2 = weight((1.0 - f.x) / 2.0 + 0.5);
96 half3 columntaps1 = weight((1.0 - f.y) / 2.0);
97 half3 columntaps2 = weight((1.0 - f.y) / 2.0 + 0.5);
99 // kernel generation code made sure taps add up to 1, no need to adjust here.
101 float2 xystart = (-2.0 - f) * g_StepXY + In.TextureUV;
102 float3 xpos1 = float3(
104 xystart.x + g_StepXY.x,
105 xystart.x + g_StepXY.x * 2.0);
106 float3 xpos2 = half3(
107 xystart.x + g_StepXY.x * 3.0,
108 xystart.x + g_StepXY.x * 4.0,
109 xystart.x + g_StepXY.x * 5.0);
111 OUT.RGBColor.rgb = getLine(xystart.y , xpos1, xpos2, linetaps1, linetaps2) * columntaps1.r +
112 getLine(xystart.y + g_StepXY.y , xpos1, xpos2, linetaps1, linetaps2) * columntaps2.r +
113 getLine(xystart.y + g_StepXY.y * 2.0, xpos1, xpos2, linetaps1, linetaps2) * columntaps1.g +
114 getLine(xystart.y + g_StepXY.y * 3.0, xpos1, xpos2, linetaps1, linetaps2) * columntaps2.g +
115 getLine(xystart.y + g_StepXY.y * 4.0, xpos1, xpos2, linetaps1, linetaps2) * columntaps1.b +
116 getLine(xystart.y + g_StepXY.y * 5.0, xpos1, xpos2, linetaps1, linetaps2) * columntaps2.b;
118 OUT.RGBColor.a = 1.0;
126 PixelShader = compile ps_3_0 CONVOLUTION6x6();