aboutsummaryrefslogtreecommitdiff
path: root/assets/shaders
diff options
context:
space:
mode:
authorhwc4872012-05-17 15:15:43 -0700
committerhwc4872012-05-17 15:15:43 -0700
commitdc92188fef67d7a2032173d7746fbc16a951a366 (patch)
treeb542107966cd76d2c299cb39759840e395afe39e /assets/shaders
parent0a3c703ce285941da20167a6d04b13b7eced23be (diff)
downloadninja-dc92188fef67d7a2032173d7746fbc16a951a366.tar.gz
Exposing parameters for pulse and plasma materials
Diffstat (limited to 'assets/shaders')
-rw-r--r--assets/shaders/Pulse.frag.glsl12
-rw-r--r--assets/shaders/plasma.frag.glsl16
2 files changed, 20 insertions, 8 deletions
diff --git a/assets/shaders/Pulse.frag.glsl b/assets/shaders/Pulse.frag.glsl
index b24c9bef..9aeb05c9 100644
--- a/assets/shaders/Pulse.frag.glsl
+++ b/assets/shaders/Pulse.frag.glsl
@@ -6,16 +6,22 @@ uniform float u_time;
6uniform vec2 u_resolution; 6uniform vec2 u_resolution;
7uniform sampler2D u_tex0; 7uniform sampler2D u_tex0;
8 8
9uniform float u_speed;
10uniform float u_xscale;
11uniform float u_yscale;
12
9void main(void) 13void main(void)
10{ 14{
11 vec2 halfres = u_resolution.xy/2.0; 15 vec2 halfres = u_resolution.xy/2.0;
12 vec2 cPos = gl_FragCoord.xy; 16 vec2 cPos = gl_FragCoord.xy;
13 17
14 cPos.x -= 0.5*halfres.x*sin(u_time/2.0)+0.3*halfres.x*cos(u_time)+halfres.x; 18 float time = u_time * u_speed;
15 cPos.y -= 0.4*halfres.y*sin(u_time/5.0)+0.3*halfres.y*cos(u_time)+halfres.y; 19
20 cPos.x -= u_xscale*halfres.x*sin(time/2.0)+0.3*halfres.x*cos(time)+halfres.x;
21 cPos.y -= u_yscale*halfres.y*sin(time/5.0)+0.3*halfres.y*cos(time)+halfres.y;
16 float cLength = length(cPos); 22 float cLength = length(cPos);
17 23
18 vec2 uv = gl_FragCoord.xy/u_resolution.xy+(cPos/cLength)*sin(cLength/30.0-u_time*10.0)/25.0; 24 vec2 uv = gl_FragCoord.xy/u_resolution.xy+(cPos/cLength)*sin(cLength/30.0-time*10.0)/25.0;
19 vec3 col = texture2D(u_tex0,uv).xyz*50.0/cLength; 25 vec3 col = texture2D(u_tex0,uv).xyz*50.0/cLength;
20 26
21 gl_FragColor = vec4(col,1.0); 27 gl_FragColor = vec4(col,1.0);
diff --git a/assets/shaders/plasma.frag.glsl b/assets/shaders/plasma.frag.glsl
index 248288a6..4a5ac3da 100644
--- a/assets/shaders/plasma.frag.glsl
+++ b/assets/shaders/plasma.frag.glsl
@@ -16,15 +16,21 @@ precision highp float;
16 16
17varying vec2 v_uv; 17varying vec2 v_uv;
18uniform float u_time; 18uniform float u_time;
19uniform vec4 color; 19
20uniform float u_wave;
21uniform float u_wave1;
22uniform float u_wave2;
23uniform float u_speed;
20 24
21void main(void) 25void main(void)
22{ 26{
23 float x = v_uv.x ; 27 float x = v_uv.x ;
24 float y = v_uv.y ; 28 float y = v_uv.y ;
25 float time = u_time; 29 float time = u_time*u_speed;
26 float wave = (cos(time + y / 0.2 + cos(x / 0.3 + cos((y / 0.1))))); 30
27 float wave1 = (sin(abs(wave + y/0.6))); 31 float wave = (cos(time + y / (u_wave+0.2) + cos(x / (u_wave+0.3) + cos((y / (u_wave+0.1))))));
28 float wave2 = (sin(abs(wave1 + y/0.8))); 32 float wave1 = (sin(abs(wave + y/u_wave1)));
33 float wave2 = (sin(abs(wave1 + y/u_wave2)));
34
29 gl_FragColor = vec4( abs(vec3(wave2,wave1,wave)),1.0); 35 gl_FragColor = vec4( abs(vec3(wave2,wave1,wave)),1.0);
30} 36}