-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathPS_Zoom Blur.hlsl
54 lines (40 loc) · 1.24 KB
/
PS_Zoom Blur.hlsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
sampler s0 : register(s0);
float4 p0 : register(c0);
float4 p1 : register(c1);
#define width (p0[0])
#define height (p0[1])
#define counter (p0[2])
#define clock (p0[3])
#define one_over_width (p1[0])
#define one_over_height (p1[1])
#define PI acos(-1)
float4 main(float2 tex : TEXCOORD0) : COLOR
{
float4 c0 = tex2D(s0, tex);
float xTrans = (tex.x*2)-1;
float yTrans = 1-(tex.y*2);
float angle = atan(yTrans/xTrans) + PI;
if (sign(xTrans) == 1) {
angle+= PI;
}
float radius = sqrt(pow(xTrans,2) + pow(yTrans,2));
float2 currentCoord;
float4 accumulatedColor = {0,0,0,0};
float4 currentColor = tex2D(s0, currentCoord);
accumulatedColor = currentColor;
int samples = 64;
float magnitude = 0.5;
accumulatedColor = c0/samples;
for(int i = 1; i< samples; i++) {
float currentRadius ;
// Distance to center dependent
currentRadius = max(0,radius - (radius/1000 * i));
// Continuous;
// currentRadius = max(0,radius - (0.0004 * i));
currentCoord.x = (currentRadius * cos(angle)+1.0)/2.0;
currentCoord.y = -1* ((currentRadius * sin(angle)-1.0)/2.0);
float4 currentColor = tex2D(s0, currentCoord);
accumulatedColor += currentColor/samples;
}
return accumulatedColor;
}