From d5b216d9d6d2b8cb93106e8f8ca351089d05b41d Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 22 Feb 2012 11:52:31 -0800 Subject: Integrating canvas-2d and WebGL drawing fixes. Also adding back WebGL materials. Signed-off-by: Nivesh Rajbhandari --- assets/shaders/Deform.frag.glsl | 29 ++++++++ assets/shaders/Flag.vert.glsl | 35 ++++++++++ assets/shaders/Fly.frag.glsl | 23 +++++++ assets/shaders/Julia.frag.glsl | 25 +++++++ assets/shaders/Keleidoscope.frag.glsl | 25 +++++++ assets/shaders/Mandel.frag.glsl | 55 +++++++++++++++ assets/shaders/Pulse.frag.glsl | 22 ++++++ assets/shaders/ReliefTunnel.frag.glsl | 35 ++++++++++ assets/shaders/SquareTunnel.frag.glsl | 21 ++++++ assets/shaders/Star.frag.glsl | 28 ++++++++ assets/shaders/Taper.frag.glsl | 17 +++++ assets/shaders/Taper.vert.glsl | 122 ++++++++++++++++++++++++++++++++++ assets/shaders/Tunnel.frag.glsl | 23 +++++++ assets/shaders/Twist.frag.glsl | 23 +++++++ assets/shaders/TwistVert.frag.glsl | 32 +++++++++ assets/shaders/TwistVert.vert.glsl | 97 +++++++++++++++++++++++++++ assets/shaders/Water.frag.glsl | 55 +++++++++++++++ assets/shaders/Water2.frag.glsl | 66 ++++++++++++++++++ assets/shaders/ZInvert.frag.glsl | 23 +++++++ assets/shaders/plasma.frag.glsl | 32 +++++++++ assets/shaders/plasma.vert.glsl | 42 ++++++++++++ assets/shaders/radialBlur.frag.glsl | 47 +++++++++++++ 22 files changed, 877 insertions(+) create mode 100644 assets/shaders/Deform.frag.glsl create mode 100644 assets/shaders/Flag.vert.glsl create mode 100644 assets/shaders/Fly.frag.glsl create mode 100644 assets/shaders/Julia.frag.glsl create mode 100644 assets/shaders/Keleidoscope.frag.glsl create mode 100644 assets/shaders/Mandel.frag.glsl create mode 100644 assets/shaders/Pulse.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/Taper.frag.glsl create mode 100644 assets/shaders/Taper.vert.glsl create mode 100644 assets/shaders/Tunnel.frag.glsl create mode 100644 assets/shaders/Twist.frag.glsl create mode 100644 assets/shaders/TwistVert.frag.glsl create mode 100644 assets/shaders/TwistVert.vert.glsl create mode 100644 assets/shaders/Water.frag.glsl create mode 100644 assets/shaders/Water2.frag.glsl create mode 100644 assets/shaders/ZInvert.frag.glsl create mode 100644 assets/shaders/plasma.frag.glsl create mode 100644 assets/shaders/plasma.vert.glsl create mode 100644 assets/shaders/radialBlur.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/Flag.vert.glsl b/assets/shaders/Flag.vert.glsl new file mode 100644 index 00000000..7dc932a7 --- /dev/null +++ b/assets/shaders/Flag.vert.glsl @@ -0,0 +1,35 @@ +/* +This file contains proprietary software owned by Motorola Mobility, Inc.
+No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ + + +#ifdef GL_ES +precision highp float; +#endif + + +// attributes +attribute vec3 a_pos; +attribute vec2 texcoord; + +// scalar uniforms +uniform float u_time; + +// matrix uniforms +uniform mat4 u_mvMatrix; +uniform mat4 u_projMatrix; +uniform mat4 u_worldMatrix; + +void main() +{ + float angle = (u_time%360)*2; + + a_pos.z = sin( a_pos.x + angle); + a_pos.z += sin( a_pos.y/2 + angle); + a_pos.z *= a_pos.x * 0.09; + gl_Position = u_projMatrix * u_mvMatrix * vec4(a_pos,1.0) ; + + gl_FragColor = v_color; +} 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/Julia.frag.glsl b/assets/shaders/Julia.frag.glsl new file mode 100644 index 00000000..68cda703 --- /dev/null +++ b/assets/shaders/Julia.frag.glsl @@ -0,0 +1,25 @@ +#ifdef GL_ES +precision highp float; +#endif + +uniform vec2 u_resolution; +uniform float u_time; + +void main(void) +{ + vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; + vec2 cc = vec2( cos(.25*u_time), sin(.25*u_time*1.423) ); + + float dmin = 1000.0; + vec2 z = p*vec2(1.33,1.0); + for( int i=0; i<64; i++ ) + { + z = cc + vec2( z.x*z.x - z.y*z.y, 2.0*z.x*z.y ); + float m2 = dot(z,z); + if( m2>100.0 ) break; + dmin=min(dmin,m2); + } + + float color = sqrt(sqrt(dmin))*0.7; + gl_FragColor = vec4(color,color,color,1.0); +} \ No newline at end of file diff --git a/assets/shaders/Keleidoscope.frag.glsl b/assets/shaders/Keleidoscope.frag.glsl new file mode 100644 index 00000000..7d1bdb17 --- /dev/null +++ b/assets/shaders/Keleidoscope.frag.glsl @@ -0,0 +1,25 @@ +#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 = 7.0*a/3.1416; + uv.y = -u_time+ sin(7.0*r+u_time) + .7*cos(u_time+7.0*a); + + float w = .5+.5*(sin(u_time+7.0*r)+ .7*cos(u_time+7.0*a)); + + vec3 col = texture2D(u_tex0,uv*.5).xyz; + + gl_FragColor = vec4(col*w,1.0); +} \ No newline at end of file diff --git a/assets/shaders/Mandel.frag.glsl b/assets/shaders/Mandel.frag.glsl new file mode 100644 index 00000000..6465899d --- /dev/null +++ b/assets/shaders/Mandel.frag.glsl @@ -0,0 +1,55 @@ +#ifdef GL_ES +precision highp float; +#endif + +uniform vec2 u_resolution; +uniform float u_time; + +void main(void) +{ + vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; + p.x *= u_resolution.x/u_resolution.y; + + float zoo = .62+.38*sin(.1*u_time); + float coa = cos( 0.1*(1.0-zoo)*u_time ); + float sia = sin( 0.1*(1.0-zoo)*u_time ); + zoo = pow( zoo,8.0); + vec2 xy = vec2( p.x*coa-p.y*sia, p.x*sia+p.y*coa); + vec2 cc = vec2(-.745,.186) + xy*zoo; + + vec2 z = vec2(0.0); + vec2 z2 = z*z; + float m2; + float co = 0.0; + + + // chrome/angelproject/nvidia/glslES don't seem to like to "break" a loop... + // so we have to rewrite it in another way +/* + for( int i=0; i<256; i++ ) + { + z = cc + vec2( z.x*z.x - z.y*z.y, 2.0*z.x*z.y ); + m2 = dot(z,z); + if( m2>1024.0 ) break; + co += 1.0; + } +*/ + + for( int i=0; i<256; i++ ) + { + if( m2<1024.0 ) + { + z = cc + vec2( z.x*z.x - z.y*z.y, 2.0*z.x*z.y ); + m2 = dot(z,z); + co += 1.0; + } + } + + co = co + 1.0 - log2(.5*log2(m2)); + + co = sqrt(co/256.0); + gl_FragColor = vec4( .5+.5*cos(6.2831*co+0.0), + .5+.5*cos(6.2831*co+0.4), + .5+.5*cos(6.2831*co+0.7), + 1.0 ); +} \ No newline at end of file diff --git a/assets/shaders/Pulse.frag.glsl b/assets/shaders/Pulse.frag.glsl new file mode 100644 index 00000000..b24c9bef --- /dev/null +++ b/assets/shaders/Pulse.frag.glsl @@ -0,0 +1,22 @@ +#ifdef GL_ES +precision highp float; +#endif + +uniform float u_time; +uniform vec2 u_resolution; +uniform sampler2D u_tex0; + +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 cLength = length(cPos); + + vec2 uv = gl_FragCoord.xy/u_resolution.xy+(cPos/cLength)*sin(cLength/30.0-u_time*10.0)/25.0; + vec3 col = texture2D(u_tex0,uv).xyz*50.0/cLength; + + gl_FragColor = vec4(col,1.0); +} \ No newline at end of file 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/Taper.frag.glsl b/assets/shaders/Taper.frag.glsl new file mode 100644 index 00000000..3a5766fb --- /dev/null +++ b/assets/shaders/Taper.frag.glsl @@ -0,0 +1,17 @@ +/* +This file contains proprietary software owned by Motorola Mobility, Inc.
+No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ + + +#ifdef GL_ES +precision highp float; +#endif + +//uniform vec4 color; +varying vec4 v_color; + +void main() { + gl_FragColor = v_color; +} diff --git a/assets/shaders/Taper.vert.glsl b/assets/shaders/Taper.vert.glsl new file mode 100644 index 00000000..30b73456 --- /dev/null +++ b/assets/shaders/Taper.vert.glsl @@ -0,0 +1,122 @@ +/* +This file contains proprietary software owned by Motorola Mobility, Inc.
+No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ + + +#ifdef GL_ES +precision highp float; +#endif + + +// attributes +attribute vec3 vert; +attribute vec3 normal; +attribute vec2 texcoord; + +// scalar uniforms +uniform float u_limit1; +uniform float u_limit2; +uniform float u_limit3; +uniform float u_taperAmount; +uniform float u_minVal; +uniform float u_maxVal; +uniform float u_center; + +uniform vec4 color; + + +// matrix uniforms +uniform mat4 u_mvMatrix; +uniform mat4 u_projMatrix; +uniform mat4 u_worldMatrix; + +varying vec4 v_color; + + + +float TaperAmount( float param ) +{ + // Bezier coordinates of the X coordinate. + // Adjust these to get tighter or looser + float tightness = 0.8; + + float x0, y0, x1, y1, x2, y2; + float t; + if (param < 0.5) + { + t = 2.0*param; + x0 = 0.0; y0 = 0.0; + x1 = tightness; y1 = 0.0; + x2 = 1.0; y2 = 0.5; + } + else + { + t = (param - 0.5)*2.0; + x0 = 0.0; y0 = 0.5; + x1 = 1.0 - tightness; y1 = 1.0; + x2 = 1.0; y2 = 1.0; + } + + float a = x0 - 2.0*x1 + x2; + float b = 2.0*(x1 - x0); + float c = x0 - t; + + float descr = sqrt( b*b - 4.0*a*c ); + float denom = 2.0*a; + float n1 = (-b + descr)/denom; + float n2 = (-b - descr)/denom; + if ((n1 >= 0.0) || (n1 <= 1.0)) t = n1; + else if ((n2 >= 0.0) || (n2 <= 1.0)) t = n2; + else + t = 0.0; + + float ya = y0 + t*(y1 - y0); + float yb = y1 + t*(y2 - y1); + float yc = ya + t*(yb - ya); + + return yc; +} + + +void main(void) +{ + vec3 pos = vert; + vec2 uv = texcoord; + + + float limit1 = u_limit1, + limit2 = u_limit2, + limit3 = u_limit2; + + v_color = vec4(texcoord.x, texcoord.y, 0, 1); + if ((uv.x > u_limit1) && (uv.x < u_limit3)) + { + float t; + if (uv.x < u_limit2) + { + t = (uv.x - u_limit1)/(u_limit2 - u_limit1); + } + else + { + t = 1.0 - (uv.x - u_limit2)/(u_limit3 - u_limit2); + } + t = TaperAmount( t ); + + float maxVal; + if (pos.y > u_center) + { + maxVal = u_maxVal; + } + else + { + maxVal = u_minVal; + } + + float yFrac = (pos.y - u_center)/(maxVal-u_center); + pos.y = pos.y - yFrac * (maxVal - u_center)*t*u_taperAmount; + } + + gl_Position = u_projMatrix * u_mvMatrix * vec4(pos,1.0) ; +} \ No newline at end of file diff --git a/assets/shaders/Tunnel.frag.glsl b/assets/shaders/Tunnel.frag.glsl new file mode 100644 index 00000000..9deb52fb --- /dev/null +++ b/assets/shaders/Tunnel.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 = .75*u_time+.1/r; + uv.y = a/3.1416; + + vec3 col = texture2D(u_tex0,uv).xyz; + + gl_FragColor = vec4(col*r,1.0); +} \ No newline at end of file diff --git a/assets/shaders/Twist.frag.glsl b/assets/shaders/Twist.frag.glsl new file mode 100644 index 00000000..b7477747 --- /dev/null +++ b/assets/shaders/Twist.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 = r - .25*u_time; + uv.y = cos(a*5.0 + 2.0*sin(u_time+7.0*r)) ; + + vec3 col = (.5+.5*uv.y)*texture2D(u_tex0,uv).xyz; + + gl_FragColor = vec4(col,1.0); +} \ No newline at end of file diff --git a/assets/shaders/TwistVert.frag.glsl b/assets/shaders/TwistVert.frag.glsl new file mode 100644 index 00000000..f8490615 --- /dev/null +++ b/assets/shaders/TwistVert.frag.glsl @@ -0,0 +1,32 @@ +/* +This file contains proprietary software owned by Motorola Mobility, Inc.
+No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ + + +#ifdef GL_ES +precision highp float; +#endif + +// texture sampler uniforms +uniform sampler2D u_tex0; +uniform sampler2D u_tex1; + +//uniform vec4 color; +//varying vec4 v_color; +varying float v_zNormal; +varying vec2 v_texcoord; + + +void main() +{ + vec3 col; + if (v_zNormal >= 0.0) + col = texture2D(u_tex0, v_texcoord).xyz; + else + col = texture2D(u_tex1, v_texcoord).xyz; + + gl_FragColor = vec4(col, 1.0); + //gl_FragColor = v_color; +} diff --git a/assets/shaders/TwistVert.vert.glsl b/assets/shaders/TwistVert.vert.glsl new file mode 100644 index 00000000..29cb30ea --- /dev/null +++ b/assets/shaders/TwistVert.vert.glsl @@ -0,0 +1,97 @@ +/* +This file contains proprietary software owned by Motorola Mobility, Inc.
+No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ + + +#ifdef GL_ES +precision highp float; +#endif + + +// attributes +attribute vec3 vert; +attribute vec3 normal; +attribute vec2 texcoord; + +// scalar uniforms +uniform float u_limit1; +uniform float u_limit2; +uniform float u_twistAmount; +uniform float u_center; + +// texture sampler uniforms +uniform sampler2D u_tex0; +uniform sampler2D u_tex1; + +uniform vec4 color; + + +// matrix uniforms +uniform mat4 u_mvMatrix; +uniform mat4 u_projMatrix; +uniform mat4 u_worldMatrix; + +//varying vec4 v_color; +varying float v_zNormal; +varying vec2 v_texcoord; + + +float GetAngle( float t ) +{ + float angle= 0.0; + if (t < u_limit2) + { + if (t < u_limit1) + { + angle = u_twistAmount; + } + else + { + angle = (t - u_limit2)/(u_limit1 - u_limit2)*u_twistAmount; + } + } + + return angle; +} + + +void main(void) +{ + vec3 pos = vert; + vec2 uv = texcoord; + v_texcoord = texcoord; + + //v_color = vec4(texcoord.x, texcoord.y, 0, 1); + + v_zNormal = 1.0; + if (uv.x < u_limit2) + { + float angle = GetAngle( uv.x ); + float cs = cos(angle), sn = sin(angle); + + pos.y -= u_center; + vec3 ctrPt = pos; + float y = pos.y*cs - pos.z*sn + u_center; + pos.z = pos.y*sn + pos.z*cs; + pos.y = y; + + // rotate the normal + mat3 rotMat = mat3( vec3( 1.0, 0.0, 0.0 ), vec3( 0.0, cs, sn ), vec3( 0.0, -sn, cs ) ); + vec3 pt0 = ctrPt, pt1 = vec3(ctrPt.x, ctrPt.y+1.0, ctrPt.z), pt2 = vec3( ctrPt.x+1.0, ctrPt.y, ctrPt.z); + pt0 = rotMat * pt0; pt1 = rotMat * pt1; + angle = GetAngle(1.0); + cs = cos(angle); sn = sin(angle); + rotMat = mat3( vec3( 1.0, 0.0, 0.0 ), vec3( 0.0, cs, sn ), vec3( 0.0, -sn, cs ) ); + pt2 = rotMat * pt2; + pt0.y += u_center; pt1.y += u_center; pt2.y += u_center; + //vec4 nrm = u_projMatrix * u_mvMatrix * vec4( cross(pt1-pt0, pt2-pt0), 1.0 ); + vec4 nrm = vec4( cross(pt1-pt0, pt2-pt0), 1.0 ); + + //v_zNormal = normal.y*sn + normal.z*cs; + v_zNormal = -nrm.z; + } + + gl_Position = u_projMatrix * u_mvMatrix * vec4(pos,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/Water2.frag.glsl b/assets/shaders/Water2.frag.glsl new file mode 100644 index 00000000..39b6aa55 --- /dev/null +++ b/assets/shaders/Water2.frag.glsl @@ -0,0 +1,66 @@ +#ifdef GL_ES +precision highp float; +#endif + +uniform sampler2D u_tex0; +uniform float u_time; +uniform vec2 u_resolution; +const float PI = 3.1415926535897932; + +//speed +const float speed = 0.2; +const float speed_x = 0.3; +const float speed_y = 0.3; + +// geometry +const float intensity = 3.; +const int steps = 8; +const float frequency = 4.0; +const int angle = 7; // better when a prime + +// reflection and emboss +const float delta = 20.; +const float intence = 400.; +const float emboss = 0.3; + +//---------- crystals effect + + float col(vec2 coord) + { + float delta_theta = 2.0 * PI / float(angle); + float col = 0.0; + float theta = 0.0; + for (int i = 0; i < steps; i++) + { + vec2 adjc = coord; + theta = delta_theta*float(i); + adjc.x += cos(theta)*u_time*speed + u_time * speed_x; + adjc.y -= sin(theta)*u_time*speed - u_time * speed_y; + col = col + cos( (adjc.x*cos(theta) - adjc.y*sin(theta))*frequency)*intensity; + } + + return cos(col); + } + +//---------- main + +void main(void) +{ +vec2 p = (gl_FragCoord.xy) / u_resolution.xy, c1 = p, c2 = p; +float cc1 = col(c1); + +c2.x += u_resolution.x/delta; +float dx = emboss*(cc1-col(c2))/delta; + +c2.x = p.x; +c2.y += u_resolution.y/delta; +float dy = emboss*(cc1-col(c2))/delta; + +c1.x += dx; +c1.y = -(c1.y+dy); + +float alpha = 1.+dot(dx,dy)*intence; +gl_FragColor = texture2D(u_tex0,c1)*(alpha); +// gl_FragColor = vec4(col(p),0,0,1); + +} 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 diff --git a/assets/shaders/plasma.frag.glsl b/assets/shaders/plasma.frag.glsl new file mode 100644 index 00000000..2ab8f49c --- /dev/null +++ b/assets/shaders/plasma.frag.glsl @@ -0,0 +1,32 @@ +// +// Fragment shader for procedural bricks +// +// Authors: Dave Baldwin, Steve Koren, Randi Rost +// based on a shader by Darwyn Peachey +// +// Copyright (c) 2002-2006 3Dlabs Inc. Ltd. +// +// See 3Dlabs-License.txt for license information +// + +#ifdef GL_ES +precision highp float; +#endif + + +varying vec2 v_uv; +uniform float u_time; +uniform vec4 color; + +void main(void) +{ + float x = v_uv.x ; + float y = v_uv.y ; + float time = color.x; + 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 tmp = u_time * 0.1; + gl_FragColor = vec4( abs(vec3(wave2,wave1,wave)),1.0); + //gl_FragColor = color; +} diff --git a/assets/shaders/plasma.vert.glsl b/assets/shaders/plasma.vert.glsl new file mode 100644 index 00000000..f817c143 --- /dev/null +++ b/assets/shaders/plasma.vert.glsl @@ -0,0 +1,42 @@ +// +// Vertex shader for procedural bricks +// +// Authors: Dave Baldwin, Steve Koren, Randi Rost +// based on a shader by Darwyn Peachey +// +// Copyright (c) 2002-2006 3Dlabs Inc. Ltd. +// +// See 3Dlabs-License.txt for license information +// + +//uniform vec3 LightPosition; + +#ifdef GL_ES +precision highp float; +#endif + + +// attributes +attribute vec3 vert; +attribute vec3 normal; +attribute vec2 texcoord; + +uniform mat4 u_shadowLightWorld; +uniform mat4 u_shadowBiasMatrix; +uniform mat4 u_vShadowLight; +uniform vec3 u_lightPos; + +// matrix uniforms +uniform mat4 u_mvMatrix; +uniform vec3 u_eye; +uniform mat4 u_normalMatrix; +uniform mat4 u_projMatrix; +uniform mat4 u_worldMatrix; + +varying vec2 v_uv; + +void main(void) +{ + gl_Position = u_projMatrix * u_mvMatrix * vec4(vert,1.0) ; + v_uv = texcoord; +} \ No newline at end of file diff --git a/assets/shaders/radialBlur.frag.glsl b/assets/shaders/radialBlur.frag.glsl new file mode 100644 index 00000000..673d082a --- /dev/null +++ b/assets/shaders/radialBlur.frag.glsl @@ -0,0 +1,47 @@ + +precision highp float; + +uniform vec2 u_resolution; +uniform float u_time; +uniform vec4 color; +uniform sampler2D u_tex0; + +vec3 deform( in vec2 p ) +{ + vec2 uv; + + //float time = color.x; + float time = u_time; + vec2 q = vec2( sin(1.1*time+p.x),sin(1.2*time+p.y) ); + + float a = atan(q.y,q.x); + float r = sqrt(dot(q,q)); + + uv.x = sin(0.0+1.0*time)+p.x*sqrt(r*r+1.0); + uv.y = sin(0.6+1.1*time)+p.y*sqrt(r*r+1.0); + + return texture2D(u_tex0,uv*.5).xyz; +} + +void main(void) +{ + vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; + //vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / vec2(500,500).xy; + vec2 s = p; + + vec3 total = vec3(0.0); + vec2 d = (vec2(0.0,0.0)-p)/40.0; + float w = 1.0; + for( int i=0; i<40; i++ ) + { + vec3 res = deform(s); + res = smoothstep(0.1,1.0,res*res); + total += w*res; + w *= .99; + s += d; + } + total /= 40.0; + float r = 1.5/(1.0+dot(p,p)); + + gl_FragColor = vec4( total*r,1.0); +} \ No newline at end of file -- cgit v1.2.3