aboutsummaryrefslogtreecommitdiff
path: root/assets/shaders
diff options
context:
space:
mode:
authorValerio Virgillito2012-07-12 15:42:58 -0700
committerValerio Virgillito2012-07-12 15:42:58 -0700
commit2880e1d55a374d48cf39ee074a7a812cd57e1092 (patch)
treeb1f12bce35d5281a3a3d47e3cdcbd75d4c498810 /assets/shaders
parent688e22dc367f37d4b8734a37daa3b823ea450295 (diff)
parent325cf1dcbd7fc1e1ec6a9ac4829954f7e0ae2afb (diff)
downloadninja-2880e1d55a374d48cf39ee074a7a812cd57e1092.tar.gz
Merge pull request #389 from ericmueller/GridFixes
Grid fixes
Diffstat (limited to 'assets/shaders')
-rw-r--r--assets/shaders/radialBlur.frag.glsl75
1 files changed, 75 insertions, 0 deletions
diff --git a/assets/shaders/radialBlur.frag.glsl b/assets/shaders/radialBlur.frag.glsl
new file mode 100644
index 00000000..953e6f07
--- /dev/null
+++ b/assets/shaders/radialBlur.frag.glsl
@@ -0,0 +1,75 @@
1
2/* <copyright>
3Copyright (c) 2012, Motorola Mobility LLC.
4All Rights Reserved.
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met:
8
9* Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
11
12* Redistributions in binary form must reproduce the above copyright notice,
13 this list of conditions and the following disclaimer in the documentation
14 and/or other materials provided with the distribution.
15
16* Neither the name of Motorola Mobility LLC nor the names of its
17 contributors may be used to endorse or promote products derived from this
18 software without specific prior written permission.
19
20THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30POSSIBILITY OF SUCH DAMAGE.
31</copyright> */
32
33#ifdef GL_ES
34precision highp float;
35#endif
36
37uniform vec2 u_resolution;
38uniform float u_time;
39uniform float u_speed;
40uniform sampler2D u_tex0;
41
42
43void main(void)
44{
45 vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy;
46 vec2 s = p;
47
48 float time = u_time * u_speed;
49 float c1 = 1.1*time, c2 = 1.2*time, c3 = 0.6+1.1*time;
50 float sc3 = sin(c3), st = sin(time);
51
52 const float iterCount = 40.0;
53 const int iIterCount = int( iterCount );
54
55 vec3 sum = vec3(0.0);
56 vec2 delta = -p/iterCount;
57 vec2 uv;
58 for( int i=0; i<iIterCount; i++ )
59 {
60 vec2 q = vec2( sin(c1 + s.x), sin(c2 + s.y) );
61 float a = atan(q.y,q.x);
62 float rsq = abs(dot(q,q)) + 1.0;
63 uv.x = st + s.x*rsq;
64 uv.y = sc3 + s.y*rsq;
65 vec3 res = texture2D(u_tex0, uv*.5).xyz;
66
67 res = smoothstep(0.1,1.0,res*res);
68 sum += res;
69 s += delta;
70 }
71 sum /= iterCount;
72 float r = 1.5/(1.0+dot(p,p));
73
74 gl_FragColor = vec4( sum*r, 1.0);
75} \ No newline at end of file