diff options
author | Anton Fedchin <afedchin@ruswizards.com> | 2015-04-22 18:08:15 +0300 |
---|---|---|
committer | Anton Fedchin <afedchin@ruswizards.com> | 2015-07-04 10:25:09 +0300 |
commit | 557bc0c362b43ab24439d2cf8149f87885162ff6 (patch) | |
tree | 95e733b5bf1d8c3c3e37f070ffe5fd9ca775f580 /system/shaders/convolution-6x6_d3d.fx | |
parent | ec543ddedbfb323ff7042b4e5f74430ff9cd2095 (diff) |
[WinVideoFilter] Rework to DirectX11.
Diffstat (limited to 'system/shaders/convolution-6x6_d3d.fx')
-rw-r--r-- | system/shaders/convolution-6x6_d3d.fx | 120 |
1 files changed, 58 insertions, 62 deletions
diff --git a/system/shaders/convolution-6x6_d3d.fx b/system/shaders/convolution-6x6_d3d.fx index 06cec53d29..a773a01855 100644 --- a/system/shaders/convolution-6x6_d3d.fx +++ b/system/shaders/convolution-6x6_d3d.fx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010-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,76 +18,74 @@ * */ -texture g_Texture; -texture g_KernelTexture; -float2 g_StepXY; - -sampler RGBSampler = - sampler_state { - Texture = <g_Texture>; - AddressU = CLAMP; - AddressV = CLAMP; - MinFilter = POINT; - MagFilter = POINT; - }; - -sampler KernelSampler = - sampler_state - { - Texture = <g_KernelTexture>; - AddressU = CLAMP; - AddressV = CLAMP; - MinFilter = LINEAR; - MagFilter = LINEAR; - }; +texture2D g_Texture; +texture2D g_KernelTexture; +float2 g_StepXY; +float g_viewportWidth; +float g_viewportHeight; + +SamplerState RGBSampler : IMMUTABLE +{ + AddressU = CLAMP; + AddressV = CLAMP; + Filter = MIN_MAG_MIP_POINT; +}; + +SamplerState KernelSampler : IMMUTABLE +{ + AddressU = CLAMP; + AddressV = CLAMP; + Filter = MIN_MAG_MIP_LINEAR; +}; struct VS_OUTPUT { - float4 Position : POSITION; + float4 Position : SV_POSITION; float2 TextureUV : TEXCOORD0; }; -struct PS_OUTPUT +// +// VS for rendering in screen space +// +VS_OUTPUT VS(VS_OUTPUT In) { - float4 RGBColor : COLOR0; -}; + 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; +} 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(float xpos, float ypos) -{ - return tex2D(RGBSampler, float2(xpos, ypos)).rgb; -} - -half3 getLine(float ypos, float3 xpos1, float3 xpos2, half3 linetaps1, half3 linetaps2) +inline 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; + 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 CONVOLUTION6x6(VS_OUTPUT In) +float4 CONVOLUTION6x6(VS_OUTPUT In) : SV_TARGET { - PS_OUTPUT OUT; - float2 pos = In.TextureUV + g_StepXY * 0.5; float2 f = frac(pos / g_StepXY); @@ -108,24 +106,22 @@ PS_OUTPUT CONVOLUTION6x6(VS_OUTPUT In) 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; + float3 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; - OUT.RGBColor.a = 1.0; - return OUT; + return float4(rgb, 1.0f); } -technique SCALER_T +technique10 SCALER_T { pass P0 { - PixelShader = compile ps_3_0 CONVOLUTION6x6(); - ZEnable = False; - FillMode = Solid; - FogEnable = False; + SetVertexShader( CompileShader( vs_4_0_level_9_3, VS() ) ); + SetPixelShader( CompileShader( ps_4_0_level_9_3, CONVOLUTION6x6() ) ); } }; |