diff options
Diffstat (limited to 'system/shaders/convolutionsep-6x6_d3d.fx')
-rw-r--r-- | system/shaders/convolutionsep-6x6_d3d.fx | 189 |
1 files changed, 84 insertions, 105 deletions
diff --git a/system/shaders/convolutionsep-6x6_d3d.fx b/system/shaders/convolutionsep-6x6_d3d.fx index db106e62e8..9a5f27f8d3 100644 --- a/system/shaders/convolutionsep-6x6_d3d.fx +++ b/system/shaders/convolutionsep-6x6_d3d.fx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2013 Team XBMC + * Copyright (C) 2005-2015 Team XBMC * http://xbmc.org * * This Program is free software; you can redistribute it and/or modify @@ -18,92 +18,87 @@ * */ -texture g_Texture; -texture g_KernelTexture; -texture g_IntermediateTexture; -float2 g_StepXY_P0; -float2 g_StepXY_P1; - -sampler RGBSampler = - sampler_state { - Texture = <g_Texture>; - AddressU = CLAMP; - AddressV = CLAMP; - MipFilter = LINEAR; - MinFilter = POINT; - MagFilter = POINT; - }; - -sampler KernelSampler = - sampler_state - { - Texture = <g_KernelTexture>; - AddressU = CLAMP; - AddressV = CLAMP; - MipFilter = LINEAR; - MinFilter = LINEAR; - MagFilter = LINEAR; - }; - -sampler IntermediateSampler = - sampler_state { - Texture = <g_IntermediateTexture>; - AddressU = CLAMP; - AddressV = CLAMP; - MipFilter = LINEAR; - MinFilter = POINT; - MagFilter = POINT; - }; +texture2D g_Texture; +texture2D g_KernelTexture; +float2 g_StepXY_P0; +float2 g_StepXY_P1; +float g_viewportWidth; +float g_viewportHeight; -struct VS_OUTPUT +SamplerState RGBSampler : IMMUTABLE +{ + AddressU = CLAMP; + AddressV = CLAMP; + Filter = MIN_MAG_POINT_MIP_LINEAR; +}; + +SamplerState KernelSampler : IMMUTABLE +{ + AddressU = CLAMP; + AddressV = CLAMP; + Filter = MIN_MAG_MIP_LINEAR; +}; + +struct VS_INPUT { float4 Position : POSITION; float2 TextureUV : TEXCOORD0; }; -struct PS_OUTPUT +struct VS_OUTPUT { - float4 RGBColor : COLOR0; + float4 Position : SV_POSITION; + float2 TextureUV : TEXCOORD0; }; -half3 weight(float pos) +// +// VS for rendering in screen space +// +VS_OUTPUT VS(VS_INPUT In) +{ + VS_OUTPUT output = (VS_OUTPUT)0; + output.Position.x = (In.Position.x / (g_viewportWidth / 2.0)) - 1; + output.Position.y = -(In.Position.y / (g_viewportHeight / 2.0)) + 1; + output.Position.z = output.Position.z; + output.Position.w = 1.0; + output.TextureUV = In.TextureUV; + + return output; +} + +inline half3 weight(float pos) { - half3 w; #ifdef HAS_RGBA - w = tex1D(KernelSampler, pos).rgb; + half3 w = g_KernelTexture.Sample(KernelSampler, pos).rgb; #else - w = tex1D(KernelSampler, pos).bgr; + half3 w = g_KernelTexture.Sample(KernelSampler, pos).bgr; #endif -#ifdef HAS_FLOAT_TEXTURE - return w; -#else - return w * 2.0 - 1.0; +#ifndef HAS_FLOAT_TEXTURE + w = w * 2.0 - 1.0; #endif + return w; } -half3 pixel(sampler samp, float xpos, float ypos) +inline half3 pixel(texture2D tex, float xpos, float ypos) { - return tex2D(samp, float2(xpos, ypos)).rgb; + return tex.Sample(RGBSampler, float2(xpos, ypos)).rgb; } -// Code for first pass - horizontal - half3 getLine(float ypos, float3 xpos1, float3 xpos2, half3 linetaps1, half3 linetaps2) { return - 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; + g_Texture.Sample(RGBSampler, float2(xpos1.r, ypos)).rgb * linetaps1.r + + g_Texture.Sample(RGBSampler, float2(xpos1.g, ypos)).rgb * linetaps2.r + + g_Texture.Sample(RGBSampler, float2(xpos1.b, ypos)).rgb * linetaps1.g + + g_Texture.Sample(RGBSampler, float2(xpos2.r, ypos)).rgb * linetaps2.g + + g_Texture.Sample(RGBSampler, float2(xpos2.g, ypos)).rgb * linetaps1.b + + g_Texture.Sample(RGBSampler, float2(xpos2.b, ypos)).rgb * linetaps2.b; } -PS_OUTPUT CONVOLUTION6x6Horiz(VS_OUTPUT In) +// Code for first pass - horizontal +float4 CONVOLUTION6x6Horiz(VS_OUTPUT In) : SV_TARGET { - PS_OUTPUT OUT; - float2 pos = In.TextureUV + g_StepXY_P0 * 0.5; float2 f = frac(pos / g_StepXY_P0); @@ -112,23 +107,18 @@ PS_OUTPUT CONVOLUTION6x6Horiz(VS_OUTPUT In) // kernel generation code made sure taps add up to 1, no need to adjust here. - float2 xystart; - xystart.x = (-2.0 - f.x) * g_StepXY_P0.x + In.TextureUV.x; - xystart.y = In.TextureUV.y; + float xstart = (-2.0 - f.x) * g_StepXY_P0.x + In.TextureUV.x; float3 xpos1 = float3( - xystart.x, - xystart.x + g_StepXY_P0.x, - xystart.x + g_StepXY_P0.x * 2.0); + xstart, + xstart + g_StepXY_P0.x, + xstart + g_StepXY_P0.x * 2.0); float3 xpos2 = half3( - 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; + xstart + g_StepXY_P0.x * 3.0, + xstart + g_StepXY_P0.x * 4.0, + xstart + g_StepXY_P0.x * 5.0); - return OUT; + return float4(getLine(In.TextureUV.y, xpos1, xpos2, linetaps1, linetaps2), 1.0); } // Code for second pass - vertical @@ -136,18 +126,16 @@ PS_OUTPUT CONVOLUTION6x6Horiz(VS_OUTPUT In) 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; + g_Texture.Sample(RGBSampler, float2(xpos, ypos1.r)).rgb * columntaps1.r + + g_Texture.Sample(RGBSampler, float2(xpos, ypos1.g)).rgb * columntaps2.r + + g_Texture.Sample(RGBSampler, float2(xpos, ypos1.b)).rgb * columntaps1.g + + g_Texture.Sample(RGBSampler, float2(xpos, ypos2.r)).rgb * columntaps2.g + + g_Texture.Sample(RGBSampler, float2(xpos, ypos2.g)).rgb * columntaps1.b + + g_Texture.Sample(RGBSampler, float2(xpos, ypos2.b)).rgb * columntaps2.b; } -PS_OUTPUT CONVOLUTION6x6Vert(VS_OUTPUT In) +float4 CONVOLUTION6x6Vert(VS_OUTPUT In) : SV_TARGET { - PS_OUTPUT OUT; - float2 pos = In.TextureUV + g_StepXY_P1 * 0.5; float2 f = frac(pos / g_StepXY_P1); @@ -156,39 +144,30 @@ PS_OUTPUT CONVOLUTION6x6Vert(VS_OUTPUT In) // kernel generation code made sure taps add up to 1, no need to adjust here. - float2 xystart; - xystart.x = In.TextureUV.x; - xystart.y = (-2.0 - f.y) * g_StepXY_P1.y + In.TextureUV.y; + float ystart = (-2.0 - f.y) * g_StepXY_P1.y + In.TextureUV.y; float3 ypos1 = float3( - xystart.y, - xystart.y + g_StepXY_P1.y, - xystart.y + g_StepXY_P1.y * 2.0); + ystart, + ystart + g_StepXY_P1.y, + ystart + 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; + ystart + g_StepXY_P1.y * 3.0, + ystart + g_StepXY_P1.y * 4.0, + ystart + g_StepXY_P1.y * 5.0); - return OUT; + return float4(getRow(In.TextureUV.x, ypos1, ypos2, columntaps1, columntaps2), 1.0); } -technique SCALER_T +technique10 SCALER_T { pass P0 { - PixelShader = compile ps_3_0 CONVOLUTION6x6Horiz(); - ZEnable = False; - FillMode = Solid; - FogEnable = False; + SetVertexShader( CompileShader( vs_4_0_level_9_3, VS() ) ); + SetPixelShader( CompileShader( ps_4_0_level_9_3, CONVOLUTION6x6Horiz() ) ); } pass P1 { - PixelShader = compile ps_3_0 CONVOLUTION6x6Vert(); - ZEnable = False; - FillMode = Solid; - FogEnable = False; + SetVertexShader( CompileShader( vs_4_0_level_9_3, VS() ) ); + SetPixelShader( CompileShader( ps_4_0_level_9_3, CONVOLUTION6x6Vert() ) ); } }; |