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 half3 weight(float pos)
73 w = tex1D(KernelSampler, pos).rgb;
75 w = tex1D(KernelSampler, pos).bgr;
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, float3 xpos1, float3 xpos2, half3 linetaps1, half3 linetaps2)
95 pixel(RGBSampler, xpos1.r, ypos) * linetaps1.r +
96 pixel(RGBSampler, xpos1.g, ypos) * linetaps2.r +
97 pixel(RGBSampler, xpos1.b, ypos) * linetaps1.g +
98 pixel(RGBSampler, xpos2.r, ypos) * linetaps2.g +
99 pixel(RGBSampler, xpos2.g, ypos) * linetaps1.b +
100 pixel(RGBSampler, xpos2.b, ypos) * linetaps2.b;
103 PS_OUTPUT CONVOLUTION6x6Horiz(VS_OUTPUT In)
107 float2 pos = In.TextureUV + g_StepXY_P0 * 0.5;
108 float2 f = frac(pos / g_StepXY_P0);
110 half3 linetaps1 = weight((1.0 - f.x) / 2.0);
111 half3 linetaps2 = weight((1.0 - f.x) / 2.0 + 0.5);
113 // kernel generation code made sure taps add up to 1, no need to adjust here.
116 xystart.x = (-2.0 - f.x) * g_StepXY_P0.x + In.TextureUV.x;
117 xystart.y = In.TextureUV.y;
119 float3 xpos1 = float3(
121 xystart.x + g_StepXY_P0.x,
122 xystart.x + g_StepXY_P0.x * 2.0);
123 float3 xpos2 = half3(
124 xystart.x + g_StepXY_P0.x * 3.0,
125 xystart.x + g_StepXY_P0.x * 4.0,
126 xystart.x + g_StepXY_P0.x * 5.0);
128 OUT.RGBColor.rgb = getLine(xystart.y, xpos1, xpos2, linetaps1, linetaps2);
129 OUT.RGBColor.a = 1.0;
134 // Code for second pass - vertical
136 half3 getRow(float xpos, float3 ypos1, float3 ypos2, half3 columntaps1, half3 columntaps2)
139 pixel(IntermediateSampler, xpos, ypos1.r) * columntaps1.r +
140 pixel(IntermediateSampler, xpos, ypos1.g) * columntaps2.r +
141 pixel(IntermediateSampler, xpos, ypos1.b) * columntaps1.g +
142 pixel(IntermediateSampler, xpos, ypos2.r) * columntaps2.g +
143 pixel(IntermediateSampler, xpos, ypos2.g) * columntaps1.b +
144 pixel(IntermediateSampler, xpos, ypos2.b) * columntaps2.b;
147 PS_OUTPUT CONVOLUTION6x6Vert(VS_OUTPUT In)
151 float2 pos = In.TextureUV + g_StepXY_P1 * 0.5;
152 float2 f = frac(pos / g_StepXY_P1);
154 half3 columntaps1 = weight((1.0 - f.y) / 2.0);
155 half3 columntaps2 = weight((1.0 - f.y) / 2.0 + 0.5);
157 // kernel generation code made sure taps add up to 1, no need to adjust here.
160 xystart.x = In.TextureUV.x;
161 xystart.y = (-2.0 - f.y) * g_StepXY_P1.y + In.TextureUV.y;
163 float3 ypos1 = float3(
165 xystart.y + g_StepXY_P1.y,
166 xystart.y + g_StepXY_P1.y * 2.0);
167 float3 ypos2 = half3(
168 xystart.y + g_StepXY_P1.y * 3.0,
169 xystart.y + g_StepXY_P1.y * 4.0,
170 xystart.y + g_StepXY_P1.y * 5.0);
172 OUT.RGBColor.rgb = getRow(xystart.x, ypos1, ypos2, columntaps1, columntaps2);
173 OUT.RGBColor.a = 1.0;
182 PixelShader = compile ps_3_0 CONVOLUTION6x6Horiz();
189 PixelShader = compile ps_3_0 CONVOLUTION6x6Vert();