diff options
author | hwc487 | 2012-05-17 15:15:43 -0700 |
---|---|---|
committer | hwc487 | 2012-05-17 15:15:43 -0700 |
commit | dc92188fef67d7a2032173d7746fbc16a951a366 (patch) | |
tree | b542107966cd76d2c299cb39759840e395afe39e /assets/shaders | |
parent | 0a3c703ce285941da20167a6d04b13b7eced23be (diff) | |
download | ninja-dc92188fef67d7a2032173d7746fbc16a951a366.tar.gz |
Exposing parameters for pulse and plasma materials
Diffstat (limited to 'assets/shaders')
-rw-r--r-- | assets/shaders/Pulse.frag.glsl | 12 | ||||
-rw-r--r-- | assets/shaders/plasma.frag.glsl | 16 |
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; | |||
6 | uniform vec2 u_resolution; | 6 | uniform vec2 u_resolution; |
7 | uniform sampler2D u_tex0; | 7 | uniform sampler2D u_tex0; |
8 | 8 | ||
9 | uniform float u_speed; | ||
10 | uniform float u_xscale; | ||
11 | uniform float u_yscale; | ||
12 | |||
9 | void main(void) | 13 | void 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 | ||
17 | varying vec2 v_uv; | 17 | varying vec2 v_uv; |
18 | uniform float u_time; | 18 | uniform float u_time; |
19 | uniform vec4 color; | 19 | |
20 | uniform float u_wave; | ||
21 | uniform float u_wave1; | ||
22 | uniform float u_wave2; | ||
23 | uniform float u_speed; | ||
20 | 24 | ||
21 | void main(void) | 25 | void 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 | } |