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 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'assets/shaders/Pulse.frag.glsl') 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); -- cgit v1.2.3