ProjectArcade
71 строка · 2.3 Кб
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 and apply horizontal scanlines
25// This would have been much simpler if I could get the stupid modulo (%) to work
26// If anyone who is more well versed in Cg knows how to do this it'd be slightly more efficient
27// float lineIntensity = ((GetCoordinates()[1] % 9) - 4) / 40;
28float vPos = GetCoordinates().y*GetResolution().y / 9.0;
29float lineIntensity = (((vPos - floor(vPos)) * 9.0) - 4.0) / 40.0;
30grey = grey * 0.5 + 0.7 + lineIntensity;
31
32// darken edges
33float x = GetCoordinates().x * GetResolution().x;
34float y = GetCoordinates().y * GetResolution().y;
35
36if (x > internalresolution/2.0)
37x = internalresolution-x;
38
39if (y > internalresolution/2.0)
40y = internalresolution-y;
41
42if (x > internalresolution/2.0*0.95)
43x = internalresolution/2.0*0.95;
44
45if (y > internalresolution/2.0*0.95)
46y = internalresolution/2.0*0.95;
47
48x = -x + 641.0;
49y = -y + 641.0;
50
51//****inline square root routines*****/
52// bit of a performance bottleneck.
53// neccessary to make the darkened area rounded
54// instead of rhombus-shaped.
55float sqrt = x / 10.0;
56while ((sqrt*sqrt) < x)
57sqrt+=0.1;
58x = sqrt;
59sqrt = y / 10.0;
60while ((sqrt*sqrt) < y)
61sqrt+=0.1;
62y = sqrt;
63
64x *= 2.0;
65y *= 2.0;
66grey -= x / 200.0;
67grey -= y / 200.0;
68
69// output
70SetOutput(float4(0.0, grey, 0.0, 1.0));
71}
72