aboutsummaryrefslogtreecommitdiff
path: root/assets/shaders/Mandel.frag.glsl
diff options
context:
space:
mode:
authorAnanya Sen2012-02-23 13:52:32 -0800
committerAnanya Sen2012-02-23 13:52:32 -0800
commitec3d07c2fea4e79c68606234074f43d694982e5b (patch)
treedc7c830c361d35c04a4d9b6d55c6c36d7a5d61cd /assets/shaders/Mandel.frag.glsl
parent7283884c39df537694b21419a3ea9e3ca7793b4b (diff)
parent287a0bad5b774a380ec6c8b3ddf24dc03234e248 (diff)
downloadninja-ec3d07c2fea4e79c68606234074f43d694982e5b.tar.gz
Merge branch 'refs/heads/FileIO-jose' into FileIO
Conflicts: js/document/html-document.js js/helper-classes/3D/snap-manager.js Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'assets/shaders/Mandel.frag.glsl')
-rw-r--r--assets/shaders/Mandel.frag.glsl55
1 files changed, 55 insertions, 0 deletions
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 @@
1#ifdef GL_ES
2precision highp float;
3#endif
4
5uniform vec2 u_resolution;
6uniform float u_time;
7
8void main(void)
9{
10 vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy;
11 p.x *= u_resolution.x/u_resolution.y;
12
13 float zoo = .62+.38*sin(.1*u_time);
14 float coa = cos( 0.1*(1.0-zoo)*u_time );
15 float sia = sin( 0.1*(1.0-zoo)*u_time );
16 zoo = pow( zoo,8.0);
17 vec2 xy = vec2( p.x*coa-p.y*sia, p.x*sia+p.y*coa);
18 vec2 cc = vec2(-.745,.186) + xy*zoo;
19
20 vec2 z = vec2(0.0);
21 vec2 z2 = z*z;
22 float m2;
23 float co = 0.0;
24
25
26 // chrome/angelproject/nvidia/glslES don't seem to like to "break" a loop...
27 // so we have to rewrite it in another way
28/*
29 for( int i=0; i<256; i++ )
30 {
31 z = cc + vec2( z.x*z.x - z.y*z.y, 2.0*z.x*z.y );
32 m2 = dot(z,z);
33 if( m2>1024.0 ) break;
34 co += 1.0;
35 }
36*/
37
38 for( int i=0; i<256; i++ )
39 {
40 if( m2<1024.0 )
41 {
42 z = cc + vec2( z.x*z.x - z.y*z.y, 2.0*z.x*z.y );
43 m2 = dot(z,z);
44 co += 1.0;
45 }
46 }
47
48 co = co + 1.0 - log2(.5*log2(m2));
49
50 co = sqrt(co/256.0);
51 gl_FragColor = vec4( .5+.5*cos(6.2831*co+0.0),
52 .5+.5*cos(6.2831*co+0.4),
53 .5+.5*cos(6.2831*co+0.7),
54 1.0 );
55} \ No newline at end of file