ProjectArcade
62 строки · 1.9 Кб
1void main()
2{
3//variables
4float internalresolution = 1278.0;
5float4 c0 = Sample();
6
7//blur
8float4 blurtotal = float4(0.0, 0.0, 0.0, 0.0);
9float blursize = 1.5;
10blurtotal += SampleLocation(GetCoordinates() + float2(-blursize, -blursize) * GetInvResolution());
11blurtotal += SampleLocation(GetCoordinates() + float2(-blursize, blursize) * GetInvResolution());
12blurtotal += SampleLocation(GetCoordinates() + float2( blursize, -blursize) * GetInvResolution());
13blurtotal += SampleLocation(GetCoordinates() + float2( blursize, blursize) * GetInvResolution());
14blurtotal += SampleLocation(GetCoordinates() + float2(-blursize, 0.0) * GetInvResolution());
15blurtotal += SampleLocation(GetCoordinates() + float2( blursize, 0.0) * GetInvResolution());
16blurtotal += SampleLocation(GetCoordinates() + float2( 0.0, -blursize) * GetInvResolution());
17blurtotal += SampleLocation(GetCoordinates() + float2( 0.0, blursize) * GetInvResolution());
18blurtotal *= 0.125;
19c0 = blurtotal;
20
21//greyscale
22float grey = ((0.3 * c0.r) + (0.4 * c0.g) + (0.3 * c0.b));
23
24// brighten
25grey = grey * 0.5 + 0.7;
26
27// darken edges
28float x = GetCoordinates().x * GetResolution().x;
29float y = GetCoordinates().y * GetResolution().y;
30if (x > internalresolution/2.0)
31x = internalresolution-x;
32if (y > internalresolution/2.0)
33y = internalresolution-y;
34if (x > internalresolution/2.0*0.95)
35x = internalresolution/2.0*0.95;
36if (y > internalresolution/2.0*0.95)
37y = internalresolution/2.0*0.95;
38x = -x+641.0;
39y = -y+641.0;
40
41/*****inline square root routines*****/
42// bit of a performance bottleneck.
43// neccessary to make the darkened area rounded
44// instead of rhombus-shaped.
45float sqrt = x / 10.0;
46
47while ((sqrt*sqrt) < x)
48sqrt+=0.1;
49x = sqrt;
50sqrt = y / 10.0;
51while ((sqrt*sqrt) < y)
52sqrt+=0.1;
53y = sqrt;
54
55x *= 2.0;
56y *= 2.0;
57grey -= x / 200.0;
58grey -= y / 200.0;
59
60// output
61SetOutput(float4(0.0, grey, 0.0, 1.0));
62}
63