diff options
author | hwc487 | 2012-02-02 11:57:58 -0800 |
---|---|---|
committer | hwc487 | 2012-02-02 11:57:58 -0800 |
commit | 6321075d93044c6747682a8e7280b5996da7ec52 (patch) | |
tree | 2d484c78d66df96e1315ee0047d3ef5305b9f7f7 | |
parent | 4222db97e353fb65fab787ba5927d16d9fa4e1f7 (diff) | |
download | ninja-6321075d93044c6747682a8e7280b5996da7ec52.tar.gz |
added some additional shaders
-rw-r--r-- | assets/shaders/Deform.frag.glsl | 29 | ||||
-rw-r--r-- | assets/shaders/Fly.frag.glsl | 23 | ||||
-rw-r--r-- | assets/shaders/ReliefTunnel.frag.glsl | 35 | ||||
-rw-r--r-- | assets/shaders/SquareTunnel.frag.glsl | 21 | ||||
-rw-r--r-- | assets/shaders/Star.frag.glsl | 28 | ||||
-rw-r--r-- | assets/shaders/Water.frag.glsl | 55 | ||||
-rw-r--r-- | assets/shaders/ZInvert.frag.glsl | 23 | ||||
-rw-r--r-- | js/helper-classes/RDGE/Materials/DeformMaterial.js | 133 | ||||
-rw-r--r-- | js/helper-classes/RDGE/Materials/FlyMaterial.js | 133 | ||||
-rw-r--r-- | js/helper-classes/RDGE/Materials/ReliefTunnelMaterial.js | 133 | ||||
-rw-r--r-- | js/helper-classes/RDGE/Materials/SquareTunnelMaterial.js | 133 | ||||
-rw-r--r-- | js/helper-classes/RDGE/Materials/StarMaterial.js | 133 | ||||
-rw-r--r-- | js/helper-classes/RDGE/Materials/WaterMaterial.js | 133 | ||||
-rw-r--r-- | js/helper-classes/RDGE/Materials/ZInvertMaterial.js | 133 | ||||
-rw-r--r-- | js/helper-classes/RDGE/MaterialsLibrary.js | 21 | ||||
-rw-r--r-- | js/panels/Materials/Materials.xml | 7 | ||||
-rw-r--r-- | js/panels/Materials/materials-popup.reel/materials-popup.js | 7 | ||||
-rwxr-xr-x | js/preloader/Preloader.js | 7 |
18 files changed, 1187 insertions, 0 deletions
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 @@ | |||
1 | #ifdef GL_ES | ||
2 | precision highp float; | ||
3 | #endif | ||
4 | |||
5 | uniform float u_time; | ||
6 | uniform vec2 u_resolution; | ||
7 | //uniform vec4 mouse; | ||
8 | uniform sampler2D u_tex0; | ||
9 | |||
10 | void main(void) | ||
11 | { | ||
12 | vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; | ||
13 | //vec2 m = -1.0 + 2.0 * mouse.xy / u_resolution.xy; | ||
14 | vec2 m = vec2(-.8, .8); | ||
15 | |||
16 | float a1 = atan(p.y-m.y,p.x-m.x); | ||
17 | float r1 = sqrt(dot(p-m,p-m)); | ||
18 | float a2 = atan(p.y+m.y,p.x+m.x); | ||
19 | float r2 = sqrt(dot(p+m,p+m)); | ||
20 | |||
21 | vec2 uv; | ||
22 | uv.x = 0.2*u_time + (r1-r2)*0.25; | ||
23 | uv.y = sin(2.0*(a1-a2)); | ||
24 | |||
25 | float w = r1*r2*0.8; | ||
26 | vec3 col = texture2D(u_tex0,uv).xyz; | ||
27 | |||
28 | gl_FragColor = vec4(col/(.1+w),1.0); | ||
29 | } \ 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 @@ | |||
1 | #ifdef GL_ES | ||
2 | precision highp float; | ||
3 | #endif | ||
4 | |||
5 | uniform vec2 u_resolution; | ||
6 | uniform float u_time; | ||
7 | uniform sampler2D u_tex0; | ||
8 | |||
9 | void main(void) | ||
10 | { | ||
11 | vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; | ||
12 | vec2 uv; | ||
13 | |||
14 | float an = u_time*.25; | ||
15 | |||
16 | float x = p.x*cos(an)-p.y*sin(an); | ||
17 | float y = p.x*sin(an)+p.y*cos(an); | ||
18 | |||
19 | uv.x = .25*x/abs(y); | ||
20 | uv.y = .20*u_time + .25/abs(y); | ||
21 | |||
22 | gl_FragColor = vec4(texture2D(u_tex0,uv).xyz * y*y, 1.0); | ||
23 | } | ||
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 @@ | |||
1 | #ifdef GL_ES | ||
2 | precision highp float; | ||
3 | #endif | ||
4 | |||
5 | uniform vec2 u_resolution; | ||
6 | uniform float u_time; | ||
7 | uniform sampler2D u_tex0; | ||
8 | |||
9 | void main(void) | ||
10 | { | ||
11 | vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; | ||
12 | vec2 uv; | ||
13 | |||
14 | float r = sqrt( dot(p,p) ); | ||
15 | float a = atan(p.y,p.x) + 0.5*sin(0.5*r-0.5*u_time); | ||
16 | |||
17 | float s = 0.5 + 0.5*cos(7.0*a); | ||
18 | s = smoothstep(0.0,1.0,s); | ||
19 | s = smoothstep(0.0,1.0,s); | ||
20 | s = smoothstep(0.0,1.0,s); | ||
21 | s = smoothstep(0.0,1.0,s); | ||
22 | |||
23 | uv.x = u_time + 1.0/( r + .2*s); | ||
24 | uv.y = 3.0*a/3.1416; | ||
25 | |||
26 | float w = (0.5 + 0.5*s)*r*r; | ||
27 | |||
28 | vec3 col = texture2D(u_tex0,uv).xyz; | ||
29 | |||
30 | float ao = 0.5 + 0.5*cos(7.0*a); | ||
31 | ao = smoothstep(0.0,0.4,ao)-smoothstep(0.4,0.7,ao); | ||
32 | ao = 1.0-0.5*ao*r; | ||
33 | |||
34 | gl_FragColor = vec4(col*w*ao,1.0); | ||
35 | } | ||
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 @@ | |||
1 | #ifdef GL_ES | ||
2 | precision highp float; | ||
3 | #endif | ||
4 | |||
5 | uniform vec2 u_resolution; | ||
6 | uniform float u_time; | ||
7 | uniform sampler2D u_tex0; | ||
8 | |||
9 | void main(void) | ||
10 | { | ||
11 | vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; | ||
12 | vec2 uv; | ||
13 | |||
14 | float r = pow( pow(p.x*p.x,16.0) + pow(p.y*p.y,16.0), 1.0/32.0 ); | ||
15 | uv.x = .5*u_time + 0.5/r; | ||
16 | uv.y = 1.0*atan(p.y,p.x)/3.1416; | ||
17 | |||
18 | vec3 col = texture2D(u_tex0,uv).xyz; | ||
19 | |||
20 | gl_FragColor = vec4(col*r*r*r,1.0); | ||
21 | } | ||
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 @@ | |||
1 | #ifdef GL_ES | ||
2 | precision highp float; | ||
3 | #endif | ||
4 | |||
5 | uniform float u_time; | ||
6 | uniform vec2 u_resolution; | ||
7 | uniform sampler2D u_tex0; | ||
8 | |||
9 | void main(void) | ||
10 | { | ||
11 | vec2 uv; | ||
12 | |||
13 | vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; | ||
14 | float a = atan(p.y,p.x); | ||
15 | float r = sqrt(dot(p,p)); | ||
16 | float s = r * (1.0+0.8*cos(u_time*1.0)); | ||
17 | |||
18 | uv.x = .02*p.y+.03*cos(-u_time+a*3.0)/s; | ||
19 | uv.y = .1*u_time +.02*p.x+.03*sin(-u_time+a*3.0)/s; | ||
20 | |||
21 | float w = .9 + pow(max(1.5-r,0.0),4.0); | ||
22 | |||
23 | w*=0.6+0.4*cos(u_time+3.0*a); | ||
24 | |||
25 | vec3 col = texture2D(u_tex0,uv).xyz; | ||
26 | |||
27 | gl_FragColor = vec4(col*w,1.0); | ||
28 | } \ 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 @@ | |||
1 | #ifdef GL_ES | ||
2 | precision highp float; | ||
3 | #endif | ||
4 | |||
5 | uniform sampler2D u_tex0; | ||
6 | uniform float u_time; | ||
7 | uniform vec2 u_resolution; | ||
8 | |||
9 | const float speedx = 1./ 0.1; | ||
10 | const float speedy = 1./ .01; | ||
11 | const float speedr = 1./ 0.01; | ||
12 | const float delta = 20.; | ||
13 | const float intence = 10.; | ||
14 | const int dif = 7; | ||
15 | |||
16 | float col(vec2 coord) | ||
17 | { | ||
18 | float delta_theta = 3.1415926535897932 / float(dif); | ||
19 | float col = 0.; | ||
20 | float theta = 0.; | ||
21 | theta = u_time/200.; | ||
22 | |||
23 | coord.x += u_time/speedx; | ||
24 | coord.y += u_time/speedy; | ||
25 | for (int i = 0; i < dif; i++) | ||
26 | { | ||
27 | coord.x += u_time/speedr; | ||
28 | theta = theta + delta_theta; | ||
29 | col = col + cos( (coord.x*cos(theta) - coord.y*sin(theta))*20. ); | ||
30 | } | ||
31 | |||
32 | return cos(col); | ||
33 | } | ||
34 | |||
35 | void main(void) | ||
36 | { | ||
37 | vec2 p = (gl_FragCoord.xy) / u_resolution.xy; | ||
38 | |||
39 | vec2 c1 = p; | ||
40 | vec2 c2 = p; | ||
41 | |||
42 | c2.x = c2.x+u_resolution.x/delta; | ||
43 | float dx = (col(c1)-col(c2))/delta; | ||
44 | |||
45 | c2 = p; | ||
46 | c2.y = c2.y + u_resolution.y/delta; | ||
47 | float dy = (col(c1)-col(c2))/delta; | ||
48 | |||
49 | c1.x = c1.x+dx; | ||
50 | c1.y = -(c1.y+dy); | ||
51 | |||
52 | float alpha = 1.+dot(dx,dy)*intence; | ||
53 | if (alpha < 0.7) alpha = 0.7; | ||
54 | gl_FragColor = texture2D(u_tex0,c1)*(alpha); | ||
55 | } | ||
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 @@ | |||
1 | #ifdef GL_ES | ||
2 | precision highp float; | ||
3 | #endif | ||
4 | |||
5 | uniform vec2 u_resolution; | ||
6 | uniform float u_time; | ||
7 | uniform sampler2D u_tex0; | ||
8 | |||
9 | void main(void) | ||
10 | { | ||
11 | vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy; | ||
12 | vec2 uv; | ||
13 | |||
14 | float a = atan(p.y,p.x); | ||