aboutsummaryrefslogtreecommitdiff
path: root/data/shaders/swirlytron.frag
blob: 7d8aaecacecee833ef3efe705a68a7718ae1526f (plain)
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
/*
 * swirlytron.frag
 *
 * Swirly stuff for rendering onto swirly things...
 *
 * (c) 2007-2008 Thomas White <taw27@cam.ac.uk>
 *
 *  thrust3d - a silly game
 *
 */

varying vec2 coords;
varying vec2 incoords;
uniform float time;
uniform float rrb;		/* Recharge ripple brightness */
uniform bool rechargeripple;

void main() {
	
	vec3 colour;
	
	colour.r = 0.0;
	colour.g = 0.0;
	colour.b = 0.5*max(0.0, cos(2*3.141*coords.x-(time/250.0))) + 0.5*max(0.0, cos(2*3.141*coords.y-(time/250.0)));

	if ( rechargeripple ) {
		
		const float f = 1.0;
		float r;
		
		r = pow(abs(incoords.x), 2.0) + pow(abs(incoords.y), 2.0);
		
		colour.r += rrb * 0.8 * cos(2*f*3.141*r + (time/250.0) );
		colour.g += rrb * 0.3 * cos(2*f*3.141*r + (time/250.0) );
		colour.b += rrb * 0.1;
		
	}
	
	gl_FragColor = vec4(colour.r, colour.g, colour.b, 1.0);
	
}