-
Notifications
You must be signed in to change notification settings - Fork 0
/
galaxy-v1
83 lines (56 loc) · 1.91 KB
/
galaxy-v1
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#extension GL_OES_standard_derivatives : enable
//
// GALAXY - ENGINE
// Created by: atlas256
// Hello, from Ukraine
//
precision highp float;
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
uniform sampler2D backbuffer;
vec3 color = vec3(0.0);
void main( void ) {
vec2 uv = (gl_FragCoord.xy - resolution.xy*0.5) / resolution.y;
vec2 pix = gl_FragCoord.xy;
vec2 mouse = mouse * resolution;
color = texture2D(backbuffer, (pix.xy+vec2( 0.0, 0.0)) / resolution.xy).rgb;
vec3 sides[9];
sides[0] = texture2D(backbuffer, (pix.xy+vec2( 0.0, 0.0)) / resolution.xy).rgb;
sides[1] = texture2D(backbuffer, (pix.xy+vec2( 0.0, -1.0)) / resolution.xy).rgb;
sides[2] = texture2D(backbuffer, (pix.xy+vec2( 1.0, -1.0)) / resolution.xy).rgb;
sides[3] = texture2D(backbuffer, (pix.xy+vec2( 1.0, 0.0)) / resolution.xy).rgb;
sides[4] = texture2D(backbuffer, (pix.xy+vec2( 1.0, 1.0)) / resolution.xy).rgb;
sides[5] = texture2D(backbuffer, (pix.xy+vec2( 0.0, 1.0)) / resolution.xy).rgb;
sides[6] = texture2D(backbuffer, (pix.xy+vec2(-1.0, 1.0)) / resolution.xy).rgb;
sides[7] = texture2D(backbuffer, (pix.xy+vec2(-1.0, 0.0)) / resolution.xy).rgb;
sides[8] = texture2D(backbuffer, (pix.xy+vec2(-1.0, -1.0)) / resolution.xy).rgb;
vec3 mass = vec3(0.0);
for (int i = 0; i < 9; i++) {
mass.r += sides[i].r / 9.0;
mass.g += sides[i].g / 9.0;
mass.b += sides[i].b / 9.0;
};
color.r = mass.r;
color.g = mass.g;
color.b = mass.b;
if (mass.r == 1.0 / 9.0) {
color.g = 1.0;
} else {
color.r -= 1.0 / 1000.0;
}
if (mass.g == 1.0 / 9.0) {
color.b = 1.0;
} else {
color.g -= 1.0 / 1000.0;
}
if (mass.b == 1.0 / 9.0) {
color.r = 1.0;
} else {
color.b -= 1.0 / 1000.0;
}
float v = distance(mouse, gl_FragCoord.xy);
if(v < 10.0)color = vec3(sin(time), -sin(time), cos(time));
if (mouse.x < 1.0)color = vec3(0.0);
gl_FragColor = vec4(color, 1.0);
}