From dc92188fef67d7a2032173d7746fbc16a951a366 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Thu, 17 May 2012 15:15:43 -0700 Subject: Exposing parameters for pulse and plasma materials --- assets/shaders/Pulse.frag.glsl | 12 +++++++++--- assets/shaders/plasma.frag.glsl | 16 +++++++++++----- 2 files changed, 20 insertions(+), 8 deletions(-) (limited to 'assets/shaders') 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; uniform vec2 u_resolution; uniform sampler2D u_tex0; +uniform float u_speed; +uniform float u_xscale; +uniform float u_yscale; + void main(void) { vec2 halfres = u_resolution.xy/2.0; vec2 cPos = gl_FragCoord.xy; - cPos.x -= 0.5*halfres.x*sin(u_time/2.0)+0.3*halfres.x*cos(u_time)+halfres.x; - cPos.y -= 0.4*halfres.y*sin(u_time/5.0)+0.3*halfres.y*cos(u_time)+halfres.y; + float time = u_time * u_speed; + + cPos.x -= u_xscale*halfres.x*sin(time/2.0)+0.3*halfres.x*cos(time)+halfres.x; + cPos.y -= u_yscale*halfres.y*sin(time/5.0)+0.3*halfres.y*cos(time)+halfres.y; float cLength = length(cPos); - vec2 uv = gl_FragCoord.xy/u_resolution.xy+(cPos/cLength)*sin(cLength/30.0-u_time*10.0)/25.0; + vec2 uv = gl_FragCoord.xy/u_resolution.xy+(cPos/cLength)*sin(cLength/30.0-time*10.0)/25.0; vec3 col = texture2D(u_tex0,uv).xyz*50.0/cLength; 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; varying vec2 v_uv; uniform float u_time; -uniform vec4 color; + +uniform float u_wave; +uniform float u_wave1; +uniform float u_wave2; +uniform float u_speed; void main(void) { float x = v_uv.x ; float y = v_uv.y ; - float time = u_time; - float wave = (cos(time + y / 0.2 + cos(x / 0.3 + cos((y / 0.1))))); - float wave1 = (sin(abs(wave + y/0.6))); - float wave2 = (sin(abs(wave1 + y/0.8))); + float time = u_time*u_speed; + + float wave = (cos(time + y / (u_wave+0.2) + cos(x / (u_wave+0.3) + cos((y / (u_wave+0.1)))))); + float wave1 = (sin(abs(wave + y/u_wave1))); + float wave2 = (sin(abs(wave1 + y/u_wave2))); + gl_FragColor = vec4( abs(vec3(wave2,wave1,wave)),1.0); } -- cgit v1.2.3