From 6321075d93044c6747682a8e7280b5996da7ec52 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Thu, 2 Feb 2012 11:57:58 -0800 Subject: added some additional shaders --- assets/shaders/Deform.frag.glsl | 29 ++++++++++++++++++ assets/shaders/Fly.frag.glsl | 23 +++++++++++++++ assets/shaders/ReliefTunnel.frag.glsl | 35 ++++++++++++++++++++++ assets/shaders/SquareTunnel.frag.glsl | 21 +++++++++++++ assets/shaders/Star.frag.glsl | 28 ++++++++++++++++++ assets/shaders/Water.frag.glsl | 55 +++++++++++++++++++++++++++++++++++ assets/shaders/ZInvert.frag.glsl | 23 +++++++++++++++ 7 files changed, 214 insertions(+) create mode 100644 assets/shaders/Deform.frag.glsl create mode 100644 assets/shaders/Fly.frag.glsl create mode 100644 assets/shaders/ReliefTunnel.frag.glsl create mode 100644 assets/shaders/SquareTunnel.frag.glsl create mode 100644 assets/shaders/Star.frag.glsl create mode 100644 assets/shaders/Water.frag.glsl create mode 100644 assets/shaders/ZInvert.frag.glsl (limited to 'assets/shaders') diff --git a/assets/shaders/Deform.frag.glsl b/assets/shaders/Deform.frag.glsl new file mode 100644 index 00000000..1dbe45a0 --- /dev/null +++ b/assets/shaders/Deform.frag.glsl @@ -0,0 +1,29 @@ +#ifdef GL_ES +precision highp float; +#endif + +uniform float u_time; +uniform vec2 u_resolution; +//uniform vec4 mouse; +uniform sampler2D u_tex0; + +void main(void) +{ + vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; + //vec2 m = -1.0 + 2.0 * mouse.xy / u_resolution.xy; + vec2 m = vec2(-.8, .8); + + float a1 = atan(p.y-m.y,p.x-m.x); + float r1 = sqrt(dot(p-m,p-m)); + float a2 = atan(p.y+m.y,p.x+m.x); + float r2 = sqrt(dot(p+m,p+m)); + + vec2 uv; + uv.x = 0.2*u_time + (r1-r2)*0.25; + uv.y = sin(2.0*(a1-a2)); + + float w = r1*r2*0.8; + vec3 col = texture2D(u_tex0,uv).xyz; + + gl_FragColor = vec4(col/(.1+w),1.0); +} \ No newline at end of file diff --git a/assets/shaders/Fly.frag.glsl b/assets/shaders/Fly.frag.glsl new file mode 100644 index 00000000..f99b5ab8 --- /dev/null +++ b/assets/shaders/Fly.frag.glsl @@ -0,0 +1,23 @@ +#ifdef GL_ES +precision highp float; +#endif + +uniform vec2 u_resolution; +uniform float u_time; +uniform sampler2D u_tex0; + +void main(void) +{ + vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; + vec2 uv; + + float an = u_time*.25; + + float x = p.x*cos(an)-p.y*sin(an); + float y = p.x*sin(an)+p.y*cos(an); + + uv.x = .25*x/abs(y); + uv.y = .20*u_time + .25/abs(y); + + gl_FragColor = vec4(texture2D(u_tex0,uv).xyz * y*y, 1.0); +} diff --git a/assets/shaders/ReliefTunnel.frag.glsl b/assets/shaders/ReliefTunnel.frag.glsl new file mode 100644 index 00000000..cee707db --- /dev/null +++ b/assets/shaders/ReliefTunnel.frag.glsl @@ -0,0 +1,35 @@ +#ifdef GL_ES +precision highp float; +#endif + +uniform vec2 u_resolution; +uniform float u_time; +uniform sampler2D u_tex0; + +void main(void) +{ + vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; + vec2 uv; + + float r = sqrt( dot(p,p) ); + float a = atan(p.y,p.x) + 0.5*sin(0.5*r-0.5*u_time); + + float s = 0.5 + 0.5*cos(7.0*a); + s = smoothstep(0.0,1.0,s); + s = smoothstep(0.0,1.0,s); + s = smoothstep(0.0,1.0,s); + s = smoothstep(0.0,1.0,s); + + uv.x = u_time + 1.0/( r + .2*s); + uv.y = 3.0*a/3.1416; + + float w = (0.5 + 0.5*s)*r*r; + + vec3 col = texture2D(u_tex0,uv).xyz; + + float ao = 0.5 + 0.5*cos(7.0*a); + ao = smoothstep(0.0,0.4,ao)-smoothstep(0.4,0.7,ao); + ao = 1.0-0.5*ao*r; + + gl_FragColor = vec4(col*w*ao,1.0); +} diff --git a/assets/shaders/SquareTunnel.frag.glsl b/assets/shaders/SquareTunnel.frag.glsl new file mode 100644 index 00000000..51ef7b7c --- /dev/null +++ b/assets/shaders/SquareTunnel.frag.glsl @@ -0,0 +1,21 @@ +#ifdef GL_ES +precision highp float; +#endif + +uniform vec2 u_resolution; +uniform float u_time; +uniform sampler2D u_tex0; + +void main(void) +{ + vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; + vec2 uv; + + float r = pow( pow(p.x*p.x,16.0) + pow(p.y*p.y,16.0), 1.0/32.0 ); + uv.x = .5*u_time + 0.5/r; + uv.y = 1.0*atan(p.y,p.x)/3.1416; + + vec3 col = texture2D(u_tex0,uv).xyz; + + gl_FragColor = vec4(col*r*r*r,1.0); +} diff --git a/assets/shaders/Star.frag.glsl b/assets/shaders/Star.frag.glsl new file mode 100644 index 00000000..f63fe605 --- /dev/null +++ b/assets/shaders/Star.frag.glsl @@ -0,0 +1,28 @@ +#ifdef GL_ES +precision highp float; +#endif + +uniform float u_time; +uniform vec2 u_resolution; +uniform sampler2D u_tex0; + +void main(void) +{ + vec2 uv; + + vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; + float a = atan(p.y,p.x); + float r = sqrt(dot(p,p)); + float s = r * (1.0+0.8*cos(u_time*1.0)); + + uv.x = .02*p.y+.03*cos(-u_time+a*3.0)/s; + uv.y = .1*u_time +.02*p.x+.03*sin(-u_time+a*3.0)/s; + + float w = .9 + pow(max(1.5-r,0.0),4.0); + + w*=0.6+0.4*cos(u_time+3.0*a); + + vec3 col = texture2D(u_tex0,uv).xyz; + + gl_FragColor = vec4(col*w,1.0); +} \ No newline at end of file diff --git a/assets/shaders/Water.frag.glsl b/assets/shaders/Water.frag.glsl new file mode 100644 index 00000000..5b71a658 --- /dev/null +++ b/assets/shaders/Water.frag.glsl @@ -0,0 +1,55 @@ +#ifdef GL_ES +precision highp float; +#endif + +uniform sampler2D u_tex0; +uniform float u_time; +uniform vec2 u_resolution; + +const float speedx = 1./ 0.1; +const float speedy = 1./ .01; +const float speedr = 1./ 0.01; +const float delta = 20.; +const float intence = 10.; +const int dif = 7; + +float col(vec2 coord) +{ + float delta_theta = 3.1415926535897932 / float(dif); + float col = 0.; + float theta = 0.; + theta = u_time/200.; + + coord.x += u_time/speedx; + coord.y += u_time/speedy; + for (int i = 0; i < dif; i++) + { + coord.x += u_time/speedr; + theta = theta + delta_theta; + col = col + cos( (coord.x*cos(theta) - coord.y*sin(theta))*20. ); + } + + return cos(col); +} + +void main(void) +{ + vec2 p = (gl_FragCoord.xy) / u_resolution.xy; + + vec2 c1 = p; + vec2 c2 = p; + + c2.x = c2.x+u_resolution.x/delta; + float dx = (col(c1)-col(c2))/delta; + + c2 = p; + c2.y = c2.y + u_resolution.y/delta; + float dy = (col(c1)-col(c2))/delta; + + c1.x = c1.x+dx; + c1.y = -(c1.y+dy); + + float alpha = 1.+dot(dx,dy)*intence; + if (alpha < 0.7) alpha = 0.7; + gl_FragColor = texture2D(u_tex0,c1)*(alpha); +} diff --git a/assets/shaders/ZInvert.frag.glsl b/assets/shaders/ZInvert.frag.glsl new file mode 100644 index 00000000..b1fd1748 --- /dev/null +++ b/assets/shaders/ZInvert.frag.glsl @@ -0,0 +1,23 @@ +#ifdef GL_ES +precision highp float; +#endif + +uniform vec2 u_resolution; +uniform float u_time; +uniform sampler2D u_tex0; + +void main(void) +{ + vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; + vec2 uv; + + float a = atan(p.y,p.x); + float r = sqrt(dot(p,p)); + + uv.x = cos(0.6+u_time) + cos(cos(1.2+u_time)+a)/r; + uv.y = cos(0.3+u_time) + sin(cos(2.0+u_time)+a)/r; + + vec3 col = texture2D(u_tex0,uv*.25).xyz; + + gl_FragColor = vec4(col*r*r,1.0); +} \ No newline at end of file -- cgit v1.2.3