This repository has been archived by the owner on Feb 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathPS_Edges.hlsl
60 lines (47 loc) · 1.73 KB
/
PS_Edges.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
55
56
57
58
59
60
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)
#define angleSteps 9
#define radiusSteps 31
#define totalSteps (radiusSteps * angleSteps)
//#define angleOffset ((30.0* PI * 2)/360.0)
#define ampFactor 4.0
#define minRadius (0.0/width)
#define maxRadius (100.0/width)
#define angleDelta ((2 * PI) / angleSteps)
#define radiusDelta ((maxRadius - minRadius) / radiusSteps)
float4 main(float2 tex : TEXCOORD0) : COLOR
{
float angleOffset = PI * 2;
// angleOffset *= clock;
float4 c0 = tex2D(s0, tex);
float4 origColor = tex2D(s0, tex);
float4 accumulatedColor = {0,0,0,0};
for (int radiusStep = 0; radiusStep < radiusSteps; radiusStep++) {
float radius = minRadius + radiusStep * radiusDelta;
for (float angle=0; angle <(2*PI); angle += angleDelta) {
float modAngle = angle + angleOffset;
if (modAngle > 2*PI) { modAngle -= 2*PI; }
float2 currentCoord;
float xDiff = radius * cos(modAngle);
float yDiff = radius * sin(modAngle);
currentCoord = tex + float2(xDiff, yDiff);
float4 currentColor = tex2D(s0, currentCoord);
float4 colorDiff = abs(c0 - currentColor);
float currentFraction = ((float)(radiusSteps+1 - radiusStep)) / (radiusSteps+1);
accumulatedColor += currentFraction * colorDiff / totalSteps;
}
}
accumulatedColor *= ampFactor;
return accumulatedColor; // Traditional edge style;
return 1.0*c0+accumulatedColor; // Smoother style;
return c0+accumulatedColor; // Angel style;
return c0-accumulatedColor; // Cell shaded style
}