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, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 * http://www.gnu.org/copyleft/gpl.html
23 texture g_KernelTexture;
24 texture g_IntermediateTexture;
30 Texture = <g_Texture>;
38 sampler KernelSampler =
41 Texture = <g_KernelTexture>;
49 sampler IntermediateSampler =
51 Texture = <g_IntermediateTexture>;
61 float4 Position : POSITION;
62 float2 TextureUV : TEXCOORD0;
67 float4 RGBColor : COLOR0;
70 half3 weight(float pos)
74 w = tex1D(KernelSampler, pos).rgb;
76 w = tex1D(KernelSampler, pos).bgr;
79 #ifdef HAS_FLOAT_TEXTURE
86 half3 pixel(sampler samp, float xpos, float ypos)
88 return tex2D(samp, float2(xpos, ypos)).rgb;
91 // Code for first pass - horizontal
93 half3 getLine(float ypos, float3 xpos1, float3 xpos2, half3 linetaps1, half3 linetaps2)
96 pixel(RGBSampler, xpos1.r, ypos) * linetaps1.r +
97 pixel(RGBSampler, xpos1.g, ypos) * linetaps2.r +
98 pixel(RGBSampler, xpos1.b, ypos) * linetaps1.g +
99 pixel(RGBSampler, xpos2.r, ypos) * linetaps2.g +
100 pixel(RGBSampler, xpos2.g, ypos) * linetaps1.b +
101 pixel(RGBSampler, xpos2.b, ypos) * linetaps2.b;
104 PS_OUTPUT CONVOLUTION6x6Horiz(VS_OUTPUT In)
108 float2 pos = In.TextureUV + g_StepXY_P0 * 0.5;
109 float2 f = frac(pos / g_StepXY_P0);
111 half3 linetaps1 = weight((1.0 - f.x) / 2.0);
112 half3 linetaps2 = weight((1.0 - f.x) / 2.0 + 0.5);
114 // kernel generation code made sure taps add up to 1, no need to adjust here.
117 xystart.x = (-2.0 - f.x) * g_StepXY_P0.x + In.TextureUV.x;
118 xystart.y = In.TextureUV.y;
120 float3 xpos1 = float3(
122 xystart.x + g_StepXY_P0.x,
123 xystart.x + g_StepXY_P0.x * 2.0);
124 float3 xpos2 = half3(
125 xystart.x + g_StepXY_P0.x * 3.0,
126 xystart.x + g_StepXY_P0.x * 4.0,
127 xystart.x + g_StepXY_P0.x * 5.0);
129 OUT.RGBColor.rgb = getLine(xystart.y, xpos1, xpos2, linetaps1, linetaps2);
130 OUT.RGBColor.a = 1.0;
135 // Code for second pass - vertical
137 half3 getRow(float xpos, float3 ypos1, float3 ypos2, half3 columntaps1, half3 columntaps2)
140 pixel(IntermediateSampler, xpos, ypos1.r) * columntaps1.r +
141 pixel(IntermediateSampler, xpos, ypos1.g) * columntaps2.r +
142 pixel(IntermediateSampler, xpos, ypos1.b) * columntaps1.g +
143 pixel(IntermediateSampler, xpos, ypos2.r) * columntaps2.g +
144 pixel(IntermediateSampler, xpos, ypos2.g) * columntaps1.b +
145 pixel(IntermediateSampler, xpos, ypos2.b) * columntaps2.b;
148 PS_OUTPUT CONVOLUTION6x6Vert(VS_OUTPUT In)
152 float2 pos = In.TextureUV + g_StepXY_P1 * 0.5;
153 float2 f = frac(pos / g_StepXY_P1);
155 half3 columntaps1 = weight((1.0 - f.y) / 2.0);
156 half3 columntaps2 = weight((1.0 - f.y) / 2.0 + 0.5);
158 // kernel generation code made sure taps add up to 1, no need to adjust here.
161 xystart.x = In.TextureUV.x;
162 xystart.y = (-2.0 - f.y) * g_StepXY_P1.y + In.TextureUV.y;
164 float3 ypos1 = float3(
166 xystart.y + g_StepXY_P1.y,
167 xystart.y + g_StepXY_P1.y * 2.0);
168 float3 ypos2 = half3(
169 xystart.y + g_StepXY_P1.y * 3.0,
170 xystart.y + g_StepXY_P1.y * 4.0,
171 xystart.y + g_StepXY_P1.y * 5.0);
173 OUT.RGBColor.rgb = getRow(xystart.x, ypos1, ypos2, columntaps1, columntaps2);
174 OUT.RGBColor.a = 1.0;
183 PixelShader = compile ps_3_0 CONVOLUTION6x6Horiz();
190 PixelShader = compile ps_3_0 CONVOLUTION6x6Vert();