2 * Copyright (C) 2005-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;
23 texture g_IntermediateTexture;
29 Texture = <g_Texture>;
37 sampler KernelSampler =
40 Texture = <g_KernelTexture>;
48 sampler IntermediateSampler =
50 Texture = <g_IntermediateTexture>;
60 float4 Position : POSITION;
61 float2 TextureUV : TEXCOORD0;
66 float4 RGBColor : COLOR0;
69 half4 weight(float pos)
73 w = tex1D(KernelSampler, pos);
75 w = tex1D(KernelSampler, pos).bgra;
78 #ifdef HAS_FLOAT_TEXTURE
85 half3 pixel(sampler samp, float xpos, float ypos)
87 return tex2D(samp, float2(xpos, ypos)).rgb;
90 // Code for first pass - horizontal
92 half3 getLine(float ypos, float4 xpos, half4 linetaps)
95 pixel(RGBSampler, xpos.r, ypos) * linetaps.r +
96 pixel(RGBSampler, xpos.g, ypos) * linetaps.g +
97 pixel(RGBSampler, xpos.b, ypos) * linetaps.b +
98 pixel(RGBSampler, xpos.a, ypos) * linetaps.a;
101 PS_OUTPUT CONVOLUTION4x4Horiz(VS_OUTPUT In)
105 float2 pos = In.TextureUV + g_StepXY_P0 * 0.5;
106 float2 f = frac(pos / g_StepXY_P0);
108 half4 linetaps = weight(1.0 - f.x);
110 // kernel generation code made sure taps add up to 1, no need to adjust here.
113 xystart.x = (-1.0 - f.x) * g_StepXY_P0.x + In.TextureUV.x;
114 xystart.y = In.TextureUV.y;
116 float4 xpos = float4(
118 xystart.x + g_StepXY_P0.x,
119 xystart.x + g_StepXY_P0.x * 2.0,
120 xystart.x + g_StepXY_P0.x * 3.0);
122 OUT.RGBColor.rgb = getLine(xystart.y, xpos, linetaps);
123 OUT.RGBColor.a = 1.0;
128 // Code for second pass - vertical
130 half3 getRow(float xpos, float4 ypos, half4 columntaps)
133 pixel(IntermediateSampler, xpos, ypos.r) * columntaps.r +
134 pixel(IntermediateSampler, xpos, ypos.g) * columntaps.g +
135 pixel(IntermediateSampler, xpos, ypos.b) * columntaps.b +
136 pixel(IntermediateSampler, xpos, ypos.a) * columntaps.a;
139 PS_OUTPUT CONVOLUTION4x4Vert(VS_OUTPUT In)
143 float2 pos = In.TextureUV + g_StepXY_P1 * 0.5;
144 float2 f = frac(pos / g_StepXY_P1);
146 half4 columntaps = weight(1.0 - f.y);
148 // kernel generation code made sure taps add up to 1, no need to adjust here.
151 xystart.x = In.TextureUV.x;
152 xystart.y = (-1.0 - f.y) * g_StepXY_P1.y + In.TextureUV.y;
154 float4 ypos = float4(
156 xystart.y + g_StepXY_P1.y,
157 xystart.y + g_StepXY_P1.y * 2.0,
158 xystart.y + g_StepXY_P1.y * 3.0);
160 OUT.RGBColor.rgb = getRow(xystart.x, ypos, columntaps);
161 OUT.RGBColor.a = 1.0;
170 PixelShader = compile ps_3_0 CONVOLUTION4x4Horiz();
177 PixelShader = compile ps_3_0 CONVOLUTION4x4Vert();