aboutsummaryrefslogtreecommitdiff
path: root/assets/shaders/Mandel.frag.glsl
diff options
context:
space:
mode:
authorValerio Virgillito2012-02-23 00:34:37 -0800
committerValerio Virgillito2012-02-23 00:34:37 -0800
commit3675cac3993430490d9eef18157314d53ffa1a6a (patch)
treefb225a6d8fc3c983c96b1507483d628909dc8c1e /assets/shaders/Mandel.frag.glsl
parent2afef244a3f8124f8a049e504e9782c05904ce23 (diff)
parent3730bbc7cc5d5f07b3d788885475a8f9810b480e (diff)
downloadninja-3675cac3993430490d9eef18157314d53ffa1a6a.tar.gz
Merge pull request #60 from mqg734/WebGLMaterials
Integrating WebGL and canvas-2d drawing fixes. Fixed Materials Editor Popup to work with latest Montage framework. Also adding back WebGL materials.
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