Danbias/Code/OysterGraphics/Shader/Passes/Blur/BlurHor.hlsl

33 lines
862 B
HLSL
Raw Normal View History

2014-02-07 13:46:55 +01:00
#include "BlurSharedData.hlsli"
[numthreads(N,1,1)]
void main(int3 ThreadID : SV_DispatchThreadID, int3 gThreadID : SV_GroupThreadID)
{
if(gThreadID.x < blurRadius)
{
int x = max(ThreadID.x-blurRadius,0);
2014-02-13 15:24:19 +01:00
gCache[gThreadID.x] = inTex[min(int2(x,ThreadID.y) + Start, Stop-1)];
2014-02-07 13:46:55 +01:00
}
if(gThreadID.x >= N-blurRadius)
{
2014-02-13 15:24:19 +01:00
int x = min(ThreadID.x+blurRadius,Stop.x-1);
gCache[gThreadID.x+2*blurRadius] = inTex[int2(x,ThreadID.y) + Start];
2014-02-07 13:46:55 +01:00
}
2014-02-13 15:24:19 +01:00
gCache[gThreadID.x+blurRadius] = inTex[min(ThreadID.xy + Start, Stop-1)];
2014-02-07 13:46:55 +01:00
GroupMemoryBarrierWithGroupSync();
float4 blurCol = float4(0,0,0,0);
[unroll]
for(int i = -blurRadius; i <= blurRadius;++i)
{
int k = gThreadID.x + blurRadius + i;
blurCol +=Weights[i + blurRadius] * gCache[k];
}
2014-02-13 15:24:19 +01:00
outTex[ThreadID.xy + Start] = blurCol * BlurMask + inTex[ThreadID.xy + Start] * ( float4(1,1,1,1) - BlurMask);
2014-02-07 13:46:55 +01:00
}