Debian Codegraph @

Data/Sys/Shaders/nightvision2.glsl

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