diff options
Diffstat (limited to 'system')
-rw-r--r-- | system/shaders/convolutionsep-4x4_d3d.fx | 89 | ||||
-rw-r--r-- | system/shaders/convolutionsep-6x6_d3d.fx | 111 |
2 files changed, 100 insertions, 100 deletions
diff --git a/system/shaders/convolutionsep-4x4_d3d.fx b/system/shaders/convolutionsep-4x4_d3d.fx index d8700f16a2..9c55bc2b36 100644 --- a/system/shaders/convolutionsep-4x4_d3d.fx +++ b/system/shaders/convolutionsep-4x4_d3d.fx @@ -22,7 +22,8 @@ texture g_Texture; texture g_KernelTexture; texture g_IntermediateTexture; -float2 g_StepXY; +float2 g_StepXY_P0; +float2 g_StepXY_P1; sampler RGBSampler = sampler_state { @@ -82,84 +83,84 @@ half4 weight(float pos) #endif } -half3 pixel(float xpos, float ypos) +half3 pixel(sampler samp, float xpos, float ypos) { - return tex2D(RGBSampler, float2(xpos, ypos)).rgb; + return tex2D(samp, float2(xpos, ypos)).rgb; } +// Code for first pass - horizontal + half3 getLine(float ypos, float4 xpos, half4 linetaps) { return - pixel(xpos.r, ypos) * linetaps.r + - pixel(xpos.g, ypos) * linetaps.g + - pixel(xpos.b, ypos) * linetaps.b + - pixel(xpos.a, ypos) * linetaps.a; + pixel(RGBSampler, xpos.r, ypos) * linetaps.r + + pixel(RGBSampler, xpos.g, ypos) * linetaps.g + + pixel(RGBSampler, xpos.b, ypos) * linetaps.b + + pixel(RGBSampler, xpos.a, ypos) * linetaps.a; } PS_OUTPUT CONVOLUTION4x4Horiz(VS_OUTPUT In) { PS_OUTPUT OUT; - float2 pos = In.TextureUV + g_StepXY * 0.5; - float2 f = frac(pos / g_StepXY); + float2 pos = In.TextureUV + g_StepXY_P0 * 0.5; + float2 f = frac(pos / g_StepXY_P0); - half4 linetaps = weight(1.0 - f.x); - half4 columntaps = weight(1.0 - f.y); + half4 linetaps = weight(1.0 - f.x); // kernel generation code made sure taps add up to 1, no need to adjust here. - float2 xystart = (-1.0 - f) * g_StepXY + In.TextureUV; + float2 xystart; + xystart.x = (-1.0 - f.x) * g_StepXY_P0.x + In.TextureUV.x; + xystart.y = In.TextureUV.y; + float4 xpos = float4( xystart.x, - xystart.x + g_StepXY.x, - xystart.x + g_StepXY.x * 2.0, - xystart.x + g_StepXY.x * 3.0); - - OUT.RGBColor.rgb = - getLine(xystart.y , xpos, linetaps) * columntaps.r + - getLine(xystart.y + g_StepXY.y , xpos, linetaps) * columntaps.g + - getLine(xystart.y + g_StepXY.y * 2.0, xpos, linetaps) * columntaps.b + - getLine(xystart.y + g_StepXY.y * 3.0, xpos, linetaps) * columntaps.a; + xystart.x + g_StepXY_P0.x, + xystart.x + g_StepXY_P0.x * 2.0, + xystart.x + g_StepXY_P0.x * 3.0); + OUT.RGBColor.rgb = getLine(xystart.y, xpos, linetaps); OUT.RGBColor.a = 1.0; + return OUT; } +// Code for second pass - vertical + +half3 getRow(float xpos, float4 ypos, half4 columntaps) +{ + return + pixel(IntermediateSampler, xpos, ypos.r) * columntaps.r + + pixel(IntermediateSampler, xpos, ypos.g) * columntaps.g + + pixel(IntermediateSampler, xpos, ypos.b) * columntaps.b + + pixel(IntermediateSampler, xpos, ypos.a) * columntaps.a; +} + PS_OUTPUT CONVOLUTION4x4Vert(VS_OUTPUT In) { PS_OUTPUT OUT; - float2 pos = In.TextureUV + g_StepXY * 0.5; - float2 f = frac(pos / g_StepXY); + float2 pos = In.TextureUV + g_StepXY_P1 * 0.5; + float2 f = frac(pos / g_StepXY_P1); - half4 linetaps = weight(1.0 - f.x); half4 columntaps = weight(1.0 - f.y); // kernel generation code made sure taps add up to 1, no need to adjust here. - float2 xystart = (-1.0 - f) * g_StepXY + In.TextureUV; - float4 xpos = float4( - xystart.x, - xystart.x + g_StepXY.x, - xystart.x + g_StepXY.x * 2.0, - xystart.x + g_StepXY.x * 3.0); + float2 xystart; + xystart.x = In.TextureUV.x; + xystart.y = (-1.0 - f.y) * g_StepXY_P1.y + In.TextureUV.y; - OUT.RGBColor.rgb = - getLine(xystart.y , xpos, linetaps) * columntaps.r + - getLine(xystart.y + g_StepXY.y , xpos, linetaps) * columntaps.g + - getLine(xystart.y + g_StepXY.y * 2.0, xpos, linetaps) * columntaps.b + - getLine(xystart.y + g_StepXY.y * 3.0, xpos, linetaps) * columntaps.a; + float4 ypos = float4( + xystart.y, + xystart.y + g_StepXY_P1.y, + xystart.y + g_StepXY_P1.y * 2.0, + xystart.y + g_StepXY_P1.y * 3.0); + OUT.RGBColor.rgb = getRow(xystart.x, ypos, columntaps); OUT.RGBColor.a = 1.0; - return OUT; -} -PS_OUTPUT Nothing(VS_OUTPUT In) -{ - PS_OUTPUT OUT; - - OUT.RGBColor.rgb = tex2D(IntermediateSampler, In.TextureUV).rgb; - OUT.RGBColor.a = 1.0; return OUT; } @@ -174,7 +175,7 @@ technique SCALER_T } pass P1 { - PixelShader = compile ps_3_0 Nothing(); + PixelShader = compile ps_3_0 CONVOLUTION4x4Vert(); ZEnable = False; FillMode = Solid; FogEnable = False; diff --git a/system/shaders/convolutionsep-6x6_d3d.fx b/system/shaders/convolutionsep-6x6_d3d.fx index 52cc641664..07073e860e 100644 --- a/system/shaders/convolutionsep-6x6_d3d.fx +++ b/system/shaders/convolutionsep-6x6_d3d.fx @@ -22,7 +22,8 @@ texture g_Texture; texture g_KernelTexture; texture g_IntermediateTexture; -float2 g_StepXY; +float2 g_StepXY_P0; +float2 g_StepXY_P1; sampler RGBSampler = sampler_state { @@ -82,98 +83,96 @@ half3 weight(float pos) #endif } -half3 pixel(float xpos, float ypos) +half3 pixel(sampler samp, float xpos, float ypos) { - return tex2D(RGBSampler, float2(xpos, ypos)).rgb; + return tex2D(samp, float2(xpos, ypos)).rgb; } +// Code for first pass - horizontal + half3 getLine(float ypos, float3 xpos1, float3 xpos2, half3 linetaps1, half3 linetaps2) { return - pixel(xpos1.r, ypos) * linetaps1.r + - pixel(xpos1.g, ypos) * linetaps2.r + - pixel(xpos1.b, ypos) * linetaps1.g + - pixel(xpos2.r, ypos) * linetaps2.g + - pixel(xpos2.g, ypos) * linetaps1.b + - pixel(xpos2.b, ypos) * linetaps2.b; + pixel(RGBSampler, xpos1.r, ypos) * linetaps1.r + + pixel(RGBSampler, xpos1.g, ypos) * linetaps2.r + + pixel(RGBSampler, xpos1.b, ypos) * linetaps1.g + + pixel(RGBSampler, xpos2.r, ypos) * linetaps2.g + + pixel(RGBSampler, xpos2.g, ypos) * linetaps1.b + + pixel(RGBSampler, xpos2.b, ypos) * linetaps2.b; } PS_OUTPUT CONVOLUTION6x6Horiz(VS_OUTPUT In) { PS_OUTPUT OUT; - float2 pos = In.TextureUV + g_StepXY * 0.5; - float2 f = frac(pos / g_StepXY); + float2 pos = In.TextureUV + g_StepXY_P0 * 0.5; + float2 f = frac(pos / g_StepXY_P0); - half3 linetaps1 = weight((1.0 - f.x) / 2.0); - half3 linetaps2 = weight((1.0 - f.x) / 2.0 + 0.5); - half3 columntaps1 = weight((1.0 - f.y) / 2.0); - half3 columntaps2 = weight((1.0 - f.y) / 2.0 + 0.5); + half3 linetaps1 = weight((1.0 - f.x) / 2.0); + half3 linetaps2 = weight((1.0 - f.x) / 2.0 + 0.5); // kernel generation code made sure taps add up to 1, no need to adjust here. - float2 xystart = (-2.0 - f) * g_StepXY + In.TextureUV; + float2 xystart; + xystart.x = (-2.0 - f.x) * g_StepXY_P0.x + In.TextureUV.x; + xystart.y = In.TextureUV.y; + float3 xpos1 = float3( xystart.x, - xystart.x + g_StepXY.x, - xystart.x + g_StepXY.x * 2.0); + xystart.x + g_StepXY_P0.x, + xystart.x + g_StepXY_P0.x * 2.0); float3 xpos2 = half3( - xystart.x + g_StepXY.x * 3.0, - xystart.x + g_StepXY.x * 4.0, - xystart.x + g_StepXY.x * 5.0); - - OUT.RGBColor.rgb = getLine(xystart.y , xpos1, xpos2, linetaps1, linetaps2) * columntaps1.r + - getLine(xystart.y + g_StepXY.y , xpos1, xpos2, linetaps1, linetaps2) * columntaps2.r + - getLine(xystart.y + g_StepXY.y * 2.0, xpos1, xpos2, linetaps1, linetaps2) * columntaps1.g + - getLine(xystart.y + g_StepXY.y * 3.0, xpos1, xpos2, linetaps1, linetaps2) * columntaps2.g + - getLine(xystart.y + g_StepXY.y * 4.0, xpos1, xpos2, linetaps1, linetaps2) * columntaps1.b + - getLine(xystart.y + g_StepXY.y * 5.0, xpos1, xpos2, linetaps1, linetaps2) * columntaps2.b; + xystart.x + g_StepXY_P0.x * 3.0, + xystart.x + g_StepXY_P0.x * 4.0, + xystart.x + g_StepXY_P0.x * 5.0); + OUT.RGBColor.rgb = getLine(xystart.y, xpos1, xpos2, linetaps1, linetaps2); OUT.RGBColor.a = 1.0; + return OUT; } +// Code for second pass - vertical + +half3 getRow(float xpos, float3 ypos1, float3 ypos2, half3 columntaps1, half3 columntaps2) +{ + return + pixel(IntermediateSampler, xpos, ypos1.r) * columntaps1.r + + pixel(IntermediateSampler, xpos, ypos1.g) * columntaps2.r + + pixel(IntermediateSampler, xpos, ypos1.b) * columntaps1.g + + pixel(IntermediateSampler, xpos, ypos2.r) * columntaps2.g + + pixel(IntermediateSampler, xpos, ypos2.g) * columntaps1.b + + pixel(IntermediateSampler, xpos, ypos2.b) * columntaps2.b; +} + PS_OUTPUT CONVOLUTION6x6Vert(VS_OUTPUT In) { PS_OUTPUT OUT; - float2 pos = In.TextureUV + g_StepXY * 0.5; - float2 f = frac(pos / g_StepXY); + float2 pos = In.TextureUV + g_StepXY_P1 * 0.5; + float2 f = frac(pos / g_StepXY_P1); - half3 linetaps1 = weight((1.0 - f.x) / 2.0); - half3 linetaps2 = weight((1.0 - f.x) / 2.0 + 0.5); half3 columntaps1 = weight((1.0 - f.y) / 2.0); half3 columntaps2 = weight((1.0 - f.y) / 2.0 + 0.5); // kernel generation code made sure taps add up to 1, no need to adjust here. - float2 xystart = (-2.0 - f) * g_StepXY + In.TextureUV; - float3 xpos1 = float3( - xystart.x, - xystart.x + g_StepXY.x, - xystart.x + g_StepXY.x * 2.0); - float3 xpos2 = half3( - xystart.x + g_StepXY.x * 3.0, - xystart.x + g_StepXY.x * 4.0, - xystart.x + g_StepXY.x * 5.0); + float2 xystart; + xystart.x = In.TextureUV.x; + xystart.y = (-2.0 - f.y) * g_StepXY_P1.y + In.TextureUV.y; - OUT.RGBColor.rgb = getLine(xystart.y , xpos1, xpos2, linetaps1, linetaps2) * columntaps1.r + - getLine(xystart.y + g_StepXY.y , xpos1, xpos2, linetaps1, linetaps2) * columntaps2.r + - getLine(xystart.y + g_StepXY.y * 2.0, xpos1, xpos2, linetaps1, linetaps2) * columntaps1.g + - getLine(xystart.y + g_StepXY.y * 3.0, xpos1, xpos2, linetaps1, linetaps2) * columntaps2.g + - getLine(xystart.y + g_StepXY.y * 4.0, xpos1, xpos2, linetaps1, linetaps2) * columntaps1.b + - getLine(xystart.y + g_StepXY.y * 5.0, xpos1, xpos2, linetaps1, linetaps2) * columntaps2.b; + float3 ypos1 = float3( + xystart.y, + xystart.y + g_StepXY_P1.y, + xystart.y + g_StepXY_P1.y * 2.0); + float3 ypos2 = half3( + xystart.y + g_StepXY_P1.y * 3.0, + xystart.y + g_StepXY_P1.y * 4.0, + xystart.y + g_StepXY_P1.y * 5.0); + OUT.RGBColor.rgb = getRow(xystart.x, ypos1, ypos2, columntaps1, columntaps2); OUT.RGBColor.a = 1.0; - return OUT; -} -PS_OUTPUT Nothing(VS_OUTPUT In) -{ - PS_OUTPUT OUT; - - OUT.RGBColor.rgb = tex2D(IntermediateSampler, In.TextureUV).rgb; - OUT.RGBColor.a = 1.0; return OUT; } @@ -188,7 +187,7 @@ technique SCALER_T } pass P1 { - PixelShader = compile ps_3_0 Nothing(); + PixelShader = compile ps_3_0 CONVOLUTION6x6Vert(); ZEnable = False; FillMode = Solid; FogEnable = False; |